-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing shadow map crash on Linux. [do not merge] #7426
Conversation
@gero3 btw I am pretty sure that PRs do not always update. For example this one, I changed the light color to blue in this example and while I see it locally, getting it from the CI machine, the light is still white: http://ci.threejs.org/api/pullrequests/7426/examples/webgl_animation_skinning_morph.html |
What construct is illegal exactly? I have had a hard time figuring out Best regards,
|
Indexing an array of samplers with a loop index, most surprisingly. GLSL ES 3, 12.30 reads
That obviously excludes the index variable (even) of (finite & simple) loops. |
It should be possible to fix this bug as I've looked through the shadow map code in the basic/simple case and it seems to be nearly identical in structure to lighting. The only difference is some of the shadowMap uniforms are conditionally read based on whether or not a shadowMap test passes. I wonder if we decide to always read those uniforms before the test, it will not cause this error? Less efficient yes, but if it works on more platforms, I'm all for it. I've made that change in this PR but I haven't yet tested it on Intel drivers on Linux. But if anyone wants to the fix is live here: http://ci.threejs.org/api/pullrequests/7426/examples/webgl_animation_skinning_morph.html |
We may be using different versions or code paths because of different hardware of that driver. That example was never crashing on mine and I still get the warning (it might just be a coincidence). However, looking at the problematic ones that were crashing after running OK for a few frames before (e.g. skin / bumpmap), it seems you really did it. No crash! 👍 |
It didn't fix it on our Intel GPUs 4600/4000 unfortunately. It appears that the line in question is this one: And basically on Mesa you can not access an element of an array of samplers inside of a loop using the index. I wonder if that restriction applies to accessing a sampler in an array of structures. I will investigate this because the sampler would no longer be an array, rather it would be the structures that are the array construct. Having shadow maps use structures is a good thing anyhow. Alternatively, one could write a macro that can manually unroll loops. |
@tschw Maybe the driver is fixed in newer versions? That would be amazing. What version of the driver you are using? What is the Intel CPU model number (so I can figure out the GPU version)? What OS are you using? We are using Ubuntu 14 and 15 and we have Intel Core i7 3770 and Intel Core i7 4970 CPUs. We are using the default Intel GPU drivers included in Ubuntu. |
This has come up before: #5232 (comment) |
I wonder if it possible to use macros in a tricky way to unroll loops for us. Something like:
You'd have to put everything into a struct to pass into the function, or have multiple different versions for different number of parameters (does WebGL's preprocessor support variable number of macro parameters?) I'm making up the above, but I think something like that could technically work, even though it is super messy. |
Or we can write our own preprocess that can unroll loops. I think if we use a Macro-like interface, it shouldn't be that hard. Probably half a day's work. |
With the preprocessor, I'd do it like this: #define REPEAT0() // zero repetitions means empty
#define REPEAT1() repetitive_code(0)
#define REPEAT2() REPEAT1() repetitive_code(1)
#define REPEAT3() REPEAT2() repetitive_code(2)
#define REPEAT4() REPEAT3() repetitive_code(3)
#define REPEAT5() REPEAT4() repetitive_code(4)
#define REPEAT6() REPEAT5() repetitive_code(5)
#define REPEAT7() REPEAT6() repetitive_code(6)
#define REPEAT8() REPEAT7() repetitive_code(7)
// ...
// ---------------- Test starts here:
#define N_LIGHTS REPEAT4 // passed in via .defines
#define repetitive_code( index ) evaluate_light( foo, bar, baz, index );
N_LIGHTS()
#undef repetitive_code Note: No need for args - can curry. No need for explosion, can chain. |
|
Sweet! |
There is this error:
It occurs on Linux machines. Intel driver at least.
It occurs if shadow maps are enabled.
It should be solvable because the access patterns are similar between lights and shadow maps.