summaryrefslogtreecommitdiff
path: root/stream-servers
diff options
context:
space:
mode:
authorLingfeng Yang <lfy@google.com>2020-10-28 17:04:22 -0700
committerLingfeng Yang <lfy@google.com>2020-10-28 17:04:22 -0700
commit87321ae2198996892b6de4dd2e816f821d5e7b48 (patch)
tree7da1b1aea569e606c57062c12001ac7db034f33e /stream-servers
parentddd92cdab55edc74c575705544e4387cfa03a971 (diff)
downloadvulkan-cereal-87321ae2198996892b6de4dd2e816f821d5e7b48.tar.gz
Build decoder libs, snapshot lib, and dispatch
Bug: 171711491 Change-Id: I9b741778bd447a0b08e7549e58df16ed0af64922
Diffstat (limited to 'stream-servers')
-rw-r--r--stream-servers/CMakeLists.txt4
-rw-r--r--stream-servers/OpenGLESDispatch/EGLDispatch.cpp2
-rw-r--r--stream-servers/OpenGLESDispatch/GLESv1Dispatch.cpp30
-rw-r--r--stream-servers/OpenGLESDispatch/GLESv2Dispatch.cpp28
-rw-r--r--stream-servers/OpenGLESDispatch/OpenGLDispatchLoader.cpp26
-rw-r--r--stream-servers/OpenGLESDispatch/OpenGLDispatchLoader.h62
-rw-r--r--stream-servers/gles1_dec/CMakeLists.txt6
-rw-r--r--stream-servers/gles1_dec/GLESv1Decoder.h4
-rw-r--r--stream-servers/gles2_dec/CMakeLists.txt6
-rw-r--r--stream-servers/gles2_dec/GLESv2Decoder.cpp982
-rw-r--r--stream-servers/gles2_dec/GLESv2Decoder.h249
-rw-r--r--stream-servers/libGLSnapshot/CMakeLists.txt7
-rw-r--r--stream-servers/libGLSnapshot/GLSnapshot.cpp130
-rw-r--r--stream-servers/libGLSnapshot/GLSnapshot.h73
14 files changed, 1533 insertions, 76 deletions
diff --git a/stream-servers/CMakeLists.txt b/stream-servers/CMakeLists.txt
index 83e0a2cb..ef971a1c 100644
--- a/stream-servers/CMakeLists.txt
+++ b/stream-servers/CMakeLists.txt
@@ -3,8 +3,12 @@ add_subdirectory(vulkan)
# GLES
add_subdirectory(glestranslator)
+add_subdirectory(libGLSnapshot)
add_subdirectory(gles1_dec)
add_subdirectory(gles2_dec)
+# GLES dispatch based on Translator
+add_subdirectory(OpenGLESDispatch)
+
# RenderControl
add_subdirectory(renderControl_dec)
diff --git a/stream-servers/OpenGLESDispatch/EGLDispatch.cpp b/stream-servers/OpenGLESDispatch/EGLDispatch.cpp
index cd7e9965..46a1fab9 100644
--- a/stream-servers/OpenGLESDispatch/EGLDispatch.cpp
+++ b/stream-servers/OpenGLESDispatch/EGLDispatch.cpp
@@ -15,8 +15,6 @@
*/
#include "OpenGLESDispatch/EGLDispatch.h"
-#include "emugl/common/shared_library.h"
-
#include <stdio.h>
#include <stdlib.h>
diff --git a/stream-servers/OpenGLESDispatch/GLESv1Dispatch.cpp b/stream-servers/OpenGLESDispatch/GLESv1Dispatch.cpp
index 3c898cd9..b0ead129 100644
--- a/stream-servers/OpenGLESDispatch/GLESv1Dispatch.cpp
+++ b/stream-servers/OpenGLESDispatch/GLESv1Dispatch.cpp
@@ -18,14 +18,10 @@
#include "OpenGLESDispatch/EGLDispatch.h"
#include "OpenGLESDispatch/StaticDispatch.h"
-#include "android/utils/debug.h"
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "emugl/common/shared_library.h"
-
#define DEBUG 0
#if DEBUG
@@ -37,8 +33,6 @@
#define DPRINT(...)
#endif
-static emugl::SharedLibrary *s_gles1_lib = NULL;
-
// An unimplemented function which prints out an error message.
// To make it consistent with the guest, all GLES1 functions not supported by
// the guest driver should be redirected to this function.
@@ -122,27 +116,3 @@ bool gles1_dispatch_init(GLESv1Dispatch* dispatch_table) {
dispatch_table->initialized = true;
return true;
}
-
-//
-// This function is called only during initialization of the decoder before
-// any thread has been created - hence it should NOT be thread safe.
-//
-void *gles1_dispatch_get_proc_func(const char *name, void *userData)
-{
- void* func = NULL;
- if (s_gles1_lib) {
- func = (void *)s_gles1_lib->findSymbol(name);
- }
-
- // Check the static functions
- if (!func) {
- func = gles1_dispatch_get_proc_func_static(name);
- }
-
- // To make it consistent with the guest, redirect any unsupported functions
- // to gles1_unimplemented.
- if (!func) {
- func = (void *)gles1_unimplemented;
- }
- return func;
-}
diff --git a/stream-servers/OpenGLESDispatch/GLESv2Dispatch.cpp b/stream-servers/OpenGLESDispatch/GLESv2Dispatch.cpp
index 49a92d7f..fc525468 100644
--- a/stream-servers/OpenGLESDispatch/GLESv2Dispatch.cpp
+++ b/stream-servers/OpenGLESDispatch/GLESv2Dispatch.cpp
@@ -22,10 +22,6 @@
#include <stdlib.h>
#include <string.h>
-#include "emugl/common/shared_library.h"
-
-static emugl::SharedLibrary *s_gles2_lib = NULL;
-
#define DEFAULT_GLES_V2_LIB EMUGL_LIBNAME("GLES_V2_translator")
// An unimplemented function which prints out an error message.
@@ -51,27 +47,3 @@ bool gles2_dispatch_init(GLESv2Dispatch* dispatch_table) {
dispatch_table->initialized = true;
return true;
}
-
-//
-// This function is called only during initialization before
-// any thread has been created - hence it should NOT be thread safe.
-//
-void *gles2_dispatch_get_proc_func(const char *name, void *userData)
-{
- void* func = NULL;
- if (s_gles2_lib) {
- func = (void *)s_gles2_lib->findSymbol(name);
- }
-
- // Check the static tables.
- if (!func) {
- func = gles2_dispatch_get_proc_func_static(name);
- }
-
- // To make it consistent with the guest, redirect any unsupported functions
- // to gles2_unimplemented.
- if (!func) {
- func = (void *)gles2_unimplemented;
- }
- return func;
-}
diff --git a/stream-servers/OpenGLESDispatch/OpenGLDispatchLoader.cpp b/stream-servers/OpenGLESDispatch/OpenGLDispatchLoader.cpp
index 1f60b8eb..208858a5 100644
--- a/stream-servers/OpenGLESDispatch/OpenGLDispatchLoader.cpp
+++ b/stream-servers/OpenGLESDispatch/OpenGLDispatchLoader.cpp
@@ -12,29 +12,35 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "emugl/common/OpenGLDispatchLoader.h"
-
-#include "android/base/memory/LazyInstance.h"
+#include "OpenGLDispatchLoader.h"
#include "OpenGLESDispatch/DispatchTables.h"
GLESv1Dispatch s_gles1;
GLESv2Dispatch s_gles2;
-using android::base::LazyInstance;
using emugl::LazyLoadedGLESv1Dispatch;
using emugl::LazyLoadedGLESv2Dispatch;
using emugl::LazyLoadedEGLDispatch;
// Must be declared outside of LazyLoaded*Dispatch scope due to the use of
// sizeof(T) within the template definition.
-LazyInstance<LazyLoadedGLESv1Dispatch> sGLESv1Dispatch = LAZY_INSTANCE_INIT;
-LazyInstance<LazyLoadedGLESv2Dispatch> sGLESv2Dispatch = LAZY_INSTANCE_INIT;
-LazyInstance<LazyLoadedEGLDispatch> sEGLDispatch = LAZY_INSTANCE_INIT;
+static LazyLoadedGLESv1Dispatch* sGLESv1Dispatch() {
+ static LazyLoadedGLESv1Dispatch* l = new LazyLoadedGLESv1Dispatch;
+ return l;
+}
+static LazyLoadedGLESv2Dispatch* sGLESv2Dispatch() {
+ static LazyLoadedGLESv2Dispatch* l = new LazyLoadedGLESv2Dispatch;
+ return l;
+}
+static LazyLoadedEGLDispatch* sEGLDispatch() {
+ static LazyLoadedEGLDispatch* l = new LazyLoadedEGLDispatch;
+ return l;
+}
// static
const GLESv1Dispatch* LazyLoadedGLESv1Dispatch::get() {
- LazyLoadedGLESv1Dispatch* instance = sGLESv1Dispatch.ptr();
+ LazyLoadedGLESv1Dispatch* instance = sGLESv1Dispatch();
if (instance->mValid) {
return &s_gles1;
} else {
@@ -49,7 +55,7 @@ LazyLoadedGLESv1Dispatch::LazyLoadedGLESv1Dispatch() {
// static
const GLESv2Dispatch* LazyLoadedGLESv2Dispatch::get() {
- LazyLoadedGLESv2Dispatch* instance = sGLESv2Dispatch.ptr();
+ LazyLoadedGLESv2Dispatch* instance = sGLESv2Dispatch();
if (instance->mValid) {
return &s_gles2;
} else {
@@ -64,7 +70,7 @@ LazyLoadedGLESv2Dispatch::LazyLoadedGLESv2Dispatch() {
// static
const EGLDispatch* LazyLoadedEGLDispatch::get() {
- LazyLoadedEGLDispatch* instance = sEGLDispatch.ptr();
+ LazyLoadedEGLDispatch* instance = sEGLDispatch();
if (instance->mValid) {
return &s_egl;
} else {
diff --git a/stream-servers/OpenGLESDispatch/OpenGLDispatchLoader.h b/stream-servers/OpenGLESDispatch/OpenGLDispatchLoader.h
new file mode 100644
index 00000000..2668f65e
--- /dev/null
+++ b/stream-servers/OpenGLESDispatch/OpenGLDispatchLoader.h
@@ -0,0 +1,62 @@
+// Copyright (C) 2017 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#pragma once
+
+#include "OpenGLESDispatch/EGLDispatch.h"
+#include "OpenGLESDispatch/GLESv1Dispatch.h"
+#include "OpenGLESDispatch/GLESv2Dispatch.h"
+
+namespace emugl {
+
+// Helper classes to hold global EGLDispatch, GLESv1Dispatch and GLESv2Dispatch
+// objects, initialized lazily in a thread-safe way. The instances are leaked on
+// program exit.
+
+struct LazyLoadedGLESv1Dispatch {
+ // Return pointer to global GLESv1Dispatch instance, or nullptr if there
+ // was an error when trying to initialize/load the library.
+ static const GLESv1Dispatch* get();
+
+ LazyLoadedGLESv1Dispatch();
+
+private:
+ bool mValid;
+};
+
+struct LazyLoadedGLESv2Dispatch {
+ // Return pointer to global GLESv2Dispatch instance, or nullptr if there
+ // was an error when trying to initialize/load the library.
+ static const GLESv2Dispatch* get();
+
+ LazyLoadedGLESv2Dispatch();
+
+private:
+ bool mValid;
+};
+
+// Note that the dispatch table is provided by libOpenGLESDispatch as the
+// 's_egl' global variable.
+struct LazyLoadedEGLDispatch {
+ // Return pointer to EGLDispatch table, or nullptr if there was
+ // an error when trying to initialize/load the library.
+ static const EGLDispatch* get();
+
+ LazyLoadedEGLDispatch();
+
+private:
+ bool mValid;
+};
+
+} // namespace emugl \ No newline at end of file
diff --git a/stream-servers/gles1_dec/CMakeLists.txt b/stream-servers/gles1_dec/CMakeLists.txt
index 82b1d595..b4f54648 100644
--- a/stream-servers/gles1_dec/CMakeLists.txt
+++ b/stream-servers/gles1_dec/CMakeLists.txt
@@ -1,11 +1,13 @@
add_library(
gles1_dec
gles1_dec.cpp
- gles1_server_context.cpp)
+ gles1_server_context.cpp
+ GLESv1Decoder.cpp)
target_link_libraries(
gles1_dec
PUBLIC
- apigen-codec-common)
+ apigen-codec-common
+ GLSnapshot)
target_include_directories(
gles1_dec
PRIVATE
diff --git a/stream-servers/gles1_dec/GLESv1Decoder.h b/stream-servers/gles1_dec/GLESv1Decoder.h
index ed809c5d..0d37a325 100644
--- a/stream-servers/gles1_dec/GLESv1Decoder.h
+++ b/stream-servers/gles1_dec/GLESv1Decoder.h
@@ -19,7 +19,7 @@
#include "gles1_dec.h"
#include "GLDecoderContextData.h"
-#include "emugl/common/shared_library.h"
+#include "base/SharedLibrary.h"
typedef void (gles1_APIENTRY *glColorPointerWithDataSize_server_proc_t) (GLint, GLenum, GLsizei, const GLvoid*, GLsizei);
typedef void (gles1_APIENTRY *glNormalPointerWithDataSize_server_proc_t) (GLenum, GLsizei, const GLvoid*, GLsizei);
@@ -89,7 +89,7 @@ private:
static void * s_getProc(const char *name, void *userData);
GLDecoderContextData *m_contextData;
- emugl::SharedLibrary* m_glesDso;
+ android::base::SharedLibrary* m_glesDso;
};
#endif
diff --git a/stream-servers/gles2_dec/CMakeLists.txt b/stream-servers/gles2_dec/CMakeLists.txt
index d6e01cc2..b55032ca 100644
--- a/stream-servers/gles2_dec/CMakeLists.txt
+++ b/stream-servers/gles2_dec/CMakeLists.txt
@@ -1,11 +1,13 @@
add_library(
gles2_dec
gles2_dec.cpp
- gles2_server_context.cpp)
+ gles2_server_context.cpp
+ GLESv2Decoder.cpp)
target_link_libraries(
gles2_dec
PUBLIC
- apigen-codec-common)
+ apigen-codec-common
+ GLSnapshot)
target_include_directories(
gles2_dec
PRIVATE
diff --git a/stream-servers/gles2_dec/GLESv2Decoder.cpp b/stream-servers/gles2_dec/GLESv2Decoder.cpp
new file mode 100644
index 00000000..da160c02
--- /dev/null
+++ b/stream-servers/gles2_dec/GLESv2Decoder.cpp
@@ -0,0 +1,982 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include "GLESv2Decoder.h"
+#include "GLESv2Dispatch.h"
+
+#include "base/Lock.h"
+
+#include "host-common/vm_operations.h"
+
+#include <EGL/egl.h>
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <GLES3/gl3.h>
+#include <GLES3/gl31.h>
+
+#include <string>
+#include <vector>
+
+#include <string.h>
+
+using android::base::AutoLock;
+using android::base::StaticLock;
+
+static inline void* SafePointerFromUInt(GLuint value) {
+ return (void*)(uintptr_t)value;
+}
+
+int gles2_decoder_extended_context::initDispatch(
+ GLESv2Decoder::get_proc_func_t getProc, void *userData) {
+ gles2_server_context_t::initDispatchByName(getProc, userData);
+ glVertexAttribPointerWithDataSize =
+ (glVertexAttribPointerWithDataSize_server_proc_t)
+ getProc("glVertexAttribPointerWithDataSize", userData);
+ glVertexAttribIPointerWithDataSize =
+ (glVertexAttribIPointerWithDataSize_server_proc_t)
+ getProc("glVertexAttribIPointerWithDataSize", userData);
+ return 0;
+}
+
+static StaticLock sLock;
+static GLESv2Decoder::get_proc_func_t sGetProcFunc;
+static void* sGetProcFuncData;
+
+namespace {
+
+struct ContextTemplateLoader {
+ ContextTemplateLoader() {
+ context.initDispatch(sGetProcFunc, sGetProcFuncData);
+ }
+ gles2_decoder_extended_context context;
+};
+
+} // namespace
+
+static ContextTemplateLoader* sContextTemplate() {
+ static ContextTemplateLoader* c = new ContextTemplateLoader;
+ return c;
+}
+
+GLESv2Decoder::GLESv2Decoder()
+{
+ m_contextData = NULL;
+ m_GL2library = NULL;
+ m_snapshot = NULL;
+}
+
+GLESv2Decoder::~GLESv2Decoder()
+{
+}
+
+void *GLESv2Decoder::s_getProc(const char *name, void *userData)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *) userData;
+
+ if (ctx == NULL || ctx->m_GL2library == NULL) {
+ return NULL;
+ }
+
+ void *func = NULL;
+#ifdef USE_EGL_GETPROCADDRESS
+ func = (void *) eglGetProcAddress(name);
+#endif
+ if (func == NULL) {
+ func = (void *) ctx->m_GL2library->findSymbol(name);
+ }
+ return func;
+}
+
+#define OVERRIDE_DEC(func) func##_dec = s_##func;
+
+int GLESv2Decoder::initGL(get_proc_func_t getProcFunc, void *getProcFuncData)
+{
+ AutoLock lock(sLock);
+ sGetProcFunc = getProcFunc;
+ sGetProcFuncData = getProcFuncData;
+ static_cast<gles2_decoder_extended_context&>(*this) = sContextTemplate()->context;
+
+ glGetCompressedTextureFormats = s_glGetCompressedTextureFormats;
+ glVertexAttribPointerData = s_glVertexAttribPointerData;
+ glVertexAttribPointerOffset = s_glVertexAttribPointerOffset;
+ glShaderString = s_glShaderString;
+
+ glDrawElementsOffset = s_glDrawElementsOffset;
+ glDrawElementsData = s_glDrawElementsData;
+ glDrawElementsOffsetNullAEMU = s_glDrawElementsOffsetNullAEMU;
+ glDrawElementsDataNullAEMU = s_glDrawElementsDataNullAEMU;
+ glFinishRoundTrip = s_glFinishRoundTrip;
+ glMapBufferRangeAEMU = s_glMapBufferRangeAEMU;
+ glUnmapBufferAEMU = s_glUnmapBufferAEMU;
+ glMapBufferRangeDMA = s_glMapBufferRangeDMA;
+ glUnmapBufferDMA = s_glUnmapBufferDMA;
+ glFlushMappedBufferRangeAEMU = s_glFlushMappedBufferRangeAEMU;
+ glMapBufferRangeDirect = s_glMapBufferRangeDirect;
+ glUnmapBufferDirect = s_glUnmapBufferDirect;
+ glFlushMappedBufferRangeDirect = s_glFlushMappedBufferRangeDirect;
+ glCompressedTexImage2DOffsetAEMU = s_glCompressedTexImage2DOffsetAEMU;
+ glCompressedTexSubImage2DOffsetAEMU = s_glCompressedTexSubImage2DOffsetAEMU;
+ glTexImage2DOffsetAEMU = s_glTexImage2DOffsetAEMU;
+ glTexSubImage2DOffsetAEMU = s_glTexSubImage2DOffsetAEMU;
+ glGetUniformIndicesAEMU = s_glGetUniformIndicesAEMU;
+ glVertexAttribIPointerDataAEMU = s_glVertexAttribIPointerDataAEMU;
+ glVertexAttribIPointerOffsetAEMU = s_glVertexAttribIPointerOffsetAEMU;
+ glTransformFeedbackVaryingsAEMU = s_glTransformFeedbackVaryingsAEMU;
+ glTexImage3DOffsetAEMU = s_glTexImage3DOffsetAEMU;
+ glTexSubImage3DOffsetAEMU = s_glTexSubImage3DOffsetAEMU;
+ glCompressedTexImage3DOffsetAEMU = s_glCompressedTexImage3DOffsetAEMU;
+ glCompressedTexSubImage3DOffsetAEMU = s_glCompressedTexSubImage3DOffsetAEMU;
+ glDrawElementsInstancedOffsetAEMU = s_glDrawElementsInstancedOffsetAEMU;
+ glDrawElementsInstancedDataAEMU = s_glDrawElementsInstancedDataAEMU;
+ glReadPixelsOffsetAEMU = s_glReadPixelsOffsetAEMU;
+
+ glCreateShaderProgramvAEMU = s_glCreateShaderProgramvAEMU;
+
+ glDrawArraysIndirectDataAEMU = s_glDrawArraysIndirectDataAEMU;
+ glDrawArraysIndirectOffsetAEMU = s_glDrawArraysIndirectOffsetAEMU;
+
+ glDrawElementsIndirectDataAEMU = s_glDrawElementsIndirectDataAEMU;
+ glDrawElementsIndirectOffsetAEMU = s_glDrawElementsIndirectOffsetAEMU;
+
+ glFenceSyncAEMU = s_glFenceSyncAEMU;
+ glClientWaitSyncAEMU = s_glClientWaitSyncAEMU;
+ glWaitSyncAEMU = s_glWaitSyncAEMU;
+ glIsSyncAEMU = s_glIsSyncAEMU;
+ glGetSyncivAEMU = s_glGetSyncivAEMU;
+ glDeleteSyncAEMU = s_glDeleteSyncAEMU;
+
+ OVERRIDE_DEC(glCreateShader)
+ OVERRIDE_DEC(glCreateProgram)
+
+ OVERRIDE_DEC(glGenBuffers)
+
+ OVERRIDE_DEC(glGenFramebuffers)
+ OVERRIDE_DEC(glGenRenderbuffers)
+ OVERRIDE_DEC(glGenTextures)
+
+ OVERRIDE_DEC(glGenVertexArraysOES)
+ OVERRIDE_DEC(glGenVertexArrays)
+
+ OVERRIDE_DEC(glGenTransformFeedbacks)
+ OVERRIDE_DEC(glGenSamplers)
+ OVERRIDE_DEC(glGenQueries)
+ OVERRIDE_DEC(glGenProgramPipelines)
+
+ OVERRIDE_DEC(glDeleteShader)
+ OVERRIDE_DEC(glDeleteProgram)
+
+ OVERRIDE_DEC(glDeleteBuffers)
+ OVERRIDE_DEC(glDeleteFramebuffers)
+ OVERRIDE_DEC(glDeleteRenderbuffers)
+ OVERRIDE_DEC(glDeleteTextures)
+
+ OVERRIDE_DEC(glDeleteVertexArraysOES)
+ OVERRIDE_DEC(glDeleteVertexArrays)
+
+ OVERRIDE_DEC(glDeleteTransformFeedbacks)
+ OVERRIDE_DEC(glDeleteSamplers)
+ OVERRIDE_DEC(glDeleteQueries)
+ OVERRIDE_DEC(glDeleteProgramPipelines)
+
+ // Shaders and programs
+ OVERRIDE_DEC(glCompileShader)
+ OVERRIDE_DEC(glAttachShader)
+ OVERRIDE_DEC(glDetachShader)
+ OVERRIDE_DEC(glLinkProgram)
+ OVERRIDE_DEC(glUseProgram)
+ OVERRIDE_DEC(glValidateProgram)
+ OVERRIDE_DEC(glIsShader)
+ OVERRIDE_DEC(glIsProgram)
+ OVERRIDE_DEC(glGetShaderiv)
+ OVERRIDE_DEC(glGetProgramiv)
+ OVERRIDE_DEC(glGetShaderInfoLog)
+ OVERRIDE_DEC(glGetProgramInfoLog)
+ OVERRIDE_DEC(glGetShaderSource)
+ OVERRIDE_DEC(glBindAttribLocation)
+ OVERRIDE_DEC(glGetActiveAttrib)
+ OVERRIDE_DEC(glGetActiveUniform)
+ OVERRIDE_DEC(glGetAttachedShaders)
+ OVERRIDE_DEC(glGetAttribLocation)
+ OVERRIDE_DEC(glGetUniformfv)
+ OVERRIDE_DEC(glGetUniformiv)
+ OVERRIDE_DEC(glGetUniformLocation)
+ OVERRIDE_DEC(glGetProgramBinaryOES)
+ OVERRIDE_DEC(glProgramBinaryOES)
+ OVERRIDE_DEC(glUniformBlockBinding)
+ OVERRIDE_DEC(glGetUniformBlockIndex)
+ OVERRIDE_DEC(glGetActiveUniformBlockiv)
+ OVERRIDE_DEC(glGetActiveUniformBlockName)
+ OVERRIDE_DEC(glGetUniformuiv)
+ OVERRIDE_DEC(glGetActiveUniformsiv)
+ OVERRIDE_DEC(glTransformFeedbackVaryings)
+ OVERRIDE_DEC(glGetTransformFeedbackVarying)
+ OVERRIDE_DEC(glProgramParameteri)
+ OVERRIDE_DEC(glProgramBinary)
+ OVERRIDE_DEC(glGetProgramBinary)
+ OVERRIDE_DEC(glGetFragDataLocation)
+ OVERRIDE_DEC(glUseProgramStages)
+ OVERRIDE_DEC(glActiveShaderProgram)
+ OVERRIDE_DEC(glProgramUniform1f)
+ OVERRIDE_DEC(glProgramUniform2f)
+ OVERRIDE_DEC(glProgramUniform3f)
+ OVERRIDE_DEC(glProgramUniform4f)
+ OVERRIDE_DEC(glProgramUniform1i)
+ OVERRIDE_DEC(glProgramUniform2i)
+ OVERRIDE_DEC(glProgramUniform3i)
+ OVERRIDE_DEC(glProgramUniform4i)
+ OVERRIDE_DEC(glProgramUniform1ui)
+ OVERRIDE_DEC(glProgramUniform2ui)
+ OVERRIDE_DEC(glProgramUniform3ui)
+ OVERRIDE_DEC(glProgramUniform4ui)
+ OVERRIDE_DEC(glProgramUniform1fv)
+ OVERRIDE_DEC(glProgramUniform2fv)
+ OVERRIDE_DEC(glProgramUniform3fv)
+ OVERRIDE_DEC(glProgramUniform4fv)
+ OVERRIDE_DEC(glProgramUniform1iv)
+ OVERRIDE_DEC(glProgramUniform2iv)
+ OVERRIDE_DEC(glProgramUniform3iv)
+ OVERRIDE_DEC(glProgramUniform4iv)
+ OVERRIDE_DEC(glProgramUniform1uiv)
+ OVERRIDE_DEC(glProgramUniform2uiv)
+ OVERRIDE_DEC(glProgramUniform3uiv)
+ OVERRIDE_DEC(glProgramUniform4uiv)
+ OVERRIDE_DEC(glProgramUniformMatrix2fv)
+ OVERRIDE_DEC(glProgramUniformMatrix3fv)
+ OVERRIDE_DEC(glProgramUniformMatrix4fv)
+ OVERRIDE_DEC(glProgramUniformMatrix2x3fv)
+ OVERRIDE_DEC(glProgramUniformMatrix3x2fv)
+ OVERRIDE_DEC(glProgramUniformMatrix2x4fv)
+ OVERRIDE_DEC(glProgramUniformMatrix4x2fv)
+ OVERRIDE_DEC(glProgramUniformMatrix3x4fv)
+ OVERRIDE_DEC(glProgramUniformMatrix4x3fv)
+ OVERRIDE_DEC(glGetProgramInterfaceiv)
+ OVERRIDE_DEC(glGetProgramResourceiv)
+ OVERRIDE_DEC(glGetProgramResourceIndex)
+ OVERRIDE_DEC(glGetProgramResourceLocation)
+ OVERRIDE_DEC(glGetProgramResourceName)
+
+ return 0;
+
+}
+
+int GLESv2Decoder::s_glFinishRoundTrip(void *self)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glFinish();
+ return 0;
+}
+
+void GLESv2Decoder::s_glGetCompressedTextureFormats(void *self, int count, GLint *formats)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *) self;
+
+ int nFormats;
+ ctx->glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &nFormats);
+ if (nFormats > count) {
+ fprintf(stderr, "%s: GetCompressedTextureFormats: The requested number of formats does not match the number that is reported by OpenGL\n", __FUNCTION__);
+ } else {
+ ctx->glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats);
+ }
+}
+
+void GLESv2Decoder::s_glVertexAttribPointerData(void *self, GLuint indx, GLint size, GLenum type,
+ GLboolean normalized, GLsizei stride, void * data, GLuint datalen)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *) self;
+ if (ctx->m_contextData != NULL) {
+ ctx->m_contextData->storePointerData(indx, data, datalen);
+ // note - the stride of the data is always zero when it comes out of the codec.
+ // See gl2.attrib for the packing function call.
+ if ((void*)ctx->glVertexAttribPointerWithDataSize != gles2_unimplemented) {
+ ctx->glVertexAttribPointerWithDataSize(indx, size, type, normalized,
+ 0, ctx->m_contextData->pointerData(indx), datalen);
+ } else {
+ ctx->glVertexAttribPointer(indx, size, type, normalized, 0,
+ ctx->m_contextData->pointerData(indx));
+ }
+ }
+}
+
+void GLESv2Decoder::s_glVertexAttribPointerOffset(void *self, GLuint indx, GLint size, GLenum type,
+ GLboolean normalized, GLsizei stride, GLuint data)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *) self;
+ ctx->glVertexAttribPointer(indx, size, type, normalized, stride, SafePointerFromUInt(data));
+}
+
+
+void GLESv2Decoder::s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDrawElements(mode, count, type, data);
+}
+
+
+void GLESv2Decoder::s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDrawElements(mode, count, type, SafePointerFromUInt(offset));
+}
+
+void GLESv2Decoder::s_glDrawElementsDataNullAEMU(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDrawElementsNullAEMU(mode, count, type, data);
+}
+
+
+void GLESv2Decoder::s_glDrawElementsOffsetNullAEMU(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDrawElementsNullAEMU(mode, count, type, SafePointerFromUInt(offset));
+}
+
+void GLESv2Decoder::s_glMapBufferRangeAEMU(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, void* mapped)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ if ((access & GL_MAP_READ_BIT) ||
+ ((access & GL_MAP_WRITE_BIT) &&
+ (!(access & GL_MAP_INVALIDATE_RANGE_BIT) &&
+ !(access & GL_MAP_INVALIDATE_BUFFER_BIT)))) {
+ void* gpu_ptr = ctx->glMapBufferRange(target, offset, length, access);
+
+ // map failed, no need to copy or unmap
+ if (!gpu_ptr) {
+ fprintf(stderr, "%s: error: could not map host gpu buffer\n", __func__);
+ return;
+ }
+
+ memcpy(mapped, gpu_ptr, length);
+ ctx->glUnmapBuffer(target);
+ } else {
+ // if writing while not wanting to preserve previous contents,
+ // let |mapped| stay as garbage.
+ }
+}
+
+void GLESv2Decoder::s_glUnmapBufferAEMU(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, void* guest_buffer, GLboolean* out_res)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ *out_res = GL_TRUE;
+
+ if (access & GL_MAP_WRITE_BIT) {
+ if (!guest_buffer) {
+ // guest can flush 0 in some cases
+ return;
+ }
+ void* gpu_ptr = ctx->glMapBufferRange(target, offset, length, access);
+ if (!gpu_ptr) {
+ fprintf(stderr, "%s: could not get host gpu pointer!\n", __FUNCTION__);
+ return;
+ }
+ memcpy(gpu_ptr, guest_buffer, length);
+ *out_res = ctx->glUnmapBuffer(target);
+ }
+}
+
+void GLESv2Decoder::s_glMapBufferRangeDMA(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, uint64_t paddr)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ // Check if this is a read or write request and not an invalidate one.
+ if ((access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) &&
+ !(access & (GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT))) {
+ // Not used
+ // void* guest_buffer = emugl::g_emugl_dma_get_host_addr(paddr);
+ void* guest_buffer = nullptr;
+ void* gpu_ptr = ctx->glMapBufferRange(target, offset, length, access);
+
+ // map failed, no need to copy or unmap
+ if (!gpu_ptr) {
+ fprintf(stderr, "%s: error: could not map host gpu buffer\n", __func__);
+ return;
+ }
+
+ memcpy(guest_buffer, gpu_ptr, length);
+ ctx->glUnmapBuffer(target);
+ } else {
+ // if writing while not wanting to preserve previous contents,
+ // let |mapped| stay as garbage.
+ }
+}
+
+void GLESv2Decoder::s_glUnmapBufferDMA(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, uint64_t paddr, GLboolean* out_res)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ *out_res = GL_TRUE;
+
+ if (access & GL_MAP_WRITE_BIT) {
+ if (!paddr) {
+ // guest can flush 0 in some cases
+ return;
+ }
+ // Not used
+ // void* guest_buffer = emugl::g_emugl_dma_get_host_addr(paddr);
+ void* guest_buffer = nullptr;
+ void* gpu_ptr = ctx->glMapBufferRange(target, offset, length, access);
+ if (!gpu_ptr) {
+ fprintf(stderr, "%s: could not get host gpu pointer!\n", __FUNCTION__);
+ return;
+ }
+ memcpy(gpu_ptr, guest_buffer, length);
+ *out_res = ctx->glUnmapBuffer(target);
+ }
+}
+
+static std::pair<void*, GLsizeiptr> align_pointer_size(void* ptr, GLsizeiptr length)
+{
+ constexpr size_t PAGE_BITS = 12;
+ constexpr size_t PAGE_SIZE = 1u << PAGE_BITS;
+ constexpr size_t PAGE_OFFSET_MASK = PAGE_SIZE - 1;
+
+ uintptr_t addr = reinterpret_cast<uintptr_t>(ptr);
+ uintptr_t page_offset = addr & PAGE_OFFSET_MASK;
+
+ return { reinterpret_cast<void*>(addr - page_offset),
+ ((length + page_offset + PAGE_SIZE - 1) >> PAGE_BITS) << PAGE_BITS
+ };
+}
+
+uint64_t GLESv2Decoder::s_glMapBufferRangeDirect(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, uint64_t paddr)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ // Check if this is a read or write request and not an invalidate one.
+ if (access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) {
+ void* gpu_ptr = ctx->glMapBufferRange(target, offset, length, access);
+
+ if (gpu_ptr) {
+ std::pair<void*, GLsizeiptr> aligned = align_pointer_size(gpu_ptr, length);
+ get_emugl_vm_operations().mapUserBackedRam(paddr, aligned.first, aligned.second);
+ return reinterpret_cast<uint64_t>(gpu_ptr);
+ } else {
+ fprintf(stderr, "%s: error: could not map host gpu buffer\n", __func__);
+ return 0;
+ }
+ } else {
+ // if writing while not wanting to preserve previous contents,
+ // let |mapped| stay as garbage.
+ return 0;
+ }
+}
+
+void GLESv2Decoder::s_glUnmapBufferDirect(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, uint64_t paddr, uint64_t gpu_ptr, GLboolean* out_res)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ GLboolean res = GL_TRUE;
+
+ if (access & (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)) {
+ get_emugl_vm_operations().unmapUserBackedRam(paddr, align_pointer_size(reinterpret_cast<void*>(gpu_ptr), length).second);
+ res = ctx->glUnmapBuffer(target);
+ }
+
+ *out_res = res;
+}
+
+void GLESv2Decoder::s_glFlushMappedBufferRangeAEMU(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, void* guest_buffer) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ if (!guest_buffer) {
+ // guest can end up flushing 0 bytes in a lot of cases
+ return;
+ }
+ void* gpu_ptr = ctx->glMapBufferRange(target, offset, length, access);
+
+ // map failed, no need to copy or unmap
+ if (!gpu_ptr) {
+ fprintf(stderr, "%s: error: could not map host gpu buffer\n", __func__);
+ return;
+ }
+
+ memcpy(gpu_ptr, guest_buffer, length);
+ // |offset| was the absolute offset into the mapping, so just flush offset 0.
+ ctx->glFlushMappedBufferRange(target, 0, length);
+ ctx->glUnmapBuffer(target);
+}
+
+void GLESv2Decoder::s_glFlushMappedBufferRangeDirect(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glFlushMappedBufferRange(target, offset, length);
+}
+
+void GLESv2Decoder::s_glCompressedTexImage2DOffsetAEMU(void* self, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLuint offset) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, SafePointerFromUInt(offset));
+}
+void GLESv2Decoder::s_glCompressedTexSubImage2DOffsetAEMU(void* self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLuint offset) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, SafePointerFromUInt(offset));
+}
+void GLESv2Decoder::s_glTexImage2DOffsetAEMU(void* self, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLuint offset) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glTexImage2D(target, level, internalformat, width, height, border, format, type, SafePointerFromUInt(offset));
+}
+void GLESv2Decoder::s_glTexSubImage2DOffsetAEMU(void* self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLuint offset) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, SafePointerFromUInt(offset));
+}
+
+static const char* const kNameDelimiter = ";";
+
+static std::vector<std::string> sUnpackVarNames(GLsizei count, const char* packedNames) {
+ std::vector<std::string> unpacked;
+ GLsizei current = 0;
+
+ while (current < count) {
+ const char* delimPos = strstr(packedNames, kNameDelimiter);
+ size_t nameLen = delimPos - packedNames;
+ std::string next;
+ next.resize(nameLen);
+ memcpy(&next[0], packedNames, nameLen);
+ unpacked.push_back(next);
+ packedNames = delimPos + 1;
+ current++;
+ }
+
+ return unpacked;
+}
+
+void GLESv2Decoder::s_glGetUniformIndicesAEMU(void* self, GLuint program, GLsizei uniformCount, const GLchar* packedNames, GLsizei packedLen, GLuint* uniformIndices) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+
+ std::vector<std::string> unpacked = sUnpackVarNames(uniformCount, packedNames);
+
+ GLchar** unpackedArray = new GLchar*[unpacked.size()];
+ GLsizei i = 0;
+ for (auto& elt : unpacked) {
+ unpackedArray[i] = (GLchar*)&elt[0];
+ i++;
+ }
+
+ ctx->glGetUniformIndices(program, uniformCount, (const GLchar**)unpackedArray, uniformIndices);
+
+ delete [] unpackedArray;
+}
+
+void GLESv2Decoder::s_glVertexAttribIPointerDataAEMU(void *self, GLuint indx, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *) self;
+ if (ctx->m_contextData != NULL) {
+ ctx->m_contextData->storePointerData(indx, data, datalen);
+ // note - the stride of the data is always zero when it comes out of the codec.
+ // See gl2.attrib for the packing function call.
+ if ((void*)ctx->glVertexAttribIPointerWithDataSize != gles2_unimplemented) {
+ ctx->glVertexAttribIPointerWithDataSize(indx, size, type, 0,
+ ctx->m_contextData->pointerData(indx), datalen);
+ } else {
+ ctx->glVertexAttribIPointer(indx, size, type, 0,
+ ctx->m_contextData->pointerData(indx));
+ }
+ }
+}
+
+void GLESv2Decoder::s_glVertexAttribIPointerOffsetAEMU(void *self, GLuint indx, GLint size, GLenum type, GLsizei stride, GLuint data)
+{
+ GLESv2Decoder *ctx = (GLESv2Decoder *) self;
+ ctx->glVertexAttribIPointer(indx, size, type, stride, SafePointerFromUInt(data));
+}
+
+void GLESv2Decoder::s_glTransformFeedbackVaryingsAEMU(void* self, GLuint program, GLsizei count, const char* packedVaryings, GLuint packedVaryingsLen, GLenum bufferMode) {
+
+ GLESv2Decoder *ctx = (GLESv2Decoder *) self;
+
+ std::vector<std::string> unpacked = sUnpackVarNames(count, packedVaryings);
+
+ char** unpackedArray = new char*[unpacked.size()];
+ GLsizei i = 0;
+ for (auto& elt : unpacked) {
+ unpackedArray[i] = &elt[0];
+ i++;
+ }
+
+ ctx->glTransformFeedbackVaryings(program, count, (const char**)unpackedArray, bufferMode);
+
+ delete [] unpackedArray;
+}
+
+void GLESv2Decoder::s_glTexImage3DOffsetAEMU(void* self, GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLuint offset) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *) self;
+ ctx->glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, SafePointerFromUInt(offset));
+}
+void GLESv2Decoder::s_glTexSubImage3DOffsetAEMU(void* self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLuint offset) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *) self;
+ ctx->glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, SafePointerFromUInt(offset));
+}
+void GLESv2Decoder::s_glCompressedTexImage3DOffsetAEMU(void* self, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, GLuint offset) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *) self;
+ ctx->glCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, SafePointerFromUInt(offset));
+}
+void GLESv2Decoder::s_glCompressedTexSubImage3DOffsetAEMU(void* self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, GLuint offset) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *) self;
+ ctx->glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, SafePointerFromUInt(offset));
+}
+
+void GLESv2Decoder::s_glDrawElementsInstancedOffsetAEMU(void* self, GLenum mode, GLsizei count, GLenum type, GLuint offset, GLsizei primcount) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDrawElementsInstanced(mode, count, type, SafePointerFromUInt(offset), primcount);
+}
+
+void GLESv2Decoder::s_glDrawElementsInstancedDataAEMU(void* self, GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount, GLsizei datalen) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDrawElementsInstanced(mode, count, type, indices, primcount);
+}
+
+void GLESv2Decoder::s_glReadPixelsOffsetAEMU(void* self, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLuint offset) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glReadPixels(x, y, width, height, format, type, SafePointerFromUInt(offset));
+}
+
+GLuint GLESv2Decoder::s_glCreateShaderProgramvAEMU(void* self, GLenum type, GLsizei count, const char* packedStrings, GLuint packedLen) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ return ctx->glCreateShaderProgramv(type, 1, &packedStrings);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glDrawArraysIndirectDataAEMU(void* self, GLenum mode, const void* indirect, GLuint datalen) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDrawArraysIndirect(mode, indirect);
+}
+
+void GLESv2Decoder::s_glDrawArraysIndirectOffsetAEMU(void* self, GLenum mode, GLuint offset) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDrawArraysIndirect(mode, SafePointerFromUInt(offset));
+}
+
+void GLESv2Decoder::s_glDrawElementsIndirectDataAEMU(void* self, GLenum mode, GLenum type, const void* indirect, GLuint datalen) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDrawElementsIndirect(mode, type, indirect);
+}
+
+void GLESv2Decoder::s_glDrawElementsIndirectOffsetAEMU(void* self, GLenum mode, GLenum type, GLuint offset) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDrawElementsIndirect(mode, type, SafePointerFromUInt(offset));
+}
+
+uint64_t GLESv2Decoder::s_glFenceSyncAEMU(void* self, GLenum condition, GLbitfield flags) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ return (uint64_t)(uintptr_t)ctx->glFenceSync(condition, flags);
+}
+
+GLenum GLESv2Decoder::s_glClientWaitSyncAEMU(void* self, uint64_t wait_on, GLbitfield flags, GLuint64 timeout) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ return ctx->glClientWaitSync((GLsync)(uintptr_t)wait_on, flags, timeout);
+}
+
+void GLESv2Decoder::s_glWaitSyncAEMU(void* self, uint64_t wait_on, GLbitfield flags, GLuint64 timeout) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glWaitSync((GLsync)(uintptr_t)wait_on, flags, timeout);
+}
+
+void GLESv2Decoder::s_glDeleteSyncAEMU(void* self, uint64_t to_delete) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteSync((GLsync)(uintptr_t)to_delete);
+}
+
+GLboolean GLESv2Decoder::s_glIsSyncAEMU(void* self, uint64_t sync) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ return ctx->glIsSync((GLsync)(uintptr_t)sync);
+}
+
+void GLESv2Decoder::s_glGetSyncivAEMU(void* self, uint64_t sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glGetSynciv((GLsync)(uintptr_t)sync, pname, bufSize, length, values);
+}
+
+GLuint GLESv2Decoder::s_glCreateShader(void* self, GLenum shaderType) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ GLuint shader = ctx->glCreateShader(shaderType);
+
+ if (ctx->m_snapshot) {
+ GLuint emuName = ctx->m_snapshot->createShader(shader, shaderType);
+ return emuName;
+ }
+
+ return shader;
+}
+
+GLuint GLESv2Decoder::s_glCreateProgram(void* self) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ return ctx->glCreateProgram();
+}
+
+void GLESv2Decoder::s_glGenBuffers(void* self, GLsizei n, GLuint* buffers) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glGenBuffers(n, buffers);
+
+ if (ctx->m_snapshot) {
+ ctx->m_snapshot->genBuffers(n, buffers);
+ }
+}
+
+void GLESv2Decoder::s_glGenFramebuffers(void* self, GLsizei n, GLuint* framebuffers) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glGenFramebuffers(n, framebuffers);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glGenRenderbuffers(void* self, GLsizei n, GLuint* renderbuffers) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glGenRenderbuffers(n, renderbuffers);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glGenTextures(void* self, GLsizei n, GLuint* textures) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glGenTextures(n, textures);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glGenVertexArraysOES(void* self, GLsizei n, GLuint* arrays) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glGenVertexArraysOES(n, arrays);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glGenVertexArrays(void* self, GLsizei n, GLuint* arrays) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glGenVertexArrays(n, arrays);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glGenTransformFeedbacks(void* self, GLsizei n, GLuint* transformFeedbacks) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glGenTransformFeedbacks(n, transformFeedbacks);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glGenSamplers(void* self, GLsizei n, GLuint* samplers) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glGenSamplers(n, samplers);
+ // TODO: Snapshot names
+
+}
+
+void GLESv2Decoder::s_glGenQueries(void* self, GLsizei n, GLuint* queries) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glGenQueries(n, queries);
+ // TODO: Snapshot names
+
+}
+
+void GLESv2Decoder::s_glGenProgramPipelines(void* self, GLsizei n, GLuint* pipelines) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glGenProgramPipelines(n, pipelines);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glDeleteShader(void* self, GLuint shader) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteShader(shader);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glDeleteProgram(void* self, GLuint program) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteProgram(program);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glDeleteBuffers(void* self, GLsizei n, const GLuint *buffers) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteBuffers(n, buffers);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glDeleteFramebuffers(void* self, GLsizei n, const GLuint *framebuffers) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteFramebuffers(n, framebuffers);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glDeleteRenderbuffers(void* self, GLsizei n, const GLuint *renderbuffers) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteRenderbuffers(n, renderbuffers);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glDeleteTextures(void* self, GLsizei n, const GLuint *textures) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteTextures(n, textures);
+ // TODO: Snapshot names
+}
+
+
+void GLESv2Decoder::s_glDeleteVertexArraysOES(void* self, GLsizei n, const GLuint *arrays) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteVertexArraysOES(n, arrays);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glDeleteVertexArrays(void* self, GLsizei n, const GLuint *arrays) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteVertexArrays(n, arrays);
+ // TODO: Snapshot names
+}
+
+
+void GLESv2Decoder::s_glDeleteTransformFeedbacks(void* self, GLsizei n, const GLuint *transformFeedbacks) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteTransformFeedbacks(n, transformFeedbacks);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glDeleteSamplers(void* self, GLsizei n, const GLuint *samplers) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteSamplers(n, samplers);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glDeleteQueries(void* self, GLsizei n, const GLuint *queries) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteQueries(n, queries);
+ // TODO: Snapshot names
+}
+
+void GLESv2Decoder::s_glDeleteProgramPipelines(void* self, GLsizei n, const GLuint *pipelines) {
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self;
+ ctx->glDeleteProgramPipelines(n, pipelines);
+ // TODO: Snapshot names
+}
+
+#define SNAPSHOT_PROGRAM_NAME(x) \
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self; \
+ if (ctx->m_snapshot) { x = ctx->m_snapshot->getProgramName(x); } \
+
+#define SNAPSHOT_PROGRAM_NAME2(x,y) \
+ GLESv2Decoder *ctx = (GLESv2Decoder *)self; \
+ if (ctx->m_snapshot) { \
+ x = ctx->m_snapshot->getProgramName(x); \
+ y = ctx->m_snapshot->getProgramName(y); \
+ } \
+
+#define SNAPSHOT_SHADER_CALL(funcname,argtypes,args) \
+void GLESv2Decoder::s_##funcname argtypes { \
+ SNAPSHOT_PROGRAM_NAME(shader) \
+ ctx-> funcname args ; \
+} \
+
+#define SNAPSHOT_PROGRAM_CALL(funcname,argtypes,args) \
+void GLESv2Decoder::s_##funcname argtypes { \
+ SNAPSHOT_PROGRAM_NAME(program) \
+ ctx-> funcname args ; \
+} \
+
+#define SNAPSHOT_PROGRAM_CALL_RET(rettype, funcname, argtypes, args) \
+rettype GLESv2Decoder::s_##funcname argtypes { \
+ SNAPSHOT_PROGRAM_NAME(program) \
+ return ctx-> funcname args; \
+} \
+
+
+void GLESv2Decoder::s_glShaderString(void *self, GLuint shader, const GLchar* string, GLsizei len)
+{
+ SNAPSHOT_PROGRAM_NAME(shader);
+
+ ctx->glShaderSource(shader, 1, &string, NULL);
+
+ if (ctx->m_snapshot) {
+ ctx->m_snapshot->shaderString(shader, string);
+ }
+}
+
+void GLESv2Decoder::s_glAttachShader(void* self, GLuint program, GLuint shader) {
+ SNAPSHOT_PROGRAM_NAME2(program, shader)
+ ctx->glAttachShader(program, shader);
+}
+
+void GLESv2Decoder::s_glDetachShader(void* self, GLuint program, GLuint shader) {
+ SNAPSHOT_PROGRAM_NAME2(program, shader)
+ ctx->glDetachShader(program, shader);
+}
+
+GLboolean GLESv2Decoder::s_glIsShader(void* self, GLuint shader) {
+ SNAPSHOT_PROGRAM_NAME(shader);
+ return ctx->glIsShader(shader);
+}
+
+GLboolean GLESv2Decoder::s_glIsProgram(void* self, GLuint program) {
+ SNAPSHOT_PROGRAM_NAME(program);
+ return ctx->glIsProgram(program);
+}
+
+SNAPSHOT_SHADER_CALL(glCompileShader, (void* self, GLuint shader), (shader))
+SNAPSHOT_SHADER_CALL(glGetShaderiv, (void* self, GLuint shader, GLenum pname, GLint* params), (shader, pname, params))
+SNAPSHOT_SHADER_CALL(glGetShaderInfoLog, (void* self, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog), (shader, bufsize, length, infolog))
+SNAPSHOT_SHADER_CALL(glGetShaderSource, (void* self, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source), (shader, bufsize, length, source))
+SNAPSHOT_PROGRAM_CALL(glLinkProgram, (void* self, GLuint program), (program))
+SNAPSHOT_PROGRAM_CALL(glUseProgram, (void* self, GLuint program), (program))
+SNAPSHOT_PROGRAM_CALL(glValidateProgram, (void* self, GLuint program), (program))
+SNAPSHOT_PROGRAM_CALL(glGetProgramiv, (void* self, GLuint program, GLenum pname, GLint* params), (program, pname, params))
+SNAPSHOT_PROGRAM_CALL(glGetProgramInfoLog, (void* self, GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog), (program, bufsize, length, infolog))
+SNAPSHOT_PROGRAM_CALL(glBindAttribLocation, (void* self, GLuint program, GLuint index, const GLchar* name), (program, index, name))
+SNAPSHOT_PROGRAM_CALL(glGetActiveAttrib, (void* self, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name), (program, index, bufsize, length, size, type, name))
+SNAPSHOT_PROGRAM_CALL(glGetActiveUniform, (void* self, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name), (program, index, bufsize, length, size, type, name))
+SNAPSHOT_PROGRAM_CALL(glGetAttachedShaders, (void* self, GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders), (program, maxcount, count, shaders))
+SNAPSHOT_PROGRAM_CALL_RET(GLint, glGetAttribLocation, (void* self, GLuint program, const GLchar* name), (program, name))
+SNAPSHOT_PROGRAM_CALL(glGetUniformfv, (void* self, GLuint program, GLint location, GLfloat* params), (program, location, params))
+SNAPSHOT_PROGRAM_CALL(glGetUniformiv, (void* self, GLuint program, GLint location, GLint* params), (program, location, params))
+SNAPSHOT_PROGRAM_CALL_RET(GLint, glGetUniformLocation, (void* self, GLuint program, const GLchar* name), (program, name))
+SNAPSHOT_PROGRAM_CALL(glGetProgramBinaryOES, (void* self, GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary), (program, bufSize, length, binaryFormat, binary))
+SNAPSHOT_PROGRAM_CALL(glProgramBinaryOES, (void* self, GLuint program, GLenum binaryFormat, const GLvoid* binary, GLint length), (program, binaryFormat, binary, length))
+SNAPSHOT_PROGRAM_CALL(glUniformBlockBinding, (void* self, GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding), (program, uniformBlockIndex, uniformBlockBinding))
+SNAPSHOT_PROGRAM_CALL_RET(GLuint, glGetUniformBlockIndex, (void* self, GLuint program, const GLchar* uniformBlockName), (program, uniformBlockName))
+SNAPSHOT_PROGRAM_CALL(glGetActiveUniformBlockiv, (void* self, GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params), (program, uniformBlockIndex, pname, params))
+SNAPSHOT_PROGRAM_CALL(glGetActiveUniformBlockName, (void* self, GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName), (program, uniformBlockIndex, bufSize, length, uniformBlockName))
+SNAPSHOT_PROGRAM_CALL(glGetUniformuiv, (void* self, GLuint program, GLint location, GLuint* params), (program, location, params))
+SNAPSHOT_PROGRAM_CALL(glGetActiveUniformsiv, (void* self, GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params), (program, uniformCount, uniformIndices, pname, params))
+SNAPSHOT_PROGRAM_CALL(glTransformFeedbackVaryings, (void* self, GLuint program, GLsizei count, const char** varyings, GLenum bufferMode), (program, count, varyings, bufferMode))
+SNAPSHOT_PROGRAM_CALL(glGetTransformFeedbackVarying, (void* self, GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, char* name), (program, index, bufSize, length, size, type, name))
+SNAPSHOT_PROGRAM_CALL(glProgramParameteri, (void* self, GLuint program, GLenum pname, GLint value), (program, pname, value))
+SNAPSHOT_PROGRAM_CALL(glProgramBinary, (void* self, GLuint program, GLenum binaryFormat, const void* binary, GLsizei length), (program, binaryFormat, binary, length))
+SNAPSHOT_PROGRAM_CALL(glGetProgramBinary, (void* self, GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, void* binary), (program, bufSize, length, binaryFormat, binary))
+SNAPSHOT_PROGRAM_CALL_RET(GLint, glGetFragDataLocation, (void* self, GLuint program, const char* name), (program, name))
+SNAPSHOT_PROGRAM_CALL(glUseProgramStages, (void* self, GLuint pipeline, GLbitfield stages, GLuint program), (pipeline, stages, program))
+SNAPSHOT_PROGRAM_CALL(glActiveShaderProgram, (void* self, GLuint pipeline, GLuint program), (pipeline, program))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform1f, (void* self, GLuint program, GLint location, GLfloat v0), (program, location, v0))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform2f, (void* self, GLuint program, GLint location, GLfloat v0, GLfloat v1), (program, location, v0, v1))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform3f, (void* self, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2), (program, location, v0, v1, v2))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform4f, (void* self, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3), (program, location, v0, v1, v2, v3))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform1i, (void* self, GLuint program, GLint location, GLint v0), (program, location, v0))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform2i, (void* self, GLuint program, GLint location, GLint v0, GLint v1), (program, location, v0, v1))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform3i, (void* self, GLuint program, GLint location, GLint v0, GLint v1, GLint v2), (program, location, v0, v1, v2))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform4i, (void* self, GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3), (program, location, v0, v1, v2, v3))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform1ui, (void* self, GLuint program, GLint location, GLuint v0), (program, location, v0))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform2ui, (void* self, GLuint program, GLint location, GLint v0, GLuint v1), (program, location, v0, v1))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform3ui, (void* self, GLuint program, GLint location, GLint v0, GLint v1, GLuint v2), (program, location, v0, v1, v2))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform4ui, (void* self, GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLuint v3), (program, location, v0, v1, v2, v3))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform1fv, (void* self, GLuint program, GLint location, GLsizei count, const GLfloat* value), (program, location, count, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform2fv, (void* self, GLuint program, GLint location, GLsizei count, const GLfloat* value), (program, location, count, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform3fv, (void* self, GLuint program, GLint location, GLsizei count, const GLfloat* value), (program, location, count, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform4fv, (void* self, GLuint program, GLint location, GLsizei count, const GLfloat* value), (program, location, count, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform1iv, (void* self, GLuint program, GLint location, GLsizei count, const GLint* value), (program, location, count, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform2iv, (void* self, GLuint program, GLint location, GLsizei count, const GLint* value), (program, location, count, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform3iv, (void* self, GLuint program, GLint location, GLsizei count, const GLint* value), (program, location, count, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform4iv, (void* self, GLuint program, GLint location, GLsizei count, const GLint* value), (program, location, count, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform1uiv, (void* self, GLuint program, GLint location, GLsizei count, const GLuint* value), (program, location, count, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform2uiv, (void* self, GLuint program, GLint location, GLsizei count, const GLuint* value), (program, location, count, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform3uiv, (void* self, GLuint program, GLint location, GLsizei count, const GLuint* value), (program, location, count, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniform4uiv, (void* self, GLuint program, GLint location, GLsizei count, const GLuint* value), (program, location, count, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniformMatrix2fv, (void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (program, location, count, transpose, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniformMatrix3fv, (void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (program, location, count, transpose, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniformMatrix4fv, (void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (program, location, count, transpose, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniformMatrix2x3fv, (void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (program, location, count, transpose, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniformMatrix3x2fv, (void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (program, location, count, transpose, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniformMatrix2x4fv, (void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (program, location, count, transpose, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniformMatrix4x2fv, (void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (program, location, count, transpose, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniformMatrix3x4fv, (void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (program, location, count, transpose, value))
+SNAPSHOT_PROGRAM_CALL(glProgramUniformMatrix4x3fv, (void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat* value), (program, location, count, transpose, value))
+SNAPSHOT_PROGRAM_CALL(glGetProgramInterfaceiv, (void* self, GLuint program, GLenum programInterface, GLenum pname, GLint* params), (program, programInterface, pname, params))
+SNAPSHOT_PROGRAM_CALL(glGetProgramResourceiv, (void* self, GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum* props, GLsizei bufSize, GLsizei* length, GLint* params), (program, programInterface, index, propCount, props, bufSize, length, params))
+SNAPSHOT_PROGRAM_CALL_RET(GLuint, glGetProgramResourceIndex, (void* self, GLuint program, GLenum programInterface, const char * name), (program, programInterface, name))
+SNAPSHOT_PROGRAM_CALL_RET(GLint, glGetProgramResourceLocation, (void* self, GLuint program, GLenum programInterface, const char * name), (program, programInterface, name))
+SNAPSHOT_PROGRAM_CALL(glGetProgramResourceName, (void* self, GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, char* name), (program, programInterface, index, bufSize, length, name))
diff --git a/stream-servers/gles2_dec/GLESv2Decoder.h b/stream-servers/gles2_dec/GLESv2Decoder.h
new file mode 100644
index 00000000..f55d0d5f
--- /dev/null
+++ b/stream-servers/gles2_dec/GLESv2Decoder.h
@@ -0,0 +1,249 @@
+/*
+* Copyright 2011 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#ifndef _GL2_DECODER_H_
+#define _GL2_DECODER_H_
+
+#include "gles2_dec.h"
+#include "GLDecoderContextData.h"
+#include "base/SharedLibrary.h"
+
+#include "GLSnapshot.h"
+
+typedef void (gles2_APIENTRY *glVertexAttribPointerWithDataSize_server_proc_t) (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*, GLsizei);
+typedef void (gles2_APIENTRY *glVertexAttribIPointerWithDataSize_server_proc_t) (GLuint, GLint, GLenum, GLsizei, const GLvoid*, GLsizei);
+
+struct gles2_decoder_extended_context : gles2_decoder_context_t {
+ glVertexAttribPointerWithDataSize_server_proc_t glVertexAttribPointerWithDataSize;
+ glVertexAttribIPointerWithDataSize_server_proc_t glVertexAttribIPointerWithDataSize;
+
+ int initDispatch( void *(*getProc)(const char *name, void *userData), void *userData);
+
+private:
+ using gles2_server_context_t::initDispatchByName;
+};
+
+class GLESv2Decoder : public gles2_decoder_extended_context
+{
+public:
+ typedef void *(*get_proc_func_t)(const char *name, void *userData);
+ GLESv2Decoder();
+ ~GLESv2Decoder();
+ int initGL(get_proc_func_t getProcFunc, void *getProcFuncData);
+ void setContextData(GLDecoderContextData *contextData) { m_contextData = contextData; }
+protected:
+ GLSnapshot::GLSnapshotState *m_snapshot;
+private:
+ GLDecoderContextData *m_contextData;
+ android::base::SharedLibrary* m_GL2library;
+
+ static void *s_getProc(const char *name, void *userData);
+ static void gles2_APIENTRY s_glGetCompressedTextureFormats(void *self, int count, GLint *formats);
+ static void gles2_APIENTRY s_glVertexAttribPointerData(void *self, GLuint indx, GLint size, GLenum type,
+ GLboolean normalized, GLsizei stride, void * data, GLuint datalen);
+ static void gles2_APIENTRY s_glVertexAttribPointerOffset(void *self, GLuint indx, GLint size, GLenum type,
+ GLboolean normalized, GLsizei stride, GLuint offset);
+
+ static void gles2_APIENTRY s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset);
+ static void gles2_APIENTRY s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen);
+ static void gles2_APIENTRY s_glDrawElementsOffsetNullAEMU(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset);
+ static void gles2_APIENTRY s_glDrawElementsDataNullAEMU(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen);
+ static int gles2_APIENTRY s_glFinishRoundTrip(void *self);
+
+ static void gles2_APIENTRY s_glMapBufferRangeAEMU(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, void* mapped);
+ static void gles2_APIENTRY s_glUnmapBufferAEMU(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, void* guest_buffer, GLboolean* out_res);
+ static void gles2_APIENTRY s_glFlushMappedBufferRangeAEMU(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, void* guest_buffer);
+
+ static void gles2_APIENTRY s_glMapBufferRangeDMA(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, uint64_t paddr);
+ static void gles2_APIENTRY s_glUnmapBufferDMA(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, uint64_t paddr, GLboolean* out_res);
+
+ static uint64_t gles2_APIENTRY s_glMapBufferRangeDirect(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, uint64_t paddr);
+ static void gles2_APIENTRY s_glUnmapBufferDirect(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access, uint64_t paddr, uint64_t guest_ptr, GLboolean* out_res);
+ static void gles2_APIENTRY s_glFlushMappedBufferRangeDirect(void* self, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+
+ static void gles2_APIENTRY s_glCompressedTexImage2DOffsetAEMU(void* self, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, GLuint offset);
+ static void gles2_APIENTRY s_glCompressedTexSubImage2DOffsetAEMU(void* self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, GLuint offset);
+ static void gles2_APIENTRY s_glTexImage2DOffsetAEMU(void* self, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLuint offset);
+ static void gles2_APIENTRY s_glTexSubImage2DOffsetAEMU(void* self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLuint offset);
+
+ static void gles2_APIENTRY s_glVertexAttribIPointerDataAEMU(void *self, GLuint indx, GLint size, GLenum type, GLsizei stride, void * data, GLuint datalen);
+ static void gles2_APIENTRY s_glVertexAttribIPointerOffsetAEMU(void *self, GLuint indx, GLint size, GLenum type, GLsizei stride, GLuint offset);
+
+ static void gles2_APIENTRY s_glTexImage3DOffsetAEMU(void* self, GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLuint offset);
+ static void gles2_APIENTRY s_glTexSubImage3DOffsetAEMU(void* self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLuint offset);
+ static void gles2_APIENTRY s_glCompressedTexImage3DOffsetAEMU(void* self, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, GLuint offset);
+ static void gles2_APIENTRY s_glCompressedTexSubImage3DOffsetAEMU(void* self, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, GLuint offset);
+ static void gles2_APIENTRY s_glDrawElementsInstancedOffsetAEMU(void* self, GLenum mode, GLsizei count, GLenum type, GLuint offset, GLsizei primcount);
+ static void gles2_APIENTRY s_glDrawElementsInstancedDataAEMU(void* self, GLenum mode, GLsizei count, GLenum type, const void* indices, GLsizei primcount, GLsizei datalen);
+
+ static void gles2_APIENTRY s_glReadPixelsOffsetAEMU(void* self, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLuint offset);
+
+ static GLuint gles2_APIENTRY s_glCreateShaderProgramvAEMU(void* self, GLenum type, GLsizei count, const char* packedStrings, GLuint packedLen);
+
+ static void gles2_APIENTRY s_glDrawArraysIndirectDataAEMU(void* self, GLenum mode, const void* indirect, GLuint datalen);
+ static void gles2_APIENTRY s_glDrawArraysIndirectOffsetAEMU(void* self, GLenum mode, GLuint offset);
+
+ static void gles2_APIENTRY s_glDrawElementsIndirectDataAEMU(void* self, GLenum mode, GLenum type, const void* indirect, GLuint datalen);
+ static void gles2_APIENTRY s_glDrawElementsIndirectOffsetAEMU(void* self, GLenum mode, GLenum type, GLuint offset);
+
+ static uint64_t gles2_APIENTRY s_glFenceSyncAEMU(void* self, GLenum condition, GLbitfield flags);
+ static GLenum gles2_APIENTRY s_glClientWaitSyncAEMU(void* self, uint64_t wait_on, GLbitfield flags, GLuint64 timeout);
+ static void gles2_APIENTRY s_glWaitSyncAEMU(void* self, uint64_t wait_on, GLbitfield flags, GLuint64 timeout);
+ static void gles2_APIENTRY s_glDeleteSyncAEMU(void* self, uint64_t to_delete);
+ static GLboolean gles2_APIENTRY s_glIsSyncAEMU(void* self, uint64_t sync);
+ static void gles2_APIENTRY s_glGetSyncivAEMU(void* self, uint64_t sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+
+ //============================================================
+ // Snapshot state
+ //============================================================
+
+ // All generations============================================
+
+ static GLuint gles2_APIENTRY s_glCreateShader(void* self, GLenum shaderType);
+ static GLuint gles2_APIENTRY s_glCreateProgram(void* self);
+
+ static void gles2_APIENTRY s_glGenBuffers(void* self, GLsizei n, GLuint* buffers);
+
+ static void gles2_APIENTRY s_glGenFramebuffers(void* self, GLsizei n, GLuint* framebuffers);
+ static void gles2_APIENTRY s_glGenRenderbuffers(void* self, GLsizei n, GLuint* renderbuffers);
+ static void gles2_APIENTRY s_glGenTextures(void* self, GLsizei n, GLuint* textures);
+
+ static void gles2_APIENTRY s_glGenVertexArraysOES(void* self, GLsizei n, GLuint* arrays);
+ static void gles2_APIENTRY s_glGenVertexArrays(void* self, GLsizei n, GLuint* arrays);
+
+ static void gles2_APIENTRY s_glGenTransformFeedbacks(void* self, GLsizei n, GLuint* transformFeedbacks);
+
+ static void gles2_APIENTRY s_glGenSamplers(void* self, GLsizei n, GLuint* samplers);
+
+ static void gles2_APIENTRY s_glGenQueries(void* self, GLsizei n, GLuint* queries);
+
+ static GLuint gles2_APIENTRY s_glCreateShaderProgramv(void* self, GLenum type, GLsizei count, const char** strings);
+
+ static void gles2_APIENTRY s_glGenProgramPipelines(void* self, GLsizei n, GLuint* pipelines);
+
+ // All deletes================================================
+ static void gles2_APIENTRY s_glDeleteShader(void* self, GLuint shader);
+ static void gles2_APIENTRY s_glDeleteProgram(void* self, GLuint program);
+
+ static void gles2_APIENTRY s_glDeleteBuffers(void* self, GLsizei n, const GLuint *buffers);
+ static void gles2_APIENTRY s_glDeleteFramebuffers(void* self, GLsizei n, const GLuint *framebuffers);
+ static void gles2_APIENTRY s_glDeleteRenderbuffers(void* self, GLsizei n, const GLuint *renderbuffers);
+ static void gles2_APIENTRY s_glDeleteTextures(void* self, GLsizei n, const GLuint *textures);
+
+ static void gles2_APIENTRY s_glDeleteVertexArraysOES(void* self, GLsizei n, const GLuint *arrays);
+ static void gles2_APIENTRY s_glDeleteVertexArrays(void* self, GLsizei n, const GLuint *arrays);
+
+ static void gles2_APIENTRY s_glDeleteTransformFeedbacks(void* self, GLsizei n, const GLuint *transformfeedbacks);
+ static void gles2_APIENTRY s_glDeleteSamplers(void* self, GLsizei n, const GLuint *samplers);
+ static void gles2_APIENTRY s_glDeleteQueries(void* self, GLsizei n, const GLuint *queries);
+ static void gles2_APIENTRY s_glDeleteProgramPipelines(void* self, GLsizei n, const GLuint *pipelines);
+
+ // Shaders and programs=======================================
+ static void gles2_APIENTRY s_glShaderString(void *self, GLuint shader, const GLchar* string, GLsizei len);
+ static void gles2_APIENTRY s_glCompileShader(void* self, GLuint shader);
+ static void gles2_APIENTRY s_glAttachShader(void* self, GLuint program, GLuint shader);
+ static void gles2_APIENTRY s_glDetachShader(void* self, GLuint program, GLuint shader);
+ static void gles2_APIENTRY s_glLinkProgram(void* self, GLuint program);
+ static void gles2_APIENTRY s_glUseProgram(void* self, GLuint program);
+ static void gles2_APIENTRY s_glValidateProgram(void* self, GLuint program);
+
+ static GLboolean gles2_APIENTRY s_glIsShader(void* self, GLuint shader);
+ static GLboolean gles2_APIENTRY s_glIsProgram(void* self, GLuint program);
+
+ static void gles2_APIENTRY s_glGetShaderiv(void* self, GLuint shader, GLenum pname, GLint* params);
+ static void gles2_APIENTRY s_glGetProgramiv(void* self, GLuint program, GLenum pname, GLint* params);
+ static void gles2_APIENTRY s_glGetShaderInfoLog(void* self, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+ static void gles2_APIENTRY s_glGetProgramInfoLog(void* self, GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog);
+ static void gles2_APIENTRY s_glGetShaderSource(void* self, GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source);
+
+ static void gles2_APIENTRY s_glBindAttribLocation(void* self, GLuint program, GLuint index, const GLchar* name);
+ static void gles2_APIENTRY s_glGetActiveAttrib(void* self, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+ static void gles2_APIENTRY s_glGetActiveUniform(void* self, GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name);
+ static void gles2_APIENTRY s_glGetAttachedShaders(void* self, GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders);
+ static GLint gles2_APIENTRY s_glGetAttribLocation(void* self, GLuint program, const GLchar* name);
+
+ static void gles2_APIENTRY s_glGetUniformfv(void* self, GLuint program, GLint location, GLfloat* params);
+ static void gles2_APIENTRY s_glGetUniformiv(void* self, GLuint program, GLint location, GLint* params);
+ static GLint gles2_APIENTRY s_glGetUniformLocation(void* self, GLuint program, const GLchar* name);
+
+ static void gles2_APIENTRY s_glGetProgramBinaryOES(void* self, GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary);
+ static void gles2_APIENTRY s_glProgramBinaryOES(void* self, GLuint program, GLenum binaryFormat, const GLvoid* binary, GLint length);
+
+ static void gles2_APIENTRY s_glUniformBlockBinding(void* self, GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+ static GLuint gles2_APIENTRY s_glGetUniformBlockIndex(void* self, GLuint program, const GLchar* uniformBlockName);
+ static void gles2_APIENTRY s_glGetUniformIndicesAEMU(void* self, GLuint program, GLsizei uniformCount, const GLchar* packedNames, GLsizei packedLen, GLuint* uniformIndices);
+
+ static void gles2_APIENTRY s_glGetActiveUniformBlockiv(void* self, GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
+ static void gles2_APIENTRY s_glGetActiveUniformBlockName(void* self, GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);
+
+ static void gles2_APIENTRY s_glGetUniformuiv(void* self, GLuint program, GLint location, GLuint *params);
+ static void gles2_APIENTRY s_glGetActiveUniformsiv(void* self, GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);
+
+ static void gles2_APIENTRY s_glTransformFeedbackVaryings(void* self, GLuint program, GLsizei count, const char ** varyings, GLenum bufferMode);
+ static void gles2_APIENTRY s_glTransformFeedbackVaryingsAEMU(void* self, GLuint program, GLsizei count, const char* packedVaryings, GLuint packedVaryingsLen, GLenum bufferMode);
+ static void gles2_APIENTRY s_glGetTransformFeedbackVarying(void* self, GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLsizei * size, GLenum * type, char * name);
+
+ static void gles2_APIENTRY s_glProgramParameteri(void* self, GLuint program, GLenum pname, GLint value);
+ static void gles2_APIENTRY s_glProgramBinary(void* self, GLuint program, GLenum binaryFormat, const void *binary, GLsizei length);
+ static void gles2_APIENTRY s_glGetProgramBinary(void* self, GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
+
+ static GLint gles2_APIENTRY s_glGetFragDataLocation(void* self, GLuint program, const char * name);
+
+ static void gles2_APIENTRY s_glUseProgramStages(void* self, GLuint pipeline, GLbitfield stages, GLuint program);
+ static void gles2_APIENTRY s_glActiveShaderProgram(void* self, GLuint pipeline, GLuint program);
+
+ static void gles2_APIENTRY s_glProgramUniform1f(void* self, GLuint program, GLint location, GLfloat v0);
+ static void gles2_APIENTRY s_glProgramUniform2f(void* self, GLuint program, GLint location, GLfloat v0, GLfloat v1);
+ static void gles2_APIENTRY s_glProgramUniform3f(void* self, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+ static void gles2_APIENTRY s_glProgramUniform4f(void* self, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+ static void gles2_APIENTRY s_glProgramUniform1i(void* self, GLuint program, GLint location, GLint v0);
+ static void gles2_APIENTRY s_glProgramUniform2i(void* self, GLuint program, GLint location, GLint v0, GLint v1);
+ static void gles2_APIENTRY s_glProgramUniform3i(void* self, GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+ static void gles2_APIENTRY s_glProgramUniform4i(void* self, GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+ static void gles2_APIENTRY s_glProgramUniform1ui(void* self, GLuint program, GLint location, GLuint v0);
+ static void gles2_APIENTRY s_glProgramUniform2ui(void* self, GLuint program, GLint location, GLint v0, GLuint v1);
+ static void gles2_APIENTRY s_glProgramUniform3ui(void* self, GLuint program, GLint location, GLint v0, GLint v1, GLuint v2);
+ static void gles2_APIENTRY s_glProgramUniform4ui(void* self, GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLuint v3);
+ static void gles2_APIENTRY s_glProgramUniform1fv(void* self, GLuint program, GLint location, GLsizei count, const GLfloat *value);
+ static void gles2_APIENTRY s_glProgramUniform2fv(void* self, GLuint program, GLint location, GLsizei count, const GLfloat *value);
+ static void gles2_APIENTRY s_glProgramUniform3fv(void* self, GLuint program, GLint location, GLsizei count, const GLfloat *value);
+ static void gles2_APIENTRY s_glProgramUniform4fv(void* self, GLuint program, GLint location, GLsizei count, const GLfloat *value);
+ static void gles2_APIENTRY s_glProgramUniform1iv(void* self, GLuint program, GLint location, GLsizei count, const GLint *value);
+ static void gles2_APIENTRY s_glProgramUniform2iv(void* self, GLuint program, GLint location, GLsizei count, const GLint *value);
+ static void gles2_APIENTRY s_glProgramUniform3iv(void* self, GLuint program, GLint location, GLsizei count, const GLint *value);
+ static void gles2_APIENTRY s_glProgramUniform4iv(void* self, GLuint program, GLint location, GLsizei count, const GLint *value);
+ static void gles2_APIENTRY s_glProgramUniform1uiv(void* self, GLuint program, GLint location, GLsizei count, const GLuint *value);
+ static void gles2_APIENTRY s_glProgramUniform2uiv(void* self, GLuint program, GLint location, GLsizei count, const GLuint *value);
+ static void gles2_APIENTRY s_glProgramUniform3uiv(void* self, GLuint program, GLint location, GLsizei count, const GLuint *value);
+ static void gles2_APIENTRY s_glProgramUniform4uiv(void* self, GLuint program, GLint location, GLsizei count, const GLuint *value);
+ static void gles2_APIENTRY s_glProgramUniformMatrix2fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+ static void gles2_APIENTRY s_glProgramUniformMatrix3fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+ static void gles2_APIENTRY s_glProgramUniformMatrix4fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+ static void gles2_APIENTRY s_glProgramUniformMatrix2x3fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+ static void gles2_APIENTRY s_glProgramUniformMatrix3x2fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+ static void gles2_APIENTRY s_glProgramUniformMatrix2x4fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+ static void gles2_APIENTRY s_glProgramUniformMatrix4x2fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+ static void gles2_APIENTRY s_glProgramUniformMatrix3x4fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+ static void gles2_APIENTRY s_glProgramUniformMatrix4x3fv(void* self, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+
+ static void gles2_APIENTRY s_glGetProgramInterfaceiv(void* self, GLuint program, GLenum programInterface, GLenum pname, GLint * params);
+ static void gles2_APIENTRY s_glGetProgramResourceiv(void* self, GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum * props, GLsizei bufSize, GLsizei * length, GLint * params);
+ static GLuint gles2_APIENTRY s_glGetProgramResourceIndex(void* self, GLuint program, GLenum programInterface, const char * name);
+ static GLint gles2_APIENTRY s_glGetProgramResourceLocation(void* self, GLuint program, GLenum programInterface, const char * name);
+ static void gles2_APIENTRY s_glGetProgramResourceName(void* self, GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei * length, char * name);
+
+};
+#endif
diff --git a/stream-servers/libGLSnapshot/CMakeLists.txt b/stream-servers/libGLSnapshot/CMakeLists.txt
new file mode 100644
index 00000000..5122d4b7
--- /dev/null
+++ b/stream-servers/libGLSnapshot/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_library(GLSnapshot GLSnapshot.cpp)
+target_link_libraries(GLSnapshot PUBLIC apigen-codec-common)
+target_include_directories(GLSnapshot PUBLIC
+ ${GFXSTREAM_REPO_ROOT}/stream-servers/libGLSnapshot
+ ${GFXSTREAM_REPO_ROOT}/include
+ ${GFXSTREAM_REPO_ROOT}/stream-servers
+ ${GFXSTREAM_REPO_ROOT}/stream-servers/OpenGLESDispatch)
diff --git a/stream-servers/libGLSnapshot/GLSnapshot.cpp b/stream-servers/libGLSnapshot/GLSnapshot.cpp
new file mode 100644
index 00000000..69596541
--- /dev/null
+++ b/stream-servers/libGLSnapshot/GLSnapshot.cpp
@@ -0,0 +1,130 @@
+#include "GLSnapshot.h"
+
+#include <GLES2/gl2.h>
+#include <GLES3/gl31.h>
+
+#include <stdio.h>
+
+#define DEBUG 0
+
+#if DEBUG
+
+#define D(fmt,...) do { \
+ fprintf(stderr, "%s:%s:%d: " fmt "\n", __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
+} while(0) \
+
+#else
+#define D(...)
+#endif
+
+namespace GLSnapshot {
+
+GLSnapshotState::GLSnapshotState(const GLESv2Dispatch* gl) : mGL(gl) {
+ D("init snapshot state");
+}
+
+void GLSnapshotState::getGlobalStateEnum(GLenum name, int size) {
+ D("save 0x%x", name);
+ std::vector<GLenum>& store = mGlobals[name].enums;
+ store.resize(size);
+ mGL->glGetIntegerv(name, (GLint*)&store[0]);
+}
+
+void GLSnapshotState::getGlobalStateByte(GLenum name, int size) {
+ D("save 0x%x", name);
+ std::vector<unsigned char>& store = mGlobals[name].bytes;
+ store.resize(size);
+ mGL->glGetBooleanv(name, (GLboolean*)&store[0]);
+}
+
+void GLSnapshotState::getGlobalStateInt(GLenum name, int size) {
+ D("save 0x%x", name);
+ std::vector<uint32_t>& store = mGlobals[name].ints;
+ store.resize(size);
+ mGL->glGetIntegerv(name, (GLint*)&store[0]);
+}
+
+void GLSnapshotState::getGlobalStateFloat(GLenum name, int size) {
+ D("save 0x%x", name);
+ std::vector<float>& store = mGlobals[name].floats;
+ store.resize(size);
+ mGL->glGetFloatv(name, (GLfloat*)&store[0]);
+}
+
+void GLSnapshotState::getGlobalStateInt64(GLenum name, int size) {
+ D("save 0x%x", name);
+ std::vector<uint64_t>& store = mGlobals[name].int64s;
+ store.resize(size);
+ mGL->glGetInteger64v(name, (GLint64*)&store[0]);
+}
+
+void GLSnapshotState::getGlobalStateEnable(GLenum name) {
+ D("save 0x%x", name);
+ mEnables[name] = mGL->glIsEnabled(name) == GL_TRUE;
+}
+
+void GLSnapshotState::save() {
+ getGlobalStateEnable(GL_DEPTH_TEST);
+
+ getGlobalStateFloat(GL_COLOR_CLEAR_VALUE, 4);
+ getGlobalStateInt(GL_ACTIVE_TEXTURE, 1);
+}
+
+void GLSnapshotState::restore() {
+ for (const auto& it : mEnables) {
+ if (it.second) {
+ mGL->glEnable(it.first);
+ } else {
+ mGL->glDisable(it.first);
+ }
+ }
+
+ for (auto& it: mProgramNames) {
+ GLShaderState& shaderState = mShaderState[it.first];
+ it.second = mGL->glCreateShader(shaderState.type);
+ if (shaderState.source.size()) {
+ GLint len = shaderState.source.size();
+ const char* source = shaderState.source.c_str();
+ const char** sources = &source;
+ mGL->glShaderSource(it.second, 1, sources, &len);
+ }
+ if (shaderState.compileStatus) {
+ mGL->glCompileShader(it.second);
+ }
+ }
+
+ std::vector<float> clearColor = mGlobals[GL_COLOR_CLEAR_VALUE].floats;
+ mGL->glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
+
+ mGL->glActiveTexture(mGlobals[GL_ACTIVE_TEXTURE].ints[0]);
+}
+
+GLuint GLSnapshotState::createShader(GLuint shader, GLenum shaderType) {
+ GLuint shaderName = mProgramCounter++;
+ mProgramNames[shaderName] = shader;
+ mProgramNamesBack[shader] = shaderName;
+ mShaderState[shaderName].type = shaderType;
+ mShaderState[shaderName].source = "";
+ mShaderState[shaderName].compileStatus = false;
+ return shaderName;
+}
+
+GLuint GLSnapshotState::createProgram(GLuint program) {
+ return program;
+}
+
+
+void GLSnapshotState::shaderString(GLuint shader, const GLchar* string) {
+ mShaderState[mProgramNamesBack[shader]].source = std::string(string);
+
+}
+
+void GLSnapshotState::genBuffers(GLsizei n, GLuint* buffers) {
+ return;
+}
+
+GLuint GLSnapshotState::getProgramName(GLuint name) {
+ return mProgramNames[name];
+}
+
+} // namespace GLSnapshot
diff --git a/stream-servers/libGLSnapshot/GLSnapshot.h b/stream-servers/libGLSnapshot/GLSnapshot.h
new file mode 100644
index 00000000..fae68cc4
--- /dev/null
+++ b/stream-servers/libGLSnapshot/GLSnapshot.h
@@ -0,0 +1,73 @@
+#pragma once
+
+#include "GLESv2Dispatch.h"
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include <inttypes.h>
+
+#include <GLES2/gl2.h>
+
+namespace GLSnapshot {
+
+struct GLValue {
+ std::vector<GLenum> enums;
+ std::vector<unsigned char> bytes;
+ std::vector<uint16_t> shorts;
+ std::vector<uint32_t> ints;
+ std::vector<float> floats;
+ std::vector<uint64_t> int64s;
+};
+
+typedef std::map<GLenum, GLValue> GlobalStateMap;
+typedef std::map<GLenum, bool> GlobalEnables;
+
+struct GLShaderState {
+ GLenum type;
+ std::string source;
+ bool compileStatus;
+};
+
+struct GLProgramState {
+ std::map<GLenum, GLuint> linkage;
+ bool linkStatus;
+};
+
+class GLSnapshotState {
+public:
+ GLSnapshotState(const GLESv2Dispatch* gl);
+ void save();
+ void restore();
+
+ // Shaders
+ GLuint createShader(GLuint shader, GLenum shaderType);
+ GLuint createProgram(GLuint program);
+ void shaderString(GLuint shader, const GLchar* string);
+ void genBuffers(GLsizei n, GLuint* buffers);
+ GLuint getProgramName(GLuint name);
+
+private:
+ void getGlobalStateEnum(GLenum name, int size);
+ void getGlobalStateByte(GLenum name, int size);
+ void getGlobalStateInt(GLenum name, int size);
+ void getGlobalStateFloat(GLenum name, int size);
+ void getGlobalStateInt64(GLenum name, int size);
+
+ void getGlobalStateEnable(GLenum name);
+
+ const GLESv2Dispatch* mGL;
+ GlobalStateMap mGlobals;
+ GlobalEnables mEnables;
+
+ GLuint mProgramCounter = 1;
+
+ std::map<GLuint, GLuint> mProgramNames;
+ std::map<GLuint, GLuint> mProgramNamesBack;
+ std::map<GLuint, GLShaderState> mShaderState;
+ std::map<GLuint, GLProgramState> mShaderProgramState;
+
+};
+
+} // namespace GLSnapshot