I'm trying to pass values to a Pixel Shader. I've added the following to the HLSL files.
cbuffer QuadShaderValues : register(b0) { float3 PixelDropThresholds; float4 OverlayColor; uint PixelDropEnabled; }
I've added the follow structure to the C# code;
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct QuadShaderValues
{
public SharpDX.Vector3 PixelDropThresholds;
public SharpDX.Color4 OverlayColor;
public uint PixelDropEnabled;
}
I've added the following code to the Initialization of the device :
m_ShaderValueBuffer =
AddDisposable(new SharpDX.Direct3D11.Buffer(direct3DDevice, SharpDX.Utilities.SizeOf<QuadShaderValues>(),
SharpDX.Direct3D11.ResourceUsage.Default,
SharpDX.Direct3D11.BindFlags.ConstantBuffer,
SharpDX.Direct3D11.CpuAccessFlags.None,
SharpDX.Direct3D11.ResourceOptionFlags.None, 0));
direct3Dcontext.VertexShader.SetConstantBuffer(0, m_ShaderValueBuffer);
I've added the following code to the Render Method :
deviceContext.UpdateSubresource(ref ShaderValues, m_ShaderValueBuffer);
The values do not seem to be making it into the shader.