Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Question about binding textures to the Pipeline

4: Adsense

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   

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

#2 Nik02   Members   

4297
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   

459
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   

19420
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   Members   

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