VirtualBox

source: vbox/trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_glsl.c@ 24306

Last change on this file since 24306 was 23440, checked in by vboxsync, 16 years ago

fixed OSE header

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: packspu_glsl.c 23440 2009-09-30 12:44:51Z vboxsync $ */
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
30GLuint 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
60static 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
87GLint 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
120void 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
129void PACKSPU_APIENTRY packspu_DeleteProgram(GLuint program)
130{
131 crStateDeleteProgram(program);
132 crPackDeleteProgram(program);
133}
134
135void 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
147void PACKSPU_APIENTRY packspu_LinkProgram(GLuint program)
148{
149 crStateLinkProgram(program);
150 crPackLinkProgram(program);
151}
Note: See TracBrowser for help on using the repository browser.

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