Jump to content
  • Advertisement
Sign in to follow this  
Paul C Skertich

Issue with Cubemap Shader Resource View Mismatch

This topic is 1086 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

I've been getting this debug info error in the output window of VS 2013.

D3D11 ERROR: ID3D11DeviceContext::DrawIndexed: The Shader Resource View dimension declared in the shader code (TEXTURE2D) does not match the view type bound to slot 1 of the Pixel Shader unit (TEXTURECUBE).  This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching). [ EXECUTION ERROR #354: DEVICE_DRAW_VIEW_DIMENSION_MISMATCH]

The cubemap is created at 256 x 256. I have diffuse, normal, specular, parallax  bound to slot 0 and if there is a reflection map (Cube map) then i have it bounded to slot 1.

 

Mesh draw call:

ID3D11ShaderResourceView *textures[3] = { diffusemap.getShaderResourceView(), normalMap.getShaderResourceView(), displacementMap.getShaderResourceView() };
	canvas->getDeviceContext()->PSSetShaderResources(0, 3, textures);

	additionalSRV = reflectionMap.getShaderResourceView();
	if (additionalSRV)
		canvas->getDeviceContext()->PSSetShaderResources(1, 1, &additionalSRV);

Why would the debug info give me this error?

Share this post


Link to post
Share on other sites
Advertisement

Declaring it as TextureCube

 

basicshader.hlsl

SamplerState ss : register(s0);
Texture2D textures[3] : register(t0);
TextureCube envmapTexture;

But I think you're right about something actually - because if the reflection map doesn't exist it's still calling upon envmaptexture.sample to something that's not there. Hold on I'll give you an update - gotta update material and mesh calls - then I'll get back to you on this issue. There needs to be a check to see if there's a relfectionmap enabled in the material constant buffer. I'll get back to you one second.

Share this post


Link to post
Share on other sites

Look closely:

canvas->getDeviceContext()->PSSetShaderResources(0, 3, textures);
canvas->getDeviceContext()->PSSetShaderResources(1, 1, &additionalSRV);

Share this post


Link to post
Share on other sites

Basically you bind diffuse to slot 0, normal to slot 1, displacement to slot 2, then reflection to slot 1 again.

Share this post


Link to post
Share on other sites

ah now I see what is going on. That has always tripped me up badly! So it should more look like this:

canvas->getDeviceContext()->PSSetShaderResrouces(0,3,textures);
canvas->getDeviceContext()->PSSetShaderResrouces(4,1,&additionalSRV);
Edited by SIC Games

Share this post


Link to post
Share on other sites

No more of those errrors any more! That was tripping me up  horribly! This is good because next time someone has a similar issue they can always check this topic out and learn how to correct it.

Share this post


Link to post
Share on other sites

canvas->getDeviceContext()->PSSetShaderResrouces(0,3,textures);
canvas->getDeviceContext()->PSSetShaderResrouces(3,1,&additionalSRV);



L. Spiro

Edited by L. Spiro

Share this post


Link to post
Share on other sites

For what it's worth...

 

Texture2D textures[3] : register(t0);

 

Your original code would have worked if you'd declared this as:

 

Texture2DArray textures : register(t0);

 

And then called CreateTexture2D with ArraySize 3, and with the proviso that each of your diffuse, normal, specular, and parallax layers should be the same size.

 

I guess that this kind of usage was what you actually originally intended; unfortunately the terminology used here (i.e use of the word "array") can sometimes be a litle misleading.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!