1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:07:45 +00:00

LibVirtGPU: Improve append_set_framebuffer_state_no_attach()

Remove hardcoded framebuffer size and add argument verification.
This commit is contained in:
Stephan Unverwerth 2022-12-21 15:55:47 +01:00 committed by Andreas Kling
parent 4a4aa23aed
commit b5acfba487
2 changed files with 11 additions and 8 deletions

View file

@ -15,10 +15,6 @@
namespace VirtGPU { 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) static u32 encode_command(u16 length, Protocol::ObjectType object_type, Protocol::VirGLCommand command)
{ {
u8 command_value = to_underlying(command); u8 command_value = to_underlying(command);
@ -236,11 +232,18 @@ void CommandBufferBuilder::append_viewport(Gfx::IntSize size)
builder.appendf32(0.5f); // translate_z 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); 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) void CommandBufferBuilder::append_set_constant_buffer(Vector<float> const& constant_buffer)

View file

@ -31,7 +31,7 @@ public:
void append_create_vertex_elements(Protocol::ObjectHandle handle); void append_create_vertex_elements(Protocol::ObjectHandle handle);
void append_bind_vertex_elements(Protocol::ObjectHandle handle); void append_bind_vertex_elements(Protocol::ObjectHandle handle);
void append_viewport(Gfx::IntSize); 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_set_constant_buffer(Vector<float> const& constant_buffer);
void append_create_shader(Protocol::ObjectHandle handle, Gallium::ShaderType shader_type, StringView shader_data); 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); void append_bind_shader(Protocol::ObjectHandle handle, Gallium::ShaderType shader_type);