Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

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: 302

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   Members   -  Reputation: 1994

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
Software developer

#3 jdub   Members   -  Reputation: 302

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: 5463

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   GDNet+   -  Reputation: 2398

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.


Jason Zink :: DirectX MVP
Check out our (now available) D3D11 book: Practical Rendering and Computation with Direct3D 11
Check out my Direct3D 11 engine on CodePlex: Hieroglyph 3
Check out our free online D3D10 book: Programming Vertex, Geometry, and Pixel Shaders
Lunar Rift :: Dual-Paraboloid Mapping Article :: Parallax Occlusion Mapping Article :: Fast Silhouettes Article




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