radv: Update descriptor sets for multiple planes.
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
This commit is contained in:
@@ -563,7 +563,7 @@ radv_descriptor_set_create(struct radv_device *device,
|
|||||||
|
|
||||||
unsigned offset = layout->binding[i].offset / 4;
|
unsigned offset = layout->binding[i].offset / 4;
|
||||||
if (layout->binding[i].type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
|
if (layout->binding[i].type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
|
||||||
offset += 16;
|
offset += radv_combined_image_descriptor_sampler_offset(layout->binding + i) / 4;
|
||||||
|
|
||||||
const uint32_t *samplers = (const uint32_t*)((const char*)layout + layout->binding[i].immutable_samplers_offset);
|
const uint32_t *samplers = (const uint32_t*)((const char*)layout + layout->binding[i].immutable_samplers_offset);
|
||||||
for (unsigned j = 0; j < layout->binding[i].array_size; ++j) {
|
for (unsigned j = 0; j < layout->binding[i].array_size; ++j) {
|
||||||
@@ -882,7 +882,7 @@ static void write_dynamic_buffer_descriptor(struct radv_device *device,
|
|||||||
static void
|
static void
|
||||||
write_image_descriptor(struct radv_device *device,
|
write_image_descriptor(struct radv_device *device,
|
||||||
struct radv_cmd_buffer *cmd_buffer,
|
struct radv_cmd_buffer *cmd_buffer,
|
||||||
unsigned *dst,
|
unsigned size, unsigned *dst,
|
||||||
struct radeon_winsys_bo **buffer_list,
|
struct radeon_winsys_bo **buffer_list,
|
||||||
VkDescriptorType descriptor_type,
|
VkDescriptorType descriptor_type,
|
||||||
const VkDescriptorImageInfo *image_info)
|
const VkDescriptorImageInfo *image_info)
|
||||||
@@ -896,7 +896,7 @@ write_image_descriptor(struct radv_device *device,
|
|||||||
descriptor = &iview->descriptor;
|
descriptor = &iview->descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(dst, descriptor, 16 * 4);
|
memcpy(dst, descriptor, size);
|
||||||
|
|
||||||
if (cmd_buffer)
|
if (cmd_buffer)
|
||||||
radv_cs_add_buffer(device->ws, cmd_buffer->cs, iview->bo);
|
radv_cs_add_buffer(device->ws, cmd_buffer->cs, iview->bo);
|
||||||
@@ -907,6 +907,7 @@ write_image_descriptor(struct radv_device *device,
|
|||||||
static void
|
static void
|
||||||
write_combined_image_sampler_descriptor(struct radv_device *device,
|
write_combined_image_sampler_descriptor(struct radv_device *device,
|
||||||
struct radv_cmd_buffer *cmd_buffer,
|
struct radv_cmd_buffer *cmd_buffer,
|
||||||
|
unsigned sampler_offset,
|
||||||
unsigned *dst,
|
unsigned *dst,
|
||||||
struct radeon_winsys_bo **buffer_list,
|
struct radeon_winsys_bo **buffer_list,
|
||||||
VkDescriptorType descriptor_type,
|
VkDescriptorType descriptor_type,
|
||||||
@@ -915,10 +916,12 @@ write_combined_image_sampler_descriptor(struct radv_device *device,
|
|||||||
{
|
{
|
||||||
RADV_FROM_HANDLE(radv_sampler, sampler, image_info->sampler);
|
RADV_FROM_HANDLE(radv_sampler, sampler, image_info->sampler);
|
||||||
|
|
||||||
write_image_descriptor(device, cmd_buffer, dst, buffer_list, descriptor_type, image_info);
|
write_image_descriptor(device, cmd_buffer, sampler_offset, dst, buffer_list,
|
||||||
|
descriptor_type, image_info);
|
||||||
/* copy over sampler state */
|
/* copy over sampler state */
|
||||||
if (has_sampler)
|
if (has_sampler) {
|
||||||
memcpy(dst + 16, sampler->state, 16);
|
memcpy(dst + sampler_offset / sizeof(*dst), sampler->state, 16);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -991,20 +994,23 @@ void radv_update_descriptor_sets(
|
|||||||
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||||
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||||
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
||||||
write_image_descriptor(device, cmd_buffer, ptr, buffer_list,
|
write_image_descriptor(device, cmd_buffer, 64, ptr, buffer_list,
|
||||||
writeset->descriptorType,
|
writeset->descriptorType,
|
||||||
writeset->pImageInfo + j);
|
writeset->pImageInfo + j);
|
||||||
break;
|
break;
|
||||||
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: {
|
||||||
write_combined_image_sampler_descriptor(device, cmd_buffer, ptr, buffer_list,
|
unsigned sampler_offset = radv_combined_image_descriptor_sampler_offset(binding_layout);
|
||||||
|
write_combined_image_sampler_descriptor(device, cmd_buffer, sampler_offset,
|
||||||
|
ptr, buffer_list,
|
||||||
writeset->descriptorType,
|
writeset->descriptorType,
|
||||||
writeset->pImageInfo + j,
|
writeset->pImageInfo + j,
|
||||||
!binding_layout->immutable_samplers_offset);
|
!binding_layout->immutable_samplers_offset);
|
||||||
if (copy_immutable_samplers) {
|
if (copy_immutable_samplers) {
|
||||||
const unsigned idx = writeset->dstArrayElement + j;
|
const unsigned idx = writeset->dstArrayElement + j;
|
||||||
memcpy(ptr + 16, samplers + 4 * idx, 16);
|
memcpy((char*)ptr + sampler_offset, samplers + 4 * idx, 16);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||||
if (!binding_layout->immutable_samplers_offset) {
|
if (!binding_layout->immutable_samplers_offset) {
|
||||||
write_sampler_descriptor(device, ptr,
|
write_sampler_descriptor(device, ptr,
|
||||||
@@ -1163,6 +1169,7 @@ VkResult radv_CreateDescriptorUpdateTemplate(VkDevice _device,
|
|||||||
.dst_stride = dst_stride,
|
.dst_stride = dst_stride,
|
||||||
.buffer_offset = buffer_offset,
|
.buffer_offset = buffer_offset,
|
||||||
.has_sampler = !binding_layout->immutable_samplers_offset,
|
.has_sampler = !binding_layout->immutable_samplers_offset,
|
||||||
|
.sampler_offset = radv_combined_image_descriptor_sampler_offset(binding_layout),
|
||||||
.immutable_samplers = immutable_samplers
|
.immutable_samplers = immutable_samplers
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1227,17 +1234,18 @@ void radv_update_descriptor_set_with_template(struct radv_device *device,
|
|||||||
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||||
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||||
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
||||||
write_image_descriptor(device, cmd_buffer, pDst, buffer_list,
|
write_image_descriptor(device, cmd_buffer, 64, pDst, buffer_list,
|
||||||
templ->entry[i].descriptor_type,
|
templ->entry[i].descriptor_type,
|
||||||
(struct VkDescriptorImageInfo *) pSrc);
|
(struct VkDescriptorImageInfo *) pSrc);
|
||||||
break;
|
break;
|
||||||
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
||||||
write_combined_image_sampler_descriptor(device, cmd_buffer, pDst, buffer_list,
|
write_combined_image_sampler_descriptor(device, cmd_buffer, templ->entry[i].sampler_offset,
|
||||||
templ->entry[i].descriptor_type,
|
pDst, buffer_list, templ->entry[i].descriptor_type,
|
||||||
(struct VkDescriptorImageInfo *) pSrc,
|
(struct VkDescriptorImageInfo *) pSrc,
|
||||||
templ->entry[i].has_sampler);
|
templ->entry[i].has_sampler);
|
||||||
if (templ->entry[i].immutable_samplers)
|
if (templ->entry[i].immutable_samplers) {
|
||||||
memcpy(pDst + 16, templ->entry[i].immutable_samplers + 4 * j, 16);
|
memcpy((char*)pDst + templ->entry[i].sampler_offset, templ->entry[i].immutable_samplers + 4 * j, 16);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||||
if (templ->entry[i].has_sampler)
|
if (templ->entry[i].has_sampler)
|
||||||
|
@@ -1978,8 +1978,9 @@ static LLVMValueRef radv_get_sampler_desc(struct ac_shader_abi *abi,
|
|||||||
break;
|
break;
|
||||||
case AC_DESC_SAMPLER:
|
case AC_DESC_SAMPLER:
|
||||||
type = ctx->ac.v4i32;
|
type = ctx->ac.v4i32;
|
||||||
if (binding->type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
|
if (binding->type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) {
|
||||||
offset += 64;
|
offset += radv_combined_image_descriptor_sampler_offset(binding);
|
||||||
|
}
|
||||||
|
|
||||||
type_size = 16;
|
type_size = 16;
|
||||||
break;
|
break;
|
||||||
@@ -1987,6 +1988,13 @@ static LLVMValueRef radv_get_sampler_desc(struct ac_shader_abi *abi,
|
|||||||
type = ctx->ac.v4i32;
|
type = ctx->ac.v4i32;
|
||||||
type_size = 16;
|
type_size = 16;
|
||||||
break;
|
break;
|
||||||
|
case AC_DESC_PLANE_0:
|
||||||
|
case AC_DESC_PLANE_1:
|
||||||
|
case AC_DESC_PLANE_2:
|
||||||
|
type = ctx->ac.v8i32;
|
||||||
|
type_size = 32;
|
||||||
|
offset += 32 * (desc_type - AC_DESC_PLANE_0);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
unreachable("invalid desc_type\n");
|
unreachable("invalid desc_type\n");
|
||||||
}
|
}
|
||||||
|
@@ -809,7 +809,8 @@ struct radv_descriptor_update_template_entry {
|
|||||||
uint32_t buffer_offset;
|
uint32_t buffer_offset;
|
||||||
|
|
||||||
/* Only valid for combined image samplers and samplers */
|
/* Only valid for combined image samplers and samplers */
|
||||||
uint16_t has_sampler;
|
uint8_t has_sampler;
|
||||||
|
uint8_t sampler_offset;
|
||||||
|
|
||||||
/* In bytes */
|
/* In bytes */
|
||||||
size_t src_offset;
|
size_t src_offset;
|
||||||
|
Reference in New Issue
Block a user