1 | /* $Id: server_framebuffer.c 76553 2019-01-01 01:45:53Z 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 |
|
---|
25 | void SERVER_DISPATCH_APIENTRY
|
---|
26 | crServerDispatchGenFramebuffersEXT(GLsizei n, GLuint *framebuffers)
|
---|
27 | {
|
---|
28 | GLuint *local_buffers;
|
---|
29 | (void) framebuffers;
|
---|
30 |
|
---|
31 | if (n >= INT32_MAX / sizeof(GLuint))
|
---|
32 | {
|
---|
33 | crError("crServerDispatchGenFramebuffersEXT: parameter 'n' is out of range");
|
---|
34 | return;
|
---|
35 | }
|
---|
36 |
|
---|
37 | local_buffers = (GLuint *)crCalloc(n * sizeof(*local_buffers));
|
---|
38 |
|
---|
39 | crStateGenFramebuffersEXT(n, local_buffers);
|
---|
40 |
|
---|
41 | crServerReturnValue(local_buffers, n * sizeof(*local_buffers));
|
---|
42 | crFree(local_buffers);
|
---|
43 | }
|
---|
44 |
|
---|
45 | void SERVER_DISPATCH_APIENTRY
|
---|
46 | crServerDispatchGenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers)
|
---|
47 | {
|
---|
48 | GLuint *local_buffers;
|
---|
49 | (void) renderbuffers;
|
---|
50 |
|
---|
51 | if (n >= INT32_MAX / sizeof(GLuint))
|
---|
52 | {
|
---|
53 | crError("crServerDispatchGenRenderbuffersEXT: parameter 'n' is out of range");
|
---|
54 | return;
|
---|
55 | }
|
---|
56 |
|
---|
57 | local_buffers = (GLuint *)crCalloc(n * sizeof(*local_buffers));
|
---|
58 |
|
---|
59 | crStateGenRenderbuffersEXT(n, local_buffers);
|
---|
60 |
|
---|
61 | crServerReturnValue(local_buffers, n * sizeof(*local_buffers));
|
---|
62 | crFree(local_buffers);
|
---|
63 | }
|
---|
64 |
|
---|
65 | void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
---|
66 | {
|
---|
67 | crStateFramebufferTexture1DEXT(target, attachment, textarget, texture, level);
|
---|
68 | cr_server.head_spu->dispatch_table.FramebufferTexture1DEXT(target, attachment, textarget, crStateGetTextureHWID(texture), level);
|
---|
69 | }
|
---|
70 |
|
---|
71 | void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
|
---|
72 | {
|
---|
73 | crStateFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
|
---|
74 | cr_server.head_spu->dispatch_table.FramebufferTexture2DEXT(target, attachment, textarget, crStateGetTextureHWID(texture), level);
|
---|
75 | }
|
---|
76 |
|
---|
77 | void SERVER_DISPATCH_APIENTRY crServerDispatchFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
|
---|
78 | {
|
---|
79 | crStateFramebufferTexture3DEXT(target, attachment, textarget, texture, level, zoffset);
|
---|
80 | cr_server.head_spu->dispatch_table.FramebufferTexture3DEXT(target, attachment, textarget, crStateGetTextureHWID(texture), level, zoffset);
|
---|
81 | }
|
---|
82 |
|
---|
83 | void SERVER_DISPATCH_APIENTRY crServerDispatchBindFramebufferEXT(GLenum target, GLuint framebuffer)
|
---|
84 | {
|
---|
85 | #ifdef DEBUG_misha
|
---|
86 | GLint rfb = 0, dfb = 0;
|
---|
87 | #endif
|
---|
88 | crStateBindFramebufferEXT(target, framebuffer);
|
---|
89 |
|
---|
90 | if (0==framebuffer)
|
---|
91 | {
|
---|
92 | CRContext *ctx = crStateGetCurrent();
|
---|
93 | if (ctx->buffer.drawBuffer == GL_FRONT || ctx->buffer.drawBuffer == GL_FRONT_LEFT || ctx->buffer.drawBuffer == GL_FRONT_RIGHT)
|
---|
94 | cr_server.curClient->currentMural->bFbDraw = GL_TRUE;
|
---|
95 | }
|
---|
96 |
|
---|
97 | if (0==framebuffer && crServerIsRedirectedToFBO())
|
---|
98 | {
|
---|
99 | CRMuralInfo *mural = cr_server.curClient->currentMural;
|
---|
100 | if (target == GL_FRAMEBUFFER)
|
---|
101 | {
|
---|
102 | GLuint idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
|
---|
103 | GLuint idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
|
---|
104 | if (idDrawFBO == idReadFBO)
|
---|
105 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_FRAMEBUFFER, idDrawFBO);
|
---|
106 | else
|
---|
107 | {
|
---|
108 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, idReadFBO);
|
---|
109 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, idDrawFBO);
|
---|
110 | }
|
---|
111 | }
|
---|
112 | else if (target == GL_READ_FRAMEBUFFER)
|
---|
113 | {
|
---|
114 | GLuint idReadFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer);
|
---|
115 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_READ_FRAMEBUFFER, idReadFBO);
|
---|
116 | }
|
---|
117 | else if (target == GL_DRAW_FRAMEBUFFER)
|
---|
118 | {
|
---|
119 | GLuint idDrawFBO = CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer);
|
---|
120 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, idDrawFBO);
|
---|
121 | }
|
---|
122 | else
|
---|
123 | {
|
---|
124 | crWarning("unknown target %d", target);
|
---|
125 | }
|
---|
126 | #ifdef DEBUG_misha
|
---|
127 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
|
---|
128 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
|
---|
129 | if (GL_FRAMEBUFFER_EXT == target)
|
---|
130 | {
|
---|
131 | Assert(rfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
|
---|
132 | Assert(dfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
|
---|
133 | }
|
---|
134 | else if (GL_READ_FRAMEBUFFER_EXT == target)
|
---|
135 | {
|
---|
136 | Assert(rfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurReadBuffer));
|
---|
137 | }
|
---|
138 | else if (GL_DRAW_FRAMEBUFFER_EXT == target)
|
---|
139 | {
|
---|
140 | Assert(dfb == CR_SERVER_FBO_FOR_IDX(mural, mural->iCurDrawBuffer));
|
---|
141 | }
|
---|
142 | else
|
---|
143 | {
|
---|
144 | Assert(0);
|
---|
145 | }
|
---|
146 | #endif
|
---|
147 | }
|
---|
148 | else
|
---|
149 | {
|
---|
150 | cr_server.head_spu->dispatch_table.BindFramebufferEXT(target, crStateGetFramebufferHWID(framebuffer));
|
---|
151 | #ifdef DEBUG_misha
|
---|
152 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_READ_FRAMEBUFFER_BINDING_EXT, &rfb);
|
---|
153 | cr_server.head_spu->dispatch_table.GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING_EXT, &dfb);
|
---|
154 | if (GL_FRAMEBUFFER_EXT == target)
|
---|
155 | {
|
---|
156 | Assert(rfb == crStateGetFramebufferHWID(framebuffer));
|
---|
157 | Assert(dfb == crStateGetFramebufferHWID(framebuffer));
|
---|
158 | }
|
---|
159 | else if (GL_READ_FRAMEBUFFER_EXT == target)
|
---|
160 | {
|
---|
161 | Assert(rfb == crStateGetFramebufferHWID(framebuffer));
|
---|
162 | }
|
---|
163 | else if (GL_DRAW_FRAMEBUFFER_EXT == target)
|
---|
164 | {
|
---|
165 | Assert(dfb == crStateGetFramebufferHWID(framebuffer));
|
---|
166 | }
|
---|
167 | else
|
---|
168 | {
|
---|
169 | Assert(0);
|
---|
170 | }
|
---|
171 | #endif
|
---|
172 | }
|
---|
173 | }
|
---|
174 |
|
---|
175 | void SERVER_DISPATCH_APIENTRY crServerDispatchBindRenderbufferEXT(GLenum target, GLuint renderbuffer)
|
---|
176 | {
|
---|
177 | crStateBindRenderbufferEXT(target, renderbuffer);
|
---|
178 | cr_server.head_spu->dispatch_table.BindRenderbufferEXT(target, crStateGetRenderbufferHWID(renderbuffer));
|
---|
179 | }
|
---|
180 |
|
---|
181 | void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers)
|
---|
182 | {
|
---|
183 | crStateDeleteFramebuffersEXT(n, framebuffers);
|
---|
184 | }
|
---|
185 |
|
---|
186 | void SERVER_DISPATCH_APIENTRY crServerDispatchDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers)
|
---|
187 | {
|
---|
188 | crStateDeleteRenderbuffersEXT(n, renderbuffers);
|
---|
189 | }
|
---|
190 |
|
---|
191 | void SERVER_DISPATCH_APIENTRY
|
---|
192 | crServerDispatchFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
|
---|
193 | {
|
---|
194 | crStateFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer);
|
---|
195 | cr_server.head_spu->dispatch_table.FramebufferRenderbufferEXT(target, attachment, renderbuffertarget, crStateGetRenderbufferHWID(renderbuffer));
|
---|
196 | }
|
---|
197 |
|
---|
198 | void SERVER_DISPATCH_APIENTRY
|
---|
199 | crServerDispatchGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint * params)
|
---|
200 | {
|
---|
201 | GLint local_params[1];
|
---|
202 | (void) params;
|
---|
203 | crStateGetFramebufferAttachmentParameterivEXT(target, attachment, pname, local_params);
|
---|
204 |
|
---|
205 | crServerReturnValue(&(local_params[0]), 1*sizeof(GLint));
|
---|
206 | }
|
---|
207 |
|
---|
208 | GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsFramebufferEXT( GLuint framebuffer )
|
---|
209 | {
|
---|
210 | /* since GenFramebuffers/Renderbuffers issued to host ogl only on bind + some other ops, the host drivers may not know about them
|
---|
211 | * so use state data*/
|
---|
212 | GLboolean retval = crStateIsFramebufferEXT(framebuffer);
|
---|
213 | crServerReturnValue( &retval, sizeof(retval) );
|
---|
214 | return retval; /* WILL PROBABLY BE IGNORED */
|
---|
215 | }
|
---|
216 |
|
---|
217 | GLboolean SERVER_DISPATCH_APIENTRY crServerDispatchIsRenderbufferEXT( GLuint renderbuffer )
|
---|
218 | {
|
---|
219 | /* since GenFramebuffers/Renderbuffers issued to host ogl only on bind + some other ops, the host drivers may not know about them
|
---|
220 | * so use state data*/
|
---|
221 | GLboolean retval = crStateIsRenderbufferEXT(renderbuffer);
|
---|
222 | crServerReturnValue( &retval, sizeof(retval) );
|
---|
223 | return retval; /* WILL PROBABLY BE IGNORED */
|
---|
224 | }
|
---|