acae607703
This is required to avoid relying on complex sub-expression elimination in compilers, and generates cleaner code. The problem case is if a complex expression is used in an access chain, like: Composite comp = buffer[texture(...)]; vec4 a = comp.a + comp.b + comp.c; Before, we did not have common subexpression tracking for OpLoad/OpAccessChain, so we easily ended up with code like: vec4 a = buffer[texture(...)].a + buffer[texture(...)].b + buffer[texture(...)].c; A good compiler will optimize this, but we should not rely on it, and forcing texture(...) to a temporary also looks better. The solution is to add a vector "implied_expression_reads", which works similarly to expression_dependencies. We also need an extra mechanism in to_expression which lets us skip expression read checking and do it later. E.g. for expr -> access chain -> load, we should only trigger a read of expr when using the loaded expression.
38 lines
938 B
GLSL
38 lines
938 B
GLSL
RWByteAddressBuffer _34 : register(u0);
|
|
Texture2D<int4> Buf : register(t1);
|
|
SamplerState _Buf_sampler : register(s1);
|
|
|
|
static float4 gl_FragCoord;
|
|
static int vIn;
|
|
static int vIn2;
|
|
static float4 FragColor;
|
|
|
|
struct SPIRV_Cross_Input
|
|
{
|
|
nointerpolation int vIn : TEXCOORD0;
|
|
nointerpolation int vIn2 : TEXCOORD1;
|
|
float4 gl_FragCoord : SV_Position;
|
|
};
|
|
|
|
struct SPIRV_Cross_Output
|
|
{
|
|
float4 FragColor : SV_Target0;
|
|
};
|
|
|
|
void frag_main()
|
|
{
|
|
int _40 = Buf.Load(int3(int2(gl_FragCoord.xy), 0)).x % 16;
|
|
FragColor = (asfloat(_34.Load4(_40 * 16 + 0)) + asfloat(_34.Load4(_40 * 16 + 0))) + asfloat(_34.Load4(((vIn * vIn) + (vIn2 * vIn2)) * 16 + 0));
|
|
}
|
|
|
|
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
|
{
|
|
gl_FragCoord = stage_input.gl_FragCoord;
|
|
vIn = stage_input.vIn;
|
|
vIn2 = stage_input.vIn2;
|
|
frag_main();
|
|
SPIRV_Cross_Output stage_output;
|
|
stage_output.FragColor = FragColor;
|
|
return stage_output;
|
|
}
|