[Piglit] [PATCH 2/2] sso: Add a test that passes data using the legacy gl_TexCoord varyings.

Ian Romanick idr at freedesktop.org
Wed Sep 23 12:17:38 PDT 2015


On 09/11/2015 11:52 PM, Kenneth Graunke wrote:
> In compatiblity profiles, the GL_ARB_separate_shader_objects extension
> allows passing data via built-in varyings such as gl_TexCoord[].  We
> don't do compatibility profiles, but we do expose SSO in legacy GL
> contexts and allow it with GLSL 1.30.
> 
> This test actually tries to do that in a rendering test.
> 
> This is particularly interesting because Mesa's VARYING_SLOT_* enums
> handle built-in varyings different than generic ones.  I wanted to be
> able to see how those came through; this provides a simple example.
> 
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  .../arb_separate_shader_objects/CMakeLists.gl.txt  |   1 +
>  .../arb_separate_shader_objects/compat-builtins.c  | 111 +++++++++++++++++++++
>  2 files changed, 112 insertions(+)
>  create mode 100644 tests/spec/arb_separate_shader_objects/compat-builtins.c
> 
> diff --git a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt
> index f7feb27..b596f67 100644
> --- a/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt
> +++ b/tests/spec/arb_separate_shader_objects/CMakeLists.gl.txt
> @@ -12,6 +12,7 @@ link_libraries (
>  piglit_add_executable (arb_separate_shader_object-400-combinations 400-combinations.c)
>  piglit_add_executable (arb_separate_shader_object-active-sampler-conflict active-sampler-conflict.c)
>  piglit_add_executable (arb_separate_shader_object-ActiveShaderProgram-invalid-program ActiveShaderProgram-invalid-program.c)
> +piglit_add_executable (arb_separate_shader_object-compat-builtins compat-builtins.c)
>  piglit_add_executable (arb_separate_shader_object-GetProgramPipelineiv GetProgramPipelineiv.c)
>  piglit_add_executable (arb_separate_shader_object-IsProgramPipeline IsProgramPipeline.c)
>  piglit_add_executable (arb_separate_shader_object-ProgramUniform-coverage ProgramUniform-coverage.c)
> diff --git a/tests/spec/arb_separate_shader_objects/compat-builtins.c b/tests/spec/arb_separate_shader_objects/compat-builtins.c
> new file mode 100644
> index 0000000..e84b746
> --- /dev/null
> +++ b/tests/spec/arb_separate_shader_objects/compat-builtins.c
> @@ -0,0 +1,111 @@
> +/*
> + * Copyright © 2015 Intel Corporation
> + * Copyright © 2015 Advanced Micro Devices, Inc.
> + *
> + * 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.
> + */
> +
> +/**
> + */

Something missing here? :)

> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +	config.supports_gl_compat_version = 30;

Other than using "in" and "out", this doesn't really need anything from
GLSL 1.30, does it?

> +	config.supports_gl_core_version = 0;
> +	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static GLuint pipeline;
> +
> +static const char *vs_code =
> +	"#version 130\n"
> +	"#extension GL_ARB_separate_shader_objects: require\n"
> +	"#extension GL_ARB_explicit_attrib_location: require\n"

Don't need GL_ARB_explicit_attrib_location here or below.

> +	"\n"
> +	"out vec4 gl_TexCoord[2];\n"
> +	"\n"
> +	"void main()\n"
> +	"{\n"
> +	"    gl_Position = gl_Vertex;\n"
> +	"    gl_TexCoord[0] = vec4(0.1, 0.2, 0.3, 0.4);\n"
> +	"    gl_TexCoord[1] = vec4(0.01, 0.02, 0.03, 0.04);\n"
> +	"}\n"
> +	;
> +
> +static const char *fs_code =
> +	"#version 130\n"
> +	"#extension GL_ARB_separate_shader_objects: require\n"
> +	"#extension GL_ARB_explicit_attrib_location: require\n"
> +	"\n"
> +	"in vec4 gl_TexCoord[2];\n"
> +	"\n"
> +	"void main()\n"
> +	"{\n"
> +	"    gl_FragColor = gl_TexCoord[0] + gl_TexCoord[1];\n"

This probably can't suffer from the "out of order" problem, but I'd
still be tempted to use the cross-product method from
rendezvous_by_location.c. *shrug*

> +	"}\n"
> +	;
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +	static const float expected[] = {
> +		0.11, 0.22, 0.33, 0.44
> +	};
> +	bool pass;
> +
> +	glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
> +	glClear(GL_COLOR_BUFFER_BIT);
> +
> +	glBindProgramPipeline(pipeline);
> +	piglit_draw_rect(-1, -1, 2, 2);
> +
> +	pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height,
> +				      expected);
> +
> +	piglit_present_results();
> +	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +void piglit_init(int argc, char **argv)
> +{
> +	GLuint vs_prog, fs_prog;
> +
> +	piglit_require_extension("GL_ARB_separate_shader_objects");
> +	piglit_require_GLSL_version(130);

This check is unnecessary.  If you reduce the GL version requirement,
you may need to replace this with

	piglit_require_vertex_shader();
	piglit_require_fragment_shader();

> +
> +	vs_prog = glCreateShaderProgramv(GL_VERTEX_SHADER, 1,
> +					 (const GLchar *const*)&vs_code);
                                                             ^
Missing space.

If you fix this, reduce the GL requirement, remove the unnecessary
#extension lines, this patch is

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

> +	piglit_link_check_status(vs_prog);
> +
> +	fs_prog = glCreateShaderProgramv(GL_FRAGMENT_SHADER, 1,
> +					 (const GLchar *const *)&fs_code);
> +	piglit_link_check_status(fs_prog);
> +
> +	glGenProgramPipelines(1, &pipeline);
> +	glUseProgramStages(pipeline, GL_VERTEX_SHADER_BIT, vs_prog);
> +	glUseProgramStages(pipeline, GL_FRAGMENT_SHADER_BIT, fs_prog);
> +	piglit_program_pipeline_check_status(pipeline);
> +
> +	if (!piglit_check_gl_error(0))
> +		piglit_report_result(PIGLIT_FAIL);
> +}
> 



More information about the Piglit mailing list