VirtualBox

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

Last change on this file since 33988 was 33988, checked in by vboxsync, 14 years ago

crOpenGL/wddm: more multithreading fixes, vista expirience index works now

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