zink: hash blend state pointers on creation
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Thu, 17 Jun 2021 20:05:00 +0000 (16:05 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 7 Sep 2021 13:03:08 +0000 (13:03 +0000)
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12660>

src/gallium/drivers/zink/zink_pipeline.h
src/gallium/drivers/zink/zink_state.c
src/gallium/drivers/zink/zink_state.h

index 5297189..c829204 100644 (file)
@@ -46,7 +46,7 @@ struct zink_gfx_pipeline_state {
    VkSampleMask sample_mask;
 
    unsigned rp_state;
-   struct zink_blend_state *blend_state;
+   uint32_t blend_id;
 
    /* Pre-hashed value for table lookup, invalid when zero.
     * Members after this point are not included in pipeline state hash key */
@@ -74,6 +74,7 @@ struct zink_gfx_pipeline_state {
    bool sample_locations_enabled;
    bool have_EXT_extended_dynamic_state;
    bool have_EXT_extended_dynamic_state2;
+   struct zink_blend_state *blend_state;
    struct zink_render_pass *render_pass;
    VkPipeline pipeline;
    uint8_t patch_vertices;
index 9d29513..0a77943 100644 (file)
@@ -251,6 +251,7 @@ zink_create_blend_state(struct pipe_context *pctx,
    struct zink_blend_state *cso = CALLOC_STRUCT(zink_blend_state);
    if (!cso)
       return NULL;
+   cso->hash = _mesa_hash_pointer(cso);
 
    if (blend_state->logicop_enable) {
       cso->logicop_enable = VK_TRUE;
@@ -313,9 +314,11 @@ zink_bind_blend_state(struct pipe_context *pctx, void *cso)
 {
    struct zink_context *ctx = zink_context(pctx);
    struct zink_gfx_pipeline_state* state = &zink_context(pctx)->gfx_pipeline_state;
+   struct zink_blend_state *blend = cso;
 
    if (state->blend_state != cso) {
       state->blend_state = cso;
+      state->blend_id = blend ? blend->hash : 0;
       state->dirty = true;
       ctx->blend_state_changed = true;
    }
index f43d432..e9c33c1 100644 (file)
@@ -79,6 +79,7 @@ struct zink_rasterizer_state {
 };
 
 struct zink_blend_state {
+   uint32_t hash;
    VkPipelineColorBlendAttachmentState attachments[PIPE_MAX_COLOR_BUFS];
 
    VkBool32 logicop_enable;