Anonymous Login
2018-02-23 15:01 CET

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000786OpenClonkEngine - Graphicspublic2017-08-12 21:37
Assigned ToLuchs 
StatusclosedResolutionwon't fix 
PlatformGNU G++OSLinuxOS Version 
Product Version 
Target Version8.0Fixed in Version 
Summary0000786: High-res landscape shader not using correct workaround with gallium r300g driver on linux
DescriptionThe high-res landscape shader is not working when using the gallium r300 driver - with an rv570 or X1950 Pro card. The same shader works on windows using the latest available driver. The gallium driver is the only usable driver with 3d support for that card on Linux.

By "not working" I mean that the landscape is not drawing, its just black.

After some testing with the developers of the driver it seems that defining BROKEN_ARRAYS_WORKAROUND in the shader would solve the problem. There seems to be code that automatically tries workarounds, including this, if compilation fails. The gallium driver though, according to the person I chatted with, does not report compilation errors to the application so the game would not know that the compilation failed.

His/her suggested solution is as follows "They should define that macro based on the maximum number of uniforms reported by the OpenGL implementation."
TagsNo tags attached.
Attached Files
  • log file icon output.log (2,487 bytes) 2012-05-23 10:28
  • png file icon Screenshot003.png (Attachment missing)
  • patch file icon 786-check-uniform-limits-in-engine.patch (1,604 bytes) 2012-05-29 21:07 -
    # HG changeset patch
    # User Nicolas Hake <>
    # Date 1338318323 -7200
    # Node ID e5506fcc1ed666c7376bc21b33a4bb0e40438361
    # Parent  1e18f918992c51696db2abd6d37cb0988d90faf5
    GL: Move uniform count branch out of the shader into the engine
    diff --git a/planet/Graphics.ocg/LandscapeShader.c b/planet/Graphics.ocg/LandscapeShader.c
    --- a/planet/Graphics.ocg/LandscapeShader.c
    +++ b/planet/Graphics.ocg/LandscapeShader.c
    @@ -9,12 +9,6 @@ uniform sampler3D materialTex;
     // Resolution of the landscape texture
     uniform vec2 resolution;
    -// Use sampler if the GPU doesn't support enough uniforms to
    -// get the matMap as an array
     // Texture map
     uniform sampler1D matMapTex;
    diff --git a/src/landscape/C4LandscapeRender.cpp b/src/landscape/C4LandscapeRender.cpp
    --- a/src/landscape/C4LandscapeRender.cpp
    +++ b/src/landscape/C4LandscapeRender.cpp
    @@ -550,9 +550,10 @@ GLhandleARB C4LandscapeRenderGL::CreateS
     	// Get number of available uniforms from driver
     	GLint max_uniforms = 0;
     	glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, &max_uniforms);
    -	Version.AppendFormat("#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS %d\n", max_uniforms);
    -	glGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &max_uniforms);
    -	Version.AppendFormat("#define GL_MAX_VERTEX_UNIFORM_COMPONENTS %d\n", max_uniforms);
    +	if (max_uniforms < 259)
    +	{
    +		Version.Append("#define BROKEN_ARRAYS_WORKAROUND\n");
    +	}
     	// Build code
     	const char *szCodes[C4LR_ShaderWorkaroundCount + 2];
    patch file icon 786-check-uniform-limits-in-engine.patch (1,604 bytes) 2012-05-29 21:07 +
  • log file icon output_new.log (4,479 bytes) 2012-05-30 17:23




Isilkor (developer)

I've added some code that checks for low uniform limits and activates the broken arrays workaround if we're exceeding them. Unfortunately I don't have a r300, but I still think this is fixed in e730362b2d0a (reopen if it isn't, please).


beliar (reporter)

Sadly while the patch looks like it would fix the issue it did not. Now the game reports that the shader failed to link.

If it is indeed correct that the gallium driver, for whatever reason, does not report shader compilation errors (correctly?) then I think the actual problem lies there. I guess if you really want to fix it you need to make a check like that for every workaround. And also a check if the card supports the shader (version) at all. I only know basic graphics/opengl programming so I don't know how that could be done.

Btw.: I am not using an actual r300 card, that's just the name of the driver for a range of graphics card from r300 to r500. I am using an X1950 card (rv570).


