Skip to content

Commit

Permalink
Merge pull request #2962 from MirServer/platform-API-merge
Browse files Browse the repository at this point in the history
Platform api merge
  • Loading branch information
AlanGriffiths authored Oct 18, 2023
2 parents effa154 + 926748e commit 1d57c1d
Show file tree
Hide file tree
Showing 186 changed files with 8,832 additions and 5,496 deletions.
11 changes: 2 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "${build_types}" FORCE)
# Enable cmake-gui to display a drop down list for CMAKE_BUILD_TYPE
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${build_types}")

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Expand Down Expand Up @@ -233,6 +233,7 @@ if(NOT GLM_FOUND)
endif()
pkg_check_modules(DRM REQUIRED IMPORTED_TARGET libdrm)
pkg_check_modules(EGL REQUIRED IMPORTED_TARGET egl)
pkg_check_modules(EPOXY REQUIRED IMPORTED_TARGET epoxy)
pkg_check_modules(GFlags REQUIRED IMPORTED_TARGET gflags)
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0 gio-unix-2.0)
pkg_check_modules(GLESv2 REQUIRED IMPORTED_TARGET glesv2)
Expand Down Expand Up @@ -271,14 +272,6 @@ if (MIR_BUILD_PLATFORM_GBM_KMS)
pkg_check_modules(GBM REQUIRED IMPORTED_TARGET gbm>=11.0.0)
endif()

if (MIR_BUILD_PLATFORM_EGLSTREAM_KMS)
pkg_check_modules(EPOXY REQUIRED IMPORTED_TARGET epoxy)
endif()

if (MIR_BUILD_PLATFORM_WAYLAND)
pkg_check_modules(EPOXY REQUIRED IMPORTED_TARGET epoxy)
endif()

set(MIR_TRACEPOINT_LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/mir/tools)

