1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "cr_spu.h"
|
---|
8 | #include "chromium.h"
|
---|
9 | #include "cr_mem.h"
|
---|
10 | #include "cr_net.h"
|
---|
11 | #include "server_dispatch.h"
|
---|
12 | #include "server.h"
|
---|
13 |
|
---|
14 | void SERVER_DISPATCH_APIENTRY crServerDispatchGenTextures( GLsizei n, GLuint *textures )
|
---|
15 | {
|
---|
16 | GLsizei i;
|
---|
17 | GLuint *local_textures = (GLuint *) crAlloc( n*sizeof( *local_textures) );
|
---|
18 | (void) textures;
|
---|
19 | cr_server.head_spu->dispatch_table.GenTextures( n, local_textures );
|
---|
20 |
|
---|
21 | /* This is somewhat hacky.
|
---|
22 | * We have to make sure we're going to generate unique texture IDs.
|
---|
23 | * That wasn't the case before snapshot loading, because we could just rely on host video drivers.
|
---|
24 | * Now we could have a set of loaded texture IDs which aren't already reserved in the host driver.
|
---|
25 | * Note: It seems, that it's easy to reserve ATI/NVidia IDs, by simply calling glGenTextures
|
---|
26 | * with n==number of loaded textures. But it's really implementation dependant. So can't rely that it'll not change.
|
---|
27 | */
|
---|
28 | for (i=0; i<n; ++i)
|
---|
29 | {
|
---|
30 | /* translate the ID as it'd be done in glBindTexture call */
|
---|
31 | GLuint tID = crServerTranslateTextureID(local_textures[i]);
|
---|
32 | /* check if we have a texture with same ID loaded from snapshot */
|
---|
33 | while (crStateIsTexture(tID))
|
---|
34 | {
|
---|
35 | /* request new ID */
|
---|
36 | cr_server.head_spu->dispatch_table.GenTextures(1, &tID);
|
---|
37 | local_textures[i] = tID;
|
---|
38 | tID = crServerTranslateTextureID(tID);
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | crServerReturnValue( local_textures, n*sizeof( *local_textures ) );
|
---|
43 | crFree( local_textures );
|
---|
44 | }
|
---|
45 |
|
---|
46 |
|
---|
47 | void SERVER_DISPATCH_APIENTRY crServerDispatchGenProgramsNV( GLsizei n, GLuint * ids )
|
---|
48 | {
|
---|
49 | GLuint *local_progs = (GLuint *) crAlloc( n*sizeof( *local_progs) );
|
---|
50 | (void) ids;
|
---|
51 | cr_server.head_spu->dispatch_table.GenProgramsNV( n, local_progs );
|
---|
52 | crServerReturnValue( local_progs, n*sizeof( *local_progs ) );
|
---|
53 | crFree( local_progs );
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | void SERVER_DISPATCH_APIENTRY crServerDispatchGenFencesNV( GLsizei n, GLuint * ids )
|
---|
58 | {
|
---|
59 | GLuint *local_fences = (GLuint *) crAlloc( n*sizeof( *local_fences) );
|
---|
60 | (void) ids;
|
---|
61 | cr_server.head_spu->dispatch_table.GenFencesNV( n, local_fences );
|
---|
62 | crServerReturnValue( local_fences, n*sizeof( *local_fences ) );
|
---|
63 | crFree( local_fences );
|
---|
64 | }
|
---|
65 |
|
---|
66 | void SERVER_DISPATCH_APIENTRY crServerDispatchGenProgramsARB( GLsizei n, GLuint * ids )
|
---|
67 | {
|
---|
68 | GLuint *local_progs = (GLuint *) crAlloc( n*sizeof( *local_progs) );
|
---|
69 | GLsizei i;
|
---|
70 | (void) ids;
|
---|
71 | cr_server.head_spu->dispatch_table.GenProgramsARB( n, local_progs );
|
---|
72 |
|
---|
73 | /* see comments in crServerDispatchGenTextures */
|
---|
74 | for (i=0; i<n; ++i)
|
---|
75 | {
|
---|
76 | GLuint tID = crServerTranslateProgramID(local_progs[i]);
|
---|
77 | while (crStateIsProgramARB(tID))
|
---|
78 | {
|
---|
79 | cr_server.head_spu->dispatch_table.GenProgramsARB(1, &tID);
|
---|
80 | local_progs[i] = tID;
|
---|
81 | tID = crServerTranslateProgramID(tID);
|
---|
82 | }
|
---|
83 | }
|
---|
84 |
|
---|
85 | crServerReturnValue( local_progs, n*sizeof( *local_progs ) );
|
---|
86 | crFree( local_progs );
|
---|
87 | }
|
---|