renderControl_enc: Add two renderControl methods.
1) GLint rcSetColorBufferVulkanMode2(
uint32_t colorBuffer, uint32_t mode, uint32_t memoryProperty);
2) int rcMapGpaToColorBuffer(uint32_t colorBuffer, uint64_t gpa);
These two methods will be used on host-visible images on Vulkan AEMU/FEMU.
Change-Id: I3698505ad79897bebed8c66d2731b3218fe4d61d
diff --git a/system/renderControl_enc/renderControl_client_context.cpp b/system/renderControl_enc/renderControl_client_context.cpp
index ca38884..61dda7c 100644
--- a/system/renderControl_enc/renderControl_client_context.cpp
+++ b/system/renderControl_enc/renderControl_client_context.cpp
@@ -61,6 +61,8 @@
rcCreateColorBufferWithHandle = (rcCreateColorBufferWithHandle_client_proc_t) getProc("rcCreateColorBufferWithHandle", userData);
rcCreateBuffer = (rcCreateBuffer_client_proc_t) getProc("rcCreateBuffer", userData);
rcCloseBuffer = (rcCloseBuffer_client_proc_t) getProc("rcCloseBuffer", userData);
+ rcSetColorBufferVulkanMode2 = (rcSetColorBufferVulkanMode2_client_proc_t) getProc("rcSetColorBufferVulkanMode2", userData);
+ rcMapGpaToColorBuffer = (rcMapGpaToColorBuffer_client_proc_t) getProc("rcMapGpaToColorBuffer", userData);
return 0;
}
diff --git a/system/renderControl_enc/renderControl_client_context.h b/system/renderControl_enc/renderControl_client_context.h
index c9dc410..acf79cd 100644
--- a/system/renderControl_enc/renderControl_client_context.h
+++ b/system/renderControl_enc/renderControl_client_context.h
@@ -61,6 +61,8 @@
rcCreateColorBufferWithHandle_client_proc_t rcCreateColorBufferWithHandle;
rcCreateBuffer_client_proc_t rcCreateBuffer;
rcCloseBuffer_client_proc_t rcCloseBuffer;
+ rcSetColorBufferVulkanMode2_client_proc_t rcSetColorBufferVulkanMode2;
+ rcMapGpaToColorBuffer_client_proc_t rcMapGpaToColorBuffer;
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 4192b0e..19ae22d 100644
--- a/system/renderControl_enc/renderControl_client_proc.h
+++ b/system/renderControl_enc/renderControl_client_proc.h
@@ -63,6 +63,8 @@
typedef void (renderControl_APIENTRY *rcCreateColorBufferWithHandle_client_proc_t) (void * ctx, uint32_t, uint32_t, GLenum, uint32_t);
typedef uint32_t (renderControl_APIENTRY *rcCreateBuffer_client_proc_t) (void * ctx, uint32_t);
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 *rcMapGpaToColorBuffer_client_proc_t) (void * ctx, uint32_t, uint64_t);
#endif
diff --git a/system/renderControl_enc/renderControl_enc.cpp b/system/renderControl_enc/renderControl_enc.cpp
index b841bf1..6f1a33f 100644
--- a/system/renderControl_enc/renderControl_enc.cpp
+++ b/system/renderControl_enc/renderControl_enc.cpp
@@ -1966,6 +1966,89 @@
}
+GLint rcSetColorBufferVulkanMode2_enc(void *self , uint32_t colorBuffer, uint32_t mode, uint32_t memoryProperty)
+{
+
+ 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 + 4 + 4 + 4;
+ const size_t checksumSize = checksumCalculator->checksumByteSize();
+ const size_t totalSize = sizeWithoutChecksum + checksumSize;
+ buf = stream->alloc(totalSize);
+ ptr = buf;
+ int tmp = OP_rcSetColorBufferVulkanMode2;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &totalSize, 4); ptr += 4;
+
+ memcpy(ptr, &colorBuffer, 4); ptr += 4;
+ memcpy(ptr, &mode, 4); ptr += 4;
+ memcpy(ptr, &memoryProperty, 4); ptr += 4;
+
+ if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
+ if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
+
+
+ GLint 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("rcSetColorBufferVulkanMode2: GL communication error, please report this issue to b.android.com.\n");
+ abort();
+ }
+ }
+ return retval;
+}
+
+int rcMapGpaToColorBuffer_enc(void *self , uint32_t colorBuffer, uint64_t gpa)
+{
+
+ 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 + 4 + 8;
+ const size_t checksumSize = checksumCalculator->checksumByteSize();
+ const size_t totalSize = sizeWithoutChecksum + checksumSize;
+ buf = stream->alloc(totalSize);
+ ptr = buf;
+ int tmp = OP_rcMapGpaToColorBuffer;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &totalSize, 4); ptr += 4;
+
+ memcpy(ptr, &colorBuffer, 4); ptr += 4;
+ memcpy(ptr, &gpa, 8); ptr += 8;
+
+ if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
+ if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
+
+
+ int 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("rcMapGpaToColorBuffer: 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)
@@ -2024,5 +2107,7 @@
this->rcCreateColorBufferWithHandle = &rcCreateColorBufferWithHandle_enc;
this->rcCreateBuffer = &rcCreateBuffer_enc;
this->rcCloseBuffer = &rcCloseBuffer_enc;
+ this->rcSetColorBufferVulkanMode2 = &rcSetColorBufferVulkanMode2_enc;
+ this->rcMapGpaToColorBuffer = &rcMapGpaToColorBuffer_enc;
}
diff --git a/system/renderControl_enc/renderControl_entry.cpp b/system/renderControl_enc/renderControl_entry.cpp
index ffa0cdd..0500bf2 100644
--- a/system/renderControl_enc/renderControl_entry.cpp
+++ b/system/renderControl_enc/renderControl_entry.cpp
@@ -56,6 +56,8 @@
void rcCreateColorBufferWithHandle(uint32_t width, uint32_t height, GLenum internalFormat, uint32_t handle);
uint32_t rcCreateBuffer(uint32_t size);
void rcCloseBuffer(uint32_t buffer);
+ GLint rcSetColorBufferVulkanMode2(uint32_t colorBuffer, uint32_t mode, uint32_t memoryProperty);
+ int rcMapGpaToColorBuffer(uint32_t colorBuffer, uint64_t gpa);
};
#ifndef GET_CONTEXT
@@ -370,3 +372,15 @@
ctx->rcCloseBuffer(ctx, buffer);
}
+GLint rcSetColorBufferVulkanMode2(uint32_t colorBuffer, uint32_t mode, uint32_t memoryProperty)
+{
+ GET_CONTEXT;
+ return ctx->rcSetColorBufferVulkanMode2(ctx, colorBuffer, mode, memoryProperty);
+}
+
+int rcMapGpaToColorBuffer(uint32_t colorBuffer, uint64_t gpa)
+{
+ GET_CONTEXT;
+ return ctx->rcMapGpaToColorBuffer(ctx, colorBuffer, gpa);
+}
+
diff --git a/system/renderControl_enc/renderControl_ftable.h b/system/renderControl_enc/renderControl_ftable.h
index 13aebed..9ab9148 100644
--- a/system/renderControl_enc/renderControl_ftable.h
+++ b/system/renderControl_enc/renderControl_ftable.h
@@ -59,6 +59,8 @@
{"rcCreateColorBufferWithHandle", (void*)rcCreateColorBufferWithHandle},
{"rcCreateBuffer", (void*)rcCreateBuffer},
{"rcCloseBuffer", (void*)rcCloseBuffer},
+ {"rcSetColorBufferVulkanMode2", (void*)rcSetColorBufferVulkanMode2},
+ {"rcMapGpaToColorBuffer", (void*)rcMapGpaToColorBuffer},
};
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 f1207f2..7c66651 100644
--- a/system/renderControl_enc/renderControl_opcodes.h
+++ b/system/renderControl_enc/renderControl_opcodes.h
@@ -54,7 +54,9 @@
#define OP_rcCreateColorBufferWithHandle 10048
#define OP_rcCreateBuffer 10049
#define OP_rcCloseBuffer 10050
-#define OP_last 10051
+#define OP_rcSetColorBufferVulkanMode2 10051
+#define OP_rcMapGpaToColorBuffer 10052
+#define OP_last 10053
#endif