summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2017-08-11 11:14:22 +1000
committerDave Airlie <airlied@redhat.com>2018-06-05 14:44:30 +1000
commit2ace3b4ea5755f41e6e8cd788c0acfb6fb654d68 (patch)
tree8e18f5471360a34f8401e5ec9cff7b387404a030
parentbb405ac545e385446e5b004954492e418b0a695a (diff)
renderer: change logic around patching to make tess easier to add
-rw-r--r--src/vrend_renderer.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index c8eafef..cc77c80 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -880,12 +880,17 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte
GLint lret;
int id;
int last_shader;
+ bool do_patch = false;
if (!sprog)
return NULL;
/* need to rewrite VS code to add interpolation params */
- if ((gs && gs->compiled_fs_id != fs->id) ||
- (!gs && vs->compiled_fs_id != fs->id)) {
+ if (gs && gs->compiled_fs_id != fs->id)
+ do_patch = true;
+ if (!gs && vs->compiled_fs_id != fs->id)
+ do_patch = true;
+
+ if (do_patch) {
bool ret;
if (gs)
@@ -1082,12 +1087,15 @@ static struct vrend_linked_shader_program *lookup_shader_program(struct vrend_co
LIST_FOR_EACH_ENTRY(ent, &ctx->sub->programs, head) {
if (ent->dual_src_linked != dual_src)
continue;
- if (ent->ss[PIPE_SHADER_VERTEX]->id == vs_id && ent->ss[PIPE_SHADER_FRAGMENT]->id == fs_id) {
- if (!ent->ss[PIPE_SHADER_GEOMETRY] && gs_id == 0)
- return ent;
- if (ent->ss[PIPE_SHADER_GEOMETRY] && ent->ss[PIPE_SHADER_GEOMETRY]->id == gs_id)
- return ent;
- }
+
+ if (ent->ss[PIPE_SHADER_VERTEX]->id != vs_id)
+ continue;
+ if (ent->ss[PIPE_SHADER_FRAGMENT]->id != vs_id)
+ continue;
+ if (ent->ss[PIPE_SHADER_GEOMETRY] &&
+ ent->ss[PIPE_SHADER_GEOMETRY]->id != gs_id)
+ continue;
+ return ent;
}
return NULL;
}
@@ -2994,7 +3002,9 @@ void vrend_draw_vbo(struct vrend_context *ctx,
if (ctx->sub->shaders[PIPE_SHADER_GEOMETRY])
vrend_shader_select(ctx, ctx->sub->shaders[PIPE_SHADER_GEOMETRY], &gs_dirty);
- if (!ctx->sub->shaders[PIPE_SHADER_VERTEX]->current || !ctx->sub->shaders[PIPE_SHADER_FRAGMENT]->current || (ctx->sub->shaders[PIPE_SHADER_GEOMETRY] && !ctx->sub->shaders[PIPE_SHADER_GEOMETRY]->current)) {
+ if (!ctx->sub->shaders[PIPE_SHADER_VERTEX]->current ||
+ !ctx->sub->shaders[PIPE_SHADER_FRAGMENT]->current ||
+ (ctx->sub->shaders[PIPE_SHADER_GEOMETRY] && !ctx->sub->shaders[PIPE_SHADER_GEOMETRY]->current)) {
fprintf(stderr, "failure to compile shader variants: %s\n", ctx->debug_name);
return;
}
@@ -3009,11 +3019,16 @@ void vrend_draw_vbo(struct vrend_context *ctx,
same_prog = false;
if (!same_prog) {
- prog = lookup_shader_program(ctx, ctx->sub->shaders[PIPE_SHADER_VERTEX]->current->id, ctx->sub->shaders[PIPE_SHADER_FRAGMENT]->current->id, ctx->sub->shaders[PIPE_SHADER_GEOMETRY] ? ctx->sub->shaders[PIPE_SHADER_GEOMETRY]->current->id : 0, dual_src);
+ prog = lookup_shader_program(ctx,
+ ctx->sub->shaders[PIPE_SHADER_VERTEX]->current->id,
+ ctx->sub->shaders[PIPE_SHADER_FRAGMENT]->current->id,
+ ctx->sub->shaders[PIPE_SHADER_GEOMETRY] ? ctx->sub->shaders[PIPE_SHADER_GEOMETRY]->current->id : 0,
+ dual_src);
if (!prog) {
prog = add_shader_program(ctx,
ctx->sub->shaders[PIPE_SHADER_VERTEX]->current,
- ctx->sub->shaders[PIPE_SHADER_FRAGMENT]->current, ctx->sub->shaders[PIPE_SHADER_GEOMETRY] ? ctx->sub->shaders[PIPE_SHADER_GEOMETRY]->current : NULL);
+ ctx->sub->shaders[PIPE_SHADER_FRAGMENT]->current,
+ ctx->sub->shaders[PIPE_SHADER_GEOMETRY] ? ctx->sub->shaders[PIPE_SHADER_GEOMETRY]->current : NULL);
if (!prog)
return;
}