mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 13:58:04 +02:00
pvr: preliminary support for combined image samplers
Signed-off-by: Simon Perretta <simon.perretta@imgtec.com> Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36412>
This commit is contained in:
parent
0ecaad3145
commit
eb04027350
3 changed files with 43 additions and 0 deletions
|
|
@ -78,6 +78,9 @@ typedef struct _pco_cs_data {
|
|||
typedef struct _pco_binding_data {
|
||||
pco_range range; /** Descriptor location range. */
|
||||
bool used; /** Whether the descriptor binding is used by the shader. */
|
||||
|
||||
/** Whether the descriptor binding is a combined image sampler. */
|
||||
bool is_img_smp;
|
||||
} pco_binding_data;
|
||||
|
||||
/** PCO descriptor set data. */
|
||||
|
|
|
|||
|
|
@ -79,6 +79,9 @@ static unsigned pvr_descriptor_size(VkDescriptorType type)
|
|||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
return sizeof(struct pvr_buffer_descriptor);
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
||||
return sizeof(struct pvr_combined_image_sampler_descriptor);
|
||||
|
||||
default:
|
||||
mesa_loge("Unsupported descriptor type %s.\n",
|
||||
vk_DescriptorType_to_str(type));
|
||||
|
|
@ -478,6 +481,30 @@ write_buffer(const struct pvr_descriptor_set *set,
|
|||
memcpy(desc_mapping, &buffer_desc, sizeof(buffer_desc));
|
||||
}
|
||||
|
||||
static void
|
||||
write_image_sampler(const struct pvr_descriptor_set *set,
|
||||
const VkDescriptorImageInfo *image_info,
|
||||
const struct pvr_descriptor_set_layout_binding *binding,
|
||||
uint32_t elem)
|
||||
{
|
||||
PVR_FROM_HANDLE(pvr_sampler, info_sampler, image_info->sampler);
|
||||
PVR_FROM_HANDLE(pvr_image_view, image_view, image_info->imageView);
|
||||
|
||||
const unsigned desc_offset = binding->offset + (elem * binding->stride);
|
||||
void *desc_mapping = (uint8_t *)set->mapping + desc_offset;
|
||||
|
||||
struct pvr_sampler *sampler = binding->immutable_sampler_count
|
||||
? binding->immutable_samplers[elem]
|
||||
: info_sampler;
|
||||
|
||||
struct pvr_combined_image_sampler_descriptor image_sampler_desc = {
|
||||
.image = image_view->image_state[PVR_TEXTURE_STATE_SAMPLE],
|
||||
.sampler = sampler->descriptor,
|
||||
};
|
||||
|
||||
memcpy(desc_mapping, &image_sampler_desc, sizeof(image_sampler_desc));
|
||||
}
|
||||
|
||||
void pvr_UpdateDescriptorSets(VkDevice _device,
|
||||
uint32_t descriptorWriteCount,
|
||||
const VkWriteDescriptorSet *pDescriptorWrites,
|
||||
|
|
@ -511,6 +538,15 @@ void pvr_UpdateDescriptorSets(VkDevice _device,
|
|||
}
|
||||
break;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
write_image_sampler(set,
|
||||
&write->pImageInfo[j],
|
||||
binding,
|
||||
write->dstArrayElement + j);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
UNREACHABLE("");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1960,6 +1960,7 @@ static void pvr_setup_descriptors(pco_data *data,
|
|||
{
|
||||
mesa_shader_stage stage = nir->info.stage;
|
||||
|
||||
/* Allocate shareds for the descriptors. */
|
||||
for (unsigned desc_set = 0; desc_set < layout->set_count; ++desc_set) {
|
||||
const struct pvr_descriptor_set_layout *set_layout =
|
||||
vk_to_pvr_descriptor_set_layout(layout->set_layouts[desc_set]);
|
||||
|
|
@ -1989,6 +1990,9 @@ static void pvr_setup_descriptors(pco_data *data,
|
|||
&set_layout->bindings[binding];
|
||||
pco_binding_data *binding_data = &desc_set_data->bindings[binding];
|
||||
|
||||
binding_data->is_img_smp = layout_binding->type ==
|
||||
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
|
||||
|
||||
binding_data->range = (pco_range){
|
||||
.start = desc_set_range->start +
|
||||
(layout_binding->offset / sizeof(uint32_t)),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue