~ubuntu-branches/ubuntu/trusty/virtualbox-ose/trusty

« back to all changes in this revision

Viewing changes to include/VBox/VBoxGL2D.h

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
 *
 
3
 * VBox frontends: Qt GUI ("VirtualBox"):
 
4
 * OpenGL support info used for 2D support detection
 
5
 */
 
6
 
 
7
/*
 
8
 * Copyright (C) 2009 Sun Microsystems, Inc.
 
9
 *
 
10
 * This file is part of VirtualBox Open Source Edition (OSE), as
 
11
 * available from http://www.virtualbox.org. This file is free software;
 
12
 * you can redistribute it and/or modify it under the terms of the GNU
 
13
 * General Public License (GPL) as published by the Free Software
 
14
 * Foundation, in version 2 as it comes in the "COPYING" file of the
 
15
 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
 
16
 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
 
17
 *
 
18
 * The contents of this file may alternatively be used under the terms
 
19
 * of the Common Development and Distribution License Version 1.0
 
20
 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
 
21
 * VirtualBox OSE distribution, in which case the provisions of the
 
22
 * CDDL are applicable instead of those of the GPL.
 
23
 *
 
24
 * You may elect to license modified versions of this file under the
 
25
 * terms and conditions of either the GPL or the CDDL or both.
 
26
 *
 
27
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
 
28
 * Clara, CA 95054 USA or visit http://www.sun.com if you need
 
29
 * additional information or have any questions.
 
30
 */
 
31
#ifndef __VBoxGLSupportInfo_h__
 
32
#define __VBoxGLSupportInfo_h__
 
33
 
 
34
#include <iprt/types.h>
 
35
 
 
36
typedef char GLchar;
 
37
 
 
38
#ifndef GL_COMPILE_STATUS
 
39
# define GL_COMPILE_STATUS 0x8b81
 
40
#endif
 
41
#ifndef GL_LINK_STATUS
 
42
# define GL_LINK_STATUS    0x8b82
 
43
#endif
 
44
#ifndef GL_FRAGMENT_SHADER
 
45
# define GL_FRAGMENT_SHADER 0x8b30
 
46
#endif
 
47
#ifndef GL_VERTEX_SHADER
 
48
# define GL_VERTEX_SHADER 0x8b31
 
49
#endif
 
50
 
 
51
/* GL_ARB_multitexture */
 
52
#ifndef GL_TEXTURE0
 
53
# define GL_TEXTURE0                    0x84c0
 
54
#endif
 
55
#ifndef GL_TEXTURE1
 
56
# define GL_TEXTURE1                    0x84c1
 
57
#endif
 
58
#ifndef GL_MAX_TEXTURE_COORDS
 
59
# define GL_MAX_TEXTURE_COORDS          0x8871
 
60
#endif
 
61
#ifndef GL_MAX_TEXTURE_IMAGE_UNITS
 
62
# define GL_MAX_TEXTURE_IMAGE_UNITS     0x8872
 
63
#endif
 
64
 
 
65
#ifndef APIENTRY
 
66
# define APIENTRY
 
67
#endif
 
68
 
 
69
typedef GLvoid (APIENTRY *PFNVBOXVHWA_ACTIVE_TEXTURE) (GLenum texture);
 
70
typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2I) (GLenum texture, GLint v0, GLint v1);
 
71
typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2F) (GLenum texture, GLfloat v0, GLfloat v1);
 
72
typedef GLvoid (APIENTRY *PFNVBOXVHWA_MULTI_TEX_COORD2D) (GLenum texture, GLdouble v0, GLdouble v1);
 
73
 
 
74
/* GL_ARB_texture_rectangle */
 
75
#ifndef GL_TEXTURE_RECTANGLE
 
76
# define GL_TEXTURE_RECTANGLE 0x84F5
 
77
#endif
 
78
 
 
79
/* GL_ARB_shader_objects */
 
80
/* GL_ARB_fragment_shader */
 
81
 
 
82
typedef GLuint (APIENTRY *PFNVBOXVHWA_CREATE_SHADER)  (GLenum type);
 
83
typedef GLvoid (APIENTRY *PFNVBOXVHWA_SHADER_SOURCE)  (GLuint shader, GLsizei count, const GLchar **string, const GLint *length);
 
84
typedef GLvoid (APIENTRY *PFNVBOXVHWA_COMPILE_SHADER) (GLuint shader);
 
85
typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_SHADER)  (GLuint shader);
 
86
 
 
87
typedef GLuint (APIENTRY *PFNVBOXVHWA_CREATE_PROGRAM) ();
 
