
This checkin adds a --flatten-uniform-arrays option which can break uniform arrays of samplers, textures, or UBOs up into individual scalars named (e.g) myarray[0], myarray[1], etc. These appear as individual linkage objects. Code notes: - shouldFlatten internally calls shouldFlattenIO, and shouldFlattenUniform, but is the only flattening query directly called. - flattenVariable will handle structs or arrays (but not yet arrayed structs; this is tested an an error is generated). - There's some error checking around unhandled situations. E.g, flattening uniform arrays with initializer lists is not implemented. - This piggybacks on as much of the existing mechanism for struct flattening as it can. E.g, it uses the same flattenMap, and the same flattenAccess() method. - handleAssign() has been generalized to cope with either structs or arrays. - Extended test infrastructure to test flattening ability.
39 lines
1.0 KiB
GLSL
39 lines
1.0 KiB
GLSL
|
|
// uniform Texture1D g_tex3[3][2]; // TODO: legal in HLSL, but we don't handle it yet.
|
|
|
|
uniform Texture1D g_tex[3];
|
|
uniform Texture1D g_tex_explicit[3] : register(t1);
|
|
|
|
SamplerState g_samp[3];
|
|
SamplerState g_samp_explicit[3] : register(s5);
|
|
|
|
uniform float3x3 g_mats[4];
|
|
uniform float3x3 g_mats_explicit[4] : register(b10);
|
|
uniform float g_floats[4];
|
|
|
|
// uniform float g_floats[4] = { 10, 11, 12, 13 }; // TODO: ... add when initializer lists can be flattened.
|
|
|
|
float4 TestFn1()
|
|
{
|
|
return g_tex[1].Sample(g_samp[1], 0.2);
|
|
}
|
|
|
|
float4 TestFn2(Texture1D l_tex[3], SamplerState l_samp[3])
|
|
{
|
|
return l_tex[2].Sample(l_samp[2], 0.2);
|
|
}
|
|
|
|
int not_flattened_a[5] = { 1, 2, 3, 4, 5 };
|
|
|
|
struct PS_OUTPUT { float4 color : SV_Target0; };
|
|
|
|
void main(out PS_OUTPUT ps_output)
|
|
{
|
|
// test flattening for local assignment initialization
|
|
SamplerState local_sampler_array[3] = g_samp;
|
|
Texture1D local_texture_array[3] = g_tex;
|
|
float local_float_array[4] = g_floats;
|
|
|
|
ps_output.color = TestFn1() + TestFn2(g_tex, g_samp);
|
|
}
|