🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Unordered Access View output

Started by
0 comments, last by lucky9999 3 years, 10 months ago

Hi, it's jacky here.

I am creating a compute shader that outputs a bunch of floats, for example

struct BoidData
{
float a;
float b;
float numFlockMates;
}

RWStructuredBuffer<BoidData> boidData : register(u0);
[numthreads(1,1,1)]
void main(uint3 id : SV_DispatchThreadID)
{
boidData[id.x].numFlockMates=10;
}
//
D3D11_BUFFER_DESC bufferDesc;
ZeroMemory(&amp;bufferDesc, sizeof(bufferDesc));

bufferDesc.StructureByteStride=sizeof(BoidData);
bufferDesc.ByteWidth=boidsData.size() * sizeof(BoidData);
bufferDesc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
bufferDesc.Usage = D3D11_USAGE_DEFAULT;
this->m_pDevice->CreateBuffer ( &amp;bufferDesc, NULL, &amp;pBufferOut );

D3D11_UNORDERED_ACCESS_VIEW_DESC viewDescUAV;
ZeroMemory (&amp;viewDescUAV , sizeof( viewDescUAV ));

viewDescUAV.Format = DXGI_FORMAT_R32_FLOAT;
viewDescUAV.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
viewDescUAV.Buffer.FirstElement = 0;
viewDescUAV.Buffer.NumElements = sizeof(struct BoidData)*20; // 2 elements / 2 fields
this->m_pDevice->CreateUnorderedAccessView ( pBufferOut, &amp;viewDescUAV, &amp;pBufferOut_UAV );

When I created the compute shader for this data structure, I got sometimes, if I omit all the preceding fields, all tens if I assigned them to ten, or just one or two tens if I include the preceding fields.

What happened?

This topic is closed to new replies.

Advertisement