88
typedef GLvoid (APIENTRY *PFNVBOXVHWA_ATTACH_SHADER)  (GLuint program, GLuint shader);
 
89
typedef GLvoid (APIENTRY *PFNVBOXVHWA_DETACH_SHADER)  (GLuint program, GLuint shader);
 
90
typedef GLvoid (APIENTRY *PFNVBOXVHWA_LINK_PROGRAM)   (GLuint program);
 
91
typedef GLvoid (APIENTRY *PFNVBOXVHWA_USE_PROGRAM)    (GLuint program);
 
92
typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_PROGRAM) (GLuint program);
 
93
 
 
94
typedef GLboolean (APIENTRY *PFNVBOXVHWA_IS_SHADER)   (GLuint shader);
 
95
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_SHADERIV)   (GLuint shader, GLenum pname, GLint *params);
 
96
typedef GLboolean (APIENTRY *PFNVBOXVHWA_IS_PROGRAM)  (GLuint program);
 
97
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_PROGRAMIV)  (GLuint program, GLenum pname, GLint *params);
 
98
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_ATTACHED_SHADERS) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
 
99
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_SHADER_INFO_LOG)  (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
 
100
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GET_PROGRAM_INFO_LOG) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
 
101
typedef GLint (APIENTRY *PFNVBOXVHWA_GET_UNIFORM_LOCATION) (GLint programObj, const GLchar *name);
 
102
 
 
103
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM1F)(GLint location, GLfloat v0);
 
104
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM2F)(GLint location, GLfloat v0, GLfloat v1);
 
105
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM3F)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
 
106
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM4F)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
 
107
 
 
108
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM1I)(GLint location, GLint v0);
 
109
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM2I)(GLint location, GLint v0, GLint v1);
 
110
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM3I)(GLint location, GLint v0, GLint v1, GLint v2);
 
111
typedef GLvoid (APIENTRY *PFNVBOXVHWA_UNIFORM4I)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
 
112
 
 
113
/* GL_ARB_pixel_buffer_object*/
 
114
#ifndef Q_WS_MAC
 
115
/* apears to be defined on mac */
 
116
typedef ptrdiff_t GLsizeiptr;
 
117
#endif
 
118
 
 
119
#ifndef GL_READ_ONLY
 
120
# define GL_READ_ONLY                   0x88B8
 
121
#endif
 
122
#ifndef GL_WRITE_ONLY
 
123
# define GL_WRITE_ONLY                  0x88B9
 
124
#endif
 
125
#ifndef GL_READ_WRITE
 
126
# define GL_READ_WRITE                  0x88BA
 
127
#endif
 
128
#ifndef GL_STREAM_DRAW
 
129
# define GL_STREAM_DRAW                 0x88E0
 
130
#endif
 
131
#ifndef GL_STREAM_READ
 
132
# define GL_STREAM_READ                 0x88E1
 
133
#endif
 
134
#ifndef GL_STREAM_COPY
 
135
# define GL_STREAM_COPY                 0x88E2
 
136
#endif
 
137
 
 
138
#ifndef GL_PIXEL_PACK_BUFFER
 
139
# define GL_PIXEL_PACK_BUFFER           0x88EB
 
140
#endif
 
141
#ifndef GL_PIXEL_UNPACK_BUFFER
 
142
# define GL_PIXEL_UNPACK_BUFFER         0x88EC
 
143
#endif
 
144
#ifndef GL_PIXEL_PACK_BUFFER_BINDING
 
145
# define GL_PIXEL_PACK_BUFFER_BINDING   0x88ED
 
146
#endif
 
147
#ifndef GL_PIXEL_UNPACK_BUFFER_BINDING
 
148
# define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
 
149
#endif
 
150
 
 
151
typedef GLvoid (APIENTRY *PFNVBOXVHWA_GEN_BUFFERS)(GLsizei n, GLuint *buffers);
 
152
typedef GLvoid (APIENTRY *PFNVBOXVHWA_DELETE_BUFFERS)(GLsizei n, const GLuint *buffers);
 
153
typedef GLvoid (APIENTRY *PFNVBOXVHWA_BIND_BUFFER)(GLenum target, GLuint buffer);
 
