diff options
author | Stephan Unverwerth <s.unverwerth@serenityos.org> | 2022-12-21 15:55:47 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-26 09:39:20 +0100 |
commit | b5acfba487291575e04fd82cdc7a12495c585af5 (patch) | |
tree | d67db3860da5cdb6b8af0a6a2a128f894fee258c /Userland/Libraries/LibVirtGPU | |
parent | 4a4aa23aed92d2e757517b172b3a22c886b324e0 (diff) | |
download | serenity-b5acfba487291575e04fd82cdc7a12495c585af5.zip |
LibVirtGPU: Improve append_set_framebuffer_state_no_attach()
Remove hardcoded framebuffer size and add argument verification.
Diffstat (limited to 'Userland/Libraries/LibVirtGPU')
-rw-r--r-- | Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp | 17 | ||||
-rw-r--r-- | Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h | 2 |
2 files changed, 11 insertions, 8 deletions
diff --git a/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp b/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp index 3353955db4..6fb49fdefe 100644 --- a/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp +++ b/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp @@ -15,10 +15,6 @@ namespace VirtGPU { -constexpr int DRAWTARGET_WIDTH = 500; -constexpr int DRAWTARGET_HEIGHT = 500; - - static u32 encode_command(u16 length, Protocol::ObjectType object_type, Protocol::VirGLCommand command) { u8 command_value = to_underlying(command); @@ -236,11 +232,18 @@ void CommandBufferBuilder::append_viewport(Gfx::IntSize size) builder.appendf32(0.5f); // translate_z } -void CommandBufferBuilder::append_set_framebuffer_state_no_attach() +void CommandBufferBuilder::append_set_framebuffer_state_no_attach(Gfx::IntSize size) { + VERIFY(size.width() <= NumericLimits<u16>::max()); + VERIFY(size.height() <= NumericLimits<u16>::max()); + CommandBuilder builder(m_buffer, Protocol::VirGLCommand::SET_FRAMEBUFFER_STATE_NO_ATTACH, Protocol::ObjectType::NONE); - builder.appendu32((DRAWTARGET_HEIGHT << 16) | DRAWTARGET_WIDTH); // (height << 16) | width - builder.appendu32(0); // (samples << 16) | layers + + u16 samples = 0; + u16 layers = 0; + + builder.appendu32((size.height() << 16) | size.width()); + builder.appendu32((samples << 16) | layers); } void CommandBufferBuilder::append_set_constant_buffer(Vector<float> const& constant_buffer) diff --git a/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h b/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h index 4d7607b443..16a69c163d 100644 --- a/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h +++ b/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h @@ -31,7 +31,7 @@ public: void append_create_vertex_elements(Protocol::ObjectHandle handle); void append_bind_vertex_elements(Protocol::ObjectHandle handle); void append_viewport(Gfx::IntSize); - void append_set_framebuffer_state_no_attach(); + void append_set_framebuffer_state_no_attach(Gfx::IntSize); void append_set_constant_buffer(Vector<float> const& constant_buffer); void append_create_shader(Protocol::ObjectHandle handle, Gallium::ShaderType shader_type, StringView shader_data); void append_bind_shader(Protocol::ObjectHandle handle, Gallium::ShaderType shader_type); |