VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_gentextures.cpp@ 78375

Last change on this file since 78375 was 78375, checked in by vboxsync, 6 years ago

Additions/common/crOpengl,GuestHost/OpenGL,HostServices/SharedOpenGL: Eliminate all global variables from the state tracker library (state_tracker) in preparation of the SPU DLL merging, bugref:9435

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 4.1 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 GLuint *local_textures;
17 (void) textures;
18
19 if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
20 {
21 crError("crServerDispatchGenTextures: parameter 'n' is out of range");
22 return;
23 }
24
25 local_textures = (GLuint *)crCalloc(n * sizeof(*local_textures));
26
27 if (!local_textures)
28 {
29 crError("crServerDispatchGenTextures: out of memory");
30 return;
31 }
32
33 crStateGenTextures(&cr_server.StateTracker, n, local_textures);
34
35 crServerReturnValue(local_textures, n*sizeof(*local_textures));
36 crFree( local_textures );
37}
38
39void SERVER_DISPATCH_APIENTRY crServerDispatchGenProgramsNV( GLsizei n, GLuint * ids )
40{
41 GLuint *local_progs;
42 (void) ids;
43
44 if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
45 {
46 crError("crServerDispatchGenProgramsNV: parameter 'n' is out of range");
47 return;
48 }
49
50 local_progs = (GLuint *)crCalloc(n * sizeof(*local_progs));
51
52 if (!local_progs)
53 {
54 crError("crServerDispatchGenProgramsNV: out of memory");
55 return;
56 }
57
58 cr_server.head_spu->dispatch_table.GenProgramsNV( n, local_progs );
59 crServerReturnValue( local_progs, n*sizeof( *local_progs ) );
60 crFree( local_progs );
61}
62
63
64void SERVER_DISPATCH_APIENTRY crServerDispatchGenFencesNV( GLsizei n, GLuint * ids )
65{
66 GLuint *local_fences;
67 (void) ids;
68
69 if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
70 {
71 crError("crServerDispatchGenFencesNV: parameter 'n' is out of range");
72 return;
73 }
74
75 local_fences = (GLuint *)crCalloc(n * sizeof(*local_fences));
76
77 if (!local_fences)
78 {
79 crError("crServerDispatchGenFencesNV: out of memory");
80 return;
81 }
82
83 cr_server.head_spu->dispatch_table.GenFencesNV( n, local_fences );
84 crServerReturnValue( local_fences, n*sizeof( *local_fences ) );
85 crFree( local_fences );
86}
87
88void SERVER_DISPATCH_APIENTRY crServerDispatchGenProgramsARB( GLsizei n, GLuint * ids )
89{
90 GLuint *local_progs;
91 GLsizei i;
92 (void) ids;
93
94 if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
95 {
96 crError("crServerDispatchGenProgramsARB: parameter 'n' is out of range");
97 return;
98 }
99
100 local_progs = (GLuint *)crCalloc(n * sizeof(*local_progs));
101
102 if (!local_progs)
103 {
104 crError("crServerDispatchGenProgramsARB: out of money");
105 return;
106 }
107
108 cr_server.head_spu->dispatch_table.GenProgramsARB( n, local_progs );
109
110 /* see comments in crServerDispatchGenTextures */
111 for (i=0; i<n; ++i)
112 {
113 GLuint tID = crServerTranslateProgramID(local_progs[i]);
114 while (crStateIsProgramARB(&cr_server.StateTracker, tID))
115 {
116 cr_server.head_spu->dispatch_table.GenProgramsARB(1, &tID);
117 local_progs[i] = tID;
118 tID = crServerTranslateProgramID(tID);
119 }
120 }
121
122 crServerReturnValue( local_progs, n * sizeof( *local_progs ) );
123 crFree( local_progs );
124}
125
126void SERVER_DISPATCH_APIENTRY
127crServerDispatchCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
128{
129 GLsizei tw, th;
130
131 cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &tw);
132 cr_server.head_spu->dispatch_table.GetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &th);
133
134 /* Workaround for a wine or ati bug. Host drivers crash unless we first provide texture bounds. */
135 if (((tw!=width) || (th!=height)) && (internalFormat==GL_DEPTH_COMPONENT24))
136 {
137 crServerDispatchTexImage2D(target, level, internalFormat, width, height, border, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
138 }
139
140 crStateCopyTexImage2D(&cr_server.StateTracker, target, level, internalFormat, x, y, width, height, border);
141 cr_server.head_spu->dispatch_table.CopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
142}
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