shader: reorder more shader key components

Seperate more elements into the shader stages that they are used in
and evaluate them only for the stage they are relevant for.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
macos/master
Gert Wollny 4 years ago
parent 4233c35791
commit cf039b3af3
  1. 36
      src/vrend_renderer.c
  2. 6
      src/vrend_shader.c
  3. 76
      src/vrend_shader.h

@ -3304,26 +3304,29 @@ static inline void vrend_fill_shader_key(struct vrend_sub_context *sub_ctx,
bool add_alpha_test = true;
// Only use integer info when drawing to avoid stale info.
if (vrend_state.use_integer && sub_ctx->drawing) {
key->attrib_signed_int_bitmask = sub_ctx->ve->signed_int_bitmask;
key->attrib_unsigned_int_bitmask = sub_ctx->ve->unsigned_int_bitmask;
}
for (i = 0; i < sub_ctx->nr_cbufs; i++) {
if (!sub_ctx->surf[i])
continue;
if (vrend_format_is_emulated_alpha(sub_ctx->surf[i]->format))
key->fs.cbufs_are_a8_bitmask |= (1 << i);
if (util_format_is_pure_integer(sub_ctx->surf[i]->format)) {
if (vrend_state.use_integer && sub_ctx->drawing &&
type == PIPE_SHADER_VERTEX) {
key->vs.attrib_signed_int_bitmask = sub_ctx->ve->signed_int_bitmask;
key->vs.attrib_unsigned_int_bitmask = sub_ctx->ve->unsigned_int_bitmask;
}
if (type == PIPE_SHADER_FRAGMENT) {
for (i = 0; i < sub_ctx->nr_cbufs; i++) {
if (!sub_ctx->surf[i])
continue;
if (vrend_format_is_emulated_alpha(sub_ctx->surf[i]->format))
key->fs.cbufs_are_a8_bitmask |= (1 << i);
if (util_format_is_pure_integer(sub_ctx->surf[i]->format)) {
add_alpha_test = false;
UPDATE_INT_SIGN_MASK(sub_ctx->surf[i]->format, i,
key->fs.cbufs_signed_int_bitmask,
key->fs.cbufs_unsigned_int_bitmask);
}
key->fs.surface_component_bits[i] = util_format_get_component_bits(sub_ctx->surf[i]->format, UTIL_FORMAT_COLORSPACE_RGB, 0);
}
if (add_alpha_test) {
key->add_alpha_test = sub_ctx->dsa_state.alpha.enabled;
key->alpha_test = sub_ctx->dsa_state.alpha.func;
}
key->surface_component_bits[i] = util_format_get_component_bits(sub_ctx->surf[i]->format, UTIL_FORMAT_COLORSPACE_RGB, 0);
}
if (add_alpha_test) {
key->add_alpha_test = sub_ctx->dsa_state.alpha.enabled;
key->alpha_test = sub_ctx->dsa_state.alpha.func;
}
key->pstipple_tex = sub_ctx->rs_state.poly_stipple_enable;
@ -3333,8 +3336,6 @@ static inline void vrend_fill_shader_key(struct vrend_sub_context *sub_ctx,
key->flatshade = sub_ctx->rs_state.flatshade ? true : false;
}
key->fs.invert_origin = !sub_ctx->inverted_fbo_content;
key->gs_present = !!sub_ctx->shaders[PIPE_SHADER_GEOMETRY];
key->tcs_present = !!sub_ctx->shaders[PIPE_SHADER_TESS_CTRL];
key->tes_present = !!sub_ctx->shaders[PIPE_SHADER_TESS_EVAL];
@ -3379,6 +3380,7 @@ static inline void vrend_fill_shader_key(struct vrend_sub_context *sub_ctx,
int next_type = -1;
if (type == PIPE_SHADER_FRAGMENT) {
key->fs.invert_origin = !sub_ctx->inverted_fbo_content;
key->fs.swizzle_output_rgb_to_bgr = sub_ctx->swizzle_output_rgb_to_bgr;
if (vrend_state.use_gles && can_emulate_logicop(sub_ctx->blend_state.logicop_func)) {
key->fs.logicop_enabled = sub_ctx->blend_state.logicop_enable;

@ -974,8 +974,8 @@ iter_declaration(struct tgsi_iterate_context *iter,
}
if (iter->processor.Processor == TGSI_PROCESSOR_VERTEX) {
ctx->attrib_input_mask |= (1 << decl->Range.First);
ctx->inputs[i].type = get_type(ctx->key->attrib_signed_int_bitmask,
ctx->key->attrib_unsigned_int_bitmask,
ctx->inputs[i].type = get_type(ctx->key->vs.attrib_signed_int_bitmask,
ctx->key->vs.attrib_unsigned_int_bitmask,
decl->Range.First);
}
ctx->inputs[i].name = decl->Semantic.Name;
@ -2058,7 +2058,7 @@ static void emit_fragment_logicop(const struct dump_ctx *ctx,
char full_op[PIPE_MAX_COLOR_BUFS][128 + 8];
for (unsigned i = 0; i < ctx->num_outputs; i++) {
mask[i] = (1 << ctx->key->surface_component_bits[i]) - 1;
mask[i] = (1 << ctx->key->fs.surface_component_bits[i]) - 1;
scale[i] = mask[i];
switch (ctx->key->fs.logicop_func) {
case PIPE_LOGICOP_INVERT:

@ -136,51 +136,55 @@ struct vrend_shader_key {
struct vrend_fs_shader_info *fs_info;
struct vrend_shader_info_out input;
struct vrend_shader_info_in output;
struct vrend_layout_info prev_stage_generic_and_patch_outputs_layout[64];
struct {
uint8_t swizzle_output_rgb_to_bgr;
uint8_t cbufs_are_a8_bitmask;
uint8_t cbufs_signed_int_bitmask;
uint8_t cbufs_unsigned_int_bitmask;
uint32_t logicop_func : 4;
uint32_t logicop_enabled : 1;
uint32_t prim_is_points : 1;
uint32_t invert_origin : 1;
uint32_t coord_replace;
} fs;
uint32_t attrib_signed_int_bitmask;
uint32_t attrib_unsigned_int_bitmask;
uint32_t compiled_fs_uid;
union {
struct {
uint8_t surface_component_bits[PIPE_MAX_COLOR_BUFS];
uint32_t coord_replace;
uint8_t swizzle_output_rgb_to_bgr;
uint8_t cbufs_are_a8_bitmask;
uint8_t cbufs_signed_int_bitmask;
uint8_t cbufs_unsigned_int_bitmask;
uint32_t logicop_func : 4;
uint32_t logicop_enabled : 1;
uint32_t prim_is_points : 1;
uint32_t invert_origin : 1;
} fs;
struct {
uint32_t attrib_signed_int_bitmask;
uint32_t attrib_unsigned_int_bitmask;
} vs;
};
uint32_t pstipple_tex : 1;
uint32_t add_alpha_test : 1;
uint32_t color_two_side : 1;
uint32_t gs_present : 1;
uint32_t tcs_present : 1;
uint32_t tes_present : 1;
uint32_t flatshade : 1;
uint32_t compiled_fs_uid;
uint8_t alpha_test;
uint8_t clip_plane_enable;
uint8_t pstipple_tex : 1;
uint8_t add_alpha_test : 1;
uint8_t color_two_side : 1;
uint8_t gs_present : 1;
uint8_t tcs_present : 1;
uint8_t tes_present : 1;
uint8_t flatshade : 1;
uint8_t surface_component_bits[PIPE_MAX_COLOR_BUFS];
struct vrend_layout_info prev_stage_generic_and_patch_outputs_layout[64];
};
struct vrend_shader_cfg {
int glsl_version;
int max_draw_buffers;
bool use_gles;
bool use_core_profile;
bool use_explicit_locations;
bool has_arrays_of_arrays;
bool has_gpu_shader5;
bool has_es31_compat;
bool has_conservative_depth;
bool use_integer;
bool has_dual_src_blend;
bool has_fbfetch_coherent;
uint32_t glsl_version : 12;
uint32_t max_draw_buffers : 4;
uint32_t use_gles : 1;
uint32_t use_core_profile : 1;
uint32_t use_explicit_locations : 1;
uint32_t has_arrays_of_arrays : 1;
uint32_t has_gpu_shader5 : 1;
uint32_t has_es31_compat : 1;
uint32_t has_conservative_depth : 1;
uint32_t use_integer : 1;
uint32_t has_dual_src_blend : 1;
uint32_t has_fbfetch_coherent : 1;
};
struct vrend_context;

Loading…
Cancel
Save