[Piglit] [PATCH V4 1/5] shader_runner: Add basic SSO support to shader runner
Kenneth Graunke
kenneth at whitecape.org
Wed Dec 9 15:01:02 PST 2015
On Monday, December 07, 2015 11:06:33 AM Timothy Arceri wrote:
> This sets up the basics for using SSO with shader runner. This will
> only support vertex and fragment shaders but is easily extended.
>
> V2: delete pipeline in cleanup code rather than calling gen again,
> output error message when SSO fails to link
>
> V3: add new option to [require] to allow separate shader objects to be
> enabled for the entire test.
>
> V4:
> - remove infrastructure left over from V2 (as suggested by Ken)
> - rework linking so that we dont use glCreateShaderProgram() this
> allows us to support multiple shaders per stage.
>
> Example use:
> [require]
> SSO ENABLED
>
> Adding the ENABLED field rather than just using SSO will allow us to use
> DISABLED in future should we ever add the ability to automatically run
> all tests as SSO.
>
> Example shader:
>
> [require]
> GLSL >= 1.50
> SSO ENABLED
>
> [vertex shader]
>
> layout(location = 0) in vec4 piglit_vertex;
>
> layout(location = 2) out vec3 a;
> layout(location = 3) out vec3 b;
>
> void main()
> {
> gl_Position = piglit_vertex;
> a = vec3(0, 0, 1);
> b = vec3(1, 0, 0);
> }
>
> [fragment shader]
>
> layout(location = 0) out vec4 out_color;
>
> layout(location = 2) in vec3 b; /* should get vec3(0, 0, 1) */
> layout(location = 3) in vec3 a; /* should get vec3(1, 0, 0) */
>
> void main()
> {
> out_color = vec4(cross(b, a), 1);
> }
>
> [test]
> draw rect -1 -1 2 2
> probe all rgb 0 1 0
>
> Cc: Kenneth Graunke <kenneth at whitecape.org>
> ---
> tests/shaders/shader_runner.c | 158 +++++++++++++++++++++++++++++-------------
> 1 file changed, 111 insertions(+), 47 deletions(-)
>
> diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
> index eeb1aac..da21af2 100644
> --- a/tests/shaders/shader_runner.c
> +++ b/tests/shaders/shader_runner.c
> @@ -123,10 +123,12 @@ GLint shader_string_size;
> const char *vertex_data_start = NULL;
> const char *vertex_data_end = NULL;
> GLuint prog;
> +GLuint pipeline;
> size_t num_vbo_rows = 0;
> bool vbo_present = false;
> bool link_ok = false;
> bool prog_in_use = false;
> +bool sso_in_use = false;
> GLchar *prog_err_info = NULL;
> GLuint vao = 0;
> GLuint fbo = 0;
> @@ -480,6 +482,44 @@ compile_and_bind_program(GLenum target, const char *start, int len)
> prog_in_use = true;
> }
>
> +void
> +link_sso(GLenum target)
> +{
> + GLint ok;
> +
> + glLinkProgram(prog);
> +
> + glGetProgramiv(prog, GL_LINK_STATUS, &ok);
> + if (ok) {
> + link_ok = true;
> + } else {
> + GLint size;
> +
> + glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
> + prog_err_info = malloc(size);
> +
> + glGetProgramInfoLog(prog, size, NULL, prog_err_info);
> +
> + fprintf(stderr, "SSO glLinkProgram(%s) failed: %s\n",
> + target_to_short_name(target),
> + prog_err_info);
> +
> + free(prog_err_info);
> + piglit_report_result(PIGLIT_FAIL);
> +
> + return;
> + }
> +
> + switch (target) {
> + case GL_VERTEX_SHADER:
> + glUseProgramStages(pipeline, GL_VERTEX_SHADER_BIT, prog);
> + break;
> + case GL_FRAGMENT_SHADER:
> + glUseProgramStages(pipeline, GL_FRAGMENT_SHADER_BIT, prog);
> + break;
May as well add the rest of the shader stages here, too?
Either way,
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20151209/d4487a6b/attachment.sig>
More information about the Piglit
mailing list