hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/rendering
diff options
context:
space:
mode:
Diffstat (limited to 'src/rendering')
-rw-r--r--src/rendering/black_hole_renderer.cpp8
-rw-r--r--src/rendering/rhi.h22
-rw-r--r--src/rendering/scene_renderer.cpp6
3 files changed, 25 insertions, 11 deletions
diff --git a/src/rendering/black_hole_renderer.cpp b/src/rendering/black_hole_renderer.cpp
index 2534b1d..c7b58c5 100644
--- a/src/rendering/black_hole_renderer.cpp
+++ b/src/rendering/black_hole_renderer.cpp
@@ -27,8 +27,8 @@ namespace Donut
{
m_device = &device;
- m_geo_lo = device.create_render_target(GEO_LO_W, GEO_LO_H, Format::RGBA8, false, Filter::Linear);
- m_geo_hi = device.create_render_target(GEO_HI_W, GEO_HI_H, Format::RGBA8, false, Filter::Linear);
+ m_geo_lo = device.create_render_target(GEO_LO_W, GEO_LO_H, Format::RGBA8, Format::None, Filter::Linear);
+ m_geo_hi = device.create_render_target(GEO_HI_W, GEO_HI_H, Format::RGBA8, Format::None, Filter::Linear);
const float quad[] = {
-1.f, 1.f, 0.f, 1.f, -1.f, -1.f, 0.f, 0.f, 1.f, -1.f, 1.f, 0.f,
@@ -59,7 +59,7 @@ namespace Donut
{ ResourceKind::Texture, 4, "u_HDRIEnvironment" },
};
d.topology = Topology::Triangles;
- d.has_depth = false;
+ d.target = { Format::RGBA8, Format::None };
m_geo_pipeline = device.create_pipeline(d);
}
{
@@ -68,7 +68,7 @@ namespace Donut
d.vertex_layout = { 16, { { 0, 2, 0 }, { 1, 2, 8 } } };
d.resources = { { ResourceKind::Texture, 0, "u_ScreenTexture" } };
d.topology = Topology::Triangles;
- d.has_depth = true;
+ d.target = { Format::Swapchain, Format::D32 };
m_present_pipeline = device.create_pipeline(d);
}
diff --git a/src/rendering/rhi.h b/src/rendering/rhi.h
index 1a61420..7684aa0 100644
--- a/src/rendering/rhi.h
+++ b/src/rendering/rhi.h
@@ -11,11 +11,26 @@ namespace Donut::RHI
{
enum class Format
{
+ None,
+ Swapchain,
RGBA8,
RGBA16F,
D32,
};
+ struct RenderTargetFormat
+ {
+ Format color = Format::RGBA8;
+ Format depth = Format::None;
+ };
+
+ struct NativeWindow
+ {
+ void* glfw_handle = nullptr;
+ int width = 0;
+ int height = 0;
+ };
+
enum class BufferType { Vertex, Index, Uniform };
enum class Topology { Triangles, Lines };
enum class CullMode { None, Back, Front };
@@ -53,8 +68,7 @@ namespace Donut::RHI
bool depth_test = false;
bool depth_write = false;
CompareOp depth_op = CompareOp::Less;
- Format color_format = Format::RGBA8;
- bool has_depth = false;
+ RenderTargetFormat target;
};
class CommandList
@@ -83,7 +97,7 @@ namespace Donut::RHI
public:
virtual ~Device() = default;
- virtual auto init(void* glfwWindow, int width, int height) -> bool = 0;
+ virtual auto init(const NativeWindow& window) -> bool = 0;
virtual auto shutdown() -> void = 0;
virtual auto resize(int width, int height) -> void = 0;
virtual auto wait_idle() -> void = 0;
@@ -91,7 +105,7 @@ namespace Donut::RHI
virtual auto create_buffer(BufferType type, size_t size, const void* data = nullptr) -> Ref<Buffer> = 0;
virtual auto create_texture(int width, int height, Format format, Filter filter, const void* data = nullptr) -> Ref<Texture> = 0;
virtual auto create_cubemap_from_hdri(const std::string& equirect_path) -> Ref<Texture> = 0;
- virtual auto create_render_target(int width, int height, Format color, bool with_depth,
+ virtual auto create_render_target(int width, int height, Format color, Format depth = Format::None,
Filter sample_filter = Filter::Linear, int mip_levels = 1) -> Ref<RenderTarget> = 0;
virtual auto create_pipeline(const PipelineDesc& desc) -> Ref<Pipeline> = 0;
diff --git a/src/rendering/scene_renderer.cpp b/src/rendering/scene_renderer.cpp
index 076f6ba..c9da332 100644
--- a/src/rendering/scene_renderer.cpp
+++ b/src/rendering/scene_renderer.cpp
@@ -65,7 +65,7 @@ namespace Donut
d.topology = Topology::Lines;
d.blend = BlendMode::AlphaBlend;
d.depth_test = true; d.depth_write = false; d.depth_op = CompareOp::LessEqual;
- d.has_depth = true;
+ d.target = { Format::Swapchain, Format::D32 };
m_grid_pipeline = device.create_pipeline(d);
}
@@ -101,7 +101,7 @@ namespace Donut
{ ResourceKind::Texture, 1, "u_HDRIEnvironment" } };
d.topology = Topology::Triangles;
d.depth_test = true; d.depth_write = true; d.depth_op = CompareOp::Less;
- d.has_depth = true;
+ d.target = { Format::Swapchain, Format::D32 };
m_sphere_pipeline = device.create_pipeline(d);
}
@@ -124,7 +124,7 @@ namespace Donut
{ ResourceKind::Texture, 1, "u_Skybox" } };
d.topology = Topology::Triangles;
d.depth_test = false; d.depth_write = false;
- d.has_depth = true;
+ d.target = { Format::Swapchain, Format::D32 };
m_skybox_pipeline = device.create_pipeline(d);
}