d3d12: Add unions to encompass shader key stage vars, use in hashing
authorGiancarlo Devich <giancarlodevich@live.com>
Thu, 9 Feb 2023 23:22:51 +0000 (15:22 -0800)
committerMarge Bot <emma+marge@anholt.net>
Mon, 13 Feb 2023 22:57:03 +0000 (22:57 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21247>

src/gallium/drivers/d3d12/d3d12_compiler.cpp
src/gallium/drivers/d3d12/d3d12_compiler.h

index 79dd890..d3d6ed8 100644 (file)
@@ -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. */
index 142a825..85868ad 100644 (file)
@@ -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 {