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

« back to all changes in this revision

Viewing changes to src/VBox/GuestHost/OpenGL/include/state/cr_glsl.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
/* $Id: cr_glsl.h $ */
 
2
 
 
3
/** @file
 
4
 * VBox crOpenGL: GLSL related state info
 
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
 
 
23
#ifndef CR_STATE_GLSL_H
 
24
#define CR_STATE_GLSL_H
 
25
 
 
26
#include "cr_hash.h"
 
27
#include "state/cr_statetypes.h"
 
28
#include "state/cr_statefuncs.h"
 
29
 
 
30
#ifdef __cplusplus
 
31
extern "C" {
 
32
#endif
 
33
 
 
34
/* We can't go the "easy" way of just extracting all the required data when taking snapshots.
 
35
   Shader objects might be modified *after* program linkage and wouldn't affect program untill it's relinked.
 
36
   So we have to keep track of shaders statuses right before each program was linked as well as their "current" status.
 
37
*/
 
38
 
 
39
/*@todo: check rare case when successfully linked and active program is relinked with failure*/
 
40
 
 
41
typedef struct {
 
42
    GLuint      id, hwid;
 
43
    GLenum      type;               /*GL_VERTEX_SHADER or GL_FRAGMENT_SHADER*/
 
44
    GLchar*     source;             /*NULL after context loading unless in program's "active" hash*/
 
45
    GLboolean   compiled, deleted;
 
46
    GLuint      refCount;           /*valid only for shaders in CRGLSLState's hash*/
 
47
} CRGLSLShader;
 
48
 
 
49
typedef struct {
 
50
    GLchar* name;
 
51
    GLuint index;
 
52
} CRGLSLAttrib;
 
53
 
 
54
/*Note: active state will hold copies of shaders while current state references shaders in the CRGLSLState hashtable*/
 
55
/*@todo: probably don't need a hashtable here*/
 
56
typedef struct {
 
57
    CRHashTable  *attachedShaders;
 
58
    CRGLSLAttrib *pAttribs; /*several names could be bound to the same index*/
 
59
    GLuint        cAttribs;
 
60
} CRGLSLProgramState;
 
61
 
 
62
typedef struct{
 
63
    GLchar *name;
 
64
    GLenum  type;
 
65
    GLvoid *data;
 
66
#ifdef IN_GUEST
 
67
    GLint  location;
 
68
#endif
 
69
} CRGLSLUniform;
 
70
 
 
71
typedef struct {
 
72
    GLuint              id, hwid;
 
73
    GLboolean           validated, linked, deleted;
 
74
    CRGLSLProgramState  activeState, currentState;
 
75
    CRGLSLUniform      *pUniforms;
 
76
    GLuint              cUniforms;
 
77
#ifdef IN_GUEST
 
78
    GLboolean           bUniformsSynced; /*uniforms info is updated since last link program call.*/
 
79
#endif
 
80
} CRGLSLProgram;
 
81
 
 
82
typedef struct {
 
83
    CRHashTable *shaders;
 
84
    CRHashTable *programs;
 
85
 
 
86
    CRGLSLProgram *activeProgram;
 
87
 
 
88
    /* Indicates that we have to resend GLSL data to GPU on first glMakeCurrent call with owning context */
 
89
    GLboolean   bResyncNeeded;
 
90
} CRGLSLState;
 
91
 
 
92
DECLEXPORT(void) STATE_APIENTRY crStateGLSLInit(CRContext *ctx);
 
93
DECLEXPORT(void) STATE_APIENTRY crStateGLSLDestroy(CRContext *ctx);
 
94
DECLEXPORT(void) STATE_APIENTRY crStateGLSLSwitch(CRContext *from, CRContext *to);
 
95
 
 
96
DECLEXPORT(GLuint) STATE_APIENTRY crStateGetShaderHWID(GLuint id);
 
97
DECLEXPORT(GLuint) STATE_APIENTRY crStateGetProgramHWID(GLuint id);
 
98
DECLEXPORT(GLuint) STATE_APIENTRY crStateGLSLProgramHWIDtoID(GLuint hwid);
 
99
DECLEXPORT(GLuint) STATE_APIENTRY crStateGLSLShaderHWIDtoID(GLuint hwid);
 
100
 
 
101
DECLEXPORT(GLint) STATE_APIENTRY crStateGetUniformSize(GLenum type);
 
102
DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsIntUniform(GLenum type);
 
103
 
 
104
DECLEXPORT(void) STATE_APIENTRY crStateCreateShader(GLuint id, GLenum type);
 
105
DECLEXPORT(void) STATE_APIENTRY crStateCreateProgram(GLuint id);
 
106
 
 
107
DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsProgramUniformsCached(GLuint program);
 
108
 
 
109
#ifdef IN_GUEST
 
110
DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheUniforms(GLuint program, GLsizei cbData, GLvoid *pData);
 
111
#else
 
112
DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheUniforms(GLuint program, GLsizei maxcbData, GLsizei *cbData, GLvoid *pData);
 
113
#endif
 
114
 
 
115
#ifdef __cplusplus
 
116
}
 
117
#endif
 
118
 
 
119
#endif /* CR_STATE_GLSL_H */