From 427be574a29db08a685bb5609c48e0e176209667 Mon Sep 17 00:00:00 2001 From: Mikulas Florek Date: Sat, 14 Sep 2024 00:34:32 +0200 Subject: [PATCH] cleanup --- src/renderer/editor/fbx_importer.cpp | 6 ++--- src/renderer/editor/render_plugins.cpp | 4 ++-- src/renderer/gpu/gpu.h | 2 -- src/renderer/pipeline.cpp | 32 ++++++++------------------ src/renderer/pipeline.h | 2 +- 5 files changed, 16 insertions(+), 30 deletions(-) diff --git a/src/renderer/editor/fbx_importer.cpp b/src/renderer/editor/fbx_importer.cpp index 1dc521d273..6842875271 100644 --- a/src/renderer/editor/fbx_importer.cpp +++ b/src/renderer/editor/fbx_importer.cpp @@ -1274,9 +1274,9 @@ void FBXImporter::createImpostorTextures(Model* model, ImpostorTexturesContext& IVec2 tile_size; int size; float radius; - u32 depth; - u32 normalmap; - u32 output; + gpu::BindlessHandle depth; + gpu::BindlessHandle normalmap; + gpu::RWBindlessHandle output; } data; for (u32 j = 0; j < IMPOSTOR_COLS; ++j) { for (u32 i = 0; i < IMPOSTOR_COLS; ++i) { diff --git a/src/renderer/editor/render_plugins.cpp b/src/renderer/editor/render_plugins.cpp index 98c894aba7..316ce7b6a5 100644 --- a/src/renderer/editor/render_plugins.cpp +++ b/src/renderer/editor/render_plugins.cpp @@ -3561,7 +3561,7 @@ struct EnvironmentProbePlugin final : PropertyGrid::IPlugin { m_pipeline->render(false); stream.setFramebufferCube(cubemap, i, 0); - const u32 side_tex = gpu::getBindlessHandle(m_pipeline->getOutput()); + const gpu::BindlessHandle side_tex = gpu::getBindlessHandle(m_pipeline->getOutput()); m_pipeline->renderTexturedQuad(side_tex, i != 2 && i != 3, i == 2 || i == 3); } @@ -3598,7 +3598,7 @@ struct EnvironmentProbePlugin final : PropertyGrid::IPlugin { float roughness; u32 face; u32 mip; - u32 texture; + gpu::BindlessHandle texture; } drawcall = { roughness, face, mip, gpu::getBindlessHandle(cubemap) }; m_pipeline->setUniform(drawcall); stream.viewport(0, 0, texture_size >> mip, texture_size >> mip); diff --git a/src/renderer/gpu/gpu.h b/src/renderer/gpu/gpu.h index 0d3ca30a85..5b73d556a0 100644 --- a/src/renderer/gpu/gpu.h +++ b/src/renderer/gpu/gpu.h @@ -24,7 +24,6 @@ struct BindlessHandle { constexpr BindlessHandle() {} explicit BindlessHandle(u32 value) : value(value) {} u32 value = 0; - operator u32() const { return value; } }; static constexpr BindlessHandle INVALID_BINDLESS_HANDLE = {}; @@ -33,7 +32,6 @@ struct RWBindlessHandle { constexpr RWBindlessHandle() {} explicit RWBindlessHandle(u32 value) : value(value) {} u32 value = 0; - operator u32() const { return value; } }; static constexpr RWBindlessHandle INVALID_RW_BINDLESS_HANDLE = {}; diff --git a/src/renderer/pipeline.cpp b/src/renderer/pipeline.cpp index c12ec5f95d..2c9adb90e1 100644 --- a/src/renderer/pipeline.cpp +++ b/src/renderer/pipeline.cpp @@ -995,7 +995,7 @@ struct PipelineImpl final : Pipeline { stream.drawArrays(indices_offset, indices_count); } - void renderTexturedQuad(u32 texture_bindless, bool flip_x, bool flip_y) override { + void renderTexturedQuad(gpu::BindlessHandle texture_bindless, bool flip_x, bool flip_y) override { struct { Vec4 offset_scale = Vec4(0, 0, 1, 1); Vec4 r_mask = Vec4(1, 0, 0, 0); @@ -1003,7 +1003,7 @@ struct PipelineImpl final : Pipeline { Vec4 b_mask = Vec4(0, 0, 1, 0); Vec4 a_mask = Vec4(0, 0, 0, 1);; Vec4 offsets = Vec4(0, 0, 0, 1); - u32 texture; + gpu::BindlessHandle texture; } udata; udata.texture = texture_bindless; if (flip_x) udata.offset_scale.z = -1; @@ -1234,22 +1234,10 @@ struct PipelineImpl final : Pipeline { .debug_name = "hdr_copy" }); - struct { - Vec4 offset_scale = Vec4(0, 0, 1, 1); - Vec4 r_mask = Vec4(1, 0, 0, 0); - Vec4 g_mask = Vec4(0, 1, 0, 0); - Vec4 b_mask = Vec4(0, 0, 1, 0); - Vec4 a_mask = Vec4(0, 0, 0, 1);; - Vec4 offsets = Vec4(0, 0, 0, 1); - u32 texture; - } udata; DrawStream& stream = m_renderer.getDrawStream(); - udata.texture = toBindless(hdr_rb, stream); - pass(getMainCamera()); setRenderTargets(Span(&color_copy, 1)); - setUniform(udata); - drawArray(0, 3, *m_textured_quad_shader, 0, gpu::StateFlags::NONE); + renderTexturedQuad(toBindless(hdr_rb, stream), false, false); setRenderTargets(Span(&hdr_rb, 1), gbuffer.DS, true); @@ -1325,7 +1313,7 @@ struct PipelineImpl final : Pipeline { Vec4 b_mask; Vec4 a_mask; Vec4 offsets; - u32 texture; + gpu::BindlessHandle texture; } copy_ub = { Vec4(0, 0, 1, 1), r, @@ -2213,9 +2201,9 @@ struct PipelineImpl final : Pipeline { float padding; Vec4 camera_planes[6]; IVec4 indices_count[32]; - u32 culled_buffer; - u32 instanced_data; - u32 indirect_buffer; + gpu::RWBindlessHandle culled_buffer; + gpu::RWBindlessHandle instanced_data; + gpu::RWBindlessHandle indirect_buffer; }; UBValues ub_values; @@ -2313,9 +2301,9 @@ struct PipelineImpl final : Pipeline { ub_values.indirect_offset = indirect_offset; ub_values.radius = m->getOriginBoundingRadius(); ub_values.batch_size = instance_count; - ub_values.culled_buffer = gpu::getBindlessHandle(culled_buffer) + 1; - ub_values.instanced_data = gpu::getBindlessHandle(im.gpu_data) + 1; - ub_values.indirect_buffer = gpu::getBindlessHandle(m_indirect_buffer) + 1; + ub_values.culled_buffer = gpu::getRWBindlessHandle(culled_buffer); + ub_values.instanced_data = gpu::getRWBindlessHandle(im.gpu_data); + ub_values.indirect_buffer = gpu::getRWBindlessHandle(m_indirect_buffer); ASSERT((u32)m->getMeshCount() < lengthOf(ub_values.indices_count)); // TODO for (i32 i = 0; i < m->getMeshCount(); ++i) { const Mesh& mesh = m->getMesh(i); diff --git a/src/renderer/pipeline.h b/src/renderer/pipeline.h index 76fea905c8..935c86ef16 100644 --- a/src/renderer/pipeline.h +++ b/src/renderer/pipeline.h @@ -140,7 +140,7 @@ struct LUMIX_RENDERER_API Pipeline { virtual gpu::RWBindlessHandle toRWBindless(RenderBufferHandle rb_idx, DrawStream& stream) = 0; virtual void setUniformRaw(Span mem, UniformBuffer::Enum bind_point = UniformBuffer::DRAWCALL) = 0; - virtual void renderTexturedQuad(u32 texture_bindless, bool flip_x = false, bool flip_y = false) = 0; + virtual void renderTexturedQuad(gpu::BindlessHandle texture, bool flip_x = false, bool flip_y = false) = 0; virtual void viewport(i32 x, i32 y, i32 w, i32 h) = 0; virtual void pass(const CameraParams& cp) const = 0; virtual u32 cull(const CameraParams& cp, Span buckets) = 0;