add graphics pipeline class
This commit is contained in:
parent
64ecba56ed
commit
f9b84ede16
|
|
@ -5,9 +5,9 @@
|
|||
# Add source to this project's executable.
|
||||
file(GLOB_RECURSE SourceFiles "${CMAKE_CURRENT_SOURCE_DIR}/Source/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Source/*.h")
|
||||
|
||||
find_package(spdlog CONFIG REQUIRED)
|
||||
find_package(Vulkan REQUIRED)
|
||||
find_package(glm CONFIG REQUIRED)
|
||||
find_package(spdlog CONFIG REQUIRED)
|
||||
find_package(glfw3 CONFIG REQUIRED)
|
||||
|
||||
add_library (Nitric STATIC ${SourceFiles})
|
||||
|
|
|
|||
25
Nitric/Source/Platform/Vulkan/VkGraphicsPipeline.cpp
Normal file
25
Nitric/Source/Platform/Vulkan/VkGraphicsPipeline.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#include <Platform/Vulkan/VkGraphicsPipeline.h>
|
||||
|
||||
namespace Nitric {
|
||||
|
||||
VkGraphicsPipeline::VkGraphicsPipeline(const GraphicsQualitySettings &settings) {
|
||||
|
||||
}
|
||||
|
||||
GraphicsQualitySettings& VkGraphicsPipeline::GetSettings() {
|
||||
return {};
|
||||
}
|
||||
|
||||
void VkGraphicsPipeline::SetSettings(GraphicsQualitySettings &settings) {
|
||||
|
||||
}
|
||||
|
||||
void VkGraphicsPipeline::Rebuild() {
|
||||
|
||||
}
|
||||
|
||||
void VkGraphicsPipeline::BuildPipeline() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
18
Nitric/Source/Platform/Vulkan/VkGraphicsPipeline.h
Normal file
18
Nitric/Source/Platform/Vulkan/VkGraphicsPipeline.h
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#pragma once
|
||||
|
||||
#include <Render/GraphicsPipeline.h>
|
||||
|
||||
namespace Nitric {
|
||||
class VkGraphicsPipeline : public GraphicsPipeline {
|
||||
public:
|
||||
explicit VkGraphicsPipeline(const GraphicsQualitySettings& settings);
|
||||
|
||||
GraphicsQualitySettings& GetSettings() override;
|
||||
void SetSettings(GraphicsQualitySettings& settings) override;
|
||||
|
||||
void Rebuild() override;
|
||||
|
||||
private:
|
||||
void BuildPipeline();
|
||||
};
|
||||
}
|
||||
|
|
@ -27,4 +27,27 @@ namespace Nitric {
|
|||
VkShaderModule VkShader::GetModule() {
|
||||
return m_Module;
|
||||
}
|
||||
|
||||
VkPipelineShaderStageCreateInfo VkShader::GetCreateInfo() {
|
||||
return VkPipelineShaderStageCreateInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||
.stage = ConvertFromShaderType(m_Type),
|
||||
.module = m_Module,
|
||||
.pName = "main",
|
||||
};
|
||||
}
|
||||
|
||||
VkShaderStageFlagBits VkShader::ConvertFromShaderType(Shader::ShaderType type) {
|
||||
switch (type) {
|
||||
case Shader::Fragment:
|
||||
return VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
case Shader::Vertex:
|
||||
return VK_SHADER_STAGE_VERTEX_BIT;
|
||||
}
|
||||
return VK_SHADER_STAGE_ALL;
|
||||
}
|
||||
|
||||
Shader::ShaderType VkShader::GetType() {
|
||||
return m_Type;
|
||||
}
|
||||
};
|
||||
|
|
@ -13,6 +13,10 @@ namespace Nitric {
|
|||
~VkShader() override;
|
||||
|
||||
VkShaderModule GetModule();
|
||||
VkPipelineShaderStageCreateInfo GetCreateInfo();
|
||||
ShaderType GetType() override;
|
||||
|
||||
static VkShaderStageFlagBits ConvertFromShaderType(Shader::ShaderType type);
|
||||
private:
|
||||
VkShaderModule m_Module;
|
||||
ShaderType m_Type;
|
||||
|
|
|
|||
7
Nitric/Source/Render/GraphicsPipeline.cpp
Normal file
7
Nitric/Source/Render/GraphicsPipeline.cpp
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#include <Render/GraphicsPipeline.h>
|
||||
|
||||
namespace Nitric {
|
||||
Ref<GraphicsPipeline> GraphicsPipeline::Create(const GraphicsQualitySettings &settings) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
19
Nitric/Source/Render/GraphicsPipeline.h
Normal file
19
Nitric/Source/Render/GraphicsPipeline.h
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
#include <Core/Base.h>
|
||||
#include <Render/GraphicsQualitySettings.h>
|
||||
|
||||
namespace Nitric {
|
||||
|
||||
class GraphicsPipeline {
|
||||
public:
|
||||
virtual ~GraphicsPipeline() = default;
|
||||
|
||||
virtual GraphicsQualitySettings& GetSettings() = 0;
|
||||
virtual void SetSettings(GraphicsQualitySettings& settings) = 0;
|
||||
|
||||
virtual void Rebuild() = 0;
|
||||
|
||||
Ref<GraphicsPipeline> Create(const GraphicsQualitySettings& settings);
|
||||
};
|
||||
}
|
||||
12
Nitric/Source/Render/GraphicsQualitySettings.cpp
Normal file
12
Nitric/Source/Render/GraphicsQualitySettings.cpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#include <Render/GraphicsQualitySettings.h>
|
||||
|
||||
namespace Nitric {
|
||||
|
||||
GraphicsQualitySettings::GraphicsQualitySettings() {
|
||||
|
||||
}
|
||||
|
||||
GraphicsQualitySettings::~GraphicsQualitySettings() {
|
||||
|
||||
}
|
||||
}
|
||||
31
Nitric/Source/Render/GraphicsQualitySettings.h
Normal file
31
Nitric/Source/Render/GraphicsQualitySettings.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
#include <Core/Base.h>
|
||||
|
||||
namespace Nitric {
|
||||
enum class DrawMode {
|
||||
Point,
|
||||
Fill,
|
||||
Line
|
||||
};
|
||||
|
||||
class GraphicsQualitySettings {
|
||||
public:
|
||||
GraphicsQualitySettings();
|
||||
~GraphicsQualitySettings();
|
||||
|
||||
void SetFXAA(bool enabled);
|
||||
void SetSSAA(bool enabled);
|
||||
void SetDrawMode(DrawMode mode);
|
||||
|
||||
bool GetFXAA();
|
||||
bool GetSSAA();
|
||||
DrawMode GetDrawMode();
|
||||
|
||||
void SetDefaults();
|
||||
|
||||
private:
|
||||
bool m_FXAA;
|
||||
bool m_SSAA;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,5 +1,18 @@
|
|||
#include <Render/Shader.h>
|
||||
|
||||
#include <Render/GraphicsAPI.h>
|
||||
|
||||
#include <Platform/Vulkan/VkShader.h>
|
||||
|
||||
namespace Nitric {
|
||||
|
||||
Ref<Shader> Shader::Create(const std::string &filepath, Shader::ShaderType type) {
|
||||
switch (GraphicsAPI::GetAPI()) {
|
||||
case GraphicsAPI::Vulkan:
|
||||
return CreateRef<VkShader>(filepath, type);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
#include <string>
|
||||
|
||||
#include <Core/Base.h>
|
||||
#include "GraphicsAPI.h"
|
||||
|
||||
namespace Nitric {
|
||||
class Shader {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user