RHI: Add embedded shader source support via ShaderCompileDesc

- Add ShaderLanguage enum (HLSL, GLSL, SPIRV)
- Extend ShaderCompileDesc with source/sourceLanguage fields
- D3D12Device::CompileShader supports both file and embedded source
- OpenGLDevice::CompileShader supports embedded GLSL source
- Refactor test_shader.cpp to use embedded source for both backends

This enables consistent shader compilation across D3D12 and OpenGL
backends while maintaining backend-specific shader language support.
This commit is contained in:
2026-03-25 12:00:26 +08:00
parent 600892bbe2
commit 32c04b86b7
5 changed files with 178 additions and 45 deletions

View File

@@ -19,6 +19,13 @@ enum class ShaderType : uint8_t {
Library
};
enum class ShaderLanguage : uint8_t {
Unknown,
HLSL,
GLSL,
SPIRV
};
enum class CullMode : uint8_t {
None,
Front,

View File

@@ -43,10 +43,14 @@ struct ShaderCompileMacro {
std::wstring definition;
};
enum class ShaderLanguage : uint8_t;
struct ShaderCompileDesc {
std::wstring fileName;
std::vector<uint8_t> source;
ShaderLanguage sourceLanguage = ShaderLanguage::Unknown;
std::wstring entryPoint;
std::wstring profile;
std::wstring fileName;
std::vector<ShaderCompileMacro> macros;
};