Merge "[vulkan] Add renderControl api for setting Vulkan mode"
diff --git a/system/renderControl_enc/renderControl_client_context.cpp b/system/renderControl_enc/renderControl_client_context.cpp
index 839f595..6da72fc 100644
--- a/system/renderControl_enc/renderControl_client_context.cpp
+++ b/system/renderControl_enc/renderControl_client_context.cpp
@@ -55,6 +55,7 @@
rcGetColorBufferDisplay = (rcGetColorBufferDisplay_client_proc_t) getProc("rcGetColorBufferDisplay", userData);
rcGetDisplayPose = (rcGetDisplayPose_client_proc_t) getProc("rcGetDisplayPose", userData);
rcSetDisplayPose = (rcSetDisplayPose_client_proc_t) getProc("rcSetDisplayPose", userData);
+ rcSetColorBufferVulkanMode = (rcSetColorBufferVulkanMode_client_proc_t) getProc("rcSetColorBufferVulkanMode", userData);
return 0;
}
diff --git a/system/renderControl_enc/renderControl_client_context.h b/system/renderControl_enc/renderControl_client_context.h
index bcfb7a0..d05fee1 100644
--- a/system/renderControl_enc/renderControl_client_context.h
+++ b/system/renderControl_enc/renderControl_client_context.h
@@ -55,6 +55,7 @@
rcGetColorBufferDisplay_client_proc_t rcGetColorBufferDisplay;
rcGetDisplayPose_client_proc_t rcGetDisplayPose;
rcSetDisplayPose_client_proc_t rcSetDisplayPose;
+ rcSetColorBufferVulkanMode_client_proc_t rcSetColorBufferVulkanMode;
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 71160a3..f9690b6 100644
--- a/system/renderControl_enc/renderControl_client_proc.h
+++ b/system/renderControl_enc/renderControl_client_proc.h
@@ -57,6 +57,7 @@
typedef GLint (renderControl_APIENTRY *rcGetColorBufferDisplay_client_proc_t) (void * ctx, uint32_t, uint32_t*);
typedef GLint (renderControl_APIENTRY *rcGetDisplayPose_client_proc_t) (void * ctx, uint32_t, uint32_t*, uint32_t*, uint32_t*, uint32_t*);
typedef GLint (renderControl_APIENTRY *rcSetDisplayPose_client_proc_t) (void * ctx, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
+typedef GLint (renderControl_APIENTRY *rcSetColorBufferVulkanMode_client_proc_t) (void * ctx, uint32_t, uint32_t);
#endif
diff --git a/system/renderControl_enc/renderControl_enc.cpp b/system/renderControl_enc/renderControl_enc.cpp
index bd6ad9f..a2d765f 100644
--- a/system/renderControl_enc/renderControl_enc.cpp
+++ b/system/renderControl_enc/renderControl_enc.cpp
@@ -1748,6 +1748,47 @@
return retval;
}
+GLint rcSetColorBufferVulkanMode_enc(void *self , uint32_t colorBuffer, uint32_t mode)
+{
+
+ 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;
+ const size_t checksumSize = checksumCalculator->checksumByteSize();
+ const size_t totalSize = sizeWithoutChecksum + checksumSize;
+ buf = stream->alloc(totalSize);
+ ptr = buf;
+ int tmp = OP_rcSetColorBufferVulkanMode;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &totalSize, 4); ptr += 4;
+
+ memcpy(ptr, &colorBuffer, 4); ptr += 4;
+ memcpy(ptr, &mode, 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("rcSetColorBufferVulkanMode: 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)
@@ -1800,5 +1841,6 @@
this->rcGetColorBufferDisplay = &rcGetColorBufferDisplay_enc;
this->rcGetDisplayPose = &rcGetDisplayPose_enc;
this->rcSetDisplayPose = &rcSetDisplayPose_enc;
+ this->rcSetColorBufferVulkanMode = &rcSetColorBufferVulkanMode_enc;
}
diff --git a/system/renderControl_enc/renderControl_entry.cpp b/system/renderControl_enc/renderControl_entry.cpp
index f02745a..1314c7d 100644
--- a/system/renderControl_enc/renderControl_entry.cpp
+++ b/system/renderControl_enc/renderControl_entry.cpp
@@ -50,6 +50,7 @@
GLint rcGetColorBufferDisplay(uint32_t colorBuffer, uint32_t* displayId);
GLint rcGetDisplayPose(uint32_t displayId, uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h);
GLint rcSetDisplayPose(uint32_t displayId, uint32_t x, uint32_t y, uint32_t w, uint32_t h);
+ GLint rcSetColorBufferVulkanMode(uint32_t colorBuffer, uint32_t mode);
};
#ifndef GET_CONTEXT
@@ -328,3 +329,9 @@
return ctx->rcSetDisplayPose(ctx, displayId, x, y, w, h);
}
+GLint rcSetColorBufferVulkanMode(uint32_t colorBuffer, uint32_t mode)
+{
+ GET_CONTEXT;
+ return ctx->rcSetColorBufferVulkanMode(ctx, colorBuffer, mode);
+}
+
diff --git a/system/renderControl_enc/renderControl_ftable.h b/system/renderControl_enc/renderControl_ftable.h
index 5155f10..035dfac 100644
--- a/system/renderControl_enc/renderControl_ftable.h
+++ b/system/renderControl_enc/renderControl_ftable.h
@@ -53,6 +53,7 @@
{"rcGetColorBufferDisplay", (void*)rcGetColorBufferDisplay},
{"rcGetDisplayPose", (void*)rcGetDisplayPose},
{"rcSetDisplayPose", (void*)rcSetDisplayPose},
+ {"rcSetColorBufferVulkanMode", (void*)rcSetColorBufferVulkanMode},
};
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 d98a40c..d2927d2 100644
--- a/system/renderControl_enc/renderControl_opcodes.h
+++ b/system/renderControl_enc/renderControl_opcodes.h
@@ -48,7 +48,8 @@
#define OP_rcGetColorBufferDisplay 10042
#define OP_rcGetDisplayPose 10043
#define OP_rcSetDisplayPose 10044
-#define OP_last 10045
+#define OP_rcSetColorBufferVulkanMode 10045
+#define OP_last 10046
#endif