Jump to content
  • Advertisement
Snake996

DX11 Issue with the binding of 2 texture

This topic is 383 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 

 

Share this post


Link to post
Share on other sites
Advertisement

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

Share this post


Link to post
Share on other sites

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 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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. 

 

Share this post


Link to post
Share on other sites

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.

Edited by unbird
WTF: I did NOT put those ad links in :(

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!