VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_framebuffer.c@ 69500

Last change on this file since 69500 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

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