working mesh shader

This commit is contained in:
Jorijn van der Graaf 2025-04-26 20:49:56 +02:00
commit 27ba32cdf5
11 changed files with 175 additions and 30 deletions

View file

@ -6,6 +6,7 @@ module;
#include <fstream>
#include <cstdint>
#include <vector>
#include <array>
export module Crafter.Graphics:VulkanShader;
import :VulkanDevice;
@ -20,13 +21,26 @@ namespace Crafter {
char value[N];
};
export template <StringLiteral path, StringLiteral entrypoint, VkShaderStageFlagBits stage>
export struct DescriptorBinding {
VkDescriptorType type;
std::uint32_t slot;
};
export template <
StringLiteral path,
StringLiteral entrypoint,
VkShaderStageFlagBits stage,
std::uint32_t DescriptorCount,
std::array<DescriptorBinding, DescriptorCount> Descriptors
>
class VulkanShader {
public:
inline static VkShaderModule shader;
constexpr static StringLiteral _entrypoint = entrypoint;
constexpr static VkShaderStageFlagBits _stage = stage;
static void CreateShader() {
inline static VkShaderModule shader;
constexpr static std::uint32_t descriptorCount = DescriptorCount;
constexpr static std::array<DescriptorBinding, DescriptorCount> descriptors = Descriptors;
constexpr static StringLiteral _entrypoint = entrypoint;
constexpr static VkShaderStageFlagBits _stage = stage;
static void CreateShader() {
std::ifstream file(path.value, std::ios::binary);
if (!file) {
std::cerr << "Error: Could not open file " << path.value << std::endl;