Skip to content
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

Binding programs without drawing anything can result in inconsistent uniform state #39

Open
truecolour opened this issue Sep 13, 2017 · 2 comments
Labels
drawing-nothing User sets up drawing state, then proceeds to draw nothing at all.

Comments

@truecolour
Copy link

  1. Bind a program with a geometry shader.
  2. Set the first uniform in the geometry shader to value A.
  3. Without rendering anything, bind a different program without a geometry shader.
  4. Set the first uniform in the vertex shader to value B.
  5. Render something. The results will use value A.

Adding a C3D_UpdateUniforms(GPU_GEOMETRY_SHADER) between steps 2 and 3 fixes the problem.

If I understand the internals correctly, the problem is that the C3D_{FV,IV,Bool}UnifDirty flags don't get cleared when binding a new program.

@fincs
Copy link
Member

fincs commented Sep 13, 2017

Without rendering anything

That is the problem. Why are you binding a program, then afterwards binding another one without having rendered anything in the first place? Can't you avoid binding the first program since it's not used for rendering?

@fincs fincs changed the title Setting a uniform in a geometry shader can overwrite vertex shader uniforms in later programs Binding programs without drawing anything can result in inconsistent uniform state Sep 13, 2017
@truecolour
Copy link
Author

Context: I'm adding particle effects to a game I'm working on. The rendering code configures the shading, etc., binds the program, then loops through all particle sources, sets up buffers and calls DrawArrays. Regular objects get drawn afterwards. If there aren't any particle sources, the graphics get glitchy.

So yes, I can easily avoid binding the program at all. But this is really confusing behaviour. If this is intentional, IMO it should be documented somewhere.

@fincs fincs added the drawing-nothing User sets up drawing state, then proceeds to draw nothing at all. label Sep 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
drawing-nothing User sets up drawing state, then proceeds to draw nothing at all.
Projects
None yet
Development

No branches or pull requests

2 participants