From 140338670a1ee3ad0e159d0e47e37bca7ab2dbf9 Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Wed, 21 Dec 2022 16:00:28 +0100 Subject: [PATCH] LibVirtGPU: Make depth and color clearing separate functions --- .../LibVirtGPU/CommandBufferBuilder.cpp | 22 +++++++++++++++---- .../LibVirtGPU/CommandBufferBuilder.h | 3 ++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp b/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp index c1315b013c..8db8707dba 100644 --- a/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp +++ b/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp @@ -141,7 +141,7 @@ void CommandBufferBuilder::append_draw_vbo(Protocol::PipePrimitiveTypes primitiv builder.appendu32(0); // cso } -void CommandBufferBuilder::append_clear(float r, float g, float b) +void CommandBufferBuilder::append_clear(float r, float g, float b, float a) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::CLEAR, Protocol::ObjectType::NONE); Protocol::ClearType clear_flags {}; @@ -151,9 +151,23 @@ void CommandBufferBuilder::append_clear(float r, float g, float b) builder.appendf32(r); builder.appendf32(g); builder.appendf32(b); - builder.appendf32(1.0f); // Alpha - builder.appendf64(1.0); // Depth - builder.appendu32(0); // Stencil + builder.appendf32(a); + builder.appendf64(1.0); + builder.appendu32(0); +} + +void CommandBufferBuilder::append_clear(double depth) +{ + CommandBuilder builder(m_buffer, Protocol::VirGLCommand::CLEAR, Protocol::ObjectType::NONE); + Protocol::ClearType clear_flags {}; + clear_flags.flags.depth = 1; + builder.appendu32(clear_flags.value); + builder.appendf32(0); + builder.appendf32(0); + builder.appendf32(0); + builder.appendf32(0); + builder.appendf64(depth); + builder.appendu32(0); } void CommandBufferBuilder::append_set_vertex_buffers(u32 stride, u32 offset, Protocol::ResourceID resource) diff --git a/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h b/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h index 6651af274b..d5babd17b1 100644 --- a/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h +++ b/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h @@ -22,7 +22,8 @@ public: void append_transfer3d(Protocol::ResourceID resource, size_t width, size_t height = 1, size_t depth = 1, size_t direction = VIRGL_DATA_DIR_GUEST_TO_HOST); void append_end_transfers_3d(); void append_draw_vbo(Protocol::PipePrimitiveTypes, u32 count); - void append_clear(float r, float g, float b); + void append_clear(float r, float g, float b, float a); + void append_clear(double depth); void append_set_vertex_buffers(u32 stride, u32 offset, Protocol::ResourceID resource); void append_create_blend(Protocol::ObjectHandle handle); void append_bind_blend(Protocol::ObjectHandle handle);