Started implementing Pipeline system for RenderDriver

This commit is contained in:
2025-04-22 13:04:14 +10:00
parent 8ac7a46f53
commit 8d398b9c00
5 changed files with 255 additions and 6 deletions

View File

@@ -15,6 +15,7 @@
#include <string>
namespace Nova {
class NOVA_API RenderDriver {
public:
static RenderDriver* create(RenderAPI api, WindowDriver* window_driver = nullptr);
@@ -32,12 +33,6 @@ namespace Nova {
[[nodiscard]] virtual SurfaceID create_surface(WindowID window) = 0;
virtual void destroy_surface(SurfaceID surface) = 0;
// TODO: get_surface_size
// TODO: get_surface_mode
// TODO: get_surface_state
// TODO: set_surface_size
// TODO: set_surface_mode
// TODO: set_surface_state
[[nodiscard]] virtual SwapchainID create_swapchain(SurfaceID surface) = 0;
virtual void resize_swapchain(SwapchainID swapchain) = 0;
@@ -45,5 +40,9 @@ namespace Nova {
[[nodiscard]] virtual ShaderID create_shader(const std::span<u8> bytes) = 0;
virtual void destroy_shader(ShaderID shader) = 0;
[[nodiscard]] virtual PipelineID create_pipeline(GraphicsPipelineParams& params) = 0;
[[nodiscard]] virtual PipelineID create_pipeline(ComputePipelineParams& params) = 0;
virtual void destroy_pipeline(PipelineID pipeline) = 0;
};
} // namespace Nova

View File

@@ -7,15 +7,27 @@
#pragma once
namespace Nova {
enum class CullMode { NONE, FRONT, BACK };
enum class FrontFace { CLOCKWISE, COUNTER_CLOCKWISE };
enum class PipelineType { GRAPHICS, COMPUTE };
enum class PrimitiveTopology { POINT_LIST, LINE_LIST, LINE_STRIP, TRIANGLE_LIST, TRIANGLE_STRIP };
enum class RenderAPI { DX12, VULKAN };
enum class ShaderStage { VERTEX, FRAGMENT, GEOMETRY, TESS_CONTROL, TESS_EVAL, COMPUTE, MESH, TASK };
class RenderDriver;
struct RenderDevice;
struct GraphicsPipelineParams;
struct ComputePipelineParams;
struct Pipeline;
struct RenderPass;
struct Shader;
struct Surface;
struct Swapchain;
using PipelineID = Pipeline*;
using RenderPassID = RenderPass*;
using ShaderID = Shader*;
using SurfaceID = Surface*;
using SwapchainID = Swapchain*;

View File

@@ -0,0 +1,44 @@
/**
* Copyright (c) 2025, Jayden Grubb <contact@jaydengrubb.com>
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#pragma once
#include <nova/render/render_fwd.h>
#include <nova/types.h>
#include <unordered_map>
namespace Nova {
struct GraphicsPipelineParams {
std::unordered_map<ShaderStage, ShaderID> shaders;
// TODO: Vertex input state
PrimitiveTopology topology = PrimitiveTopology::TRIANGLE_LIST;
// TODO: Tessellation state
bool enable_depth_clamp = false;
bool discard_primitives = false;
bool wireframe = false;
CullMode cull_mode = CullMode::NONE;
FrontFace front_face = FrontFace::COUNTER_CLOCKWISE;
bool enable_depth_bias = false;
float depth_bias_constant = 0.0f;
float depth_bias_clamp = 0.0f;
float depth_bias_slope = 0.0f;
float line_width = 1.0f;
// TODO: Multisample state
// TODO: Depth stencil state
// TODO: Color blend state
// TODO: Dynamic state
RenderPassID render_pass = nullptr;
u32 subpass = 0;
};
struct ComputePipelineParams {};
} // namespace Nova