Jump to content

  • Log In with Google      Sign In   
  • Create Account


Binding shader resources


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
2 replies to this topic

#1 GuardianX   Crossbones+   -  Reputation: 1497

Like
0Likes
Like

Posted 12 April 2013 - 10:01 AM

Hello everyone.

 

Recently I have been lurking in DirectX 11 documentation and found interesting thing: PSSetShaderResources function keeps textures bound to graphics pipeline. So I have made up a common header for every shader program which looks like this:

 

// Defines:
// Object color type
#define OBJECT_COLOR_TYPE_COLORED 0
#define OBJECT_COLOR_TYPE_TEXTURED 1
#define USE_NORMAL_MAP 1
#define USE_SHADOW_MAP 1
#define USE_DIFFUSE_MAP 1
#define USE_AMBIENT_MAP 1
#define USE_LIGHT_MAP 1
// Textures:
Texture2D NormalMap : register(t0);
Texture2D ShadowMap : register(t1);
Texture2D DiffuseMap : register(t2);
Texture2D AmbientMap : register(t3);
Texture2D LightMap : register(t4);
// Sampler states:
SamplerState LinearSampler : register(s0);
 

 

Now, I'm trying to update textures per primitive draw call. In example, if the object uses different from previous drawn primitive diffuse color map, I call PSSetShaderResources(2, 1 , resources). Where `resources` is an array, containing single element - shader resource view for new diffuse map texture. But when I have implemented this in my engine, it doesn't render texture maps anymore. All of my shader programs are including this common file.
 
So I'm curious, does DX11 really keep those textures bound to pipeline until I free them? Or do their shader representations actually become undefined if I call PSSetShader() or change render target?

Edited by GuardianX, 12 April 2013 - 10:47 AM.


Sponsor:

#2 MJP   Moderators   -  Reputation: 11034

Like
1Likes
Like

Posted 12 April 2013 - 12:16 PM

Any resources stay bound to the context until you overwrite them, or call ClearState. If I were you, I would use the VS 2012 graphics debugger (or PIX, or Nsight, or AMD GPU PerfStudio) to capture a frame so that you can when and where the textures are getting bound and unbound. This should let you track down where your bug is.



#3 GuardianX   Crossbones+   -  Reputation: 1497

Like
0Likes
Like

Posted 12 April 2013 - 03:33 PM

Any resources stay bound to the context until you overwrite them, or call ClearState. If I were you, I would use the VS 2012 graphics debugger (or PIX, or Nsight, or AMD GPU PerfStudio) to capture a frame so that you can when and where the textures are getting bound and unbound. This should let you track down where your bug is.

 

Thank you for response.

I don't know why, but my VS2012 graphics debugger has very strange behavior - it doesn't debug shader code (may be because I compile them from .fx files at runtime, not from .hlsl by means of fxc.exe?), unable to capture screen when I re-size my window. In my current situation VS2012GD just captures black screens (but my application window actually shows something, it's not completely black) and does not allow me to target those captured black screenshots to look at their statistics gathered... Is it only me, or VS2012 graphics debugger is very, well, bugged? Also, how can I use PIX with Windows 8 SDK DX11 code? I tried, but unfortunately couldn't setup it.


Edited by GuardianX, 12 April 2013 - 04:02 PM.





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