Renderer: Replace ShaderStage by ShaderModule (a module can handle multiple stages)

This commit is contained in:
Jérôme Leclercq
2021-03-31 11:13:37 +02:00
parent c1d1838336
commit e4aabf309e
25 changed files with 235 additions and 198 deletions

View File

@@ -51,7 +51,7 @@ namespace Nz
return pipelineLayout;
}
std::shared_ptr<ShaderStage> VulkanDevice::InstantiateShaderStage(const ShaderAst& shaderAst, const ShaderWriter::States& states)
std::shared_ptr<ShaderModule> VulkanDevice::InstantiateShaderModule(const ShaderAst& shaderAst, const ShaderWriter::States& states)
{
auto stage = std::make_shared<VulkanShaderStage>();
if (!stage->Create(*this, shaderAst, states))
@@ -60,7 +60,7 @@ namespace Nz
return stage;
}
std::shared_ptr<ShaderStage> VulkanDevice::InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize)
std::shared_ptr<ShaderModule> VulkanDevice::InstantiateShaderModule(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize)
{
auto stage = std::make_shared<VulkanShaderStage>();
if (!stage->Create(*this, type, lang, source, sourceSize))

View File

@@ -164,7 +164,7 @@ namespace Nz
{
std::vector<VkPipelineShaderStageCreateInfo> shaderStageCreateInfos;
for (auto&& stagePtr : pipelineInfo.shaderStages)
for (auto&& stagePtr : pipelineInfo.shaderModules)
{
Nz::VulkanShaderStage& vulkanStage = *static_cast<Nz::VulkanShaderStage*>(stagePtr.get());

View File

@@ -20,14 +20,7 @@ namespace Nz
writer.SetEnv(env);
std::vector<UInt32> code = writer.Generate(shader, states);
if (!m_shaderModule.Create(device, code.data(), code.size() * sizeof(UInt32)))
{
NazaraError("Failed to create shader module");
return false;
}
return true;
return Create(device, m_stage, ShaderLanguage::SpirV, code.data(), code.size() * sizeof(UInt32));
}
bool VulkanShaderStage::Create(Vk::Device& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize)