Add SpirvHelper (Shader cross compilation)

- Make OpenGL2 and OpenGL3 use the same base shaders (using SpirvHelper)
- Add Transpose func to Mat4
This commit is contained in:
2026-03-18 15:17:48 +01:00
parent 186fce803e
commit 7d89ab1c47
13 changed files with 424 additions and 139 deletions

View File

@@ -0,0 +1,36 @@
#pragma once
#include <glslang/Public/ResourceLimits.h>
#include <glslang/Public/ShaderLang.h>
#include <pd/common.hpp>
namespace PD {
class SpirvHelper {
public:
enum class Format {
GLSL,
HLSL,
MSL, // Not supported yet
SPIRV,
};
enum class Stage {
Vertex = 0,
Geometry = 3,
Fragment = 4,
};
SpirvHelper() = default;
~SpirvHelper() = default;
static void Init();
static void Finalize();
static void SetupResources(TBuiltInResource& resources);
static std::vector<PD::u32> GLSL2SPV(Stage stage, const char* code,
bool vulkan_mode = false);
static std::string SPV2GLSL(const std::vector<PD::u32>& spirv, int version,
bool es = false);
static std::string SPV2HLSL(const std::vector<PD::u32>& spirv, int version);
};
} // namespace PD