d92de00cc1
This is a fairly fundamental change on how IDs are handled. It serves many purposes: - Improve performance. We only need to iterate over IDs which are relevant at any one time. - Makes sure we iterate through IDs in SPIR-V module declaration order rather than ID space. IDs don't have to be monotonically increasing, which was an assumption SPIRV-Cross used to have. It has apparently never been a problem until now. - Support LUTs of structs. We do this by interleaving declaration of constants and struct types in SPIR-V module order. To support this, the ParsedIR interface needed to change slightly. Before setting any ID with variant_set<T> we let ParsedIR know that an ID with a specific type has been added. The surface for change should be minimal. ParsedIR will maintain a per-type list of IDs which the cross-compiler will need to consider for later. Instead of looping over ir.ids[] (which can be extremely large), we loop over types now, using: ir.for_each_typed_id<SPIRVariable>([&](uint32_t id, SPIRVariable &var) { handle_variable(var); }); Now we make sure that we're never looking at irrelevant types.
39 lines
754 B
GLSL
39 lines
754 B
GLSL
struct Foo
|
|
{
|
|
float a;
|
|
float b;
|
|
};
|
|
|
|
static const float _16[4] = { 1.0f, 4.0f, 3.0f, 2.0f };
|
|
static const Foo _24 = { 10.0f, 20.0f };
|
|
static const Foo _27 = { 30.0f, 40.0f };
|
|
static const Foo _28[2] = { { 10.0f, 20.0f }, { 30.0f, 40.0f } };
|
|
|
|
static float4 FragColor;
|
|
static int _line;
|
|
|
|
struct SPIRV_Cross_Input
|
|
{
|
|
nointerpolation int _line : TEXCOORD0;
|
|
};
|
|
|
|
struct SPIRV_Cross_Output
|
|
{
|
|
float4 FragColor : SV_Target0;
|
|
};
|
|
|
|
void frag_main()
|
|
{
|
|
FragColor = _16[_line].xxxx;
|
|
FragColor += (_28[_line].a * _28[1 - _line].a).xxxx;
|
|
}
|
|
|
|
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
|
{
|
|
_line = stage_input._line;
|
|
frag_main();
|
|
SPIRV_Cross_Output stage_output;
|
|
stage_output.FragColor = FragColor;
|
|
return stage_output;
|
|
}
|