Jump to content
  • Advertisement
Sign in to follow this  
Prune

Can a bindless_sampler be mapped as normal UBO instead of using glProgramUniformHandleui64vARB ?

This topic is 1667 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ARB_bindless_texture specifies functions like glProgramUniformHandleui64vARB to update an array of texture handles. Can one, instead, use a regular uniform buffer object of GLuint64 and map it and write the handles to it, as one would write elements to any other mapped buffer object?

Edited by Prune

Share this post


Link to post
Share on other sites
Advertisement
Yes, that function is just an overload to set uniforms; you can just treat it like a blob of data and push it into a buffer as you suggest.

Share this post


Link to post
Share on other sites

Given that UBOs use a "binding" index instead of "location", do I need to switch "location" to "binding" in my GLSL declaration to use a UBO for texture handles?

layout(location = SAMPLERS, bindless_sampler) uniform sampler2D textures[MAX_TEX];

-->

layout(binding = SAMPLERS, bindless_sampler) uniform sampler2D textures[MAX_TEX];

The reason I'm not sure is because ARB_bindless_texture says:

 

With GLSL 4.20, sampler and image uniforms may be initialized in the shader using

    layout(binding = integer-constant)

as described in section 4.4.4 "Opaque-Uniform Layout Qualifiers". When ARB_bindless_texture is supported, these initial binding values are always taken to mean a texture image or image unit number, not a bindless handle.

If this "binding" refers to an image unit, is it not different than the "binding" index of UBOs?

Edited by Prune

Share this post


Link to post
Share on other sites

The bindless_sampler qualifier is necessary for uniform samplers in the default block only. If you are going to use a UBO, then it would probably look something like this:

layout(binding = SAMPLERS, std140) uniform sampler_buffer
{
    sampler2D textures[MAX_TEX];
};

Binding points for bound textures and UBO/SSBOs are completely separate.

 

Edit: Fix'd

Edited by Chris_F

Share this post


Link to post
Share on other sites

Thanks. I actually feel dumb to have asked that since I was already using block like this for transforms.

 

Just a note that std430 can't be used for UBO as in your example, only SSBO.

Edited by Prune

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!