Jump to content
  • Advertisement
Sign in to follow this  
jdub

Question about binding textures to the Pipeline

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

Is it a good idea to bind all textures to the pipeline during application initialization (given that I don't have a ridiculous amount of textures I'm using)?  Right now, my render code looks something like this (pseudo code):

void Render(void)
{
  ...
  SetTexture(this->get_mesh_texture(0));
  RenderTexture();
  ...
}

void SetTexture(Texture& t)
{
   ShaderResourceView textureView = createTextureView(t);
   this->shader->bindResource(textureView);
}

 

Does it incur a lot of overhead to be creating and binding a resource view every time I render a texture?

Edited by jdub

Share this post


Link to post
Share on other sites
Advertisement

Every time you "create" something, it is potentially expensive. Setting active shader resources, on the other hand, is not particularly expensive (apart from the associated driver call).

Share this post


Link to post
Share on other sites

So given that the texture is already loaded from file and ready to go, creating a resource view for it isn't too expensive?

Share this post


Link to post
Share on other sites

In terms of creating a D3D object, creating a resource view is probably one of the cheaper ones to create. That said, it's almost certainly still going to involve some sort of allocation so you don't want to do it unless you have to. Creating one every time you need to bind a texture is pretty wasteful, you should instead create the SRV whenever you create the texture and just hold onto it.

Share this post


Link to post
Share on other sites

In terms of creating a D3D object, creating a resource view is probably one of the cheaper ones to create. That said, it's almost certainly still going to involve some sort of allocation so you don't want to do it unless you have to. Creating one every time you need to bind a texture is pretty wasteful, you should instead create the SRV whenever you create the texture and just hold onto it.

 

This is good advice - in fact, in my engine I don't separate the two concepts.  A resource is always referenced with its resource views with a single object, making it trivial to keep the existing reference around to the resource view.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!