review refactors
This commit is contained in:
@@ -3,35 +3,10 @@
|
||||
#include "Base/Utils.hpp"
|
||||
#include "Base/Wrapper.hpp"
|
||||
|
||||
#include <spirv_cross/spirv_hlsl.hpp>
|
||||
#include <spirv_cross/spirv_glsl.hpp>
|
||||
#include <shaderc/shaderc.hpp>
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
class ShaderIncluder : public shaderc::CompileOptions::IncluderInterface
|
||||
{
|
||||
struct IncludeData
|
||||
{
|
||||
shaderc_include_result result = {};
|
||||
std::string m_fullPath;
|
||||
Array<char> m_content;
|
||||
};
|
||||
public:
|
||||
ShaderIncluder(const std::string& path);
|
||||
~ShaderIncluder() override = default;
|
||||
|
||||
shaderc_include_result* GetInclude(const char* requestedSource, shaderc_include_type type,
|
||||
const char* requestingSource, uint64_t includeDepth) override;
|
||||
void ReleaseInclude(shaderc_include_result* data) override;
|
||||
|
||||
private:
|
||||
std::string ResolveInclude(const std::string& requestedSource) const;
|
||||
|
||||
private:
|
||||
std::string m_includePath;
|
||||
};
|
||||
|
||||
class ShaderCompiler
|
||||
{
|
||||
public:
|
||||
@@ -40,10 +15,13 @@ namespace OpenVulkano
|
||||
* @param incPath - include path that will be used to resolve includes
|
||||
* @param entryPoint - the name of the void function in the shader
|
||||
* @param shaderStage - type of the shader that needs to be compiled
|
||||
* @param bHaveIncludes - if incPath is empty, make it false
|
||||
*/
|
||||
static Unique<void*> CompileGLSLToSpirv(const std::string& absPath,
|
||||
const std::string& incPath, const std::string& entryPoint,
|
||||
shaderc_shader_kind shaderStage, bool bHaveIncludes);
|
||||
static Array<uint32_t> CompileGLSLToSpirv(const std::string& absPath, bool hasIncludes,
|
||||
const std::string& incPath = std::string(), const std::string& entryPoint = "main")
|
||||
#if defined(HAS_SHADERC)
|
||||
;
|
||||
#else
|
||||
{ throw std::runtime_error("Shader compiler is not available on this platform"); }
|
||||
#endif
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user