Sign in to follow this  
jdub

Question about binding textures to the Pipeline

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this