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

LibVirtGPU: Adopt device initialization code from VirGLDemo

This commit is contained in:
Stephan Unverwerth 2022-12-22 15:11:32 +01:00 committed by Andreas Kling
parent 086c7c4c88
commit 1ec791fcd0
2 changed files with 198 additions and 1 deletions

View file

@ -8,8 +8,11 @@
#include <AK/NonnullOwnPtr.h>
#include <AK/NonnullRefPtr.h>
#include <AK/Vector.h>
#include <Kernel/API/VirGL.h>
#include <LibCore/File.h>
#include <LibGPU/Device.h>
#include <LibVirtGPU/VirGLProtocol.h>
namespace VirtGPU {
@ -19,6 +22,9 @@ public:
static ErrorOr<NonnullOwnPtr<Device>> create(Gfx::IntSize min_size);
// FIXME: Once the kernel driver supports destroying contexts we need to add this functionality here
ErrorOr<void> initialize_context(Gfx::IntSize min_size);
virtual GPU::DeviceInfo info() const override;
virtual void draw_primitives(GPU::PrimitiveType, FloatMatrix4x4 const& model_view_transform, FloatMatrix4x4 const& projection_transform, Vector<GPU::Vertex>& vertices) override;
@ -55,7 +61,33 @@ public:
virtual void bind_fragment_shader(RefPtr<GPU::Shader>) override;
private:
Protocol::ObjectHandle allocate_handle();
ErrorOr<Protocol::ResourceID> create_virgl_resource(VirGL3DResourceSpec&);
ErrorOr<void> upload_command_buffer(Vector<u32> const&);
NonnullRefPtr<Core::File> m_gpu_file;
Protocol::ResourceID m_vbo_resource_id { 0 };
Protocol::ResourceID m_drawtarget { 0 };
Protocol::ResourceID m_depthbuffer_surface { 0 };
Protocol::ObjectHandle m_blend_handle { 0 };
Protocol::ObjectHandle m_drawtarget_surface_handle { 0 };
Protocol::ObjectHandle m_depthbuffer_surface_handle { 0 };
Protocol::ObjectHandle m_ve_handle { 0 };
Protocol::ObjectHandle m_frag_shader_handle { 0 };
Protocol::ObjectHandle m_vert_shader_handle { 0 };
Protocol::ObjectHandle m_rasterizer_handle { 0 };
Protocol::ObjectHandle m_dsa_handle { 0 };
u32 m_last_allocated_handle { 0 };
struct VertexData {
float r;
float g;
float b;
float x;
float y;
float z;
};
};
}