[Piglit] [PATCH] arb_texture_view: verify that 2darray can be sampled as cube

Dylan Baker baker.dylan.c at gmail.com
Wed Aug 20 19:30:09 PDT 2014


Presumably you want to add this to all.py so it gets run.

On Wednesday, August 20, 2014 09:55:33 PM Ilia Mirkin wrote:
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>  tests/spec/arb_texture_view/CMakeLists.gl.txt      |   1 +
>  .../sampling-2d-array-as-cubemap.c                 | 119 +++++++++++++++++++++
>  2 files changed, 120 insertions(+)
>  create mode 100644 tests/spec/arb_texture_view/sampling-2d-array-as-cubemap.c
> 
> diff --git a/tests/spec/arb_texture_view/CMakeLists.gl.txt b/tests/spec/arb_texture_view/CMakeLists.gl.txt
> index f939707..293c8d6 100644
> --- a/tests/spec/arb_texture_view/CMakeLists.gl.txt
> +++ b/tests/spec/arb_texture_view/CMakeLists.gl.txt
> @@ -26,5 +26,6 @@ piglit_add_executable(arb_texture_view-clear-into-view-2d-array clear-into-view-
>  piglit_add_executable(arb_texture_view-clear-into-view-layered clear-into-view-layered.c common.c)
>  piglit_add_executable(arb_texture_view-rendering-formats rendering-formats.c)
>  piglit_add_executable(arb_texture_view-copytexsubimage-layers copytexsubimage-layers.c common.c)
> +piglit_add_executable(arb_texture_view-sampling-2d-array-as-cubemap sampling-2d-array-as-cubemap.c)
>  
>  # vim: ft=cmake:
> diff --git a/tests/spec/arb_texture_view/sampling-2d-array-as-cubemap.c b/tests/spec/arb_texture_view/sampling-2d-array-as-cubemap.c
> new file mode 100644
> index 0000000..3661027
> --- /dev/null
> +++ b/tests/spec/arb_texture_view/sampling-2d-array-as-cubemap.c
> @@ -0,0 +1,119 @@
> +/*
> + * Copyright © 2014 Ilia Mirkin
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + *
> + * Author: Ilia Mirkin <imirkin at alum.mit.edu>
> + */
> +
> +/**
> + * \file sampling-2d-array-as-cubemap.c
> + * This tests that you can cast from a 2D Array texture to a Cubemap
> + * texture and sample from the Cubemap view.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +	config.supports_gl_compat_version = 30;
> +	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static float green[] = {0, 1, 0, 1};
> +static float red[] = {1, 0, 0, 1};
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +	GLboolean pass;
> +
> +	glViewport(0, 0, piglit_width, piglit_height);
> +	glClearColor(0.5, 0.5, 0.5, 0.5);
> +	glClear(GL_COLOR_BUFFER_BIT);
> +
> +	piglit_draw_rect(-1, -1, 2, 2);
> +
> +	pass = piglit_probe_rect_rgba(-1, -1, 2, 2, green);
> +
> +	piglit_present_results();
> +
> +	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +	char *vsCode;
> +	char *fsCode;
> +	int tex_loc_cube, prog_cube, l;
> +	GLuint tex_2DArray, tex_Cube;
> +
> +	piglit_require_extension("GL_ARB_texture_view");
> +	piglit_require_extension("GL_EXT_texture_array");
> +	piglit_require_extension("GL_ARB_texture_cube_map");
> +
> +	/* setup shaders and program object for Cube rendering */
> +	asprintf(&vsCode,
> +		 "void main()\n"
> +		 "{\n"
> +		 "    gl_Position = gl_Vertex;\n"
> +		 "}\n");
> +	asprintf(&fsCode,
> +		 "uniform samplerCube tex;\n"
> +		 "void main()\n"
> +		 "{\n"
> +		 "   vec4 color	 = textureCube(tex, vec3(-1, 0, 0));\n"
> +		 "   gl_FragColor = vec4(color.xyz, 1.0);\n"
> +		 "}\n");
> +	prog_cube = piglit_build_simple_program(vsCode, fsCode);
> +	free(fsCode);
> +	free(vsCode);
> +	tex_loc_cube = glGetUniformLocation(prog_cube, "tex");
> +
> +	glGenTextures(1, &tex_2DArray);
> +	glActiveTexture(GL_TEXTURE0);
> +	glBindTexture(GL_TEXTURE_2D_ARRAY, tex_2DArray);
> +
> +	glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 1, 1, 8);
> +
> +	/* load each array layer with a different color texture */
> +	for (l = 0; l < 8; l++) {
> +		glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, l,
> +				1, 1, 1, GL_RGBA, GL_FLOAT, red);
> +	}
> +	/* make array layer 3 have green */
> +	glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 3,
> +			1, 1, 1, GL_RGBA, GL_FLOAT, green);
> +
> +	glGenTextures(1, &tex_Cube);
> +	/* the texture view starts at layer 2, so face 1 (-X) will have green */
> +	glTextureView(tex_Cube, GL_TEXTURE_CUBE_MAP, tex_2DArray, GL_RGBA8,
> +		      0, 1, 2, 6);
> +	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
> +	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
> +
> +	glActiveTexture(GL_TEXTURE0);
> +	glBindTexture(GL_TEXTURE_CUBE_MAP, tex_Cube);
> +
> +	glUseProgram(prog_cube);
> +	glUniform1i(tex_loc_cube, 0);
> +}
> -- 
> 1.8.5.5
> 
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140820/6c6ccfa1/attachment-0001.sig>


More information about the Piglit mailing list