I am new with Direct3D11. I have a compute shader and I need pass an input buffer to it. I have found nothing on Internet about how to do that. When I create a ShaderResourceView
object, there are an invalid argument error:
SharpDX.SharpDXException : 'HRESULT: [0x80070057], Module: [General], ApiCode: [E_INVALIDARG/Invalid Arguments]'
My buffer declaration:
inputBuffer = new SharpDX.Direct3D11.Buffer(D3D11Device, new SharpDX.Direct3D11.BufferDescription
{
BindFlags = SharpDX.Direct3D11.BindFlags.ShaderResource,
CpuAccessFlags = SharpDX.Direct3D11.CpuAccessFlags.None,
OptionFlags = SharpDX.Direct3D11.ResourceOptionFlags.BufferStructured,
SizeInBytes = count * sizeof(uint),
StructureByteStride = sizeof(uint),
Usage = SharpDX.Direct3D11.ResourceUsage.Default,
});
Passing buffer to the shader:
ShaderResourceViewDescription bufferResourceDescription = new ShaderResourceViewDescription
{
Dimension = ShaderResourceViewDimension.Buffer,
Format = SharpDX.DXGI.Format.R32_UInt,
Buffer = new ShaderResourceViewDescription.BufferResource() { ElementCount = outputBufferCount, ElementWidth = sizeof(uint) }
};
ShaderResourceView tilesResourceView = new ShaderResourceView(D3D11Device, inputBuffer, bufferResourceDescription); //error on this line
D3D11Context.ComputeShader.SetShaderResource(1, tilesResourceView);
The buffer declaration in the compute shader:
Buffer<uint> perTileLuminance : register(t1);
What I am doing wrong ?
User contributions licensed under CC BY-SA 3.0