Commit 372703f3 authored by Timothy Arceri's avatar Timothy Arceri

shader-db: simplify and improve SSO handling

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).
Reviewed-by: Kenneth Graunke's avatarKenneth Graunke <kenneth@whitecape.org>
parent 109520ba
...@@ -881,34 +881,13 @@ main(int argc, char **argv) ...@@ -881,34 +881,13 @@ main(int argc, char **argv)
if (num_shaders == 1 && type != TYPE_VP && type != TYPE_FP) if (num_shaders == 1 && type != TYPE_VP && type != TYPE_FP)
use_separate_shader_objects = true; use_separate_shader_objects = true;
if (use_separate_shader_objects) { if (type == TYPE_CORE || type == TYPE_COMPAT || type == TYPE_ES) {
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);
if (generate_prog_bin)
fprintf(stderr,
"Currently, program binary generation "
"doesn't support SSO.\n");
glDeleteProgram(prog);
free(text);
}
} else if (type == TYPE_CORE || type == TYPE_COMPAT || type == TYPE_ES) {
GLuint prog = glCreateProgram(); GLuint prog = glCreateProgram();
GLint param; GLint param;
if (use_separate_shader_objects)
glProgramParameteri(prog, GL_PROGRAM_SEPARABLE, GL_TRUE);
for (unsigned i = 0; i < num_shaders; i++) { for (unsigned i = 0; i < num_shaders; i++) {
GLuint s = glCreateShader(shader[i].type); GLuint s = glCreateShader(shader[i].type);
glShaderSource(s, 1, &shader[i].text, &shader[i].length); glShaderSource(s, 1, &shader[i].text, &shader[i].length);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment