glslang/Test/hlsl.cbuffer-identifier.vert
LoopDawg 7ee29ba730 HLSL: allow keyword-identifiers as cbuffer/struct names.
Issue #791 was partially fixed by PR #1161 (the mat mul implicit
truncations were its main point), but it still wouldn't compile due to
the use of ConstantBuffer as an identifier.  Apparently those fall into
the same class as "float float", where float is both a type and an
identifier.

This allows struct definitions with such keyword-identifiers,
and adds ConstantBuffer to the set.  'cbuffer int' is legal in HLSL,
and 'struct int' appears to only be rejected due to the redefinition
of the 'int' type.

Fixes #791
2017-11-28 10:17:19 -07:00

33 lines
663 B
GLSL

cbuffer ConstantBuffer : register( b0 )
{
matrix World;
matrix View;
matrix Projection;
};
struct VS_INPUT
{
float4 Pos : POSITION;
float3 Norm : NORMAL;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
float3 Norm : TEXCOORD0;
};
PS_INPUT main( VS_INPUT input )
{
int ConstantBuffer = 42; // test ConstantBuffer as an identifier
PS_INPUT output = (PS_INPUT)0;
output.Pos = mul( input.Pos, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );
output.Norm = mul( input.Norm, World ); // Work when output.Norm = mul( input.Norm, (float3x3)World );
return output;
}