[Piglit] [PATCH] textureGather: add textureGatherOffsets to execution test (v2.1)
Dave Airlie
airlied at gmail.com
Sun Feb 9 18:37:23 PST 2014
From: Dave Airlie <airlied at redhat.com>
Test for checking textureGatherOffsets from ARB_gpu_shader5 works, this
is tested on the nvidia binary driver and passes.
also add to all.py.
v2.1 fix VS bits + whitespace
Cc: Chris Forbes <chrisf at ijw.co.nz>
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
tests/all.py | 8 ++--
tests/texturing/shaders/textureGather.c | 73 ++++++++++++++++++++++++---------
2 files changed, 58 insertions(+), 23 deletions(-)
diff --git a/tests/all.py b/tests/all.py
index 68186d1..ba34543 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1694,7 +1694,7 @@ for stage in ['vs', 'fs']:
for comps in ['r', 'rg', 'rgb', 'rgba']:
for cs in [0, 1, 2, 3][:len(comps)]:
for sampler in ['2D', '2DArray', 'Cube', 'CubeArray', '2DRect']:
- for func in ['textureGather'] if 'Cube' in sampler else ['textureGather', 'textureGatherOffset']:
+ for func in ['textureGather'] if 'Cube' in sampler else ['textureGather', 'textureGatherOffset', 'textureGatherOffsets' ]:
testname = '%s/%s-%s-%s-%s-%s' % (
func, stage, comps,
cs,
@@ -1702,7 +1702,7 @@ for stage in ['vs', 'fs']:
address_mode = 'clamp' if sampler == '2DRect' else 'repeat'
cmd = 'textureGather %s %s %s %s %s %s %s' % (
stage,
- 'nonconst' if func == 'textureGatherOffset' else '',
+ 'offsets' if func == 'textureGatherOffsets' else 'nonconst' if func == 'textureGatherOffset' else '',
comps, cs, type, sampler, address_mode
)
arb_gpu_shader5[testname] = concurrent_test(cmd)
@@ -1721,12 +1721,12 @@ for stage in ['vs', 'fs']:
arb_gpu_shader5[testname] = concurrent_test(cmd)
# test shadow samplers
for sampler in ['2D', '2DArray', 'Cube', 'CubeArray', '2DRect']:
- for func in ['textureGather'] if 'Cube' in sampler else ['textureGather', 'textureGatherOffset']:
+ for func in ['textureGather'] if 'Cube' in sampler else ['textureGather', 'textureGatherOffset', 'textureGatherOffsets' ]:
testname = '%s/%s-r-none-shadow-%s' % (func, stage, sampler)
address_mode = 'clamp' if sampler == '2DRect' else 'repeat'
cmd = 'textureGather %s shadow r %s %s %s' % (
stage,
- 'nonconst' if func == 'textureGatherOffset' else '',
+ 'offsets' if func == 'textureGatherOffsets' else 'nonconst' if func == 'textureGatherOffset' else '',
sampler,
address_mode)
arb_gpu_shader5[testname] = concurrent_test(cmd)
diff --git a/tests/texturing/shaders/textureGather.c b/tests/texturing/shaders/textureGather.c
index df8781a..d10ada5 100644
--- a/tests/texturing/shaders/textureGather.c
+++ b/tests/texturing/shaders/textureGather.c
@@ -18,6 +18,7 @@ enum { UNORM_T, FLOAT_T, INT_T, UINT_T, SHADOW_T, NUM_COMPTYPES } comptype = UNO
enum { SAMPLER_2D, SAMPLER_2DARRAY, SAMPLER_CUBE, SAMPLER_CUBEARRAY, SAMPLER_2DRECT } sampler = SAMPLER_2D;
bool use_offset = false;
bool use_nonconst = false;
+bool use_offsets = false;
int components = 0;
int comp_select = -1;
@@ -84,7 +85,7 @@ piglit_display(void)
*/
static unsigned char
-pixel_value(int i, int j)
+pixel_value(int i, int j, int offset_sel)
{
if (swizzle == ZERO)
return 0;
@@ -95,6 +96,25 @@ pixel_value(int i, int j)
/* apply texel offset */
i += -8;
j += 7;
+ } else if (use_offsets) {
+ switch (offset_sel) {
+ case 0:
+ i += -8;
+ j += 7;
+ break;
+ case 1:
+ i += 7;
+ j += -8;
+ break;
+ case 2:
+ i += 3;
+ j += 3;
+ break;
+ case 3:
+ i += -3;
+ j += -3;
+ break;
+ }
}
if (address_mode == GL_REPEAT) {
@@ -146,16 +166,30 @@ make_expected(void)
for (j = 0; j < TEXTURE_HEIGHT; j++)
for (i = 0; i < TEXTURE_WIDTH; i++) {
if (comptype == SHADOW_T) {
- *pe++ = shadow_compare(norm_value(pixel_value(i, j + 1)));
- *pe++ = shadow_compare(norm_value(pixel_value(i + 1, j + 1)));
- *pe++ = shadow_compare(norm_value(pixel_value(i + 1, j)));
- *pe++ = shadow_compare(norm_value(pixel_value(i, j)));
+ if (use_offsets) {
+ *pe++ = shadow_compare(norm_value(pixel_value(i, j, 0)));
+ *pe++ = shadow_compare(norm_value(pixel_value(i, j, 1)));
+ *pe++ = shadow_compare(norm_value(pixel_value(i, j, 2)));
+ *pe++ = shadow_compare(norm_value(pixel_value(i, j, 3)));
+ } else {
+ *pe++ = shadow_compare(norm_value(pixel_value(i, j + 1, 0)));
+ *pe++ = shadow_compare(norm_value(pixel_value(i + 1, j + 1, 0)));
+ *pe++ = shadow_compare(norm_value(pixel_value(i + 1, j, 0)));
+ *pe++ = shadow_compare(norm_value(pixel_value(i, j, 0)));
+ }
}
else {
- *pe++ = norm_value(pixel_value(i, j + 1));
- *pe++ = norm_value(pixel_value(i + 1, j + 1));
- *pe++ = norm_value(pixel_value(i + 1, j));
- *pe++ = norm_value(pixel_value(i, j));
+ if (use_offsets) {
+ *pe++ = norm_value(pixel_value(i, j, 0));
+ *pe++ = norm_value(pixel_value(i, j, 1));
+ *pe++ = norm_value(pixel_value(i, j, 2));
+ *pe++ = norm_value(pixel_value(i, j, 3));
+ } else {
+ *pe++ = norm_value(pixel_value(i, j + 1, 0));
+ *pe++ = norm_value(pixel_value(i + 1, j + 1, 0));
+ *pe++ = norm_value(pixel_value(i + 1, j, 0));
+ *pe++ = norm_value(pixel_value(i, j, 0));
+ }
}
}
}
@@ -212,7 +246,7 @@ do_requires(void)
if (sampler == SAMPLER_CUBEARRAY)
piglit_require_extension("GL_ARB_texture_cube_map_array");
- if (use_offset && (sampler == SAMPLER_CUBE || sampler == SAMPLER_CUBEARRAY)) {
+ if ((use_offsets || use_offset) && (sampler == SAMPLER_CUBE || sampler == SAMPLER_CUBEARRAY)) {
printf("Offset is not supported with cube or cube array samplers.\n");
piglit_report_result(PIGLIT_SKIP);
}
@@ -231,7 +265,7 @@ do_requires(void)
* or use non-constant offsets, or use shadow comparitor, or
* use gsampler2DRect, check that we have ARB_gpu_shader5
*/
- if (comp_select != -1 || use_nonconst || comptype == SHADOW_T || sampler == SAMPLER_2DRECT)
+ if (comp_select != -1 || use_offsets || use_nonconst || comptype == SHADOW_T || sampler == SAMPLER_2DRECT)
piglit_require_extension("GL_ARB_gpu_shader5");
/* if rect sampler, repeat is not available */
@@ -364,7 +398,7 @@ do_shader_setup(void)
"gl_FragCoord.xy", /* 2drect */
};
char *comp_expr[] = {"", ", 0", ", 1", ", 2", ", 3"};
- bool need_shader5 = (comp_select != -1) || use_nonconst || (comptype == SHADOW_T) || sampler == SAMPLER_2DRECT;
+ bool need_shader5 = (comp_select != -1) || use_offsets || use_nonconst || (comptype == SHADOW_T) || sampler == SAMPLER_2DRECT;
if (stage == VS) {
asprintf(&vs_code, "#version %s\n"
@@ -388,12 +422,12 @@ do_shader_setup(void)
prefix[comptype],
samplersuffix[sampler],
comptype == SHADOW_T ? "Shadow" : "",
- use_nonconst ? "uniform ivec2 o1,o2;\n" : "",
+ use_offsets ? "const ivec2 osets[4] = ivec2[4](ivec2(-8,7), ivec2(7, -8), ivec2(3, 3), ivec2(-3, -3));\n" :use_nonconst ? "uniform ivec2 o1,o2;\n" : "",
swizzle == ONE ? scale[0] : scale[comptype],
- use_offset ? "Offset" : "",
+ use_offsets ? "Offsets" : (use_offset ? "Offset" : ""),
vs_tc_expr[sampler],
comptype == SHADOW_T ? ", 0.5" : "",
- use_nonconst ? ", o1+o2" : use_offset ? ", ivec2(-8,7)" : "",
+ use_offsets ? ", osets" : use_nonconst ? ", o1+o2" : use_offset ? ", ivec2(-8,7)" : "",
comp_expr[1 + comp_select]);
asprintf(&fs_code,
"#version %s\n"
@@ -433,12 +467,12 @@ do_shader_setup(void)
prefix[comptype],
samplersuffix[sampler],
comptype == SHADOW_T ? "Shadow" : "",
- use_nonconst ? "uniform ivec2 o1,o2;\n" : "",
+ use_offsets ? "const ivec2 osets[4] = ivec2[4](ivec2(-8,7), ivec2(7, -8), ivec2(3, 3), ivec2(-3, -3));\n" :use_nonconst ? "uniform ivec2 o1,o2;\n" : "",
swizzle == ONE ? scale[0] : scale[comptype],
- use_offset ? "Offset" : "",
+ use_offsets ? "Offsets" : (use_offset ? "Offset" : ""),
fs_tc_expr[sampler],
comptype == SHADOW_T ? ", 0.5" : "",
- use_nonconst ? ", o1+o2" : use_offset ? ", ivec2(-8,7)" : "",
+ use_offsets ? ", osets" : use_nonconst ? ", o1+o2" : use_offset ? ", ivec2(-8,7)" : "",
comp_expr[1 + comp_select]);
}
@@ -476,7 +510,7 @@ do_geometry_setup(void)
void
fail_with_usage(void)
{
- printf("Usage: textureGather <stage> [offset] [nonconst] <components> <swizzle> <comptype> <sampler> <compselect> <addressmode>\n"
+ printf("Usage: textureGather <stage> [offset] [nonconst] [offsets] <components> <swizzle> <comptype> <sampler> <compselect> <addressmode>\n"
" stage = vs|fs\n"
" components = r|rg|rgb|rgba\n"
" swizzle = red|green|blue|alpha|zero|one\n"
@@ -497,6 +531,7 @@ piglit_init(int argc, char **argv)
else if (!strcmp(opt, "fs")) stage = FS;
else if (!strcmp(opt, "offset")) use_offset = true;
else if (!strcmp(opt, "nonconst")) use_nonconst = true;
+ else if (!strcmp(opt, "offsets")) use_offsets = true;
else if (!strcmp(opt, "r")) components = 1;
else if (!strcmp(opt, "rg")) components = 2;
else if (!strcmp(opt, "rgb")) components = 3;
--
1.8.5.3
More information about the Piglit
mailing list