Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Sep 13, 2024
1 parent 7588b47 commit 427be57
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/renderer/editor/fbx_importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/editor/render_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/gpu/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand All @@ -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 = {};
Expand Down
32 changes: 10 additions & 22 deletions src/renderer/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,15 +995,15 @@ 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);
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;
gpu::BindlessHandle texture;
} udata;
udata.texture = texture_bindless;
if (flip_x) udata.offset_scale.z = -1;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct LUMIX_RENDERER_API Pipeline {
virtual gpu::RWBindlessHandle toRWBindless(RenderBufferHandle rb_idx, DrawStream& stream) = 0;

virtual void setUniformRaw(Span<const u8> 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<const BucketDesc> buckets) = 0;
Expand Down

0 comments on commit 427be57

Please sign in to comment.