aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Forbes <chrisf@ijw.co.nz>2013-01-05 19:28:27 +1300
committerChris Forbes <chrisf@ijw.co.nz>2013-03-03 21:03:21 +1300
commit195b61ef8f86a5811715109469b495ab1b13d1cb (patch)
tree75a20cd844c0cf0a34f05e8c26467a3a8dedd380
parent15aa37e12946c13aede64bc995527fa85b8c7087 (diff)
arb_texture_multisample: add new sampler targets to textureSize
Covers use of the textureSize() glsl builtin with multisample samplers Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
-rw-r--r--tests/all.tests6
-rw-r--r--tests/texturing/shaders/common.c37
-rw-r--r--tests/texturing/shaders/textureSize.c49
3 files changed, 74 insertions, 18 deletions
diff --git a/tests/all.tests b/tests/all.tests
index f6488c04..3470ee13 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -864,6 +864,8 @@ spec['ARB_point_sprite'] = arb_point_sprite
add_plain_test(arb_point_sprite, 'point-sprite')
# Group ARB_texture_multisample
+samplers_atm = ['sampler2DMS', 'isampler2DMS', 'usampler2DMS',
+ 'sampler2DMSArray', 'isampler2DMSArray', 'usampler2DMSArray']
arb_texture_multisample = Group()
spec['ARB_texture_multisample'] = arb_texture_multisample
add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-minmax')
@@ -876,6 +878,10 @@ add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-sample-mas
add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-sample-mask-value')
add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-sample-mask-execution')
add_concurrent_test(arb_texture_multisample, 'arb_texture_multisample-sample-mask-execution -tex')
+for stage in ['vs', 'fs']:
+ # textureSize():
+ for sampler in samplers_atm:
+ spec['ARB_texture_multisample/textureSize/' + stage + '-textureSize-' + sampler] = concurrent_test('textureSize ' + stage + ' ' + sampler)
# Group AMD_shader_stencil_export
spec['AMD_shader_stencil_export'] = Group()
diff --git a/tests/texturing/shaders/common.c b/tests/texturing/shaders/common.c
index aa69a5db..120e4247 100644
--- a/tests/texturing/shaders/common.c
+++ b/tests/texturing/shaders/common.c
@@ -88,6 +88,23 @@ upload_miplevel_data(GLenum target, int level, void *level_image)
glTexBuffer(GL_TEXTURE_BUFFER, internal_format, bo);
break;
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4,
+ internal_format,
+ level_size[level][0],
+ level_size[level][1],
+ GL_TRUE);
+ break;
+
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 4,
+ internal_format,
+ level_size[level][0],
+ level_size[level][1],
+ level_size[level][2],
+ GL_TRUE);
+ break;
+
default:
assert(!"Not implemented yet.");
break;
@@ -134,7 +151,9 @@ compute_miplevel_info()
miplevels = (int) log2f(max_dimension) + 1;
if (sampler.target == GL_TEXTURE_RECTANGLE ||
- sampler.target == GL_TEXTURE_BUFFER)
+ sampler.target == GL_TEXTURE_BUFFER ||
+ sampler.target == GL_TEXTURE_2D_MULTISAMPLE ||
+ sampler.target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
miplevels = 1;
/* Compute the size of each miplevel */
@@ -159,7 +178,9 @@ has_height()
return sampler.target == GL_TEXTURE_2D ||
sampler.target == GL_TEXTURE_3D ||
sampler.target == GL_TEXTURE_2D_ARRAY ||
- sampler.target == GL_TEXTURE_RECTANGLE;
+ sampler.target == GL_TEXTURE_RECTANGLE ||
+ sampler.target == GL_TEXTURE_2D_MULTISAMPLE ||
+ sampler.target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
}
bool
@@ -173,7 +194,8 @@ is_array_sampler()
{
return sampler.target == GL_TEXTURE_1D_ARRAY ||
sampler.target == GL_TEXTURE_2D_ARRAY ||
- sampler.target == GL_TEXTURE_CUBE_MAP_ARRAY;
+ sampler.target == GL_TEXTURE_CUBE_MAP_ARRAY ||
+ sampler.target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY;
}
bool
@@ -207,6 +229,8 @@ select_sampler(const char *name)
{ "sampler2DArray", GL_SAMPLER_2D_ARRAY, GL_TEXTURE_2D_ARRAY },
{ "samplerCubeArray", GL_SAMPLER_CUBE_MAP_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY },
{ "samplerBuffer", GL_SAMPLER_BUFFER, GL_TEXTURE_BUFFER },
+ { "sampler2DMS", GL_SAMPLER_2D_MULTISAMPLE, GL_TEXTURE_2D_MULTISAMPLE },
+ { "sampler2DMSArray", GL_SAMPLER_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_2D_MULTISAMPLE_ARRAY },
{ "sampler1DShadow", GL_SAMPLER_1D_SHADOW, GL_TEXTURE_1D },
{ "sampler2DShadow", GL_SAMPLER_2D_SHADOW, GL_TEXTURE_2D },
@@ -225,6 +249,8 @@ select_sampler(const char *name)
{ "isampler2DArray", GL_INT_SAMPLER_2D_ARRAY, GL_TEXTURE_2D_ARRAY },
{ "isamplerCubeArray", GL_INT_SAMPLER_CUBE_MAP_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY },
{ "isamplerBuffer", GL_INT_SAMPLER_BUFFER, GL_TEXTURE_BUFFER },
+ { "isampler2DMS", GL_INT_SAMPLER_2D_MULTISAMPLE, GL_TEXTURE_2D_MULTISAMPLE },
+ { "isampler2DMSArray", GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_2D_MULTISAMPLE_ARRAY },
{ "usampler1D", GL_UNSIGNED_INT_SAMPLER_1D, GL_TEXTURE_1D },
{ "usampler2D", GL_UNSIGNED_INT_SAMPLER_2D, GL_TEXTURE_2D },
@@ -235,6 +261,8 @@ select_sampler(const char *name)
{ "usampler2DArray", GL_UNSIGNED_INT_SAMPLER_2D_ARRAY, GL_TEXTURE_2D_ARRAY },
{ "usamplerCubeArray", GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY },
{ "usamplerBuffer", GL_UNSIGNED_INT_SAMPLER_BUFFER, GL_TEXTURE_BUFFER },
+ { "usampler2DMS", GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE, GL_TEXTURE_2D_MULTISAMPLE },
+ { "usampler2DMSArray", GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY, GL_TEXTURE_2D_MULTISAMPLE_ARRAY },
};
for (i = 0; i < ARRAY_SIZE(samplers); i++) {
@@ -321,6 +349,9 @@ require_GL_features(enum shader_target test_stage)
case GL_TEXTURE_BUFFER:
piglit_require_extension("GL_ARB_texture_buffer_object");
break;
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ piglit_require_extension("GL_ARB_texture_multisample");
}
/* If testing in the VS, check for VS texture units */
diff --git a/tests/texturing/shaders/textureSize.c b/tests/texturing/shaders/textureSize.c
index 6adca7fe..eef3855a 100644
--- a/tests/texturing/shaders/textureSize.c
+++ b/tests/texturing/shaders/textureSize.c
@@ -60,7 +60,7 @@ PIGLIT_GL_TEST_CONFIG_END
static int lod_location;
static int vertex_location;
-static char *cube_map_array_extension = "";
+static char *extension = "";
/**
* Returns the number of components expected from textureSize().
@@ -76,10 +76,12 @@ sampler_size()
case GL_TEXTURE_1D_ARRAY:
case GL_TEXTURE_CUBE_MAP:
case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_2D_MULTISAMPLE:
return 2;
case GL_TEXTURE_3D:
case GL_TEXTURE_2D_ARRAY:
case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
return 3;
default:
assert(!"Should not get here.");
@@ -181,10 +183,12 @@ generate_texture()
glGenTextures(1, &tex);
glBindTexture(target, tex);
- if (target == GL_TEXTURE_BUFFER) {
- /* Texture buffers only use texelFetch() and
- * textureSize(), so setting the filter parameters on
- * them is invalid.
+ if (target == GL_TEXTURE_BUFFER ||
+ target == GL_TEXTURE_2D_MULTISAMPLE ||
+ target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY) {
+ /* Texture buffers, multisample textures and multisample
+ * texture arrays only use texelFetch() and textureSize(),
+ * so setting the filter parameters on them is invalid.
*/
} else if (target == GL_TEXTURE_RECTANGLE) {
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -195,7 +199,9 @@ generate_texture()
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
- if (target != GL_TEXTURE_BUFFER) {
+ if (target != GL_TEXTURE_BUFFER &&
+ target != GL_TEXTURE_2D_MULTISAMPLE &&
+ target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY) {
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
@@ -212,6 +218,19 @@ generate_texture()
}
}
+bool
+has_lod(void)
+{
+ switch (sampler.target) {
+ case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_BUFFER:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ return false;
+ default:
+ return true;
+ }
+}
int
generate_GLSL(enum shader_target test_stage)
@@ -226,13 +245,10 @@ generate_GLSL(enum shader_target test_stage)
const int size = sampler_size();
/* The GLSL 1.40 sampler2DRect/samplerBuffer samplers don't
- * take a lod argument.
+ * take a lod argument. Neither do ARB_texture_multisample's
+ * sampler2DMS/sampler2DMSArray samplers.
*/
- if (sampler.target == GL_TEXTURE_RECTANGLE ||
- sampler.target == GL_TEXTURE_BUFFER)
- lod_arg = "";
- else
- lod_arg = ", lod";
+ lod_arg = has_lod() ? ", lod" : "";
switch (test_stage) {
case VS:
@@ -248,7 +264,7 @@ generate_GLSL(enum shader_target test_stage)
" size = textureSize(tex%s);\n"
" gl_Position = vertex;\n"
"}\n",
- shader_version, cube_map_array_extension, sampler.name, size, lod_arg);
+ shader_version, extension, sampler.name, size, lod_arg);
asprintf(&fs_code,
"#version %d\n"
"#define ivec1 int\n"
@@ -279,7 +295,7 @@ generate_GLSL(enum shader_target test_stage)
" ivec%d size = textureSize(tex%s);\n"
" gl_FragColor = vec4(0.01 * size,%s 1);\n"
"}\n",
- shader_version, cube_map_array_extension, sampler.name, size, lod_arg,
+ shader_version, extension, sampler.name, size, lod_arg,
zeroes[3 - size]);
break;
default:
@@ -342,7 +358,10 @@ piglit_init(int argc, char **argv)
require_GL_features(test_stage);
if (sampler.target == GL_TEXTURE_CUBE_MAP_ARRAY)
- cube_map_array_extension = "#extension GL_ARB_texture_cube_map_array : enable\n";
+ extension = "#extension GL_ARB_texture_cube_map_array : enable\n";
+ if (sampler.target == GL_TEXTURE_2D_MULTISAMPLE
+ || sampler.target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
+ extension = "#extension GL_ARB_texture_multisample : enable\n";
prog = generate_GLSL(test_stage);
if (!prog)