Renderer: Add ShaderStage class

This commit is contained in:
Lynix
2020-02-29 23:28:21 +01:00
parent 798425ce10
commit 5d449095bf
13 changed files with 190 additions and 39 deletions

View File

@@ -4,6 +4,7 @@
#include <Nazara/VulkanRenderer/VulkanDevice.hpp>
#include <Nazara/VulkanRenderer/VulkanRenderPipeline.hpp>
#include <Nazara/VulkanRenderer/VulkanShaderStage.hpp>
#include <Nazara/VulkanRenderer/Debug.hpp>
namespace Nz
@@ -19,4 +20,13 @@ namespace Nz
{
return std::make_unique<VulkanRenderPipeline>(shared_from_this(), std::move(pipelineInfo));
}
std::shared_ptr<ShaderStageImpl> VulkanDevice::InstantiateShaderStage(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize)
{
auto stage = std::make_shared<VulkanShaderStage>();
if (!stage->Create(shared_from_this(), type, lang, source, sourceSize))
return {};
return stage;
}
}

View File

@@ -0,0 +1,27 @@
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Vulkan Renderer"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/VulkanRenderer/VulkanShaderStage.hpp>
#include <Nazara/VulkanRenderer/Debug.hpp>
namespace Nz
{
bool VulkanShaderStage::Create(const Vk::DeviceHandle& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize)
{
if (lang != ShaderLanguage::SpirV)
{
NazaraError("Only Spir-V is supported for now");
return false;
}
if (!m_shaderModule.Create(device, reinterpret_cast<const Nz::UInt32*>(source), sourceSize))
{
NazaraError("Failed to create shader module");
return false;
}
m_stage = type;
return true;
}
}