diff options
author | Stephan Unverwerth <s.unverwerth@serenityos.org> | 2022-12-21 15:20:45 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-26 09:39:20 +0100 |
commit | ce57174802fefbfa9b4f5d422128af3a3f9cdf91 (patch) | |
tree | d7fbfca33275820f4089466ef6d4d16e221ef290 /Userland/Libraries/LibVirtGPU | |
parent | 51ac0d73a3399831670bee563f8f06341a3757f3 (diff) | |
download | serenity-ce57174802fefbfa9b4f5d422128af3a3f9cdf91.zip |
LibVirtGPU: Make BindTarget an enum and move it into VirtGPU::Protocol
Diffstat (limited to 'Userland/Libraries/LibVirtGPU')
-rw-r--r-- | Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp | 28 | ||||
-rw-r--r-- | Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h | 28 | ||||
-rw-r--r-- | Userland/Libraries/LibVirtGPU/VirGLProtocol.h | 38 |
3 files changed, 48 insertions, 46 deletions
diff --git a/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp b/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp index 5552d716d9..acf39ca5fc 100644 --- a/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp +++ b/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.cpp @@ -100,7 +100,7 @@ void CommandBufferBuilder::append_set_tweaks(u32 id, u32 value) builder.appendu32(value); } -void CommandBufferBuilder::append_transfer3d(ResourceID resource, size_t width, size_t height, size_t depth, size_t direction) +void CommandBufferBuilder::append_transfer3d(Protocol::ResourceID resource, size_t width, size_t height, size_t depth, size_t direction) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::TRANSFER3D, 0); builder.appendu32(resource.value()); // res_handle @@ -158,7 +158,7 @@ void CommandBufferBuilder::append_gl_clear(float r, float g, float b) builder.appendu32(0); // Stencil } -void CommandBufferBuilder::append_set_vertex_buffers(u32 stride, u32 offset, ResourceID resource) +void CommandBufferBuilder::append_set_vertex_buffers(u32 stride, u32 offset, Protocol::ResourceID resource) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::SET_VERTEX_BUFFERS, 0); builder.appendu32(stride); @@ -166,7 +166,7 @@ void CommandBufferBuilder::append_set_vertex_buffers(u32 stride, u32 offset, Res builder.appendu32(resource.value()); } -void CommandBufferBuilder::append_create_blend(ObjectHandle handle) +void CommandBufferBuilder::append_create_blend(Protocol::ObjectHandle handle) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::CREATE_OBJECT, to_underlying(Protocol::ObjectType::BLEND)); builder.appendu32(handle.value()); @@ -178,13 +178,13 @@ void CommandBufferBuilder::append_create_blend(ObjectHandle handle) } } -void CommandBufferBuilder::append_bind_blend(ObjectHandle handle) +void CommandBufferBuilder::append_bind_blend(Protocol::ObjectHandle handle) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::BIND_OBJECT, to_underlying(Protocol::ObjectType::BLEND)); builder.appendu32(handle.value()); // VIRGL_OBJ_BIND_HANDLE } -void CommandBufferBuilder::append_create_vertex_elements(ObjectHandle handle) +void CommandBufferBuilder::append_create_vertex_elements(Protocol::ObjectHandle handle) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::CREATE_OBJECT, to_underlying(Protocol::ObjectType::VERTEX_ELEMENTS)); builder.appendu32(handle.value()); @@ -198,13 +198,13 @@ void CommandBufferBuilder::append_create_vertex_elements(ObjectHandle handle) builder.appendu32(30); // src_format_1 (PIPE_FORMAT_R32G32B32_FLOAT = 30) } -void CommandBufferBuilder::append_bind_vertex_elements(ObjectHandle handle) +void CommandBufferBuilder::append_bind_vertex_elements(Protocol::ObjectHandle handle) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::BIND_OBJECT, to_underlying(Protocol::ObjectType::VERTEX_ELEMENTS)); builder.appendu32(handle.value()); // VIRGL_OBJ_BIND_HANDLE } -void CommandBufferBuilder::append_create_surface(ResourceID drawtarget_resource, ObjectHandle drawtarget_handle, Protocol::TextureFormat format) +void CommandBufferBuilder::append_create_surface(Protocol::ResourceID drawtarget_resource, Protocol::ObjectHandle drawtarget_handle, Protocol::TextureFormat format) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::CREATE_OBJECT, to_underlying(Protocol::ObjectType::SURFACE)); builder.appendu32(drawtarget_handle.value()); @@ -214,7 +214,7 @@ void CommandBufferBuilder::append_create_surface(ResourceID drawtarget_resource, builder.appendu32(0); // Last element / Texture Element } -void CommandBufferBuilder::append_set_framebuffer_state(ObjectHandle drawtarget, ObjectHandle depthbuffer) +void CommandBufferBuilder::append_set_framebuffer_state(Protocol::ObjectHandle drawtarget, Protocol::ObjectHandle depthbuffer) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::SET_FRAMEBUFFER_STATE, 0); builder.appendu32(1); // nr_cbufs @@ -251,7 +251,7 @@ void CommandBufferBuilder::append_set_constant_buffer(Vector<float> const& const } } -void CommandBufferBuilder::append_create_shader(ObjectHandle handle, Gallium::ShaderType shader_type, StringView shader_data) +void CommandBufferBuilder::append_create_shader(Protocol::ObjectHandle handle, Gallium::ShaderType shader_type, StringView shader_data) { size_t shader_len = shader_data.length() + 1; // Need to remember to copy null terminator as well if needed CommandBuilder builder(m_buffer, Protocol::VirGLCommand::CREATE_OBJECT, to_underlying(Protocol::ObjectType::SHADER)); @@ -263,14 +263,14 @@ void CommandBufferBuilder::append_create_shader(ObjectHandle handle, Gallium::Sh builder.append_string_null_padded(shader_data); } -void CommandBufferBuilder::append_bind_shader(ObjectHandle handle, Gallium::ShaderType shader_type) +void CommandBufferBuilder::append_bind_shader(Protocol::ObjectHandle handle, Gallium::ShaderType shader_type) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::BIND_SHADER, 0); builder.appendu32(handle.value()); // VIRGL_OBJ_BIND_HANDLE builder.appendu32(to_underlying(shader_type)); } -void CommandBufferBuilder::append_create_rasterizer(ObjectHandle handle) +void CommandBufferBuilder::append_create_rasterizer(Protocol::ObjectHandle handle) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::CREATE_OBJECT, to_underlying(Protocol::ObjectType::RASTERIZER)); builder.appendu32(handle.value()); // Handle @@ -284,13 +284,13 @@ void CommandBufferBuilder::append_create_rasterizer(ObjectHandle handle) builder.appendf32(0.0); // Offset clamp } -void CommandBufferBuilder::append_bind_rasterizer(ObjectHandle handle) +void CommandBufferBuilder::append_bind_rasterizer(Protocol::ObjectHandle handle) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::BIND_OBJECT, to_underlying(Protocol::ObjectType::RASTERIZER)); builder.appendu32(handle.value()); // VIRGL_OBJ_BIND_HANDLE } -void CommandBufferBuilder::append_create_dsa(ObjectHandle handle) +void CommandBufferBuilder::append_create_dsa(Protocol::ObjectHandle handle) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::CREATE_OBJECT, to_underlying(Protocol::ObjectType::DSA)); builder.appendu32(handle.value()); // Handle @@ -300,7 +300,7 @@ void CommandBufferBuilder::append_create_dsa(ObjectHandle handle) builder.appendf32(1.0); // Alpha Ref } -void CommandBufferBuilder::append_bind_dsa(ObjectHandle handle) +void CommandBufferBuilder::append_bind_dsa(Protocol::ObjectHandle handle) { CommandBuilder builder(m_buffer, Protocol::VirGLCommand::BIND_OBJECT, to_underlying(Protocol::ObjectType::DSA)); builder.appendu32(handle.value()); // VIRGL_OBJ_BIND_HANDLE diff --git a/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h b/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h index 7503cdf54a..a22f8cfcaf 100644 --- a/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h +++ b/Userland/Libraries/LibVirtGPU/CommandBufferBuilder.h @@ -18,26 +18,26 @@ namespace VirtGPU { class CommandBufferBuilder { public: void append_set_tweaks(u32 id, u32 value); - void append_transfer3d(ResourceID resource, size_t width, size_t height = 1, size_t depth = 1, size_t direction = VIRGL_DATA_DIR_GUEST_TO_HOST); + 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(u32 count); void append_gl_clear(float r, float g, float b); - void append_set_vertex_buffers(u32 stride, u32 offset, ResourceID resource); - void append_create_blend(ObjectHandle handle); - void append_bind_blend(ObjectHandle handle); - void append_create_surface(ResourceID drawtarget_resource, ObjectHandle drawtarget_handle, Protocol::TextureFormat format); - void append_set_framebuffer_state(ObjectHandle drawtarget, ObjectHandle depthbuffer = 0); - void append_create_vertex_elements(ObjectHandle handle); - void append_bind_vertex_elements(ObjectHandle handle); + 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); + void append_create_surface(Protocol::ResourceID drawtarget_resource, Protocol::ObjectHandle drawtarget_handle, Protocol::TextureFormat format); + void append_set_framebuffer_state(Protocol::ObjectHandle drawtarget, Protocol::ObjectHandle depthbuffer = 0); + void append_create_vertex_elements(Protocol::ObjectHandle handle); + void append_bind_vertex_elements(Protocol::ObjectHandle handle); void append_gl_viewport(); void append_set_framebuffer_state_no_attach(); void append_set_constant_buffer(Vector<float> const& constant_buffer); - void append_create_shader(ObjectHandle handle, Gallium::ShaderType shader_type, StringView shader_data); - void append_bind_shader(ObjectHandle handle, Gallium::ShaderType shader_type); - void append_create_rasterizer(ObjectHandle handle); - void append_bind_rasterizer(ObjectHandle handle); - void append_create_dsa(ObjectHandle handle); - void append_bind_dsa(ObjectHandle handle); + 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_create_rasterizer(Protocol::ObjectHandle handle); + void append_bind_rasterizer(Protocol::ObjectHandle handle); + void append_create_dsa(Protocol::ObjectHandle handle); + void append_bind_dsa(Protocol::ObjectHandle handle); Vector<u32> const& build() { return m_buffer; } private: diff --git a/Userland/Libraries/LibVirtGPU/VirGLProtocol.h b/Userland/Libraries/LibVirtGPU/VirGLProtocol.h index 84f7af3a59..9feef8d585 100644 --- a/Userland/Libraries/LibVirtGPU/VirGLProtocol.h +++ b/Userland/Libraries/LibVirtGPU/VirGLProtocol.h @@ -11,27 +11,29 @@ namespace VirtGPU { +namespace Protocol { + AK_TYPEDEF_DISTINCT_ORDERED_ID(u32, ObjectHandle); AK_TYPEDEF_DISTINCT_ORDERED_ID(u32, ResourceID); -#define VIRGL_BIND_DEPTH_STENCIL (1 << 0) -#define VIRGL_BIND_RENDER_TARGET (1 << 1) -#define VIRGL_BIND_SAMPLER_VIEW (1 << 3) -#define VIRGL_BIND_VERTEX_BUFFER (1 << 4) -#define VIRGL_BIND_INDEX_BUFFER (1 << 5) -#define VIRGL_BIND_CONSTANT_BUFFER (1 << 6) -#define VIRGL_BIND_DISPLAY_TARGET (1 << 7) -#define VIRGL_BIND_COMMAND_ARGS (1 << 8) -#define VIRGL_BIND_STREAM_OUTPUT (1 << 11) -#define VIRGL_BIND_SHADER_BUFFER (1 << 14) -#define VIRGL_BIND_QUERY_BUFFER (1 << 15) -#define VIRGL_BIND_CURSOR (1 << 16) -#define VIRGL_BIND_CUSTOM (1 << 17) -#define VIRGL_BIND_SCANOUT (1 << 18) -#define VIRGL_BIND_STAGING (1 << 19) -#define VIRGL_BIND_SHARED (1 << 20) - -namespace Protocol { +enum class BindTarget : u32 { + VIRGL_BIND_DEPTH_STENCIL = (1 << 0), + VIRGL_BIND_RENDER_TARGET = (1 << 1), + VIRGL_BIND_SAMPLER_VIEW = (1 << 3), + VIRGL_BIND_VERTEX_BUFFER = (1 << 4), + VIRGL_BIND_INDEX_BUFFER = (1 << 5), + VIRGL_BIND_CONSTANT_BUFFER = (1 << 6), + VIRGL_BIND_DISPLAY_TARGET = (1 << 7), + VIRGL_BIND_COMMAND_ARGS = (1 << 8), + VIRGL_BIND_STREAM_OUTPUT = (1 << 11), + VIRGL_BIND_SHADER_BUFFER = (1 << 14), + VIRGL_BIND_QUERY_BUFFER = (1 << 15), + VIRGL_BIND_CURSOR = (1 << 16), + VIRGL_BIND_CUSTOM = (1 << 17), + VIRGL_BIND_SCANOUT = (1 << 18), + VIRGL_BIND_STAGING = (1 << 19), + VIRGL_BIND_SHARED = (1 << 20), +}; enum class TextureFormat : u32 { // RGBA Formats |