SRV from UAV on the same texture in directx
Posted
by
notabene
on Game Development
See other posts from Game Development
or by notabene
Published on 2011-01-07T22:38:55Z
Indexed on
2011/01/07
22:59 UTC
Read the original article
Hit count: 291
I'm programming gpgpu raymarching (volumetric raytracing) in directx11. I succesfully perform compute shader and save raymarched volume data to texture. Then i want to use same texture as SRV in normal graphic pipeline. But it doesnt work, texture is not visible.
Texture is ok, when i save it file it is what i expect. Texture rendering is ok too, when i render another SRV, it is ok. So problem is only in UAV->SRV. I also triple checked if pointers are ok. Please help, i'm getting mad about this.
Here is some code:
//before dispatch
D3D11_TEXTURE2D_DESC textureDesc;
ZeroMemory( &textureDesc, sizeof( textureDesc ) );
textureDesc.Width = xr;
textureDesc.Height = yr;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
textureDesc.BindFlags = D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_SHADER_RESOURCE ;
textureDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
D3D->CreateTexture2D( &textureDesc, NULL, &pTexture );
D3D11_UNORDERED_ACCESS_VIEW_DESC viewDescUAV;
ZeroMemory( &viewDescUAV, sizeof( viewDescUAV ) );
viewDescUAV.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
viewDescUAV.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D;
viewDescUAV.Texture2D.MipSlice = 0;
D3DD->CreateUnorderedAccessView( pTexture, &viewDescUAV, &pTextureUAV );
//the getSRV function after dispatch.
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc ;
ZeroMemory( &srvDesc, sizeof( srvDesc ) );
srvDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
srvDesc.Texture2D.MipLevels = 1;
D3DD->CreateShaderResourceView( pTexture, &srvDesc, &pTextureSRV);
© Game Development or respective owner