Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
D3D->CreateTexture2D( &textureDesc, NULL, &pTexture );

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.
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);
share|improve this question
Also i release UAV before creating and using SRV – Notabene Jan 8 '11 at 0:48
up vote 4 down vote accepted

I solved this. Problem was in releasing. You can't access compute shader's resources until it is fully unbind and released.

Edit you dont have to release it at all. Only "unplug" UAV from from gpu.

//code is shortened
//create UAV
D3D->CreateTexture2D( &textureDesc, NULL, &pTexture );
D3DD->CreateUnorderedAccessView( pTexture, &viewDescUAV, &pTextureUAV );


//pTextureUAV->release(); // You dont have to release (if you want to use UAV again)
outputTexH->SetUnorderedAccessView(NULL); // This is what is important

effpass->Apply(0,D3DC); // unbind compute shader

//create SRV on the texture, use it.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.