diff options
author | Dave Airlie <airlied@redhat.com> | 2015-12-22 11:32:27 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2016-02-19 11:18:23 +1000 |
commit | 2fd6ca7eb52cb6481a11a1cae27e3465652585fe (patch) | |
tree | 86797a3d615c96d1940b02ef16b8bb3c6eb96639 | |
parent | 27a18c916814207af9a33037eee4c295c1f4ccc4 (diff) |
fix up input/output remapping for tess
-rw-r--r-- | src/vrend_renderer.c | 30 | ||||
-rw-r--r-- | src/vrend_shader.c | 68 | ||||
-rw-r--r-- | src/vrend_shader.h | 4 |
3 files changed, 80 insertions, 22 deletions
diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index a24d7c7..791c3d9 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -815,31 +815,43 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte GLuint prog_id; GLint lret; int id; - + 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 && tes && tes->compiled_fs_id != fs->id) + do_patch = true; + if (!gs && !tes && vs->compiled_fs_id != fs->id) + do_patch = true; + + if (do_patch) { bool ret; if (gs) vrend_patch_vertex_shader_interpolants(gs->glsl_prog, &gs->sel->sinfo, - &fs->sel->sinfo, true, fs->key.flatshade); + &fs->sel->sinfo, "gso", fs->key.flatshade); + else if (tes) + vrend_patch_vertex_shader_interpolants(tes->glsl_prog, + &tes->sel->sinfo, + &fs->sel->sinfo, "teo", fs->key.flatshade); else vrend_patch_vertex_shader_interpolants(vs->glsl_prog, &vs->sel->sinfo, - &fs->sel->sinfo, false, fs->key.flatshade); - ret = vrend_compile_shader(ctx, gs ? gs : vs); + &fs->sel->sinfo, "vso", fs->key.flatshade); + ret = vrend_compile_shader(ctx, gs ? gs : (tes ? tes : vs)); if (ret == false) { - glDeleteShader(gs ? gs->id : vs->id); + glDeleteShader(gs ? gs->id : (tes ? tes->id : vs->id)); free(sprog); return NULL; } if (gs) gs->compiled_fs_id = fs->id; + else if (tes) + tes->compiled_fs_id = fs->id; else vs->compiled_fs_id = fs->id; } @@ -2046,6 +2058,10 @@ static inline void vrend_fill_shader_key(struct vrend_context *ctx, if (ctx->sub->shaders[PIPE_SHADER_GEOMETRY]) key->gs_present = true; + if (ctx->sub->shaders[PIPE_SHADER_TESS_CTRL]) + key->tcs_present = true; + if (ctx->sub->shaders[PIPE_SHADER_TESS_EVAL]) + key->tes_present = true; } static inline int conv_shader_type(int type) diff --git a/src/vrend_shader.c b/src/vrend_shader.c index 89070f6..3d0c94d 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -435,15 +435,35 @@ iter_declaration(struct tgsi_iterate_context *iter, } } default: - if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT || - iter->processor.Processor == TGSI_PROCESSOR_GEOMETRY) { - if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT && - ctx->key->gs_present) - name_prefix = "out"; + switch (iter->processor.Processor) { + case TGSI_PROCESSOR_FRAGMENT: + if (ctx->key->gs_present) + name_prefix = "gso"; + else if (ctx->key->tes_present) + name_prefix = "teo"; else - name_prefix = "ex"; - } else + name_prefix = "vso"; + break; + case TGSI_PROCESSOR_GEOMETRY: + if (ctx->key->tes_present) + name_prefix = "teo"; + else + name_prefix = "vso"; + break; + case TGSI_PROCESSOR_TESS_EVAL: + if (ctx->key->tcs_present) + name_prefix = "tco"; + else + name_prefix = "vso"; + break; + case TGSI_PROCESSOR_TESS_CTRL: + name_prefix = "vso"; + break; + case TGSI_PROCESSOR_VERTEX: + default: name_prefix = "in"; + break; + } break; } @@ -622,12 +642,26 @@ iter_declaration(struct tgsi_iterate_context *iter, default: - if (iter->processor.Processor == TGSI_PROCESSOR_VERTEX) - name_prefix = "ex"; - else if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT) + switch (iter->processor.Processor) { + case TGSI_PROCESSOR_FRAGMENT: name_prefix = "fsout"; - else + break; + case TGSI_PROCESSOR_VERTEX: + name_prefix = "vso"; + break; + case TGSI_PROCESSOR_GEOMETRY: + name_prefix = "gso"; + break; + case TGSI_PROCESSOR_TESS_CTRL: + name_prefix = "tco"; + break; + case TGSI_PROCESSOR_TESS_EVAL: + name_prefix = "teo"; + break; + default: name_prefix = "out"; + break; + } break; } @@ -2531,7 +2565,12 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr) bcolor_emitted[ctx->outputs[i].sid] = true; } if (!ctx->outputs[i].glsl_predefined_no_emit) { - if ((ctx->prog_type == TGSI_PROCESSOR_VERTEX || ctx->prog_type == TGSI_PROCESSOR_GEOMETRY) && (ctx->outputs[i].name == TGSI_SEMANTIC_GENERIC || ctx->outputs[i].name == TGSI_SEMANTIC_COLOR || ctx->outputs[i].name == TGSI_SEMANTIC_BCOLOR)) { + if ((ctx->prog_type == TGSI_PROCESSOR_VERTEX || + ctx->prog_type == TGSI_PROCESSOR_GEOMETRY || + ctx->prog_type == TGSI_PROCESSOR_TESS_EVAL) && + (ctx->outputs[i].name == TGSI_SEMANTIC_GENERIC || + ctx->outputs[i].name == TGSI_SEMANTIC_COLOR || + ctx->outputs[i].name == TGSI_SEMANTIC_BCOLOR)) { ctx->num_interps++; prefix = INTERP_PREFIX; } else @@ -2889,7 +2928,8 @@ static void replace_interp(char *program, bool vrend_patch_vertex_shader_interpolants(char *program, struct vrend_shader_info *vs_info, - struct vrend_shader_info *fs_info, bool is_gs, bool flatshade) + struct vrend_shader_info *fs_info, + const char *oprefix, bool flatshade) { int i; const char *pstring; @@ -2924,7 +2964,7 @@ bool vrend_patch_vertex_shader_interpolants(char *program, } break; case TGSI_SEMANTIC_GENERIC: - snprintf(glsl_name, 64, "%s_g%d", is_gs ? "out" : "ex", fs_info->interpinfo[i].semantic_index); + snprintf(glsl_name, 64, "%s_g%d", oprefix, fs_info->interpinfo[i].semantic_index); replace_interp(program, glsl_name, pstring); break; default: diff --git a/src/vrend_shader.h b/src/vrend_shader.h index 5f42d23..bd2b352 100644 --- a/src/vrend_shader.h +++ b/src/vrend_shader.h @@ -73,6 +73,8 @@ struct vrend_shader_key { uint8_t alpha_test; uint8_t clip_plane_enable; bool gs_present; + bool tcs_present; + bool tes_present; bool flatshade; float alpha_ref_val; uint32_t cbufs_are_a8_bitmask; @@ -87,7 +89,7 @@ struct vrend_shader_cfg { bool vrend_patch_vertex_shader_interpolants(char *program, struct vrend_shader_info *vs_info, struct vrend_shader_info *fs_info, - bool is_gs, bool flatshade); + const char *oprefix, bool flatshade); char *vrend_convert_shader(struct vrend_shader_cfg *cfg, const struct tgsi_token *tokens, |