mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
radv/meta: convert the FMASK copy pipelines to vk_meta
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32744>
This commit is contained in:
parent
a3aeeab434
commit
4521eb1b2b
4 changed files with 54 additions and 96 deletions
|
|
@ -495,12 +495,6 @@ radv_device_init_meta(struct radv_device *device)
|
|||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
if (pdev->use_fmask) {
|
||||
result = radv_device_init_meta_fmask_copy_state(device, on_demand);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
}
|
||||
|
||||
result = radv_device_init_meta_etc_decode_state(device, on_demand);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
|
@ -557,7 +551,6 @@ radv_device_finish_meta(struct radv_device *device)
|
|||
radv_device_finish_meta_resolve_compute_state(device);
|
||||
radv_device_finish_meta_resolve_fragment_state(device);
|
||||
radv_device_finish_meta_dcc_retile_state(device);
|
||||
radv_device_finish_meta_fmask_copy_state(device);
|
||||
|
||||
radv_store_meta_pipeline(device);
|
||||
vk_common_DestroyPipelineCache(radv_device_to_handle(device), device->meta_state.cache, NULL);
|
||||
|
|
|
|||
|
|
@ -132,9 +132,6 @@ void radv_device_finish_meta_resolve_compute_state(struct radv_device *device);
|
|||
VkResult radv_device_init_meta_resolve_fragment_state(struct radv_device *device, bool on_demand);
|
||||
void radv_device_finish_meta_resolve_fragment_state(struct radv_device *device);
|
||||
|
||||
VkResult radv_device_init_meta_fmask_copy_state(struct radv_device *device, bool on_demand);
|
||||
void radv_device_finish_meta_fmask_copy_state(struct radv_device *device);
|
||||
|
||||
void radv_device_finish_meta_dcc_retile_state(struct radv_device *device);
|
||||
|
||||
VkResult radv_device_init_null_accel_struct(struct radv_device *device);
|
||||
|
|
|
|||
|
|
@ -83,98 +83,71 @@ build_fmask_copy_compute_shader(struct radv_device *dev, int samples)
|
|||
}
|
||||
|
||||
static VkResult
|
||||
create_pipeline(struct radv_device *device, int samples, VkPipeline *pipeline)
|
||||
get_pipeline(struct radv_device *device, uint32_t samples_log2, VkPipeline *pipeline_out, VkPipelineLayout *layout_out)
|
||||
{
|
||||
struct radv_meta_state *state = &device->meta_state;
|
||||
const uint32_t samples = 1 << samples_log2;
|
||||
char key_data[64];
|
||||
VkResult result;
|
||||
|
||||
if (!state->fmask_copy.ds_layout) {
|
||||
const VkDescriptorSetLayoutBinding bindings[] = {
|
||||
{
|
||||
.binding = 0,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||
},
|
||||
{
|
||||
.binding = 1,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||
},
|
||||
};
|
||||
snprintf(key_data, sizeof(key_data), "radv-fmask-copy-%d", samples);
|
||||
|
||||
result = radv_meta_create_descriptor_set_layout(device, 2, bindings, &state->fmask_copy.ds_layout);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
}
|
||||
const VkDescriptorSetLayoutBinding bindings[] = {
|
||||
{
|
||||
.binding = 0,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||
},
|
||||
{
|
||||
.binding = 1,
|
||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||
.descriptorCount = 1,
|
||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||
},
|
||||
};
|
||||
|
||||
if (!state->fmask_copy.p_layout) {
|
||||
result =
|
||||
radv_meta_create_pipeline_layout(device, &state->fmask_copy.ds_layout, 0, NULL, &state->fmask_copy.p_layout);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
const VkDescriptorSetLayoutCreateInfo desc_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||
.flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT,
|
||||
.bindingCount = 2,
|
||||
.pBindings = bindings,
|
||||
};
|
||||
|
||||
result = vk_meta_get_pipeline_layout(&device->vk, &device->meta_state.device, &desc_info, NULL, key_data,
|
||||
strlen(key_data), layout_out);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
VkPipeline pipeline_from_cache = vk_meta_lookup_pipeline(&device->meta_state.device, key_data, strlen(key_data));
|
||||
if (pipeline_from_cache != VK_NULL_HANDLE) {
|
||||
*pipeline_out = pipeline_from_cache;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
nir_shader *cs = build_fmask_copy_compute_shader(device, samples);
|
||||
|
||||
result = radv_meta_create_compute_pipeline(device, cs, state->fmask_copy.p_layout, pipeline);
|
||||
const VkPipelineShaderStageCreateInfo stage_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||
.stage = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||
.module = vk_shader_module_handle_from_nir(cs),
|
||||
.pName = "main",
|
||||
.pSpecializationInfo = NULL,
|
||||
};
|
||||
|
||||
const VkComputePipelineCreateInfo pipeline_info = {
|
||||
.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
|
||||
.stage = stage_info,
|
||||
.flags = 0,
|
||||
.layout = *layout_out,
|
||||
};
|
||||
|
||||
result = vk_meta_create_compute_pipeline(&device->vk, &device->meta_state.device, &pipeline_info, key_data,
|
||||
strlen(key_data), pipeline_out);
|
||||
|
||||
ralloc_free(cs);
|
||||
return result;
|
||||
}
|
||||
|
||||
static VkResult
|
||||
get_pipeline(struct radv_device *device, uint32_t samples_log2, VkPipeline *pipeline_out)
|
||||
{
|
||||
struct radv_meta_state *state = &device->meta_state;
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
mtx_lock(&state->mtx);
|
||||
if (!state->fmask_copy.pipeline[samples_log2]) {
|
||||
result = create_pipeline(device, 1 << samples_log2, &state->fmask_copy.pipeline[samples_log2]);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
*pipeline_out = state->fmask_copy.pipeline[samples_log2];
|
||||
|
||||
fail:
|
||||
mtx_unlock(&state->mtx);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
radv_device_finish_meta_fmask_copy_state(struct radv_device *device)
|
||||
{
|
||||
struct radv_meta_state *state = &device->meta_state;
|
||||
|
||||
radv_DestroyPipelineLayout(radv_device_to_handle(device), state->fmask_copy.p_layout, &state->alloc);
|
||||
device->vk.dispatch_table.DestroyDescriptorSetLayout(radv_device_to_handle(device), state->fmask_copy.ds_layout,
|
||||
&state->alloc);
|
||||
|
||||
for (uint32_t i = 0; i < MAX_SAMPLES_LOG2; ++i) {
|
||||
radv_DestroyPipeline(radv_device_to_handle(device), state->fmask_copy.pipeline[i], &state->alloc);
|
||||
}
|
||||
}
|
||||
|
||||
VkResult
|
||||
radv_device_init_meta_fmask_copy_state(struct radv_device *device, bool on_demand)
|
||||
{
|
||||
VkResult result;
|
||||
|
||||
if (on_demand)
|
||||
return VK_SUCCESS;
|
||||
|
||||
for (uint32_t i = 0; i < MAX_SAMPLES_LOG2; i++) {
|
||||
result = create_pipeline(device, 1u << i, &device->meta_state.fmask_copy.pipeline[i]);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
}
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
radv_fixup_copy_dst_metadata(struct radv_cmd_buffer *cmd_buffer, const struct radv_image *src_image,
|
||||
const struct radv_image *dst_image)
|
||||
|
|
@ -246,10 +219,11 @@ radv_fmask_copy(struct radv_cmd_buffer *cmd_buffer, struct radv_meta_blit2d_surf
|
|||
struct radv_image_view src_iview, dst_iview;
|
||||
uint32_t samples = src->image->vk.samples;
|
||||
uint32_t samples_log2 = ffs(samples) - 1;
|
||||
VkPipelineLayout layout;
|
||||
VkPipeline pipeline;
|
||||
VkResult result;
|
||||
|
||||
result = get_pipeline(device, samples_log2, &pipeline);
|
||||
result = get_pipeline(device, samples_log2, &pipeline, &layout);
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_command_buffer_set_error(&cmd_buffer->vk, result);
|
||||
return;
|
||||
|
|
@ -291,8 +265,7 @@ radv_fmask_copy(struct radv_cmd_buffer *cmd_buffer, struct radv_meta_blit2d_surf
|
|||
},
|
||||
NULL);
|
||||
|
||||
radv_meta_push_descriptor_set(cmd_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, device->meta_state.fmask_copy.p_layout, 0,
|
||||
2,
|
||||
radv_meta_push_descriptor_set(cmd_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, layout, 0, 2,
|
||||
(VkWriteDescriptorSet[]){{.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.dstBinding = 0,
|
||||
.dstArrayElement = 0,
|
||||
|
|
|
|||
|
|
@ -192,11 +192,6 @@ struct radv_meta_state {
|
|||
VkDescriptorSetLayout img_ds_layout;
|
||||
VkPipeline pipeline;
|
||||
} cleari_r32g32b32;
|
||||
struct {
|
||||
VkPipelineLayout p_layout;
|
||||
VkDescriptorSetLayout ds_layout;
|
||||
VkPipeline pipeline[MAX_SAMPLES_LOG2];
|
||||
} fmask_copy;
|
||||
|
||||
struct {
|
||||
VkPipelineLayout p_layout;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue