Jump to content
  • Advertisement
Sign in to follow this  
realm087

Help with directx resources

This topic is 1810 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 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 *

 

sizeof(UINT);

descGPUBuffer.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;

descGPUBuffer.StructureByteStride = sizeof(UINT);

 

 

UINT* colorIndices = new UINT[vertexNum];

 

 

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

 

 

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

{

    colorIndices[x] = 1;

}

 

 

D3D11_SUBRESOURCE_DATA colorData;

 

 

ZeroMemory(&colorData, sizeof(colorData));

colorData.pSysMem = colorIndices;

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

 

 

D3D11_BUFFER_DESC descBuf;

 

 

ZeroMemory( &descBuf, sizeof(descBuf) );

colorBuffer->GetDesc( &descBuf );

 

 

D3D11_SHADER_RESOURCE_VIEW_DESC descSRV;

 

 

ZeroMemory( &descSRV, sizeof(descSRV) );

descSRV.ViewDimension =

 

D3D11_SRV_DIMENSION_BUFFEREX;

descSRV.BufferEx.FirstElement = 0;

descSRV.Format =

 

DXGI_FORMAT_UNKNOWN;

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 = cameraPosition.xyz - worldPosition.xyz;

    vertex.viewDirection = normalize(vertex.viewDirection);

    return vertex;

}

 

 

[maxvertexcount(24)]

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

inout TriangleStream< GSOutput > output)

 

etc...

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
Advertisement
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!