Jump to content
  • Advertisement
Sign in to follow this  

Resource reported as empty

This topic is 1470 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, I'm currently having trouble reading an SRV that points to the same data as the UAV. So the UAV is first cleared, then written to, then unbind, then the srv that points to the same data is bound. The data from the UAV seems to be wriitten to completely fine, below you'll see that there is infact data in it:




This is after writing to the UAV, but, when binding the UAV for reading later on, its reported empty, renderDoc ( free Software by crytek ) reports it as empty as well:




Now, to the actual code, how I create the buffer, UAV and SRV:

D3D11_BUFFER_DESC bufferDesc;
                int stride = size;
                bufferDesc.ByteWidth = stride*count;
                bufferDesc.Usage = D3D11_USAGE_DEFAULT;
                bufferDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS;
                bufferDesc.CPUAccessFlags = 0;
                bufferDesc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
                bufferDesc.StructureByteStride = stride;
                if (pDev->CreateBuffer(&bufferDesc, pInitialDataRaw, &pp->pData) != S_OK)
                        return NULL;
                D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc;
                uavDesc.Format = DXGI_FORMAT_UNKNOWN;
                uavDesc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
                uavDesc.Buffer.FirstElement = 0;
                uavDesc.Buffer.Flags = 0;
                uavDesc.Buffer.NumElements = count;
                if (pDev->CreateUnorderedAccessView(pp->pData, &uavDesc, &pp->pUAV) != S_OK)
                        return NULL;
                D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
                srvDesc.Format = DXGI_FORMAT_UNKNOWN;
                srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
                srvDesc.Buffer.ElementOffset = 0;
                srvDesc.Buffer.ElementWidth = size;
                srvDesc.Buffer.NumElements = count;
                if (pDev->CreateShaderResourceView(pp->pData, &srvDesc, &pp->pSRV) != S_OK)
                        return NULL;

How I bind and Unbind:

Bind the UAV PS
                        0, 0, 0,
                        start, 1, &p->pUAV, 0

Bind the UAV CS
                        start, 1, &p->pUAV, 0

Binding the SRV:
                        pDevcon->PSSetShaderResources(start, 1, &p->pSRV);

If anything else is needed please tell me.


Question: Why is the resource reported as empty?


Thank you for your time.


Share this post

Link to post
Share on other sites

Try running with the D3D debug device - add the D3D11_CREATE_DEVICE_DEBUG flag when creating your device - and pay attention to the output window when attached in visual studio. If you're running through renderdoc you can check 'Create Debug Device' when capturing and examine the messages in Window -> Debug Messages.


If there are any conflicts between the UAV and SRV the debug device will tell you - it sounds like somehow the buffer is still bound on output (either OM or CS UAV) when you try to set it as a shader resource and so NULL is bound instead. The order is important, you have to unbind it as UAV in all locations before binding it as SRV as you specified. If there's some other problem the debug device will also report the vast majority of possible invalid uses of the API.

Share this post

Link to post
Share on other sites

Hi baldurk,


I've already tried all of those, the buffer is unbound from the RTV/UAV slot, theres no warnings at all after I've been tidying up.


Im still looking into the issue.


I appreciate your time!

Share this post

Link to post
Share on other sites

After cleaning up, the error disappeared, I'm currently not sure what the actual fault was.


But I appreciate anyone that read the issue.

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!