Commit bfeed4dd by Olli Etuaho Committed by Commit Bot

Add a compiler perf test shader to stress traversers

Add a compiler perf test that's targeted at AST traversers. It triggers many traversers that mutate the AST and run multiple iterations particularly on the HLSL backend. BUG=angleproject:827 TEST=angle_perftests Change-Id: I75d89e8ae0fd7959f2c7fbb133c13ccde22abc37 Reviewed-on: https://chromium-review.googlesource.com/904622Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 2d1c0a2b
...@@ -76,6 +76,92 @@ void main(void) ...@@ -76,6 +76,92 @@ void main(void)
const char *kRealWorldESSL100Id = "RealWorldESSL100"; const char *kRealWorldESSL100Id = "RealWorldESSL100";
// This shader is intended to trigger many AST transformations, particularly on the HLSL backend.
const char *kTrickyESSL300FragSource = R"(#version 300 es
precision highp float;
precision highp sampler2D;
precision highp isampler2D;
precision highp int;
float globalF;
uniform ivec4 uivec;
uniform int ui;
struct SS
{
int iField;
float fField;
vec2 f2Field;
sampler2D sField;
isampler2D isField;
};
uniform SS us;
out vec4 my_FragColor;
float[3] sideEffectArray()
{
globalF += 1.0;
return float[3](globalF, globalF * 2.0, globalF * 3.0);
}
// This struct is unused and can be pruned.
struct SUnused
{
vec2 fField;
};
void main()
{
struct S2
{
float fField;
} s2;
vec4 foo = vec4(ui);
mat4 fooM = mat4(foo.x);
// Some unused variables that can be pruned.
float fUnused, fUnused2;
ivec4 iUnused, iUnused2;
globalF = us.fField;
s2.fField = us.fField;
float[3] fa = sideEffectArray();
globalF -= us.fField;
if (fa == sideEffectArray())
{
globalF += us.fField * sin(2.0);
}
// Switch with fall-through.
switch (ui)
{
case 0:
// Sequence operator and matrix and vector dynamic indexing.
(globalF += 1.0, fooM[ui][ui] += fooM[ui - 1][uivec[ui] + 1]);
case 1:
// Built-in emulation.
foo[3] = tanh(foo[1]);
default:
// Sequence operator and length of an array expression with side effects.
foo[2] += (globalF -= 1.0, float((sideEffectArray()).length() * 2));
}
int i = 0;
do
{
s2.fField = us.fField * us.f2Field.x;
// Sequence operator and short-circuiting operator with side effects on the right hand side.
} while ((++i, i < int(us.fField) && ++i <= ui || ++i < ui * 2 - 3));
// Samplers in structures and integer texture sampling.
foo += texture(us.sField, us.f2Field) + intBitsToFloat(texture(us.isField, us.f2Field + 4.0));
my_FragColor = foo * s2.fField * globalF + fooM[ui];
})";
const char *kTrickyESSL300Id = "TrickyESSL300";
struct CompilerPerfParameters final : public angle::CompilerParameters struct CompilerPerfParameters final : public angle::CompilerParameters
{ {
CompilerPerfParameters(ShShaderOutput output, CompilerPerfParameters(ShShaderOutput output,
...@@ -191,13 +277,16 @@ ANGLE_INSTANTIATE_TEST( ...@@ -191,13 +277,16 @@ ANGLE_INSTANTIATE_TEST(
CompilerPerfParameters(SH_HLSL_4_1_OUTPUT, kSimpleESSL100FragSource, kSimpleESSL100Id), CompilerPerfParameters(SH_HLSL_4_1_OUTPUT, kSimpleESSL100FragSource, kSimpleESSL100Id),
CompilerPerfParameters(SH_HLSL_4_1_OUTPUT, kSimpleESSL300FragSource, kSimpleESSL300Id), CompilerPerfParameters(SH_HLSL_4_1_OUTPUT, kSimpleESSL300FragSource, kSimpleESSL300Id),
CompilerPerfParameters(SH_HLSL_4_1_OUTPUT, kRealWorldESSL100FragSource, kRealWorldESSL100Id), CompilerPerfParameters(SH_HLSL_4_1_OUTPUT, kRealWorldESSL100FragSource, kRealWorldESSL100Id),
CompilerPerfParameters(SH_HLSL_4_1_OUTPUT, kTrickyESSL300FragSource, kTrickyESSL300Id),
CompilerPerfParameters(SH_GLSL_450_CORE_OUTPUT, kSimpleESSL100FragSource, kSimpleESSL100Id), CompilerPerfParameters(SH_GLSL_450_CORE_OUTPUT, kSimpleESSL100FragSource, kSimpleESSL100Id),
CompilerPerfParameters(SH_GLSL_450_CORE_OUTPUT, kSimpleESSL300FragSource, kSimpleESSL300Id), CompilerPerfParameters(SH_GLSL_450_CORE_OUTPUT, kSimpleESSL300FragSource, kSimpleESSL300Id),
CompilerPerfParameters(SH_GLSL_450_CORE_OUTPUT, CompilerPerfParameters(SH_GLSL_450_CORE_OUTPUT,
kRealWorldESSL100FragSource, kRealWorldESSL100FragSource,
kRealWorldESSL100Id), kRealWorldESSL100Id),
CompilerPerfParameters(SH_GLSL_450_CORE_OUTPUT, kTrickyESSL300FragSource, kTrickyESSL300Id),
CompilerPerfParameters(SH_ESSL_OUTPUT, kSimpleESSL100FragSource, kSimpleESSL100Id), CompilerPerfParameters(SH_ESSL_OUTPUT, kSimpleESSL100FragSource, kSimpleESSL100Id),
CompilerPerfParameters(SH_ESSL_OUTPUT, kSimpleESSL300FragSource, kSimpleESSL300Id), CompilerPerfParameters(SH_ESSL_OUTPUT, kSimpleESSL300FragSource, kSimpleESSL300Id),
CompilerPerfParameters(SH_ESSL_OUTPUT, kRealWorldESSL100FragSource, kRealWorldESSL100Id)); CompilerPerfParameters(SH_ESSL_OUTPUT, kRealWorldESSL100FragSource, kRealWorldESSL100Id),
CompilerPerfParameters(SH_ESSL_OUTPUT, kTrickyESSL300FragSource, kTrickyESSL300Id));
} // anonymous namespace } // anonymous namespace
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment