summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2012-03-05 12:29:42 -0800
committerMatt Turner <mattst88@gmail.com>2016-10-26 13:04:03 -0700
commita30bf1c4f9d1a34e7151a46fd4935f4435dc5158 (patch)
tree27e0f6fda8e8353b0655149b5a726f540202dd2f
parent21cb417808fa41c48e5ffa6f00cfd11bb7b1ceae (diff)
arb program: Add binary result templates
These templates are used to verify most instructions. A small program snippet containing the instruction to be tested is executed. The result of this program, stored in R0, is compared against an expected value. If the calculated value is within a specified tolerance of the expected value, green is emitted. Otherwise red is emitted. The program for the sub.shader_test for ARB_vertex_program will look like: !!ARBvp1.0 TEMP R0, R1; TEMP fail, pass; # program.env[0..2] are the operands for the instructions # program.env[3..19] are the expected values # program.env[20..36] are the tolerance values # program.env[37] is { never expected value, 0, 1, 0 } # Combination 0 MOV R0, program.env[37].xxxx; ADD R0, program.env[0], program.env[1]; # fail = any(greaterThanEqual(abs(value - expect), tolerance)); SUB R0, R0, program.env[3]; ABS R0, R0; SGE R0, R0, program.env[20]; DP4 fail.x, R0, R0; # Combination 1 MOV R0, program.env[37].xxyy; ADD R0.xy, program.env[0].xxyw, program.env[1].xxzw; # fail = fail || any(greaterThanEqual(abs(value - expect), tolerance)); SUB R0, R0, program.env[4]; ABS R0, R0; SGE R0, R0, program.env[21]; DP4 R0.x, R0, R0; ADD fail.x, fail.x, R0.x; ... MIN fail.x, fail.x, {1.0}.x; # Clamp to [0,1] SUB pass.x, {1.0}.x, fail.x; # Logical not MUL R1, pass.x, {0.0, 1.0, 0.0, 1.0}; MAD result.color, fail.x, {1.0, 0.0, 0.0, 1.0}, R1; MOV result.position, vertex.position; END The program for the add.shader_test for NV_vertex_program will look like: !!VP1.0 # R11 it the boolean "fail" variable. This is stored in a high # register index so that code to test any possible instruction will # not stomp on it. # c[0..2] are the operands for the instructions # c[3..15] are the expected values # c[16..28] are the tolerance values # c[29] is { never expected value, 0, 1, 0 } # Combination 0 MOV R0, c[29].xxxx; MOV R1, c[1]; ADD R0, c[0], R1; # fail = any(greaterThanEqual(abs(value - expect), tolerance)); ADD R0, R0, -c[3]; MAX R0, R0, -R0; SGE R0, R0, c[16]; DP4 R11.x, R0, R0; # Combination 1 MOV R0, c[29].xxyy; MOV R1, c[1]; ADD R0.xy, c[0].xxyw, R1.xxzw; # fail = fail || any(greaterThanEqual(abs(value - expect), tolerance)); ADD R0, R0, -c[4]; MAX R0, R0, -R0; SGE R0, R0, c[17]; DP4 R0.x, R0, R0; ADD R11.x, R11.x, R0.x; ... MIN R11.x, R11.x, c[29].z; # Clamp to [0,1] ADD R11.y, c[29].z, -R11.x; # Logical not MUL R1, R1.y, c[29].yzyz; # Select green on !fail or... MAD o[COL0], R11.x, c[29].zyyz, R11; # ...red on fail. MOV o[HPOS], v[OPOS]; END The fragment program versions are very similar. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> squash! 644413eb5570531ba7030a2f6c5830ad52f7c6f7
-rw-r--r--generated_tests/spec/arb_fragment_program/binary_result.template61
-rw-r--r--generated_tests/spec/arb_vertex_program/binary_result.template63
-rw-r--r--generated_tests/spec/nv_vertex_program/binary_result.template63
-rw-r--r--generated_tests/spec/nv_vertex_program1_1/binary_result.template63
4 files changed, 250 insertions, 0 deletions
diff --git a/generated_tests/spec/arb_fragment_program/binary_result.template b/generated_tests/spec/arb_fragment_program/binary_result.template
new file mode 100644
index 000000000..54bcaec77
--- /dev/null
+++ b/generated_tests/spec/arb_fragment_program/binary_result.template
@@ -0,0 +1,61 @@
+[require]
+GL_ARB_fragment_program
+
+[fragment program]
+!!ARBfp1.0
+ TEMP R0, R1;
+ TEMP fail, pass;
+
+ # program.env[0..2] are the operands for the instructions
+ # program.env[3..${3 + len(programs) - 1}] are the expected values
+ # program.env[${3 + len(programs)}..${3 + 2 * len(programs) - 1}] are the tolerance values
+ # program.env[${3 + 2 * len(programs)}] is { never expected value, 0, 1, 0 }
+
+% for i in range(len(programs)):
+ # Combination ${i}
+${programs[i]}
+% if i == 0:
+ # fail = any(greaterThanEqual(abs(value - expect), tolerance));
+% elif i == 1:
+ # fail = fail || any(greaterThanEqual(abs(value - expect), tolerance));
+% endif
+ SUB R0, R0, program.env[${3 + i}];
+ ABS R0, R0;
+ SGE R0, R0, program.env[${3 + len(programs) + i}];
+% if i == 0:
+ DP4 fail.x, R0, R0;
+% else:
+ DP4 R0.x, R0, R0;
+ ADD_SAT fail.x, fail.x, R0.x;
+% endif
+
+% endfor
+ SUB pass.x, {1.0}.x, fail.x; # Logical not
+ MUL R1, pass.x, {0.0, 1.0, 0.0, 1.0};
+ MAD result.color, fail.x, {1.0, 0.0, 0.0, 1.0}, R1;
+ END
+
+[test]
+clear color 0.5 0.5 0.5 0.5
+clear
+% for [env, expected, not_expected, x, y, w, h] in test_vectors:
+
+% for i in range(len(env)):
+parameter env_fp ${i} (${env[i][0]}, ${env[i][1]}, ${env[i][2]}, ${env[i][3]})
+% endfor
+# Expected values
+% for i in range(len(expected)):
+parameter env_fp ${i + 3} (${expected[i][0]}, ${expected[i][1]}, ${expected[i][2]}, ${expected[i][3]})
+% endfor
+# Tolerance values
+% for i in range(len(expected)):
+parameter env_fp ${i + 3 + len(expected)} (${max(1e-5, 1e-6 * expected[i][0])}, ${max(1e-5, 1e-6 * expected[i][1])}, ${max(1e-5, 1e-6 * expected[i][2])}, ${max(1e-5, 1e-6 * expected[i][3])})
+% endfor
+# "Not expected" value
+parameter env_fp ${3 + 2 * len(expected)} (${not_expected}, 0, 1, 0)
+draw rect ${x} ${y} ${w} ${h}
+% endfor
+
+% for [env, expected, not_expected, x, y, w, h] in test_vectors:
+relative probe rgb (${.5 * (x + w * .5) + .5}, ${.5 * (y + h * .5) + .5}) (0, 1, 0)
+% endfor
diff --git a/generated_tests/spec/arb_vertex_program/binary_result.template b/generated_tests/spec/arb_vertex_program/binary_result.template
new file mode 100644
index 000000000..35fd00c02
--- /dev/null
+++ b/generated_tests/spec/arb_vertex_program/binary_result.template
@@ -0,0 +1,63 @@
+[require]
+GL_ARB_vertex_program
+
+[vertex program]
+!!ARBvp1.0
+ TEMP R0, R1;
+ TEMP fail, pass;
+
+ # program.env[0..2] are the operands for the instructions
+ # program.env[3..${3 + len(programs) - 1}] are the expected values
+ # program.env[${3 + len(programs)}..${3 + 2 * len(programs) - 1}] are the tolerance values
+ # program.env[${3 + 2 * len(programs)}] is { never expected value, 0, 1, 0 }
+
+% for i in range(len(programs)):
+ # Combination ${i}
+${programs[i]}
+% if i == 0:
+ # fail = any(greaterThanEqual(abs(value - expect), tolerance));
+% elif i == 1:
+ # fail = fail || any(greaterThanEqual(abs(value - expect), tolerance));
+% endif
+ SUB R0, R0, program.env[${3 + i}];
+ ABS R0, R0;
+ SGE R0, R0, program.env[${3 + len(programs) + i}];
+% if i == 0:
+ DP4 fail.x, R0, R0;
+% else:
+ DP4 R0.x, R0, R0;
+ ADD fail.x, fail.x, R0.x;
+% endif
+
+% endfor
+ MIN fail.x, fail.x, {1.0}.x; # Clamp to [0,1]
+ SUB pass.x, {1.0}.x, fail.x; # Logical not
+ MUL R1, pass.x, {0.0, 1.0, 0.0, 1.0};
+ MAD result.color, fail.x, {1.0, 0.0, 0.0, 1.0}, R1;
+ MOV result.position, vertex.position;
+ END
+
+[test]
+clear color 0.5 0.5 0.5 0.5
+clear
+% for [env, expected, not_expected, x, y, w, h] in test_vectors:
+
+% for i in range(len(env)):
+parameter env_vp ${i} (${env[i][0]}, ${env[i][1]}, ${env[i][2]}, ${env[i][3]})
+% endfor
+# Expected values
+% for i in range(len(expected)):
+parameter env_vp ${i + 3} (${expected[i][0]}, ${expected[i][1]}, ${expected[i][2]}, ${expected[i][3]})
+% endfor
+# Tolerance values
+% for i in range(len(expected)):
+parameter env_vp ${i + 3 + len(expected)} (${max(1e-5, 1e-6 * expected[i][0])}, ${max(1e-5, 1e-6 * expected[i][1])}, ${max(1e-5, 1e-6 * expected[i][2])}, ${max(1e-5, 1e-6 * expected[i][3])})
+% endfor
+# "Not expected" value
+parameter env_vp ${3 + 2 * len(expected)} (${not_expected}, 0, 1, 0)
+draw rect ${x} ${y} ${w} ${h}
+% endfor
+
+% for [env, expected, not_expected, x, y, w, h] in test_vectors:
+relative probe rgb (${.5 * (x + w * .5) + .5}, ${.5 * (y + h * .5) + .5}) (0, 1, 0)
+% endfor
diff --git a/generated_tests/spec/nv_vertex_program/binary_result.template b/generated_tests/spec/nv_vertex_program/binary_result.template
new file mode 100644
index 000000000..a711916dc
--- /dev/null
+++ b/generated_tests/spec/nv_vertex_program/binary_result.template
@@ -0,0 +1,63 @@
+[require]
+GL_NV_vertex_program
+
+[vertex program]
+!!VP1.0
+ # R11 it the boolean "fail" variable. This is stored in a high
+ # register index so that code to test any possible instruction will
+ # not stomp on it.
+
+ # c[0..2] are the operands for the instructions
+ # c[3..${3 + len(programs) - 1}] are the expected values
+ # c[${3 + len(programs)}..${3 + 2 * len(programs) - 1}] are the tolerance values
+ # c[${3 + 2 * len(programs)}] is { never expected value, 0, 1, 0 }
+% for i in range(len(programs)):
+ # Combination ${i}
+${programs[i]}
+% if i == 0:
+ # fail = any(greaterThanEqual(abs(value - expect), tolerance));
+% elif i == 1:
+ # fail = fail || any(greaterThanEqual(abs(value - expect), tolerance));
+% endif
+ ADD R0, R0, -c[${3+i}];
+ MAX R0, R0, -R0;
+ SGE R0, R0, c[${3+len(programs)+i}];
+% if i == 0:
+ DP4 R11.x, R0, R0;
+% else:
+ DP4 R0.x, R0, R0;
+ ADD R11.x, R11.x, R0.x;
+% endif
+
+% endfor
+ MIN R11.x, R11.x, c[${3 + 2 * len(programs)}].z; # Clamp to [0,1]
+ ADD R11.y, c[${3 + 2 * len(programs)}].z, -R11.x; # Logical not
+ MUL R1, R1.y, c[${3 + 2 * len(programs)}].yzyz; # Select green on !fail or...
+ MAD o[COL0], R11.x, c[${3 + 2 * len(programs)}].zyyz, R11; # ...red on fail.
+ MOV o[HPOS], v[OPOS];
+ END
+
+[test]
+clear color 0.5 0.5 0.5 0.5
+clear
+% for [env, expected, not_expected, x, y, w, h] in test_vectors:
+
+% for i in range(len(env)):
+parameter env_vp ${i} (${env[i][0]}, ${env[i][1]}, ${env[i][2]}, ${env[i][3]})
+% endfor
+# Expected values
+% for i in range(len(expected)):
+parameter env_vp ${i + 3} (${expected[i][0]}, ${expected[i][1]}, ${expected[i][2]}, ${expected[i][3]})
+% endfor
+# Tolerance values
+% for i in range(len(expected)):
+parameter env_vp ${i + 3 + len(expected)} (${max(1e-5, 1e-6 * expected[i][0])}, ${max(1e-5, 1e-6 * expected[i][1])}, ${max(1e-5, 1e-6 * expected[i][2])}, ${max(1e-5, 1e-6 * expected[i][3])})
+% endfor
+# "Not expected" value
+parameter env_vp ${3 + 2 * len(expected)} (${not_expected}, 0, 1, 0)
+draw rect ${x} ${y} ${w} ${h}
+% endfor
+
+% for [env, expected, not_expected, x, y, w, h] in test_vectors:
+relative probe rgb (${.5 * (x + w * .5) + .5}, ${.5 * (y + h * .5) + .5}) (0, 1, 0)
+% endfor
diff --git a/generated_tests/spec/nv_vertex_program1_1/binary_result.template b/generated_tests/spec/nv_vertex_program1_1/binary_result.template
new file mode 100644
index 000000000..69c40dad3
--- /dev/null
+++ b/generated_tests/spec/nv_vertex_program1_1/binary_result.template
@@ -0,0 +1,63 @@
+[require]
+GL_NV_vertex_program1_1
+
+[vertex program]
+!!VP1.1
+ # R11 it the boolean "fail" variable. This is stored in a high
+ # register index so that code to test any possible instruction will
+ # not stomp on it.
+
+ # c[0..2] are the operands for the instructions
+ # c[3..${3 + len(programs) - 1}] are the expected values
+ # c[${3 + len(programs)}..${3 + 2 * len(programs) - 1}] are the tolerance values
+ # c[${3 + 2 * len(programs)}] is { never expected value, 0, 1, 0 }
+% for i in range(len(programs)):
+ # Combination ${i}
+${programs[i]}
+% if i == 0:
+ # fail = any(greaterThanEqual(abs(value - expect), tolerance));
+% elif i == 1:
+ # fail = fail || any(greaterThanEqual(abs(value - expect), tolerance));
+% endif
+ SUB R0, R0, c[${3+i}];
+ ABS R0, R0;
+ SGE R0, R0, c[${3+len(programs)+i}];
+% if i == 0:
+ DP4 R11.x, R0, R0;
+% else:
+ DP4 R0.x, R0, R0;
+ ADD R11.x, R11.x, R0.x;
+% endif
+
+% endfor
+ MIN R11.x, R11.x, c[${3 + 2 * len(programs)}].z; # Clamp to [0,1]
+ SUB R11.y, c[${3 + 2 * len(programs)}].z, R11.x; # Logical not
+ MUL R1, R1.y, c[${3 + 2 * len(programs)}].yzyz; # Select green on !fail or...
+ MAD o[COL0], R11.x, c[${3 + 2 * len(programs)}].zyyz, R11; # ...red on fail.
+ MOV o[HPOS], v[OPOS];
+ END
+
+[test]
+clear color 0.5 0.5 0.5 0.5
+clear
+% for [env, expected, not_expected, x, y, w, h] in test_vectors:
+
+% for i in range(len(env)):
+parameter env_vp ${i} (${env[i][0]}, ${env[i][1]}, ${env[i][2]}, ${env[i][3]})
+% endfor
+# Expected values
+% for i in range(len(expected)):
+parameter env_vp ${i + 3} (${expected[i][0]}, ${expected[i][1]}, ${expected[i][2]}, ${expected[i][3]})
+% endfor
+# Tolerance values
+% for i in range(len(expected)):
+parameter env_vp ${i + 3 + len(expected)} (${max(1e-5, 1e-6 * expected[i][0])}, ${max(1e-5, 1e-6 * expected[i][1])}, ${max(1e-5, 1e-6 * expected[i][2])}, ${max(1e-5, 1e-6 * expected[i][3])})
+% endfor
+# "Not expected" value
+parameter env_vp ${3 + 2 * len(expected)} (${not_expected}, 0, 1, 0)
+draw rect ${x} ${y} ${w} ${h}
+% endfor
+
+% for [env, expected, not_expected, x, y, w, h] in test_vectors:
+relative probe rgb (${.5 * (x + w * .5) + .5}, ${.5 * (y + h * .5) + .5}) (0, 1, 0)
+% endfor