Add encoder entries for EGL_KHR_fence_sync
- also update encoder templates to latest version
This is part of a sequential, multi-CL change. There is also
a corresponding multi-CL change on the host side:
https://android-review.googlesource.com/#/q/topic:emu-glsync-host
The changes in the system image are as follows:
platform/build:
https://googleplex-android-review.git.corp.google.com/1024926
device/generic/goldfish:
https://googleplex-android-review.git.corp.google.com/1230942
device/generic/goldfish-opengl:
https://googleplex-android-review.git.corp.google.com/1219535
https://googleplex-android-review.git.corp.google.com/1219536 <- this CL
https://googleplex-android-review.git.corp.google.com/1219537
https://googleplex-android-review.git.corp.google.com/1219538
https://googleplex-android-review.git.corp.google.com/1219539
https://googleplex-android-review.git.corp.google.com/1219570 <- uses this
https://googleplex-android-review.git.corp.google.com/1219571
Change-Id: Ief436ccf8947d35c4b7719dc9ef6def4488cb3f0
diff --git a/system/renderControl_enc/renderControl.attrib b/system/renderControl_enc/renderControl.attrib
index 0fa0469..fbf52f7 100644
--- a/system/renderControl_enc/renderControl.attrib
+++ b/system/renderControl_enc/renderControl.attrib
@@ -43,3 +43,13 @@
rcCloseColorBuffer
flag flushOnEncode
+rcCloseColorBufferPuid
+ flag flushOnEncode
+
+rcCreateSyncKHR
+ dir attribs in
+ len attribs num_attribs
+ dir glsync_out out
+ len glsync_out sizeof(uint64_t)
+ dir syncthread_out out
+ len syncthread_out sizeof(uint64_t)
diff --git a/system/renderControl_enc/renderControl.in b/system/renderControl_enc/renderControl.in
index ebbf0fe..2076fc1 100644
--- a/system/renderControl_enc/renderControl.in
+++ b/system/renderControl_enc/renderControl.in
@@ -27,3 +27,9 @@
GL_ENTRY(uint32_t, rcCreateClientImage, uint32_t context, EGLenum target, GLuint buffer)
GL_ENTRY(int, rcDestroyClientImage, uint32_t image)
GL_ENTRY(void, rcSelectChecksumHelper, uint32_t newProtocol, uint32_t reserved)
+GL_ENTRY(uint32_t, rcCreateColorBufferPuid, uint32_t width, uint32_t height, GLenum internalFormat, uint64_t puid)
+GL_ENTRY(int, rcOpenColorBuffer2Puid, uint32_t colorbuffer, uint64_t puid)
+GL_ENTRY(void, rcCloseColorBufferPuid, uint32_t colorbuffer, uint64_t puid)
+GL_ENTRY(void, rcCreateSyncKHR, EGLenum type, EGLint* attribs, uint32_t num_attribs, uint64_t* glsync_out, uint64_t* syncthread_out)
+GL_ENTRY(EGLint, rcClientWaitSyncKHR, uint64_t sync, EGLint flags, uint64_t timeout)
+GL_ENTRY(void, rcFlushWindowColorBufferAsync, uint32_t windowSurface)
diff --git a/system/renderControl_enc/renderControl.types b/system/renderControl_enc/renderControl.types
index a7d96ab..578492b 100644
--- a/system/renderControl_enc/renderControl.types
+++ b/system/renderControl_enc/renderControl.types
@@ -1,11 +1,14 @@
-uint32_t 32 0x%08x false
-EGLint 32 0x%08x false
-GLint 32 0x%08x false
-GLuint 32 0x%08x false
-GLenum 32 0x%08x false
-EGLenum 32 0x%08x false
-uint32_t* 32 0x%08x true
-EGLint* 32 0x%08x true
-GLint* 32 0x%08x true
-GLuint* 32 0x%08x true
-void* 32 0x%08x true
+uint32_t 32 0x%08x
+uint64_t 64 0x%016lx
+EGLint 32 0x%08x
+GLint 32 0x%08x
+GLuint 32 0x%08x
+GLenum 32 0x%08x
+EGLenum 32 0x%08x
+uint32_t* 32 0x%08x
+EGLint* 32 0x%08x
+int* 32 0x%08x
+GLint* 32 0x%08x
+GLuint* 32 0x%08x
+void* 32 0x%08x
+uint64_t* 32 0x%08x
diff --git a/system/renderControl_enc/renderControl_client_context.cpp b/system/renderControl_enc/renderControl_client_context.cpp
index fad61d9..6dabb3c 100644
--- a/system/renderControl_enc/renderControl_client_context.cpp
+++ b/system/renderControl_enc/renderControl_client_context.cpp
@@ -42,6 +42,9 @@
rcCreateColorBufferPuid = (rcCreateColorBufferPuid_client_proc_t) getProc("rcCreateColorBufferPuid", userData);
rcOpenColorBuffer2Puid = (rcOpenColorBuffer2Puid_client_proc_t) getProc("rcOpenColorBuffer2Puid", userData);
rcCloseColorBufferPuid = (rcCloseColorBufferPuid_client_proc_t) getProc("rcCloseColorBufferPuid", userData);
+ rcCreateSyncKHR = (rcCreateSyncKHR_client_proc_t) getProc("rcCreateSyncKHR", userData);
+ rcClientWaitSyncKHR = (rcClientWaitSyncKHR_client_proc_t) getProc("rcClientWaitSyncKHR", userData);
+ rcFlushWindowColorBufferAsync = (rcFlushWindowColorBufferAsync_client_proc_t) getProc("rcFlushWindowColorBufferAsync", userData);
return 0;
}
diff --git a/system/renderControl_enc/renderControl_client_context.h b/system/renderControl_enc/renderControl_client_context.h
index b251f30..5901a35 100644
--- a/system/renderControl_enc/renderControl_client_context.h
+++ b/system/renderControl_enc/renderControl_client_context.h
@@ -42,6 +42,9 @@
rcCreateColorBufferPuid_client_proc_t rcCreateColorBufferPuid;
rcOpenColorBuffer2Puid_client_proc_t rcOpenColorBuffer2Puid;
rcCloseColorBufferPuid_client_proc_t rcCloseColorBufferPuid;
+ rcCreateSyncKHR_client_proc_t rcCreateSyncKHR;
+ rcClientWaitSyncKHR_client_proc_t rcClientWaitSyncKHR;
+ rcFlushWindowColorBufferAsync_client_proc_t rcFlushWindowColorBufferAsync;
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 bc04b83..db5d4d6 100644
--- a/system/renderControl_enc/renderControl_client_proc.h
+++ b/system/renderControl_enc/renderControl_client_proc.h
@@ -41,6 +41,9 @@
typedef uint32_t (renderControl_APIENTRY *rcCreateColorBufferPuid_client_proc_t) (void * ctx, uint32_t, uint32_t, GLenum, uint64_t);
typedef int (renderControl_APIENTRY *rcOpenColorBuffer2Puid_client_proc_t) (void * ctx, uint32_t, uint64_t);
typedef void (renderControl_APIENTRY *rcCloseColorBufferPuid_client_proc_t) (void * ctx, uint32_t, uint64_t);
+typedef void (renderControl_APIENTRY *rcCreateSyncKHR_client_proc_t) (void * ctx, EGLenum, EGLint*, uint32_t, uint64_t*, uint64_t*);
+typedef EGLint (renderControl_APIENTRY *rcClientWaitSyncKHR_client_proc_t) (void * ctx, uint64_t, EGLint, uint64_t);
+typedef void (renderControl_APIENTRY *rcFlushWindowColorBufferAsync_client_proc_t) (void * ctx, uint32_t);
#endif
diff --git a/system/renderControl_enc/renderControl_enc.cpp b/system/renderControl_enc/renderControl_enc.cpp
index 5a2db61..3d65d7c 100644
--- a/system/renderControl_enc/renderControl_enc.cpp
+++ b/system/renderControl_enc/renderControl_enc.cpp
@@ -1205,6 +1205,120 @@
stream->flush();
}
+void rcCreateSyncKHR_enc(void *self , EGLenum type, EGLint* attribs, uint32_t num_attribs, uint64_t* glsync_out, uint64_t* syncthread_out)
+{
+
+ 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;
+
+ const unsigned int __size_attribs = num_attribs;
+ const unsigned int __size_glsync_out = sizeof(uint64_t);
+ const unsigned int __size_syncthread_out = sizeof(uint64_t);
+ unsigned char *ptr;
+ unsigned char *buf;
+ const size_t sizeWithoutChecksum = 8 + 4 + __size_attribs + 4 + __size_glsync_out + __size_syncthread_out + 3*4;
+ const size_t checksumSize = checksumCalculator->checksumByteSize();
+ const size_t totalSize = sizeWithoutChecksum + checksumSize;
+ buf = stream->alloc(totalSize);
+ ptr = buf;
+ int tmp = OP_rcCreateSyncKHR;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &totalSize, 4); ptr += 4;
+
+ memcpy(ptr, &type, 4); ptr += 4;
+ *(unsigned int *)(ptr) = __size_attribs; ptr += 4;
+ memcpy(ptr, attribs, __size_attribs);ptr += __size_attribs;
+ memcpy(ptr, &num_attribs, 4); ptr += 4;
+ *(unsigned int *)(ptr) = __size_glsync_out; ptr += 4;
+ *(unsigned int *)(ptr) = __size_syncthread_out; ptr += 4;
+
+ if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
+ if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
+
+ stream->readback(glsync_out, __size_glsync_out);
+ if (useChecksum) checksumCalculator->addBuffer(glsync_out, __size_glsync_out);
+ stream->readback(syncthread_out, __size_syncthread_out);
+ if (useChecksum) checksumCalculator->addBuffer(syncthread_out, __size_syncthread_out);
+ if (useChecksum) {
+ unsigned char *checksumBufPtr = NULL;
+ std::vector<unsigned char> checksumBuf(checksumSize);
+ if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
+ stream->readback(checksumBufPtr, checksumSize);
+ if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
+ ALOGE("rcCreateSyncKHR: GL communication error, please report this issue to b.android.com.\n");
+ abort();
+ }
+ }
+}
+
+EGLint rcClientWaitSyncKHR_enc(void *self , uint64_t sync, EGLint flags, uint64_t timeout)
+{
+
+ 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 + 8;
+ const size_t checksumSize = checksumCalculator->checksumByteSize();
+ const size_t totalSize = sizeWithoutChecksum + checksumSize;
+ buf = stream->alloc(totalSize);
+ ptr = buf;
+ int tmp = OP_rcClientWaitSyncKHR;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &totalSize, 4); ptr += 4;
+
+ memcpy(ptr, &sync, 8); ptr += 8;
+ memcpy(ptr, &flags, 4); ptr += 4;
+ memcpy(ptr, &timeout, 8); ptr += 8;
+
+ if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
+ if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
+
+
+ EGLint retval;
+ stream->readback(&retval, 4);
+ if (useChecksum) checksumCalculator->addBuffer(&retval, 4);
+ if (useChecksum) {
+ unsigned char *checksumBufPtr = NULL;
+ std::vector<unsigned char> checksumBuf(checksumSize);
+ if (checksumSize > 0) checksumBufPtr = &checksumBuf[0];
+ stream->readback(checksumBufPtr, checksumSize);
+ if (!checksumCalculator->validate(checksumBufPtr, checksumSize)) {
+ ALOGE("rcClientWaitSyncKHR: GL communication error, please report this issue to b.android.com.\n");
+ abort();
+ }
+ }
+ return retval;
+}
+
+void rcFlushWindowColorBufferAsync_enc(void *self , uint32_t windowSurface)
+{
+
+ 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;
+ const size_t checksumSize = checksumCalculator->checksumByteSize();
+ const size_t totalSize = sizeWithoutChecksum + checksumSize;
+ buf = stream->alloc(totalSize);
+ ptr = buf;
+ int tmp = OP_rcFlushWindowColorBufferAsync;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &totalSize, 4); ptr += 4;
+
+ memcpy(ptr, &windowSurface, 4); ptr += 4;
+
+ if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
+ if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
+
+}
+
} // namespace
renderControl_encoder_context_t::renderControl_encoder_context_t(IOStream *stream, ChecksumCalculator *checksumCalculator)
@@ -1244,5 +1358,8 @@
this->rcCreateColorBufferPuid = &rcCreateColorBufferPuid_enc;
this->rcOpenColorBuffer2Puid = &rcOpenColorBuffer2Puid_enc;
this->rcCloseColorBufferPuid = &rcCloseColorBufferPuid_enc;
+ this->rcCreateSyncKHR = &rcCreateSyncKHR_enc;
+ this->rcClientWaitSyncKHR = &rcClientWaitSyncKHR_enc;
+ this->rcFlushWindowColorBufferAsync = &rcFlushWindowColorBufferAsync_enc;
}
diff --git a/system/renderControl_enc/renderControl_entry.cpp b/system/renderControl_enc/renderControl_entry.cpp
index df8c53d..e4ee7de 100644
--- a/system/renderControl_enc/renderControl_entry.cpp
+++ b/system/renderControl_enc/renderControl_entry.cpp
@@ -38,6 +38,9 @@
uint32_t rcCreateColorBufferPuid(uint32_t width, uint32_t height, GLenum internalFormat, uint64_t puid);
int rcOpenColorBuffer2Puid(uint32_t colorbuffer, uint64_t puid);
void rcCloseColorBufferPuid(uint32_t colorbuffer, uint64_t puid);
+ void rcCreateSyncKHR(EGLenum type, EGLint* attribs, uint32_t num_attribs, uint64_t* glsync_out, uint64_t* syncthread_out);
+ EGLint rcClientWaitSyncKHR(uint64_t sync, EGLint flags, uint64_t timeout);
+ void rcFlushWindowColorBufferAsync(uint32_t windowSurface);
};
#endif
@@ -239,3 +242,21 @@
ctx->rcCloseColorBufferPuid(ctx, colorbuffer, puid);
}
+void rcCreateSyncKHR(EGLenum type, EGLint* attribs, uint32_t num_attribs, uint64_t* glsync_out, uint64_t* syncthread_out)
+{
+ GET_CONTEXT;
+ ctx->rcCreateSyncKHR(ctx, type, attribs, num_attribs, glsync_out, syncthread_out);
+}
+
+EGLint rcClientWaitSyncKHR(uint64_t sync, EGLint flags, uint64_t timeout)
+{
+ GET_CONTEXT;
+ return ctx->rcClientWaitSyncKHR(ctx, sync, flags, timeout);
+}
+
+void rcFlushWindowColorBufferAsync(uint32_t windowSurface)
+{
+ GET_CONTEXT;
+ ctx->rcFlushWindowColorBufferAsync(ctx, windowSurface);
+}
+
diff --git a/system/renderControl_enc/renderControl_ftable.h b/system/renderControl_enc/renderControl_ftable.h
index 3871913..9838128 100644
--- a/system/renderControl_enc/renderControl_ftable.h
+++ b/system/renderControl_enc/renderControl_ftable.h
@@ -40,6 +40,9 @@
{"rcCreateColorBufferPuid", (void*)rcCreateColorBufferPuid},
{"rcOpenColorBuffer2Puid", (void*)rcOpenColorBuffer2Puid},
{"rcCloseColorBufferPuid", (void*)rcCloseColorBufferPuid},
+ {"rcCreateSyncKHR", (void*)rcCreateSyncKHR},
+ {"rcClientWaitSyncKHR", (void*)rcClientWaitSyncKHR},
+ {"rcFlushWindowColorBufferAsync", (void*)rcFlushWindowColorBufferAsync},
};
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 042b5d2..23cf4de 100644
--- a/system/renderControl_enc/renderControl_opcodes.h
+++ b/system/renderControl_enc/renderControl_opcodes.h
@@ -35,7 +35,10 @@
#define OP_rcCreateColorBufferPuid 10029
#define OP_rcOpenColorBuffer2Puid 10030
#define OP_rcCloseColorBufferPuid 10031
-#define OP_last 10032
+#define OP_rcCreateSyncKHR 10032
+#define OP_rcClientWaitSyncKHR 10033
+#define OP_rcFlushWindowColorBufferAsync 10034
+#define OP_last 10035
#endif