Isilkor (developer)

CC'ing Peter on this report because he wrote the shader code originally and might have an idea.


Isilkor (developer)

Can you check whether the attached patch fixes your problem?


beliar (reporter)

Now its back to the same problem as before, shader links but the landscape is black.

I do get a different error from the the shader compiler now. I uploaded a new log. The error now is:

r300 FP: Compiler Error:
Fragment program does not support relative addressing of source operands.
Using a dummy shader instead.


Günther (developer)

Last edited: 2012-05-30 23:48

View 2 revisions

After, the shader failed tp link for me, too. I'm using "Gallium 0.4 on AMD RV730", and apart from a missing texture2DLod the shader worked fine. I pushed to make it work again.


beliar (reporter)

After the latest commit its back again to the start.

I found something curious though. The driver/card reports that it has a limit of 4096 uniforms. Even when, according to this: , it has to be devided by 4 for ati/amd cards it is 4 times too many:


Günther (developer)

So that all sounds so very fragile that I doubt we can get an universal solution by querying hardware capabilities. The "test whether the shader can actually draw something" solution Peter mentioned in IRC sounds more and more like the only trustworthy one. (Well, until a driver decides to misbehave by drawing something horrible, but we can refine the test method once we encounter that.)


Clonkonaut (developer)

Is this still an issue?


beliar (reporter)

I can't say, I updated my computer since then. I think the landscape was being drawn last time I checked, though there were some minor glitches if I remember correctly. Colored pixels around at egdes I think. Can't really check anymore, as I said, though.


Clonkonaut (developer)

Thanks for the feedback! I get it that now OC works fine?

I'll change the priority to low then. If we don't get any new input by other people this might be forgotten / closed in the future.


Luchs (developer)

OC 8.0 requires at least OpenGL 3.1, so there's no hope of supporting this particular GPU anymore.

-Issue History
Date Modified Username Field Change
2012-05-22 17:50 beliar New Issue
2012-05-23 10:28 beliar File Added: output.log
2012-05-23 10:28 beliar File Added: Screenshot003.png
2012-05-28 16:09 Isilkor Note Added: 0002157
2012-05-28 16:09 Isilkor Status new => resolved
2012-05-28 16:09 Isilkor Resolution open => fixed
2012-05-28 16:09 Isilkor Assigned To => Isilkor
2012-05-28 18:10 beliar Note Added: 0002159
2012-05-28 18:10 beliar Status resolved => feedback
2012-05-28 18:10 beliar Resolution fixed => reopened
2012-05-28 21:07 Isilkor Note Added: 0002160
2012-05-29 21:07 Isilkor File Added: 786-check-uniform-limits-in-engine.patch
2012-05-29 21:07 Isilkor Note Added: 0002161
2012-05-29 21:07 Isilkor Resolution reopened => open
2012-05-30 17:23 beliar File Added: output_new.log
2012-05-30 17:24 beliar Note Added: 0002162
2012-05-30 17:24 beliar Status feedback => assigned
2012-05-30 23:47 Günther Note Added: 0002163
2012-05-30 23:48 Günther Note Edited: 0002163 View Revisions
2012-05-31 10:09 beliar Note Added: 0002164
2012-05-31 12:01 Günther Note Added: 0002165
2013-03-27 12:32 Isilkor Assigned To Isilkor =>
2013-03-27 12:32 Isilkor Status assigned => acknowledged
2015-10-16 02:33 Sven2 Target Version => 7.0
2016-01-02 20:46 Clonkonaut Note Added: 0004446
2016-01-02 20:46 Clonkonaut Status acknowledged => feedback
2016-01-02 20:46 Clonkonaut Target Version 7.0 => 8.0
2016-01-03 10:04 beliar Note Added: 0004452
2016-01-03 10:04 beliar Status feedback => new
2016-01-04 15:39 Clonkonaut Note Added: 0004460
2016-01-04 15:39 Clonkonaut Priority normal => low
2016-01-04 15:39 Clonkonaut Status new => acknowledged
2017-08-12 21:37 Luchs Assigned To => Luchs
2017-08-12 21:37 Luchs Status acknowledged => closed
2017-08-12 21:37 Luchs Resolution open => won't fix
2017-08-12 21:37 Luchs Note Added: 0005719
+Issue History