mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-01-06 05:44:48 +08:00
radv/meta: create itoi layouts on-demand
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30640>
This commit is contained in:
parent
bd00446bb0
commit
1dfb6e19d5
@ -511,13 +511,57 @@ build_nir_itoi_compute_shader(struct radv_device *dev, bool src_3d, bool dst_3d,
|
|||||||
return b.shader;
|
return b.shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VkResult
|
||||||
|
create_itoi_layout(struct radv_device *device)
|
||||||
|
{
|
||||||
|
VkResult result = VK_SUCCESS;
|
||||||
|
|
||||||
|
if (!device->meta_state.itoi.img_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,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
result = radv_meta_create_descriptor_set_layout(device, 2, bindings, &device->meta_state.itoi.img_ds_layout);
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!device->meta_state.itoi.img_p_layout) {
|
||||||
|
const VkPushConstantRange pc_range = {
|
||||||
|
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
|
.size = 24,
|
||||||
|
};
|
||||||
|
|
||||||
|
result = radv_meta_create_pipeline_layout(device, &device->meta_state.itoi.img_ds_layout, 1, &pc_range,
|
||||||
|
&device->meta_state.itoi.img_p_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static VkResult
|
static VkResult
|
||||||
create_itoi_pipeline(struct radv_device *device, bool src_3d, bool dst_3d, int samples, VkPipeline *pipeline)
|
create_itoi_pipeline(struct radv_device *device, bool src_3d, bool dst_3d, int samples, VkPipeline *pipeline)
|
||||||
{
|
{
|
||||||
struct radv_meta_state *state = &device->meta_state;
|
struct radv_meta_state *state = &device->meta_state;
|
||||||
nir_shader *cs = build_nir_itoi_compute_shader(device, src_3d, dst_3d, samples);
|
|
||||||
VkResult result;
|
VkResult result;
|
||||||
|
|
||||||
|
result = create_itoi_layout(device);
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
nir_shader *cs = build_nir_itoi_compute_shader(device, src_3d, dst_3d, samples);
|
||||||
|
|
||||||
result = radv_meta_create_compute_pipeline(device, cs, state->itoi.img_p_layout, pipeline);
|
result = radv_meta_create_compute_pipeline(device, cs, state->itoi.img_p_layout, pipeline);
|
||||||
ralloc_free(cs);
|
ralloc_free(cs);
|
||||||
return result;
|
return result;
|
||||||
@ -564,35 +608,6 @@ radv_device_init_meta_itoi_state(struct radv_device *device, bool on_demand)
|
|||||||
{
|
{
|
||||||
VkResult result;
|
VkResult 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,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
result = radv_meta_create_descriptor_set_layout(device, 2, bindings, &device->meta_state.itoi.img_ds_layout);
|
|
||||||
if (result != VK_SUCCESS)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
const VkPushConstantRange pc_range = {
|
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
.size = 24,
|
|
||||||
};
|
|
||||||
|
|
||||||
result = radv_meta_create_pipeline_layout(device, &device->meta_state.itoi.img_ds_layout, 1, &pc_range,
|
|
||||||
&device->meta_state.itoi.img_p_layout);
|
|
||||||
if (result != VK_SUCCESS)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
if (on_demand)
|
if (on_demand)
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
|
|
||||||
@ -693,10 +708,55 @@ build_nir_itoi_r32g32b32_compute_shader(struct radv_device *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Image to image - special path for R32G32B32 */
|
/* Image to image - special path for R32G32B32 */
|
||||||
|
static VkResult
|
||||||
|
create_itoi_r32g32b32_layout(struct radv_device *device)
|
||||||
|
{
|
||||||
|
VkResult result = VK_SUCCESS;
|
||||||
|
|
||||||
|
if (!device->meta_state.itoi_r32g32b32.img_ds_layout) {
|
||||||
|
const VkDescriptorSetLayoutBinding bindings[] = {
|
||||||
|
{
|
||||||
|
.binding = 0,
|
||||||
|
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.binding = 1,
|
||||||
|
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
result =
|
||||||
|
radv_meta_create_descriptor_set_layout(device, 2, bindings, &device->meta_state.itoi_r32g32b32.img_ds_layout);
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!device->meta_state.itoi_r32g32b32.img_p_layout) {
|
||||||
|
const VkPushConstantRange pc_range = {
|
||||||
|
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
|
.size = 24,
|
||||||
|
};
|
||||||
|
|
||||||
|
result = radv_meta_create_pipeline_layout(device, &device->meta_state.itoi_r32g32b32.img_ds_layout, 1, &pc_range,
|
||||||
|
&device->meta_state.itoi_r32g32b32.img_p_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
static VkResult
|
static VkResult
|
||||||
create_itoi_r32g32b32_pipeline(struct radv_device *device, VkPipeline *pipeline)
|
create_itoi_r32g32b32_pipeline(struct radv_device *device, VkPipeline *pipeline)
|
||||||
{
|
{
|
||||||
VkResult result;
|
VkResult result;
|
||||||
|
|
||||||
|
result = create_itoi_r32g32b32_layout(device);
|
||||||
|
if (result != VK_SUCCESS)
|
||||||
|
return result;
|
||||||
|
|
||||||
nir_shader *cs = build_nir_itoi_r32g32b32_compute_shader(device);
|
nir_shader *cs = build_nir_itoi_r32g32b32_compute_shader(device);
|
||||||
|
|
||||||
result = radv_meta_create_compute_pipeline(device, cs, device->meta_state.itoi_r32g32b32.img_p_layout, pipeline);
|
result = radv_meta_create_compute_pipeline(device, cs, device->meta_state.itoi_r32g32b32.img_p_layout, pipeline);
|
||||||
@ -728,38 +788,6 @@ fail:
|
|||||||
static VkResult
|
static VkResult
|
||||||
radv_device_init_meta_itoi_r32g32b32_state(struct radv_device *device, bool on_demand)
|
radv_device_init_meta_itoi_r32g32b32_state(struct radv_device *device, bool on_demand)
|
||||||
{
|
{
|
||||||
VkResult result;
|
|
||||||
|
|
||||||
const VkDescriptorSetLayoutBinding bindings[] = {
|
|
||||||
{
|
|
||||||
.binding = 0,
|
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
|
|
||||||
.descriptorCount = 1,
|
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.binding = 1,
|
|
||||||
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
|
|
||||||
.descriptorCount = 1,
|
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
result =
|
|
||||||
radv_meta_create_descriptor_set_layout(device, 2, bindings, &device->meta_state.itoi_r32g32b32.img_ds_layout);
|
|
||||||
if (result != VK_SUCCESS)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
const VkPushConstantRange pc_range = {
|
|
||||||
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
|
||||||
.size = 24,
|
|
||||||
};
|
|
||||||
|
|
||||||
result = radv_meta_create_pipeline_layout(device, &device->meta_state.itoi_r32g32b32.img_ds_layout, 1, &pc_range,
|
|
||||||
&device->meta_state.itoi_r32g32b32.img_p_layout);
|
|
||||||
if (result != VK_SUCCESS)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
if (on_demand)
|
if (on_demand)
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user