Resource reported as empty

Started by
2 comments, last by Migi0027 9 years, 7 months ago

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

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

Advertisement

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.

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!

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

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

But I appreciate anyone that read the issue.

FastCall22: "I want to make the distinction that my laptop is a whore-box that connects to different network"

Blog about... stuff (GDNet, WordPress): www.gamedev.net/blog/1882-the-cuboid-zone/, cuboidzone.wordpress.com/

This topic is closed to new replies.

Advertisement