Sign in to follow this  

Resource reported as empty

This topic is 1188 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:

 

7gD5KWx.png

 

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:

 

v7x5ADX.png

 

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
pDevcon->OMSetRenderTargetsAndUnorderedAccessViews(
                        0, 0, 0,
                        start, 1, &p->pUAV, 0
                        );

Bind the UAV CS
pDevcon->CSSetUnorderedAccessViews(
                        start, 1, &p->pUAV, 0
                        );

UNBIND
pDevcon->PS/CSSetUnorderedAccessViews(
 
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.

-MIGI0027

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

This topic is 1188 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this