zink: move gpl usability checks to static inline for reuse
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 6 Feb 2023 19:36:22 +0000 (14:36 -0500)
committerMarge Bot <emma+marge@anholt.net>
Wed, 8 Feb 2023 02:35:36 +0000 (02:35 +0000)
Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21169>

src/gallium/drivers/zink/zink_program.h
src/gallium/drivers/zink/zink_program_state.hpp

index 1c59431..a154b9e 100644 (file)
@@ -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
index 0e78e9e..70514ae 100644 (file)
@@ -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;