Jump to content
  • Advertisement
Sign in to follow this  

Get texture infos in the shader, is it bad ?

This topic is 618 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

In different things like for example select the mipmap or the cubemap lookup calcule, you need to have the size and the number of mipmaps.
HLSL for example contains the GetDimensions function, is it bad to use it and better to send the infos in a constant buffer ?

Edited by Alundra

Share this post

Link to post
Share on other sites
I'm not sure about every vendor, but the way that texturing works on AMD is, for each texture in your HLSL code (e.g. Texture2D variable), this basically gets replaced with a cbuffer along the lines of:
struct Texture2D {
void* data;
uint width, height, mips, format;

When you perform a Sample instruction, it has to read the data out of this 'hidden cbuffer' to know where and how to perform the texture sampling.

So, I would assume that querying the texture dimensions would be exactly the same speed as reading a value from a 'normal' cbuffer.

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!