Advertisement

Issue with the binding of 2 texture

Started by July 03, 2017 09:17 AM
6 comments, last by unbird 7 years, 5 months ago

Hi,

I've got a issue with the binding of a texture in my Directx11 programme. I have 2 textures that i must pass to the pixel shader, one is a Texture3D and the other is a Texture2D from a render to texture. So i give it to the Pixel Shader like this  specifying the  register index.


deviceContext->PSSetShaderResources(0, 1, &backfaceTexture);
deviceContext->PSSetShaderResources(1, 1, &volumeTexture);

In the pixel shader i declare the 2 textures like this.


Texture2D backFaceTexture : register(t0);
Texture3D volumeTexture : register(t1);

And when i use it, the backface texture is empty an the volume texture contains the backface texture.

But when i use the graphics debugger from Visual Studio i can see that my 2 textures are correctly load in the GPU 

Capture.PNG.bb902a27f7ab6ea772fd74c10d890acb.PNG

If someone have any idea why is not working 

 

Hi Snake996,

looking at the documentation for the call - MSDN it implies that you can pass in the calls in a single array, have you tried passing both in in a single call?

Cheers

Steve

Advertisement

Hi Steve 

I already try to pass in a array but there two different type of textures, one is 3d and the other is 2d. 

So in the shader i can't declare a array of a 3d and 2d textures.

Thank for reply 

What happens if you remove the register code in the shader?

HI Snake,

I'm more thinking about doing the following in your code:

ID3D11ShaderResourceView* srvs [2];
srvs[0] = backFaceTexture.Get();
srvs[1] = volumeTexture.Get();
deviceContext->PSSetShaderResources(0, ARRAYSIZE(srvs), srvs)

Rather than changing any of the shader code. Although doing a quick google search, this link implies that your code and mine are equivalent (was hoping that it would be something like that).

The only other thing I can suggest is having a look at the Rastertek series - Multitexturing. And see if there's anything obvious between that and your code.

Good luck!

Steve

Quote
1 hour ago, Syntac_ said:

What happens if you remove the register code in the shader?

I already try that at the beginning of my issue. 

 

1 hour ago, Steven Ford said:

HI Snake,

I'm more thinking about doing the following in your code:

ID3D11ShaderResourceView* srvs [2];
srvs[0] = backFaceTexture.Get();
srvs[1] = volumeTexture.Get();
deviceContext->PSSetShaderResources(0, ARRAYSIZE(srvs), srvs)

Rather than changing any of the shader code. Although doing a quick google search, this link implies that your code and mine are equivalent (was hoping that it would be something like that).

The only other thing I can suggest is having a look at the Rastertek series - Multitexturing. And see if there's anything obvious between that and your code.

Good luck!

Steve

I have already find this post on stackoverflow ans read the Rastertek tutorial, but it's doesn't help me.

when using Texture Arrays it's necessary to declare a array of textures 2d in the shader.


Texture2D arrayTextures[2];

but i have a Texture3D and Texture2D. 

 

Advertisement

Yeah, that doesn't really work. Keep your shader as is. The problem is likely elsewhere.

The log you show only demonstrates your intention, not necessarily the result. I guess you have a (temporary) read write hazard, which the pipeline forbids and resets. Since one is called backFaceTexture I expect it was a rendertarget at some point. Reset the rendertarget (output merger stage) to null before setting the SRV.

To make sure: turn up the DX debug layer (which immediately reports such things) and/or dig deeper, e.g. with renderdoc and check if the SRV slots are actually set.

Edit: Be warned about that Rastertek article, it's misleading. He confuses texture arrays with, well, arrays of textures. A texture array is one resource (and then one SRV / slot) with several slices similar to a 3D texture. In HLSL this is explicitly written as Texture2DArray . On the other hand Texture2D blah[2] will generate two slots.

This topic is closed to new replies.

Advertisement