Sign in to follow this  

Help with directx resources

Recommended Posts

Hi, I'm trying to make a game using directx but I'm finding some problems when trying to bind a structured buffer resource to my Geometry Shader. It simply won't even bother to bind the resource to a slot, despite it being created succefuly.

I'm creating the buffer like this:


D3D11_BUFFER_DESC descGPUBuffer;


ZeroMemory(&descGPUBuffer, sizeof(descGPUBuffer));

descGPUBuffer.BindFlags = D3D11_BIND_SHADER_RESOURCE;

descGPUBuffer.ByteWidth = vertexNum *




descGPUBuffer.StructureByteStride = sizeof(UINT);



UINT* colorIndices = new UINT[vertexNum];



ZeroMemory(colorIndices, vertexNum * sizeof(UINT));



for(int x = 0;x < vertexNum;x++)


    colorIndices[x] = 1;







ZeroMemory(&colorData, sizeof(colorData));

colorData.pSysMem = colorIndices;

dev->CreateBuffer(&descGPUBuffer, &colorData, &colorBuffer);



D3D11_BUFFER_DESC descBuf;



ZeroMemory( &descBuf, sizeof(descBuf) );

colorBuffer->GetDesc( &descBuf );






ZeroMemory( &descSRV, sizeof(descSRV) );

descSRV.ViewDimension =



descSRV.BufferEx.FirstElement = 0;

descSRV.Format =



descSRV.BufferEx.NumElements = descBuf.ByteWidth / descBuf.StructureByteStride;

dev->CreateShaderResourceView(colorBuffer.Get(), &descSRV, &colorSRV);



devcon->GSSetShaderResources(0, 1, &colorSRV);

and my shader where the structured buffer is declared is like this:


StructuredBuffer<uint> BufferColors: register(t0);


GSOutput calcVertex(float4 position, float3 normal)


    GSOutput vertex;



    float4 worldPosition;

    vertex.position = mul(final, position);

    vertex.normal = normal;

    worldPosition = mul(position, world);

    vertex.viewDirection = -;

    vertex.viewDirection = normalize(vertex.viewDirection);

    return vertex;





void main(point float4 input_point[1] : SV_POSITION, uint primID : SV_PrimitiveID,

inout TriangleStream< GSOutput > output)



Can you guys please help me? I'm desperate I can't really find the error.

Share this post

Link to post
Share on other sites

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