Jump to content

  • Log In with Google      Sign In   
  • Create Account


Question about binding textures to the Pipeline


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 jdub   Members   -  Reputation: 419

Like
0Likes
Like

Posted 06 February 2013 - 01:54 PM

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, 06 February 2013 - 01:55 PM.

J.W.

Sponsor:

#2 Nik02   Crossbones+   -  Reputation: 2738

Like
0Likes
Like

Posted 06 February 2013 - 02:39 PM

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).


Niko Suni


#3 jdub   Members   -  Reputation: 419

Like
0Likes
Like

Posted 06 February 2013 - 02:52 PM

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


J.W.

#4 MJP   Moderators   -  Reputation: 10623

Like
0Likes
Like

Posted 06 February 2013 - 03:19 PM

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.



#5 Jason Z   Crossbones+   -  Reputation: 4859

Like
0Likes
Like

Posted 06 February 2013 - 09:09 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS