CommandBufferBuilder.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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/VirGLProtocol.h>
  13. #include <sys/ioctl_numbers.h>
  14. namespace VirtGPU {
  15. class CommandBufferBuilder {
  16. public:
  17. void append_set_tweaks(u32 id, u32 value);
  18. 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);
  19. void append_end_transfers_3d();
  20. void append_draw_vbo(Protocol::PipePrimitiveTypes, u32 count);
  21. void append_clear(float r, float g, float b, float a);
  22. void append_clear(double depth);
  23. void append_set_vertex_buffers(u32 stride, u32 offset, Protocol::ResourceID resource);
  24. void append_create_blend(Protocol::ObjectHandle handle);
  25. void append_bind_blend(Protocol::ObjectHandle handle);
  26. void append_create_surface(Protocol::ResourceID drawtarget_resource, Protocol::ObjectHandle drawtarget_handle, Protocol::TextureFormat format);
  27. void append_set_framebuffer_state(Protocol::ObjectHandle drawtarget, Protocol::ObjectHandle depthbuffer = 0);
  28. void append_create_vertex_elements(Protocol::ObjectHandle handle);
  29. void append_bind_vertex_elements(Protocol::ObjectHandle handle);
  30. void append_viewport(Gfx::IntSize);
  31. void append_set_framebuffer_state_no_attach(Gfx::IntSize);
  32. void append_set_constant_buffer(Vector<float> const& constant_buffer);
  33. void append_create_shader(Protocol::ObjectHandle handle, Gallium::ShaderType shader_type, StringView shader_data);
  34. void append_bind_shader(Protocol::ObjectHandle handle, Gallium::ShaderType shader_type);
  35. void append_create_rasterizer(Protocol::ObjectHandle handle);
  36. void append_bind_rasterizer(Protocol::ObjectHandle handle);
  37. void append_create_dsa(Protocol::ObjectHandle handle);
  38. void append_bind_dsa(Protocol::ObjectHandle handle);
  39. Vector<u32> const& build() { return m_buffer; }
  40. private:
  41. Vector<u32> m_buffer;
  42. };
  43. }