diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 8a12466c45b..b667cfff67d 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -5149,6 +5149,19 @@ zink_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) ctx->di.db.texel_images[i][j].sType = VK_STRUCTURE_TYPE_DESCRIPTOR_ADDRESS_INFO_EXT; } } + if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB) { + assert(sizeof(ctx->di.fbfetch_db) <= screen->info.db_props.inputAttachmentDescriptorSize); + /* cache null fbfetch descriptor info */ + ctx->di.fbfetch.imageView = zink_get_dummy_surface(ctx, 0)->image_view; + ctx->di.fbfetch.imageLayout = VK_IMAGE_LAYOUT_GENERAL; + VkDescriptorGetInfoEXT info; + info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT; + info.pNext = NULL; + info.type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; + info.data.pInputAttachmentImage = &ctx->di.fbfetch; + VKSCR(GetDescriptorEXT)(screen->dev, &info, screen->info.db_props.inputAttachmentDescriptorSize, ctx->di.fbfetch_db); + memset(&ctx->di.fbfetch, 0, sizeof(ctx->di.fbfetch)); + } if (!screen->info.rb2_feats.nullDescriptor) ctx->di.fbfetch.imageView = zink_get_dummy_surface(ctx, 0)->image_view; diff --git a/src/gallium/drivers/zink/zink_descriptors.c b/src/gallium/drivers/zink/zink_descriptors.c index 265191406a6..c733615c064 100644 --- a/src/gallium/drivers/zink/zink_descriptors.c +++ b/src/gallium/drivers/zink/zink_descriptors.c @@ -1140,14 +1140,20 @@ zink_descriptors_update(struct zink_context *ctx, bool is_compute) bs->dd.db_map[ZINK_DESCRIPTOR_TYPE_UNIFORMS] + stage_offset); } if (!is_compute && ctx->dd.has_fbfetch) { - VkDescriptorGetInfoEXT info; - info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT; - info.pNext = NULL; - info.type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; - info.data.pInputAttachmentImage = &ctx->di.fbfetch; uint64_t stage_offset = offset + ctx->dd.db_offset[MESA_SHADER_FRAGMENT + 1]; - VKSCR(GetDescriptorEXT)(screen->dev, &info, screen->info.db_props.robustUniformBufferDescriptorSize, - bs->dd.db_map[ZINK_DESCRIPTOR_TYPE_UNIFORMS] + stage_offset); + if (pg->dd.fbfetch) { + /* real fbfetch descriptor */ + VkDescriptorGetInfoEXT info; + info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT; + info.pNext = NULL; + info.type = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT; + info.data.pInputAttachmentImage = &ctx->di.fbfetch; + VKSCR(GetDescriptorEXT)(screen->dev, &info, screen->info.db_props.inputAttachmentDescriptorSize, + bs->dd.db_map[ZINK_DESCRIPTOR_TYPE_UNIFORMS] + stage_offset); + } else { + /* reuse cached dummy descriptor */ + memcpy(bs->dd.db_map[ZINK_DESCRIPTOR_TYPE_UNIFORMS] + stage_offset, ctx->di.fbfetch_db, screen->info.db_props.inputAttachmentDescriptorSize); + } } bs->dd.cur_db_offset[ZINK_DESCRIPTOR_TYPE_UNIFORMS] = bs->dd.db_offset[ZINK_DESCRIPTOR_TYPE_UNIFORMS]; bs->dd.db_offset[ZINK_DESCRIPTOR_TYPE_UNIFORMS] += ctx->dd.db_size[is_compute]; diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index 6e33f2243ff..cb3e6933662 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -1737,6 +1737,7 @@ struct zink_context { }; VkDescriptorImageInfo fbfetch; + uint8_t fbfetch_db[64]; //max size from gpuinfo /* the current state of the shadow swizzle data */ struct zink_fs_shadow_key shadow;