Jump to content

  • Log In with Google      Sign In   
  • Create Account

Compute Shader - Unbind UAV


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
2 replies to this topic

#1 Migi0027   Crossbones+   -  Reputation: 2119

Like
0Likes
Like

Posted 29 January 2014 - 03:44 PM

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, 29 January 2014 - 03:53 PM.

Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to steal all their shaders!

Sponsor:

#2 Alundra   Members   -  Reputation: 926

Like
3Likes
Like

Posted 29 January 2014 - 03:59 PM

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.



#3 Migi0027   Crossbones+   -  Reputation: 2119

Like
0Likes
Like

Posted 30 January 2014 - 12:05 AM

Ahh, thank you, I've got no idea why I didn't think of this. happy.png

 

Thanks!

-MIGI0027


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to steal all their shaders!




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