glslang/Test/hlsl.array.implicit-size.frag
steve-lunarg 265c0618b1 HLSL: allow implicit array sizing.
In HLSL array sizes need not be provided explicitly in all circumstances.
For example, this is valid (note no number between the [ ]):

  // no explicit array size
  uniform float g_array[] = { 1, 2, 3, 4, 5 };

This PR does not attempt to validate most invalid cases.

A new test is added to verify the resulting linker objects.
2016-09-27 14:28:26 -06:00

32 lines
740 B
GLSL

// implicit sized array
uniform float g_array [ ] = { 1, 2, 3, 4, 5 };
// Unused implicit sized array
uniform float g_array_unused [ ] = { 1, 2, 3, 4, 5, 6, 7 };
// Test implicit size arrayed structs
uniform struct mystruct {
int i;
float f;
} g_mystruct[] = {
{ 1, 2.0 },
{ 3, 4.0 },
};
struct PS_OUTPUT { float4 color : SV_Target0; };
// INVALID: implicit size requires an initializer expression.
// uniform float bad[];
// INVALID: function parameters cannot be implicitly sized
// void BadFunction(int a[]) { }
void main(out PS_OUTPUT ps_output)
{
// implicit sized local array
float l_array[] = { 1, 2, 3 };
ps_output.color = g_array[0] + g_array[4] + l_array[1] + g_mystruct[0].f + g_array[idx];
}