packspu_getshaders.c revision d68511fc6827e32ca38d7bbaed520c34b6c9f050
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync/* $Id$ */
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync/** @file
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync * VBox OpenGL DRI driver functions
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync */
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync/*
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync *
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync * Sun Microsystems, Inc. confidential
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync * All rights reserved
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync */
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync#include "packspu.h"
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync#include "cr_packfunctions.h"
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync#include "cr_net.h"
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync#include "packspu_proto.h"
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync#include "cr_mem.h"
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync/*@todo combine with the one from server_getshaders.c*/
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsynctypedef struct _crGetActive_t
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync{
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GLsizei length;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GLint size;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GLenum type;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync} crGetActive_t;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsyncvoid PACKSPU_APIENTRY packspu_GetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, char * name)
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync{
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GET_THREAD(thread);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync int writeback = 1;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crGetActive_t *pLocal;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (!size || !type || !name) return;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync pLocal = (crGetActive_t*) crAlloc(bufSize+sizeof(crGetActive_t));
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (!pLocal) return;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crPackGetActiveAttrib(program, index, bufSize, (GLsizei*)pLocal, NULL, NULL, NULL, &writeback);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync packspuFlush((void *) thread);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync while (writeback)
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crNetRecv();
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (*length) *length = pLocal->length;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync *size = pLocal->size;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync *type = pLocal->type;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crMemcpy(name, (char*)&pLocal[1], pLocal->length+1);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crFree(pLocal);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync}
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsyncvoid PACKSPU_APIENTRY packspu_GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, char * name)
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync{
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GET_THREAD(thread);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync int writeback = 1;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crGetActive_t *pLocal;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (!size || !type || !name) return;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync pLocal = (crGetActive_t*) crAlloc(bufSize+sizeof(crGetActive_t));
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (!pLocal) return;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crPackGetActiveUniform(program, index, bufSize, (GLsizei*)pLocal, NULL, NULL, NULL, &writeback);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync packspuFlush((void *) thread);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync while (writeback)
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crNetRecv();
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (*length) *length = pLocal->length;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync *size = pLocal->size;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync *type = pLocal->type;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crMemcpy(name, &pLocal[1], pLocal->length+1);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crFree(pLocal);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync}
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsyncvoid PACKSPU_APIENTRY packspu_GetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders)
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync{
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GET_THREAD(thread);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync int writeback = 1;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GLsizei *pLocal;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (!shaders) return;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync pLocal = (GLsizei*) crAlloc(maxCount*sizeof(GLuint)+sizeof(GLsizei));
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (!pLocal) return;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crPackGetAttachedShaders(program, maxCount, pLocal, NULL, &writeback);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync packspuFlush((void *) thread);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync while (writeback)
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crNetRecv();
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (count) *count=*pLocal;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crMemcpy(shaders, &pLocal[1], *pLocal*sizeof(GLuint));
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crFree(pLocal);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync}
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsyncvoid PACKSPU_APIENTRY packspu_GetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei * length, char * infoLog)
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync{
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GET_THREAD(thread);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync int writeback = 1;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GLsizei *pLocal;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (!infoLog) return;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (!pLocal) return;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crPackGetProgramInfoLog(program, bufSize, pLocal, NULL, &writeback);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync packspuFlush((void *) thread);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync while (writeback)
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crNetRecv();
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (length) *length=*pLocal;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crMemcpy(infoLog, &pLocal[1], (*pLocal)+1);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crFree(pLocal);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync}
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsyncvoid PACKSPU_APIENTRY packspu_GetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei * length, char * infoLog)
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync{
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GET_THREAD(thread);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync int writeback = 1;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GLsizei *pLocal;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (!infoLog) return;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (!pLocal) return;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crPackGetShaderInfoLog(shader, bufSize, pLocal, NULL, &writeback);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync packspuFlush((void *) thread);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync while (writeback)
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crNetRecv();
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (length) *length=*pLocal;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crMemcpy(infoLog, &pLocal[1], (*pLocal)+1);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crFree(pLocal);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync}
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsyncvoid PACKSPU_APIENTRY packspu_GetShaderSource(GLuint shader, GLsizei bufSize, GLsizei * length, char * source)
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync{
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GET_THREAD(thread);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync int writeback = 1;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync GLsizei *pLocal;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (!source) return;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync pLocal = (GLsizei*) crAlloc(bufSize+sizeof(GLsizei));
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (!pLocal) return;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crPackGetShaderSource(shader, bufSize, pLocal, NULL, &writeback);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync packspuFlush((void *) thread);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync while (writeback)
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crNetRecv();
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync if (length) *length=*pLocal;
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crMemcpy(source, &pLocal[1], (*pLocal)+1);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync crFree(pLocal);
d68511fc6827e32ca38d7bbaed520c34b6c9f050vboxsync}