summaryrefslogtreecommitdiff
path: root/src/VBox/GuestHost/OpenGL/include
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2014-03-26 19:21:20 +0000
committer <>2014-05-08 15:03:54 +0000
commitfb123f93f9f5ce42c8e5785d2f8e0edaf951740e (patch)
treec2103d76aec5f1f10892cd1d3a38e24f665ae5db /src/VBox/GuestHost/OpenGL/include
parent58ed4748338f9466599adfc8a9171280ed99e23f (diff)
downloadVirtualBox-master.tar.gz
Imported from /home/lorry/working-area/delta_VirtualBox/VirtualBox-4.3.10.tar.bz2.HEADVirtualBox-4.3.10master
Diffstat (limited to 'src/VBox/GuestHost/OpenGL/include')
-rw-r--r--src/VBox/GuestHost/OpenGL/include/GL/glext.h122
-rw-r--r--src/VBox/GuestHost/OpenGL/include/chromium.h45
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_blitter.h323
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_bmpscale.h25
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_compositor.h233
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_dump.h177
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_error.h19
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_extstring.h4
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_glext.h34
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_glstate.h65
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_hash.h22
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_htable.h120
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_pack.h22
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_pixeldata.h3
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_protocol.h46
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_server.h287
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_string.h24
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_version.h39
-rw-r--r--src/VBox/GuestHost/OpenGL/include/cr_vreg.h377
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h12
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h5
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_client.h6
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h14
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h3
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_point.h3
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h84
-rw-r--r--src/VBox/GuestHost/OpenGL/include/state/cr_texture.h4
27 files changed, 1952 insertions, 166 deletions
diff --git a/src/VBox/GuestHost/OpenGL/include/GL/glext.h b/src/VBox/GuestHost/OpenGL/include/GL/glext.h
index 90cd2c01..7f754544 100644
--- a/src/VBox/GuestHost/OpenGL/include/GL/glext.h
+++ b/src/VBox/GuestHost/OpenGL/include/GL/glext.h
@@ -3722,29 +3722,17 @@ typedef ptrdiff_t GLintptrARB;
typedef ptrdiff_t GLsizeiptrARB;
#endif
-/* VBox: HACK ALERT! When building the host side against Mac OS X 10.7 headers,
- /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gltypes.h
- is included and it typedefs GLhandleARB differently. In 10.6 and earlier,
- gl.h was included instead of gltypes.h (new file) avoiding the conflicting
- typedef in Headers/glext.h.
-
- Since sizeof the gltypes.h typedef is 64-bit on 64-bit platforms, we're in
- trouble if the type is used for anything important. Fortunately, the
- conflict only occurs in three files: renderspu_config.c, renderspu_cocoa.c
- and renderspu_cocoa_helper.m. */
-#ifdef RT_OS_DARWIN
-# ifndef MAC_OS_X_VERSION_MIN_REQUIRED
-# error "MAC_OS_X_VERSION_MIN_REQUIRED is not defined"
-# endif
-# if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 && defined(__gltypes_h_)
-# define GLhandleARB VBoxGLhandleARB
-# endif
-#endif
-
#ifndef GL_ARB_shader_objects
/* GL types for handling shader object handles and program/shader text */
typedef char GLcharARB; /* native character */
-typedef unsigned int GLhandleARB; /* shader object handle */
+typedef unsigned int VBoxGLhandleARB; /* shader object handle */
+# ifdef RT_OS_DARWIN
+typedef void* GLhandleARB; /* shader object handle */
+# else
+typedef unsigned int GLhandleARB; /* native shader object handle */
+# endif
+#else
+# error "GL_ARB_shader_objects should NOT be defined here!!"
#endif
/* GL types for "half" precision (s10e5) float data in host memory */
@@ -4770,17 +4758,17 @@ typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname,
#ifndef GL_ARB_shader_objects
#define GL_ARB_shader_objects 1
#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB);
-GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum);
-GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB);
-GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum);
-GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *);
-GLAPI void APIENTRY glCompileShaderARB (GLhandleARB);
-GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void);
-GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB);
-GLAPI void APIENTRY glLinkProgramARB (GLhandleARB);
-GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB);
-GLAPI void APIENTRY glValidateProgramARB (GLhandleARB);
+GLAPI void APIENTRY glDeleteObjectARB (VBoxGLhandleARB);
+GLAPI VBoxGLhandleARB APIENTRY glGetHandleARB (GLenum);
+GLAPI void APIENTRY glDetachObjectARB (VBoxGLhandleARB, VBoxGLhandleARB);
+GLAPI VBoxGLhandleARB APIENTRY glCreateShaderObjectARB (GLenum);
+GLAPI void APIENTRY glShaderSourceARB (VBoxGLhandleARB, GLsizei, const GLcharARB* *, const GLint *);
+GLAPI void APIENTRY glCompileShaderARB (VBoxGLhandleARB);
+GLAPI VBoxGLhandleARB APIENTRY glCreateProgramObjectARB (void);
+GLAPI void APIENTRY glAttachObjectARB (VBoxGLhandleARB, VBoxGLhandleARB);
+GLAPI void APIENTRY glLinkProgramARB (VBoxGLhandleARB);
+GLAPI void APIENTRY glUseProgramObjectARB (VBoxGLhandleARB);
+GLAPI void APIENTRY glValidateProgramARB (VBoxGLhandleARB);
GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat);
GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat);
GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat);
@@ -4800,27 +4788,27 @@ GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *);
GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
-GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *);
-GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
-GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *);
-GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *);
-GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
-GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *);
-GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *);
-GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);
-typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname);
-typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj);
-typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);
-typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
-typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj);
-typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void);
-typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj);
-typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj);
-typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj);
-typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);
+GLAPI void APIENTRY glGetObjectParameterfvARB (VBoxGLhandleARB, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetObjectParameterivARB (VBoxGLhandleARB, GLenum, GLint *);
+GLAPI void APIENTRY glGetInfoLogARB (VBoxGLhandleARB, GLsizei, GLsizei *, GLcharARB *);
+GLAPI void APIENTRY glGetAttachedObjectsARB (VBoxGLhandleARB, GLsizei, GLsizei *, VBoxGLhandleARB *);
+GLAPI GLint APIENTRY glGetUniformLocationARB (VBoxGLhandleARB, const GLcharARB *);
+GLAPI void APIENTRY glGetActiveUniformARB (VBoxGLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
+GLAPI void APIENTRY glGetUniformfvARB (VBoxGLhandleARB, GLint, GLfloat *);
+GLAPI void APIENTRY glGetUniformivARB (VBoxGLhandleARB, GLint, GLint *);
+GLAPI void APIENTRY glGetShaderSourceARB (VBoxGLhandleARB, GLsizei, GLsizei *, GLcharARB *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (VBoxGLhandleARB obj);
+typedef VBoxGLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname);
+typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (VBoxGLhandleARB containerObj, VBoxGLhandleARB attachedObj);
+typedef VBoxGLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);
+typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (VBoxGLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
+typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (VBoxGLhandleARB shaderObj);
+typedef VBoxGLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void);
+typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (VBoxGLhandleARB containerObj, VBoxGLhandleARB obj);
+typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (VBoxGLhandleARB programObj);
+typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (VBoxGLhandleARB programObj);
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (VBoxGLhandleARB programObj);
typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);
typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);
typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
@@ -4840,27 +4828,27 @@ typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count,
typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
-typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
-typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
-typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params);
-typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (VBoxGLhandleARB obj, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (VBoxGLhandleARB obj, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (VBoxGLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
+typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (VBoxGLhandleARB containerObj, GLsizei maxCount, GLsizei *count, VBoxGLhandleARB *obj);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (VBoxGLhandleARB programObj, const GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (VBoxGLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (VBoxGLhandleARB programObj, GLint location, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (VBoxGLhandleARB programObj, GLint location, GLint *params);
+typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (VBoxGLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
#endif
#ifndef GL_ARB_vertex_shader
#define GL_ARB_vertex_shader 1
#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *);
-GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
-GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *);
+GLAPI void APIENTRY glBindAttribLocationARB (VBoxGLhandleARB, GLuint, const GLcharARB *);
+GLAPI void APIENTRY glGetActiveAttribARB (VBoxGLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
+GLAPI GLint APIENTRY glGetAttribLocationARB (VBoxGLhandleARB, const GLcharARB *);
#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name);
-typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
-typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
+typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (VBoxGLhandleARB programObj, GLuint index, const GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (VBoxGLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (VBoxGLhandleARB programObj, const GLcharARB *name);
#endif
#ifndef GL_ARB_fragment_shader
diff --git a/src/VBox/GuestHost/OpenGL/include/chromium.h b/src/VBox/GuestHost/OpenGL/include/chromium.h
index f316e23a..4e1ed628 100644
--- a/src/VBox/GuestHost/OpenGL/include/chromium.h
+++ b/src/VBox/GuestHost/OpenGL/include/chromium.h
@@ -21,24 +21,24 @@
#include "cr_compiler.h"
#ifdef IN_RING0
-#include <common/VBoxMPUtils.h>
-#define WINGDIAPI
+# include <common/VBoxMPUtils.h>
+# define WINGDIAPI
#endif
/*
* We effectively wrap gl.h, glu.h, etc, just like GLUT
*/
#ifndef GL_GLEXT_PROTOTYPES
-#define GL_GLEXT_PROTOTYPES
+# define GL_GLEXT_PROTOTYPES
#endif
#if defined(WINDOWS)
# ifdef IN_RING0
# error "should not happen!"
# endif
-#define WIN32_LEAN_AND_MEAN
-#define WGL_APIENTRY __stdcall
-#include <windows.h>
+# define WIN32_LEAN_AND_MEAN
+# define WGL_APIENTRY __stdcall
+# include <windows.h>
#elif defined(DARWIN)
/* nothing */
#else
@@ -55,23 +55,23 @@
#ifdef GLX
-#ifndef GLX_GLXEXT_PROTOTYPES
-#define GLX_GLXEXT_PROTOTYPES
-#endif
-#include <GL/glx.h>
+# ifndef GLX_GLXEXT_PROTOTYPES
+# define GLX_GLXEXT_PROTOTYPES
+# endif
+# include <GL/glx.h>
#endif
#ifdef USE_OSMESA
-#include <GL/osmesa.h>
+# include <GL/osmesa.h>
#endif
#ifdef DARWIN
-#include <stddef.h>
+# include <stddef.h>
#elif !defined(FreeBSD)
-#include <malloc.h> /* to get ptrdiff_t used below */
+# include <malloc.h> /* to get ptrdiff_t used below */
#endif
-#include <GL/glext.h>
+#include "cr_glext.h"
#ifdef __cplusplus
extern "C" {
@@ -79,6 +79,11 @@ extern "C" {
/* to shut up gcc warning for struct VBOXUHGSMI * parameters */
struct VBOXUHGSMI;
+struct VBOXVR_SCR_COMPOSITOR;
+struct VBOXVR_SCR_COMPOSITOR_ENTRY;
+
+#define CR_RENDER_DEFAULT_CONTEXT_ID (INT32_MAX-1)
+#define CR_RENDER_DEFAULT_WINDOW_ID (INT32_MAX-1)
#if defined(IN_GUEST) && (WINDOWS) && defined(VBOX_WITH_WDDM)
# ifdef VBOX_WDDM_WOW64
@@ -607,6 +612,7 @@ extern void APIENTRY glGetChromiumParametervCR(GLenum target, GLuint index, GLen
#define GL_WINDOW_SIZE_CR 0x8B06
#define GL_MAX_WINDOW_SIZE_CR 0x8B24 /* new */
+#define GL_WINDOW_VISIBILITY_CR 0x8B25 /* new */
#endif /* GL_CR_window_size */
@@ -714,7 +720,13 @@ extern void APIENTRY glZPixCR(GLsizei width, GLsizei height, GLenum format,
/*report that the shared resource is no longer used by this context, the parameter value is a texture name*/
#define GL_RCUSAGE_TEXTURE_CLEAR_CR 0x8B2A
/*configures host to create windows initially hidden*/
-#define GL_HOST_WND_CREATED_HIDDEN 0x8B2B
+#define GL_HOST_WND_CREATED_HIDDEN_CR 0x8B2B
+/* guest requests host whether e debug break is needed*/
+#define GL_DBG_CHECK_BREAK_CR 0x8B2C
+/* Tells renderspu the default context id being used by the crserver */
+#define GL_HH_SET_DEFAULT_SHARED_CTX 0x8B2D
+
+#define GL_HH_SET_TMPCTX_MAKE_CURRENT 0x8B2E
/**********************************************************************/
/***** Chromium-specific API *****/
@@ -765,8 +777,9 @@ extern GLint APIENTRY crWindowCreate(const char *dpyName, GLint visBits);
extern void APIENTRY crWindowDestroy(GLint window);
extern void APIENTRY crWindowSize(GLint window, GLint w, GLint h);
extern void APIENTRY crWindowPosition(GLint window, GLint x, GLint y);
-extern void APIENTRY crWindowVisibleRegion( GLint window, GLint cRects, void *pRects );
+extern void APIENTRY crWindowVisibleRegion( GLint window, GLint cRects, const void *pRects );
extern void APIENTRY crWindowShow( GLint window, GLint flag );
+extern void APIENTRY crVBoxTexPresent(GLuint texture, GLuint cfg, GLint xPos, GLint yPos, GLint cRects, const GLint *pRects);
typedef int (CR_APIENTRY *CR_PROC)();
CR_PROC APIENTRY crGetProcAddress( const char *name );
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_blitter.h b/src/VBox/GuestHost/OpenGL/include/cr_blitter.h
new file mode 100644
index 00000000..2a01d3b6
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/cr_blitter.h
@@ -0,0 +1,323 @@
+/* $Id$ */
+
+/** @file
+ * Blitter API
+ */
+/*
+ * Copyright (C) 2013 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+#ifndef ___cr_blitter_h__
+#define ___cr_blitter_h__
+
+#include <iprt/cdefs.h>
+#include <iprt/asm.h>
+#include "cr_spu.h"
+#include "cr_vreg.h"
+
+#ifndef IN_RING0
+# define VBOXBLITTERDECL(_type) DECLEXPORT(_type)
+#else
+# define VBOXBLITTERDECL(_type) RTDECL(_type)
+#endif
+
+RT_C_DECLS_BEGIN
+/* GLSL Cache */
+typedef struct CR_GLSL_CACHE
+{
+ int iGlVersion;
+ GLuint uNoAlpha2DProg;
+ GLuint uNoAlpha2DRectProg;
+ SPUDispatchTable *pDispatch;
+} CR_GLSL_CACHE;
+
+DECLINLINE(void) CrGlslInit(CR_GLSL_CACHE *pCache, SPUDispatchTable *pDispatch)
+{
+ memset(pCache, 0, sizeof (*pCache));
+ pCache->pDispatch = pDispatch;
+}
+
+DECLINLINE(bool) CrGlslIsInited(const CR_GLSL_CACHE *pCache)
+{
+ return !!pCache->pDispatch;
+}
+
+/* clients should set proper context before calling these funcs */
+VBOXBLITTERDECL(bool) CrGlslIsSupported(CR_GLSL_CACHE *pCache);
+VBOXBLITTERDECL(int) CrGlslProgGenAllNoAlpha(CR_GLSL_CACHE *pCache);
+VBOXBLITTERDECL(int) CrGlslProgGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget);
+VBOXBLITTERDECL(int) CrGlslProgUseGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget);
+VBOXBLITTERDECL(int) CrGlslProgUseNoAlpha(const CR_GLSL_CACHE *pCache, GLenum enmTexTarget);
+VBOXBLITTERDECL(void) CrGlslProgClear(const CR_GLSL_CACHE *pCache);
+VBOXBLITTERDECL(bool) CrGlslNeedsCleanup(const CR_GLSL_CACHE *pCache);
+VBOXBLITTERDECL(void) CrGlslCleanup(CR_GLSL_CACHE *pCache);
+VBOXBLITTERDECL(void) CrGlslTerm(CR_GLSL_CACHE *pCache);
+
+/* BLITTER */
+typedef struct CR_BLITTER_BUFFER
+{
+ GLuint cbBuffer;
+ GLvoid * pvBuffer;
+} CR_BLITTER_BUFFER, *PCR_BLITTER_BUFFER;
+
+typedef union CR_BLITTER_FLAGS
+{
+ struct
+ {
+ uint32_t Initialized : 1;
+ uint32_t CtxCreated : 1;
+ uint32_t SupportsFBO : 1;
+ uint32_t SupportsPBO : 1;
+ uint32_t CurrentMuralChanged : 1;
+ uint32_t LastWasFBODraw : 1;
+ uint32_t ForceDrawBlit : 1;
+ uint32_t ShadersGloal : 1;
+ uint32_t Reserved : 24;
+ };
+ uint32_t Value;
+} CR_BLITTER_FLAGS, *PCR_BLITTER_FLAGS;
+
+struct CR_BLITTER;
+
+typedef DECLCALLBACK(int) FNCRBLT_BLITTER(struct CR_BLITTER *pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRect, const RTRECTSIZE *pDstSize, const RTRECT *paDstRect, uint32_t cRects, uint32_t fFlags);
+typedef FNCRBLT_BLITTER *PFNCRBLT_BLITTER;
+
+typedef struct CR_BLITTER_SPUITEM
+{
+ int id;
+ GLint visualBits;
+} CR_BLITTER_SPUITEM, *PCR_BLITTER_SPUITEM;
+
+typedef struct CR_BLITTER_CONTEXT
+{
+ CR_BLITTER_SPUITEM Base;
+} CR_BLITTER_CONTEXT, *PCR_BLITTER_CONTEXT;
+
+typedef struct CR_BLITTER_WINDOW
+{
+ CR_BLITTER_SPUITEM Base;
+ GLuint width, height;
+} CR_BLITTER_WINDOW, *PCR_BLITTER_WINDOW;
+
+typedef struct CR_BLITTER_IMG
+{
+ void *pvData;
+ GLuint cbData;
+ GLenum enmFormat;
+ GLuint width, height;
+ GLuint bpp;
+ GLuint pitch;
+} CR_BLITTER_IMG, *PCR_BLITTER_IMG;
+
+typedef struct CR_BLITTER
+{
+ GLuint idFBO;
+ CR_BLITTER_FLAGS Flags;
+ uint32_t cEnters;
+ PFNCRBLT_BLITTER pfnBlt;
+ CR_BLITTER_BUFFER Verticies;
+ CR_BLITTER_BUFFER Indicies;
+ RTRECTSIZE CurrentSetSize;
+ CR_BLITTER_WINDOW CurrentMural;
+ CR_BLITTER_CONTEXT CtxInfo;
+ int32_t i32MakeCurrentUserData;
+ SPUDispatchTable *pDispatch;
+ const CR_GLSL_CACHE *pGlslCache;
+ CR_GLSL_CACHE LocalGlslCache;
+} CR_BLITTER, *PCR_BLITTER;
+
+DECLINLINE(GLboolean) CrBltIsInitialized(PCR_BLITTER pBlitter)
+{
+ return !!pBlitter->pDispatch;
+}
+
+VBOXBLITTERDECL(int) CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, bool fCreateNewCtx, bool fForceDrawBlt, const CR_GLSL_CACHE *pShaders, SPUDispatchTable *pDispatch);
+
+VBOXBLITTERDECL(void) CrBltTerm(PCR_BLITTER pBlitter);
+
+VBOXBLITTERDECL(int) CrBltCleanup(PCR_BLITTER pBlitter);
+
+DECLINLINE(GLboolean) CrBltSupportsTexTex(PCR_BLITTER pBlitter)
+{
+ return pBlitter->Flags.SupportsFBO;
+}
+
+DECLINLINE(GLboolean) CrBltIsEntered(PCR_BLITTER pBlitter)
+{
+ return !!pBlitter->cEnters;
+}
+
+DECLINLINE(GLint) CrBltGetVisBits(PCR_BLITTER pBlitter)
+{
+ return pBlitter->CtxInfo.Base.visualBits;
+}
+
+
+DECLINLINE(GLboolean) CrBltIsEverEntered(PCR_BLITTER pBlitter)
+{
+ return !!pBlitter->Flags.Initialized;
+}
+
+DECLINLINE(void) CrBltSetMakeCurrentUserData(PCR_BLITTER pBlitter, int32_t i32MakeCurrentUserData)
+{
+ pBlitter->i32MakeCurrentUserData = i32MakeCurrentUserData;
+}
+
+VBOXBLITTERDECL(int) CrBltMuralSetCurrentInfo(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural);
+DECLINLINE(const CR_BLITTER_WINDOW *) CrBltMuralGetCurrentInfo(PCR_BLITTER pBlitter)
+{
+ return &pBlitter->CurrentMural;
+}
+
+VBOXBLITTERDECL(void) CrBltCheckUpdateViewport(PCR_BLITTER pBlitter);
+
+VBOXBLITTERDECL(void) CrBltLeave(PCR_BLITTER pBlitter);
+VBOXBLITTERDECL(int) CrBltEnter(PCR_BLITTER pBlitter);
+VBOXBLITTERDECL(void) CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags);
+VBOXBLITTERDECL(void) CrBltBlitTexTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *pSrcRect, const VBOXVR_TEXTURE *pDst, const RTRECT *pDstRect, uint32_t cRects, uint32_t fFlags);
+VBOXBLITTERDECL(int) CrBltImgGetTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, GLenum enmFormat, CR_BLITTER_IMG *pDst);
+
+VBOXBLITTERDECL(int) CrBltImgGetMural(PCR_BLITTER pBlitter, bool fBb, CR_BLITTER_IMG *pDst);
+VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, CR_BLITTER_IMG *pDst);
+VBOXBLITTERDECL(void) CrBltPresent(PCR_BLITTER pBlitter);
+/* */
+struct CR_TEXDATA;
+
+typedef DECLCALLBACK(void) FNCRTEXDATA_RELEASED(struct CR_TEXDATA *pTexture);
+typedef FNCRTEXDATA_RELEASED *PFNCRTEXDATA_RELEASED;
+
+typedef union CR_TEXDATA_FLAGS
+{
+ struct
+ {
+ uint32_t DataValid : 1;
+ uint32_t DataAcquired : 1;
+ uint32_t DataInverted : 1;
+ uint32_t Entered : 1;
+ uint32_t Reserved : 28;
+ };
+ uint32_t Value;
+} CR_TEXDATA_FLAGS, *PCR_TEXDATA_FLAGS;
+
+
+typedef struct CR_TEXDATA
+{
+ VBOXVR_TEXTURE Tex;
+ volatile uint32_t cRefs;
+ /* fields specific to texture data download */
+ uint32_t idInvertTex;
+ uint32_t idPBO;
+ CR_TEXDATA_FLAGS Flags;
+ PCR_BLITTER pBlitter;
+ CR_BLITTER_IMG Img;
+ /*dtor*/
+ PFNCRTEXDATA_RELEASED pfnTextureReleased;
+ struct CR_TEXDATA *pScaledCache;
+} CR_TEXDATA, *PCR_TEXDATA;
+
+DECLINLINE(void) CrTdInit(PCR_TEXDATA pTex, const VBOXVR_TEXTURE *pVrTex, PCR_BLITTER pBlitter, PFNCRTEXDATA_RELEASED pfnTextureReleased)
+{
+ memset(pTex, 0, sizeof (*pTex));
+ pTex->Tex = *pVrTex;
+ pTex->cRefs = 1;
+ pTex->pBlitter = pBlitter;
+ pTex->pfnTextureReleased = pfnTextureReleased;
+}
+
+DECLINLINE(const VBOXVR_TEXTURE*) CrTdTexGet(const CR_TEXDATA *pTex)
+{
+ return &pTex->Tex;
+}
+
+DECLINLINE(PCR_BLITTER) CrTdBlitterGet(CR_TEXDATA *pTex)
+{
+ return pTex->pBlitter;
+}
+
+DECLINLINE(int) CrTdBltEnter(PCR_TEXDATA pTex)
+{
+ int rc;
+ if (pTex->Flags.Entered)
+ return VERR_INVALID_STATE;
+ rc = CrBltEnter(pTex->pBlitter);
+ if (!RT_SUCCESS(rc))
+ {
+ WARN(("CrBltEnter failed rc %d", rc));
+ return rc;
+ }
+ pTex->Flags.Entered = 1;
+ return VINF_SUCCESS;
+}
+
+DECLINLINE(bool) CrTdBltIsEntered(PCR_TEXDATA pTex)
+{
+ return pTex->Flags.Entered;
+}
+
+DECLINLINE(void) CrTdBltLeave(PCR_TEXDATA pTex)
+{
+ if (!pTex->Flags.Entered)
+ {
+ WARN(("invalid Blt Leave"));
+ return;
+ }
+
+ CrBltLeave(pTex->pBlitter);
+
+ pTex->Flags.Entered = 0;
+}
+
+/* the CrTdBltXxx calls are done with the entered blitter */
+/* acquire the texture data, returns the cached data in case it is cached.
+ * the data remains cached in the CR_TEXDATA object until it is discarded with CrTdBltDataFree or CrTdBltDataCleanup.
+ * */
+VBOXBLITTERDECL(int) CrTdBltDataAcquire(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, const CR_BLITTER_IMG**ppImg);
+
+VBOXBLITTERDECL(int) CrTdBltDataAcquireScaled(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, uint32_t width, uint32_t height, const CR_BLITTER_IMG**ppImg);
+
+VBOXBLITTERDECL(int) CrTdBltDataReleaseScaled(PCR_TEXDATA pTex, const CR_BLITTER_IMG *pImg);
+
+VBOXBLITTERDECL(void) CrTdBltScaleCacheMoveTo(PCR_TEXDATA pTex, PCR_TEXDATA pDstTex);
+
+/* release the texture data, the data remains cached in the CR_TEXDATA object until it is discarded with CrTdBltDataFree or CrTdBltDataCleanup */
+VBOXBLITTERDECL(int) CrTdBltDataRelease(PCR_TEXDATA pTex);
+/* discard the texture data cached with previous CrTdBltDataAcquire.
+ * Must be called wit data released (CrTdBltDataRelease) */
+VBOXBLITTERDECL(int) CrTdBltDataFree(PCR_TEXDATA pTex);
+VBOXBLITTERDECL(int) CrTdBltDataFreeNe(PCR_TEXDATA pTex);
+VBOXBLITTERDECL(void) CrTdBltDataInvalidateNe(PCR_TEXDATA pTex);
+/* does same as CrTdBltDataFree, and in addition cleans up.
+ * this is kind of a texture destructor, which clients should call on texture object destruction, e.g. from the PFNCRTEXDATA_RELEASED callback */
+VBOXBLITTERDECL(int) CrTdBltDataCleanup(PCR_TEXDATA pTex);
+
+VBOXBLITTERDECL(int) CrTdBltDataCleanupNe(PCR_TEXDATA pTex);
+
+DECLINLINE(uint32_t) CrTdAddRef(PCR_TEXDATA pTex)
+{
+ return ASMAtomicIncU32(&pTex->cRefs);
+}
+
+DECLINLINE(uint32_t) CrTdRelease(PCR_TEXDATA pTex)
+{
+ uint32_t cRefs = ASMAtomicDecU32(&pTex->cRefs);
+ if (!cRefs)
+ {
+ if (pTex->pfnTextureReleased)
+ pTex->pfnTextureReleased(pTex);
+ else
+ CrTdBltDataCleanupNe(pTex);
+ }
+
+ return cRefs;
+}
+
+RT_C_DECLS_END
+
+#endif /* #ifndef ___cr_blitter_h__ */
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_bmpscale.h b/src/VBox/GuestHost/OpenGL/include/cr_bmpscale.h
new file mode 100644
index 00000000..fda56bac
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/cr_bmpscale.h
@@ -0,0 +1,25 @@
+#ifndef ___cr_bmpscale_h__
+#define ___cr_bmpscale_h__
+
+#include <iprt/types.h>
+#include <iprt/cdefs.h>
+
+
+RT_C_DECLS_BEGIN
+
+#ifndef IN_RING0
+# define VBOXBMPSCALEDECL(_type) DECLEXPORT(_type)
+#else
+# define VBOXBLITTERDECL(_type) RTDECL(_type)
+#endif
+
+VBOXBMPSCALEDECL(void) CrBmpScale32 (uint8_t *dst,
+ int iDstDeltaLine,
+ int dstW, int dstH,
+ const uint8_t *src,
+ int iSrcDeltaLine,
+ int srcW, int srcH);
+
+RT_C_DECLS_END
+
+#endif /* #ifndef ___cr_bmpscale_h__ */
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_compositor.h b/src/VBox/GuestHost/OpenGL/include/cr_compositor.h
new file mode 100644
index 00000000..4ad56936
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/cr_compositor.h
@@ -0,0 +1,233 @@
+/* $Id: cr_compositor.h $ */
+
+/** @file
+ * uint32_t compositor API
+ */
+
+/*
+ * Copyright (C) 2013 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+#ifndef ___cr_compositor_h_
+#define ___cr_compositor_h_
+#include <cr_vreg.h>
+#include <cr_blitter.h>
+
+/* Compositor with Stretching & Cached Rectangles info */
+
+RT_C_DECLS_BEGIN
+
+struct VBOXVR_SCR_COMPOSITOR_ENTRY;
+struct VBOXVR_SCR_COMPOSITOR;
+
+typedef DECLCALLBACK(void) FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED(const struct VBOXVR_SCR_COMPOSITOR *pCompositor, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry, struct VBOXVR_SCR_COMPOSITOR_ENTRY *pReplacingEntry);
+typedef FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED;
+
+
+typedef struct VBOXVR_SCR_COMPOSITOR_ENTRY
+{
+ VBOXVR_COMPOSITOR_ENTRY Ce;
+ RTRECT Rect;
+ uint32_t fChanged;
+ uint32_t fFlags;
+ uint32_t cRects;
+ PRTRECT paSrcRects;
+ PRTRECT paDstRects;
+ PRTRECT paDstUnstretchedRects;
+ PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased;
+ PCR_TEXDATA pTex;
+} VBOXVR_SCR_COMPOSITOR_ENTRY, *PVBOXVR_SCR_COMPOSITOR_ENTRY;
+
+typedef struct VBOXVR_SCR_COMPOSITOR
+{
+ VBOXVR_COMPOSITOR Compositor;
+ RTRECT Rect;
+#ifndef IN_RING0
+ float StretchX;
+ float StretchY;
+#endif
+ uint32_t fFlags;
+ uint32_t cRects;
+ uint32_t cRectsBuffer;
+ PRTRECT paSrcRects;
+ PRTRECT paDstRects;
+ PRTRECT paDstUnstretchedRects;
+} VBOXVR_SCR_COMPOSITOR, *PVBOXVR_SCR_COMPOSITOR;
+
+
+typedef DECLCALLBACK(bool) FNVBOXVRSCRCOMPOSITOR_VISITOR(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, void *pvVisitor);
+typedef FNVBOXVRSCRCOMPOSITOR_VISITOR *PFNVBOXVRSCRCOMPOSITOR_VISITOR;
+
+DECLINLINE(void) CrVrScrCompositorEntryInit(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const RTRECT *pRect, CR_TEXDATA *pTex, PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased)
+{
+ memset(pEntry, 0, sizeof (*pEntry));
+ VBoxVrCompositorEntryInit(&pEntry->Ce);
+ pEntry->Rect = *pRect;
+ pEntry->pfnEntryReleased = pfnEntryReleased;
+ if (pTex)
+ {
+ CrTdAddRef(pTex);
+ pEntry->pTex = pTex;
+ }
+}
+
+DECLINLINE(void) CrVrScrCompositorEntryCleanup(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry)
+{
+ if (pEntry->pTex)
+ {
+ CrTdRelease(pEntry->pTex);
+ pEntry->pTex = NULL;
+ }
+}
+
+DECLINLINE(bool) CrVrScrCompositorEntryIsUsed(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
+{
+ return VBoxVrCompositorEntryIsInList(&pEntry->Ce);
+}
+
+DECLINLINE(void) CrVrScrCompositorEntrySetChanged(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, bool fChanged)
+{
+ pEntry->fChanged = !!fChanged;
+}
+
+DECLINLINE(void) CrVrScrCompositorEntryTexSet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, CR_TEXDATA *pTex)
+{
+ if (pEntry->pTex)
+ CrTdRelease(pEntry->pTex);
+
+ if (pTex)
+ CrTdAddRef(pTex);
+
+ pEntry->pTex = pTex;
+}
+
+DECLINLINE(CR_TEXDATA *) CrVrScrCompositorEntryTexGet(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
+{
+ return pEntry->pTex;
+}
+
+DECLINLINE(bool) CrVrScrCompositorEntryIsChanged(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
+{
+ return !!pEntry->fChanged;
+}
+
+DECLINLINE(bool) CrVrScrCompositorIsEmpty(const VBOXVR_SCR_COMPOSITOR *pCompositor)
+{
+ return VBoxVrCompositorIsEmpty(&pCompositor->Compositor);
+}
+
+VBOXVREGDECL(int) CrVrScrCompositorEntryRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const RTRECT *pRect);
+VBOXVREGDECL(int) CrVrScrCompositorEntryTexAssign(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, CR_TEXDATA *pTex);
+VBOXVREGDECL(void) CrVrScrCompositorVisit(PVBOXVR_SCR_COMPOSITOR pCompositor, PFNVBOXVRSCRCOMPOSITOR_VISITOR pfnVisitor, void *pvVisitor);
+VBOXVREGDECL(void) CrVrScrCompositorEntrySetAllChanged(PVBOXVR_SCR_COMPOSITOR pCompositor, bool fChanged);
+DECLINLINE(bool) CrVrScrCompositorEntryIsInList(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
+{
+ return VBoxVrCompositorEntryIsInList(&pEntry->Ce);
+}
+VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsAdd(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions, bool fPosRelated, VBOXVR_SCR_COMPOSITOR_ENTRY **ppReplacedScrEntry, uint32_t *pfChangeFlags);
+VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const RTPOINT *pPos, uint32_t cRegions, const RTRECT *paRegions, bool fPosRelated, bool *pfChanged);
+VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const VBOXVR_LIST *pList2, bool *pfChanged);
+VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
+VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
+VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, const VBOXVR_LIST *pList2, bool *pfChanged);
+VBOXVREGDECL(int) CrVrScrCompositorEntryPosSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, const RTPOINT *pPos);
+DECLINLINE(const RTRECT*) CrVrScrCompositorEntryRectGet(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
+{
+ return &pEntry->Rect;
+}
+
+/* regions are valid until the next CrVrScrCompositor call */
+VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsGet(const VBOXVR_SCR_COMPOSITOR *pCompositor, const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry, uint32_t *pcRegions, const RTRECT **ppaSrcRegions, const RTRECT **ppaDstRegions, const RTRECT **ppaDstUnstretchedRects);
+VBOXVREGDECL(int) CrVrScrCompositorEntryRemove(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry);
+VBOXVREGDECL(bool) CrVrScrCompositorEntryReplace(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, PVBOXVR_SCR_COMPOSITOR_ENTRY pNewEntry);
+VBOXVREGDECL(void) CrVrScrCompositorEntryFlagsSet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t fFlags);
+VBOXVREGDECL(uint32_t) CrVrScrCompositorEntryFlagsCombinedGet(const VBOXVR_SCR_COMPOSITOR *pCompositor, const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry);
+DECLINLINE(uint32_t) CrVrScrCompositorEntryFlagsGet(const VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry)
+{
+ return pEntry->fFlags;
+}
+
+VBOXVREGDECL(void) CrVrScrCompositorInit(PVBOXVR_SCR_COMPOSITOR pCompositor, const RTRECT *pRect);
+VBOXVREGDECL(int) CrVrScrCompositorRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, const RTRECT *pRect, bool *pfChanged);
+DECLINLINE(const RTRECT*) CrVrScrCompositorRectGet(const VBOXVR_SCR_COMPOSITOR *pCompositor)
+{
+ return &pCompositor->Rect;
+}
+
+VBOXVREGDECL(void) CrVrScrCompositorClear(PVBOXVR_SCR_COMPOSITOR pCompositor);
+VBOXVREGDECL(void) CrVrScrCompositorRegionsClear(PVBOXVR_SCR_COMPOSITOR pCompositor, bool *pfChanged);
+
+typedef DECLCALLBACK(VBOXVR_SCR_COMPOSITOR_ENTRY*) FNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR(const VBOXVR_SCR_COMPOSITOR_ENTRY*pEntry, void *pvContext);
+typedef FNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR *PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR;
+
+VBOXVREGDECL(int) CrVrScrCompositorClone(const VBOXVR_SCR_COMPOSITOR *pCompositor, PVBOXVR_SCR_COMPOSITOR pDstCompositor, PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void* pvEntryFor);
+VBOXVREGDECL(int) CrVrScrCompositorIntersectList(PVBOXVR_SCR_COMPOSITOR pCompositor, const VBOXVR_LIST *pVr, bool *pfChanged);
+VBOXVREGDECL(int) CrVrScrCompositorIntersectedList(const VBOXVR_SCR_COMPOSITOR *pCompositor, const VBOXVR_LIST *pVr, PVBOXVR_SCR_COMPOSITOR pDstCompositor, PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void* pvEntryFor, bool *pfChanged);
+#ifndef IN_RING0
+VBOXVREGDECL(void) CrVrScrCompositorSetStretching(PVBOXVR_SCR_COMPOSITOR pCompositor, float StretchX, float StretchY);
+DECLINLINE(void) CrVrScrCompositorGetStretching(const VBOXVR_SCR_COMPOSITOR *pCompositor, float *pStretchX, float *pStretchY)
+{
+ if (pStretchX)
+ *pStretchX = pCompositor->StretchX;
+
+ if (pStretchY)
+ *pStretchY = pCompositor->StretchY;
+}
+#endif
+/* regions are valid until the next CrVrScrCompositor call */
+VBOXVREGDECL(int) CrVrScrCompositorRegionsGet(const VBOXVR_SCR_COMPOSITOR *pCompositor, uint32_t *pcRegions, const RTRECT **ppaSrcRegions, const RTRECT **ppaDstRegions, const RTRECT **ppaDstUnstretchedRects);
+
+#define VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(_p) ((PVBOXVR_SCR_COMPOSITOR_ENTRY)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_SCR_COMPOSITOR_ENTRY, Ce)))
+#define VBOXVR_SCR_COMPOSITOR_CONST_ENTRY_FROM_ENTRY(_p) ((const VBOXVR_SCR_COMPOSITOR_ENTRY*)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_SCR_COMPOSITOR_ENTRY, Ce)))
+#define VBOXVR_SCR_COMPOSITOR_FROM_COMPOSITOR(_p) ((PVBOXVR_SCR_COMPOSITOR)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_SCR_COMPOSITOR, Compositor)))
+
+typedef struct VBOXVR_SCR_COMPOSITOR_ITERATOR
+{
+ VBOXVR_COMPOSITOR_ITERATOR Base;
+} VBOXVR_SCR_COMPOSITOR_ITERATOR ,*PVBOXVR_SCR_COMPOSITOR_ITERATOR;
+
+typedef struct VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR
+{
+ VBOXVR_COMPOSITOR_CONST_ITERATOR Base;
+} VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR ,*PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR;
+
+DECLINLINE(void) CrVrScrCompositorIterInit(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ITERATOR pIter)
+{
+ VBoxVrCompositorIterInit(&pCompositor->Compositor, &pIter->Base);
+}
+
+DECLINLINE(void) CrVrScrCompositorConstIterInit(const VBOXVR_SCR_COMPOSITOR *pCompositor, PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR pIter)
+{
+ VBoxVrCompositorConstIterInit(&pCompositor->Compositor, &pIter->Base);
+}
+
+DECLINLINE(PVBOXVR_SCR_COMPOSITOR_ENTRY) CrVrScrCompositorIterNext(PVBOXVR_SCR_COMPOSITOR_ITERATOR pIter)
+{
+ PVBOXVR_COMPOSITOR_ENTRY pCe = VBoxVrCompositorIterNext(&pIter->Base);
+ if (pCe)
+ {
+ return VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pCe);
+ }
+ return NULL;
+}
+
+DECLINLINE(const VBOXVR_SCR_COMPOSITOR_ENTRY*) CrVrScrCompositorConstIterNext(PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR pIter)
+{
+ const VBOXVR_COMPOSITOR_ENTRY *pCe = VBoxVrCompositorConstIterNext(&pIter->Base);
+ if (pCe)
+ {
+ return VBOXVR_SCR_COMPOSITOR_CONST_ENTRY_FROM_ENTRY(pCe);
+ }
+ return NULL;
+}
+
+RT_C_DECLS_END
+
+#endif /* ___cr_compositor_h_ */
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_dump.h b/src/VBox/GuestHost/OpenGL/include/cr_dump.h
new file mode 100644
index 00000000..0946f56e
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/cr_dump.h
@@ -0,0 +1,177 @@
+/* $Id: cr_dump.h $ */
+
+/** @file
+ * Debugging: Dump API
+ */
+/*
+ * Copyright (C) 2013 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+#ifndef ___cr_dump_h__
+#define ___cr_dump_h__
+
+/* dump stuff */
+//#define VBOX_WITH_CRDUMPER
+#ifdef VBOX_WITH_CRDUMPER
+
+#include <iprt/cdefs.h>
+#include <iprt/string.h>
+#include <cr_spu.h>
+#include <cr_glstate.h>
+#include <cr_blitter.h>
+
+# define VBOXDUMPDECL(_type) DECLEXPORT(_type)
+
+RT_C_DECLS_BEGIN
+
+#ifdef RT_OS_WINDOWS
+DECLEXPORT(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc);
+
+DECLEXPORT(void) crDmpDumpStrDbgPrint(struct CR_DUMPER * pDumper, const char*pszStr);
+#endif
+
+struct CR_DUMPER;
+
+typedef DECLCALLBACKPTR(void, PFNCRDUMPIMG)(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc);
+typedef DECLCALLBACKPTR(void, PFNCRDUMPSTR)(struct CR_DUMPER * pDumper, const char*pszStr);
+
+typedef struct CR_DUMPER
+{
+ PFNCRDUMPIMG pfnDumpImg;
+ PFNCRDUMPSTR pfnDumpStr;
+} CR_DUMPER;
+
+#define crDmpImg(_pDumper, _pImg, _pDesc) do { \
+ (_pDumper)->pfnDumpImg((_pDumper), (_pImg), (_pDesc)); \
+ } while (0)
+
+#define crDmpStr(_pDumper, _pDesc) do { \
+ (_pDumper)->pfnDumpStr((_pDumper), (_pDesc)); \
+ } while (0)
+
+#ifndef RT_OS_WINDOWS
+# define vsprintf_s vsnprintf
+# define sprintf_s snprintf
+#endif
+
+DECLINLINE(void) crDmpStrV(CR_DUMPER *pDumper, const char *pszStr, va_list pArgList)
+{
+ char szBuffer[4096] = {0};
+ vsprintf_s(szBuffer, sizeof (szBuffer), pszStr, pArgList);
+ crDmpStr(pDumper, szBuffer);
+}
+
+DECLINLINE(void) crDmpStrF(CR_DUMPER *pDumper, const char *pszStr, ...)
+{
+ va_list pArgList;
+ va_start(pArgList, pszStr);
+ crDmpStrV(pDumper, pszStr, pArgList);
+ va_end(pArgList);
+}
+
+DECLINLINE(void) crDmpImgV(CR_DUMPER *pDumper, CR_BLITTER_IMG *pImg, const char *pszStr, va_list pArgList)
+{
+ char szBuffer[4096] = {0};
+ vsprintf_s(szBuffer, sizeof (szBuffer), pszStr, pArgList);
+ crDmpImg(pDumper, pImg, szBuffer);
+}
+
+DECLINLINE(void) crDmpImgF(CR_DUMPER *pDumper, CR_BLITTER_IMG *pImg, const char *pszStr, ...)
+{
+ va_list pArgList;
+ va_start(pArgList, pszStr);
+ crDmpImgV(pDumper, pImg, pszStr, pArgList);
+ va_end(pArgList);
+}
+
+VBOXDUMPDECL(size_t) crDmpFormatArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pVal, uint32_t cVal);
+VBOXDUMPDECL(size_t) crDmpFormatRawArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pVal, uint32_t cVal);
+VBOXDUMPDECL(size_t) crDmpFormatMatrixArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pVal, uint32_t cX, uint32_t cY);
+
+typedef struct CR_DBGPRINT_DUMPER
+{
+ CR_DUMPER Base;
+} CR_DBGPRINT_DUMPER;
+
+typedef struct CR_HTML_DUMPER
+{
+ CR_DUMPER Base;
+ const char* pszFile;
+ const char* pszDir;
+ FILE *pFile;
+ uint32_t cImg;
+} CR_HTML_DUMPER;
+
+DECLEXPORT(bool) crDmpHtmlIsInited(struct CR_HTML_DUMPER * pDumper);
+DECLEXPORT(void) crDmpHtmlTerm(struct CR_HTML_DUMPER * pDumper);
+DECLEXPORT(int) crDmpHtmlInit(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile);
+DECLEXPORT(int) crDmpHtmlInitV(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile, va_list pArgList);
+DECLEXPORT(int) crDmpHtmlInitF(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile, ...);
+
+#ifdef RT_OS_WINDOWS
+DECLINLINE(void) crDmpDbgPrintInit(CR_DBGPRINT_DUMPER *pDumper)
+{
+ pDumper->Base.pfnDumpImg = crDmpDumpImgDmlBreak;
+ pDumper->Base.pfnDumpStr = crDmpDumpStrDbgPrint;
+}
+#endif
+
+typedef struct CR_RECORDER
+{
+ CR_BLITTER *pBlitter;
+ SPUDispatchTable *pDispatch;
+ CR_DUMPER *pDumper;
+} CR_RECORDER;
+
+DECLINLINE(void) crRecInit(CR_RECORDER *pRec, CR_BLITTER *pBlitter, SPUDispatchTable *pDispatch, CR_DUMPER *pDumper)
+{
+ pRec->pBlitter = pBlitter;
+ pRec->pDispatch = pDispatch;
+ pRec->pDumper = pDumper;
+}
+
+VBOXDUMPDECL(void) crRecDumpBuffer(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, GLint idRedirFBO, VBOXVR_TEXTURE *pRedirTex);
+VBOXDUMPDECL(void) crRecDumpTextures(CR_RECORDER *pRec, CRContext *ctx, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin);
+VBOXDUMPDECL(void) crRecDumpTextureV(CR_RECORDER *pRec, const VBOXVR_TEXTURE *pTex, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, const char *pszStr, va_list pArgList);
+VBOXDUMPDECL(void) crRecDumpTextureF(CR_RECORDER *pRec, const VBOXVR_TEXTURE *pTex, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, const char *pszStr, ...);
+VBOXDUMPDECL(void) crRecDumpTextureByIdV(CR_RECORDER *pRec, CRContext *ctx, GLint id, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, const char *pszStr, va_list pArgList);
+VBOXDUMPDECL(void) crRecDumpTextureByIdF(CR_RECORDER *pRec, CRContext *ctx, GLint id, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, const char *pszStr, ...);
+VBOXDUMPDECL(void) crRecDumpShader(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
+VBOXDUMPDECL(void) crRecDumpProgram(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
+VBOXDUMPDECL(void) crRecRecompileShader(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
+VBOXDUMPDECL(void) crRecRecompileProgram(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
+VBOXDUMPDECL(void) crRecDumpCurrentProgram(CR_RECORDER *pRec, CRContext *ctx);
+VBOXDUMPDECL(void) crRecDumpProgramUniforms(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
+VBOXDUMPDECL(void) crRecDumpCurrentProgramUniforms(CR_RECORDER *pRec, CRContext *ctx);
+VBOXDUMPDECL(void) crRecRecompileCurrentProgram(CR_RECORDER *pRec, CRContext *ctx);
+VBOXDUMPDECL(void) crRecDumpProgramAttribs(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid);
+VBOXDUMPDECL(void) crRecDumpCurrentProgramAttribs(CR_RECORDER *pRec, CRContext *ctx);
+VBOXDUMPDECL(void) crRecDumpGlGetState(CR_RECORDER *pRec, CRContext *ctx);
+VBOXDUMPDECL(void) crRecDumpGlEnableState(CR_RECORDER *pRec, CRContext *ctx);
+VBOXDUMPDECL(void) crRecDumpVertAttrv(CR_RECORDER *pRec, CRContext *ctx, GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal);
+VBOXDUMPDECL(void) crRecDumpVertAttrF(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, ...);
+VBOXDUMPDECL(void) crRecDumpVertAttrV(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, va_list pArgList);
+VBOXDUMPDECL(void) crRecDumpTexParam(CR_RECORDER *pRec, CRContext *ctx, GLenum enmTarget);
+VBOXDUMPDECL(void) crRecDumpTexEnv(CR_RECORDER *pRec, CRContext *ctx);
+VBOXDUMPDECL(void) crRecDumpTexGen(CR_RECORDER *pRec, CRContext *ctx);
+
+VBOXDUMPDECL(int) crRecAlphaImgCreate(const CR_BLITTER_IMG *pImg, CR_BLITTER_IMG *pAlphaImg);
+VBOXDUMPDECL(void) crRecAlphaImgDestroy(CR_BLITTER_IMG *pImg);
+
+
+typedef DECLCALLBACKPTR(GLuint, PFNCRDUMPGETHWID)(void *pvObj);
+void* crDmpHashtableSearchByHwid(CRHashTable *pHash, GLuint hwid, PFNCRDUMPGETHWID pfnGetHwid, unsigned long *pKey);
+
+RT_C_DECLS_END
+
+#endif /* VBOX_WITH_CRDUMPER */
+/* */
+
+#endif /* #ifndef ___cr_dump_h__ */
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_error.h b/src/VBox/GuestHost/OpenGL/include/cr_error.h
index a73a47bc..ca472d28 100644
--- a/src/VBox/GuestHost/OpenGL/include/cr_error.h
+++ b/src/VBox/GuestHost/OpenGL/include/cr_error.h
@@ -24,10 +24,29 @@ extern "C" {
#define PRINTF
#endif
+#ifndef WARN
+# ifndef IN_RING0
+# define LOG(_m) do { crDebug _m ; } while (0)
+# define LOGREL(_m) do { crDebug _m ; } while (0)
+# define WARN(_m) do { crWarning _m ; AssertMsgFailed(_m); } while (0)
+# else
+# define LOG(_m) do { } while (0)
+# define LOGREL(_m) do { } while (0)
+# define WARN(_m) do { AssertMsgFailed(_m); } while (0)
+# endif
+#endif
+
DECLEXPORT(void) crEnableWarnings(int onOff);
DECLEXPORT(void) crDebug(const char *format, ... ) PRINTF;
+#if defined(DEBUG_misha) && defined(RT_OS_WINDOWS)
+typedef void FNCRDEBUG(const char *format, ... ) PRINTF;
+typedef FNCRDEBUG *PFNCRDEBUG;
+DECLINLINE(PFNCRDEBUG) crGetDebug() {return crDebug;}
+# define crWarning (RT_BREAKPOINT(), crDebug)
+#else
DECLEXPORT(void) crWarning(const char *format, ... ) PRINTF;
+#endif
DECLEXPORT(void) crInfo(const char *format, ... ) PRINTF;
DECLEXPORT(void) crError(const char *format, ... ) NORETURN_PRINTF;
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_extstring.h b/src/VBox/GuestHost/OpenGL/include/cr_extstring.h
index 1d894983..5940379e 100644
--- a/src/VBox/GuestHost/OpenGL/include/cr_extstring.h
+++ b/src/VBox/GuestHost/OpenGL/include/cr_extstring.h
@@ -237,6 +237,10 @@ static const char *crExtensions =
#ifdef CR_EXT_stencil_two_side
"GL_EXT_stencil_two_side "
#endif
+#ifdef CR_GREMEDY_string_marker
+ "GL_GREMEDY_string_marker "
+#endif
+
"";
/*
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_glext.h b/src/VBox/GuestHost/OpenGL/include/cr_glext.h
new file mode 100644
index 00000000..429e218c
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/cr_glext.h
@@ -0,0 +1,34 @@
+/* $Id: cr_glext.h $ */
+
+/** @file
+ * GL chromium platform specifics
+ */
+/*
+ * Copyright (C) 2014 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+#ifndef ___cr_glext_h__
+#define ___cr_glext_h__
+
+#include <iprt/assert.h>
+
+#ifndef __glext_h_
+/* glext NOT included yet */
+# include "GL/glext.h"
+#else
+/* glext IS included yet */
+# ifndef RT_OS_DARWIN
+typedef unsigned int VBoxGLhandleARB; /* shader object handle */
+AssertCompile(sizeof (VBoxGLhandleARB) == sizeof (GLhandleARB));
+# else
+# error "patched glext is required for OSX!"
+# endif
+#endif
+#endif /*___cr_glext_h__*/
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_glstate.h b/src/VBox/GuestHost/OpenGL/include/cr_glstate.h
index fd82b576..95b3477d 100644
--- a/src/VBox/GuestHost/OpenGL/include/cr_glstate.h
+++ b/src/VBox/GuestHost/OpenGL/include/cr_glstate.h
@@ -51,20 +51,19 @@ typedef struct CRContext CRContext;
#include <iprt/cdefs.h>
-#ifndef IN_GUEST
# include <VBox/vmm/ssm.h>
# include <iprt/asm.h>
# define CR_STATE_SHAREDOBJ_USAGE_INIT(_pObj) (crMemset((_pObj)->ctxUsage, 0, sizeof ((_pObj)->ctxUsage)))
# define CR_STATE_SHAREDOBJ_USAGE_SET(_pObj, _pCtx) (ASMBitSet((_pObj)->ctxUsage, (_pCtx)->id))
-# define CR_STATE_SHAREDOBJ_USAGE_CLEAR(_pObj, _pCtx) (ASMBitClear((_pObj)->ctxUsage, (_pCtx)->id))
+# define CR_STATE_SHAREDOBJ_USAGE_IS_SET(_pObj, _pCtx) (ASMBitTest((_pObj)->ctxUsage, (_pCtx)->id))
+# define CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(_pObj, _i) (ASMBitClear((_pObj)->ctxUsage, (_i)))
+# define CR_STATE_SHAREDOBJ_USAGE_CLEAR(_pObj, _pCtx) (CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX((_pObj), (_pCtx)->id))
# define CR_STATE_SHAREDOBJ_USAGE_IS_USED(_pObj) (ASMBitFirstSet((_pObj)->ctxUsage, sizeof ((_pObj)->ctxUsage)<<3) >= 0)
-#else
-# define CR_STATE_SHAREDOBJ_USAGE_INIT(_pObj) do {} while (0)
-# define CR_STATE_SHAREDOBJ_USAGE_SET(_pObj, _pCtx) do {} while (0)
-# define CR_STATE_SHAREDOBJ_USAGE_CLEAR(_pObj, _pCtx) do {} while (0)
-# define CR_STATE_SHAREDOBJ_USAGE_IS_USED(_pObj) (GL_FALSE)
-#endif
+# define CR_STATE_SHAREDOBJ_USAGE_GET_FIRST_USED_IDX(_pObj) (ASMBitFirstSet((_pObj)->ctxUsage, sizeof ((_pObj)->ctxUsage)<<3))
+# define CR_STATE_SHAREDOBJ_USAGE_GET_NEXT_USED_IDX(_pObj, _i) (ASMBitNextSet((_pObj)->ctxUsage, sizeof ((_pObj)->ctxUsage)<<3, (_i)))
+
+# define CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(_pObj, _i) for ((_i) = CR_STATE_SHAREDOBJ_USAGE_GET_FIRST_USED_IDX(_pObj); ((int)(_i)) >= 0; (_i) = CR_STATE_SHAREDOBJ_USAGE_GET_NEXT_USED_IDX((_pObj), ((int)(_i))))
#define CR_MAX_EXTENTS 256
@@ -218,8 +217,10 @@ DECLEXPORT(CRContext *) crStateGetCurrent(void);
DECLEXPORT(void) crStateDestroyContext(CRContext *ctx);
DECLEXPORT(GLboolean) crStateEnableDiffOnMakeCurrent(GLboolean fEnable);
-CRContext * crStateSwichPrepare(CRContext *toCtx, GLboolean fMultipleContexts, GLuint idFBO);
-void crStateSwichPostprocess(CRContext *fromCtx, GLboolean fMultipleContexts, GLuint idFBO);
+void crStateSwitchPrepare(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO);
+void crStateSwitchPostprocess(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO);
+
+void crStateSyncHWErrorState(CRContext *ctx);
DECLEXPORT(void) crStateFlushFunc( CRStateFlushFunc ff );
DECLEXPORT(void) crStateFlushArg( void *arg );
@@ -233,15 +234,53 @@ DECLEXPORT(void) crStateSetExtensionString( CRContext *ctx, const GLubyte *exten
DECLEXPORT(void) crStateDiffContext( CRContext *from, CRContext *to );
DECLEXPORT(void) crStateSwitchContext( CRContext *from, CRContext *to );
-DECLEXPORT(void) crStateApplyFBImage(CRContext *to);
+
+DECLEXPORT(unsigned int) crStateHlpComponentsCount( GLenum pname );
+
+typedef struct CRFBDataElement
+{
+ /* FBO, can be NULL */
+ GLint idFBO;
+ /* to be used for glDraw/ReadBuffer, i.e. GL_FRONT, GL_BACK, GL_COLOR_ATTACHMENTX */
+ GLenum enmBuffer;
+ GLint posX;
+ GLint posY;
+ GLint width;
+ GLint height;
+ GLenum enmFormat;
+ GLenum enmType;
+ GLuint cbData;
+ GLvoid *pvData;
+} CRFBDataElement;
+
+typedef struct CRFBData
+{
+ /* override default draw and read buffers to be used for offscreen rendering */
+ GLint idOverrrideFBO;
+ uint32_t cElements;
+ CRFBDataElement aElements[1];
+} CRFBData;
+
+DECLEXPORT(void) crStateApplyFBImage(CRContext *to, CRFBData *data);
+DECLEXPORT(int) crStateAcquireFBImage(CRContext *to, CRFBData *data);
+DECLEXPORT(void) crStateFreeFBImageLegacy(CRContext *to);
+
+DECLEXPORT(void) crStateGetTextureObjectAndImage(CRContext *g, GLenum texTarget, GLint level,
+ CRTextureObj **obj, CRTextureLevel **img);
+
#ifndef IN_GUEST
DECLEXPORT(int32_t) crStateSaveContext(CRContext *pContext, PSSMHANDLE pSSM);
typedef DECLCALLBACK(CRContext*) FNCRSTATE_CONTEXT_GET(void*);
typedef FNCRSTATE_CONTEXT_GET *PFNCRSTATE_CONTEXT_GET;
DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PFNCRSTATE_CONTEXT_GET pfnCtxGet, PSSMHANDLE pSSM, uint32_t u32Version);
-DECLEXPORT(void) crStateFreeShared(CRContext *pContext, CRSharedState *s);
DECLEXPORT(void) crStateFreeShared(CRContext *pContext, CRSharedState *s);
+
+DECLEXPORT(int32_t) crStateLoadGlobals(PSSMHANDLE pSSM, uint32_t u32Version);
+DECLEXPORT(int32_t) crStateSaveGlobals(PSSMHANDLE pSSM);
+
+DECLEXPORT(CRSharedState *) crStateGlobalSharedAcquire();
+DECLEXPORT(void) crStateGlobalSharedRelease();
#endif
DECLEXPORT(void) crStateSetTextureUsed(GLuint texture, GLboolean used);
@@ -270,7 +309,7 @@ DECLEXPORT(void) STATE_APIENTRY crStateShareContext(GLboolean value);
DECLEXPORT(void) STATE_APIENTRY crStateSetSharedContext(CRContext *pCtx);
DECLEXPORT(GLboolean) STATE_APIENTRY crStateContextIsShared(CRContext *pCtx);
-DECLEXPORT(void) STATE_APIENTRY crStateQueryHWState();
+DECLEXPORT(void) STATE_APIENTRY crStateQueryHWState(GLuint fbFbo, GLuint bbFbo);
#ifdef __cplusplus
}
#endif
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_hash.h b/src/VBox/GuestHost/OpenGL/include/cr_hash.h
index 9bda7454..0f28c798 100644
--- a/src/VBox/GuestHost/OpenGL/include/cr_hash.h
+++ b/src/VBox/GuestHost/OpenGL/include/cr_hash.h
@@ -15,17 +15,36 @@
extern "C" {
#endif
+typedef struct CRHashIdPool CRHashIdPool;
typedef struct CRHashTable CRHashTable;
/* Callback function used for freeing/deleting table entries */
typedef void (*CRHashtableCallback)(void *data);
/* Callback function used for walking through table entries */
typedef void (*CRHashtableWalkCallback)(unsigned long key, void *data1, void *data2);
+/* Callback function used for walking through allocated keys */
+typedef void (*CRHashIdWalkKeys)(unsigned long firstKey, unsigned long count, void *data);
+
+DECLEXPORT(CRHashIdPool *) crAllocHashIdPool( void );
+DECLEXPORT(CRHashIdPool *) crAllocHashIdPoolEx( GLuint min, GLuint max );
+DECLEXPORT(void) crFreeHashIdPool( CRHashIdPool *pool );
+DECLEXPORT(GLboolean) crHashIdPoolIsIdFree( const CRHashIdPool *pool, GLuint id );
+DECLEXPORT(GLuint) crHashIdPoolAllocBlock( CRHashIdPool *pool, GLuint count );
+DECLEXPORT(void) crHashIdPoolFreeBlock( CRHashIdPool *pool, GLuint first, GLuint count );
+/* @return GL_TRUE if the id is allocated, and GL_FALSE if the id was already allocated */
+DECLEXPORT(GLboolean) crHashIdPoolAllocId( CRHashIdPool *pool, GLuint id );
+DECLEXPORT(void) crHashIdWalkKeys( CRHashIdPool *pool, CRHashIdWalkKeys walkFunc , void *data);
DECLEXPORT(CRHashTable *) crAllocHashtable( void );
+DECLEXPORT(CRHashTable *) crAllocHashtableEx( GLuint min, GLuint max );
DECLEXPORT(void) crFreeHashtable( CRHashTable *hash, CRHashtableCallback deleteCallback );
DECLEXPORT(void) crHashtableAdd( CRHashTable *h, unsigned long key, void *data );
+/* to ensure hash table pool id consistency, there is no crHashTableFreeKeys/UnregisterKey,
+ * one should call crHashtableDelete to free unneeded keys,
+ * which will also ensure there is no entry with the specified key left in the table */
DECLEXPORT(GLuint) crHashtableAllocKeys( CRHashTable *h, GLsizei range );
+/* @return GL_TRUE if the id is allocated, and GL_FALSE if the id was already allocated */
+DECLEXPORT(GLboolean) crHashtableAllocRegisterKey( CRHashTable *h, GLuint key);
DECLEXPORT(void) crHashtableDelete( CRHashTable *h, unsigned long key, CRHashtableCallback deleteCallback );
DECLEXPORT(void) crHashtableDeleteBlock( CRHashTable *h, unsigned long key, GLsizei range, CRHashtableCallback deleteFunc );
DECLEXPORT(void *) crHashtableSearch( const CRHashTable *h, unsigned long key );
@@ -33,10 +52,13 @@ DECLEXPORT(void) crHashtableReplace( CRHashTable *h, unsigned long key, void *da
DECLEXPORT(unsigned int) crHashtableNumElements( const CRHashTable *h) ;
DECLEXPORT(GLboolean) crHashtableIsKeyUsed( const CRHashTable *h, GLuint id );
DECLEXPORT(void) crHashtableWalk( CRHashTable *hash, CRHashtableWalkCallback walkFunc , void *data);
+/* walk the hashtable w/o holding the table lock */
+DECLEXPORT(void) crHashtableWalkUnlocked( CRHashTable *hash, CRHashtableWalkCallback walkFunc , void *data);
/*Returns GL_TRUE if given hashtable hold the data, pKey is updated with key value for data in this case*/
DECLEXPORT(GLboolean) crHashtableGetDataKey(CRHashTable *pHash, void *pData, unsigned long *pKey);
DECLEXPORT(void) crHashtableLock(CRHashTable *h);
DECLEXPORT(void) crHashtableUnlock(CRHashTable *h);
+DECLEXPORT(void) crHashtableWalkKeys(CRHashTable *hash, CRHashIdWalkKeys walkFunc , void *data);
#ifdef __cplusplus
} /* extern "C" */
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_htable.h b/src/VBox/GuestHost/OpenGL/include/cr_htable.h
new file mode 100644
index 00000000..26c8bffd
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/cr_htable.h
@@ -0,0 +1,120 @@
+/* $Id: cr_htable.h $ */
+
+/** @file
+ * uint32_t handle to void simple table API
+ */
+
+/*
+ * Copyright (C) 2013 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+#ifndef ___cr_htable_h_
+#define ___cr_htable_h_
+
+#include <iprt/types.h>
+#include <iprt/cdefs.h>
+
+#include <cr_error.h>
+
+#ifndef IN_RING0
+# define VBOXHTABLEDECL(_type) DECLEXPORT(_type)
+#else
+# define VBOXHTABLEDECL(_type) RTDECL(_type)
+#endif
+
+
+
+RT_C_DECLS_BEGIN
+
+typedef uint32_t CRHTABLE_HANDLE;
+#define CRHTABLE_HANDLE_INVALID 0UL
+
+typedef struct CRHTABLE
+{
+ uint32_t cData;
+ uint32_t iNext2Search;
+ uint32_t cSize;
+ void **paData;
+} CRHTABLE, *PCRHTABLE;
+
+typedef struct CRHTABLE_ITERATOR
+{
+ PCRHTABLE pTbl;
+ uint32_t iCur;
+ uint32_t cLeft;
+} VCRHTABLE_ITERATOR, *PCRHTABLE_ITERATOR;
+
+/*private stuff, not to be used directly */
+DECLINLINE(CRHTABLE_HANDLE) crHTableIndex2Handle(uint32_t iIndex)
+{
+ return iIndex+1;
+}
+
+DECLINLINE(uint32_t) crHTableHandle2Index(CRHTABLE_HANDLE hHandle)
+{
+ return hHandle-1;
+}
+
+/* public API */
+DECLINLINE(void) CrHTableIterInit(PCRHTABLE pTbl, PCRHTABLE_ITERATOR pIter)
+{
+ pIter->pTbl = pTbl;
+ pIter->iCur = 0;
+ pIter->cLeft = pTbl->cData;
+}
+
+DECLINLINE(void*) CrHTableIterNext(PCRHTABLE_ITERATOR pIter, CRHTABLE_HANDLE *phHandle)
+{
+ PCRHTABLE pTbl;
+ uint32_t i;
+ if (!pIter->cLeft)
+ {
+ if (phHandle)
+ *phHandle = 0;
+ return NULL;
+ }
+
+ pTbl = pIter->pTbl;
+
+ for (i = pIter->iCur; i < pTbl->cSize; ++i)
+ {
+ if (pTbl->paData[i])
+ {
+ pIter->iCur = i+1;
+ --(pIter->cLeft);
+ if (phHandle)
+ *phHandle = crHTableIndex2Handle(i);
+ return pTbl->paData[i];
+ }
+ }
+
+ crWarning("interator concurent modification!");
+ return NULL;
+}
+
+VBOXHTABLEDECL(int) CrHTableCreate(PCRHTABLE pTbl, uint32_t cSize);
+DECLINLINE(void) CrHTableMoveTo(PCRHTABLE pSrcTbl, PCRHTABLE pDstTbl)
+{
+ *pDstTbl = *pSrcTbl;
+ CrHTableCreate(pSrcTbl, 0);
+}
+VBOXHTABLEDECL(void) CrHTableEmpty(PCRHTABLE pTbl);
+VBOXHTABLEDECL(void) CrHTableDestroy(PCRHTABLE pTbl);
+VBOXHTABLEDECL(int) CrHTableRealloc(PCRHTABLE pTbl, uint32_t cNewSize);
+VBOXHTABLEDECL(CRHTABLE_HANDLE) CrHTablePut(PCRHTABLE pTbl, void *pvData);
+VBOXHTABLEDECL(int) CrHTablePutToSlot(PCRHTABLE pTbl, CRHTABLE_HANDLE hHandle, void* pvData);
+
+/* note: can be called for the element returned with CrHTableIterNext w/o corrupting the iterator */
+VBOXHTABLEDECL(void*) CrHTableRemove(PCRHTABLE pTbl, CRHTABLE_HANDLE hHandle);
+VBOXHTABLEDECL(void*) CrHTableGet(PCRHTABLE pTbl, CRHTABLE_HANDLE hHandle);
+
+RT_C_DECLS_END
+
+#endif /* #ifndef ___cr_htable_h_*/
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_pack.h b/src/VBox/GuestHost/OpenGL/include/cr_pack.h
index 82f7d5d7..3f7f930e 100644
--- a/src/VBox/GuestHost/OpenGL/include/cr_pack.h
+++ b/src/VBox/GuestHost/OpenGL/include/cr_pack.h
@@ -117,7 +117,11 @@ extern DECLEXPORT(void) crPackResetPointers( CRPackContext *pc );
extern DECLEXPORT(int) crPackMaxOpcodes( int buffer_size );
extern DECLEXPORT(int) crPackMaxData( int buffer_size );
-extern DECLEXPORT(void) crPackInitBuffer( CRPackBuffer *buffer, void *buf, int size, int mtu );
+extern DECLEXPORT(void) crPackInitBuffer( CRPackBuffer *buffer, void *buf, int size, int mtu
+#ifdef IN_RING0
+ , unsigned int num_opcodes
+#endif
+ );
extern DECLEXPORT(void) crPackFlushFunc( CRPackContext *pc, CRPackFlushFunc ff );
extern DECLEXPORT(void) crPackFlushArg( CRPackContext *pc, void *flush_arg );
extern DECLEXPORT(void) crPackSendHugeFunc( CRPackContext *pc, CRPackSendHugeFunc shf );
@@ -140,8 +144,10 @@ extern DECLEXPORT(int) crPackCanHoldBoundedBuffer( CR_PACKER_CONTEXT_ARGDECL con
#else
#undef CR_UNALIGNED_ACCESS_OKAY
#endif
+#ifndef IN_RING0
extern DECLEXPORT(void) crWriteUnalignedDouble( void *buffer, double d );
extern DECLEXPORT(void) crWriteSwappedDouble( void *buffer, double d );
+#endif
extern DECLEXPORT(void) *crPackAlloc( CR_PACKER_CONTEXT_ARGDECL unsigned int len );
extern DECLEXPORT(void) crHugePacket( CR_PACKER_CONTEXT_ARGDECL CROpcode op, void *ptr );
@@ -304,12 +310,22 @@ crPackCanHoldOpcode(const CRPackContext *pc, int num_opcode, int num_data)
#define WRITE_DOUBLE( offset, data ) \
WRITE_DATA( offset, GLdouble, data )
#else
-#define WRITE_DOUBLE( offset, data ) \
- crWriteUnalignedDouble( data_ptr + (offset), (data) )
+# ifndef IN_RING0
+# define WRITE_DOUBLE( offset, data ) \
+ crWriteUnalignedDouble( data_ptr + (offset), (data) )
+# else
+# define WRITE_DOUBLE( offset, data ) \
+ AssertReleaseFailed()
+# endif
#endif
+#ifndef IN_RING0
#define WRITE_SWAPPED_DOUBLE( offset, data ) \
crWriteSwappedDouble( data_ptr + (offset), (data) )
+#else
+#define WRITE_SWAPPED_DOUBLE( offset, data ) \
+ AssertReleaseFailed()
+#endif
#define WRITE_OPCODE( pc, opcode ) \
*(pc->buffer.opcode_current--) = (unsigned char) opcode
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_pixeldata.h b/src/VBox/GuestHost/OpenGL/include/cr_pixeldata.h
index 9b194eef..da3ebe34 100644
--- a/src/VBox/GuestHost/OpenGL/include/cr_pixeldata.h
+++ b/src/VBox/GuestHost/OpenGL/include/cr_pixeldata.h
@@ -11,6 +11,7 @@
#include "state/cr_client.h"
#include <iprt/cdefs.h>
+#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
@@ -43,6 +44,8 @@ DECLEXPORT(void) crBitmapCopy( GLsizei width, GLsizei height, GLubyte *dstPtr,
const GLubyte *srcPtr, const CRPixelPackState *srcPacking );
DECLEXPORT(void) crDumpNamedTGA(const char *fname, GLint w, GLint h, GLvoid *data);
+DECLEXPORT(void) crDumpNamedTGAV(GLint w, GLint h, GLvoid *data, const char* fname, va_list va);
+DECLEXPORT(void) crDumpNamedTGAF(GLint w, GLint h, GLvoid *data, const char* fname, ...);
DECLEXPORT(void) crDumpTGA(GLint w, GLint h, GLvoid *data);
#ifdef __cplusplus
}
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_protocol.h b/src/VBox/GuestHost/OpenGL/include/cr_protocol.h
index 5e24f207..1bf785ba 100644
--- a/src/VBox/GuestHost/OpenGL/include/cr_protocol.h
+++ b/src/VBox/GuestHost/OpenGL/include/cr_protocol.h
@@ -7,6 +7,7 @@
#ifndef CR_PROTOCOL_H
#define CR_PROTOCOL_H
+#include <iprt/types.h>
#include <iprt/cdefs.h>
#ifdef DEBUG_misha
#include "cr_error.h"
@@ -21,6 +22,23 @@ extern "C" {
#define CR_PROTOCOL_VERSION_MAJOR 9
#define CR_PROTOCOL_VERSION_MINOR 1
+/* new TexPresent mechanism is available */
+#define CR_VBOX_CAP_TEX_PRESENT 0x00000001
+/* vbva command submission mechanism supported */
+#define CR_VBOX_CAP_CMDVBVA 0x00000002
+
+
+#define CR_PRESENT_SCREEN_MASK 0xffff
+#define CR_PRESENT_FLAGS_OFFSET 16
+#define CR_PRESENT_FLAGS_MASK 0xffff0000
+#define CR_PRESENT_DEFINE_FLAG(_f) (1 << (CR_PRESENT_FLAGS_OFFSET + _f))
+
+#define CR_PRESENT_FLAG_CLEAR_RECTS CR_PRESENT_DEFINE_FLAG(0)
+#define CR_PRESENT_FLAG_TEX_NONINVERT_YCOORD CR_PRESENT_DEFINE_FLAG(1)
+
+#define CR_PRESENT_GET_SCREEN(_cfg) ((_cfg) & CR_PRESENT_SCREEN_MASK)
+#define CR_PRESENT_GET_FLAGS(_cfg) ((_cfg) & CR_PRESENT_FLAGS_MASK)
+
typedef enum {
/* first message types is 'wGL\001', so we can immediately
recognize bad message types */
@@ -51,7 +69,7 @@ typedef union {
/* unsigned int junk[512]; */
} CRNetworkPointer;
-#ifdef DEBUG_misha
+#if 0 //def DEBUG_misha
#define CRDBGPTR_SETZ(_p) crMemset((_p), 0, sizeof (CRNetworkPointer))
#define CRDBGPTR_CHECKZ(_p) do { \
CRNetworkPointer _ptr = {0}; \
@@ -80,26 +98,32 @@ typedef union {
#ifdef VBOX_WITH_CRHGSMI
typedef struct CRVBOXHGSMI_CMDDATA {
- struct VBOXVDMACMD_CHROMIUM_CMD *pCmd;
+ union
+ {
+ struct VBOXVDMACMD_CHROMIUM_CMD *pHgsmiCmd;
+ struct VBOXCMDVBVA_CRCMD_CMD *pVbvaCmd;
+ void *pvCmd;
+ };
int *pCmdRc;
char *pWriteback;
unsigned int *pcbWriteback;
unsigned int cbWriteback;
+ bool fHgsmiCmd;
} CRVBOXHGSMI_CMDDATA, *PCRVBOXHGSMI_CMDDATA;
#ifdef DEBUG
# define CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData) do { \
- CRASSERT(!(_pData)->pCmd == !(_pData)->pCmdRc); \
+ CRASSERT(!(_pData)->pvCmd == !(_pData)->pCmdRc); \
CRASSERT(!(_pData)->pWriteback == !(_pData)->pcbWriteback); \
CRASSERT(!(_pData)->pWriteback == !(_pData)->cbWriteback); \
if ((_pData)->pWriteback) \
{ \
- CRASSERT((_pData)->pCmd); \
+ CRASSERT((_pData)->pvCmd); \
} \
} while (0)
# define CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData) do { \
- CRASSERT(!(_pData)->pCmd); \
+ CRASSERT(!(_pData)->pvCmd); \
CRASSERT(!(_pData)->pCmdRc); \
CRASSERT(!(_pData)->pWriteback); \
CRASSERT(!(_pData)->pcbWriteback); \
@@ -122,7 +146,8 @@ typedef struct CRVBOXHGSMI_CMDDATA {
# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSETWB(_pData) do { } while (0)
#endif
-#define CRVBOXHGSMI_CMDDATA_IS_SET(_pData) (!!(_pData)->pCmd)
+#define CRVBOXHGSMI_CMDDATA_IS_HGSMICMD(_pData) (!!(_pData)->fHgsmiCmd)
+#define CRVBOXHGSMI_CMDDATA_IS_SET(_pData) (!!(_pData)->pvCmd)
#define CRVBOXHGSMI_CMDDATA_IS_SETWB(_pData) (!!(_pData)->pWriteback)
#define CRVBOXHGSMI_CMDDATA_CLEANUP(_pData) do { \
@@ -131,15 +156,16 @@ typedef struct CRVBOXHGSMI_CMDDATA {
CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
} while (0)
-#define CRVBOXHGSMI_CMDDATA_SET(_pData, _pCmd, _pHdr) do { \
+#define CRVBOXHGSMI_CMDDATA_SET(_pData, _pCmd, _pHdr, _fHgsmiCmd) do { \
CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData); \
- (_pData)->pCmd = (_pCmd); \
+ (_pData)->pvCmd = (_pCmd); \
(_pData)->pCmdRc = &(_pHdr)->result; \
+ (_pData)->fHgsmiCmd = (_fHgsmiCmd); \
CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \
} while (0)
-#define CRVBOXHGSMI_CMDDATA_SETWB(_pData, _pCmd, _pHdr, _pWb, _cbWb, _pcbWb) do { \
- CRVBOXHGSMI_CMDDATA_SET(_pData, _pCmd, _pHdr); \
+#define CRVBOXHGSMI_CMDDATA_SETWB(_pData, _pCmd, _pHdr, _pWb, _cbWb, _pcbWb, _fHgsmiCmd) do { \
+ CRVBOXHGSMI_CMDDATA_SET(_pData, _pCmd, _pHdr, _fHgsmiCmd); \
(_pData)->pWriteback = (_pWb); \
(_pData)->pcbWriteback = (_pcbWb); \
(_pData)->cbWriteback = (_cbWb); \
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_server.h b/src/VBox/GuestHost/OpenGL/include/cr_server.h
index 027354a2..b215d4cb 100644
--- a/src/VBox/GuestHost/OpenGL/include/cr_server.h
+++ b/src/VBox/GuestHost/OpenGL/include/cr_server.h
@@ -12,19 +12,28 @@
#include "cr_hash.h"
#include "cr_protocol.h"
#include "cr_glstate.h"
+#include "cr_vreg.h"
+#include "cr_blitter.h"
#include "spu_dispatch_table.h"
+#include "cr_dump.h"
#include "state/cr_currentpointers.h"
#include <iprt/types.h>
#include <iprt/err.h>
#include <iprt/string.h>
+#include <iprt/list.h>
+#include <iprt/thread.h>
+#include <iprt/critsect.h>
+#include <iprt/semaphore.h>
+#include <iprt/memcache.h>
#include <VBox/vmm/ssm.h>
-#ifdef VBOX_WITH_CRHGSMI
-# include <VBox/VBoxVideo.h>
-#endif
+#include <VBox/VBoxVideo.h>
+#include <VBox/Hardware/VBoxVideoVBE.h>
+#include <VBox/VBoxVideo3D.h>
+#include <VBox/VBoxVideoHost3D.h>
#ifdef __cplusplus
extern "C" {
@@ -34,7 +43,7 @@ extern "C" {
#define CR_MAX_CLIENTS 64
/*@todo must match MaxGuestMonitors from SchemaDefs.h*/
-#define CR_MAX_GUEST_MONITORS 8
+#define CR_MAX_GUEST_MONITORS VBOX_VIDEO_MAX_SCREENS
typedef DECLCALLBACKPTR(void, PFNCRSERVERPRESENTFBO) (void *data, int32_t screenId, int32_t x, int32_t y, uint32_t w, uint32_t h);
@@ -54,7 +63,7 @@ typedef struct {
DECLR3CALLBACKMEMBER(void, CRORGeometry, (void *pvInstance,
int32_t x, int32_t y, uint32_t w, uint32_t h));
DECLR3CALLBACKMEMBER(void, CRORVisibleRegion, (void *pvInstance,
- uint32_t cRects, RTRECT *paRects));
+ uint32_t cRects, const RTRECT *paRects));
DECLR3CALLBACKMEMBER(void, CRORFrame, (void *pvInstance,
void *pvData, uint32_t cbData));
DECLR3CALLBACKMEMBER(void, CROREnd, (void *pvInstance));
@@ -75,6 +84,140 @@ typedef struct {
struct BucketingInfo;
+typedef struct {
+ char *pszDpyName;
+ GLint visualBits;
+ int32_t externalID;
+} CRCreateInfo_t;
+
+typedef struct {
+ char *pszDpyName;
+ int32_t externalID;
+ GLint requestedVisualBits;
+ GLint realVisualBits;
+} CRCreateInfoEx_t;
+
+/* VRAM->RAM worker thread */
+
+typedef enum
+{
+ CR_SERVER_RPW_STATE_UNINITIALIZED = 0,
+ CR_SERVER_RPW_STATE_INITIALIZING,
+ CR_SERVER_RPW_STATE_INITIALIZED,
+ CR_SERVER_RPW_STATE_UNINITIALIZING,
+} CR_SERVER_RPW_STATE;
+
+/* worker control command */
+typedef enum
+{
+ CR_SERVER_RPW_CTL_TYPE_UNDEFINED = 0,
+ CR_SERVER_RPW_CTL_TYPE_WAIT_COMPLETE,
+ CR_SERVER_RPW_CTL_TYPE_TERM
+} CR_SERVER_RPW_CTL_TYPE;
+
+struct CR_SERVER_RPW_ENTRY;
+
+typedef struct CR_SERVER_RPW_CTL {
+ CR_SERVER_RPW_CTL_TYPE enmType;
+ int rc;
+ RTSEMEVENT hCompleteEvent;
+ /* valid for *_WAIT_COMPLETE and *_CANCEL */
+ struct CR_SERVER_RPW_ENTRY *pEntry;
+} CR_SERVER_RPW_CTL;
+
+
+struct CR_SERVER_RPW_ENTRY;
+
+typedef DECLCALLBACKPTR(void, PFNCR_SERVER_RPW_DATA) (const struct CR_SERVER_RPW_ENTRY* pEntry, void *pvEntryTexData);
+
+typedef DECLCALLBACKPTR(void, PFNCRSERVERNOTIFYEVENT) (int32_t screenId, uint32_t uEvent, void*pvData);
+
+typedef struct CR_SERVER_RPW_ENTRY
+{
+ RTRECTSIZE Size;
+ /* We have to use 4 textures here.
+ *
+ * 1. iDrawTex - the texture clients can draw to and then submit it for contents acquisition via crServerRpwEntrySubmit
+ * 2. iSubmittedTex - the texture submitted to the worker for processing and, whose processing has not start yet,
+ * i.e. it is being in the queue and can be safely removed/replaced [from] there
+ * 3. iWorkerTex - the texture being prepared & passed by the worker to the GPU (stage 1 of a worker contents acquisition process)
+ * 4. iGpuTex - the texture passed/processed to/by the GPU, whose data is then acquired by the server (stage 2 of a worker contents acquisition process)
+ *
+ * - There can be valid distinct iGpuTex, iWorkerTex, iSubmittedTex and iDrawTex present simultaneously.
+ * - Either or both of iSubmittedTex and iFreeTex are always valid
+ *
+ * Detail:
+ *
+ * - iSubmittedTex and iFreeTex modifications are performed under CR_SERVER_RPW::CritSect lock.
+ *
+ * - iDrawTex can only be changed by client side (i.e. the crServerRpwEntrySubmit caller), this is why client thread can access it w/o a lock
+ * - iSubmittedTex and iFreeTex can be modified by both client and worker, so lock is always required
+ *
+ * - iDrawTex can be accessed by client code only
+ * - iWorkerTex and iGpuTex can be accessed by worker code only
+ * - iSubmittedTex and iFreeTex can be accessed under CR_SERVER_RPW::CritSect lock only
+ * - either or both of iSubmittedTex and iFreeTex are always valid (see below for more explanation),
+ * this is why client can easily determine the new iDrawTex value on Submit, i.e. :
+ *
+ * (if initial iSubmittedTex was valid)
+ * ---------------
+ * | ^
+ * > |
+ * Submit-> iDrawTex -> iSubmittedTex
+ * ^
+ * | (if initial iSubmittedTex was NOT valid)
+ * iFreeTex
+ *
+ * - The worker can invalidate the iSubmittedTex (i.e. do iSubmittedTex -> iWorkerTex) only after it is done
+ * with the last iWorkerTex -> iGpuTex transformation freeing the previously used iGpuTex to iFreeTex.
+ *
+ * - A simplified worker iXxxTex transformation logic is:
+ * 1. iFreeTex is initially valid
+ * 2. iSubmittedTex -> iWorkerTex;
+ * 3. submit iWorkerTex acquire request to the GPU
+ * 4. complete current iGpuTex
+ * 5. iGpuTex -> iFreeTex
+ * 6. iWorkerTex -> iGpuTex
+ * 7. goto 1
+ *
+ * */
+ int8_t iTexDraw;
+ int8_t iTexSubmitted;
+ int8_t iTexWorker;
+ int8_t iTexGpu;
+ int8_t iCurPBO;
+ GLuint aidWorkerTexs[4];
+ GLuint aidPBOs[2];
+ RTLISTNODE WorkEntry;
+ RTLISTNODE WorkerWorkEntry;
+ RTLISTNODE GpuSubmittedEntry;
+ PFNCR_SERVER_RPW_DATA pfnData;
+} CR_SERVER_RPW_ENTRY;
+
+typedef struct CR_SERVER_RPW {
+ RTLISTNODE WorkList;
+ RTCRITSECT CritSect;
+ RTSEMEVENT hSubmitEvent;
+ /* only one outstanding command is supported,
+ * and ctl requests must be cynchronized, hold it right here */
+ CR_SERVER_RPW_CTL Ctl;
+ int ctxId;
+ GLint ctxVisBits;
+ RTTHREAD hThread;
+} CR_SERVER_RPW;
+/* */
+
+/* FRAMEBUFFER */
+typedef struct CR_FRAMEBUFFER *HCR_FRAMEBUFFER;
+typedef struct CR_FRAMEBUFFER_ENTRY *HCR_FRAMEBUFFER_ENTRY;
+/* */
+
+typedef struct CR_FBDATA
+{
+ HCR_FRAMEBUFFER hFb;
+ HCR_FRAMEBUFFER_ENTRY hFbEntry;
+ CR_TEXDATA* apTexDatas[2];
+} CR_FBDATA;
/**
* Mural info
*/
@@ -88,30 +231,55 @@ typedef struct {
int screenId;
GLboolean bVisible; /*guest window is visible*/
- GLboolean bUseFBO; /*redirect to FBO instead of real host window*/
+ GLubyte u8Unused; /*redirect to FBO instead of real host window*/
GLboolean bFbDraw; /*GL_FRONT buffer is drawn to directly*/
+ GLboolean fIsDummyRefference;
GLint cVisibleRects; /*count of visible rects*/
GLint *pVisibleRects; /*visible rects left, top, right, bottom*/
GLboolean bReceivedRects; /*indicates if guest did any updates for visible regions*/
- GLuint idFBO, idColorTex, idDepthStencilRB;
+ GLuint cBuffers;
+ GLuint iBbBuffer;
+ GLuint aidFBOs[2];
+ GLuint aidColorTexs[2];
+
+ void *pvReserved;
+
+ CRCreateInfoEx_t CreateInfo;
+
+ /* to avoid saved state breakage we need to keep RT_OFFSETOF(CRMuralInfo, CreateInfo) intact
+ * this is why we place some FBO stuff to the tail
+ * @todo: once we need to increment a saved state version, we could refactor this structure */
+ GLint iCurDrawBuffer;
+ GLint iCurReadBuffer;
+
+ GLuint idDepthStencilRB;
GLuint fboWidth, fboHeight;
- GLuint idPBO;
- void *pvOutputRedirectInstance;
-} CRMuralInfo;
+ GLboolean fHasParentWindow;
-typedef struct {
- char *pszDpyName;
- GLint visualBits;
- int32_t externalID;
-} CRCreateInfo_t;
+ GLboolean fRedirected;
+ GLboolean fForcePresentState;
+ GLboolean fOrPresentOnReenable;
+
+ GLboolean fIsVisible;
+
+ CR_TEXDATA aTexs[2];
+ uint32_t cUsedFBDatas;
+ CR_FBDATA *apUsedFBDatas[CR_MAX_GUEST_MONITORS];
+ CR_FBDATA aFBDatas[CR_MAX_GUEST_MONITORS];
+
+ /* bitfield representing contexts the mural has been ever current with
+ * we just reuse CR_STATE_SHAREDOBJ_USAGE_XXX API here for simplicity */
+ CRbitvalue ctxUsage[CR_MAX_BITARRAY];
+} CRMuralInfo;
typedef struct {
CRContext *pContext;
int SpuContext;
- CRCreateInfo_t CreateInfo;
+ CRCreateInfoEx_t CreateInfo;
+ CRMuralInfo * currentMural;
} CRContextInfo;
/**
@@ -168,10 +336,15 @@ typedef struct {
} CRScreenInfo;
typedef struct {
- int32_t x, y;
- uint32_t w, h;
+ RTRECT Rect;
} CRScreenViewportInfo;
+/* BFB (BlitFramebuffer Blitter) flags
+ * so far only CR_SERVER_BFB_ON_ALWAIS is supported and is alwais used if any flag is set */
+#define CR_SERVER_BFB_DISABLED 0
+#define CR_SERVER_BFB_ON_INVERTED_BLIT 1
+#define CR_SERVER_BFB_ON_STRAIGHT_BLIT 2
+#define CR_SERVER_BFB_ON_ALWAIS (CR_SERVER_BFB_ON_INVERTED_BLIT | CR_SERVER_BFB_ON_STRAIGHT_BLIT)
typedef struct {
unsigned short tcpip_port;
@@ -194,14 +367,12 @@ typedef struct {
CRContextInfo *currentCtxInfo;
GLint currentWindow;
GLint currentNativeWindow;
+ CRMuralInfo *currentMural;
CRHashTable *muralTable; /**< hash table where all murals are stored */
- CRHashTable *pWindowCreateInfoTable; /**< hash table with windows creation info */
int client_spu_id;
- CRServerFreeIDsPool_t idsPool;
-
int mtu;
int buffer_size;
char protocol[1024];
@@ -221,6 +392,23 @@ typedef struct {
CRHashTable *programTable; /**< for vertex programs */
GLuint currentProgram;
+ /* visBits -> dummy mural association */
+ CRHashTable *dummyMuralTable;
+
+ GLboolean fRootVrOn;
+ VBOXVR_LIST RootVr;
+ /* we need to translate Root Vr to each window coords, this one cpecifies the current translation point
+ * note that since window attributes modifications is performed in HGCM thread only and thus is serialized,
+ * we deal with the global RootVr data directly */
+ RTPOINT RootVrCurPoint;
+
+ /* blitter so far used for working around host drivers BlitFramebuffer bugs
+ * by implementing */
+ uint32_t fBlitterMode;
+ CR_BLITTER Blitter;
+
+ CR_SERVER_RPW RpwWorker;
+
/** configuration options */
/*@{*/
int useL2;
@@ -276,14 +464,38 @@ typedef struct {
GLuint currentSerialNo;
PFNCRSERVERPRESENTFBO pfnPresentFBO;
- GLboolean bForceOffscreenRendering; /*Force server to render 3d data offscreen
- *using callback above to update vbox framebuffers*/
+
+ GLuint fVisualBitsDefault;
GLboolean bUsePBOForReadback; /*Use PBO's for data readback*/
- GLboolean bUseOutputRedirect; /* Whether the output redirect was set. */
CROutputRedirect outputRedirect;
GLboolean bUseMultipleContexts;
+
+ GLboolean bWindowsInitiallyHidden;
+
+ /* OR-ed CR_VBOX_CAP_XXX cap values
+ * describing VBox Chromium functionality caps visible to guest
+ * Currently can have only CR_VBOX_CAP_TEX_PRESENT cap to notify
+ * that the TexPresent mechanism is available and enabled */
+ uint32_t u32Caps;
+
+ PFNCRSERVERNOTIFYEVENT pfnNotifyEventCB;
+
+ SPUDispatchTable TmpCtxDispatch;
+
+ VBOXCRCMD_SVRENABLE_INFO CrCmdClientInfo;
+
+#ifdef VBOX_WITH_CRSERVER_DUMPER
+ CR_RECORDER Recorder;
+ CR_BLITTER RecorderBlitter;
+ CR_DBGPRINT_DUMPER DbgPrintDumper;
+ CR_HTML_DUMPER HtmlDumper;
+ CR_DUMPER *pDumper;
+#endif
+
+ int RcToGuest;
+ int RcToGuestOnce;
} CRServer;
@@ -301,16 +513,31 @@ extern DECLEXPORT(void) crVBoxServerRemoveClient(uint32_t u32ClientID);
extern DECLEXPORT(int32_t) crVBoxServerClientWrite(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t cbBuffer);
extern DECLEXPORT(int32_t) crVBoxServerClientRead(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t *pcbBuffer);
extern DECLEXPORT(int32_t) crVBoxServerClientSetVersion(uint32_t u32ClientID, uint32_t vMajor, uint32_t vMinor);
+extern DECLEXPORT(int32_t) crVBoxServerClientGetCaps(uint32_t u32ClientID, uint32_t *pu32Caps);
extern DECLEXPORT(int32_t) crVBoxServerClientSetPID(uint32_t u32ClientID, uint64_t pid);
extern DECLEXPORT(int32_t) crVBoxServerSaveState(PSSMHANDLE pSSM);
extern DECLEXPORT(int32_t) crVBoxServerLoadState(PSSMHANDLE pSSM, uint32_t version);
+typedef struct
+{
+ CR_BLITTER_IMG Img;
+ uint32_t u32Screen;
+ uint32_t fDataAllocated;
+} CR_SCREENSHOT;
+
+extern DECLEXPORT(int) crServerVBoxWindowsShow(bool fShow);
+extern DECLEXPORT(int) crServerVBoxScreenshotGet(uint32_t u32Screen, uint32_t width, uint32_t height, uint32_t pitch, void *pvBuffer, CR_SCREENSHOT *pScreenshot);
+extern DECLEXPORT(void) crServerVBoxScreenshotRelease(CR_SCREENSHOT *pScreenshot);
+
+extern DECLEXPORT(void) crServerVBoxCompositionSetEnableStateGlobal(GLboolean fEnable);
extern DECLEXPORT(int32_t) crVBoxServerSetScreenCount(int sCount);
extern DECLEXPORT(int32_t) crVBoxServerUnmapScreen(int sIndex);
extern DECLEXPORT(int32_t) crVBoxServerMapScreen(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h, uint64_t winID);
-
-extern DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, GLint *pRects);
+extern DECLEXPORT(void) crServerVBoxCompositionSetEnableStateGlobal(GLboolean fEnable);
+struct VBVAINFOSCREEN;
+extern DECLEXPORT(int) crVBoxServerNotifyResize(const struct VBVAINFOSCREEN *pScreen, void *pvVRAM);
+extern DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, const RTRECT *pRects);
extern DECLEXPORT(void) crVBoxServerSetPresentFBOCB(PFNCRSERVERPRESENTFBO pfnPresentFBO);
@@ -320,6 +547,8 @@ extern DECLEXPORT(int32_t) crVBoxServerOutputRedirectSet(const CROutputRedirect
extern DECLEXPORT(int32_t) crVBoxServerSetScreenViewport(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h);
+extern DECLEXPORT(void) crServerVBoxSetNotifyEventCB(PFNCRSERVERNOTIFYEVENT pfnCb);
+
#ifdef VBOX_WITH_CRHGSMI
/* We moved all CrHgsmi command processing to crserverlib to keep the logic of dealing with CrHgsmi commands in one place.
*
@@ -336,8 +565,14 @@ extern DECLEXPORT(int32_t) crVBoxServerSetScreenViewport(int sIndex, int32_t x,
* */
extern DECLEXPORT(int32_t) crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, uint32_t cbCmd);
extern DECLEXPORT(int32_t) crVBoxServerCrHgsmiCtl(struct VBOXVDMACMD_CHROMIUM_CTL *pCtl, uint32_t cbCtl);
+
#endif
+extern DECLEXPORT(int32_t) crVBoxServerHgcmEnable(HVBOXCRCMDCTL_REMAINING_HOST_COMMAND hRHCmd, PFNVBOXCRCMDCTL_REMAINING_HOST_COMMAND pfnRHCmd);
+extern DECLEXPORT(int32_t) crVBoxServerHgcmDisable();
+
+extern int crVBoxServerHostCtl(VBOXCRCMDCTL *pCtl, uint32_t cbCtl);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_string.h b/src/VBox/GuestHost/OpenGL/include/cr_string.h
index 87f1df38..972d08f1 100644
--- a/src/VBox/GuestHost/OpenGL/include/cr_string.h
+++ b/src/VBox/GuestHost/OpenGL/include/cr_string.h
@@ -36,6 +36,30 @@ DECLEXPORT(int) crIsDigit( char c );
DECLEXPORT(void) crBytesToString( char *string, int nstring, void *data, int ndata );
DECLEXPORT(void) crWordsToString( char *string, int nstring, void *data, int ndata );
+#define CR_GLVERSION_OFFSET_MAJOR (24)
+#define CR_GLVERSION_OFFSET_MINOR (16)
+#define CR_GLVERSION_OFFSET_BUILD (0)
+
+#define CR_GLVERSION_MAX_MAJOR (0x7f)
+#define CR_GLVERSION_MAX_MINOR (0xff)
+#define CR_GLVERSION_MAX_BUILD (0xffff)
+
+#define CR_GLVERSION_MASK_MAJOR (CR_GLVERSION_MAX_MAJOR << CR_GLVERSION_OFFSET_MAJOR)
+#define CR_GLVERSION_MASK_MINOR (CR_GLVERSION_MAX_MINOR << CR_GLVERSION_OFFSET_MINOR)
+#define CR_GLVERSION_MASK_BUILD (CR_GLVERSION_MAX_BUILD << CR_GLVERSION_OFFSET_BUILD)
+
+#define CR_GLVERSION_COMPOSE_EL(_val, _type) (((_val) << CR_GLVERSION_OFFSET_##_type) & CR_GLVERSION_MASK_##_type)
+
+#define CR_GLVERSION_COMPOSE(_maj, _min, _build) (CR_GLVERSION_COMPOSE_EL((_maj), MAJOR) \
+ + CR_GLVERSION_COMPOSE_EL((_min), MINOR) \
+ + CR_GLVERSION_COMPOSE_EL((_build), BUILD))
+
+#define CR_GLVERSION_GET_EL(_val, _type) (((_val) & CR_GLVERSION_MASK_##_type) >> CR_GLVERSION_OFFSET_##_type)
+#define CR_GLVERSION_GET_MAJOR(_val) CR_GLVERSION_GET_EL((_val), MAJOR)
+#define CR_GLVERSION_GET_MINOR(_val) CR_GLVERSION_GET_EL((_val), MINOR)
+#define CR_GLVERSION_GET_BUILD(_val) CR_GLVERSION_GET_EL((_val), BUILD)
+
+DECLEXPORT(int) crStrParseGlVersion(const char * ver);
RT_C_DECLS_END
#endif /* CR_STRING_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_version.h b/src/VBox/GuestHost/OpenGL/include/cr_version.h
index 06d99de6..6b6a7c5f 100644
--- a/src/VBox/GuestHost/OpenGL/include/cr_version.h
+++ b/src/VBox/GuestHost/OpenGL/include/cr_version.h
@@ -7,9 +7,40 @@
#ifndef CR_VERSION_H
#define CR_VERSION_H
-#define SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS 28
-#define SHCROGL_SSM_VERSION_BEFORE_FRONT_DRAW_TRACKING 29
-#define SHCROGL_SSM_VERSION 30
+#define SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS 28
+/* version which might have context usage bits saved */
+#define SHCROGL_SSM_VERSION_WITH_SAVED_CTXUSAGE_BITS SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS
+#define SHCROGL_SSM_VERSION_BEFORE_FRONT_DRAW_TRACKING 29
+/* version that might have corrupted state data */
+#define SHCROGL_SSM_VERSION_WITH_CORUPTED_STATE 30
+/* version with invalid glGetError state */
+#define SHCROGL_SSM_VERSION_WITH_INVALID_ERROR_STATE 30
+/* VBox 4.2.12 had a bug that incorrectly CRMuralInfo data
+ * in a different format without changing the state version,
+ * i.e. 30 version can have both "correct" and "incorrect" CRMuralInfo data */
+#define SHCROGL_SSM_VERSION_WITH_BUGGY_MURAL_INFO 30
+/* the saved state has incorrect front and back buffer image data */
+#define SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA 31
+#define SHCROGL_SSM_VERSION_WITH_STATE_BITS 33
+#define SHCROGL_SSM_VERSION_WITH_WINDOW_CTX_USAGE 33
+#define SHCROGL_SSM_VERSION_WITH_FIXED_STENCIL 34
+#define SHCROGL_SSM_VERSION_WITH_SAVED_DEPTH_STENCIL_BUFFER 35
+/* some ogl drivers fail to Read/DrawPixels for DEPTH and STENCIL separately
+ * from DEPTH_STENCIL renderbuffer we used for offscreen rendering
+ * this is why we switched to glReadDrawPixels(GL_DEPTH_STENCIL) in one run */
+#define SHCROGL_SSM_VERSION_WITH_SINGLE_DEPTH_STENCIL 36
+#define SHCROGL_SSM_VERSION_WITH_PRESENT_STATE 37
+/* older state did not have glPointParameter ( GL_POINT_SPRITE_COORD_ORIGIN ) implementation */
+#define SHCROGL_SSM_VERSION_WITH_SPRITE_COORD_ORIGIN 38
+/* dirty bits are not needed for now, remove */
+#define SHCROGL_SSM_VERSION_WITHOUT_DIRTY_BITS 38
+/* dummy windows and contexts have 0 external IDs, so never get stored to the state */
+#define SHCROGL_SSM_VERSION_WITH_FIXED_DUMMYIDS 39
+#define SHCROGL_SSM_VERSION_WITH_SCREEN_INFO 40
+#define SHCROGL_SSM_VERSION_WITH_ALLOCATED_KEYS 41
+#define SHCROGL_SSM_VERSION_WITH_FB_INFO 42
+#define SHCROGL_SSM_VERSION_WITH_BUGGY_KEYS 42
+#define SHCROGL_SSM_VERSION 43
/* These define the Chromium release number.
* Alpha Release = 0.1.0, Beta Release = 0.2.0
@@ -139,4 +170,6 @@
#define CR_EXT_blend_equation_separate 1
#define CR_EXT_stencil_two_side 1
+#define CR_GREMEDY_string_marker 1
+
#endif /* CR_VERSION_H */
diff --git a/src/VBox/GuestHost/OpenGL/include/cr_vreg.h b/src/VBox/GuestHost/OpenGL/include/cr_vreg.h
new file mode 100644
index 00000000..0f5786be
--- /dev/null
+++ b/src/VBox/GuestHost/OpenGL/include/cr_vreg.h
@@ -0,0 +1,377 @@
+/* $Id: cr_vreg.h $ */
+
+/** @file
+ * Visible Regions processing API
+ */
+
+/*
+ * Copyright (C) 2012 Oracle Corporation
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License (GPL) as published by the Free Software
+ * Foundation, in version 2 as it comes in the "COPYING" file of the
+ * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
+ * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
+ */
+#ifndef ___cr_vreg_h_
+#define ___cr_vreg_h_
+
+#include <iprt/list.h>
+#include <iprt/types.h>
+#include <iprt/mem.h>
+#include <iprt/string.h>
+#include <iprt/assert.h>
+#include <iprt/critsect.h>
+#include <iprt/asm.h>
+
+#ifndef IN_RING0
+# define VBOXVREGDECL(_type) DECLEXPORT(_type)
+#else
+# define VBOXVREGDECL(_type) RTDECL(_type)
+#endif
+
+
+
+RT_C_DECLS_BEGIN
+
+typedef struct VBOXVR_LIST
+{
+ RTLISTNODE ListHead;
+ uint32_t cEntries;
+} VBOXVR_LIST, *PVBOXVR_LIST;
+
+DECLINLINE(int) VBoxRectCmp(const RTRECT * pRect1, const RTRECT * pRect2)
+{
+ return memcmp(pRect1, pRect2, sizeof (*pRect1));
+}
+
+#ifndef IN_RING0
+#define CR_FLOAT_RCAST(_t, _v) ((_t)((float)(_v) + 0.5))
+
+DECLINLINE(void) VBoxRectScale(PRTRECT pRect, float xScale, float yScale)
+{
+ pRect->xLeft = CR_FLOAT_RCAST(int32_t, pRect->xLeft * xScale);
+ pRect->yTop = CR_FLOAT_RCAST(int32_t, pRect->yTop * yScale);
+ pRect->xRight = CR_FLOAT_RCAST(int32_t, pRect->xRight * xScale);
+ pRect->yBottom = CR_FLOAT_RCAST(int32_t, pRect->yBottom * yScale);
+}
+
+DECLINLINE(void) VBoxRectScaled(const RTRECT *pRect, float xScale, float yScale, PRTRECT pResult)
+{
+ *pResult = *pRect;
+ VBoxRectScale(pResult, xScale, yScale);
+}
+
+DECLINLINE(void) VBoxRectUnscale(PRTRECT pRect, float xScale, float yScale)
+{
+ pRect->xLeft = CR_FLOAT_RCAST(int32_t, pRect->xLeft / xScale);
+ pRect->yTop = CR_FLOAT_RCAST(int32_t, pRect->yTop / yScale);
+ pRect->xRight = CR_FLOAT_RCAST(int32_t, pRect->xRight / xScale);
+ pRect->yBottom = CR_FLOAT_RCAST(int32_t, pRect->yBottom / yScale);
+}
+
+DECLINLINE(void) VBoxRectUnscaled(const RTRECT *pRect, float xScale, float yScale, PRTRECT pResult)
+{
+ *pResult = *pRect;
+ VBoxRectUnscale(pResult, xScale, yScale);
+}
+#endif
+
+DECLINLINE(void) VBoxRectIntersect(PRTRECT pRect1, const RTRECT * pRect2)
+{
+ Assert(pRect1);
+ Assert(pRect2);
+ pRect1->xLeft = RT_MAX(pRect1->xLeft, pRect2->xLeft);
+ pRect1->yTop = RT_MAX(pRect1->yTop, pRect2->yTop);
+ pRect1->xRight = RT_MIN(pRect1->xRight, pRect2->xRight);
+ pRect1->yBottom = RT_MIN(pRect1->yBottom, pRect2->yBottom);
+}
+
+DECLINLINE(void) VBoxRectIntersected(const RTRECT *pRect1, const RTRECT * pRect2, RTRECT *pResult)
+{
+ *pResult = *pRect1;
+ VBoxRectIntersect(pResult, pRect2);
+}
+
+
+DECLINLINE(void) VBoxRectTranslate(RTRECT * pRect, int32_t x, int32_t y)
+{
+ pRect->xLeft += x;
+ pRect->yTop += y;
+ pRect->xRight += x;
+ pRect->yBottom += y;
+}
+
+DECLINLINE(void) VBoxRectTranslated(const RTRECT * pRect, int32_t x, int32_t y, RTRECT *pResult)
+{
+ *pResult = *pRect;
+ VBoxRectTranslate(pResult, x, y);
+}
+
+DECLINLINE(void) VBoxRectInvertY(RTRECT * pRect)
+{
+ int32_t y = pRect->yTop;
+ pRect->yTop = pRect->yBottom;
+ pRect->yBottom = y;
+}
+
+DECLINLINE(void) VBoxRectInvertedY(const RTRECT * pRect, RTRECT * pResult)
+{
+ *pResult = *pRect;
+ VBoxRectInvertY(pResult);
+}
+
+DECLINLINE(void) VBoxRectMove(RTRECT * pRect, int32_t x, int32_t y)
+{
+ int32_t w = pRect->xRight - pRect->xLeft;
+ int32_t h = pRect->yBottom - pRect->yTop;
+ pRect->xLeft = x;
+ pRect->yTop = y;
+ pRect->xRight = w + x;
+ pRect->yBottom = h + y;
+}
+
+DECLINLINE(void) VBoxRectMoved(const RTRECT * pRect, int32_t x, int32_t y, RTRECT *pResult)
+{
+ *pResult = *pRect;
+ VBoxRectMove(pResult, x, y);
+}
+
+DECLINLINE(bool) VBoxRectCovers(const RTRECT *pRect, const RTRECT *pCovered)
+{
+ Assert(pRect);
+ Assert(pCovered);
+ if (pRect->xLeft > pCovered->xLeft)
+ return false;
+ if (pRect->yTop > pCovered->yTop)
+ return false;
+ if (pRect->xRight < pCovered->xRight)
+ return false;
+ if (pRect->yBottom < pCovered->yBottom)
+ return false;
+ return true;
+}
+
+DECLINLINE(bool) VBoxRectIsZero(const RTRECT *pRect)
+{
+ return pRect->xLeft == pRect->xRight || pRect->yTop == pRect->yBottom;
+}
+
+DECLINLINE(bool) VBoxRectIsIntersect(const RTRECT * pRect1, const RTRECT * pRect2)
+{
+ return !((pRect1->xLeft < pRect2->xLeft && pRect1->xRight <= pRect2->xLeft)
+ || (pRect2->xLeft < pRect1->xLeft && pRect2->xRight <= pRect1->xLeft)
+ || (pRect1->yTop < pRect2->yTop && pRect1->yBottom <= pRect2->yTop)
+ || (pRect2->yTop < pRect1->yTop && pRect2->yBottom <= pRect1->yTop));
+}
+
+DECLINLINE(uint32_t) VBoxVrListRectsCount(const VBOXVR_LIST *pList)
+{
+ return pList->cEntries;
+}
+
+DECLINLINE(bool) VBoxVrListIsEmpty(const VBOXVR_LIST *pList)
+{
+ return !VBoxVrListRectsCount(pList);
+}
+
+DECLINLINE(void) VBoxVrListInit(PVBOXVR_LIST pList)
+{
+ RTListInit(&pList->ListHead);
+ pList->cEntries = 0;
+}
+
+VBOXVREGDECL(void) VBoxVrListClear(PVBOXVR_LIST pList);
+
+/* moves list data to pDstList and empties the pList */
+VBOXVREGDECL(void) VBoxVrListMoveTo(PVBOXVR_LIST pList, PVBOXVR_LIST pDstList);
+
+VBOXVREGDECL(void) VBoxVrListTranslate(PVBOXVR_LIST pList, int32_t x, int32_t y);
+
+VBOXVREGDECL(int) VBoxVrListCmp(const VBOXVR_LIST *pList1, const VBOXVR_LIST *pList2);
+
+VBOXVREGDECL(int) VBoxVrListRectsSet(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
+VBOXVREGDECL(int) VBoxVrListRectsAdd(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
+VBOXVREGDECL(int) VBoxVrListRectsSubst(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
+VBOXVREGDECL(int) VBoxVrListRectsGet(PVBOXVR_LIST pList, uint32_t cRects, RTRECT * aRects);
+
+VBOXVREGDECL(int) VBoxVrListClone(const VBOXVR_LIST *pList, VBOXVR_LIST *pDstList);
+
+/* NOTE: with the current implementation the VBoxVrListIntersect is faster than VBoxVrListRectsIntersect,
+ * i.e. VBoxVrListRectsIntersect is actually a convenience function that create a temporary list and calls VBoxVrListIntersect internally */
+VBOXVREGDECL(int) VBoxVrListRectsIntersect(PVBOXVR_LIST pList, uint32_t cRects, const RTRECT * aRects, bool *pfChanged);
+VBOXVREGDECL(int) VBoxVrListIntersect(PVBOXVR_LIST pList, const VBOXVR_LIST *pList2, bool *pfChanged);
+
+VBOXVREGDECL(int) VBoxVrInit(void);
+VBOXVREGDECL(void) VBoxVrTerm(void);
+
+typedef struct VBOXVR_LIST_ITERATOR
+{
+ PVBOXVR_LIST pList;
+ PRTLISTNODE pNextEntry;
+} VBOXVR_LIST_ITERATOR, *PVBOXVR_LIST_ITERATOR;
+
+DECLINLINE(void) VBoxVrListIterInit(PVBOXVR_LIST pList, PVBOXVR_LIST_ITERATOR pIter)
+{
+ pIter->pList = pList;
+ pIter->pNextEntry = pList->ListHead.pNext;
+}
+
+typedef struct VBOXVR_REG
+{
+ RTLISTNODE ListEntry;
+ RTRECT Rect;
+} VBOXVR_REG, *PVBOXVR_REG;
+
+#define PVBOXVR_REG_FROM_ENTRY(_pEntry) ((PVBOXVR_REG)(((uint8_t*)(_pEntry)) - RT_OFFSETOF(VBOXVR_REG, ListEntry)))
+
+DECLINLINE(PCRTRECT) VBoxVrListIterNext(PVBOXVR_LIST_ITERATOR pIter)
+{
+ PRTLISTNODE pNextEntry = pIter->pNextEntry;
+ if (pNextEntry != &pIter->pList->ListHead)
+ {
+ PCRTRECT pRect = &(PVBOXVR_REG_FROM_ENTRY(pNextEntry)->Rect);
+ pIter->pNextEntry = pNextEntry->pNext;
+ return pRect;
+ }
+ return NULL;
+}
+
+typedef struct VBOXVR_COMPOSITOR_ENTRY
+{
+ RTLISTNODE Node;
+ VBOXVR_LIST Vr;
+ uint32_t cRefs;
+} VBOXVR_COMPOSITOR_ENTRY, *PVBOXVR_COMPOSITOR_ENTRY;
+
+struct VBOXVR_COMPOSITOR;
+
+typedef DECLCALLBACK(void) FNVBOXVRCOMPOSITOR_ENTRY_RELEASED(const struct VBOXVR_COMPOSITOR *pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry);
+typedef FNVBOXVRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED;
+
+typedef struct VBOXVR_COMPOSITOR
+{
+ RTLISTNODE List;
+ PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased;
+} VBOXVR_COMPOSITOR, *PVBOXVR_COMPOSITOR;
+
+typedef DECLCALLBACK(bool) FNVBOXVRCOMPOSITOR_VISITOR(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, void *pvVisitor);
+typedef FNVBOXVRCOMPOSITOR_VISITOR *PFNVBOXVRCOMPOSITOR_VISITOR;
+
+VBOXVREGDECL(void) VBoxVrCompositorInit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased);
+VBOXVREGDECL(void) VBoxVrCompositorClear(PVBOXVR_COMPOSITOR pCompositor);
+VBOXVREGDECL(void) VBoxVrCompositorRegionsClear(PVBOXVR_COMPOSITOR pCompositor, bool *pfChanged);
+VBOXVREGDECL(void) VBoxVrCompositorEntryInit(PVBOXVR_COMPOSITOR_ENTRY pEntry);
+DECLINLINE(bool) VBoxVrCompositorEntryIsInList(const VBOXVR_COMPOSITOR_ENTRY *pEntry)
+{
+ return !VBoxVrListIsEmpty(&pEntry->Vr);
+}
+
+#define CRBLT_F_LINEAR 0x00000001
+#define CRBLT_F_INVERT_SRC_YCOORDS 0x00000002
+#define CRBLT_F_INVERT_DST_YCOORDS 0x00000004
+#define CRBLT_F_INVERT_YCOORDS (CRBLT_F_INVERT_SRC_YCOORDS | CRBLT_F_INVERT_DST_YCOORDS)
+/* the blit operation with discard the source alpha channel values and set the destination alpha values to 1.0 */
+#define CRBLT_F_NOALPHA 0x00000010
+
+#define CRBLT_FTYPE_XOR CRBLT_F_INVERT_YCOORDS
+#define CRBLT_FTYPE_OR (CRBLT_F_LINEAR | CRBLT_F_NOALPHA)
+#define CRBLT_FOP_COMBINE(_f1, _f2) ((((_f1) ^ (_f2)) & CRBLT_FTYPE_XOR) | (((_f1) | (_f2)) & CRBLT_FTYPE_OR))
+
+#define CRBLT_FLAGS_FROM_FILTER(_f) ( ((_f) & GL_LINEAR) ? CRBLT_F_LINEAR : 0)
+#define CRBLT_FILTER_FROM_FLAGS(_f) (((_f) & CRBLT_F_LINEAR) ? GL_LINEAR : GL_NEAREST)
+
+/* compositor regions changed */
+#define VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED 0x00000001
+/* other entries changed along while doing current entry modification
+ * always comes with VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED */
+#define VBOXVR_COMPOSITOR_CF_OTHER_ENTRIES_REGIONS_CHANGED 0x00000002
+/* only current entry regions changed
+ * can come wither with VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED or with VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED */
+#define VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED 0x00000004
+/* the given entry has replaced some other entry, while overal regions did NOT change.
+ * always comes with VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED */
+#define VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED 0x00000008
+
+
+VBOXVREGDECL(bool) VBoxVrCompositorEntryRemove(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry);
+VBOXVREGDECL(bool) VBoxVrCompositorEntryReplace(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, PVBOXVR_COMPOSITOR_ENTRY pNewEntry);
+VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsAdd(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, PVBOXVR_COMPOSITOR_ENTRY *ppReplacedEntry, uint32_t *pfChangeFlags);
+VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSubst(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
+VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSet(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
+VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
+VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, const VBOXVR_LIST *pList2, bool *pfChanged);
+VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersectAll(PVBOXVR_COMPOSITOR pCompositor, uint32_t cRegions, const RTRECT *paRegions, bool *pfChanged);
+VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersectAll(PVBOXVR_COMPOSITOR pCompositor, const VBOXVR_LIST *pList2, bool *pfChanged);
+VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsTranslate(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, int32_t x, int32_t y, bool *pfChanged);
+VBOXVREGDECL(void) VBoxVrCompositorVisit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_VISITOR pfnVisitor, void *pvVisitor);
+
+DECLINLINE(bool) VBoxVrCompositorIsEmpty(const VBOXVR_COMPOSITOR *pCompositor)
+{
+ return RTListIsEmpty(&pCompositor->List);
+}
+
+typedef struct VBOXVR_COMPOSITOR_ITERATOR
+{
+ PVBOXVR_COMPOSITOR pCompositor;
+ PRTLISTNODE pNextEntry;
+} VBOXVR_COMPOSITOR_ITERATOR ,*PVBOXVR_COMPOSITOR_ITERATOR;
+
+typedef struct VBOXVR_COMPOSITOR_CONST_ITERATOR
+{
+ const VBOXVR_COMPOSITOR *pCompositor;
+ const RTLISTNODE *pNextEntry;
+} VBOXVR_COMPOSITOR_CONST_ITERATOR ,*PVBOXVR_COMPOSITOR_CONST_ITERATOR;
+
+DECLINLINE(void) VBoxVrCompositorIterInit(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ITERATOR pIter)
+{
+ pIter->pCompositor = pCompositor;
+ pIter->pNextEntry = pCompositor->List.pNext;
+}
+
+DECLINLINE(void) VBoxVrCompositorConstIterInit(const VBOXVR_COMPOSITOR *pCompositor, PVBOXVR_COMPOSITOR_CONST_ITERATOR pIter)
+{
+ pIter->pCompositor = pCompositor;
+ pIter->pNextEntry = pCompositor->List.pNext;
+}
+
+#define VBOXVR_COMPOSITOR_ENTRY_FROM_NODE(_p) ((PVBOXVR_COMPOSITOR_ENTRY)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_COMPOSITOR_ENTRY, Node)))
+#define VBOXVR_COMPOSITOR_CONST_ENTRY_FROM_NODE(_p) ((const VBOXVR_COMPOSITOR_ENTRY*)(((uint8_t*)(_p)) - RT_OFFSETOF(VBOXVR_COMPOSITOR_ENTRY, Node)))
+
+DECLINLINE(PVBOXVR_COMPOSITOR_ENTRY) VBoxVrCompositorIterNext(PVBOXVR_COMPOSITOR_ITERATOR pIter)
+{
+ PRTLISTNODE pNextEntry = pIter->pNextEntry;
+ if (pNextEntry != &pIter->pCompositor->List)
+ {
+ PVBOXVR_COMPOSITOR_ENTRY pEntry = VBOXVR_COMPOSITOR_ENTRY_FROM_NODE(pNextEntry);
+ pIter->pNextEntry = pNextEntry->pNext;
+ return pEntry;
+ }
+ return NULL;
+}
+
+DECLINLINE(const VBOXVR_COMPOSITOR_ENTRY*) VBoxVrCompositorConstIterNext(PVBOXVR_COMPOSITOR_CONST_ITERATOR pIter)
+{
+ const RTLISTNODE *pNextEntry = pIter->pNextEntry;
+ if (pNextEntry != &pIter->pCompositor->List)
+ {
+ const VBOXVR_COMPOSITOR_ENTRY *pEntry = VBOXVR_COMPOSITOR_CONST_ENTRY_FROM_NODE(pNextEntry);
+ pIter->pNextEntry = pNextEntry->pNext;
+ return pEntry;
+ }
+ return NULL;
+}
+
+typedef struct VBOXVR_TEXTURE
+{
+ int32_t width;
+ int32_t height;
+ uint32_t target;
+ uint32_t hwid;
+} VBOXVR_TEXTURE, *PVBOXVR_TEXTURE;
+
+RT_C_DECLS_END
+
+#endif /* #ifndef ___cr_vreg_h_ */
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h b/src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h
index 855f5736..579e71dd 100644
--- a/src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h
@@ -245,6 +245,18 @@ typedef struct {
GLenum passDepthPass;
GLint clearValue;
GLint writeMask;
+} CRStencilBufferStack_v_33;
+
+typedef struct {
+ /* true if stencil test is enabled */
+ GLboolean stencilTest;
+ /* true if GL_EXT_stencil_two_side is enabled (glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)) */
+ GLboolean stencilTwoSideEXT;
+ /* GL_FRONT or GL_BACK */
+ GLenum activeStencilFace;
+ GLint clearValue;
+ GLint writeMask;
+ CRStencilBufferState buffers[CRSTATE_STENCIL_BUFFER_COUNT];
} CRStencilBufferStack;
typedef struct {
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h b/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h
index d83ac973..8584adc0 100644
--- a/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h
@@ -41,10 +41,8 @@ typedef struct {
so we need to resync every time guest wants to read from it*/
CRbitvalue dirty[CR_MAX_BITARRAY]; /* dirty data or state */
GLintptrARB dirtyStart, dirtyLength; /* dirty region */
-#ifndef IN_GUEST
/* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */
CRbitvalue ctxUsage[CR_MAX_BITARRAY];
-#endif
} CRBufferObject;
typedef struct {
@@ -59,10 +57,13 @@ typedef struct {
DECLEXPORT(CRBufferObject *) crStateGetBoundBufferObject(GLenum target, CRBufferObjectState *b);
DECLEXPORT(GLboolean) crStateIsBufferBound(GLenum target);
+struct CRContext;
+DECLEXPORT(GLboolean) crStateIsBufferBoundForCtx(struct CRContext *g, GLenum target);
DECLEXPORT(GLuint) STATE_APIENTRY crStateBufferHWIDtoID(GLuint hwid);
DECLEXPORT(GLuint) STATE_APIENTRY crStateGetBufferHWID(GLuint id);
+DECLEXPORT(void) crStateRegBuffers(GLsizei n, GLuint *buffers);
#ifdef __cplusplus
}
#endif
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_client.h b/src/VBox/GuestHost/OpenGL/include/state/cr_client.h
index e328857a..a727f260 100644
--- a/src/VBox/GuestHost/OpenGL/include/state/cr_client.h
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_client.h
@@ -125,10 +125,12 @@ typedef struct {
extern const CRPixelPackState crStateNativePixelPacking;
+struct CRContext;
+
DECLEXPORT(void) crStateClientInitBits(CRClientBits *c);
DECLEXPORT(void) crStateClientDestroyBits(CRClientBits *c);
-DECLEXPORT(void) crStateClientInit(CRClientState *c);
-DECLEXPORT(void) crStateClientDestroy(CRClientState *c);
+DECLEXPORT(void) crStateClientInit(struct CRContext *g);
+DECLEXPORT(void) crStateClientDestroy(struct CRContext *g);
DECLEXPORT(GLboolean) crStateUseServerArrays(void);
DECLEXPORT(GLboolean) crStateUseServerArrayElements(void);
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h b/src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h
index adc7b3b2..f8da8a7c 100644
--- a/src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -48,10 +48,9 @@ typedef struct {
GLenum drawbuffer[1];
#ifdef IN_GUEST
GLenum status;
-#else
+#endif
/* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */
CRbitvalue ctxUsage[CR_MAX_BITARRAY];
-#endif
} CRFramebufferObject;
typedef struct {
@@ -59,10 +58,8 @@ typedef struct {
GLsizei width, height;
GLenum internalformat;
GLuint redBits, greenBits, blueBits, alphaBits, depthBits, stencilBits;
-#ifndef IN_GUEST
/* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */
CRbitvalue ctxUsage[CR_MAX_BITARRAY];
-#endif
} CRRenderbufferObject;
typedef struct {
@@ -74,8 +71,8 @@ DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectInit(CRContext *ctx);
DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectDestroy(CRContext *ctx);
DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectSwitch(CRContext *from, CRContext *to);
-DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectDisableHW(CRContext *ctx, GLuint idFBO);
-DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectReenableHW(CRContext *fromCtx, CRContext *toCtx, GLuint idFBO);
+DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectDisableHW(CRContext *ctx, GLuint idDrawFBO, GLuint idReadFBO);
+DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectReenableHW(CRContext *fromCtx, CRContext *toCtx, GLuint idDrawFBO, GLuint idReadFBO);
DECLEXPORT(GLuint) STATE_APIENTRY crStateGetFramebufferHWID(GLuint id);
DECLEXPORT(GLuint) STATE_APIENTRY crStateGetRenderbufferHWID(GLuint id);
@@ -96,6 +93,9 @@ DECLEXPORT(void) STATE_APIENTRY crStateGenerateMipmapEXT(GLenum target);
DECLEXPORT(GLuint) STATE_APIENTRY crStateFBOHWIDtoID(GLuint hwid);
DECLEXPORT(GLuint) STATE_APIENTRY crStateRBOHWIDtoID(GLuint hwid);
+DECLEXPORT(void) crStateRegFramebuffers(GLsizei n, GLuint *buffers);
+DECLEXPORT(void) crStateRegRenderbuffers(GLsizei n, GLuint *buffers);
+
#ifdef IN_GUEST
DECLEXPORT(GLenum) STATE_APIENTRY crStateCheckFramebufferStatusEXT(GLenum target);
DECLEXPORT(GLenum) STATE_APIENTRY crStateSetFramebufferStatus(GLenum target, GLenum status);
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h b/src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h
index 2713c434..81ed568e 100644
--- a/src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (C) 2009 Oracle Corporation
+ * Copyright (C) 2009-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
@@ -99,6 +99,7 @@ DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsIntUniform(GLenum type);
DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateShader(GLuint id, GLenum type);
DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateProgram(GLuint id);
+DECLEXPORT(GLuint) STATE_APIENTRY crStateDeleteObjectARB( VBoxGLhandleARB obj );
DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsProgramUniformsCached(GLuint program);
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_point.h b/src/VBox/GuestHost/OpenGL/include/state/cr_point.h
index 4f5987b0..fe3dffe3 100644
--- a/src/VBox/GuestHost/OpenGL/include/state/cr_point.h
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_point.h
@@ -28,6 +28,7 @@ typedef struct {
CRbitvalue enableSprite[CR_MAX_BITARRAY];
CRbitvalue coordReplacement[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
#endif
+ CRbitvalue spriteCoordOrigin[CR_MAX_BITARRAY];
CRbitvalue dirty[CR_MAX_BITARRAY];
} CRPointBits;
@@ -43,6 +44,8 @@ typedef struct {
GLboolean pointSprite;
GLboolean coordReplacement[CR_MAX_TEXTURE_UNITS];
#endif
+ GLfloat spriteCoordOrigin;
+ GLfloat reserved; /* added to make sure alignment of sttructures following CRPointState in CRContext does not change */
} CRPointState;
DECLEXPORT(void) crStatePointInit (CRContext *ctx);
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h b/src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h
index 1443e951..27823eb2 100644
--- a/src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h
@@ -11,33 +11,89 @@
#include "state/cr_statetypes.h"
#include <iprt/cdefs.h>
+#include <iprt/assert.h>
#ifdef __cplusplus
extern "C" {
#endif
+#define CRSTATE_STENCIL_BUFFER_ID_FRONT 0
+#define CRSTATE_STENCIL_BUFFER_ID_BACK 1
+#define CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK 2
+#define CRSTATE_STENCIL_BUFFER_COUNT 3
+
+/* stencil buffer settings were accessed with StencilXxx with ActiveStencilFaceEXT == GL_FRONT or StencilXxxSeparate(GL_FRONT_AND_BACK) */
+#define CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK 0
+/* stencil buffer settings were accessed with StencilXxxSeparate(GL_FRONT_FRONT) */
+#define CRSTATE_STENCIL_BUFFER_REF_ID_FRONT 1
+/* stencil buffer settings were accessed with StencilXxxSeparate(GL_FRONT_BACK) */
+#define CRSTATE_STENCIL_BUFFER_REF_ID_BACK 2
+/* stencil buffer settings were accessed with StencilXxx with ActiveStencilFaceEXT == GL_BACK */
+#define CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK 3
+#define CRSTATE_STENCIL_BUFFER_REF_COUNT 4
+
+typedef struct {
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue func[CR_MAX_BITARRAY];
+ CRbitvalue op[CR_MAX_BITARRAY];
+ CRbitvalue clearValue[CR_MAX_BITARRAY];
+ CRbitvalue writeMask[CR_MAX_BITARRAY];
+} CRStencilBits_v_33;
+
+typedef struct {
+ CRbitvalue func[CR_MAX_BITARRAY];
+ CRbitvalue op[CR_MAX_BITARRAY];
+} CRStencilBufferRefBits;
+
typedef struct {
- CRbitvalue dirty[CR_MAX_BITARRAY];
- CRbitvalue enable[CR_MAX_BITARRAY];
- CRbitvalue func[CR_MAX_BITARRAY];
- CRbitvalue op[CR_MAX_BITARRAY];
- CRbitvalue clearValue[CR_MAX_BITARRAY];
- CRbitvalue writeMask[CR_MAX_BITARRAY];
+ CRbitvalue dirty[CR_MAX_BITARRAY];
+ CRbitvalue enable[CR_MAX_BITARRAY];
+ CRbitvalue enableTwoSideEXT[CR_MAX_BITARRAY];
+ CRbitvalue activeStencilFace[CR_MAX_BITARRAY];
+ CRbitvalue clearValue[CR_MAX_BITARRAY];
+ CRbitvalue writeMask[CR_MAX_BITARRAY];
+ /* note: here we use _BUFFER_REF_ rather than _REF_ because we track the way buffers are accessed here,
+ * to ensure the correct function is called on hw->chromium state restoration,
+ * i.e. we want to avoid always calling StencilXxxSeparate, but call StencilXxx when it was actually called */
+ CRStencilBufferRefBits bufferRefs[CRSTATE_STENCIL_BUFFER_REF_COUNT];
} CRStencilBits;
typedef struct {
+ GLboolean stencilTest;
+ GLenum func;
+ GLint mask;
+ GLint ref;
+ GLenum fail;
+ GLenum passDepthFail;
+ GLenum passDepthPass;
+ GLint clearValue;
+ GLint writeMask;
+} CRStencilState_v_33;
+
+typedef struct {
+ GLenum func;
+ GLint mask;
+ GLint ref;
+ GLenum fail;
+ GLenum passDepthFail;
+ GLenum passDepthPass;
+} CRStencilBufferState;
+
+typedef struct {
+ /* true if stencil test is enabled */
GLboolean stencilTest;
- GLenum func;
- GLint mask;
- GLint ref;
- GLenum fail;
- GLenum passDepthFail;
- GLenum passDepthPass;
- GLint clearValue;
- GLint writeMask;
+ /* true if GL_EXT_stencil_two_side is enabled (glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)) */
+ GLboolean stencilTwoSideEXT;
+ /* GL_FRONT or GL_BACK */
+ GLenum activeStencilFace;
+ GLint clearValue;
+ GLint writeMask;
+ CRStencilBufferState buffers[CRSTATE_STENCIL_BUFFER_COUNT];
} CRStencilState;
DECLEXPORT(void) crStateStencilInit(CRContext *ctx);
+DECLEXPORT(void) crStateStencilBufferInit(CRStencilBufferState *s);
DECLEXPORT(void) crStateStencilDiff(CRStencilBits *bb, CRbitvalue *bitID,
CRContext *fromCtx, CRContext *toCtx);
diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h b/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h
index 5d0262d4..c55d0da9 100644
--- a/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h
+++ b/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h
@@ -96,10 +96,8 @@ typedef struct {
CRbitvalue dirty[CR_MAX_BITARRAY];
CRbitvalue imageBit[CR_MAX_BITARRAY];
CRbitvalue paramsBit[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY];
-#ifndef IN_GUEST
/* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */
CRbitvalue ctxUsage[CR_MAX_BITARRAY];
-#endif
} CRTextureObj;
typedef struct {
@@ -242,6 +240,8 @@ DECLEXPORT(GLuint) STATE_APIENTRY crStateTextureHWIDtoID(GLuint hwid);
DECLEXPORT(GLuint) STATE_APIENTRY crStateGetTextureHWID(GLuint id);
DECLEXPORT(GLuint) STATE_APIENTRY crStateGetTextureObjHWID(CRTextureObj *tobj);
+void crStateRegTextures(GLsizei n, GLuint *names);
+
#ifdef __cplusplus
}
#endif