Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualGuardianX

Posted 12 April 2013 - 10:47 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?

#1GuardianX

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. E.g. if an object uses different from previous drawn primitive diffuse color map, I call PSSetShaderResources(2, 1 , resources). `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 keeps those textures bound to pipeline until I free them? Or does they actually change if I call PSSetShader() or change render target?

PARTNERS