VirtualBox

Changeset 23732 in vbox


Ignore:
Timestamp:
Oct 13, 2009 2:46:44 PM (15 years ago)
Author:
vboxsync
Message:

video 2d accel: move gl 2D support check to a separate executable (enabled for win for now), code cleaning, bug-fixing

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r23452 r23732  
    484484if defined(VBOX_WITH_VIDEOHWACCEL) || defined(VBOX_GUI_USE_QGL)
    485485 VirtualBox_SOURCES += \
    486         src/VBoxFBQGL.cpp \
    487         src/VBoxFBOverlay.cpp
     486    src/VBoxFBQGL.cpp \
     487    src/VBoxFBOverlay.cpp \
     488    src/VBoxGLSupportInfo.cpp
    488489endif
    489490# The Qt modules we're using.
     
    645646endif # darwin
    646647
     648#
     649# App for testing GL support
     650#
     651if defined(VBOX_WITH_VIDEOHWACCEL)
     652 if1of ($(KBUILD_TARGET), win linux)
     653  PROGRAMS += VBoxTestOGL2D
     654  VBoxTestOGL2D_TEMPLATE := $(if $(VBOX_WITH_HARDENING),VBOXQT4GUI,VBOXQT4GUIEXE)
     655  VBoxTestOGL2D_SOURCES = \
     656      src/VBoxTestQGLApp.cpp \
     657      src/VBoxGLSupportInfo.cpp
     658  VBoxTestOGL2D_QT_MODULES = Core Gui OpenGL
     659  VBoxTestOGL2D_INCS = include
     660  VBoxTestOGL2D_LDFLAGS.darwin += -framework OpenGL
     661  VBoxTestOGL2D_LIBS.win     += $(PATH_SDK_WINPSDK_LIB)/Opengl32.lib
     662  VBoxTestOGL2D_LIBS.solaris += GL
     663 endif
     664endif
    647665
    648666#
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxFBOverlay.h

    r23657 r23732  
    2727//#define VBOXQGL_DBG_SURF 1
    2828
    29 #include "COMDefs.h"
     29//#include "COMDefs.h"
    3030#include <QGLWidget>
    3131#include <iprt/assert.h>
    3232#include <iprt/critsect.h>
    3333
     34#include "VBoxGLSupportInfo.h"
     35
    3436#define VBOXVHWA_ALLOW_PRIMARY_AND_OVERLAY_ONLY 1
    35 
    36 #if defined(DEBUG) && !defined(DEBUG_sandervl)
    37 # include "iprt/stream.h"
    38 # define VBOXQGLLOG(_m) RTPrintf _m
    39 # define VBOXQGLLOGREL(_m) do { RTPrintf _m ; LogRel( _m ); } while(0)
    40 #else
    41 # define VBOXQGLLOG(_m)    do {}while(0)
    42 # define VBOXQGLLOGREL(_m) LogRel( _m )
    43 #endif
    44 #define VBOXQGLLOG_ENTER(_m)
    45 //do{VBOXQGLLOG(("==>[%s]:", __FUNCTION__)); VBOXQGLLOG(_m);}while(0)
    46 #define VBOXQGLLOG_EXIT(_m)
    47 //do{VBOXQGLLOG(("<==[%s]:", __FUNCTION__)); VBOXQGLLOG(_m);}while(0)
    48 #ifdef DEBUG
    49  #define VBOXQGL_ASSERTNOERR() \
    50     do { GLenum err = glGetError(); \
    51         if(err != GL_NO_ERROR) VBOXQGLLOG(("gl error ocured (0x%x)\n", err)); \
    52         Assert(err == GL_NO_ERROR); \
    53     }while(0)
    54 
    55  #define VBOXQGL_CHECKERR(_op) \
    56     do { \
    57         glGetError(); \
    58         _op \
    59         VBOXQGL_ASSERTNOERR(); \
    60     }while(0)
    61 #else
    62  #define VBOXQGL_ASSERTNOERR() \
    63     do {}while(0)
    64 
    65  #define VBOXQGL_CHECKERR(_op) \
    66     do { \
    67         _op \
    68     }while(0)
    69 #endif
    70 
    71 #ifdef DEBUG
    72 #include <iprt/time.h>
    73 
    74 #define VBOXGETTIME() RTTimeNanoTS()
    75 
    76 #define VBOXPRINTDIF(_nano, _m) do{\
    77         uint64_t cur = VBOXGETTIME(); \
    78         VBOXQGLLOG(_m); \
    79         VBOXQGLLOG(("(%Lu)\n", cur - (_nano))); \
    80     }while(0)
    81 
    82 class VBoxVHWADbgTimeCounter
    83 {
    84 public:
    85     VBoxVHWADbgTimeCounter(const char* msg) {mTime = VBOXGETTIME(); mMsg=msg;}
    86     ~VBoxVHWADbgTimeCounter() {VBOXPRINTDIF(mTime, (mMsg));}
    87 private:
    88     uint64_t mTime;
    89     const char* mMsg;
    90 };
    91 
    92 #define VBOXQGLLOG_METHODTIME(_m) VBoxVHWADbgTimeCounter _dbgTimeCounter(_m)
    93 
    94 #define VBOXQG_CHECKCONTEXT() \
    95         { \
    96             const GLubyte * str; \
    97             VBOXQGL_CHECKERR(   \
    98                     str = glGetString(GL_VERSION); \
    99             ); \
    100             Assert(str); \
    101             if(str) \
    102             { \
    103                 Assert(str[0]); \
    104             } \
    105         }
    106 #else
    107 #define VBOXQGLLOG_METHODTIME(_m)
    108 #define VBOXQG_CHECKCONTEXT() do{}while(0)
    109 #endif
    110 
    111 #define VBOXQGLLOG_QRECT(_p, _pr, _s) do{\
    112     VBOXQGLLOG((_p " x(%d), y(%d), w(%d), h(%d)" _s, (_pr)->x(), (_pr)->y(), (_pr)->width(), (_pr)->height()));\
    113     }while(0)
    114 
    115 #define VBOXQGLLOG_CKEY(_p, _pck, _s) do{\
    116     VBOXQGLLOG((_p " l(0x%x), u(0x%x)" _s, (_pck)->lower(), (_pck)->upper()));\
    117     }while(0)
    11837
    11938class VBoxVHWADirtyRect
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBOverlay.cpp

    r23691 r23732  
    2929#include "VBoxGlobal.h"
    3030
     31#include "VBoxGLSupportInfo.h"
     32
    3133/* Qt includes */
    3234#include <QGLWidget>
     
    127129#endif
    128130
    129 #define VBOXQGL_MAKEFOURCC(ch0, ch1, ch2, ch3)                              \
    130                 ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) |       \
    131                 ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
    132 
    133 #define FOURCC_AYUV VBOXQGL_MAKEFOURCC('A', 'Y', 'U', 'V')
    134 #define FOURCC_UYVY VBOXQGL_MAKEFOURCC('U', 'Y', 'V', 'Y')
    135 #define FOURCC_YUY2 VBOXQGL_MAKEFOURCC('Y', 'U', 'Y', '2')
    136 #define FOURCC_YV12 VBOXQGL_MAKEFOURCC('Y', 'V', '1', '2')
    137 #define VBOXVHWA_NUMFOURCC 4
    138 
    139 typedef char GLchar;
    140 
    141 #ifndef GL_COMPILE_STATUS
    142 # define GL_COMPILE_STATUS 0x8b81
    143 #endif
    144 #ifndef GL_LINK_STATUS
    145 # define GL_LINK_STATUS    0x8b82
    146 #endif
    147 #ifndef GL_FRAGMENT_SHADER
    148 # define GL_FRAGMENT_SHADER 0x8b30
    149 #endif
    150 #ifndef GL_VERTEX_SHADER
    151 # define GL_VERTEX_SHADER 0x8b31
    152 #endif
    153 
    154 /* GL_ARB_multitexture */
    155 #ifndef GL_TEXTURE0
    156 # define GL_TEXTURE0                    0x84c0
    157 #endif
    158 #ifndef GL_TEXTURE1
    159 # define GL_TEXTURE1                    0x84c1
    160 #endif
    161 #ifndef GL_MAX_TEXTURE_COORDS
    162 # define GL_MAX_TEXTURE_COORDS          0x8871
    163 #endif
    164 #ifndef GL_MAX_TEXTURE_IMAGE_UNITS
    165 # define GL_MAX_TEXTURE_IMAGE_UNITS     0x8872
    166 #endif
    167 
    168 #ifndef APIENTRY
    169 # define APIENTRY
    170 #endif
    171 
    172 typedef GLvoid (APIENTRY *PFNVBOXVHWA_ACTIVE_TEXTURE) (GLenum texture);
    173 typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2I) (GLenum texture, GLint v0, GLint v1);
    174 typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2F) (GLenum texture, GLfloat v0, GLfloat v1);
    175 typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2D) (GLenum texture, GLdouble v0, GLdouble v1);
    176 
    177 /* GL_ARB_texture_rectangle */
    178 #ifndef GL_TEXTURE_RECTANGLE
    179 # define GL_TEXTURE_RECTANGLE 0x84F5
    180 #endif
    181 
    182 /* GL_ARB_shader_objects */
    183 /* GL_ARB_fragment_shader */
    184 
    185 typedef GLuint (APIENTRY *PFNVBOXVHWA_CREATE_SHADER)  (GLenum type);
    186 typedef GLvoid (APIENTRY *PFNVBOXVHWA_SHADER_SOURCE)  (GLuint shader, GLsizei count, const GLchar **string, const GLint *length);
    187 typedef GLvoid (APIENTRY *PFNVBOXVHWA_COMPILE_SHADER) (GLuint shader);
    188 typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_SHADER)  (GLuint shader);
    189 
    190 typedef GLuint (APIENTRY *PFNVBOXVHWA_CREATE_PROGRAM) ();
    191 typedef GLvoid (APIENTRY *PFNVBOXVHWA_ATTACH_SHADER)  (GLuint program, GLuint shader);
    192 typedef GLvoid (APIENTRY *PFNVBOXVHWA_DETACH_SHADER)  (GLuint program, GLuint shader);
    193 typedef GLvoid (APIENTRY *PFNVBOXVHWA_LINK_PROGRAM)   (GLuint program);
    194 typedef GLvoid (APIENTRY *PFNVBOXVHWA_USE_PROGRAM)    (GLuint program);
    195 typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_PROGRAM) (GLuint program);
    196 
    197 typedef GLboolean (APIENTRY *PFNVBOXVHWA_IS_SHADER)   (GLuint shader);
    198 typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_SHADERIV)   (GLuint shader, GLenum pname, GLint *params);
    199 typedef GLboolean (APIENTRY *PFNVBOXVHWA_IS_PROGRAM)  (GLuint program);
    200 typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_PROGRAMIV)  (GLuint program, GLenum pname, GLint *params);
    201 typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_ATTACHED_SHADERS) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
    202 typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_SHADER_INFO_LOG)  (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
    203 typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_PROGRAM_INFO_LOG) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
    204 typedef GLint (APIENTRY *PFNVBOXVHWA_GET_UNIFORM_LOCATION) (GLint programObj, const GLchar *name);
    205 
    206 typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM1F)(GLint location, GLfloat v0);
    207 typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM2F)(GLint location, GLfloat v0, GLfloat v1);
    208 typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM3F)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
    209 typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM4F)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
    210 
    211 typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM1I)(GLint location, GLint v0);
    212 typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM2I)(GLint location, GLint v0, GLint v1);
    213 typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM3I)(GLint location, GLint v0, GLint v1, GLint v2);
    214 typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM4I)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
    215 
    216 /* GL_ARB_pixel_buffer_object*/
    217 #ifndef Q_WS_MAC
    218 /* apears to be defined on mac */
    219 typedef ptrdiff_t GLsizeiptr;
    220 #endif
    221 
    222 #ifndef GL_READ_ONLY
    223 # define GL_READ_ONLY                   0x88B8
    224 #endif
    225 #ifndef GL_WRITE_ONLY
    226 # define GL_WRITE_ONLY                  0x88B9
    227 #endif
    228 #ifndef GL_READ_WRITE
    229 # define GL_READ_WRITE                  0x88BA
    230 #endif
    231 #ifndef GL_STREAM_DRAW
    232 # define GL_STREAM_DRAW                 0x88E0
    233 #endif
    234 #ifndef GL_STREAM_READ
    235 # define GL_STREAM_READ                 0x88E1
    236 #endif
    237 #ifndef GL_STREAM_COPY
    238 # define GL_STREAM_COPY                 0x88E2
    239 #endif
    240 
    241 #ifndef GL_PIXEL_PACK_BUFFER
    242 # define GL_PIXEL_PACK_BUFFER           0x88EB
    243 #endif
    244 #ifndef GL_PIXEL_UNPACK_BUFFER
    245 # define GL_PIXEL_UNPACK_BUFFER         0x88EC
    246 #endif
    247 #ifndef GL_PIXEL_PACK_BUFFER_BINDING
    248 # define GL_PIXEL_PACK_BUFFER_BINDING   0x88ED
    249 #endif
    250 #ifndef GL_PIXEL_UNPACK_BUFFER_BINDING
    251 # define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
    252 #endif
    253 
    254 typedef GLvoid (APIENTRY *PFNVBOXVHWA_GEN_BUFFERS)(GLsizei n, GLuint *buffers);
    255 typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_BUFFERS)(GLsizei n, const GLuint *buffers);
    256 typedef GLvoid (APIENTRY *PFNVBOXVHWA_BIND_BUFFER)(GLenum target, GLuint buffer);
    257 typedef GLvoid (APIENTRY *PFNVBOXVHWA_BUFFER_DATA)(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
    258 typedef GLvoid* (APIENTRY *PFNVBOXVHWA_MAP_BUFFER)(GLenum target, GLenum access);
    259 typedef GLboolean (APIENTRY *PFNVBOXVHWA_UNMAP_BUFFER)(GLenum target);
    260 
    261 /*****************/
    262 
    263 /* functions */
    264 
    265 PFNVBOXVHWA_ACTIVE_TEXTURE vboxglActiveTexture = NULL;
    266 PFNVBOXVHWA_MULTI_TEX_COORD2I vboxglMultiTexCoord2i = NULL;
    267 PFNVBOXVHWA_MULTI_TEX_COORD2D vboxglMultiTexCoord2d = NULL;
    268 PFNVBOXVHWA_MULTI_TEX_COORD2F vboxglMultiTexCoord2f = NULL;
    269 
    270 
    271 PFNVBOXVHWA_CREATE_SHADER   vboxglCreateShader  = NULL;
    272 PFNVBOXVHWA_SHADER_SOURCE   vboxglShaderSource  = NULL;
    273 PFNVBOXVHWA_COMPILE_SHADER  vboxglCompileShader = NULL;
    274 PFNVBOXVHWA_DELETE_SHADER   vboxglDeleteShader  = NULL;
    275 
    276 PFNVBOXVHWA_CREATE_PROGRAM  vboxglCreateProgram = NULL;
    277 PFNVBOXVHWA_ATTACH_SHADER   vboxglAttachShader  = NULL;
    278 PFNVBOXVHWA_DETACH_SHADER   vboxglDetachShader  = NULL;
    279 PFNVBOXVHWA_LINK_PROGRAM    vboxglLinkProgram   = NULL;
    280 PFNVBOXVHWA_USE_PROGRAM     vboxglUseProgram    = NULL;
    281 PFNVBOXVHWA_DELETE_PROGRAM  vboxglDeleteProgram = NULL;
    282 
    283 PFNVBOXVHWA_IS_SHADER       vboxglIsShader      = NULL;
    284 PFNVBOXVHWA_GET_SHADERIV    vboxglGetShaderiv   = NULL;
    285 PFNVBOXVHWA_IS_PROGRAM      vboxglIsProgram     = NULL;
    286 PFNVBOXVHWA_GET_PROGRAMIV   vboxglGetProgramiv  = NULL;
    287 PFNVBOXVHWA_GET_ATTACHED_SHADERS vboxglGetAttachedShaders = NULL;
    288 PFNVBOXVHWA_GET_SHADER_INFO_LOG  vboxglGetShaderInfoLog   = NULL;
    289 PFNVBOXVHWA_GET_PROGRAM_INFO_LOG vboxglGetProgramInfoLog  = NULL;
    290 
    291 PFNVBOXVHWA_GET_UNIFORM_LOCATION vboxglGetUniformLocation = NULL;
    292 
    293 PFNVBOXVHWA_UNIFORM1F vboxglUniform1f;
    294 PFNVBOXVHWA_UNIFORM2F vboxglUniform2f;
    295 PFNVBOXVHWA_UNIFORM3F vboxglUniform3f;
    296 PFNVBOXVHWA_UNIFORM4F vboxglUniform4f;
    297 
    298 PFNVBOXVHWA_UNIFORM1I vboxglUniform1i;
    299 PFNVBOXVHWA_UNIFORM2I vboxglUniform2i;
    300 PFNVBOXVHWA_UNIFORM3I vboxglUniform3i;
    301 PFNVBOXVHWA_UNIFORM4I vboxglUniform4i;
    302 
    303 PFNVBOXVHWA_GEN_BUFFERS vboxglGenBuffers = NULL;
    304 PFNVBOXVHWA_DELETE_BUFFERS vboxglDeleteBuffers = NULL;
    305 PFNVBOXVHWA_BIND_BUFFER vboxglBindBuffer = NULL;
    306 PFNVBOXVHWA_BUFFER_DATA vboxglBufferData = NULL;
    307 PFNVBOXVHWA_MAP_BUFFER vboxglMapBuffer = NULL;
    308 PFNVBOXVHWA_UNMAP_BUFFER vboxglUnmapBuffer = NULL;
    309 
    310 #if 0
    311 #if defined Q_WS_WIN
    312 #define VBOXVHWA_GETPROCADDRESS(_t, _n) (_t)wglGetProcAddress(_n)
    313 #elif defined Q_WS_X11
    314 #include <GL/glx.h>
    315 #define VBOXVHWA_GETPROCADDRESS(_t, _n) (_t)glXGetProcAddress((const GLubyte *)(_n))
    316 #else
    317 #error "Port me!!!"
    318 #endif
    319 #endif
    320 
    321 #define VBOXVHWA_GETPROCADDRESS(_c, _t, _n) ((_t)(_c).getProcAddress(QString(_n)))
    322 
    323 #define VBOXVHWA_PFNINIT_SAME(_c, _t, _v, _rc) \
    324     do { \
    325         if((vboxgl##_v = VBOXVHWA_GETPROCADDRESS(_c, _t, "gl"#_v)) == NULL) \
    326         { \
    327             VBOXQGLLOG(("ERROR: '%s' function is not found\n", "gl"#_v));\
    328             AssertBreakpoint(); \
    329             if((vboxgl##_v = VBOXVHWA_GETPROCADDRESS(_c, _t, "gl"#_v"ARB")) == NULL) \
    330             { \
    331                 VBOXQGLLOG(("ERROR: '%s' function is not found\n", "gl"#_v"ARB"));\
    332                 AssertBreakpoint(); \
    333                 if((vboxgl##_v = VBOXVHWA_GETPROCADDRESS(_c, _t, "gl"#_v"EXT")) == NULL) \
    334                 { \
    335                     VBOXQGLLOG(("ERROR: '%s' function is not found\n", "gl"#_v"EXT"));\
    336                     AssertBreakpoint(); \
    337                     (_rc)++; \
    338                 } \
    339             } \
    340         } \
    341     }while(0)
    342 
    343 #define VBOXVHWA_PFNINIT(_c, _t, _v, _f,_rc) \
    344     do { \
    345         if((vboxgl##_v = VBOXVHWA_GETPROCADDRESS(_c, _t, "gl"#_f)) == NULL) \
    346         { \
    347             VBOXQGLLOG(("ERROR: '%s' function is not found\n", "gl"#_f));\
    348             AssertBreakpoint(); \
    349             (_rc)++; \
    350         } \
    351     }while(0)
    352 
    353 //#define VBOXVHWA_PFNINIT_OBJECT_ARB(_t, _v, _rc) VBOXVHWA_PFNINIT(_t, _v, #_v"ObjectARB" ,_rc)
    354 #define VBOXVHWA_PFNINIT_OBJECT_ARB(_c, _t, _v, _rc) \
    355         do { \
    356             if((vboxgl##_v = VBOXVHWA_GETPROCADDRESS(_c, _t, "gl"#_v"ObjectARB")) == NULL) \
    357             { \
    358                 VBOXQGLLOG(("ERROR: '%s' function is not found\n", "gl"#_v"ObjectARB"));\
    359                 AssertBreakpoint(); \
    360                 (_rc)++; \
    361             } \
    362         }while(0)
    363 
    364 //#define VBOXVHWA_PFNINIT_ARB(_t, _v, _rc) VBOXVHWA_PFNINIT(_t, _v, #_v"ARB" ,_rc)
    365 #define VBOXVHWA_PFNINIT_ARB(_c, _t, _v, _rc) \
    366         do { \
    367             if((vboxgl##_v = VBOXVHWA_GETPROCADDRESS(_c, _t, "gl"#_v"ARB")) == NULL) \
    368             { \
    369                 VBOXQGLLOG(("ERROR: '%s' function is not found\n", "gl"#_v"ARB"));\
    370                 AssertBreakpoint(); \
    371                 (_rc)++; \
    372             } \
    373         }while(0)
    374 
    375 
    376 static bool g_vboxVHWAGlSupportInitialized = false;
    377 /* vbox version in the format 0x00mjmnbl
    378  * in case of a failure contains -1 (0xffffffff) */
    379 static int g_vboxVHWAGlVersion = 0;
    380 
    381 static bool g_GL_ARB_multitexture        = false;
    382 static bool g_GL_ARB_shader_objects      = false;
    383 static bool g_GL_ARB_fragment_shader     = false;
    384 static bool g_GL_ARB_pixel_buffer_object = false;
    385 static bool g_GL_ARB_texture_rectangle   = false;
    386 static bool g_GL_EXT_texture_rectangle   = false;
    387 static bool g_GL_NV_texture_rectangle         = false;
    388 static bool g_GL_ARB_texture_non_power_of_two = false;
    389 
    390 /* gl features supported */
    391 static bool g_vboxVHWAGlShaderSupported = false;
    392 static bool g_vboxVHWAGlTextureRectangleSupported = false;
    393 static bool g_vboxVHWAGlTextureNP2Supported = false;
    394 static bool g_vboxVHWAGlPBOSupported = false;
    395 static int g_vboxVHWAGlMultiTexNumSupported = 1; /* 1 would mean it is not supported */
    396 
    397 /* vhwa features supported */
    398 static uint32_t g_vboxVHWAFourccSupportedList[VBOXVHWA_NUMFOURCC];
    399 static uint32_t g_vboxVHWAFourccSupportedCount = 0;
    400 
    401 
    402 static int vboxVHWAGlParseSubver(const GLubyte * ver, const GLubyte ** pNext, bool bSpacePrefixAllowed)
    403 {
    404     int val = 0;
    405 
    406     for(;;++ver)
    407     {
    408         if(*ver >= '0' && *ver <= '9')
    409         {
    410             if(!val)
     131static VBoxVHWAInfo g_VBoxVHWASupportInfo;
     132static bool g_bVBoxVHWAChecked = false;
     133static bool g_bVBoxVHWASupported = false;
     134
     135static const VBoxVHWAInfo & vboxVHWAGetSupportInfo(const QGLContext *pContext)
     136{
     137    if(!g_VBoxVHWASupportInfo.isInitialized())
     138    {
     139        if(pContext)
     140        {
     141            g_VBoxVHWASupportInfo.init(pContext);
     142        }
     143        else
     144        {
     145            VBoxGLTmpContext ctx;
     146            const QGLContext *pContext = ctx.makeCurrent();
     147            Assert(pContext);
     148            if(pContext)
    411149            {
    412                 if(*ver == '0')
    413                     continue;
     150                g_VBoxVHWASupportInfo.init(pContext);
    414151            }
    415             else
    416             {
    417                 val *= 10;
    418             }
    419             val += *ver - '0';
    420         }
    421         else if(*ver == '.')
    422         {
    423             *pNext = ver+1;
    424             break;
    425         }
    426         else if(*ver == '\0')
    427         {
    428             *pNext = NULL;
    429             break;
    430         }
    431         else if(*ver == ' ' || *ver == '\t' ||  *ver == 0x0d || *ver == 0x0a)
    432         {
    433             if(bSpacePrefixAllowed)
    434             {
    435                 if(!val)
    436                 {
    437                     continue;
    438                 }
    439             }
    440 
    441             /* treat this as the end ov version string */
    442             *pNext = NULL;
    443             break;
    444         }
    445         else
    446         {
    447             Assert(0);
    448             val = -1;
    449             break;
    450         }
    451     }
    452 
    453     return val;
    454 }
    455 
    456 static int vboxVHWAGlParseVersion(const GLubyte * ver)
    457 {
    458     int iVer = vboxVHWAGlParseSubver(ver, &ver, true);
    459     if(iVer)
    460     {
    461         iVer <<= 16;
    462         if(ver)
    463         {
    464             int tmp = vboxVHWAGlParseSubver(ver, &ver, false);
    465             if(tmp >= 0)
    466             {
    467                 iVer |= tmp << 8;
    468                 if(ver)
    469                 {
    470                     tmp = vboxVHWAGlParseSubver(ver, &ver, false);
    471                     if(tmp >= 0)
    472                     {
    473                         iVer |= tmp;
    474                     }
    475                     else
    476                     {
    477                         Assert(0);
    478                         iVer = -1;
    479                     }
    480                 }
    481             }
    482             else
    483             {
    484                 Assert(0);
    485                 iVer = -1;
    486             }
    487         }
    488     }
    489     return iVer;
    490 }
    491 
    492 static void vboxVHWAGlInitExtSupport(const QGLContext & context)
    493 {
    494     int rc = 0;
    495     do
    496     {
    497         rc = 0;
    498         g_vboxVHWAGlMultiTexNumSupported = 1; /* default, 1 means not supported */
    499         if(g_vboxVHWAGlVersion >= 0x010201) /* ogl >= 1.2.1 */
    500         {
    501             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_ACTIVE_TEXTURE, ActiveTexture, rc);
    502             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_MULTI_TEX_COORD2I, MultiTexCoord2i, rc);
    503             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_MULTI_TEX_COORD2D, MultiTexCoord2d, rc);
    504             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_MULTI_TEX_COORD2F, MultiTexCoord2f, rc);
    505         }
    506         else if(g_GL_ARB_multitexture)
    507         {
    508             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_ACTIVE_TEXTURE, ActiveTexture, rc);
    509             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_MULTI_TEX_COORD2I, MultiTexCoord2i, rc);
    510             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_MULTI_TEX_COORD2D, MultiTexCoord2d, rc);
    511             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_MULTI_TEX_COORD2F, MultiTexCoord2f, rc);
    512         }
    513         else
    514         {
    515             break;
    516         }
    517 
    518         if(RT_FAILURE(rc))
    519             break;
    520 
    521         GLint maxCoords, maxUnits;
    522         glGetIntegerv(GL_MAX_TEXTURE_COORDS, &maxCoords);
    523         glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxUnits);
    524 
    525         VBOXQGLLOGREL(("Max Tex Coords (%d), Img Units (%d)\n", maxCoords, maxUnits));
    526         /* take the minimum of those */
    527         if(maxUnits < maxCoords)
    528             maxCoords = maxUnits;
    529         if(maxUnits < 2)
    530         {
    531             VBOXQGLLOGREL(("Max Tex Coord or Img Units < 2 disabling MultiTex support\n"));
    532             break;
    533         }
    534 
    535         g_vboxVHWAGlMultiTexNumSupported = maxUnits;
    536     }while(0);
    537 
    538 
    539     do
    540     {
    541         rc = 0;
    542         g_vboxVHWAGlPBOSupported = false;
    543 
    544         if(g_GL_ARB_pixel_buffer_object)
    545         {
    546             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_GEN_BUFFERS, GenBuffers, rc);
    547             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_DELETE_BUFFERS, DeleteBuffers, rc);
    548             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_BIND_BUFFER, BindBuffer, rc);
    549             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_BUFFER_DATA, BufferData, rc);
    550             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_MAP_BUFFER, MapBuffer, rc);
    551             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_UNMAP_BUFFER, UnmapBuffer, rc);
    552         }
    553         else
    554         {
    555             break;
    556         }
    557 
    558         if(RT_FAILURE(rc))
    559             break;
    560 
    561         g_vboxVHWAGlPBOSupported = true;
    562     } while(0);
    563 
    564     do
    565     {
    566         rc = 0;
    567         g_vboxVHWAGlShaderSupported = false;
    568 
    569         if(g_vboxVHWAGlVersion >= 0x020000)  /* if ogl >= 2.0*/
    570         {
    571             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_CREATE_SHADER, CreateShader, rc);
    572             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_SHADER_SOURCE, ShaderSource, rc);
    573             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_COMPILE_SHADER, CompileShader, rc);
    574             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_DELETE_SHADER, DeleteShader, rc);
    575 
    576             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_CREATE_PROGRAM, CreateProgram, rc);
    577             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_ATTACH_SHADER, AttachShader, rc);
    578             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_DETACH_SHADER, DetachShader, rc);
    579             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_LINK_PROGRAM, LinkProgram, rc);
    580             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_USE_PROGRAM, UseProgram, rc);
    581             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_DELETE_PROGRAM, DeleteProgram, rc);
    582 
    583             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_IS_SHADER, IsShader, rc);
    584             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_GET_SHADERIV, GetShaderiv, rc);
    585             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_IS_PROGRAM, IsProgram, rc);
    586             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_GET_PROGRAMIV, GetProgramiv, rc);
    587             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_GET_ATTACHED_SHADERS, GetAttachedShaders,  rc);
    588             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_GET_SHADER_INFO_LOG, GetShaderInfoLog, rc);
    589             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_GET_PROGRAM_INFO_LOG, GetProgramInfoLog, rc);
    590 
    591             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_GET_UNIFORM_LOCATION, GetUniformLocation, rc);
    592 
    593             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_UNIFORM1F, Uniform1f, rc);
    594             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_UNIFORM2F, Uniform2f, rc);
    595             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_UNIFORM3F, Uniform3f, rc);
    596             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_UNIFORM4F, Uniform4f, rc);
    597 
    598             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_UNIFORM1I, Uniform1i, rc);
    599             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_UNIFORM2I, Uniform2i, rc);
    600             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_UNIFORM3I, Uniform3i, rc);
    601             VBOXVHWA_PFNINIT_SAME(context, PFNVBOXVHWA_UNIFORM4I, Uniform4i, rc);
    602         }
    603         else if(g_GL_ARB_shader_objects && g_GL_ARB_fragment_shader)
    604         {
    605             VBOXVHWA_PFNINIT_OBJECT_ARB(context, PFNVBOXVHWA_CREATE_SHADER, CreateShader, rc);
    606             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_SHADER_SOURCE, ShaderSource, rc);
    607             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_COMPILE_SHADER, CompileShader, rc);
    608             VBOXVHWA_PFNINIT(context, PFNVBOXVHWA_DELETE_SHADER, DeleteShader, DeleteObjectARB, rc);
    609 
    610             VBOXVHWA_PFNINIT_OBJECT_ARB(context, PFNVBOXVHWA_CREATE_PROGRAM, CreateProgram, rc);
    611             VBOXVHWA_PFNINIT(context, PFNVBOXVHWA_ATTACH_SHADER, AttachShader, AttachObjectARB, rc);
    612             VBOXVHWA_PFNINIT(context, PFNVBOXVHWA_DETACH_SHADER, DetachShader, DetachObjectARB, rc);
    613             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_LINK_PROGRAM, LinkProgram, rc);
    614             VBOXVHWA_PFNINIT_OBJECT_ARB(context, PFNVBOXVHWA_USE_PROGRAM, UseProgram, rc);
    615             VBOXVHWA_PFNINIT(context, PFNVBOXVHWA_DELETE_PROGRAM, DeleteProgram, DeleteObjectARB, rc);
    616 
    617         //TODO:    VBOXVHWA_PFNINIT(PFNVBOXVHWA_IS_SHADER, IsShader, rc);
    618             VBOXVHWA_PFNINIT(context, PFNVBOXVHWA_GET_SHADERIV, GetShaderiv, GetObjectParameterivARB, rc);
    619         //TODO:    VBOXVHWA_PFNINIT(PFNVBOXVHWA_IS_PROGRAM, IsProgram, rc);
    620             VBOXVHWA_PFNINIT(context, PFNVBOXVHWA_GET_PROGRAMIV, GetProgramiv, GetObjectParameterivARB, rc);
    621             VBOXVHWA_PFNINIT(context, PFNVBOXVHWA_GET_ATTACHED_SHADERS, GetAttachedShaders, GetAttachedObjectsARB, rc);
    622             VBOXVHWA_PFNINIT(context, PFNVBOXVHWA_GET_SHADER_INFO_LOG, GetShaderInfoLog, GetInfoLogARB, rc);
    623             VBOXVHWA_PFNINIT(context, PFNVBOXVHWA_GET_PROGRAM_INFO_LOG, GetProgramInfoLog, GetInfoLogARB, rc);
    624 
    625             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_GET_UNIFORM_LOCATION, GetUniformLocation, rc);
    626 
    627             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_UNIFORM1F, Uniform1f, rc);
    628             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_UNIFORM2F, Uniform2f, rc);
    629             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_UNIFORM3F, Uniform3f, rc);
    630             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_UNIFORM4F, Uniform4f, rc);
    631 
    632             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_UNIFORM1I, Uniform1i, rc);
    633             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_UNIFORM2I, Uniform2i, rc);
    634             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_UNIFORM3I, Uniform3i, rc);
    635             VBOXVHWA_PFNINIT_ARB(context, PFNVBOXVHWA_UNIFORM4I, Uniform4i, rc);
    636         }
    637         else
    638         {
    639             break;
    640         }
    641 
    642         if(RT_FAILURE(rc))
    643             break;
    644 
    645         g_vboxVHWAGlShaderSupported = true;
    646     } while(0);
    647 
    648     if(g_GL_ARB_texture_rectangle || g_GL_EXT_texture_rectangle || g_GL_NV_texture_rectangle)
    649     {
    650         g_vboxVHWAGlTextureRectangleSupported = true;
    651     }
    652     else
    653     {
    654         g_vboxVHWAGlTextureRectangleSupported = false;
    655     }
    656 
    657     g_vboxVHWAGlTextureNP2Supported = g_GL_ARB_texture_non_power_of_two;
    658 }
    659 
    660 static void vboxVHWAGlInitFeatureSupport()
    661 {
    662     if(g_vboxVHWAGlShaderSupported && g_vboxVHWAGlTextureRectangleSupported)
    663     {
    664         uint32_t num = 0;
    665         g_vboxVHWAFourccSupportedList[num++] = FOURCC_AYUV;
    666         g_vboxVHWAFourccSupportedList[num++] = FOURCC_UYVY;
    667         g_vboxVHWAFourccSupportedList[num++] = FOURCC_YUY2;
    668         if(g_vboxVHWAGlMultiTexNumSupported >= 4)
    669         {
    670             /* YV12 currently requires 3 units (for each color component)
    671              * + 1 unit for dst texture for color-keying + 3 units for each color component
    672              * TODO: we could store YV12 data in one texture to eliminate this requirement*/
    673             g_vboxVHWAFourccSupportedList[num++] = FOURCC_YV12;
    674         }
    675 
    676         Assert(num <= VBOXVHWA_NUMFOURCC);
    677         g_vboxVHWAFourccSupportedCount = num;
    678     }
    679     else
    680     {
    681         g_vboxVHWAFourccSupportedCount = 0;
    682     }
    683 }
    684 
    685 static void vboxVHWAGlInit(const QGLContext * pContext)
    686 {
    687     if(g_vboxVHWAGlSupportInitialized)
    688         return;
    689 
    690     g_vboxVHWAGlSupportInitialized = true;
    691 
    692     if (!QGLFormat::hasOpenGL())
    693     {
    694         VBOXQGLLOGREL (("no gl support available\n"));
    695         return;
    696     }
    697 
    698     QGLWidget *pTmpWidget = NULL;
    699 
    700     if(!pContext)
    701     {
    702         QGLWidget *pTmpWidget = new QGLWidget();
    703         pTmpWidget->makeCurrent();
    704         pContext = pTmpWidget->context();
    705     }
    706 
    707     const GLubyte * str;
    708     VBOXQGL_CHECKERR(
    709             str = glGetString(GL_VERSION);
    710             );
    711 
    712     if(str)
    713     {
    714         VBOXQGLLOGREL (("gl version string: 0%s\n", str));
    715 
    716         g_vboxVHWAGlVersion = vboxVHWAGlParseVersion(str);
    717         Assert(g_vboxVHWAGlVersion > 0);
    718         if(g_vboxVHWAGlVersion < 0)
    719         {
    720             g_vboxVHWAGlVersion = 0;
    721         }
    722         else
    723         {
    724             VBOXQGLLOGREL (("gl version: 0x%x\n", g_vboxVHWAGlVersion));
    725             VBOXQGL_CHECKERR(
    726                     str = glGetString(GL_EXTENSIONS);
    727                     );
    728 
    729             const char * pos = strstr((const char *)str, "GL_ARB_multitexture");
    730             g_GL_ARB_multitexture = pos != NULL;
    731             VBOXQGLLOGREL (("GL_ARB_multitexture: %d\n", g_GL_ARB_multitexture));
    732 
    733             pos = strstr((const char *)str, "GL_ARB_shader_objects");
    734             g_GL_ARB_shader_objects = pos != NULL;
    735             VBOXQGLLOGREL (("GL_ARB_shader_objects: %d\n", g_GL_ARB_shader_objects));
    736 
    737             pos = strstr((const char *)str, "GL_ARB_fragment_shader");
    738             g_GL_ARB_fragment_shader = pos != NULL;
    739             VBOXQGLLOGREL (("GL_ARB_fragment_shader: %d\n", g_GL_ARB_fragment_shader));
    740 
    741             pos = strstr((const char *)str, "GL_ARB_pixel_buffer_object");
    742             g_GL_ARB_pixel_buffer_object = pos != NULL;
    743             VBOXQGLLOGREL (("GL_ARB_pixel_buffer_object: %d\n", g_GL_ARB_pixel_buffer_object));
    744 
    745             pos = strstr((const char *)str, "GL_ARB_texture_rectangle");
    746             g_GL_ARB_texture_rectangle = pos != NULL;
    747             VBOXQGLLOGREL (("GL_ARB_texture_rectangle: %d\n", g_GL_ARB_texture_rectangle));
    748 
    749             pos = strstr((const char *)str, "GL_EXT_texture_rectangle");
    750             g_GL_EXT_texture_rectangle = pos != NULL;
    751             VBOXQGLLOGREL (("GL_EXT_texture_rectangle: %d\n", g_GL_EXT_texture_rectangle));
    752 
    753             pos = strstr((const char *)str, "GL_NV_texture_rectangle");
    754             g_GL_NV_texture_rectangle = pos != NULL;
    755             VBOXQGLLOGREL (("GL_NV_texture_rectangle: %d\n", g_GL_NV_texture_rectangle));
    756 
    757             pos = strstr((const char *)str, "GL_ARB_texture_non_power_of_two");
    758             g_GL_ARB_texture_non_power_of_two = pos != NULL;
    759             VBOXQGLLOGREL (("GL_ARB_texture_non_power_of_two: %d\n", g_GL_ARB_texture_non_power_of_two));
    760 
    761             vboxVHWAGlInitExtSupport(*pContext);
    762 
    763             vboxVHWAGlInitFeatureSupport();
    764         }
    765     }
    766     else
    767     {
    768         VBOXQGLLOGREL (("failed to make the context current, treating as unsupported\n"));
    769     }
    770 
    771 
    772     if(pTmpWidget)
    773     {
    774         delete pTmpWidget;
    775     }
    776 }
    777 
    778 static bool vboxVHWASupportedInternal()
    779 {
    780     if(g_vboxVHWAGlVersion <= 0)
    781     {
    782         /* error occurred while gl info initialization */
    783         return false;
    784     }
    785 
    786 #ifndef DEBUGVHWASTRICT
    787     /* in case we do not support shaders & multitexturing we can not supprt dst colorkey,
    788      * no sense to report Video Acceleration supported */
    789     if(!g_vboxVHWAGlShaderSupported)
    790         return false;
    791 #endif
    792     if(g_vboxVHWAGlMultiTexNumSupported < 2)
    793         return false;
    794 
    795     /* color conversion now supported only GL_TEXTURE_RECTANGLE
    796      * in this case only stretching is accelerated
    797      * report as unsupported, TODO: probably should report as supported for stretch acceleration */
    798     if(!g_vboxVHWAGlTextureRectangleSupported)
    799         return false;
    800 
    801     return true;
     152        }
     153    }
     154    return g_VBoxVHWASupportInfo;
    802155}
    803156
     
    913266}
    914267
    915 static VBoxVHWATexture* vboxVHWATextureCreate(const QRect & aRect, const VBoxVHWAColorFormat & aFormat, bool bVGA)
    916 {
    917     if(!bVGA && g_GL_ARB_pixel_buffer_object)
     268static VBoxVHWATexture* vboxVHWATextureCreate(const QGLContext * pContext, const QRect & aRect, const VBoxVHWAColorFormat & aFormat, bool bVGA)
     269{
     270    const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(pContext);
     271
     272    if(!bVGA && info.getGlInfo().isPBOSupported())
    918273    {
    919274        VBOXQGLLOG(("VBoxVHWATextureNP2RectPBO\n"));
    920275        return new VBoxVHWATextureNP2RectPBO(aRect, aFormat);
    921276    }
    922     else if(g_vboxVHWAGlTextureRectangleSupported)
     277    else if(info.getGlInfo().isTextureRectangleSupported())
    923278    {
    924279        VBOXQGLLOG(("VBoxVHWATextureNP2Rect\n"));
    925280        return new VBoxVHWATextureNP2Rect(aRect, aFormat);
    926281    }
    927     else if(g_GL_ARB_texture_non_power_of_two)
     282    else if(info.getGlInfo().isTextureNP2Supported())
    928283    {
    929284        VBOXQGLLOG(("VBoxVHWATextureNP2\n"));
     
    18561211    resetDefaultSrcOverlayCKey();
    18571212
    1858     mpTex[0] = vboxVHWATextureCreate(QRect(0,0,aSize.width(),aSize.height()), mColorFormat, bVGA);
     1213    mpTex[0] = vboxVHWATextureCreate(mWidget->context(), QRect(0,0,aSize.width(),aSize.height()), mColorFormat, bVGA);
    18591214    if(mColorFormat.fourcc() == FOURCC_YV12)
    18601215    {
    18611216        QRect rect(0,0,aSize.width()/2,aSize.height()/2);
    1862         mpTex[1] = vboxVHWATextureCreate(rect, mColorFormat, bVGA);
    1863         mpTex[2] = vboxVHWATextureCreate(rect, mColorFormat, bVGA);
     1217        mpTex[1] = vboxVHWATextureCreate(mWidget->context(), rect, mColorFormat, bVGA);
     1218        mpTex[2] = vboxVHWATextureCreate(mWidget->context(), rect, mColorFormat, bVGA);
    18641219    }
    18651220
     
    33502705    VBOXQGLLOG_ENTER(("\n"));
    33512706
     2707    const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(context());
     2708
    33522709    if(!(pCmd->SurfInfo.flags & VBOXVHWA_SD_CAPS))
    33532710    {
     
    34172774            /* detect whether we support this format */
    34182775            bool bFound = false;
    3419             for(uint32_t i = 0; i < g_vboxVHWAFourccSupportedCount; i++)
     2776            for(int i = 0; i < info.getFourccSupportedCount(); i++)
    34202777            {
    3421                 if(g_vboxVHWAFourccSupportedList[i] == pCmd->SurfInfo.PixelFormat.fourCC)
     2778                if(info.getFourccSupportedList()[i] == pCmd->SurfInfo.PixelFormat.fourCC)
    34222779                {
    34232780                    bFound = true;
     
    40833440    VBOXQGLLOG_ENTER(("\n"));
    40843441    bool bEnabled = false;
    4085     if(vboxVHWASupportedInternal())
     3442    const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(context());
     3443    if(info.isVHWASupported())
    40863444    {
    40873445        Assert(pCmd->u.in.guestVersion.maj == VBOXVHWA_VERSION_MAJ);
     
    41423500                            ;
    41433501
    4144         if(g_vboxVHWAGlShaderSupported && g_vboxVHWAGlMultiTexNumSupported >= 2)
     3502        if(info.getGlInfo().isFragmentShaderSupported() && info.getGlInfo().getMultiTexNumSupported() >= 2)
    41453503        {
    41463504            pCmd->u.out.caps |= VBOXVHWA_CAPS_COLORKEY
     
    41553513                            ;
    41563514
    4157             if(g_vboxVHWAGlTextureRectangleSupported)
     3515            if(info.getGlInfo().isTextureRectangleSupported())
    41583516            {
    41593517                pCmd->u.out.caps |= VBOXVHWA_CAPS_OVERLAYFOURCC
     
    41683526//              pCmd->u.out.caps2 |= VBOXVHWA_CAPS2_COPYFOURCC;
    41693527
    4170                 pCmd->u.out.numFourCC = g_vboxVHWAFourccSupportedCount;
     3528                pCmd->u.out.numFourCC = info.getFourccSupportedCount();
    41713529            }
    41723530        }
     
    41803538    VBOXQGLLOG_ENTER(("\n"));
    41813539
    4182     Assert(pCmd->numFourCC >= g_vboxVHWAFourccSupportedCount);
    4183     if(pCmd->numFourCC < g_vboxVHWAFourccSupportedCount)
     3540    const VBoxVHWAInfo & info = vboxVHWAGetSupportInfo(context());
     3541
     3542    Assert(pCmd->numFourCC >= (uint32_t)info.getFourccSupportedCount());
     3543    if(pCmd->numFourCC < (uint32_t)info.getFourccSupportedCount())
    41843544        return VERR_GENERAL_FAILURE;
    41853545
    4186     pCmd->numFourCC = g_vboxVHWAFourccSupportedCount;
    4187     for(uint32_t i = 0; i < g_vboxVHWAFourccSupportedCount; i++)
    4188     {
    4189         pCmd->FourCC[i] = g_vboxVHWAFourccSupportedList[i];
     3546    pCmd->numFourCC = (uint32_t)info.getFourccSupportedCount();
     3547    for(int i = 0; i < info.getFourccSupportedCount(); i++)
     3548    {
     3549        pCmd->FourCC[i] = info.getFourccSupportedList()[i];
    41903550    }
    41913551    return VINF_SUCCESS;
     
    47084068void VBoxGLWidget::initializeGL()
    47094069{
    4710     vboxVHWAGlInit(context());
     4070    vboxVHWAGetSupportInfo(context());
    47114071    VBoxVHWASurfaceBase::globalInit();
    47124072}
     
    58355195bool VBoxQGLOverlay::isAcceleration2DVideoAvailable()
    58365196{
    5837     vboxVHWAGlInit(NULL);
    5838     return vboxVHWASupportedInternal();
     5197    static bool g_bVBoxVHWAChecked = false;
     5198    static bool g_bVBoxVHWASupported = false;
     5199    if(!g_bVBoxVHWAChecked)
     5200    {
     5201        g_bVBoxVHWAChecked = true;
     5202        g_bVBoxVHWASupported = VBoxVHWAInfo::checkVHWASupport();
     5203    }
     5204    return g_bVBoxVHWASupported;
    58395205}
    58405206
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette