server_gentextures.c revision 51e7ffc68ae0a6122fcfdc746905b6c7dae2c610
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/* Copyright (c) 2001, Stanford University
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * All rights reserved
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync *
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * See the file LICENSE.txt for information on redistributing this software.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "cr_spu.h"
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync#include "chromium.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "cr_mem.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "cr_net.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "server_dispatch.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "server.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncvoid SERVER_DISPATCH_APIENTRY crServerDispatchGenTextures( GLsizei n, GLuint *textures )
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync GLsizei i;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync GLuint *local_textures = (GLuint *) crAlloc( n*sizeof( *local_textures) );
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync (void) textures;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync cr_server.head_spu->dispatch_table.GenTextures( n, local_textures );
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* This is somewhat hacky.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * We have to make sure we're going to generate unique texture IDs.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * That wasn't the case before snapshot loading, because we could just rely on host video drivers.
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync * Now we could have a set of loaded texture IDs which aren't already reserved in the host driver.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Note: It seems, that it's easy to reserve ATI/NVidia IDs, by simply calling glGenTextures
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * with n==number of loaded textures. But it's really implementation dependant. So can't rely that it'll not change.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync */
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync for (i=0; i<n; ++i)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync {
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync /* translate the ID as it'd be done in glBindTexture call */
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync GLuint tID = crServerTranslateTextureID(local_textures[i]);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /* check if we have a texture with same ID loaded from snapshot */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync while (crStateIsTexture(tID))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* request new ID */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync cr_server.head_spu->dispatch_table.GenTextures(1, &tID);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync local_textures[i] = tID;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync tID = crServerTranslateTextureID(tID);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync crServerReturnValue( local_textures, n*sizeof( *local_textures ) );
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync crFree( local_textures );
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncvoid SERVER_DISPATCH_APIENTRY crServerDispatchGenProgramsNV( GLsizei n, GLuint * ids )
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync GLuint *local_progs = (GLuint *) crAlloc( n*sizeof( *local_progs) );
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync (void) ids;
cd059a6642b11828bd0ad8b3108f5f7f611d144fvboxsync cr_server.head_spu->dispatch_table.GenProgramsNV( n, local_progs );
cd059a6642b11828bd0ad8b3108f5f7f611d144fvboxsync crServerReturnValue( local_progs, n*sizeof( *local_progs ) );
cd059a6642b11828bd0ad8b3108f5f7f611d144fvboxsync crFree( local_progs );
cd059a6642b11828bd0ad8b3108f5f7f611d144fvboxsync}
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsyncvoid SERVER_DISPATCH_APIENTRY crServerDispatchGenFencesNV( GLsizei n, GLuint * ids )
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync GLuint *local_fences = (GLuint *) crAlloc( n*sizeof( *local_fences) );
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync (void) ids;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync cr_server.head_spu->dispatch_table.GenFencesNV( n, local_fences );
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync crServerReturnValue( local_fences, n*sizeof( *local_fences ) );
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync crFree( local_fences );
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncvoid SERVER_DISPATCH_APIENTRY crServerDispatchGenProgramsARB( GLsizei n, GLuint * ids )
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync GLuint *local_progs = (GLuint *) crAlloc( n*sizeof( *local_progs) );
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync GLsizei i;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync (void) ids;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync cr_server.head_spu->dispatch_table.GenProgramsARB( n, local_progs );
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /* see comments in crServerDispatchGenTextures */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync for (i=0; i<n; ++i)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync {
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync GLuint tID = crServerTranslateProgramID(local_progs[i]);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync while (crStateIsProgramARB(tID))
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync {
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync cr_server.head_spu->dispatch_table.GenProgramsARB(1, &tID);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync local_progs[i] = tID;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync tID = crServerTranslateProgramID(tID);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync }
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync }
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync crServerReturnValue( local_progs, n*sizeof( *local_progs ) );
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync crFree( local_progs );
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync}
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsyncvoid SERVER_DISPATCH_APIENTRY
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsynccrServerDispatchCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync{
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync GLsizei tw, th;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &tw);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &th);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Workaround for a wine or ati bug. Host drivers crash unless we first provide texture bounds. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (((tw!=width) || (th!=height)) && (internalFormat==GL_DEPTH_COMPONENT24))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync crServerDispatchTexImage2D(target, level, internalFormat, width, height, border, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync crStateCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync cr_server.head_spu->dispatch_table.CopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync}
c740281e4f5e61397e892447aeef2a7bdbbaaf8dvboxsync