From b2e54841716f0c5cb8f844b43d0ea1907a3084de Mon Sep 17 00:00:00 2001 From: Giancarlo Devich Date: Thu, 9 Feb 2023 15:22:51 -0800 Subject: [PATCH] d3d12: Add unions to encompass shader key stage vars, use in hashing Part-of: --- src/gallium/drivers/d3d12/d3d12_compiler.cpp | 8 ++-- src/gallium/drivers/d3d12/d3d12_compiler.h | 65 ++++++++++++++++------------ 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/gallium/drivers/d3d12/d3d12_compiler.cpp b/src/gallium/drivers/d3d12/d3d12_compiler.cpp index 79dd890..d3d6ed8 100644 --- a/src/gallium/drivers/d3d12/d3d12_compiler.cpp +++ b/src/gallium/drivers/d3d12/d3d12_compiler.cpp @@ -834,20 +834,22 @@ d3d12_shader_key_hash(const d3d12_shader_key *key) * hashing for now until this is shown to be worthwhile. */ break; case PIPE_SHADER_GEOMETRY: - hash = _mesa_hash_data_with_seed(&key->gs, sizeof(key->gs), hash); + hash += key->gs.all; break; case PIPE_SHADER_FRAGMENT: - hash = _mesa_hash_data_with_seed(&key->fs, sizeof(key->fs), hash); + hash += key->fs.all; break; case PIPE_SHADER_COMPUTE: hash = _mesa_hash_data_with_seed(&key->cs, sizeof(key->cs), hash); break; case PIPE_SHADER_TESS_CTRL: - hash += key->hs.next_patch_inputs; + hash += key->hs.all; + hash += key->hs.required_patch_outputs.mask; break; case PIPE_SHADER_TESS_EVAL: hash += key->ds.tcs_vertices_out; hash += key->ds.prev_patch_outputs; + hash += key->ds.required_patch_inputs.mask; break; default: /* No type specific information to hash for other stages. */ diff --git a/src/gallium/drivers/d3d12/d3d12_compiler.h b/src/gallium/drivers/d3d12/d3d12_compiler.h index 142a825..85868ad 100644 --- a/src/gallium/drivers/d3d12/d3d12_compiler.h +++ b/src/gallium/drivers/d3d12/d3d12_compiler.h @@ -104,44 +104,55 @@ struct d3d12_shader_key { enum pipe_format format_conversion[PIPE_MAX_ATTRIBS]; } vs; - struct { - unsigned sprite_coord_enable:24; - unsigned sprite_origin_upper_left:1; - unsigned point_pos_stream_out:1; - unsigned writes_psize:1; - unsigned point_size_per_vertex:1; - unsigned aa_point:1; - unsigned stream_output_factor:3; - unsigned primitive_id:1; - unsigned triangle_strip:1; + union { + struct { + unsigned sprite_coord_enable:24; + unsigned sprite_origin_upper_left:1; + unsigned point_pos_stream_out:1; + unsigned writes_psize:1; + unsigned point_size_per_vertex:1; + unsigned aa_point:1; + unsigned stream_output_factor:3; + unsigned primitive_id:1; + unsigned triangle_strip:1; + }; + uint64_t all; } gs; struct { - unsigned primitive_mode:2; - unsigned ccw:1; - unsigned point_mode:1; - unsigned spacing:2; - unsigned patch_vertices_in:5; + union { + struct { + uint32_t next_patch_inputs; + unsigned primitive_mode:2; + unsigned ccw:1; + unsigned point_mode:1; + unsigned spacing:2; + unsigned patch_vertices_in:5; + }; + uint64_t all; + }; struct d3d12_varying_info required_patch_outputs; - uint32_t next_patch_inputs; } hs; struct { unsigned tcs_vertices_out; - struct d3d12_varying_info required_patch_inputs; uint32_t prev_patch_outputs; + struct d3d12_varying_info required_patch_inputs; } ds; - struct { - unsigned missing_dual_src_outputs : 2; - unsigned frag_result_color_lowering : 4; - unsigned cast_to_uint : 1; - unsigned cast_to_int : 1; - unsigned provoking_vertex : 2; - unsigned manual_depth_range : 1; - unsigned polygon_stipple : 1; - unsigned remap_front_facing : 1; - unsigned multisample_disabled : 1; + union { + struct { + unsigned missing_dual_src_outputs : 2; + unsigned frag_result_color_lowering : 4; + unsigned cast_to_uint : 1; + unsigned cast_to_int : 1; + unsigned provoking_vertex : 2; + unsigned manual_depth_range : 1; + unsigned polygon_stipple : 1; + unsigned remap_front_facing : 1; + unsigned multisample_disabled : 1; + }; + unsigned short all; } fs; struct { -- 2.7.4