Make RenderLib, Renderer APIs compatible with AEMU.
Bug: 224794781
Test: presubmit
Change-Id: I56d0eb7f424ba1e80bd1e2fad9b941abe0fecb0d
diff --git a/Android.bp b/Android.bp
index c0c7830..7c81606 100644
--- a/Android.bp
+++ b/Android.bp
@@ -75,20 +75,25 @@
cc_defaults {
name: "gfxstream_defaults",
- cflags: ["-D_FILE_OFFSET_BITS=64",
- "-DVIRGL_RENDERER_UNSTABLE_APIS",
- "-Wno-unreachable-code-loop-increment",
- "-Wno-unused-parameter",
- "-Wno-unused-function",
- "-Wno-unused-variable",
- "-Wno-ignored-qualifiers",
- "-Wno-reorder-ctor",
- "-Wno-mismatched-tags",
- "-Wno-missing-field-initializers",
- "-Wno-implicit-fallthrough",
- "-Wno-unused-private-field",
- "-Wno-macro-redefined",
- ],
+ cflags: [
+ // Android build system has some global cflags that we cannot override (e.g.
+ // -Werror=return-type), so -Wno-return-type and -Wno-return-type-c-linkage will not work.
+ // See build/soong/cc/config/global.go
+ "-DUSING_ANDROID_BP",
+ "-D_FILE_OFFSET_BITS=64",
+ "-DVIRGL_RENDERER_UNSTABLE_APIS",
+ "-Wno-unreachable-code-loop-increment",
+ "-Wno-unused-parameter",
+ "-Wno-unused-function",
+ "-Wno-unused-variable",
+ "-Wno-ignored-qualifiers",
+ "-Wno-reorder-ctor",
+ "-Wno-mismatched-tags",
+ "-Wno-missing-field-initializers",
+ "-Wno-implicit-fallthrough",
+ "-Wno-unused-private-field",
+ "-Wno-macro-redefined",
+ ],
header_libs: [
"gfxstream_headers",
"gfxstream_x11_headers",
diff --git a/host-common/include/host-common/opengl/emugl_config.h b/host-common/include/host-common/opengl/emugl_config.h
index 32e8cf0..e37a34c 100644
--- a/host-common/include/host-common/opengl/emugl_config.h
+++ b/host-common/include/host-common/opengl/emugl_config.h
@@ -95,6 +95,8 @@
SELECTED_RENDERER_ERROR = 255,
} SelectedRenderer;
+enum GrallocImplementation { MINIGBM, GOLDFISH_GRALLOC };
+
// Returns SelectedRenderer value the selected gpu mode.
// Assumes that the -gpu command line option
// has been taken into account already.
diff --git a/host-common/include/host-common/vm_operations.h b/host-common/include/host-common/vm_operations.h
index df22479..d6d3c93 100644
--- a/host-common/include/host-common/vm_operations.h
+++ b/host-common/include/host-common/vm_operations.h
@@ -194,6 +194,12 @@
void* opaque,
LineConsumerCallback errConsumer);
+ // Get the name of the last loaded snapshot (current snapshot).
+ // Will print "(null)" if the emulator cold booted and loaded no snapshots.
+ bool (*snapshotLastLoaded)(void* opaque,
+ LineConsumerCallback outConsumer,
+ LineConsumerCallback errConsumer);
+
// Sets a set of callback to listen for snapshot operations.
void (*setSnapshotCallbacks)(void* opaque,
const SnapshotCallbacks* callbacks);
@@ -235,6 +241,8 @@
struct HostmemEntry (*hostmemGetInfo)(uint64_t id);
EmuRunState (*getRunState)();
+ // virtio display
+ bool (*setDisplay)(int32_t id, int32_t w, int32_t h, uint32_t dpi);
} QAndroidVmOperations;
#ifdef _MSC_VER
diff --git a/stream-servers/RenderLib.h b/stream-servers/RenderLib.h
index b0b0fcd..9e88059 100644
--- a/stream-servers/RenderLib.h
+++ b/stream-servers/RenderLib.h
@@ -88,6 +88,8 @@
virtual void setUsageTracker(android::base::CpuUsage* cpuUsage,
android::base::MemoryTracker* memUsage) = 0;
+ virtual void setGrallocImplementation(GrallocImplementation gralloc) = 0;
+
virtual void* getGLESv2Dispatch(void) = 0;
virtual void* getEGLDispatch(void) = 0;
diff --git a/stream-servers/RenderLibImpl.cpp b/stream-servers/RenderLibImpl.cpp
index 220fed0..bb32ffc 100644
--- a/stream-servers/RenderLibImpl.cpp
+++ b/stream-servers/RenderLibImpl.cpp
@@ -100,6 +100,11 @@
emugl::setMemoryTracker(memUsage);
}
+void RenderLibImpl::setGrallocImplementation(GrallocImplementation gralloc) {
+ // TODO(joshuaduong): need a full CP of go/oag/1950399
+ (void) gralloc;
+}
+
void* RenderLibImpl::getGLESv2Dispatch(void) {
return &s_gles2;
}
diff --git a/stream-servers/RenderLibImpl.h b/stream-servers/RenderLibImpl.h
index 6304345..895faf8 100644
--- a/stream-servers/RenderLibImpl.h
+++ b/stream-servers/RenderLibImpl.h
@@ -52,6 +52,7 @@
virtual void setUsageTracker(android::base::CpuUsage* cpuUsage,
android::base::MemoryTracker* memUsage) override;
+ virtual void setGrallocImplementation(GrallocImplementation gralloc) override;
virtual void* getGLESv2Dispatch(void) override;
diff --git a/stream-servers/Renderer.h b/stream-servers/Renderer.h
index 601f046..51252fa 100644
--- a/stream-servers/Renderer.h
+++ b/stream-servers/Renderer.h
@@ -31,6 +31,15 @@
namespace emugl {
+enum class FrameBufferChange {
+ FrameReady = 0,
+};
+
+struct FrameBufferChangeEvent {
+ FrameBufferChange change;
+ uint64_t frameNumber;
+};
+
// Renderer - an object that manages a single OpenGL window used for drawing
// and is able to create individual render channels for that window.
//
@@ -109,6 +118,17 @@
bool useBgraReadback,
uint32_t displayId) = 0;
+ using FrameBufferChangeEventListener =
+ std::function<void(const FrameBufferChangeEvent evt)>;
+
+ // Adds a FramebufferChangeEventListener. The listener will be invoked
+ // whenever a new frame has been made available and is to be rendered on
+ // screen. You should do as little work as possible on this callback.
+ virtual void addListener(FrameBufferChangeEventListener* listener) = 0;
+
+ // Removes the listener.
+ virtual void removeListener(FrameBufferChangeEventListener* listener) = 0;
+
// Async readback API
virtual bool asyncReadbackSupported() = 0;
@@ -239,6 +259,9 @@
int snapshotterOp,
int snapshotterStage) = 0;
+ virtual void setVsyncHz(int vsyncHz) = 0;
+ virtual void setDisplayConfigs(int configId, int w, int h, int dpiX, int dpiY) = 0;
+ virtual void setDisplayActiveConfig(int configId) = 0;
protected:
~Renderer() = default;
};
diff --git a/stream-servers/RendererImpl.cpp b/stream-servers/RendererImpl.cpp
index 239bf97..ee23f75 100644
--- a/stream-servers/RendererImpl.cpp
+++ b/stream-servers/RendererImpl.cpp
@@ -233,6 +233,16 @@
return channel;
}
+void RendererImpl::addListener(FrameBufferChangeEventListener* listener) {
+ // TODO: need CP
+ (void)listener;
+}
+
+void RendererImpl::removeListener(FrameBufferChangeEventListener* listener) {
+ // TODO: need CP
+ (void)listener;
+}
+
void* RendererImpl::addressSpaceGraphicsConsumerCreate(
struct asg_context context,
android::base::Stream* loadStream,
@@ -649,4 +659,23 @@
}
}
+void RendererImpl::setVsyncHz(int vsyncHz) {
+ // TODO: need CP
+ (void)vsyncHz;
+}
+
+void RendererImpl::setDisplayConfigs(int configId, int w, int h,
+ int dpiX, int dpiY) {
+ // TODO: need CP
+ (void)configId;
+ (void)w;
+ (void)h;
+ (void)dpiX;
+ (void)dpiY;
+}
+
+void RendererImpl::setDisplayActiveConfig(int configId) {
+ // TODO: need CP
+ (void)configId;
+}
} // namespace emugl
diff --git a/stream-servers/RendererImpl.h b/stream-servers/RendererImpl.h
index 635f2dd..e663a6f 100644
--- a/stream-servers/RendererImpl.h
+++ b/stream-servers/RendererImpl.h
@@ -113,6 +113,13 @@
int snapshotterOp,
int snapshotterStage) final;
+ void addListener(FrameBufferChangeEventListener* listener) override;
+ void removeListener(FrameBufferChangeEventListener* listener) override;
+
+ void setVsyncHz(int vsyncHz) final;
+ void setDisplayConfigs(int configId, int w, int h, int dpiX, int dpiY) override;
+ void setDisplayActiveConfig(int configId) override;
+
private:
DISALLOW_COPY_ASSIGN_AND_MOVE(RendererImpl);
diff --git a/stream-servers/render_api.h b/stream-servers/render_api.h
index de0561f..bec1780 100644
--- a/stream-servers/render_api.h
+++ b/stream-servers/render_api.h
@@ -17,11 +17,17 @@
#include "render_api_functions.h"
+#include "base/c_header.h"
+
#include <KHR/khrplatform.h>
// All interfaces which can fail return an int, with zero indicating failure
// and anything else indicating success.
+#ifndef USING_ANDROID_BP
+ANDROID_BEGIN_HEADER
+#endif
+
// Use KHRONOS_APICALL to control visibility, but do not use KHRONOS_APIENTRY
// because we don't need the functions to be __stdcall on Win32.
#define RENDER_APICALL KHRONOS_APICALL
@@ -34,3 +40,7 @@
LIST_RENDER_API_FUNCTIONS(RENDER_API_DECLARE)
RENDER_APICALL emugl::RenderLibPtr RENDER_APIENTRY initLibrary();
+
+#ifndef USING_ANDROID_BP
+ANDROID_END_HEADER
+#endif