Module: Mesa
Branch: main
Commit: e4ba343ac913989829bef71d23dd913ea4d84a03
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e4ba343ac913989829bef71d23dd913ea4d84a03

Author: Giancarlo Devich <[email protected]>
Date:   Tue Feb 28 15:49:15 2023 -0800

d3d12: Compare shader key common parts with memcmp, instead of if's

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21610>

---

 src/gallium/drivers/d3d12/d3d12_compiler.cpp | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/src/gallium/drivers/d3d12/d3d12_compiler.cpp 
b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
index 5ebf49b7d71..5d5055db1d9 100644
--- a/src/gallium/drivers/d3d12/d3d12_compiler.cpp
+++ b/src/gallium/drivers/d3d12/d3d12_compiler.cpp
@@ -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;

Reply via email to