VirtualBox

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

Last change on this file since 42499 was 42499, checked in by vboxsync, 12 years ago

crOgl/wddm: per-context connections

  • 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 42499 2012-08-01 10:26:43Z 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 CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
45 if (pack_spu.swap)
46 {
47 return_val = (GLuint) SWAP32(return_val);
48 }
49
50 crStateCreateProgram(return_val);
51
52 return return_val;
53}
54
55static GLint packspu_GetUniformLocationUncached(GLuint program, const char * name)
56{
57 GET_THREAD(thread);
58 int writeback = 1;
59 GLint return_val = (GLint) 0;
60 if (!(pack_spu.thread[pack_spu.idxThreadInUse].netServer.conn->actual_network))
61 {
62 crError("packspu_GetUniformLocation doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!");
63 }
64 if (pack_spu.swap)
65 {
66 crPackGetUniformLocationSWAP(program, name, &return_val, &writeback);
67 }
68 else
69 {
70 crPackGetUniformLocation(program, name, &return_val, &writeback);
71 }
72 packspuFlush((void *) thread);
73 CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
74 if (pack_spu.swap)
75 {
76 return_val = (GLint) SWAP32(return_val);
77 }
78 return return_val;
79}
80
81GLint PACKSPU_APIENTRY packspu_GetUniformLocation(GLuint program, const char * name)
82{
83 if (!crStateIsProgramUniformsCached(program))
84 {
85 GET_THREAD(thread);
86 int writeback = 1;
87 GLsizei maxcbData;
88 GLsizei *pData;
89 GLint mu;
90
91 packspu_GetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &mu);
92 maxcbData = 16*mu*sizeof(char);
93
94 pData = (GLsizei *) crAlloc(maxcbData+sizeof(GLsizei));
95 if (!pData)
96 {
97 crWarning("packspu_GetUniformLocation: not enough memory, fallback to single query");
98 return packspu_GetUniformLocationUncached(program, name);
99 }
100
101 crPackGetUniformsLocations(program, maxcbData, pData, NULL, &writeback);
102
103 packspuFlush((void *) thread);
104 CRPACKSPU_WRITEBACK_WAIT(thread, writeback);
105
106 crStateGLSLProgramCacheUniforms(program, pData[0], &pData[1]);
107
108 CRASSERT(crStateIsProgramUniformsCached(program));
109
110 crFree(pData);
111 }
112
113 /*crDebug("packspu_GetUniformLocation(%d, %s)=%i", program, name, crStateGetUniformLocation(program, name));*/
114 return crStateGetUniformLocation(program, name);
115}
116
117void PACKSPU_APIENTRY packspu_GetUniformsLocations(GLuint program, GLsizei maxcbData, GLsizei * cbData, GLvoid * pData)
118{
119 (void) program;
120 (void) maxcbData;
121 (void) cbData;
122 (void) pData;
123 crWarning("packspu_GetUniformsLocations shouldn't be called directly");
124}
125
126void PACKSPU_APIENTRY packspu_DeleteProgram(GLuint program)
127{
128 crStateDeleteProgram(program);
129 crPackDeleteProgram(program);
130}
131
132void PACK_APIENTRY packspu_DeleteObjectARB(GLhandleARB obj)
133{
134 GLuint hwid = crStateGetProgramHWID(obj);
135
136 CRASSERT(obj);
137
138 if (hwid)
139 {
140 crStateDeleteProgram(obj);
141 }
142
143 crPackDeleteObjectARB(obj);
144}
145
146void PACKSPU_APIENTRY packspu_LinkProgram(GLuint program)
147{
148 crStateLinkProgram(program);
149 crPackLinkProgram(program);
150}
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