aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYilong Li <liyl@google.com>2020-09-14 20:27:15 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-09-14 20:27:15 +0000
commit897450889e520caa28aaf1583389d9b45c962f75 (patch)
treef1ee87b9424834ef3df038a6a7019e3b44fdd110
parent5cb1b09ee5d1ffbe71d5de3867d2352aa8609745 (diff)
parent379f5c30b103297480fcae6863ad402711aa56f9 (diff)
downloaddevice_generic_goldfish-opengl-897450889e520caa28aaf1583389d9b45c962f75.tar.gz
device_generic_goldfish-opengl-897450889e520caa28aaf1583389d9b45c962f75.tar.bz2
device_generic_goldfish-opengl-897450889e520caa28aaf1583389d9b45c962f75.zip
Merge changes Ia3f63a83,Icc4f5ab9
* changes: fuchsia: Fix Fuchsia build renderControl_enc: Add rcCreateBuffer2 method.
-rw-r--r--system/renderControl_enc/renderControl_client_context.cpp1
-rw-r--r--system/renderControl_enc/renderControl_client_context.h1
-rw-r--r--system/renderControl_enc/renderControl_client_proc.h1
-rw-r--r--system/renderControl_enc/renderControl_enc.cpp43
-rw-r--r--system/renderControl_enc/renderControl_entry.cpp7
-rw-r--r--system/renderControl_enc/renderControl_ftable.h1
-rw-r--r--system/renderControl_enc/renderControl_opcodes.h3
-rw-r--r--system/vulkan_enc/goldfish_vk_private_defs.h7
-rw-r--r--system/vulkan_enc/vk_format_info.h5
9 files changed, 68 insertions, 1 deletions
diff --git a/system/renderControl_enc/renderControl_client_context.cpp b/system/renderControl_enc/renderControl_client_context.cpp
index 34e973d1..ded019b8 100644
--- a/system/renderControl_enc/renderControl_client_context.cpp
+++ b/system/renderControl_enc/renderControl_client_context.cpp
@@ -63,6 +63,7 @@ int renderControl_client_context_t::initDispatchByName(void *(*getProc)(const ch
rcCloseBuffer = (rcCloseBuffer_client_proc_t) getProc("rcCloseBuffer", userData);
rcSetColorBufferVulkanMode2 = (rcSetColorBufferVulkanMode2_client_proc_t) getProc("rcSetColorBufferVulkanMode2", userData);
rcMapGpaToBufferHandle = (rcMapGpaToBufferHandle_client_proc_t) getProc("rcMapGpaToBufferHandle", userData);
+ rcCreateBuffer2 = (rcCreateBuffer2_client_proc_t) getProc("rcCreateBuffer2", userData);
return 0;
}
diff --git a/system/renderControl_enc/renderControl_client_context.h b/system/renderControl_enc/renderControl_client_context.h
index 62518fcf..54749dfd 100644
--- a/system/renderControl_enc/renderControl_client_context.h
+++ b/system/renderControl_enc/renderControl_client_context.h
@@ -63,6 +63,7 @@ struct renderControl_client_context_t {
rcCloseBuffer_client_proc_t rcCloseBuffer;
rcSetColorBufferVulkanMode2_client_proc_t rcSetColorBufferVulkanMode2;
rcMapGpaToBufferHandle_client_proc_t rcMapGpaToBufferHandle;
+ rcCreateBuffer2_client_proc_t rcCreateBuffer2;
virtual ~renderControl_client_context_t() {}
typedef renderControl_client_context_t *CONTEXT_ACCESSOR_TYPE(void);
diff --git a/system/renderControl_enc/renderControl_client_proc.h b/system/renderControl_enc/renderControl_client_proc.h
index a303e36a..9f8f39c9 100644
--- a/system/renderControl_enc/renderControl_client_proc.h
+++ b/system/renderControl_enc/renderControl_client_proc.h
@@ -65,6 +65,7 @@ typedef uint32_t (renderControl_APIENTRY *rcCreateBuffer_client_proc_t) (void *
typedef void (renderControl_APIENTRY *rcCloseBuffer_client_proc_t) (void * ctx, uint32_t);
typedef GLint (renderControl_APIENTRY *rcSetColorBufferVulkanMode2_client_proc_t) (void * ctx, uint32_t, uint32_t, uint32_t);
typedef int (renderControl_APIENTRY *rcMapGpaToBufferHandle_client_proc_t) (void * ctx, uint32_t, uint64_t);
+typedef uint32_t (renderControl_APIENTRY *rcCreateBuffer2_client_proc_t) (void * ctx, uint64_t, uint32_t);
#endif
diff --git a/system/renderControl_enc/renderControl_enc.cpp b/system/renderControl_enc/renderControl_enc.cpp
index f4024054..f9994c47 100644
--- a/system/renderControl_enc/renderControl_enc.cpp
+++ b/system/renderControl_enc/renderControl_enc.cpp
@@ -2103,6 +2103,48 @@ int rcMapGpaToBufferHandle_enc(void *self , uint32_t bufferHandle, uint64_t gpa)
return retval;
}
+uint32_t rcCreateBuffer2_enc(void *self , uint64_t size, uint32_t memoryProperty)
+{
+ AEMU_SCOPED_TRACE("rcCreateBuffer2 encode");
+
+ renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
+ IOStream *stream = ctx->m_stream;
+ ChecksumCalculator *checksumCalculator = ctx->m_checksumCalculator;
+ bool useChecksum = checksumCalculator->getVersion() > 0;
+
+ unsigned char *ptr;
+ unsigned char *buf;
+ const size_t sizeWithoutChecksum = 8 + 8 + 4;
+ const size_t checksumSize = checksumCalculator->checksumByteSize();
+ const size_t totalSize = sizeWithoutChecksum + checksumSize;
+ buf = stream->alloc(totalSize);
+ ptr = buf;
+ int tmp = OP_rcCreateBuffer2;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &totalSize, 4); ptr += 4;
+
+ memcpy(ptr, &size, 8); ptr += 8;
+ memcpy(ptr, &memoryProperty, 4); ptr += 4;
+
+ if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
+ if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
+
+
+ uint32_t retval;
+ stream->readback(&retval, 4);
+ if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
+ if (useChecksum) {
+ unsigned char *checksumBufPtr = NULL;
+ unsigned char checksumBuf[ChecksumCalculator::kMaxChecksumSize];
+ if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
+ stream->readback(checksumBufPtr, checksumSize);
+ if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
+ ALOGE("rcCreateBuffer2: GL communication error, please report this issue to b.android.com.\n");
+ abort();
+ }
+ }
+ return retval;
+}
+
} // namespace
renderControl_encoder_context_t::renderControl_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator)
@@ -2163,5 +2205,6 @@ renderControl_encoder_context_t::renderControl_encoder_context_t(IOStream *strea
this->rcCloseBuffer = &rcCloseBuffer_enc;
this->rcSetColorBufferVulkanMode2 = &rcSetColorBufferVulkanMode2_enc;
this->rcMapGpaToBufferHandle = &rcMapGpaToBufferHandle_enc;
+ this->rcCreateBuffer2 = &rcCreateBuffer2_enc;
}
diff --git a/system/renderControl_enc/renderControl_entry.cpp b/system/renderControl_enc/renderControl_entry.cpp
index 2d38bc11..2f30f4c6 100644
--- a/system/renderControl_enc/renderControl_entry.cpp
+++ b/system/renderControl_enc/renderControl_entry.cpp
@@ -58,6 +58,7 @@ extern "C" {
void rcCloseBuffer(uint32_t buffer);
GLint rcSetColorBufferVulkanMode2(uint32_t colorBuffer, uint32_t mode, uint32_t memoryProperty);
int rcMapGpaToBufferHandle(uint32_t bufferHandle, uint64_t gpa);
+ uint32_t rcCreateBuffer2(uint64_t size, uint32_t memoryProperty);
};
#ifndef GET_CONTEXT
@@ -384,3 +385,9 @@ int rcMapGpaToBufferHandle(uint32_t bufferHandle, uint64_t gpa)
return ctx->rcMapGpaToBufferHandle(ctx, bufferHandle, gpa);
}
+uint32_t rcCreateBuffer2(uint64_t size, uint32_t memoryProperty)
+{
+ GET_CONTEXT;
+ return ctx->rcCreateBuffer2(ctx, size, memoryProperty);
+}
+
diff --git a/system/renderControl_enc/renderControl_ftable.h b/system/renderControl_enc/renderControl_ftable.h
index d41bd632..3cec1d36 100644
--- a/system/renderControl_enc/renderControl_ftable.h
+++ b/system/renderControl_enc/renderControl_ftable.h
@@ -61,6 +61,7 @@ static const struct _renderControl_funcs_by_name {
{"rcCloseBuffer", (void*)rcCloseBuffer},
{"rcSetColorBufferVulkanMode2", (void*)rcSetColorBufferVulkanMode2},
{"rcMapGpaToBufferHandle", (void*)rcMapGpaToBufferHandle},
+ {"rcCreateBuffer2", (void*)rcCreateBuffer2},
};
static const int renderControl_num_funcs = sizeof(renderControl_funcs_by_name) / sizeof(struct _renderControl_funcs_by_name);
diff --git a/system/renderControl_enc/renderControl_opcodes.h b/system/renderControl_enc/renderControl_opcodes.h
index df1803a3..a59306d0 100644
--- a/system/renderControl_enc/renderControl_opcodes.h
+++ b/system/renderControl_enc/renderControl_opcodes.h
@@ -56,7 +56,8 @@
#define OP_rcCloseBuffer 10050
#define OP_rcSetColorBufferVulkanMode2 10051
#define OP_rcMapGpaToBufferHandle 10052
-#define OP_last 10053
+#define OP_rcCreateBuffer2 10053
+#define OP_last 10054
#endif
diff --git a/system/vulkan_enc/goldfish_vk_private_defs.h b/system/vulkan_enc/goldfish_vk_private_defs.h
index dc4b7c64..b295eda6 100644
--- a/system/vulkan_enc/goldfish_vk_private_defs.h
+++ b/system/vulkan_enc/goldfish_vk_private_defs.h
@@ -282,6 +282,13 @@ enum AHardwareBuffer_Format {
* OpenGL ES: GL_STENCIL_INDEX8
*/
AHARDWAREBUFFER_FORMAT_S8_UINT = 0x35,
+ /**
+ * YUV 420 888 format.
+ * Must have an even width and height. Can be accessed in OpenGL
+ * shaders through an external sampler. Does not support mip-maps
+ * cube-maps or multi-layered textures.
+ */
+ AHARDWAREBUFFER_FORMAT_Y8Cb8Cr8_420 = 0x23,
};
/**
* Buffer usage flags, specifying how the buffer will be accessed.
diff --git a/system/vulkan_enc/vk_format_info.h b/system/vulkan_enc/vk_format_info.h
index 80f69d91..d80d9c34 100644
--- a/system/vulkan_enc/vk_format_info.h
+++ b/system/vulkan_enc/vk_format_info.h
@@ -29,6 +29,11 @@
#include <stdbool.h>
#ifdef VK_USE_PLATFORM_ANDROID_KHR
#include <system/graphics.h>
+#else
+/* See system/graphics.h. */
+enum {
+ HAL_PIXEL_FORMAT_YV12 = 842094169,
+};
#endif
#include <vulkan/vulkan.h>
#include <vndk/hardware_buffer.h>