Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Image size limitation?  (Read 2061 times)

0 Members and 1 Guest are viewing this topic.

foxcode

  • Newbie
  • *
  • Posts: 4
    • View Profile
sf::Image size limitation?
« on: February 28, 2014, 02:20:01 pm »
Hello everyone, I feel bad to be posting another question but I am so close...

I have made a program to create the mandelbrot fractal using a shader. The program works fine unless you increase the resolution to around 10k by 10k. At this point The program crashed. I thought maybe the resolution was too high for the gpu, so I altered my program to make 4 textures, and stitch them all together in the image save function, alas I am getting similar problems.

this is the code that is crashing:

sf::Image master;
  try
  {
    master.create(m_width, m_height);
  }

  catch (bad_alloc& ba)
  {
    cerr << "bad_alloc caught: " << ba.what() << endl;
  }

  sf::Vector2u test = master.getSize();

  master.copy(one,0,0,rect,true);

no bad allocation is being thrown, the program crashes at master.copy but only the high resolutions
cause a crash.

I have 16GB of ram and a Radeon 7950HD so I really doubt it is a memory limitation. Could this maybe be a 32 bit issue or is there some sfml limitation I do not know about.

When debugging the error produced is:
Debug assertion failed. C++ vector subscript out of range.
This was at a resolution of 15360x8640

Thanks

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11029
    • View Profile
    • development blog
    • Email
Re: sf::Image size limitation?
« Reply #1 on: February 28, 2014, 02:32:51 pm »
With a 10k by 10k image you'd be allocating around 380 MiB of memory. Not sure how easy it is to allocate 380 MIB of continuous memory.

What if you put the try/catch clause around the copy function?

What happens if you run this:

std::vecotr<sf::Uint8> pixels;
pixels.reserve(10000*10000*4);

And also important, what compiler and OS are you using? ;)
« Last Edit: February 28, 2014, 03:02:45 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Image size limitation?
« Reply #2 on: February 28, 2014, 02:46:28 pm »
sf::Image is nothing more than what eXpl0it3r shows: an array of 8-bit integers in RAM. The graphics card is not involved here.
Laurent Gomila - SFML developer

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: sf::Image size limitation?
« Reply #3 on: February 28, 2014, 03:03:12 pm »
Quote
Debug assertion failed. C++ vector subscript out of range.

It seems as if memory is not the issue, but rather that you are accessing elements that are outside the array size. Remember subscripts are 0 based, so a valid range is from 0 to size - 1  ;)
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

foxcode

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: sf::Image size limitation?
« Reply #4 on: February 28, 2014, 04:59:48 pm »
Thanks for the help guys. I ended up download the 64bit libraries and compiling for that just to see if it would work, what do you know it fixed it. Turns out when calling copy I was going over the 2GB limit. Thanks for the help.