[Mesa-dev] [PATCH] shader-db: simplify and improve SSO handling
Kenneth Graunke
kenneth at whitecape.org
Fri Jul 20 09:39:20 UTC 2018
On Wednesday, July 18, 2018 4:22:41 AM PDT Timothy Arceri wrote:
> This does two things:
>
> 1. Allows cross shader optimisations to be preformed on SSO
> programs that contain more than one stage (seems like I
> don't have any of these in my shader-db collection).
>
> 2. Allows us to write compilation errors to stderr. With this
> change I discovered a Deus Ex: MD shader was failing to
> compile (I've reported it to Feral).
> ---
> run.c | 23 ++++-------------------
> 1 file changed, 4 insertions(+), 19 deletions(-)
>
> diff --git a/run.c b/run.c
> index fdb610d..aa64d2c 100644
> --- a/run.c
> +++ b/run.c
> @@ -809,27 +809,12 @@ main(int argc, char **argv)
> if (num_shaders == 1 && type != TYPE_VP && type != TYPE_FP)
> use_separate_shader_objects = true;
>
> - if (use_separate_shader_objects) {
> - for (unsigned i = 0; i < num_shaders; i++) {
> - const char *const_text;
> - unsigned size = shader[i].length + 1;
> - /* Using alloca crashes in the GLSL compiler. */
> - char *text = malloc(size);
> - memset(text, 0, size);
> -
> - /* Make it zero-terminated. */
> - memcpy(text, shader[i].text, shader[i].length);
> - text[shader[i].length] = 0;
> -
> - const_text = text;
> - GLuint prog = glCreateShaderProgramv(shader[i].type, 1,
> - &const_text);
> - glDeleteProgram(prog);
> - free(text);
> - }
> - } else if (type == TYPE_CORE || type == TYPE_COMPAT || type == TYPE_ES) {
> + if (type == TYPE_CORE || type == TYPE_COMPAT || type == TYPE_ES) {
> GLuint prog = glCreateProgram();
>
> + if (use_separate_shader_objects)
> + glProgramParameteri(prog, GL_PROGRAM_SEPARABLE, GL_TRUE);
> +
> for (unsigned i = 0; i < num_shaders; i++) {
> GLuint s = glCreateShader(shader[i].type);
> glShaderSource(s, 1, &shader[i].text, &shader[i].length);
>
This looks good to me. It looks like MESA_SHADER_CAPTURE_PATH would
dump multiple shaders to the same file, with "SSO ENABLED" set, if a
SSO program contained multiple shader stages. At which point, we'd
want to compile them together...which your patch arranges for.
If there's only one stage in a program, then your patch should be
equivalent.
Also, it's much less code.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20180720/6402a263/attachment.sig>
More information about the mesa-dev
mailing list