libobs-opengl: Support gl_FragCoord and cull unused interpolants

This commit is contained in:
jpark37 2019-07-23 08:31:57 -07:00
parent ce9e4dd4d2
commit df59046050

View File

@ -167,7 +167,16 @@ static void gl_write_storage_var(struct gl_shader_parser *glsp,
if (st) {
gl_unwrap_storage_struct(glsp, st, var->name, input, prefix);
} else if (!input || strcmp(var->mapping, "VERTEXID")) {
} else {
if (input && (strcmp(var->mapping, "VERTEXID") == 0))
return;
if (strcmp(var->mapping, "POSITION") == 0) {
if (!input && (glsp->type == GS_SHADER_VERTEX))
return;
if (input && (glsp->type == GS_SHADER_PIXEL))
return;
}
struct gl_parser_attrib attrib;
gl_parser_attrib_init(&attrib);
@ -555,17 +564,23 @@ static void gl_write_main_storage_assign(struct gl_shader_parser *glsp,
dstr_free(&src_copy);
} else {
if (!dstr_is_empty(&dst_copy))
dstr_cat_dstr(&glsp->gl_string, &dst_copy);
dstr_cat(&glsp->gl_string, " = ");
if (input && (strcmp(var->mapping, "VERTEXID") == 0))
dstr_cat(&glsp->gl_string, "uint(gl_VertexID)");
else {
if (src)
dstr_cat(&glsp->gl_string, src);
dstr_cat(&glsp->gl_string, var->name);
if (input || (glsp->type != GS_SHADER_VERTEX) ||
(strcmp(var->mapping, "POSITION"))) {
if (!dstr_is_empty(&dst_copy))
dstr_cat_dstr(&glsp->gl_string, &dst_copy);
dstr_cat(&glsp->gl_string, " = ");
if (input && (strcmp(var->mapping, "VERTEXID") == 0))
dstr_cat(&glsp->gl_string, "uint(gl_VertexID)");
else if (input && (glsp->type == GS_SHADER_PIXEL) &&
(strcmp(var->mapping, "POSITION") == 0))
dstr_cat(&glsp->gl_string, "gl_FragCoord");
else {
if (src)
dstr_cat(&glsp->gl_string, src);
dstr_cat(&glsp->gl_string, var->name);
}
dstr_cat(&glsp->gl_string, ";\n");
}
dstr_cat(&glsp->gl_string, ";\n");
if (!input)
gl_write_main_interface_assign(glsp, var, src);