glBindTextures will bind by texture unit. No guarantee that layout(binding) is the same as texture unit. In fact, glUniform1i allows you to change the texture unit for the uniform at a given location. https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glBindTextures.xhtml …
-
-
Vastauksena käyttäjälle @tloch14
https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_shading_language_420pack.txt … "The identifier binding specifies which unit will be bound."
1 vastaus 0 uudelleentwiittausta 0 tykkäystä -
Vastauksena käyttäjälle @mikulasflorek
Hmm... I missed that. So next question, how do I introspect the shader to get that value? (ie, in c++ I don't want to hard-code it to 3).
2 vastausta 0 uudelleentwiittausta 0 tykkäystä -
Vastauksena käyttäjille @tloch14 ja @mikulasflorek
see this family of functions https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetProgramResource.xhtml …
1 vastaus 0 uudelleentwiittausta 0 tykkäystä -
Vastauksena käyttäjille @radgeRayden ja @mikulasflorek
I was just looking at it when trying to find something that would get me the same result as glGetUniform1i, except in the glProgramX pattern, like glProgramUniform1i. It's not clear to me how to use the functions to get that value.
1 vastaus 0 uudelleentwiittausta 1 tykkäys -
Vastauksena käyttäjille @tloch14 ja @mikulasflorek
hopefully this will help as I don't 100% understand the problem, but I did a bit of shader reflection in my program and what I do is use glGetProgramInterfaceiv to build a map of uniforms and locations, that I can then use later with my shader object
1 vastaus 0 uudelleentwiittausta 0 tykkäystä -
relevant functions: glGetProgramInterfaceiv, glGetProgramResourceiv, glGetProgramResourceName would share code but it's not C/C++
1 vastaus 0 uudelleentwiittausta 0 tykkäystä -
Vastauksena käyttäjille @radgeRayden ja @mikulasflorek
building a map of name->bindpoints is exactly what I'm doing. Then I can take all the resources used for a particular drawcall, create arrays I can pass to glBindTextures/glBindSamplers/glBindImageTextures, and use those.
1 vastaus 0 uudelleentwiittausta 1 tykkäys -
And then re-use those "bundles" frame over frame. Pay the cost of building them once and reuse.
1 vastaus 0 uudelleentwiittausta 1 tykkäys -
Vastauksena käyttäjille @tloch14 ja @mikulasflorek
yep it works pretty nicely and you can even cheaply address stuff by name if you do it right.
1 vastaus 0 uudelleentwiittausta 0 tykkäystä
Yes! Exactly. I just need to get that binding index. I can call glProgramUniform1i to set it myself, but I'd rather attempt to respect what the shader author wrote in the layout qualifier.
-
-
Vastauksena käyttäjille @tloch14 ja @radgeRayden
Quick googling suggests glGetUniform should work.
1 vastaus 0 uudelleentwiittausta 0 tykkäystä -
Vastauksena käyttäjille @mikulasflorek ja @radgeRayden
Right. I expect glGetUniform1i to work. I was hoping for there to be a glGetProgramUniform1i(program, location).
1 vastaus 0 uudelleentwiittausta 0 tykkäystä - Näytä vastaukset
Uusi keskustelu -
Lataaminen näyttää kestävän hetken.
Twitter saattaa olla ruuhkautunut tai ongelma on muuten hetkellinen. Yritä uudelleen tai käy Twitterin tilasivulla saadaksesi lisätietoja.