new descriptor layout 2
This commit is contained in:
parent
74832c6824
commit
d1b8e45fb6
13 changed files with 412 additions and 128 deletions
|
|
@ -40,27 +40,13 @@ export namespace Crafter {
|
|||
template <
|
||||
StringLiteral path,
|
||||
StringLiteral entrypoint,
|
||||
VkShaderStageFlagBits stage,
|
||||
std::uint32_t DescriptorCount,
|
||||
const std::array<DescriptorBinding, DescriptorCount> Descriptors
|
||||
VkShaderStageFlagBits stage
|
||||
>
|
||||
class VulkanShader {
|
||||
public:
|
||||
constexpr static VkShaderStageFlagBits _stage = stage;
|
||||
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);
|
||||
|
|
@ -88,14 +74,6 @@ 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