1 | /* $Id: server_framebuffer.cpp 78375 2019-05-03 21:51:02Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox OpenGL: EXT_framebuffer_object
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2019 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | */
|
---|
17 |
|
---|
18 | #include "cr_spu.h"
|
---|
19 | #include "chromium.h"
|
---|
20 | #include "cr_mem.h"
|
---|
21 | #include "cr_net.h"
|
---|
22 | #include "server_dispatch.h"
|
---|
23 | #include "server.h"
|
---|
24 | #include "cr_unpack.h"
|
---|
25 |
|
---|
26 | void SERVER_DISPATCH_APIENTRY
|
---|
27 | crServerDispatchGenFramebuffersEXT(GLsizei n, GLuint *framebuffers)
|
---|
28 | {
|
---|
29 | GLuint *local_buffers;
|
---|
30 | (void) framebuffers;
|
---|
31 |
|
---|
32 | if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
|
---|
33 | {
|
---|
34 | crError("crServerDispatchGenFramebuffersEXT: parameter 'n' is out of range");
|
---|
35 | return;
|
---|
36 | }
|
---|
37 |
|
---|
38 | local_buffers = (GLuint *)crCalloc(n * sizeof(*local_buffers));
|
---|
39 |
|
---|
40 | crStateGenFramebuffersEXT(&cr_server.StateTracker, n, local_buffers);
|
---|
41 |
|
---|
42 | crServerReturnValue(local_buffers, n * sizeof(*local_buffers));
|
---|
43 | crFree(local_buffers);
|
---|
44 | }
|
---|
45 |
|
---|
46 | void SERVER_DISPATCH_APIENTRY
|
---|
47 | crServerDispatchGenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers)
|
---|
48 | {
|
---|
49 | GLuint *local_buffers;
|
---|
50 | (void) renderbuffers;
|
---|
51 |
|
---|
52 | if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
|
---|
53 | {
|
---|
54 | crError("crServerDispatchGenRenderbuffersEXT: parameter 'n' is out of range");
|
---|
55 | return;
|
---|
56 | }
|
---|
57 |
|
---|
58 | local_buffers = (GLuint *)crCalloc(n * sizeof(*local_buffers));
|
---|
59 |
|
---|
60 | crStateGenRenderbuffersEXT(&cr_server.StateTracker, n, local_buffers);
|
---|
61 |
|
---|
62 | crServerReturnValue(local_buffers, n * sizeof(*local_buffers));
|
---|
63 | crFree(local_buffers);
|
---|
64 | }
|
---|
65 |
|
---|
66 | void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
---|
67 | {
|
---|
68 | crStateFramebufferTexture1DEXT(&cr_server.StateTracker, target, attachment, textarget, texture, level);
|
---|
69 | cr_server.head_spu->dispatch_table.FramebufferTexture1DEXT(target, attachment, textarget, crStateGetTextureHWID(&cr_server.StateTracker, texture), level);
|
---|
70 | }
|
---|
71 |
|
---|
72 | void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
---|
73 | {
|
---|
74 | crStateFramebufferTexture2DEXT(&cr_server.StateTracker, target, attachment, textarget, texture, level);
|
---|
75 | cr_server.head_spu->dispatch_table.FramebufferTexture2DEXT(target, attachment, textarget, crStateGetTextureHWID(&cr_server.StateTracker, texture), level);
|
---|
76 | }
|
---|
77 |
|
---|
78 | void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
|
---|
79 | {
|
---|
80 | crStateFramebufferTexture3DEXT(&cr_server.StateTracker, target, attachment, textarget, texture, level, zoffset);
|
---|
81 | cr_server.head_spu->dispatch_table.FramebufferTexture3DEXT(target, attachment, textarget, crStateGetTextureHWID(&cr_server.StateTracker, texture), level, zoffset);
|
---|
82 | }
|
---|
83 |
|
---|
84 | void SERVER_DISPATCH_APIENTRY crServerDispatchBindFramebufferEXT(GLenum target, GLuint framebuffer)
|
---|
85 | {
|
---|
86 | #ifdef DEBUG_misha
|
---|
87 | GLint rfb = 0, dfb = 0;
|
---|
88 | #endif
|
---|
89 | crStateBindFramebufferEXT(&cr_server.StateTracker, target, framebuffer);
|
---|
90 |
|
---|
91 | if (0==framebuffer)
|
---|
92 | {
|
---|
93 | CRContext *ctx = crStateGetCurrent(&cr_server.StateTracker);
|
---|
94 | if (ctx->buffer.drawBuffer == GL_FRONT || ctx->buffer.drawBuffer == GL_FRONT_LEFT || ctx->buffer.drawBuffer == GL_FRONT_RIGHT)
|
---|
95 | cr_server.curClient->currentMural->bFbDraw = GL_TRUE;
|
---|
96 | }
|
---|
97 |
|
---|
98 | if (0==framebuffer && crServerIsRedirectedToFBO())
|
---|
99 | {
|
---|
100 | CRMuralInfo *mural = cr_server.curClient->currentMural;
|
---|
101 | if (target == GL_FRAMEBUFFER)
|
---|
102 | {
|
---|
103 | GLuint idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
|
---|
104 | GLuint idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
|
---|
105 | if (idDrawFBO == idReadFBO)
|
---|
106 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_FRAMEBUFFER, idDrawFBO);
|
---|
107 | else
|
---|
108 | {
|
---|
109 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, idReadFBO);
|
---|
110 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, idDrawFBO);
|
---|
111 | }
|
---|
112 | }
|
---|
113 | else if (target == GL_READ_FRAMEBUFFER)
|
---|
114 | {
|
---|
115 | GLuint idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
|
---|
116 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, idReadFBO);
|
---|
117 | }
|
---|
118 | else if (target == GL_DRAW_FRAMEBUFFER)
|
---|
119 | {
|
---|
120 | GLuint idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
|
---|
121 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, idDrawFBO);
|
---|
122 | }
|
---|
123 | else
|
---|
124 | {
|
---|
125 | crWarning("unknown target %d", target);
|
---|
126 | }
|
---|
127 | #ifdef DEBUG_misha
|
---|
128 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
|
---|
129 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
|
---|
130 | if (GL_FRAMEBUFFER_EXT == target)
|
---|
131 | {
|
---|
132 | Assert(rfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
|
---|
133 | Assert(dfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
|
---|
134 | }
|
---|
135 | else if (GL_READ_FRAMEBUFFER_EXT == target)
|
---|
136 | {
|
---|
137 | Assert(rfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
|
---|
138 | }
|
---|
139 | else if (GL_DRAW_FRAMEBUFFER_EXT == target)
|
---|
140 | {
|
---|
141 | Assert(dfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
|
---|
142 | }
|
---|
143 | else
|
---|
144 | {
|
---|
145 | Assert(0);
|
---|
146 | }
|
---|
147 | #endif
|
---|
148 | }
|
---|
149 | else
|
---|
150 | {
|
---|
151 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(target, crStateGetFramebufferHWID(&cr_server.StateTracker, framebuffer));
|
---|
152 | #ifdef DEBUG_misha
|
---|
153 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
|
---|
154 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
|
---|
155 | if (GL_FRAMEBUFFER_EXT == target)
|
---|
156 | {
|
---|
157 | Assert(rfb == crStateGetFramebufferHWID(&cr_server.StateTracker, framebuffer));
|
---|
158 | Assert(dfb == crStateGetFramebufferHWID(&cr_server.StateTracker, framebuffer));
|
---|
159 | }
|
---|
160 | else if (GL_READ_FRAMEBUFFER_EXT == target)
|
---|
161 | {
|
---|
162 | Assert(rfb == crStateGetFramebufferHWID(&cr_server.StateTracker, framebuffer));
|
---|
163 | }
|
---|
164 | else if (GL_DRAW_FRAMEBUFFER_EXT == target)
|
---|
165 | {
|
---|
166 | Assert(dfb == crStateGetFramebufferHWID(&cr_server.StateTracker, framebuffer));
|
---|
167 | }
|
---|
168 | else
|
---|
169 | {
|
---|
170 | Assert(0);
|
---|
171 | }
|
---|
172 | #endif
|
---|
173 | }
|
---|
174 | }
|
---|
175 |
|
---|
176 | void SERVER_DISPATCH_APIENTRY crServerDispatchBindRenderbufferEXT(GLenum target, GLuint renderbuffer)
|
---|
177 | {
|
---|
178 | crStateBindRenderbufferEXT(&cr_server.StateTracker, target, renderbuffer);
|
---|
179 | cr_server.head_spu->dispatch_table.BindRenderbufferEXT(target, crStateGetRenderbufferHWID(&cr_server.StateTracker, renderbuffer));
|
---|
180 | }
|
---|
181 |
|
---|
182 | void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers)
|
---|
183 | {
|
---|
184 | if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
|
---|
185 | {
|
---|
186 | crError("crStateDeleteFramebuffersEXT: parameter 'n' is out of range");
|
---|
187 | return;
|
---|
188 | }
|
---|
189 |
|
---|
190 | crStateDeleteFramebuffersEXT(&cr_server.StateTracker, n, framebuffers);
|
---|
191 | }
|
---|
192 |
|
---|
193 | void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers)
|
---|
194 | {
|
---|
195 | if (n <= 0 || n >= INT32_MAX / sizeof(GLuint))
|
---|
196 | {
|
---|
197 | crError("glDeleteRenderbuffersEXT: parameter 'n' is out of range");
|
---|
198 | return;
|
---|
199 | }
|
---|
200 |
|
---|
201 | crStateDeleteRenderbuffersEXT(&cr_server.StateTracker, n, renderbuffers);
|
---|
202 | }
|
---|
203 |
|
---|
204 | void SERVER_DISPATCH_APIENTRY
|
---|
205 | crServerDispatchFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
|
---|
206 | {
|
---|
207 | crStateFramebufferRenderbufferEXT(&cr_server.StateTracker, target, attachment, renderbuffertarget, renderbuffer);
|
---|
208 | cr_server.head_spu->dispatch_table.FramebufferRenderbufferEXT(target, attachment, renderbuffertarget, crStateGetRenderbufferHWID(&cr_server.StateTracker, renderbuffer));
|
---|
209 | }
|
---|
210 |
|
---|
211 | void SERVER_DISPATCH_APIENTRY
|
---|
212 | crServerDispatchGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint * params)
|
---|
213 | {
|
---|
214 | GLint local_params[1];
|
---|
215 | (void) params;
|
---|
216 | crStateGetFramebufferAttachmentParameterivEXT(&cr_server.StateTracker, target, attachment, pname, local_params);
|
---|
217 |
|
---|
218 | crServerReturnValue(&(local_params[0]), 1*sizeof(GLint));
|
---|
219 | }
|
---|
220 |
|
---|
221 | GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsFramebufferEXT( GLuint framebuffer )
|
---|
222 | {
|
---|
223 | /* since GenFramebuffers/Renderbuffers issued to host ogl only on bind + some other ops, the host drivers may not know about them
|
---|
224 | * so use state data*/
|
---|
225 | GLboolean retval = crStateIsFramebufferEXT(&cr_server.StateTracker, framebuffer);
|
---|
226 | crServerReturnValue( &retval, sizeof(retval) );
|
---|
227 | return retval; /* WILL PROBABLY BE IGNORED */
|
---|
228 | }
|
---|
229 |
|
---|
230 | GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsRenderbufferEXT( GLuint renderbuffer )
|
---|
231 | {
|
---|
232 | /* since GenFramebuffers/Renderbuffers issued to host ogl only on bind + some other ops, the host drivers may not know about them
|
---|
233 | * so use state data*/
|
---|
234 | GLboolean retval = crStateIsRenderbufferEXT(&cr_server.StateTracker, renderbuffer);
|
---|
235 | crServerReturnValue( &retval, sizeof(retval) );
|
---|
236 | return retval; /* WILL PROBABLY BE IGNORED */
|
---|
237 | }
|
---|