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

« back to all changes in this revision

Viewing changes to src/VBox/Additions/common/crOpenGL/pack/packspu_glsl.c

  • 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: packspu_glsl.c $ */
 
2
 
 
3
/** @file
 
4
 * VBox OpenGL GLSL related functions
 
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
#include "packspu.h"
 
24
#include "cr_packfunctions.h"
 
25
#include "cr_net.h"
 
26
#include "packspu_proto.h"
 
27
#include "cr_mem.h"
 
28
 
 
29
 
 
30
GLuint PACKSPU_APIENTRY packspu_CreateProgram(void)
 
31
{
 
32
    GET_THREAD(thread);
 
33
    int writeback = 1;
 
34
    GLuint return_val = (GLuint) 0;
 
35
    if (!(pack_spu.thread[0].netServer.conn->actual_network))
 
36
    {
 
37
        crError("packspu_CreateProgram doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!");
 
38
    }
 
39
    if (pack_spu.swap)
 
40
    {
 
41
        crPackCreateProgramSWAP(&return_val, &writeback);
 
42
    }
 
43
    else
 
44
    {
 
45
        crPackCreateProgram(&return_val, &writeback);
 
46
    }
 
47
    packspuFlush((void *) thread);
 
48
    while (writeback)
 
49
        crNetRecv();
 
50
    if (pack_spu.swap)
 
51
    {
 
52
        return_val = (GLuint) SWAP32(return_val);
 
53
    }
 
54
 
 
55
    crStateCreateProgram(return_val);
 
56
 
 
57
    return return_val;
 
58
}
 
59
 
 
60
static GLint packspu_GetUniformLocationUncached(GLuint program, const char * name)
 
61
{
 
62
    GET_THREAD(thread);
 
63
    int writeback = 1;
 
64
    GLint return_val = (GLint) 0;
 
65
    if (!(pack_spu.thread[0].netServer.conn->actual_network))
 
66
    {
 
67
        crError("packspu_GetUniformLocation doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!");
 
68
    }
 
69
    if (pack_spu.swap)
 
70
    {
 
71
        crPackGetUniformLocationSWAP(program, name, &return_val, &writeback);
 
72
    }
 
73
    else
 
74
    {
 
75
        crPackGetUniformLocation(program, name, &return_val, &writeback);
 
76
    }
 
77
    packspuFlush((void *) thread);
 
78
    while (writeback)
 
79
        crNetRecv();
 
80
    if (pack_spu.swap)
 
81
    {
 
82
        return_val = (GLint) SWAP32(return_val);
 
83
    }
 
84
    return return_val;
 
85
}
 
86
 
 
87
GLint PACKSPU_APIENTRY packspu_GetUniformLocation(GLuint program, const char * name)
 
88
{
 
89
    if (!crStateIsProgramUniformsCached(program))  
 
90
    {
 
91
        GET_THREAD(thread);
 
92
        int writeback = 1;
 
93
        GLsizei maxcbData = 16*1024*sizeof(char);
 
94
        GLsizei *pData;
 
95
 
 
96
        pData = (GLsizei *) crAlloc(maxcbData+sizeof(GLsizei));
 
97
        if (!pData)
 
98
        {
 
99
            crWarning("packspu_GetUniformLocation: not enough memory, fallback to single query");
 
100
            return packspu_GetUniformLocationUncached(program, name);
 
101
        }
 
102
 
 
103
        crPackGetUniformsLocations(program, maxcbData, pData, NULL, &writeback);
 
104
 
 
105
        packspuFlush((void *) thread);
 
106
        while (writeback)
 
107
            crNetRecv();
 
108
 
 
109
        crStateGLSLProgramCacheUniforms(program, pData[0], &pData[1]);
 
110
 
 
111
        CRASSERT(crStateIsProgramUniformsCached(program));
 
112
 
 
113
        crFree(pData);
 
114
    }
 
115
 
 
116
    /*crDebug("packspu_GetUniformLocation(%d, %s)=%i", program, name, crStateGetUniformLocation(program, name));*/
 
117
    return crStateGetUniformLocation(program, name);
 
118
}
 
119
 
 
120
void PACKSPU_APIENTRY packspu_GetUniformsLocations(GLuint program, GLsizei maxcbData, GLsizei * cbData, GLvoid * pData)
 
121
{
 
122
    (void) program;
 
123
    (void) maxcbData;
 
124
    (void) cbData;
 
125
    (void) pData;
 
126
    crWarning("packspu_GetUniformsLocations shouldn't be called directly");
 
127
}
 
128
 
 
129
void PACKSPU_APIENTRY packspu_DeleteProgram(GLuint program)
 
130
{
 
131
    crStateDeleteProgram(program);
 
132
    crPackDeleteProgram(program);
 
133
}
 
134
 
 
135
void PACK_APIENTRY packspu_DeleteObjectARB(GLhandleARB obj)
 
136
{
 
137
    GLuint hwid = crStateGetProgramHWID(obj);
 
138
 
 
139
    if (hwid)
 
140
    {
 
141
        crStateDeleteProgram(obj);
 
142
    }
 
143
 
 
144
    crPackDeleteObjectARB(obj);
 
145
}
 
146
 
 
147
void PACKSPU_APIENTRY packspu_LinkProgram(GLuint program)
 
148
{
 
149
    crStateLinkProgram(program);
 
150
    crPackLinkProgram(program);
 
151
}