3#include <shaderc/shaderc.h>
4#include <shaderc/status.h>
12#include <vulkan/vulkan.hpp>
13#include <vulkan/vulkan_enums.hpp>
14#include <vulkan/vulkan_handles.hpp>
15#include <vulkan/vulkan_structs.hpp>
21 shaderc_compilation_status_invalid_stage,
22 shaderc_compilation_status_compilation_error,
23 shaderc_compilation_status_internal_error,
24 shaderc_compilation_status_null_result_object,
25 shaderc_compilation_status_validation_error,
26 shaderc_compilation_status_transformation_error,
27 shaderc_compilation_status_configuration_error)
29namespace wren::reflect {
30using spirv_t = std::vector<uint32_t>;
38 reflect::spirv_t spirv;
39 ::vk::ShaderModule
module;
40 std::shared_ptr<spv_reflect::ShaderModule> reflection;
42 ShaderModule() =
default;
43 ShaderModule(reflect::spirv_t spirv, const ::vk::ShaderModule &module);
45 [[nodiscard]]
auto get_vertex_input_bindings() const
46 -> std::vector<::
vk::VertexInputBindingDescription>;
48 [[nodiscard]] auto get_vertex_input_attributes() const
49 -> std::vector<::
vk::VertexInputAttributeDescription>;
51 [[nodiscard]] auto get_descriptor_set_layout_bindings() const
52 -> std::vector<::
vk::DescriptorSetLayoutBinding>;
57 using Ptr = std::shared_ptr<Shader>;
59 static auto create(const ::vk::Device &device,
60 const std::string &vertex_shader,
61 const std::string &fragment_shader) -> expected<Ptr>;
63 static auto create(const ::vk::Device &device,
64 const std::filesystem::path &shader_path) -> expected<Ptr>;
66 static auto compile_shader(const ::vk::Device &device,
67 const shaderc_shader_kind &shader_kind,
68 const std::string &filename,
69 const std::string &shader_source)
72 [[nodiscard]]
auto get_pipeline()
const {
return pipeline_; }
73 [[nodiscard]]
auto pipeline_layout()
const {
return pipeline_layout_; }
74 [[nodiscard]]
auto descriptor_layout()
const {
return descriptor_layout_; }
76 void fragment_shader(
const ShaderModule &fragment) {
77 fragment_shader_module_ = fragment;
80 void vertex_shader(
const ShaderModule &vertex) {
81 vertex_shader_module_ = vertex;
84 auto create_graphics_pipeline(const ::vk::Device &device,
85 const ::vk::RenderPass &render_pass,
86 const math::Vec2f &size,
bool depth)
90 static auto read_wren_shader_file(
const std::filesystem::path &path)
91 -> expected<std::map<ShaderType, std::string>>;
93 ::vk::DescriptorSetLayout descriptor_layout_;
94 ::vk::PipelineLayout pipeline_layout_;
95 ::vk::Pipeline pipeline_;
97 ShaderModule vertex_shader_module_;
98 ShaderModule fragment_shader_module_;
#define DESCRIBED_ENUM(E,...)
Definition enums.hpp:7
BOOST_DESCRIBE_ENUM(Result, eSuccess, eNotReady, eTimeout, eEventSet, eEventReset, eIncomplete, eErrorOutOfHostMemory, eErrorOutOfDeviceMemory, eErrorInitializationFailed, eErrorDeviceLost, eErrorMemoryMapFailed, eErrorLayerNotPresent, eErrorExtensionNotPresent, eErrorFeatureNotPresent, eErrorIncompatibleDriver, eErrorTooManyObjects, eErrorFormatNotSupported, eErrorFragmentedPool, eErrorUnknown, eErrorOutOfPoolMemory, eErrorOutOfPoolMemoryKHR, eErrorInvalidExternalHandle, eErrorInvalidExternalHandleKHR, eErrorFragmentation, eErrorFragmentationEXT, eErrorInvalidOpaqueCaptureAddress, eErrorInvalidDeviceAddressEXT, eErrorInvalidOpaqueCaptureAddressKHR, ePipelineCompileRequired, eErrorPipelineCompileRequiredEXT, ePipelineCompileRequiredEXT, eErrorSurfaceLostKHR, eErrorNativeWindowInUseKHR, eSuboptimalKHR, eErrorOutOfDateKHR, eErrorIncompatibleDisplayKHR, eErrorValidationFailedEXT, eErrorInvalidShaderNV, eErrorImageUsageNotSupportedKHR, eErrorVideoPictureLayoutNotSupportedKHR, eErrorVideoProfileOperationNotSupportedKHR, eErrorVideoProfileFormatNotSupportedKHR, eErrorVideoProfileCodecNotSupportedKHR, eErrorVideoStdVersionNotSupportedKHR, eErrorInvalidDrmFormatModifierPlaneLayoutEXT, eErrorNotPermittedKHR, eErrorNotPermittedEXT, eThreadIdleKHR, eThreadDoneKHR, eOperationDeferredKHR, eOperationNotDeferredKHR, eErrorCompressionExhaustedEXT)
Definition render_pass.hpp:19
std::expected< T, Err > expected
Definition result.hpp:49
#define DEFINE_ERROR_IMPL(CAT_NAME, ERROR_ENUM)
This macro creates the hooks into std::error_code for a given error enum.
Definition result.hpp:60