VirtualBox

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

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

crOpenGL: fix world of warcraft crash on second login

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