【发布时间】:2014-12-04 17:52:39
【问题描述】:
我有一个 HLSL 着色器,当我将特定变量添加到常量缓冲区时,它会给出意外错误。整个着色器在下面。为了排除一切,我包括了整个着色器。
将NewVariable添加到第三个常量缓冲区时出现错误。
我在文档中没有找到这一点,但我可以不执行以下打包,其中向量开始部分进入 c0 向量?
float1 var1 : packoffset( c0.x );
float3 var2 : packoffset( c0.yzw );
我收到记录不充分的错误 X3530 (ERR_BIND_INVALID)。 MSDN 说,“执行了无效的绑定操作。例如,缓冲区只能绑定到一个插槽或一个常量偏移量;无效的寄存器规范,因为预期的特定绑定但没有发生;不能将 packoffset 元素与 nonpackoffset 元素混合在 cbuffer 中。”这个错误消息并没有告诉我什么是错误的,并且包偏移量在我看来是正确的。
cbuffer SceneGlobals : register( b0 )
{
int NumAmbientLights : packoffset( c0 );
int NumDirectionalLights : packoffset( c0.y );
int NumPointLights : packoffset( c0.z );
int NumSpotLights : packoffset( c0.w );
}
cbuffer FrameGlobals : register( b1 )
{
float Time : packoffset( c0 );
float Timestep : packoffset( c0.y );
int NumCameras : packoffset( c0.z );
float4 CameraPosition[1] : packoffset( c1 );
float4x4 CameraView[1] : packoffset( c2 );
float4x4 CameraProjection[1] : packoffset( c6 );
float4x4 CameraViewProjection[1] : packoffset( c10 );
}
cbuffer ObjectGlobals : register( b2 )
{
int ActiveCamera : packoffset( c0 );
int3 NewVariable : packoffset( c0.yzw ); // ERROR OCCURS HERE
}
struct InputStruct
{
float4 Position : POSITION;
float4 Color : COLOR;
};
struct OutputStruct
{
float4 Position : SV_POSITION0;
float4 Color : COLOR0;
float4 Normal : NORMAL0;
float4 WorldPos : POSITION0;
float4 TexCoords : TEXCOORD0;
};
OutputStruct VS( InputStruct Input )
{
OutputStruct Output = (OutputStruct)0;
Output.Position = mul(CameraViewProjection[ActiveCamera], Input.Position);
Output.Color = Input.Color;
return Output;
}
【问题讨论】:
标签: directx-11 hlsl