VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_gentextures.c@ 25154

Last change on this file since 25154 was 25154, checked in by vboxsync, 15 years ago

crOpenGL: fix various texture tracking issues

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
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
14void 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
47void 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
57void 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
66void 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}
88
89void SERVER_DISPATCH_APIENTRY
90crServerDispatchCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
91{
92 GLsizei tw, th;
93
94 cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &tw);
95 cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &th);
96
97 /* Workaround for a wine or ati bug. Host drivers crash unless we first provide texture bounds. */
98 if (((tw!=width) || (th!=height)) && (internalFormat==GL_DEPTH_COMPONENT24))
99 {
100 crServerDispatchTexImage2D(target, level, internalFormat, width, height, border, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
101 }
102
103 crStateCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
104 cr_server.head_spu->dispatch_table.CopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
105}
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