Unroll

Started by
11 comments, last by Tommato 7 years, 6 months ago

Hi All

After several days of debugging

// It does NOT work, crash in glDrawElements
#define MAX_TEXTURES 8
..
for (int i = 0; i < MAX_TEXTURES; ++i) {
...
}

// All is ok
uniform int textureCount;
...
for (int i = 0; i < textureCount; ++i) {
...
}

I guess it's unroll problem (correct me if not). I use old ATI card intentionally as "minimal" because users can have any. So should I avoid unroll anywhere just because "there are some cards where it won't work"? What are better solutions for this?

Thank you

Advertisement
I would try to isolate what is crashing the program. What happens if you put a constant 8 in place of MAX_TEXTURES and leave out the define. What happens if you unroll the loop manually? This could help you isolate the source of the crash.
My current game project Platform RPG

How old is that ATI card?

If it's too old you'll run into two problems:

  • Radeon HD 2000-4000: OpenGL propietary drivers are no longer updated. They're known for being a bit buggy now.
  • Pre-Radeon HD 2000 (i.e. ATI Radeon X1000 series): These cards are so bad it drove us crazy back in the day. Unrolling your loop 8 times could be hitting the limit of 256 instruction slots these cards had.
Are there any errors that occur but currently aren't detected in the lead up to thecrash in glDrawElements, such as during shader linking?

You can try running the code below just after the suspecious OpenGL call was made for visualizing the error code.


void CheckGLError()
{
	GLenum code = glGetError();
	if (code != GL_NO_ERROR)
	{
		fprintf(stderr, "OpenGL error = %d\n", code );
		assert(false);
	}
}

This could help you isolate the source of the crash.
I've played several days with this. Activating/deactivating of absolute different (not related) pieces of code produces misc effects like "fantastic" drawing or crash deeply in glDrawElements. Only if I avoid unroll all works as it should

Are there any errors that occur but currently aren't detected in the lead up to thecrash in glDrawElements, such as during shader linking?
No any errors/warnings given, glGetError also returns 0

Radeon HD 2000-4000: OpenGL propietary drivers are no longer updated. They're known for being a bit buggy now. Pre-Radeon HD 2000 (i.e. ATI Radeon X1000 series): These cards are so bad it drove us crazy back in the day. Unrolling your loop 8 times could be hitting the limit of 256 instruction slots these cards had.

ATI Radeon HD 2600 XT 256 MB
OpenGL Version: 2.1 ATI-7.32.12

Wait, this is a Mac on OS X?

The OS X OpenGL drivers are generally bad. Bugs like these are common. Does the problem go away if MAX_TEXTURES has other values (try 1, 2, 4...)

Wait, this is a Mac on OS X?
Yes

The OS X OpenGL drivers are generally bad. Bugs like these are common. Does the problem go away if MAX_TEXTURES has other values (try 1, 2, 4...)
Nope, crashes with any texture count, even with 1 (single)

Then it's quite certain this is a driver bug. Knowing Apple's track record of not caring for OpenGL, I doubt this will get fixed. You'll have to find a workaround.

BS like this is the reason I wrote my own parser so I could unroll loops myself.

What version of macOS are you using? Updates tend to contain graphics driver updates (including bug fixes).

This topic is closed to new replies.

Advertisement