Shader: Add initial support for options (WIP)

This commit is contained in:
Jérôme Leclercq
2021-04-17 14:43:00 +02:00
parent 7da02c8708
commit 87ce2edc6e
45 changed files with 586 additions and 113 deletions

View File

@@ -60,10 +60,10 @@ namespace Nz
return stage;
}
std::shared_ptr<ShaderModule> VulkanDevice::InstantiateShaderModule(ShaderStageTypeFlags stages, ShaderLanguage lang, const void* source, std::size_t sourceSize)
std::shared_ptr<ShaderModule> VulkanDevice::InstantiateShaderModule(ShaderStageTypeFlags stages, ShaderLanguage lang, const void* source, std::size_t sourceSize, const ShaderWriter::States& states)
{
auto stage = std::make_shared<VulkanShaderModule>();
if (!stage->Create(*this, stages, lang, source, sourceSize))
if (!stage->Create(*this, stages, lang, source, sourceSize, states))
throw std::runtime_error("failed to instanciate vulkan shader module");
return stage;

View File

@@ -65,10 +65,10 @@ namespace Nz
writer.SetEnv(env);
std::vector<UInt32> code = writer.Generate(shaderAst, states);
return Create(device, shaderStages, ShaderLanguage::SpirV, code.data(), code.size() * sizeof(UInt32));
return Create(device, shaderStages, ShaderLanguage::SpirV, code.data(), code.size() * sizeof(UInt32), {});
}
bool VulkanShaderModule::Create(Vk::Device& device, ShaderStageTypeFlags shaderStages, ShaderLanguage lang, const void* source, std::size_t sourceSize)
bool VulkanShaderModule::Create(Vk::Device& device, ShaderStageTypeFlags shaderStages, ShaderLanguage lang, const void* source, std::size_t sourceSize, const ShaderWriter::States& states)
{
switch (lang)
{
@@ -89,7 +89,7 @@ namespace Nz
Nz::ShaderLang::Parser parser;
Nz::ShaderAst::StatementPtr shaderAst = parser.Parse(tokens);
return Create(device, shaderStages, shaderAst, {});
return Create(device, shaderStages, shaderAst, states);
}
case ShaderLanguage::SpirV: