VirtualBox

source: vbox/trunk/include/VBox/VBoxGL2D.h@ 24130

Last change on this file since 24130 was 23746, checked in by vboxsync, 15 years ago

video 2d accel: some code cleaning

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

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