2016-09-10 01:32:09 +03:00
|
|
|
struct VI {
|
2017-07-31 10:19:26 +03:00
|
|
|
float4 m[2] : mysemA;
|
|
|
|
float4 coord : SV_POSITION;
|
|
|
|
linear float4 b : mysemB;
|
2016-09-10 01:32:09 +03:00
|
|
|
};
|
|
|
|
|
2017-07-31 10:19:26 +03:00
|
|
|
VI main(float4 d : mysem, VI vi, float4 e : mysem)
|
2016-09-10 01:32:09 +03:00
|
|
|
{
|
2016-09-17 02:10:39 +03:00
|
|
|
VI local;
|
|
|
|
|
2017-07-31 10:19:26 +03:00
|
|
|
local.b = vi.m[1] + vi.m[0] + (float4)vi.coord.x + d + e;
|
|
|
|
local.coord = (float4)1;
|
|
|
|
local.m[0] = (float4)2;
|
|
|
|
local.m[1] = (float4)3;
|
2016-09-17 02:10:39 +03:00
|
|
|
|
|
|
|
return local;
|
HLSL: Recursive composite flattening
This PR implements recursive type flattening. For example, an array of structs of other structs
can be flattened to individual member variables at the shader interface.
This is sufficient for many purposes, e.g, uniforms containing opaque types, but is not sufficient
for geometry shader arrayed inputs. That will be handled separately with structure splitting,
which is not implemented by this PR. In the meantime, that case is detected and triggers an error.
The recursive flattening extends the following three aspects of single-level flattening:
- Flattening of structures to individual members with names such as "foo[0].samp[1]";
- Turning constant references to the nested composite type into a reference to a particular
flattened member.
- Shadow copies between arrays of flattened members and the nested composite type.
Previous single-level flattening only flattened at the shader interface, and that is unchanged by this PR.
Internally, shadow copies are, such as if the type is passed to a function.
Also, the reasons for flattening are unchanged. Uniforms containing opaque types, and interface struct
types are flattened. (The latter will change with structure splitting).
One existing test changes: hlsl.structin.vert, which did in fact contain a nested composite type to be
flattened.
Two new tests are added: hlsl.structarray.flatten.frag, and hlsl.structarray.flatten.geom (currently
issues an error until type splitting is online).
The process of arriving at the individual member from chained postfix expressions is more complex than
it was with one level. See large-ish comment above HlslParseContext::flatten() for details.
2016-11-29 03:09:54 +03:00
|
|
|
}
|