VulkanRenderer: Fix handling of shader modules

This commit is contained in:
Jérôme Leclercq
2021-04-04 20:29:44 +02:00
parent 09df5f389e
commit feffcfa6e5
8 changed files with 223 additions and 132 deletions

View File

@@ -29,8 +29,8 @@ namespace Nz
std::shared_ptr<RenderPass> InstantiateRenderPass(std::vector<RenderPass::Attachment> attachments, std::vector<RenderPass::SubpassDescription> subpassDescriptions, std::vector<RenderPass::SubpassDependency> subpassDependencies) override;
std::shared_ptr<RenderPipeline> InstantiateRenderPipeline(RenderPipelineInfo pipelineInfo) override;
std::shared_ptr<RenderPipelineLayout> InstantiateRenderPipelineLayout(RenderPipelineLayoutInfo pipelineLayoutInfo) override;
std::shared_ptr<ShaderModule> InstantiateShaderModule(const ShaderAst& shaderAst, const ShaderWriter::States& states) override;
std::shared_ptr<ShaderModule> InstantiateShaderModule(ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize) override;
std::shared_ptr<ShaderModule> InstantiateShaderModule(ShaderStageTypeFlags stages, ShaderAst::StatementPtr& shaderAst, const ShaderWriter::States& states) override;
std::shared_ptr<ShaderModule> InstantiateShaderModule(ShaderStageTypeFlags stages, ShaderLanguage lang, const void* source, std::size_t sourceSize) override;
std::shared_ptr<Texture> InstantiateTexture(const TextureInfo& params) override;
std::shared_ptr<TextureSampler> InstantiateTextureSampler(const TextureSamplerInfo& params) override;

View File

@@ -0,0 +1,53 @@
// Copyright (C) 2020 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
#pragma once
#ifndef NAZARA_VULKANRENDERER_VULKANSHADERSTAGE_HPP
#define NAZARA_VULKANRENDERER_VULKANSHADERSTAGE_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Renderer/ShaderModule.hpp>
#include <Nazara/Shader/ShaderNodes.hpp>
#include <Nazara/Shader/ShaderWriter.hpp>
#include <Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp>
#include <vector>
namespace Nz
{
class NAZARA_VULKANRENDERER_API VulkanShaderModule : public ShaderModule
{
public:
struct Stage;
VulkanShaderModule() = default;
VulkanShaderModule(const VulkanShaderModule&) = delete;
VulkanShaderModule(VulkanShaderModule&&) = delete;
~VulkanShaderModule() = default;
bool Create(Vk::Device& device, ShaderStageTypeFlags shaderStages, ShaderAst::StatementPtr& shaderAst, const ShaderWriter::States& states);
bool Create(Vk::Device& device, ShaderStageTypeFlags shaderStages, ShaderLanguage lang, const void* source, std::size_t sourceSize);
inline const Vk::ShaderModule& GetHandle() const;
inline const std::vector<Stage>& GetStages() const;
VulkanShaderModule& operator=(const VulkanShaderModule&) = delete;
VulkanShaderModule& operator=(VulkanShaderModule&&) = delete;
struct Stage
{
ShaderStageType stage;
std::string name;
};
private:
Vk::ShaderModule m_shaderModule;
std::vector<Stage> m_stages;
};
}
#include <Nazara/VulkanRenderer/VulkanShaderModule.inl>
#endif // NAZARA_VULKANRENDERER_VULKANSHADERSTAGE_HPP

View File

@@ -2,19 +2,19 @@
// 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/VulkanShaderModule.hpp>
#include <Nazara/VulkanRenderer/Debug.hpp>
namespace Nz
{
inline const Vk::ShaderModule& VulkanShaderStage::GetHandle() const
inline const Vk::ShaderModule& VulkanShaderModule::GetHandle() const
{
return m_shaderModule;
}
inline ShaderStageType VulkanShaderStage::GetStageType() const
inline auto VulkanShaderModule::GetStages() const -> const std::vector<Stage>&
{
return m_stage;
return m_stages;
}
}

View File

@@ -1,44 +0,0 @@
// Copyright (C) 2020 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
#pragma once
#ifndef NAZARA_VULKANRENDERER_VULKANSHADERSTAGE_HPP
#define NAZARA_VULKANRENDERER_VULKANSHADERSTAGE_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Renderer/ShaderModule.hpp>
#include <Nazara/Shader/ShaderWriter.hpp>
#include <Nazara/VulkanRenderer/Wrapper/ShaderModule.hpp>
#include <vector>
namespace Nz
{
class NAZARA_VULKANRENDERER_API VulkanShaderStage : public ShaderModule
{
public:
VulkanShaderStage() = default;
VulkanShaderStage(const VulkanShaderStage&) = delete;
VulkanShaderStage(VulkanShaderStage&&) = delete;
~VulkanShaderStage() = default;
bool Create(Vk::Device& device, const ShaderAst& shader, const ShaderWriter::States& states);
bool Create(Vk::Device& device, ShaderStageType type, ShaderLanguage lang, const void* source, std::size_t sourceSize);
inline const Vk::ShaderModule& GetHandle() const;
inline ShaderStageType GetStageType() const;
VulkanShaderStage& operator=(const VulkanShaderStage&) = delete;
VulkanShaderStage& operator=(VulkanShaderStage&&) = delete;
private:
Vk::ShaderModule m_shaderModule;
ShaderStageType m_stage;
};
}
#include <Nazara/VulkanRenderer/VulkanShaderStage.inl>
#endif // NAZARA_VULKANRENDERER_VULKANSHADERSTAGE_HPP