1
/* $Id: packspu_glsl.c $ */
4
* VBox OpenGL GLSL related functions
8
* Copyright (C) 2009 Sun Microsystems, Inc.
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.
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.
24
#include "cr_packfunctions.h"
26
#include "packspu_proto.h"
30
GLuint PACKSPU_APIENTRY packspu_CreateProgram(void)
34
GLuint return_val = (GLuint) 0;
35
if (!(pack_spu.thread[0].netServer.conn->actual_network))
37
crError("packspu_CreateProgram doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!");
41
crPackCreateProgramSWAP(&return_val, &writeback);
45
crPackCreateProgram(&return_val, &writeback);
47
packspuFlush((void *) thread);
52
return_val = (GLuint) SWAP32(return_val);
55
crStateCreateProgram(return_val);
60
static GLint packspu_GetUniformLocationUncached(GLuint program, const char * name)
64
GLint return_val = (GLint) 0;
65
if (!(pack_spu.thread[0].netServer.conn->actual_network))
67
crError("packspu_GetUniformLocation doesn't work when there's no actual network involved!\nTry using the simplequery SPU in your chain!");
71
crPackGetUniformLocationSWAP(program, name, &return_val, &writeback);
75
crPackGetUniformLocation(program, name, &return_val, &writeback);
77
packspuFlush((void *) thread);
82
return_val = (GLint) SWAP32(return_val);
87
GLint PACKSPU_APIENTRY packspu_GetUniformLocation(GLuint program, const char * name)
89
if (!crStateIsProgramUniformsCached(program))
93
GLsizei maxcbData = 16*1024*sizeof(char);
96
pData = (GLsizei *) crAlloc(maxcbData+sizeof(GLsizei));
99
crWarning("packspu_GetUniformLocation: not enough memory, fallback to single query");
100
return packspu_GetUniformLocationUncached(program, name);
103
crPackGetUniformsLocations(program, maxcbData, pData, NULL, &writeback);
105
packspuFlush((void *) thread);
109
crStateGLSLProgramCacheUniforms(program, pData[0], &pData[1]);
111
CRASSERT(crStateIsProgramUniformsCached(program));
116
/*crDebug("packspu_GetUniformLocation(%d, %s)=%i", program, name, crStateGetUniformLocation(program, name));*/
117
return crStateGetUniformLocation(program, name);
120
void PACKSPU_APIENTRY packspu_GetUniformsLocations(GLuint program, GLsizei maxcbData, GLsizei * cbData, GLvoid * pData)
126
crWarning("packspu_GetUniformsLocations shouldn't be called directly");
129
void PACKSPU_APIENTRY packspu_DeleteProgram(GLuint program)
131
crStateDeleteProgram(program);
132
crPackDeleteProgram(program);
135
void PACK_APIENTRY packspu_DeleteObjectARB(GLhandleARB obj)
137
GLuint hwid = crStateGetProgramHWID(obj);
141
crStateDeleteProgram(obj);
144
crPackDeleteObjectARB(obj);
147
void PACKSPU_APIENTRY packspu_LinkProgram(GLuint program)
149
crStateLinkProgram(program);
150
crPackLinkProgram(program);