vrend: make sure gl_PerVertex is consistent even if GS has no clip inputs

This fixes:
clip-distance-vs-gs-out.shader_test

Signed-off-by: Dave Airlie <airlied@redhat.com>
macos/master
Dave Airlie 8 years ago
parent 6566b8ae3f
commit 0acd5a8e8f
  1. 8
      src/vrend_renderer.c
  2. 16
      src/vrend_shader.c
  3. 3
      src/vrend_shader.h

@ -1998,6 +1998,7 @@ static void vrend_destroy_shader_object(void *obj_ptr)
} }
static inline void vrend_fill_shader_key(struct vrend_context *ctx, static inline void vrend_fill_shader_key(struct vrend_context *ctx,
unsigned type,
struct vrend_shader_key *key) struct vrend_shader_key *key)
{ {
if (vrend_state.use_core_profile == true) { if (vrend_state.use_core_profile == true) {
@ -2032,6 +2033,11 @@ static inline void vrend_fill_shader_key(struct vrend_context *ctx,
if (ctx->sub->shaders[PIPE_SHADER_GEOMETRY]) if (ctx->sub->shaders[PIPE_SHADER_GEOMETRY])
key->gs_present = true; key->gs_present = true;
if (type == PIPE_SHADER_GEOMETRY && ctx->sub->shaders[PIPE_SHADER_VERTEX]) {
key->vs_has_pervertex = ctx->sub->shaders[PIPE_SHADER_VERTEX]->sinfo.num_pervertex_clip > 0;
key->vs_pervertex_num_clip = ctx->sub->shaders[PIPE_SHADER_VERTEX]->sinfo.num_pervertex_clip;
}
} }
static inline int conv_shader_type(int type) static inline int conv_shader_type(int type)
@ -2086,7 +2092,7 @@ static int vrend_shader_select(struct vrend_context *ctx,
int r; int r;
memset(&key, 0, sizeof(key)); memset(&key, 0, sizeof(key));
vrend_fill_shader_key(ctx, &key); vrend_fill_shader_key(ctx, sel->type, &key);
if (sel->current && !memcmp(&sel->current->key, &key, sizeof(key))) if (sel->current && !memcmp(&sel->current->key, &key, sizeof(key)))
return 0; return 0;

@ -140,6 +140,7 @@ struct dump_ctx {
bool has_clipvertex_so; bool has_clipvertex_so;
bool has_viewport_idx; bool has_viewport_idx;
bool has_frag_viewport_idx; bool has_frag_viewport_idx;
bool vs_has_pervertex;
}; };
static inline const char *tgsi_proc_to_prefix(int shader_type) static inline const char *tgsi_proc_to_prefix(int shader_type)
@ -2290,6 +2291,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
} }
if (ctx->key->gs_present) { if (ctx->key->gs_present) {
ctx->vs_has_pervertex = true;
snprintf(buf, 255, "out gl_PerVertex {\n vec4 gl_Position;\n float gl_PointSize;\n float gl_ClipDistance[%d];\n};\n", ctx->num_clip_dist ? ctx->num_clip_dist : 8); snprintf(buf, 255, "out gl_PerVertex {\n vec4 gl_Position;\n float gl_PointSize;\n float gl_ClipDistance[%d];\n};\n", ctx->num_clip_dist ? ctx->num_clip_dist : 8);
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
} else { } else {
@ -2304,8 +2306,17 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
if (ctx->prog_type == TGSI_PROCESSOR_GEOMETRY) { if (ctx->prog_type == TGSI_PROCESSOR_GEOMETRY) {
snprintf(buf, 255, "uniform vec4 winsys_adjust;\n"); snprintf(buf, 255, "uniform vec4 winsys_adjust;\n");
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
if (ctx->num_in_clip_dist || ctx->key->clip_plane_enable) { if (ctx->num_in_clip_dist || ctx->key->clip_plane_enable || ctx->key->vs_has_pervertex) {
snprintf(buf, 255, "in gl_PerVertex {\n vec4 gl_Position;\n float gl_PointSize; \n float gl_ClipDistance[%d];\n} gl_in[];\n", ctx->num_in_clip_dist ? ctx->num_in_clip_dist : 8); int clip_dist;
if (ctx->key->vs_has_pervertex)
clip_dist = ctx->key->vs_pervertex_num_clip;
else if (ctx->num_in_clip_dist)
clip_dist = ctx->num_in_clip_dist;
else
clip_dist = 8;
snprintf(buf, 255, "in gl_PerVertex {\n vec4 gl_Position;\n float gl_PointSize; \n float gl_ClipDistance[%d];\n} gl_in[];\n", clip_dist);
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
} }
if (ctx->num_clip_dist) { if (ctx->num_clip_dist) {
@ -2515,6 +2526,7 @@ char *vrend_convert_shader(struct vrend_shader_cfg *cfg,
free(ctx.glsl_main); free(ctx.glsl_main);
free(glsl_hdr); free(glsl_hdr);
sinfo->num_ucp = ctx.key->clip_plane_enable ? 8 : 0; sinfo->num_ucp = ctx.key->clip_plane_enable ? 8 : 0;
sinfo->num_pervertex_clip = (ctx.vs_has_pervertex ? (ctx.num_clip_dist ? ctx.num_clip_dist : 8) : 0);
sinfo->samplers_used_mask = ctx.samplers_used; sinfo->samplers_used_mask = ctx.samplers_used;
sinfo->num_consts = ctx.num_consts; sinfo->num_consts = ctx.num_consts;
sinfo->num_ubos = ctx.num_ubo; sinfo->num_ubos = ctx.num_ubo;

@ -43,6 +43,7 @@ struct vrend_shader_info {
int num_ubos; int num_ubos;
int num_ucp; int num_ucp;
int glsl_ver; int glsl_ver;
uint8_t num_pervertex_clip;
uint32_t shadow_samp_mask; uint32_t shadow_samp_mask;
int gs_out_prim; int gs_out_prim;
uint32_t attrib_input_mask; uint32_t attrib_input_mask;
@ -62,6 +63,8 @@ struct vrend_shader_key {
uint8_t clip_plane_enable; uint8_t clip_plane_enable;
bool gs_present; bool gs_present;
bool flatshade; bool flatshade;
bool vs_has_pervertex;
uint8_t vs_pervertex_num_clip;
float alpha_ref_val; float alpha_ref_val;
uint32_t cbufs_are_a8_bitmask; uint32_t cbufs_are_a8_bitmask;
}; };

Loading…
Cancel
Save