154
typedef GLvoid (APIENTRY *PFNVBOXVHWA_BUFFER_DATA)(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
 
155
typedef GLvoid* (APIENTRY *PFNVBOXVHWA_MAP_BUFFER)(GLenum target, GLenum access);
 
156
typedef GLboolean (APIENTRY *PFNVBOXVHWA_UNMAP_BUFFER)(GLenum target);
 
157
 
 
158
 
 
159
/*****************/
 
160
 
 
161
/* functions */
 
162
 
 
163
/* @todo: move those to VBoxGLInfo class instance members ??? */
 
164
extern PFNVBOXVHWA_ACTIVE_TEXTURE vboxglActiveTexture;
 
165
extern PFNVBOXVHWA_MULTI_TEX_COORD2I vboxglMultiTexCoord2i;
 
166
extern PFNVBOXVHWA_MULTI_TEX_COORD2D vboxglMultiTexCoord2d;
 
167
extern PFNVBOXVHWA_MULTI_TEX_COORD2F vboxglMultiTexCoord2f;
 
168
 
 
169
 
 
170
extern PFNVBOXVHWA_CREATE_SHADER   vboxglCreateShader;
 
171
extern PFNVBOXVHWA_SHADER_SOURCE   vboxglShaderSource;
 
172
extern PFNVBOXVHWA_COMPILE_SHADER  vboxglCompileShader;
 
173
extern PFNVBOXVHWA_DELETE_SHADER   vboxglDeleteShader;
 
174
 
 
175
extern PFNVBOXVHWA_CREATE_PROGRAM  vboxglCreateProgram;
 
176
extern PFNVBOXVHWA_ATTACH_SHADER   vboxglAttachShader;
 
177
extern PFNVBOXVHWA_DETACH_SHADER   vboxglDetachShader;
 
178
extern PFNVBOXVHWA_LINK_PROGRAM    vboxglLinkProgram;
 
179
extern PFNVBOXVHWA_USE_PROGRAM     vboxglUseProgram;
 
180
extern PFNVBOXVHWA_DELETE_PROGRAM  vboxglDeleteProgram;
 
181
 
 
182
extern PFNVBOXVHWA_IS_SHADER       vboxglIsShader;
 
183
extern PFNVBOXVHWA_GET_SHADERIV    vboxglGetShaderiv;
 
184
extern PFNVBOXVHWA_IS_PROGRAM      vboxglIsProgram;
 
185
extern PFNVBOXVHWA_GET_PROGRAMIV   vboxglGetProgramiv;
 
186
extern PFNVBOXVHWA_GET_ATTACHED_SHADERS vboxglGetAttachedShaders;
 
187
extern PFNVBOXVHWA_GET_SHADER_INFO_LOG  vboxglGetShaderInfoLog;
 
188
extern PFNVBOXVHWA_GET_PROGRAM_INFO_LOG vboxglGetProgramInfoLog;
 
189
 
 
190
extern PFNVBOXVHWA_GET_UNIFORM_LOCATION vboxglGetUniformLocation;
 
191
 
 
192
extern PFNVBOXVHWA_UNIFORM1F vboxglUniform1f;
 
193
extern PFNVBOXVHWA_UNIFORM2F vboxglUniform2f;
 
194
extern PFNVBOXVHWA_UNIFORM3F vboxglUniform3f;
 
195
extern PFNVBOXVHWA_UNIFORM4F vboxglUniform4f;
 
196
 
 
197
extern PFNVBOXVHWA_UNIFORM1I vboxglUniform1i;
 
198
extern PFNVBOXVHWA_UNIFORM2I vboxglUniform2i;
 
199
extern PFNVBOXVHWA_UNIFORM3I vboxglUniform3i;
 
200
extern PFNVBOXVHWA_UNIFORM4I vboxglUniform4i;
 
201
 
 
202
extern PFNVBOXVHWA_GEN_BUFFERS vboxglGenBuffers;
 
203
extern PFNVBOXVHWA_DELETE_BUFFERS vboxglDeleteBuffers;
 
204
extern PFNVBOXVHWA_BIND_BUFFER vboxglBindBuffer;
 
205
extern PFNVBOXVHWA_BUFFER_DATA vboxglBufferData;
 
206
extern PFNVBOXVHWA_MAP_BUFFER vboxglMapBuffer;
 
207
extern PFNVBOXVHWA_UNMAP_BUFFER vboxglUnmapBuffer;
 
208
 
 
209
class VBoxGLInfo
 
210
{
 
211
public:
 
212
    VBoxGLInfo() :
 
213
        mGLVersion(0),
 
214
        mFragmentShaderSupported(false),
 
215
        mTextureRectangleSupported(false),
 
216
        mTextureNP2Supported(false),
 
217
        mPBOSupported(false),
 
218
        mMultiTexNumSupported(1), /* 1 would mean it is not supported */
 
219
        m_GL_ARB_multitexture(false),
 
220
        m_GL_ARB_shader_objects(false),
 
221
        m_GL_ARB_fragment_shader(false),
 
222
        m_GL_ARB_pixel_buffer_object(false),
 
223
        m_GL_ARB_texture_rectangle(false),
 
224
        m_GL_EXT_texture_rectangle(false),
 
225
        m_GL_NV_texture_rectangle(false),
 
226
        m_GL_ARB_texture_non_power_of_two(false),
 
227
        mInitialized(false)
 
228
    {}
 
229
 
 
230
    void init(const class QGLContext * pContext);
 
231
 
 
232
    bool isInitialized() const { return mInitialized; }
 
233
 
 
234
    int getGLVersion() const { return mGLVersion; }
 
235
    bool isFragmentShaderSupported() const { return mFragmentShaderSupported; }
 
236
    bool isTextureRectangleSupported() const { return mTextureRectangleSupported; }
 
237
    bool isTextureNP2Supported() const { return mTextureNP2Supported; }
 
238
    bool isPBOSupported() const { return mPBOSupported; }
 
239
    /* 1 would mean it is not supported */
 
240
    int getMultiTexNumSupported() const { return mMultiTexNumSupported; }
 
241
 
 
242
    static int parseVersion(const GLubyte * ver);
 
243
private:
 
244
    void initExtSupport(const class QGLContext & context);
 
245
 
 
246
    int mGLVersion;
 
247
    bool mFragmentShaderSupported;
 
248
    bool mTextureRectangleSupported;
 
249
    bool mTextureNP2Supported;
 
250
    bool mPBOSupported;
 
251
    int mMultiTexNumSupported; /* 1 would mean it is not supported */
 
252
 
 
253
    bool m_GL_ARB_multitexture;
 
254
    bool m_GL_ARB_shader_objects;
 
255
    bool m_GL_ARB_fragment_shader;
 
256
    bool m_GL_ARB_pixel_buffer_object;
 
257
    bool m_GL_ARB_texture_rectangle;
 
258
    bool m_GL_EXT_texture_rectangle;
 
259
    bool m_GL_NV_texture_rectangle;
 
260
    bool m_GL_ARB_texture_non_power_of_two;
 
261
 
 
262
    bool mInitialized;
 
263
};
 
264
 
 
265
class VBoxGLTmpContext
 
266
{
 
267
public:
 
268
    VBoxGLTmpContext();
 
269
    ~VBoxGLTmpContext();
 
270
 
 
271
    const class QGLContext * makeCurrent();
 
272
private:
 
273
    class QGLWidget * mWidget;
 
274
};
 
275
 
 
276
 
 
277
#define VBOXQGL_MAKEFOURCC(ch0, ch1, ch2, ch3)                              \
 
278
                ((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) |       \
 
279
                ((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
 
280
 
 
281
#define FOURCC_AYUV VBOXQGL_MAKEFOURCC('A', 'Y', 'U', 'V')
 
282
#define FOURCC_UYVY VBOXQGL_MAKEFOURCC('U', 'Y', 'V', 'Y')
 
283
#define FOURCC_YUY2 VBOXQGL_MAKEFOURCC('Y', 'U', 'Y', '2')
 
284
#define FOURCC_YV12 VBOXQGL_MAKEFOURCC('Y', 'V', '1', '2')
 
285
#define VBOXVHWA_NUMFOURCC 4
 
286
 
 
287
class VBoxVHWAInfo
 
288
{
 
289
public:
 
290
    VBoxVHWAInfo() :
 
291
        mFourccSupportedCount(0),
 
292
        mInitialized(false)
 
293
    {}
 
294
 
 
295
    VBoxVHWAInfo(const VBoxGLInfo & glInfo) :
 
296
        mglInfo(glInfo),
 
297
        mFourccSupportedCount(0),
 
298
        mInitialized(false)
 
299
    {}
 
300
 
 
301
    void init(const class QGLContext * pContext);
 
302
 
 
303
    bool isInitialized() const { return mInitialized; }
 
304
 
 
305
    const VBoxGLInfo & getGlInfo() const { return mglInfo; }
 
306
 
 
307
    bool isVHWASupported() const;
 
308
 
 
309
    int getFourccSupportedCount() const { return mFourccSupportedCount; }
 
310
    const uint32_t * getFourccSupportedList() const { return mFourccSupportedList; }
 
311
 
 
312
    static bool checkVHWASupport();
 
313
private:
 
314
    VBoxGLInfo mglInfo;
 
315
    uint32_t mFourccSupportedList[VBOXVHWA_NUMFOURCC];
 
316
    int mFourccSupportedCount;
 
317
 
 
318
    bool mInitialized;
 
319
};
 
320
 
 
321
#endif /* #ifndef __VBoxGLSupportInfo_h__ */