mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 05:34:58 +00:00
LibVirtGPU: Add a new GPU device that talks to our VirtIO-GPU driver
At this moment this only contains function stubs.
This commit is contained in:
parent
3b2ded1d44
commit
c52abe0bea
9 changed files with 335 additions and 0 deletions
|
@ -57,6 +57,7 @@ add_subdirectory(LibTLS)
|
|||
add_subdirectory(LibUnicode)
|
||||
add_subdirectory(LibUSBDB)
|
||||
add_subdirectory(LibVideo)
|
||||
add_subdirectory(LibVirtGPU)
|
||||
add_subdirectory(LibVT)
|
||||
add_subdirectory(LibWasm)
|
||||
add_subdirectory(LibWeb)
|
||||
|
|
|
@ -7,3 +7,7 @@ serenity_lib(LibGPU gpu)
|
|||
target_link_libraries(LibGPU PRIVATE LibCore ${CMAKE_DL_LIBS})
|
||||
|
||||
add_dependencies(LibGPU LibSoftGPU)
|
||||
|
||||
if (SERENITYOS)
|
||||
add_dependencies(LibGPU LibVirtGPU)
|
||||
endif()
|
||||
|
|
9
Userland/Libraries/LibVirtGPU/CMakeLists.txt
Normal file
9
Userland/Libraries/LibVirtGPU/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
set(SOURCES
|
||||
Device.cpp
|
||||
Image.cpp
|
||||
Shader.cpp
|
||||
)
|
||||
|
||||
serenity_lib(LibVirtGPU virtgpu)
|
||||
target_link_libraries(LibVirtGPU PRIVATE LibCore)
|
||||
target_sources(LibVirtGPU PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../LibGPU/Image.cpp")
|
175
Userland/Libraries/LibVirtGPU/Device.cpp
Normal file
175
Userland/Libraries/LibVirtGPU/Device.cpp
Normal file
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibVirtGPU/Device.h>
|
||||
#include <LibVirtGPU/Image.h>
|
||||
#include <LibVirtGPU/Shader.h>
|
||||
|
||||
namespace VirtGPU {
|
||||
|
||||
GPU::DeviceInfo Device::info() const
|
||||
{
|
||||
return {
|
||||
.vendor_name = "SerenityOS",
|
||||
.device_name = "VirtGPU",
|
||||
.num_texture_units = GPU::NUM_TEXTURE_UNITS,
|
||||
.num_lights = 8,
|
||||
.max_clip_planes = 6,
|
||||
.max_texture_size = 4096,
|
||||
.max_texture_lod_bias = 2.f,
|
||||
.stencil_bits = sizeof(GPU::StencilType) * 8,
|
||||
.supports_npot_textures = true,
|
||||
.supports_texture_clamp_to_edge = true,
|
||||
.supports_texture_env_add = true,
|
||||
};
|
||||
}
|
||||
|
||||
void Device::draw_primitives(GPU::PrimitiveType, FloatMatrix4x4 const&, FloatMatrix4x4 const&, Vector<GPU::Vertex>&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::draw_primitives(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::resize(Gfx::IntSize)
|
||||
{
|
||||
dbgln("VirtGPU::Device::resize(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::clear_color(FloatVector4 const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::clear_color(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::clear_depth(GPU::DepthType)
|
||||
{
|
||||
dbgln("VirtGPU::Device::clear_depth(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::clear_stencil(GPU::StencilType)
|
||||
{
|
||||
dbgln("VirtGPU::Device::clear_stencil(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::blit_from_color_buffer(Gfx::Bitmap&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::blit_from_color_buffer(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::blit_from_color_buffer(NonnullRefPtr<GPU::Image>, u32, Vector2<u32>, Vector2<i32>, Vector3<i32>)
|
||||
{
|
||||
dbgln("VirtGPU::Device::blit_from_color_buffer(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::blit_from_color_buffer(void*, Vector2<i32>, GPU::ImageDataLayout const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::blit_from_color_buffer(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::blit_from_depth_buffer(void*, Vector2<i32>, GPU::ImageDataLayout const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::blit_from_depth_buffer(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::blit_from_depth_buffer(NonnullRefPtr<GPU::Image>, u32, Vector2<u32>, Vector2<i32>, Vector3<i32>)
|
||||
{
|
||||
dbgln("VirtGPU::Device::blit_from_depth_buffer(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::blit_to_color_buffer_at_raster_position(void const*, GPU::ImageDataLayout const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::blit_to_color_buffer_at_raster_position(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::blit_to_depth_buffer_at_raster_position(void const*, GPU::ImageDataLayout const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::blit_to_depth_buffer_at_raster_position(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::set_options(GPU::RasterizerOptions const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::set_options(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::set_light_model_params(GPU::LightModelParameters const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::set_light_model_params(): unimplemented");
|
||||
}
|
||||
|
||||
GPU::RasterizerOptions Device::options() const
|
||||
{
|
||||
dbgln("VirtGPU::Device::options(): unimplemented");
|
||||
return {};
|
||||
}
|
||||
|
||||
GPU::LightModelParameters Device::light_model() const
|
||||
{
|
||||
dbgln("VirtGPU::Device::light_model(): unimplemented");
|
||||
return {};
|
||||
}
|
||||
|
||||
NonnullRefPtr<GPU::Image> Device::create_image(GPU::PixelFormat const& pixel_format, u32 width, u32 height, u32 depth, u32 max_levels)
|
||||
{
|
||||
dbgln("VirtGPU::Device::create_image(): unimplemented");
|
||||
return adopt_ref(*new Image(this, pixel_format, width, height, depth, max_levels));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<GPU::Shader>> Device::create_shader(GPU::IR::Shader const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::create_shader(): unimplemented");
|
||||
return adopt_ref(*new Shader(this));
|
||||
}
|
||||
|
||||
void Device::set_sampler_config(unsigned, GPU::SamplerConfig const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::set_sampler_config(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::set_light_state(unsigned, GPU::Light const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::set_light_state(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::set_material_state(GPU::Face, GPU::Material const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::set_material_state(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::set_stencil_configuration(GPU::Face, GPU::StencilConfiguration const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::set_stencil_configuration(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::set_texture_unit_configuration(GPU::TextureUnitIndex, GPU::TextureUnitConfiguration const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::set_texture_unit_configuration(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::set_clip_planes(Vector<FloatVector4> const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::set_clip_planes(): unimplemented");
|
||||
}
|
||||
|
||||
GPU::RasterPosition Device::raster_position() const
|
||||
{
|
||||
dbgln("VirtGPU::Device::raster_position(): unimplemented");
|
||||
return {};
|
||||
}
|
||||
|
||||
void Device::set_raster_position(GPU::RasterPosition const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::set_raster_position(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::set_raster_position(FloatVector4 const&, FloatMatrix4x4 const&, FloatMatrix4x4 const&)
|
||||
{
|
||||
dbgln("VirtGPU::Device::set_raster_position(): unimplemented");
|
||||
}
|
||||
|
||||
void Device::bind_fragment_shader(RefPtr<GPU::Shader>)
|
||||
{
|
||||
dbgln("VirtGPU::Device::bind_fragment_shader(): unimplemented");
|
||||
}
|
||||
|
||||
}
|
51
Userland/Libraries/LibVirtGPU/Device.h
Normal file
51
Userland/Libraries/LibVirtGPU/Device.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGPU/Device.h>
|
||||
|
||||
namespace VirtGPU {
|
||||
|
||||
class Device final : public GPU::Device {
|
||||
public:
|
||||
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;
|
||||
virtual void resize(Gfx::IntSize min_size) override;
|
||||
virtual void clear_color(FloatVector4 const&) override;
|
||||
virtual void clear_depth(GPU::DepthType) override;
|
||||
virtual void clear_stencil(GPU::StencilType) override;
|
||||
virtual void blit_from_color_buffer(Gfx::Bitmap& target) override;
|
||||
virtual void blit_from_color_buffer(NonnullRefPtr<GPU::Image>, u32 level, Vector2<u32> input_size, Vector2<i32> input_offset, Vector3<i32> output_offset) override;
|
||||
virtual void blit_from_color_buffer(void*, Vector2<i32> offset, GPU::ImageDataLayout const&) override;
|
||||
virtual void blit_from_depth_buffer(void*, Vector2<i32> offset, GPU::ImageDataLayout const&) override;
|
||||
virtual void blit_from_depth_buffer(NonnullRefPtr<GPU::Image>, u32 level, Vector2<u32> input_size, Vector2<i32> input_offset, Vector3<i32> output_offset) override;
|
||||
virtual void blit_to_color_buffer_at_raster_position(void const*, GPU::ImageDataLayout const&) override;
|
||||
virtual void blit_to_depth_buffer_at_raster_position(void const*, GPU::ImageDataLayout const&) override;
|
||||
virtual void set_options(GPU::RasterizerOptions const&) override;
|
||||
virtual void set_light_model_params(GPU::LightModelParameters const&) override;
|
||||
virtual GPU::RasterizerOptions options() const override;
|
||||
virtual GPU::LightModelParameters light_model() const override;
|
||||
|
||||
virtual NonnullRefPtr<GPU::Image> create_image(GPU::PixelFormat const&, u32 width, u32 height, u32 depth, u32 max_levels) override;
|
||||
virtual ErrorOr<NonnullRefPtr<GPU::Shader>> create_shader(GPU::IR::Shader const&) override;
|
||||
|
||||
virtual void set_sampler_config(unsigned, GPU::SamplerConfig const&) override;
|
||||
virtual void set_light_state(unsigned, GPU::Light const&) override;
|
||||
virtual void set_material_state(GPU::Face, GPU::Material const&) override;
|
||||
virtual void set_stencil_configuration(GPU::Face, GPU::StencilConfiguration const&) override;
|
||||
virtual void set_texture_unit_configuration(GPU::TextureUnitIndex, GPU::TextureUnitConfiguration const&) override;
|
||||
virtual void set_clip_planes(Vector<FloatVector4> const&) override;
|
||||
|
||||
virtual GPU::RasterPosition raster_position() const override;
|
||||
virtual void set_raster_position(GPU::RasterPosition const& raster_position) override;
|
||||
virtual void set_raster_position(FloatVector4 const& position, FloatMatrix4x4 const& model_view_transform, FloatMatrix4x4 const& projection_transform) override;
|
||||
|
||||
virtual void bind_fragment_shader(RefPtr<GPU::Shader>) override;
|
||||
};
|
||||
|
||||
}
|
37
Userland/Libraries/LibVirtGPU/Image.cpp
Normal file
37
Userland/Libraries/LibVirtGPU/Image.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibVirtGPU/Image.h>
|
||||
|
||||
namespace VirtGPU {
|
||||
|
||||
Image::Image(void const* ownership_token, GPU::PixelFormat const& pixel_format, u32 width, u32 height, u32 depth, u32 max_levels)
|
||||
: GPU::Image(ownership_token, pixel_format, width, height, depth, max_levels)
|
||||
{
|
||||
dbgln("VirtGPU::Image::Image(): unimplemented");
|
||||
}
|
||||
|
||||
void Image::regenerate_mipmaps()
|
||||
{
|
||||
dbgln("VirtGPU::Image::regenerate_mipmaps(): unimplemented");
|
||||
}
|
||||
|
||||
void Image::write_texels(u32, Vector3<i32> const&, void const*, GPU::ImageDataLayout const&)
|
||||
{
|
||||
dbgln("VirtGPU::Image::write_texels(): unimplemented");
|
||||
}
|
||||
|
||||
void Image::read_texels(u32, Vector3<i32> const&, void*, GPU::ImageDataLayout const&) const
|
||||
{
|
||||
dbgln("VirtGPU::Image::read_texels(): unimplemented");
|
||||
}
|
||||
|
||||
void Image::copy_texels(GPU::Image const&, u32, Vector3<u32> const&, Vector3<u32> const&, u32, Vector3<u32> const&)
|
||||
{
|
||||
dbgln("VirtGPU::Image::copy_texels(): unimplemented");
|
||||
}
|
||||
|
||||
}
|
24
Userland/Libraries/LibVirtGPU/Image.h
Normal file
24
Userland/Libraries/LibVirtGPU/Image.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGPU/Image.h>
|
||||
|
||||
namespace VirtGPU {
|
||||
|
||||
class Image final : public GPU::Image {
|
||||
public:
|
||||
Image(void const* ownership_token, GPU::PixelFormat const&, u32 width, u32 height, u32 depth, u32 max_levels);
|
||||
|
||||
virtual void regenerate_mipmaps() override;
|
||||
|
||||
virtual void write_texels(u32 level, Vector3<i32> const& output_offset, void const* input_data, GPU::ImageDataLayout const&) override;
|
||||
virtual void read_texels(u32 level, Vector3<i32> const& input_offset, void* output_data, GPU::ImageDataLayout const&) const override;
|
||||
virtual void copy_texels(GPU::Image const& source, u32 source_level, Vector3<u32> const& source_offset, Vector3<u32> const& size, u32 destination_level, Vector3<u32> const& destination_offset) override;
|
||||
};
|
||||
|
||||
}
|
16
Userland/Libraries/LibVirtGPU/Shader.cpp
Normal file
16
Userland/Libraries/LibVirtGPU/Shader.cpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibVirtGPU/Shader.h>
|
||||
|
||||
namespace VirtGPU {
|
||||
|
||||
Shader::Shader(void const* ownership_token)
|
||||
: GPU::Shader(ownership_token)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
18
Userland/Libraries/LibVirtGPU/Shader.h
Normal file
18
Userland/Libraries/LibVirtGPU/Shader.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGPU/Shader.h>
|
||||
|
||||
namespace VirtGPU {
|
||||
|
||||
class Shader final : public GPU::Shader {
|
||||
public:
|
||||
Shader(void const* ownership_token);
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue