shader: rework shader patching to be able to patch various IOs with the same sid

With enhanced layouts and input arrays enabled it may happen that more then
one shader IO variable have the same sid, and since the other parts of the
glsl_name are not available at this point rewrite the patching routine to
be able to patch more than one instance of a delaration with the same
variable prefix.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-By: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Gert Wollny 6 years ago committed by Gert Wollny
parent 31562ef40b
commit 5fb91750b8
  1. 21
      src/vrend_shader.c

@ -6109,19 +6109,22 @@ static void replace_interp(struct vrend_strarray *program,
const char *var_name, const char *var_name,
const char *pstring, const char *auxstring) const char *pstring, const char *auxstring)
{ {
char *ptr; int mylen = strlen(INTERP_PREFIX) + strlen("out float ");
int mylen = strlen(INTERP_PREFIX) + strlen("out vec4 ");
ptr = strstr(program->strings[SHADER_STRING_HDR].buf, var_name); char *ptr = program->strings[SHADER_STRING_HDR].buf;
do {
char *p = strstr(ptr, var_name);
if (!p)
break;
if (!ptr) ptr = p - mylen;
return;
ptr -= mylen; memset(ptr, ' ', strlen(INTERP_PREFIX));
memcpy(ptr, pstring, strlen(pstring));
memcpy(ptr + strlen(pstring), auxstring, strlen(auxstring));
memset(ptr, ' ', strlen(INTERP_PREFIX)); ptr = p + strlen(var_name);
memcpy(ptr, pstring, strlen(pstring)); } while (1);
memcpy(ptr + strlen(pstring), auxstring, strlen(auxstring));
} }
static const char *gpu_shader5_string = "#extension GL_ARB_gpu_shader5 : require\n"; static const char *gpu_shader5_string = "#extension GL_ARB_gpu_shader5 : require\n";

Loading…
Cancel
Save