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

Author: Mike Blumenkrantz <[email protected]>
Date:   Mon Feb  6 14:36:22 2023 -0500

zink: move gpl usability checks to static inline for reuse

Reviewed-by: Emma Anholt <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21169>

---

 src/gallium/drivers/zink/zink_program.h         | 15 +++++++++++++++
 src/gallium/drivers/zink/zink_program_state.hpp | 11 +----------
 2 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/zink/zink_program.h 
b/src/gallium/drivers/zink/zink_program.h
index 1c59431d57f..a154b9e08b4 100644
--- a/src/gallium/drivers/zink/zink_program.h
+++ b/src/gallium/drivers/zink/zink_program.h
@@ -382,6 +382,21 @@ zink_set_shader_key_base(struct zink_context *ctx, 
gl_shader_stage pstage)
    return &ctx->gfx_pipeline_state.shader_keys.key[pstage].base;
 }
 
+ALWAYS_INLINE static bool
+zink_can_use_pipeline_libs(const struct zink_context *ctx)
+{
+   return
+          /* TODO: if there's ever a dynamic render extension with input 
attachments */
+          !ctx->gfx_pipeline_state.render_pass &&
+          /* this is just terrible */
+          !zink_get_fs_base_key(ctx)->shadow_needs_shader_swizzle &&
+          /* TODO: is sample shading even possible to handle with GPL? */
+          
!ctx->gfx_stages[MESA_SHADER_FRAGMENT]->nir->info.fs.uses_sample_shading &&
+          !zink_get_fs_base_key(ctx)->fbfetch_ms &&
+          !ctx->gfx_pipeline_state.force_persample_interp &&
+          !ctx->gfx_pipeline_state.min_samples;
+}
+
 bool
 zink_set_rasterizer_discard(struct zink_context *ctx, bool disable);
 void
diff --git a/src/gallium/drivers/zink/zink_program_state.hpp 
b/src/gallium/drivers/zink/zink_program_state.hpp
index 0e78e9ea9c1..70514ae93bf 100644
--- a/src/gallium/drivers/zink/zink_program_state.hpp
+++ b/src/gallium/drivers/zink/zink_program_state.hpp
@@ -251,16 +251,7 @@ zink_get_gfx_pipeline(struct zink_context *ctx,
       /* init the optimized background compile fence */
       util_queue_fence_init(&pc_entry->fence);
       entry = 
_mesa_hash_table_insert_pre_hashed(&prog->pipelines[rp_idx][idx], 
state->final_hash, pc_entry, pc_entry);
-      if (HAVE_LIB &&
-          /* TODO: if there's ever a dynamic render extension with input 
attachments */
-          !ctx->gfx_pipeline_state.render_pass &&
-          /* this is just terrible */
-          !zink_get_fs_base_key(ctx)->shadow_needs_shader_swizzle &&
-          /* TODO: is sample shading even possible to handle with GPL? */
-          
!ctx->gfx_stages[MESA_SHADER_FRAGMENT]->nir->info.fs.uses_sample_shading &&
-          !zink_get_fs_base_key(ctx)->fbfetch_ms &&
-          !ctx->gfx_pipeline_state.force_persample_interp &&
-          !ctx->gfx_pipeline_state.min_samples) {
+      if (HAVE_LIB && zink_can_use_pipeline_libs(ctx)) {
          /* this is the graphics pipeline library path: find/construct all 
partial pipelines */
          struct set_entry *he = _mesa_set_search(&prog->libs, 
&ctx->gfx_pipeline_state.optimal_key);
          struct zink_gfx_library_key *gkey;

Reply via email to