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. 14
      src/vrend_renderer.c
  2. 6
      src/vrend_shader.c
  3. 50
      src/vrend_shader.h

@ -3304,10 +3304,12 @@ static inline void vrend_fill_shader_key(struct vrend_sub_context *sub_ctx,
bool add_alpha_test = true; bool add_alpha_test = true;
// Only use integer info when drawing to avoid stale info. // Only use integer info when drawing to avoid stale info.
if (vrend_state.use_integer && sub_ctx->drawing) { if (vrend_state.use_integer && sub_ctx->drawing &&
key->attrib_signed_int_bitmask = sub_ctx->ve->signed_int_bitmask; type == PIPE_SHADER_VERTEX) {
key->attrib_unsigned_int_bitmask = sub_ctx->ve->unsigned_int_bitmask; 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++) { for (i = 0; i < sub_ctx->nr_cbufs; i++) {
if (!sub_ctx->surf[i]) if (!sub_ctx->surf[i])
continue; continue;
@ -3319,12 +3321,13 @@ static inline void vrend_fill_shader_key(struct vrend_sub_context *sub_ctx,
key->fs.cbufs_signed_int_bitmask, key->fs.cbufs_signed_int_bitmask,
key->fs.cbufs_unsigned_int_bitmask); key->fs.cbufs_unsigned_int_bitmask);
} }
key->surface_component_bits[i] = util_format_get_component_bits(sub_ctx->surf[i]->format, UTIL_FORMAT_COLORSPACE_RGB, 0); 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) { if (add_alpha_test) {
key->add_alpha_test = sub_ctx->dsa_state.alpha.enabled; key->add_alpha_test = sub_ctx->dsa_state.alpha.enabled;
key->alpha_test = sub_ctx->dsa_state.alpha.func; key->alpha_test = sub_ctx->dsa_state.alpha.func;
} }
}
key->pstipple_tex = sub_ctx->rs_state.poly_stipple_enable; key->pstipple_tex = sub_ctx->rs_state.poly_stipple_enable;
key->color_two_side = sub_ctx->rs_state.light_twoside; key->color_two_side = sub_ctx->rs_state.light_twoside;
@ -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->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->gs_present = !!sub_ctx->shaders[PIPE_SHADER_GEOMETRY];
key->tcs_present = !!sub_ctx->shaders[PIPE_SHADER_TESS_CTRL]; key->tcs_present = !!sub_ctx->shaders[PIPE_SHADER_TESS_CTRL];
key->tes_present = !!sub_ctx->shaders[PIPE_SHADER_TESS_EVAL]; 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; int next_type = -1;
if (type == PIPE_SHADER_FRAGMENT) { 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; 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)) { if (vrend_state.use_gles && can_emulate_logicop(sub_ctx->blend_state.logicop_func)) {
key->fs.logicop_enabled = sub_ctx->blend_state.logicop_enable; 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) { if (iter->processor.Processor == TGSI_PROCESSOR_VERTEX) {
ctx->attrib_input_mask |= (1 << decl->Range.First); ctx->attrib_input_mask |= (1 << decl->Range.First);
ctx->inputs[i].type = get_type(ctx->key->attrib_signed_int_bitmask, ctx->inputs[i].type = get_type(ctx->key->vs.attrib_signed_int_bitmask,
ctx->key->attrib_unsigned_int_bitmask, ctx->key->vs.attrib_unsigned_int_bitmask,
decl->Range.First); decl->Range.First);
} }
ctx->inputs[i].name = decl->Semantic.Name; 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]; char full_op[PIPE_MAX_COLOR_BUFS][128 + 8];
for (unsigned i = 0; i < ctx->num_outputs; i++) { 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]; scale[i] = mask[i];
switch (ctx->key->fs.logicop_func) { switch (ctx->key->fs.logicop_func) {
case PIPE_LOGICOP_INVERT: case PIPE_LOGICOP_INVERT:

@ -136,8 +136,12 @@ struct vrend_shader_key {
struct vrend_fs_shader_info *fs_info; struct vrend_fs_shader_info *fs_info;
struct vrend_shader_info_out input; struct vrend_shader_info_out input;
struct vrend_shader_info_in output; struct vrend_shader_info_in output;
struct vrend_layout_info prev_stage_generic_and_patch_outputs_layout[64];
union {
struct { struct {
uint8_t surface_component_bits[PIPE_MAX_COLOR_BUFS];
uint32_t coord_replace;
uint8_t swizzle_output_rgb_to_bgr; uint8_t swizzle_output_rgb_to_bgr;
uint8_t cbufs_are_a8_bitmask; uint8_t cbufs_are_a8_bitmask;
uint8_t cbufs_signed_int_bitmask; uint8_t cbufs_signed_int_bitmask;
@ -146,41 +150,41 @@ struct vrend_shader_key {
uint32_t logicop_enabled : 1; uint32_t logicop_enabled : 1;
uint32_t prim_is_points : 1; uint32_t prim_is_points : 1;
uint32_t invert_origin : 1; uint32_t invert_origin : 1;
uint32_t coord_replace;
} fs; } fs;
struct {
uint32_t attrib_signed_int_bitmask; uint32_t attrib_signed_int_bitmask;
uint32_t attrib_unsigned_int_bitmask; uint32_t attrib_unsigned_int_bitmask;
uint32_t compiled_fs_uid; } vs;
};
uint32_t pstipple_tex : 1; uint32_t compiled_fs_uid;
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;
uint8_t alpha_test; uint8_t alpha_test;
uint8_t clip_plane_enable; 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 { struct vrend_shader_cfg {
int glsl_version; uint32_t glsl_version : 12;
int max_draw_buffers; uint32_t max_draw_buffers : 4;
bool use_gles; uint32_t use_gles : 1;
bool use_core_profile; uint32_t use_core_profile : 1;
bool use_explicit_locations; uint32_t use_explicit_locations : 1;
bool has_arrays_of_arrays; uint32_t has_arrays_of_arrays : 1;
bool has_gpu_shader5; uint32_t has_gpu_shader5 : 1;
bool has_es31_compat; uint32_t has_es31_compat : 1;
bool has_conservative_depth; uint32_t has_conservative_depth : 1;
bool use_integer; uint32_t use_integer : 1;
bool has_dual_src_blend; uint32_t has_dual_src_blend : 1;
bool has_fbfetch_coherent; uint32_t has_fbfetch_coherent : 1;
}; };
struct vrend_context; struct vrend_context;

Loading…
Cancel
Save