• Advertisement
Sign in to follow this  

Compute Shader - Unbind UAV

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

Hi guys wink.png .

 

I've got my UAV, initialized with the SRV like this:

D3D11_SUBRESOURCE_DATA data;
data.pSysMem = texArray;
data.SysMemPitch = width * type;
//data.SysMemSlicePitch = width * height * type;

// Build the texture header descriptor
D3D11_TEXTURE2D_DESC descTex;
descTex.Width = width;
descTex.Height = height;
descTex.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
descTex.Usage = D3D11_USAGE_DEFAULT;
descTex.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_RENDER_TARGET;
descTex.CPUAccessFlags = 0;
descTex.MipLevels = 1;
descTex.ArraySize = 1;
descTex.SampleDesc.Count = 1;
descTex.SampleDesc.Quality = 0;
descTex.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;

// Create the 2d texture from data
ID3D11Texture2D * pTexture_t = NULL;
HV( dev->CreateTexture2D( &descTex, &data, &pTexture_t ));

// Create resource view descriptor
D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc;
uavDesc.Format = descTex.Format;
uavDesc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D;

uavDesc.Texture2D.MipSlice = 0;

// Create the shader resource view
HV( dev->CreateUnorderedAccessView( pTexture_t, &uavDesc, &pTexture ));

// Create resource view descriptor
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
srvDesc.Format = descTex.Format;
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;

srvDesc.Texture2D.MostDetailedMip = 0;
srvDesc.Texture2D.MipLevels = D3D11_RESOURCE_MISC_GENERATE_MIPS;

// Create the shader resource view
HV( dev->CreateShaderResourceView( pTexture_t, &srvDesc, &SRV ));

 
I've chosen to bind this UAV to the compute shader, for now it's simply only writing a white color to it, which works fine ( debugged it ). I set it like this:

devcon->CSSetUnorderedAccessViews(0, 1, &pOUT, 0);

 
Now I'd imagine that I'd need to unbind it for a simple shader resource to be accessed, like so:

devcon->CSSetShader(NULL,0,0);
devcon->CSSetUnorderedAccessViews(0, 0, NULL, 0); // This one

 
But, when trying to access/send the SRV which points to the same data to the GPU, the debug layer gives me the following warning (or threat really):

Resource being set to PS shader resource slot 0 is still bound on output! Forcing to NULL

 
Suggesting that the UAV might still be bound somehow, I think, so the SRV is never sent.

 

What could I have done wrong in this? Do you need anything else?

 

Thank you for your time, as always. 

-MIGI0027

Edited by Migi0027

Share this post


Link to post
Share on other sites
Advertisement

UAV and SRV must never be bind same time, you have to unbind correctly.

You set using :

devcon->CSSetUnorderedAccessViews(0, 1, &pOUT, 0);

you unbind :

ID3D11UnorderedAccessView* UAV_NULL = NULL;
devcon->CSSetUnorderedAccessViews(0, 1, &UAV_NULL, 0);

When you send the SRV on shader, you must do the same kind of code.

Share this post


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

  • Advertisement