mir_make_pkgconfig_variable(PKGCONFIG_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
Expand Down
8 changes: 4 additions & 4 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Description: Display server for Ubuntu - server library
.
Contains the shared library needed by server applications for Mir.

Package: libmirplatform26
Package: libmirplatform27
Section: libs
Architecture: linux-any
Multi-Arch: same
Expand Down Expand Up @@ -124,7 +124,7 @@ Section: libdevel
Architecture: linux-any
Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
Depends: libmirplatform26 (= ${binary:Version}),
Depends: libmirplatform27 (= ${binary:Version}),
libmircommon-dev (= ${binary:Version}),
libboost-program-options-dev,
${misc:Depends},
Expand Down Expand Up @@ -520,7 +520,7 @@ Description: Developer files for the Mir ABI-stable abstraction layer
Contains header files required for development using the MirAL abstraction
layer.

Package: libmiroil3
Package: libmiroil4
Section: libs
Architecture: linux-any
Multi-Arch: same
Expand All @@ -537,7 +537,7 @@ Section: libdevel
Architecture: linux-any
Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
Depends: libmiroil3 (= ${binary:Version}),
Depends: libmiroil4 (= ${binary:Version}),
${misc:Depends},
Description: Developer files for the Mir Lomiri compatibility library
MirOil provides the Lomiri compatibility API.
Expand Down
1 change: 0 additions & 1 deletion debian/libmiroil3.install

This file was deleted.

1 change: 1 addition & 0 deletions debian/libmiroil4.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/lib/*/libmiroil.so.4
1 change: 0 additions & 1 deletion debian/libmirplatform26.install

This file was deleted.

1 change: 1 addition & 0 deletions debian/libmirplatform27.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/lib/*/libmirplatform.so.27
1 change: 1 addition & 0 deletions doc/sphinx/.readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ build:
- libboost-system-dev
- libdrm-dev
- libegl-dev
- libepoxy-dev
- libfreetype-dev
- libglib2.0-dev
- libgles2-mesa-dev
Expand Down
3 changes: 0 additions & 3 deletions include/platform/mir/graphics/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
#include "mir/geometry/size.h"
#include "mir_toolkit/common.h"

#include <memory>
#include <functional>

namespace mir
{
namespace graphics
Expand Down
2 changes: 1 addition & 1 deletion include/platform/mir/graphics/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class DisplaySyncGroup
/**
* Interface to the display subsystem.
*/
class Display : public renderer::gl::ContextSource
class Display
{
public:
/**
Expand Down
47 changes: 30 additions & 17 deletions include/platform/mir/graphics/display_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,24 @@ namespace mir
namespace graphics
{

class Buffer;
class Framebuffer;
class DisplayInterfaceProvider;

class NativeDisplayBuffer
struct DisplayElement
{
protected:
NativeDisplayBuffer() = default;
virtual ~NativeDisplayBuffer() = default;
NativeDisplayBuffer(NativeDisplayBuffer const&) = delete;
NativeDisplayBuffer operator=(NativeDisplayBuffer const&) = delete;
/// Position and size of this element on-screen
geometry::Rectangle screen_positon;
/** Position and size of region of the buffer to sample from
*
* This will typically be (0,0) ->(buffer width, buffer height)
* to use the whole buffer (with screen_position.size = (buffer width, buffer height)).
*
* Scaling can be specified by having screen_position.size != source_position.size,
* clipping can be specified by having source_position.size != buffer.size
*/
geometry::RectangleF source_position;
std::shared_ptr<Framebuffer> buffer;
};

/**
* Interface to an output framebuffer.
*/
Expand All @@ -64,7 +71,20 @@ class DisplayBuffer
* caller should then render the list another way using a graphics
* library such as OpenGL.
**/
virtual bool overlay(RenderableList const& renderlist) = 0;
virtual bool overlay(std::vector<DisplayElement> const& renderlist) = 0;

/**
* Set the content for the next submission of this display
*
* This is basically a specialisation of overlay(), above, with extra constraints
* and guarantees. Namely:
* * The Framebuffer must be exactly view_area().size big, and
* * The DisplayPlatform guarantees that this call will succeed with a framebuffer
* allocated for this DisplayBuffer
*
* \param content
*/
virtual void set_next_image(std::unique_ptr<Framebuffer> content) = 0;

/**
* Returns a transformation that the renderer must apply to all rendering.
Expand All @@ -75,14 +95,7 @@ class DisplayBuffer
*/
virtual glm::mat2 transformation() const = 0;

/** Returns a pointer to the native display buffer object backing this
* display buffer.
*
* The pointer to the native display buffer remains valid as long as the
* display buffer object is valid.
*/
virtual NativeDisplayBuffer* native_display_buffer() = 0;

virtual auto display_provider() const -> std::shared_ptr<DisplayInterfaceProvider> = 0;
protected:
DisplayBuffer() = default;
DisplayBuffer(DisplayBuffer const& c) = delete;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class DisplayConfigurationPolicy
virtual ~DisplayConfigurationPolicy() = default;

virtual void apply_to(DisplayConfiguration& conf) = 0;
virtual void confirm(DisplayConfiguration const& conf) = 0;

protected:
DisplayConfigurationPolicy() = default;
Expand Down
8 changes: 6 additions & 2 deletions include/platform/mir/graphics/dmabuf_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
#include <optional>

#include "mir/graphics/buffer.h"
#include "mir/graphics/texture.h"
#include "mir/fd.h"

namespace mir
{
namespace graphics
{
class DRMFormat;
/**
* A logical buffer backed by one-or-more dmabuf buffers
*/
Expand All @@ -42,9 +44,9 @@ class DMABufBuffer : public NativeBufferBase
virtual ~DMABufBuffer() = default;

/**
* The format of this logical buffer, as in <drm_fourcc.h>
* The format of this logical buffer
*/
virtual auto drm_fourcc() const -> uint32_t = 0;
virtual auto format() const -> DRMFormat = 0;

/**
* The DRM modifier of this logical buffer, if specified.
Expand All @@ -57,6 +59,8 @@ class DMABufBuffer : public NativeBufferBase

virtual auto planes() const -> std::vector<PlaneDescriptor> const& = 0;

virtual auto layout() const -> gl::Texture::Layout = 0;

virtual auto size() const -> geometry::Size = 0;
};
}
Expand Down
2 changes: 2 additions & 0 deletions include/platform/mir/graphics/drm_formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class DRMFormat
operator uint32_t() const;

auto as_mir_format() const -> std::optional<MirPixelFormat>;
static auto from_mir_format(MirPixelFormat format) -> DRMFormat;

struct FormatInfo;
private:
FormatInfo const* info;
Expand Down
11 changes: 10 additions & 1 deletion include/platform/mir/graphics/egl_extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,17 @@ struct EGLExtensions
PFNEGLQUERYDMABUFFORMATSEXTPROC const eglQueryDmaBufFormatsExt;
PFNEGLQUERYDMABUFMODIFIERSEXTPROC const eglQueryDmaBufModifiersExt;
};
};

struct MESADmaBufExport
{
MESADmaBufExport(EGLDisplay dpy);

static auto extension_if_supported(EGLDisplay dpy) -> std::optional<MESADmaBufExport>;

PFNEGLEXPORTDMABUFIMAGEMESAPROC const eglExportDMABUFImageMESA;
PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC const eglExportDMABUFImageQueryMESA;
};
};
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/platform/mir/graphics/graphic_buffer_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class GraphicBufferAllocator
* Deinitialise the BufferAllocator for this Wayland display
*
* This should do whatever is required to clean up before the Wayland loop is stopped. For
* example, calling eglUnindWaylandDisplayWL.
* example, calling eglUnbindWaylandDisplayWL.
*
* \param display [in] The Wayland display to unbind from
*/
Expand Down
68 changes: 58 additions & 10 deletions include/platform/mir/graphics/linux_dmabuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@
#include "linux-dmabuf-unstable-v1_wrapper.h"

#include <EGL/egl.h>
#include <memory>
#include <span>

#include "mir/graphics/buffer.h"
#include "mir/graphics/drm_formats.h"
#include "mir/graphics/egl_extensions.h"


namespace mir
{
namespace renderer
Expand All @@ -38,35 +40,81 @@ class Context;

namespace graphics
{
namespace gl
{
class Texture;
}

namespace common
{
class EGLContextExecutor;
}

class DmaBufFormatDescriptors;
class DMABufBuffer;
class EGLBufferCopier;

class DMABufEGLProvider : public std::enable_shared_from_this<DMABufEGLProvider>
{
public:
using EGLImageAllocator =
std::function<std::shared_ptr<DMABufBuffer>(DRMFormat, std::span<uint64_t const>, geometry::Size)>;
DMABufEGLProvider(
EGLDisplay dpy,
std::shared_ptr<EGLExtensions> egl_extensions,
EGLExtensions::EXTImageDmaBufImportModifiers const& dmabuf_ext,
std::shared_ptr<common::EGLContextExecutor> egl_delegate,
EGLImageAllocator allocate_importable_image);

~DMABufEGLProvider();

auto import_dma_buf(
DMABufBuffer const& dma_buf,
std::function<void()>&& on_consumed,
std::function<void()>&& on_release)
-> std::shared_ptr<Buffer>;

/**
* Validate that this provider *can* import this DMA-BUF
*
* @param dma_buf
* \throws EGL exception on failure
*/
void validate_import(DMABufBuffer const& dma_buf);

auto as_texture(
std::shared_ptr<Buffer> buffer)
-> std::shared_ptr<gl::Texture>;

auto supported_formats() const -> DmaBufFormatDescriptors const&;
private:
EGLDisplay const dpy;
std::shared_ptr<EGLExtensions> const egl_extensions;
std::optional<EGLExtensions::MESADmaBufExport> const dmabuf_export_ext;
std::unique_ptr<DmaBufFormatDescriptors> const formats;
std::shared_ptr<common::EGLContextExecutor> const egl_delegate;
EGLImageAllocator allocate_importable_image;
std::unique_ptr<EGLBufferCopier> const blitter;
};

class LinuxDmaBufUnstable : public mir::wayland::LinuxDmabufV1::Global
{
public:
LinuxDmaBufUnstable(
wl_display* display,
EGLDisplay dpy,
std::shared_ptr<EGLExtensions> egl_extensions,
EGLExtensions::EXTImageDmaBufImportModifiers const& dmabuf_ext);
std::shared_ptr<DMABufEGLProvider> provider);

std::shared_ptr<Buffer> buffer_from_resource(
auto buffer_from_resource(
wl_resource* buffer,
std::function<void()>&& on_consumed,
std::function<void()>&& on_release,
std::shared_ptr<common::EGLContextExecutor> egl_delegate);

std::shared_ptr<common::EGLContextExecutor> egl_delegate)
-> std::shared_ptr<Buffer>;
private:
class Instance;
void bind(wl_resource* new_resource) override;

EGLDisplay const dpy;
std::shared_ptr<EGLExtensions> const egl_extensions;
std::shared_ptr<DmaBufFormatDescriptors> const formats;
std::shared_ptr<DMABufEGLProvider> const provider;
};

}
Expand Down
Loading

0 comments on commit 1d57c1d

Please sign in to comment.