shader: track variable sinfo with the shader variant

Up until now sme of the info stored in sinfo was changed
based on the shader key, and since this info is used for
all shader variants when evaluating the key for shaders
to be linked, this may result in the wrong shader
variant being picked up.

Instead track the shader info that can be changed like this
in the shader variant itself.

Closes: #239

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Tested-by: Dave Airlie <airlied@redhat.com>
macos/master
Gert Wollny 3 years ago committed by Gert Wollny
parent 1d1783fce1
commit f2ab66c6c0
  1. 11
      src/vrend_renderer.c
  2. 19
      src/vrend_shader.c
  3. 8
      src/vrend_shader.h

@ -437,6 +437,8 @@ struct vrend_shader {
struct vrend_shader *next_variant;
struct vrend_shader_selector *sel;
struct vrend_variable_shader_info var_sinfo;
struct vrend_strarray glsl_strings;
GLuint id;
uint32_t uid;
@ -1748,8 +1750,8 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_sub_c
sprog->attrib_locs = NULL;
}
if (vs->sel->sinfo.num_ucp) {
for (i = 0; i < vs->sel->sinfo.num_ucp; i++) {
if (vs->var_sinfo.num_ucp) {
for (i = 0; i < vs->var_sinfo.num_ucp; i++) {
snprintf(name, 32, "clipp[%d]", i);
sprog->clip_locs[i] = glGetUniformLocation(prog_id, name);
}
@ -3422,7 +3424,7 @@ static inline void vrend_sync_shader_io(struct vrend_sub_context *sub_ctx,
struct vrend_shader *fs =
sub_ctx->shaders[PIPE_SHADER_FRAGMENT]->current;
key->compiled_fs_uid = fs->uid;
key->fs_info = &fs->sel->sinfo.fs_info;
key->fs_info = &fs->var_sinfo.fs_info;
next_type = PIPE_SHADER_FRAGMENT;
}
}
@ -3527,7 +3529,8 @@ static int vrend_shader_create(struct vrend_context *ctx,
if (shader->sel->tokens) {
bool ret = vrend_convert_shader(ctx, &ctx->shader_cfg, shader->sel->tokens,
shader->sel->req_local_mem, key, &shader->sel->sinfo, &shader->glsl_strings);
shader->sel->req_local_mem, key, &shader->sel->sinfo,
&shader->var_sinfo, &shader->glsl_strings);
if (!ret) {
vrend_report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_SHADER, shader->sel->type);
return -1;

@ -6913,7 +6913,7 @@ static boolean fill_fragment_interpolants(const struct dump_ctx *ctx, struct vre
return true;
}
static boolean fill_interpolants(const struct dump_ctx *ctx, struct vrend_shader_info *sinfo)
static boolean fill_interpolants(const struct dump_ctx *ctx, struct vrend_variable_shader_info *sinfo)
{
if (!ctx->num_interps)
return true;
@ -6955,11 +6955,17 @@ static boolean analyze_instruction(struct tgsi_iterate_context *iter,
return true;
}
static void fill_sinfo(const struct dump_ctx *ctx, struct vrend_shader_info *sinfo)
static void fill_var_sinfo(const struct dump_ctx *ctx, struct vrend_variable_shader_info *sinfo)
{
sinfo->num_ucp = ctx->key->clip_plane_enable ? 8 : 0;
sinfo->in.use_pervertex = ctx->has_pervertex;
sinfo->fs_info.has_sample_input = ctx->has_sample_input;
sinfo->fs_info.num_interps = ctx->num_interps;
sinfo->fs_info.glsl_ver = ctx->glsl_ver_required;
}
static void fill_sinfo(const struct dump_ctx *ctx, struct vrend_shader_info *sinfo)
{
sinfo->in.use_pervertex = ctx->has_pervertex;
bool has_prop = (ctx->num_clip_dist_prop + ctx->num_cull_dist_prop) > 0;
sinfo->out.num_clip = has_prop ? ctx->num_clip_dist_prop : (ctx->num_clip_dist ? ctx->num_clip_dist : 8);
sinfo->out.num_cull = has_prop ? ctx->num_cull_dist_prop : 0;
@ -6985,10 +6991,8 @@ static void fill_sinfo(const struct dump_ctx *ctx, struct vrend_shader_info *sin
sinfo->out.num_indirect_patch = ctx->patch_ios.output_range.io.last - ctx->patch_ios.output_range.io.sid + 1;
sinfo->num_inputs = ctx->num_inputs;
sinfo->fs_info.num_interps = ctx->num_interps;
sinfo->num_outputs = ctx->num_outputs;
sinfo->shadow_samp_mask = ctx->shadow_samp_mask;
sinfo->fs_info.glsl_ver = ctx->glsl_ver_required;
sinfo->gs_out_prim = ctx->gs_out_prim;
sinfo->tes_prim = ctx->tes_prim_mode;
sinfo->tes_point_mode = ctx->tes_point_mode;
@ -7080,6 +7084,7 @@ bool vrend_convert_shader(const struct vrend_context *rctx,
uint32_t req_local_mem,
const struct vrend_shader_key *key,
struct vrend_shader_info *sinfo,
struct vrend_variable_shader_info *var_sinfo,
struct vrend_strarray *shader)
{
struct dump_ctx ctx;
@ -7163,13 +7168,15 @@ bool vrend_convert_shader(const struct vrend_context *rctx,
if (strbuf_get_error(&ctx.glsl_strbufs.glsl_hdr))
goto fail;
bret = fill_interpolants(&ctx, sinfo);
bret = fill_interpolants(&ctx, var_sinfo);
if (bret == false)
goto fail;
free(ctx.temp_ranges);
fill_sinfo(&ctx, sinfo);
fill_var_sinfo(&ctx, var_sinfo);
set_strbuffers(rctx, &ctx.glsl_strbufs, shader);
if (ctx.prog_type == TGSI_PROCESSOR_GEOMETRY) {

@ -106,7 +106,6 @@ struct vrend_shader_info {
struct vrend_array *sampler_arrays;
struct vrend_array *image_arrays;
char **so_names;
struct vrend_fs_shader_info fs_info;
struct pipe_stream_output_info so_info;
uint32_t samplers_used_mask;
@ -122,7 +121,6 @@ struct vrend_shader_info {
int num_consts;
int num_inputs;
int num_outputs;
int num_ucp;
int gs_out_prim;
int tes_prim;
int num_sampler_arrays;
@ -133,6 +131,11 @@ struct vrend_shader_info {
uint8_t gles_use_tex_query_level : 1;
};
struct vrend_variable_shader_info {
struct vrend_fs_shader_info fs_info;
int num_ucp;
};
struct vrend_shader_key {
uint64_t force_invariant_inputs;
@ -204,6 +207,7 @@ bool vrend_convert_shader(const struct vrend_context *rctx,
uint32_t req_local_mem,
const struct vrend_shader_key *key,
struct vrend_shader_info *sinfo,
struct vrend_variable_shader_info *var_sinfo,
struct vrend_strarray *shader);
const char *vrend_shader_samplertypeconv(bool use_gles, int sampler_type);

Loading…
Cancel
Save