fixed descriptors
This commit is contained in:
parent
83bb8ebd61
commit
5e3a7738ed
14 changed files with 334 additions and 167 deletions
|
|
@ -47,10 +47,20 @@ export namespace Crafter {
|
|||
class VulkanShader {
|
||||
public:
|
||||
constexpr static VkShaderStageFlagBits _stage = stage;
|
||||
constexpr static std::array<DescriptorBinding, DescriptorCount> descriptors = Descriptors;
|
||||
constexpr static std::uint32_t descriptorCount = DescriptorCount;
|
||||
constexpr static StringLiteral _entrypoint = entrypoint;
|
||||
constexpr static std::span<const DescriptorBinding> descriptors = Descriptors;
|
||||
inline static VkShaderModule shader;
|
||||
inline static VkDescriptorSetLayout layout;
|
||||
|
||||
consteval static std::array<VkDescriptorSetLayoutBinding, DescriptorCount> GetDescriptorSet() {
|
||||
std::array<VkDescriptorSetLayoutBinding, DescriptorCount> set;
|
||||
|
||||
for(std::uint32_t i = 0; i < Descriptors.size(); i++) {
|
||||
set[i] = {Descriptors[i].slot, Descriptors[i].type, 1, stage, nullptr};
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
static void CreateShader() {
|
||||
std::ifstream file(path.value, std::ios::binary);
|
||||
|
|
@ -78,6 +88,14 @@ export namespace Crafter {
|
|||
|
||||
VkShaderModule shader_module;
|
||||
VulkanDevice::CheckVkResult(vkCreateShaderModule(VulkanDevice::device, &module_info, nullptr, &shader));
|
||||
|
||||
constexpr std::array<VkDescriptorSetLayoutBinding, DescriptorCount> setLayoutBindingsMesh = GetDescriptorSet();
|
||||
VkDescriptorSetLayoutCreateInfo descriptorLayoutInfoMesh = {
|
||||
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||
.bindingCount = DescriptorCount,
|
||||
.pBindings = setLayoutBindingsMesh.data()
|
||||
};
|
||||
VulkanDevice::CheckVkResult(vkCreateDescriptorSetLayout(VulkanDevice::device, &descriptorLayoutInfoMesh, nullptr, &layout));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue