d3d12: Compare shader key common parts with memcmp, instead of if's
authorGiancarlo Devich <gdevich@microsoft.com>
Tue, 28 Feb 2023 23:49:15 +0000 (15:49 -0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 1 Mar 2023 19:40:06 +0000 (19:40 +0000)
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21610>

src/gallium/drivers/d3d12/d3d12_compiler.cpp

index 5ebf49b..5d5055d 100644 (file)
@@ -803,18 +803,13 @@ d3d12_compare_shader_keys(struct d3d12_selection_context* sel_ctx, const d3d12_s
    default:
       unreachable("invalid stage");
    }
-
-   if (expect->input_clip_size != have->input_clip_size)
-      return false;
-
-   if (expect->tex_saturate_s != have->tex_saturate_s ||
-       expect->tex_saturate_r != have->tex_saturate_r ||
-       expect->tex_saturate_t != have->tex_saturate_t)
-      return false;
-
-   if (expect->samples_int_textures != have->samples_int_textures)
+   
+   
+   if (memcmp(&expect->next_varying_inputs,
+              &have->next_varying_inputs,
+              offsetof(d3d12_shader_key, vs) - offsetof(d3d12_shader_key, next_varying_inputs)) != 0)
       return false;
-
+   
    if (expect->n_texture_states != have->n_texture_states)
       return false;
 
@@ -837,21 +832,15 @@ d3d12_compare_shader_keys(struct d3d12_selection_context* sel_ctx, const d3d12_s
       expect->n_images * sizeof(struct d3d12_image_format_conversion_info)))
       return false;
 
-   if (expect->invert_depth != have->invert_depth ||
-       expect->halfz != have->halfz)
-      return false;
-
    /* Because we only add varyings we check that a shader has at least the expected in-
     * and outputs. */
 
    if (!d3d12_compare_varying_info(expect->required_varying_inputs,
-                                   have->required_varying_inputs) ||
-       expect->next_varying_inputs != have->next_varying_inputs)
+                                   have->required_varying_inputs))
       return false;
 
    if (!d3d12_compare_varying_info(expect->required_varying_outputs,
-                                   have->required_varying_outputs) ||
-       expect->prev_varying_outputs != have->prev_varying_outputs)
+                                   have->required_varying_outputs))
       return false;
 
    return true;