DX10 - Depth buffer to texture problems.

Started by
2 comments, last by ET3D 14 years, 4 months ago
Hey! i have been working on postprocessing in the latest and have come realy far, but my current problem is Depth of Field, which need me to retrive the depth buffer fron the device, and then make it to a texture! my code dose this but the texture is blank and pix cant display my texture. the dx error gives me the following issues : D3D10: INFO: ID3D10Device::DrawIndexed: The Pixel Shader unit expects a Shader Resource View at Slot 0, but none is bound. This is OK, as reads of an unbound Shader Resource View are defined to return 0. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Shader Resource View here. [ EXECUTION INFO #353: DEVICE_DRAW_SHADERRESOURCEVIEW_NOT_SET ] D3D10: WARNING: ID3D10Device::PSSetShaderResources: Resource being set to PS shader resource slot 0 is still bound on output! Forcing to NULL. [ STATE_SETTING WARNING #7: DEVICE_PSSETSHADERRESOURCES_HAZARD ] my first tought was that there was somthing wrong with the shadersourceview, but it seems like it´s not since i dont get any break/or error messages about it. any help is wellcome ! cheers.
"There will be major features. none to be thought of yet"
Advertisement
Quote:Resource being set to PS shader resource slot 0 is still bound on output


This means that you can't use the depth buffer texture as a shader resource while it's still bound as a render target. First unbind it as a render target, then bind it as a shader resource.
Oh! so i have to make a new call for set rendertarget and to pass on null instead of the depthbuffer?

*EDIT*

i added this code to my CreateShaderResourceView funktion :
D3D10_SHADER_RESOURCE_VIEW_DESC descSRV;descSRV.Format = DXGI_FORMAT_R32_FLOAT;	descSRV.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;descSRV.Texture2D.MipLevels = 1;descSRV.Texture2D.MostDetailedMip = 0;   		g_d3d.g_pd3dDevice->OMSetRenderTargets(1,&g_d3d.g_pRenderTargetView,NULL); //<----- this code!		if(FAILED(g_d3d.g_pd3dDevice->CreateShaderResourceView(g_d3d.pDepthStencil,&descSRV,&pTexture))){	MessageBox(NULL,L"ERROR",L"ERROR",MB_OK);}   return true;


the result is a red texture, with no depth data at all!
my clues end there and i dont know what to do!
here is my other Depth code.

ZeroMemory(&descDepth,sizeof(descDepth));descDepth.Width = SCREEN_W;descDepth.Height = SCREEN_H;descDepth.MipLevels = 1;descDepth.ArraySize = 1;descDepth.Format = DXGI_FORMAT_R32_TYPELESS;descDepth.SampleDesc.Count = 1;descDepth.SampleDesc.Quality = 0;descDepth.Usage = D3D10_USAGE_DEFAULT;descDepth.BindFlags = D3D10_BIND_DEPTH_STENCIL | D3D10_BIND_SHADER_RESOURCE;descDepth.CPUAccessFlags = 0;descDepth.MiscFlags = 0;if( FAILED( g_pd3dDevice->CreateTexture2D( &descDepth, NULL, &pDepthStencil ) ) ){	MessageBox(NULL,L"Cant create depth duffer",L"Error",MB_OK|MB_ICONERROR);	return false;}  desc.Format = DXGI_FORMAT_D32_FLOAT;desc.ViewDimension = D3D10_DSV_DIMENSION_TEXTURE2D;desc.Texture2D.MipSlice = 0;if( FAILED( g_pd3dDevice->CreateDepthStencilView( pDepthStencil, &desc, &pDepthStencilView ) ) ) {	MessageBox(NULL,L"Cant create depth view",L"Error",MB_OK|MB_ICONERROR);	return false;}g_pd3dDevice->OMSetRenderTargets(1, &g_pRenderTargetView, pDepthStencilView );


[Edited by - Tordin on December 7, 2009 4:51:32 AM]
"There will be major features. none to be thought of yet"
You should set the render target depth to NULL while rendering, before you try to set it as a shader resource, and not when creating the view.

This topic is closed to new replies.

Advertisement