CommandBufferBuilder.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2022, Sahan Fernando <sahan.h.fernando@gmail.com>
  3. * Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
  4. * Copyright (c) 2022, the SerenityOS developers.
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #pragma once
  9. #include <AK/StringView.h>
  10. #include <AK/Vector.h>
  11. #include <LibGfx/Size.h>
  12. #include <LibVirtGPU/Commands.h>
  13. #include <LibVirtGPU/VirGLProtocol.h>
  14. #include <sys/ioctl.h>
  15. namespace VirtGPU {
  16. class CommandBufferBuilder {
  17. public:
  18. void append_set_tweaks(u32 id, u32 value);
  19. 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);
  20. void append_end_transfers_3d();
  21. void append_draw_vbo(Protocol::PipePrimitiveTypes, u32 count);
  22. void append_clear(float r, float g, float b, float a);
  23. void append_clear(double depth);
  24. void append_set_vertex_buffers(u32 stride, u32 offset, Protocol::ResourceID resource);
  25. void append_create_blend(Protocol::ObjectHandle handle);
  26. void append_bind_blend(Protocol::ObjectHandle handle);
  27. void append_create_surface(Protocol::ResourceID drawtarget_resource, Protocol::ObjectHandle drawtarget_handle, Protocol::TextureFormat format);
  28. void append_set_framebuffer_state(Protocol::ObjectHandle drawtarget, Protocol::ObjectHandle depthbuffer = 0);
  29. void append_create_vertex_elements(Protocol::ObjectHandle handle, Vector<CreateVertexElementsCommand::ElementBinding> const&);
  30. void append_bind_vertex_elements(Protocol::ObjectHandle handle);
  31. void append_viewport(Gfx::IntSize);
  32. void append_set_framebuffer_state_no_attach(Gfx::IntSize);
  33. void append_set_constant_buffer(Vector<float> const& constant_buffer);
  34. void append_create_shader(Protocol::ObjectHandle handle, Gallium::ShaderType shader_type, StringView shader_data);
  35. void append_bind_shader(Protocol::ObjectHandle handle, Gallium::ShaderType shader_type);
  36. void append_create_rasterizer(Protocol::ObjectHandle handle);
  37. void append_bind_rasterizer(Protocol::ObjectHandle handle);
  38. void append_create_dsa(Protocol::ObjectHandle handle);
  39. void append_bind_dsa(Protocol::ObjectHandle handle);
  40. Vector<u32> const& build() { return m_buffer; }
  41. private:
  42. Vector<u32> m_buffer;
  43. };
  44. }