diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 21fc7d6..5bf2b3b 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -3209,7 +3209,6 @@ static inline void vrend_fill_shader_key(struct vrend_context *ctx, } if (prev_type != -1 && ctx->sub->shaders[prev_type]) { - key->prev_stage_pervertex_out = ctx->sub->shaders[prev_type]->sinfo.has_pervertex_out; key->prev_stage_num_clip_out = ctx->sub->shaders[prev_type]->sinfo.num_clip_out; key->prev_stage_num_cull_out = ctx->sub->shaders[prev_type]->sinfo.num_cull_out; key->num_indirect_generic_inputs = ctx->sub->shaders[prev_type]->sinfo.num_indirect_generic_outputs; @@ -3254,6 +3253,7 @@ static inline void vrend_fill_shader_key(struct vrend_context *ctx, } if (next_type != -1 && ctx->sub->shaders[next_type]) { + key->next_stage_pervertex_in = ctx->sub->shaders[next_type]->sinfo.has_pervertex_in; key->num_indirect_generic_outputs = ctx->sub->shaders[next_type]->sinfo.num_indirect_generic_inputs; key->num_indirect_patch_outputs = ctx->sub->shaders[next_type]->sinfo.num_indirect_patch_inputs; key->generic_outputs_expected_mask = ctx->sub->shaders[next_type]->sinfo.generic_inputs_emitted_mask; diff --git a/src/vrend_shader.c b/src/vrend_shader.c index c042376..fbf0aec 100644 --- a/src/vrend_shader.c +++ b/src/vrend_shader.c @@ -237,11 +237,11 @@ struct dump_ctx { int color_in_mask; /* only used when cull is enabled */ uint8_t num_cull_dist_prop, num_clip_dist_prop; + bool has_pervertex; bool front_face_emitted; bool has_clipvertex; bool has_clipvertex_so; - bool vs_has_pervertex; bool write_mul_utemp; bool write_mul_itemp; bool has_sample_input; @@ -6121,8 +6121,7 @@ static void emit_ios_vs(struct dump_ctx *ctx) if (ctx->key->clip_plane_enable) { emit_hdr(ctx, "uniform vec4 clipp[8];\n"); } - if (ctx->key->gs_present || ctx->key->tes_present) { - ctx->vs_has_pervertex = true; + if ((ctx->key->gs_present || ctx->key->tes_present) && ctx->key->next_stage_pervertex_in) { emit_hdrf(ctx, "out gl_PerVertex {\n vec4 gl_Position;\n %s%s};\n", clip_buf, cull_buf); } else { emit_hdrf(ctx, "%s%s", clip_buf, cull_buf); @@ -6306,7 +6305,7 @@ static void emit_ios_geom(struct dump_ctx *ctx) emit_winsys_correction(ctx); - if (ctx->num_in_clip_dist || ctx->key->clip_plane_enable || ctx->key->prev_stage_pervertex_out) { + if (ctx->num_in_clip_dist || ctx->key->clip_plane_enable) { int clip_dist, cull_dist; char clip_var[64] = ""; char cull_var[64] = ""; @@ -6319,6 +6318,7 @@ static void emit_ios_geom(struct dump_ctx *ctx) if (cull_dist) snprintf(cull_var, 64, "float gl_CullDistance[%d];\n", cull_dist); + ctx->has_pervertex = true; emit_hdrf(ctx, "in gl_PerVertex {\n vec4 gl_Position; \n %s%s\n} gl_in[];\n", clip_var, cull_var); } if (ctx->num_clip_dist) { @@ -6380,7 +6380,7 @@ static void emit_ios_tcs(struct dump_ctx *ctx) } } - if (ctx->num_in_clip_dist || ctx->key->prev_stage_pervertex_out) { + if (ctx->num_in_clip_dist) { int clip_dist, cull_dist; char clip_var[64] = "", cull_var[64] = ""; @@ -6392,10 +6392,11 @@ static void emit_ios_tcs(struct dump_ctx *ctx) if (cull_dist) snprintf(cull_var, 64, "float gl_CullDistance[%d];\n", cull_dist); + ctx->has_pervertex = true; emit_hdrf(ctx, "in gl_PerVertex {\n vec4 gl_Position; \n %s%s} gl_in[];\n", clip_var, cull_var); } - if (ctx->num_clip_dist) { - emit_hdrf(ctx, "out gl_PerVertex {\n vec4 gl_Position;\n float gl_ClipDistance[%d];\n} gl_out[];\n", ctx->num_clip_dist ? ctx->num_clip_dist : 8); + if (ctx->num_clip_dist && ctx->key->next_stage_pervertex_in) { + emit_hdrf(ctx, "out gl_PerVertex {\n vec4 gl_Position;\n float gl_ClipDistance[%d];\n} gl_out[];\n", ctx->num_clip_dist); emit_hdr(ctx, "vec4 clip_dist_temp[2];\n"); } } @@ -6431,7 +6432,7 @@ static void emit_ios_tes(struct dump_ctx *ctx) emit_winsys_correction(ctx); - if (ctx->num_in_clip_dist || ctx->key->prev_stage_pervertex_out) { + if (ctx->num_in_clip_dist) { int clip_dist, cull_dist; char clip_var[64] = "", cull_var[64] = ""; @@ -6443,10 +6444,11 @@ static void emit_ios_tes(struct dump_ctx *ctx) if (cull_dist) snprintf(cull_var, 64, "float gl_CullDistance[%d];\n", cull_dist); + ctx->has_pervertex = true; emit_hdrf(ctx, "in gl_PerVertex {\n vec4 gl_Position; \n %s%s} gl_in[];\n", clip_var, cull_var); } - if (ctx->num_clip_dist) { - emit_hdrf(ctx, "out gl_PerVertex {\n vec4 gl_Position;\n float gl_ClipDistance[%d];\n} gl_out[];\n", ctx->num_clip_dist ? ctx->num_clip_dist : 8); + if (ctx->num_clip_dist && ctx->key->next_stage_pervertex_in) { + emit_hdrf(ctx, "out gl_PerVertex {\n vec4 gl_Position;\n float gl_ClipDistance[%d];\n} gl_out[];\n", ctx->num_clip_dist); emit_hdr(ctx, "vec4 clip_dist_temp[2];\n"); } } @@ -6603,7 +6605,7 @@ static boolean analyze_instruction(struct tgsi_iterate_context *iter, static void fill_sinfo(struct dump_ctx *ctx, struct vrend_shader_info *sinfo) { sinfo->num_ucp = ctx->key->clip_plane_enable ? 8 : 0; - sinfo->has_pervertex_out = ctx->vs_has_pervertex; + sinfo->has_pervertex_in = ctx->has_pervertex; sinfo->has_sample_input = ctx->has_sample_input; bool has_prop = (ctx->num_clip_dist_prop + ctx->num_cull_dist_prop) > 0; sinfo->num_clip_out = has_prop ? ctx->num_clip_dist_prop : (ctx->num_clip_dist ? ctx->num_clip_dist : 8); diff --git a/src/vrend_shader.h b/src/vrend_shader.h index 956e134..8c94e25 100644 --- a/src/vrend_shader.h +++ b/src/vrend_shader.h @@ -56,6 +56,7 @@ struct vrend_shader_info { uint32_t ubo_used_mask; uint32_t ssbo_used_mask; uint32_t num_generic_and_patch_outputs; + bool has_pervertex_in; bool guest_sent_io_arrays; struct vrend_layout_info generic_outputs_layout[64]; int num_consts; @@ -70,7 +71,6 @@ struct vrend_shader_info { uint32_t generic_inputs_emitted_mask; int num_ucp; int glsl_ver; - bool has_pervertex_out; bool has_sample_input; uint8_t num_clip_out; uint8_t num_cull_out; @@ -105,7 +105,6 @@ struct vrend_shader_key { bool tcs_present; bool tes_present; bool flatshade; - bool prev_stage_pervertex_out; bool guest_sent_io_arrays; bool fs_logicop_enabled; bool fs_logicop_emulate_coherent; @@ -117,6 +116,7 @@ struct vrend_shader_key { uint8_t prev_stage_num_clip_out; uint8_t prev_stage_num_cull_out; + bool next_stage_pervertex_in; uint32_t cbufs_are_a8_bitmask; uint8_t num_indirect_generic_outputs; uint8_t num_indirect_patch_outputs;