shader: fix mismatching shader invariants on GL

On OpenGL with GLSL < 4.30 the invariant input specifiers must match the
invariant output specifiers of the previous stage.

Fixes #75

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
macos/master
Gert Wollny 5 years ago
parent abcd75475b
commit 5f28eb8868
  1. 1
      src/vrend_renderer.c
  2. 14
      src/vrend_shader.c
  3. 2
      src/vrend_shader.h

@ -3139,6 +3139,7 @@ static inline void vrend_fill_shader_key(struct vrend_context *ctx,
memcpy(key->prev_stage_generic_and_patch_outputs_layout, memcpy(key->prev_stage_generic_and_patch_outputs_layout,
ctx->sub->shaders[prev_type]->sinfo.generic_outputs_layout, ctx->sub->shaders[prev_type]->sinfo.generic_outputs_layout,
64 * sizeof (struct vrend_layout_info)); 64 * sizeof (struct vrend_layout_info));
key->force_invariant_inputs = ctx->sub->shaders[prev_type]->sinfo.invariant_outputs;
} }
int next_type = -1; int next_type = -1;

@ -4644,6 +4644,15 @@ iter_instruction(struct tgsi_iterate_context *iter,
} }
if (ctx->so) if (ctx->so)
prepare_so_movs(ctx); prepare_so_movs(ctx);
/* GLES doesn't allow invariant specifiers on inputs, but on GL with
* GLSL < 4.30 it is required to match the output of the previous stage */
if (!ctx->cfg->use_gles) {
for (unsigned i = 0; i < ctx->num_inputs; ++i) {
if (ctx->key->force_invariant_inputs & (1ull << i))
ctx->inputs[i].invariant = 1;
}
}
} }
if (!get_destination_info(ctx, inst, &dinfo, dsts, fp64_dsts, writemask)) if (!get_destination_info(ctx, inst, &dinfo, dsts, fp64_dsts, writemask))
@ -6567,6 +6576,11 @@ static void fill_sinfo(struct dump_ctx *ctx, struct vrend_shader_info *sinfo)
sinfo->image_arrays = ctx->image_arrays; sinfo->image_arrays = ctx->image_arrays;
sinfo->num_image_arrays = ctx->num_image_arrays; sinfo->num_image_arrays = ctx->num_image_arrays;
sinfo->generic_inputs_emitted_mask = ctx->generic_inputs_emitted_mask; sinfo->generic_inputs_emitted_mask = ctx->generic_inputs_emitted_mask;
for (unsigned i = 0; i < ctx->num_outputs; ++i) {
if (ctx->outputs[i].invariant)
sinfo->invariant_outputs |= 1ull << i;
}
} }
static bool allocate_strbuffers(struct dump_ctx* ctx) static bool allocate_strbuffers(struct dump_ctx* ctx)

@ -90,6 +90,7 @@ struct vrend_shader_info {
struct vrend_interp_info *interpinfo; struct vrend_interp_info *interpinfo;
char **so_names; char **so_names;
uint64_t invariant_outputs;
}; };
struct vrend_shader_key { struct vrend_shader_key {
@ -125,6 +126,7 @@ struct vrend_shader_key {
uint8_t num_indirect_patch_inputs; uint8_t num_indirect_patch_inputs;
uint32_t generic_outputs_expected_mask; uint32_t generic_outputs_expected_mask;
uint8_t fs_swizzle_output_rgb_to_bgr; uint8_t fs_swizzle_output_rgb_to_bgr;
uint64_t force_invariant_inputs;
}; };
struct vrend_shader_cfg { struct vrend_shader_cfg {

Loading…
Cancel
Save