mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-26 10:00:22 +01:00
nvk: Use a descriptor type instead of a hand-rolled thing
This was an attempt to prematurely optimize some things. Sure, it's a hot-path, but there's other control-flow in there and we can optimize it later if needed. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>
This commit is contained in:
parent
0648f0fa03
commit
8b08bbe2cf
1 changed files with 6 additions and 23 deletions
|
|
@ -34,24 +34,23 @@ write_desc(struct nvk_descriptor_set *set, uint32_t binding, uint32_t elem,
|
|||
memcpy(desc_ubo_data(set, binding, elem), desc_data, desc_size);
|
||||
}
|
||||
|
||||
#define IMAGE_VIEW 0x1
|
||||
#define SAMPLER 0x2
|
||||
|
||||
static void
|
||||
write_image_view_desc(struct nvk_descriptor_set *set,
|
||||
const VkDescriptorImageInfo *const info,
|
||||
uint32_t binding, uint32_t elem,
|
||||
int handles)
|
||||
VkDescriptorType descriptor_type)
|
||||
{
|
||||
struct nvk_image_descriptor desc = { };
|
||||
|
||||
if ((handles & IMAGE_VIEW) && info->imageView != VK_NULL_HANDLE) {
|
||||
if (descriptor_type != VK_DESCRIPTOR_TYPE_SAMPLER &&
|
||||
info->imageView != VK_NULL_HANDLE) {
|
||||
VK_FROM_HANDLE(nvk_image_view, view, info->imageView);
|
||||
assert(view->desc_index < (1 << 20));
|
||||
desc.image_index = view->desc_index;
|
||||
}
|
||||
|
||||
if (handles & SAMPLER) {
|
||||
if (descriptor_type == VK_DESCRIPTOR_TYPE_SAMPLER ||
|
||||
descriptor_type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) {
|
||||
const struct nvk_descriptor_set_binding_layout *binding_layout =
|
||||
&set->layout->binding[binding];
|
||||
|
||||
|
|
@ -135,23 +134,7 @@ nvk_UpdateDescriptorSets(VkDevice device,
|
|||
|
||||
switch (write->descriptorType) {
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
write_image_view_desc(set, write->pImageInfo + j,
|
||||
write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
SAMPLER);
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
|
||||
for (uint32_t j = 0; j < write->descriptorCount; j++) {
|
||||
write_image_view_desc(set, write->pImageInfo + j,
|
||||
write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
IMAGE_VIEW | SAMPLER);
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||
case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
|
||||
|
|
@ -159,7 +142,7 @@ nvk_UpdateDescriptorSets(VkDevice device,
|
|||
write_image_view_desc(set, write->pImageInfo + j,
|
||||
write->dstBinding,
|
||||
write->dstArrayElement + j,
|
||||
IMAGE_VIEW);
|
||||
write->descriptorType);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue