summaryrefslogtreecommitdiff
path: root/video.cpp
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2025-02-09 18:49:00 +1100
committerquou <quou@disroot.org>2025-02-09 18:51:30 +1100
commit8c644dd120c63244f4b576b45cd4ae96842736f8 (patch)
tree6074b73b48f391634f6b8fd431d2391de3a2dbfc /video.cpp
parentdf87506693471686140282e79f5513dfc27a7854 (diff)
support for structured buffers
Diffstat (limited to 'video.cpp')
-rw-r--r--video.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/video.cpp b/video.cpp
index f108319..f1fb512 100644
--- a/video.cpp
+++ b/video.cpp
@@ -2662,6 +2662,8 @@ void Context_Vk::submit_descriptors(
} break;
case Descriptor::Type::constant_buffer:
break; /* todo */
+ case Descriptor::Type::structured_buffer:
+ break; /* todo */
}
}
vkCmdBindDescriptorSets(
@@ -3062,6 +3064,9 @@ void Pipeline_Vk::init_descriptors(
case Descriptor::Type::constant_buffer:
dst.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
break;
+ case Descriptor::Type::structured_buffer:
+ dst.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
+ break;
}
dst.binding = src.slot;
dst.descriptorCount = 1;
@@ -3180,7 +3185,7 @@ void Descriptor_Set_Vk::init(
const Pipeline& desc
) {
int count = desc.descriptor_count, i;
- int sampler_count = 0, cbuffer_count = 0;
+ int sampler_count = 0, cbuffer_count = 0, sbuffer_count = 0;
int size_count = 0;
VkDescriptorSetAllocateInfo da{};
VkDescriptorPoolSize sizes[4];
@@ -3194,6 +3199,9 @@ void Descriptor_Set_Vk::init(
case Descriptor::Type::constant_buffer:
cbuffer_count++;
break;
+ case Descriptor::Type::structured_buffer:
+ sbuffer_count++;
+ break;
}
}
if (sampler_count) {
@@ -3210,6 +3218,13 @@ void Descriptor_Set_Vk::init(
.descriptorCount = (uint32_t)cbuffer_count
};
}
+ if (sbuffer_count) {
+ int idx = size_count++;
+ sizes[idx] = {
+ .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
+ .descriptorCount = (uint32_t)sbuffer_count
+ };
+ }
{
VkDescriptorPoolCreateInfo di{};
di.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
@@ -3260,8 +3275,8 @@ void Descriptor_Set_Vk::init(
wd.pImageInfo = &img;
} break;
case Descriptor::Type::constant_buffer: {
- Constant_Buffer_Descriptor* cd =
- (Constant_Buffer_Descriptor*)src.payload;
+ Buffer_Descriptor* cd =
+ (Buffer_Descriptor*)src.payload;
Buffer_Vk& b = *(Buffer_Vk*)&dev->get_buffer(cd->buffer);
assert(cd->buffer);
buf.buffer = b.buf;
@@ -3270,6 +3285,17 @@ void Descriptor_Set_Vk::init(
wd.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
wd.pBufferInfo = &buf;
} break;
+ case Descriptor::Type::structured_buffer: {
+ Buffer_Descriptor* cd =
+ (Buffer_Descriptor*)src.payload;
+ Buffer_Vk& b = *(Buffer_Vk*)&dev->get_buffer(cd->buffer);
+ assert(cd->buffer);
+ buf.buffer = b.buf;
+ buf.offset = cd->offset;
+ buf.range = cd->size? cd->size: b.size;
+ wd.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
+ wd.pBufferInfo = &buf;
+ } break;
}
vkUpdateDescriptorSets(dev->dev, 1, &wd, 0, 0);
}