1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
typedef struct FragmentTestRec {
const char * name;
uint32_t texCount;
const char * txt;
} FragmentTest;
static FragmentTest fpFill = {
"Solid color", 0,
"precision mediump float;\n"
"uniform vec4 u_color;\n"
"void main() {\n"
" gl_FragColor = u_color;\n"
"}\n"
};
static FragmentTest fpGradient = {
"Solid gradient", 0,
"precision mediump float;\n"
"varying lowp vec4 v_color;\n"
"void main() {\n"
" gl_FragColor = v_color;\n"
"}\n"
};
static FragmentTest fpCopyTex = {
"Texture copy", 1,
"precision mediump float;\n"
"varying vec2 v_tex0;\n"
"uniform sampler2D u_tex0;\n"
"void main() {\n"
" gl_FragColor = texture2D(u_tex0, v_tex0);\n"
"}\n"
};
static FragmentTest fpCopyTexGamma = {
"Texture copy with gamma", 1,
"precision mediump float;\n"
"varying vec2 v_tex0;\n"
"uniform sampler2D u_tex0;\n"
"void main() {\n"
" vec4 t = texture2D(u_tex0, v_tex0);\n"
" t.rgb = pow(t.rgb, vec3(1.4, 1.4, 1.4));\n"
" gl_FragColor = t;\n"
"}\n"
};
static FragmentTest fpTexSpec = {
"Texture spec", 1,
"precision mediump float;\n"
"varying vec2 v_tex0;\n"
"uniform sampler2D u_tex0;\n"
"void main() {\n"
" vec4 t = texture2D(u_tex0, v_tex0);\n"
" float simSpec = dot(gl_FragCoord.xyz, gl_FragCoord.xyz);\n"
" simSpec = pow(clamp(simSpec, 0.1, 1.0), 40.0);\n"
" gl_FragColor = t + vec4(simSpec, simSpec, simSpec, simSpec);\n"
"}\n"
};
static FragmentTest fpDepTex = {
"Dependent Lookup", 1,
"precision mediump float;\n"
"varying vec2 v_tex0;\n"
"uniform sampler2D u_tex0;\n"
"void main() {\n"
" vec4 t = texture2D(u_tex0, v_tex0);\n"
" t += texture2D(u_tex0, t.xy);\n"
" gl_FragColor = t;\n"
"}\n"
};
static FragmentTest fpModulateConstantTex = {
"Texture modulate constant", 1,
"precision mediump float;\n"
"varying vec2 v_tex0;\n"
"uniform sampler2D u_tex0;\n"
"uniform vec4 u_color;\n"
"void main() {\n"
" lowp vec4 c = texture2D(u_tex0, v_tex0);\n"
" c *= u_color;\n"
" gl_FragColor = c;\n"
"}\n"
};
static FragmentTest fpModulateVaryingTex = {
"Texture modulate gradient", 1,
"precision mediump float;\n"
"varying vec2 v_tex0;\n"
"varying lowp vec4 v_color;\n"
"uniform sampler2D u_tex0;\n"
"void main() {\n"
" lowp vec4 c = texture2D(u_tex0, v_tex0);\n"
" c *= v_color;\n"
" gl_FragColor = c;\n"
"}\n"
};
static FragmentTest fpModulateVaryingConstantTex = {
"Texture modulate gradient constant", 1,
"precision mediump float;\n"
"varying vec2 v_tex0;\n"
"varying lowp vec4 v_color;\n"
"uniform sampler2D u_tex0;\n"
"uniform vec4 u_color;\n"
"void main() {\n"
" lowp vec4 c = texture2D(u_tex0, v_tex0);\n"
" c *= v_color;\n"
" c *= u_color;\n"
" gl_FragColor = c;\n"
"}\n"
};
static FragmentTest *gFragmentTests[] = {
&fpFill,
&fpGradient,
&fpCopyTex,
&fpCopyTexGamma,
&fpTexSpec,
&fpDepTex,
&fpModulateConstantTex,
&fpModulateVaryingTex,
&fpModulateVaryingConstantTex,
};
static const size_t gFragmentTestCount = sizeof(gFragmentTests) / sizeof(gFragmentTests[0]);
|