Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


DX10 - Depth buffer to texture problems.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Tordin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 05 December 2009 - 02:07 PM

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.

Sponsor:

#2 Erik Rufelt   Crossbones+   -  Reputation: 3524

Like
0Likes
Like

Posted 06 December 2009 - 02:38 AM

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.

#3 Tordin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 06 December 2009 - 09:51 PM

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]

#4 ET3D   Members   -  Reputation: 806

Like
0Likes
Like

Posted 08 December 2009 - 02:02 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS