Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f0911e6 authored by Ian Elliott's avatar Ian Elliott
Browse files

Add SkiaVk backend to RenderEngine

This CL adds a new backend, SkiaVk, to RenderEngine.

The new functionality is to create a Vulkan device/instance (possibly
protected) and handle flush/waitFence via VkSemaphores fed to
GrBackendSemaphores.

+ make ctors of GLES/Vk RE's private so as to ensure GrContexts are
  created

Test: atest librenderengine_test
Bug: 236390072

Change-Id: I69119623b194885bcc4cf2ddc8e592576b713b19
parent be0905ed
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -36,8 +36,12 @@ SyncFeatures::SyncFeatures() : Singleton<SyncFeatures>(),
        mHasFenceSync(false),
        mHasWaitSync(false) {
    EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    // This can only be called after EGL has been initialized; otherwise the
    // check below will abort.
    // eglQueryString can only be called after EGL has been initialized;
    // otherwise the check below will abort.  If RenderEngine is using SkiaVk,
    // EGL will not have been initialized.  There's no problem with initializing
    // it again here (it is ref counted), and then terminating it later.
    EGLBoolean initialized = eglInitialize(dpy, nullptr, nullptr);
    LOG_ALWAYS_FATAL_IF(!initialized, "eglInitialize failed");
    const char* exts = eglQueryString(dpy, EGL_EXTENSIONS);
    LOG_ALWAYS_FATAL_IF(exts == nullptr, "eglQueryString failed");
    if (strstr(exts, "EGL_ANDROID_native_fence_sync")) {
@@ -63,6 +67,8 @@ SyncFeatures::SyncFeatures() : Singleton<SyncFeatures>(),
        mString.append(" EGL_KHR_wait_sync");
    }
    mString.append("]");
    // Terminate EGL to match the eglInitialize above
    eglTerminate(dpy);
}

bool SyncFeatures::useNativeFenceSync() const {
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ cc_defaults {
        "libsync",
        "libui",
        "libutils",
        "libvulkan",
    ],

    static_libs: [
@@ -97,6 +98,7 @@ filegroup {
        "skia/ColorSpaces.cpp",
        "skia/SkiaRenderEngine.cpp",
        "skia/SkiaGLRenderEngine.cpp",
        "skia/SkiaVkRenderEngine.cpp",
        "skia/debug/CaptureTimer.cpp",
        "skia/debug/CommonPool.cpp",
        "skia/debug/SkiaCapture.cpp",
+11 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
#include "threaded/RenderEngineThreaded.h"

#include "skia/SkiaGLRenderEngine.h"
#include "skia/SkiaVkRenderEngine.h"

namespace android {
namespace renderengine {
@@ -37,6 +38,9 @@ std::unique_ptr<RenderEngine> RenderEngine::create(const RenderEngineCreationArg
        case RenderEngineType::SKIA_GL:
            ALOGD("RenderEngine with SkiaGL Backend");
            return renderengine::skia::SkiaGLRenderEngine::create(args);
        case RenderEngineType::SKIA_VK:
            ALOGD("RenderEngine with SkiaVK Backend");
            return renderengine::skia::SkiaVkRenderEngine::create(args);
        case RenderEngineType::SKIA_GL_THREADED: {
            ALOGD("Threaded RenderEngine with SkiaGL Backend");
            return renderengine::threaded::RenderEngineThreaded::create(
@@ -45,6 +49,13 @@ std::unique_ptr<RenderEngine> RenderEngine::create(const RenderEngineCreationArg
                    },
                    args.renderEngineType);
        }
        case RenderEngineType::SKIA_VK_THREADED:
            ALOGD("Threaded RenderEngine with SkiaVK Backend");
            return renderengine::threaded::RenderEngineThreaded::create(
                    [args]() {
                        return android::renderengine::skia::SkiaVkRenderEngine::create(args);
                    },
                    args.renderEngineType);
        case RenderEngineType::GLES:
        default:
            ALOGD("RenderEngine with GLES Backend");
+4 −0
Original line number Diff line number Diff line
@@ -39,6 +39,10 @@ std::string RenderEngineTypeName(RenderEngine::RenderEngineType type) {
            return "skiaglthreaded";
        case RenderEngine::RenderEngineType::SKIA_GL:
            return "skiagl";
        case RenderEngine::RenderEngineType::SKIA_VK:
            return "skiavk";
        case RenderEngine::RenderEngineType::SKIA_VK_THREADED:
            return "skiavkthreaded";
        case RenderEngine::RenderEngineType::GLES:
        case RenderEngine::RenderEngineType::THREADED:
            LOG_ALWAYS_FATAL("GLESRenderEngine is deprecated - why time it?");
+12 −3
Original line number Diff line number Diff line
@@ -99,6 +99,8 @@ public:
        THREADED = 2,
        SKIA_GL = 3,
        SKIA_GL_THREADED = 4,
        SKIA_VK = 5,
        SKIA_VK_THREADED = 6,
    };

    static std::unique_ptr<RenderEngine> create(const RenderEngineCreationArgs& args);
@@ -170,9 +172,16 @@ public:
    virtual void cleanupPostRender() = 0;

    virtual void cleanFramebufferCache() = 0;
    // Returns the priority this context was actually created with. Note: this may not be
    // the same as specified at context creation time, due to implementation limits on the
    // number of contexts that can be created at a specific priority level in the system.

    // Returns the priority this context was actually created with. Note: this
    // may not be the same as specified at context creation time, due to
    // implementation limits on the number of contexts that can be created at a
    // specific priority level in the system.
    //
    // This should return a valid EGL context priority enum as described by
    // https://registry.khronos.org/EGL/extensions/IMG/EGL_IMG_context_priority.txt
    // or
    // https://registry.khronos.org/EGL/extensions/NV/EGL_NV_context_priority_realtime.txt
    virtual int getContextPriority() = 0;

    // Returns true if blur was requested in the RenderEngineCreationArgs and the implementation
Loading