xref: /aosp_15_r20/external/deqp/framework/opengl/simplereference/sglrContextWrapper.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES Utilities
3  * ------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Context wrapper that exposes sglr API as GL-compatible API.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "sglrContextWrapper.hpp"
25 #include "sglrContext.hpp"
26 
27 namespace sglr
28 {
29 
ContextWrapper(void)30 ContextWrapper::ContextWrapper(void) : m_curCtx(DE_NULL)
31 {
32 }
33 
~ContextWrapper(void)34 ContextWrapper::~ContextWrapper(void)
35 {
36 }
37 
setContext(Context * context)38 void ContextWrapper::setContext(Context *context)
39 {
40     m_curCtx = context;
41 }
42 
getCurrentContext(void) const43 Context *ContextWrapper::getCurrentContext(void) const
44 {
45     return m_curCtx;
46 }
47 
getWidth(void) const48 int ContextWrapper::getWidth(void) const
49 {
50     return m_curCtx->getWidth();
51 }
52 
getHeight(void) const53 int ContextWrapper::getHeight(void) const
54 {
55     return m_curCtx->getHeight();
56 }
57 
glViewport(int x,int y,int width,int height)58 void ContextWrapper::glViewport(int x, int y, int width, int height)
59 {
60     m_curCtx->viewport(x, y, width, height);
61 }
62 
glActiveTexture(uint32_t texture)63 void ContextWrapper::glActiveTexture(uint32_t texture)
64 {
65     m_curCtx->activeTexture(texture);
66 }
67 
glBindTexture(uint32_t target,uint32_t texture)68 void ContextWrapper::glBindTexture(uint32_t target, uint32_t texture)
69 {
70     m_curCtx->bindTexture(target, texture);
71 }
72 
glGenTextures(int numTextures,uint32_t * textures)73 void ContextWrapper::glGenTextures(int numTextures, uint32_t *textures)
74 {
75     m_curCtx->genTextures(numTextures, textures);
76 }
77 
glDeleteTextures(int numTextures,const uint32_t * textures)78 void ContextWrapper::glDeleteTextures(int numTextures, const uint32_t *textures)
79 {
80     m_curCtx->deleteTextures(numTextures, textures);
81 }
82 
glBindFramebuffer(uint32_t target,uint32_t framebuffer)83 void ContextWrapper::glBindFramebuffer(uint32_t target, uint32_t framebuffer)
84 {
85     m_curCtx->bindFramebuffer(target, framebuffer);
86 }
87 
glGenFramebuffers(int numFramebuffers,uint32_t * framebuffers)88 void ContextWrapper::glGenFramebuffers(int numFramebuffers, uint32_t *framebuffers)
89 {
90     m_curCtx->genFramebuffers(numFramebuffers, framebuffers);
91 }
92 
glDeleteFramebuffers(int numFramebuffers,const uint32_t * framebuffers)93 void ContextWrapper::glDeleteFramebuffers(int numFramebuffers, const uint32_t *framebuffers)
94 {
95     m_curCtx->deleteFramebuffers(numFramebuffers, framebuffers);
96 }
97 
glBindRenderbuffer(uint32_t target,uint32_t renderbuffer)98 void ContextWrapper::glBindRenderbuffer(uint32_t target, uint32_t renderbuffer)
99 {
100     m_curCtx->bindRenderbuffer(target, renderbuffer);
101 }
102 
glGenRenderbuffers(int numRenderbuffers,uint32_t * renderbuffers)103 void ContextWrapper::glGenRenderbuffers(int numRenderbuffers, uint32_t *renderbuffers)
104 {
105     m_curCtx->genRenderbuffers(numRenderbuffers, renderbuffers);
106 }
107 
glDeleteRenderbuffers(int numRenderbuffers,const uint32_t * renderbuffers)108 void ContextWrapper::glDeleteRenderbuffers(int numRenderbuffers, const uint32_t *renderbuffers)
109 {
110     m_curCtx->deleteRenderbuffers(numRenderbuffers, renderbuffers);
111 }
112 
glPixelStorei(uint32_t pname,int param)113 void ContextWrapper::glPixelStorei(uint32_t pname, int param)
114 {
115     m_curCtx->pixelStorei(pname, param);
116 }
117 
glTexImage1D(uint32_t target,int level,int internalFormat,int width,int border,uint32_t format,uint32_t type,const void * data)118 void ContextWrapper::glTexImage1D(uint32_t target, int level, int internalFormat, int width, int border,
119                                   uint32_t format, uint32_t type, const void *data)
120 {
121     m_curCtx->texImage1D(target, level, (uint32_t)internalFormat, width, border, format, type, data);
122 }
123 
glTexImage2D(uint32_t target,int level,int internalFormat,int width,int height,int border,uint32_t format,uint32_t type,const void * data)124 void ContextWrapper::glTexImage2D(uint32_t target, int level, int internalFormat, int width, int height, int border,
125                                   uint32_t format, uint32_t type, const void *data)
126 {
127     m_curCtx->texImage2D(target, level, (uint32_t)internalFormat, width, height, border, format, type, data);
128 }
129 
glTexImage3D(uint32_t target,int level,int internalFormat,int width,int height,int depth,int border,uint32_t format,uint32_t type,const void * data)130 void ContextWrapper::glTexImage3D(uint32_t target, int level, int internalFormat, int width, int height, int depth,
131                                   int border, uint32_t format, uint32_t type, const void *data)
132 {
133     m_curCtx->texImage3D(target, level, (uint32_t)internalFormat, width, height, depth, border, format, type, data);
134 }
135 
glTexSubImage1D(uint32_t target,int level,int xoffset,int width,uint32_t format,uint32_t type,const void * data)136 void ContextWrapper::glTexSubImage1D(uint32_t target, int level, int xoffset, int width, uint32_t format, uint32_t type,
137                                      const void *data)
138 {
139     m_curCtx->texSubImage1D(target, level, xoffset, width, format, type, data);
140 }
141 
glTexSubImage2D(uint32_t target,int level,int xoffset,int yoffset,int width,int height,uint32_t format,uint32_t type,const void * data)142 void ContextWrapper::glTexSubImage2D(uint32_t target, int level, int xoffset, int yoffset, int width, int height,
143                                      uint32_t format, uint32_t type, const void *data)
144 {
145     m_curCtx->texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, data);
146 }
147 
glTexSubImage3D(uint32_t target,int level,int xoffset,int yoffset,int zoffset,int width,int height,int depth,uint32_t format,uint32_t type,const void * data)148 void ContextWrapper::glTexSubImage3D(uint32_t target, int level, int xoffset, int yoffset, int zoffset, int width,
149                                      int height, int depth, uint32_t format, uint32_t type, const void *data)
150 {
151     m_curCtx->texSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data);
152 }
153 
glCopyTexImage1D(uint32_t target,int level,uint32_t internalFormat,int x,int y,int width,int border)154 void ContextWrapper::glCopyTexImage1D(uint32_t target, int level, uint32_t internalFormat, int x, int y, int width,
155                                       int border)
156 {
157     m_curCtx->copyTexImage1D(target, level, internalFormat, x, y, width, border);
158 }
159 
glCopyTexImage2D(uint32_t target,int level,uint32_t internalFormat,int x,int y,int width,int height,int border)160 void ContextWrapper::glCopyTexImage2D(uint32_t target, int level, uint32_t internalFormat, int x, int y, int width,
161                                       int height, int border)
162 {
163     m_curCtx->copyTexImage2D(target, level, internalFormat, x, y, width, height, border);
164 }
165 
glCopyTexSubImage1D(uint32_t target,int level,int xoffset,int x,int y,int width)166 void ContextWrapper::glCopyTexSubImage1D(uint32_t target, int level, int xoffset, int x, int y, int width)
167 {
168     m_curCtx->copyTexSubImage1D(target, level, xoffset, x, y, width);
169 }
170 
glCopyTexSubImage2D(uint32_t target,int level,int xoffset,int yoffset,int x,int y,int width,int height)171 void ContextWrapper::glCopyTexSubImage2D(uint32_t target, int level, int xoffset, int yoffset, int x, int y, int width,
172                                          int height)
173 {
174     m_curCtx->copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
175 }
176 
glTexStorage2D(uint32_t target,int levels,uint32_t internalFormat,int width,int height)177 void ContextWrapper::glTexStorage2D(uint32_t target, int levels, uint32_t internalFormat, int width, int height)
178 {
179     m_curCtx->texStorage2D(target, levels, internalFormat, width, height);
180 }
181 
glTexStorage3D(uint32_t target,int levels,uint32_t internalFormat,int width,int height,int depth)182 void ContextWrapper::glTexStorage3D(uint32_t target, int levels, uint32_t internalFormat, int width, int height,
183                                     int depth)
184 {
185     m_curCtx->texStorage3D(target, levels, internalFormat, width, height, depth);
186 }
187 
glTexParameteri(uint32_t target,uint32_t pname,int value)188 void ContextWrapper::glTexParameteri(uint32_t target, uint32_t pname, int value)
189 {
190     m_curCtx->texParameteri(target, pname, value);
191 }
192 
glUseProgram(uint32_t program)193 void ContextWrapper::glUseProgram(uint32_t program)
194 {
195     m_curCtx->useProgram(program);
196 }
197 
glFramebufferTexture2D(uint32_t target,uint32_t attachment,uint32_t textarget,uint32_t texture,int level)198 void ContextWrapper::glFramebufferTexture2D(uint32_t target, uint32_t attachment, uint32_t textarget, uint32_t texture,
199                                             int level)
200 {
201     m_curCtx->framebufferTexture2D(target, attachment, textarget, texture, level);
202 }
203 
glFramebufferTextureLayer(uint32_t target,uint32_t attachment,uint32_t texture,int level,int layer)204 void ContextWrapper::glFramebufferTextureLayer(uint32_t target, uint32_t attachment, uint32_t texture, int level,
205                                                int layer)
206 {
207     m_curCtx->framebufferTextureLayer(target, attachment, texture, level, layer);
208 }
209 
glFramebufferRenderbuffer(uint32_t target,uint32_t attachment,uint32_t renderbuffertarget,uint32_t renderbuffer)210 void ContextWrapper::glFramebufferRenderbuffer(uint32_t target, uint32_t attachment, uint32_t renderbuffertarget,
211                                                uint32_t renderbuffer)
212 {
213     m_curCtx->framebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
214 }
215 
glCheckFramebufferStatus(uint32_t target)216 uint32_t ContextWrapper::glCheckFramebufferStatus(uint32_t target)
217 {
218     return m_curCtx->checkFramebufferStatus(target);
219 }
220 
glGetFramebufferAttachmentParameteriv(uint32_t target,uint32_t attachment,uint32_t pname,int * params)221 void ContextWrapper::glGetFramebufferAttachmentParameteriv(uint32_t target, uint32_t attachment, uint32_t pname,
222                                                            int *params)
223 {
224     m_curCtx->getFramebufferAttachmentParameteriv(target, attachment, pname, params);
225 }
226 
glRenderbufferStorage(uint32_t target,uint32_t internalformat,int width,int height)227 void ContextWrapper::glRenderbufferStorage(uint32_t target, uint32_t internalformat, int width, int height)
228 {
229     m_curCtx->renderbufferStorage(target, internalformat, width, height);
230 }
231 
glRenderbufferStorageMultisample(uint32_t target,int samples,uint32_t internalformat,int width,int height)232 void ContextWrapper::glRenderbufferStorageMultisample(uint32_t target, int samples, uint32_t internalformat, int width,
233                                                       int height)
234 {
235     m_curCtx->renderbufferStorageMultisample(target, samples, internalformat, width, height);
236 }
237 
glBindBuffer(uint32_t target,uint32_t buffer)238 void ContextWrapper::glBindBuffer(uint32_t target, uint32_t buffer)
239 {
240     m_curCtx->bindBuffer(target, buffer);
241 }
242 
glGenBuffers(int n,uint32_t * buffers)243 void ContextWrapper::glGenBuffers(int n, uint32_t *buffers)
244 {
245     m_curCtx->genBuffers(n, buffers);
246 }
247 
glDeleteBuffers(int n,const uint32_t * buffers)248 void ContextWrapper::glDeleteBuffers(int n, const uint32_t *buffers)
249 {
250     m_curCtx->deleteBuffers(n, buffers);
251 }
252 
glBufferData(uint32_t target,intptr_t size,const void * data,uint32_t usage)253 void ContextWrapper::glBufferData(uint32_t target, intptr_t size, const void *data, uint32_t usage)
254 {
255     m_curCtx->bufferData(target, size, data, usage);
256 }
257 
glBufferSubData(uint32_t target,intptr_t offset,intptr_t size,const void * data)258 void ContextWrapper::glBufferSubData(uint32_t target, intptr_t offset, intptr_t size, const void *data)
259 {
260     m_curCtx->bufferSubData(target, offset, size, data);
261 }
262 
glClearColor(float red,float green,float blue,float alpha)263 void ContextWrapper::glClearColor(float red, float green, float blue, float alpha)
264 {
265     m_curCtx->clearColor(red, green, blue, alpha);
266 }
267 
glClearDepthf(float depth)268 void ContextWrapper::glClearDepthf(float depth)
269 {
270     m_curCtx->clearDepthf(depth);
271 }
272 
glClearStencil(int stencil)273 void ContextWrapper::glClearStencil(int stencil)
274 {
275     m_curCtx->clearStencil(stencil);
276 }
277 
glClear(uint32_t buffers)278 void ContextWrapper::glClear(uint32_t buffers)
279 {
280     m_curCtx->clear(buffers);
281 }
282 
glClearBufferiv(uint32_t buffer,int drawbuffer,const int * value)283 void ContextWrapper::glClearBufferiv(uint32_t buffer, int drawbuffer, const int *value)
284 {
285     m_curCtx->clearBufferiv(buffer, drawbuffer, value);
286 }
287 
glClearBufferfv(uint32_t buffer,int drawbuffer,const float * value)288 void ContextWrapper::glClearBufferfv(uint32_t buffer, int drawbuffer, const float *value)
289 {
290     m_curCtx->clearBufferfv(buffer, drawbuffer, value);
291 }
292 
glClearBufferuiv(uint32_t buffer,int drawbuffer,const uint32_t * value)293 void ContextWrapper::glClearBufferuiv(uint32_t buffer, int drawbuffer, const uint32_t *value)
294 {
295     m_curCtx->clearBufferuiv(buffer, drawbuffer, value);
296 }
297 
glClearBufferfi(uint32_t buffer,int drawbuffer,float depth,int stencil)298 void ContextWrapper::glClearBufferfi(uint32_t buffer, int drawbuffer, float depth, int stencil)
299 {
300     m_curCtx->clearBufferfi(buffer, drawbuffer, depth, stencil);
301 }
302 
glScissor(int x,int y,int width,int height)303 void ContextWrapper::glScissor(int x, int y, int width, int height)
304 {
305     m_curCtx->scissor(x, y, width, height);
306 }
307 
glEnable(uint32_t cap)308 void ContextWrapper::glEnable(uint32_t cap)
309 {
310     m_curCtx->enable(cap);
311 }
312 
glDisable(uint32_t cap)313 void ContextWrapper::glDisable(uint32_t cap)
314 {
315     m_curCtx->disable(cap);
316 }
317 
glStencilFunc(uint32_t func,int ref,uint32_t mask)318 void ContextWrapper::glStencilFunc(uint32_t func, int ref, uint32_t mask)
319 {
320     m_curCtx->stencilFunc(func, ref, mask);
321 }
322 
glStencilOp(uint32_t sfail,uint32_t dpfail,uint32_t dppass)323 void ContextWrapper::glStencilOp(uint32_t sfail, uint32_t dpfail, uint32_t dppass)
324 {
325     m_curCtx->stencilOp(sfail, dpfail, dppass);
326 }
327 
glDepthFunc(uint32_t func)328 void ContextWrapper::glDepthFunc(uint32_t func)
329 {
330     m_curCtx->depthFunc(func);
331 }
332 
glBlendEquation(uint32_t mode)333 void ContextWrapper::glBlendEquation(uint32_t mode)
334 {
335     m_curCtx->blendEquation(mode);
336 }
337 
glBlendEquationSeparate(uint32_t modeRGB,uint32_t modeAlpha)338 void ContextWrapper::glBlendEquationSeparate(uint32_t modeRGB, uint32_t modeAlpha)
339 {
340     m_curCtx->blendEquationSeparate(modeRGB, modeAlpha);
341 }
342 
glBlendFunc(uint32_t src,uint32_t dst)343 void ContextWrapper::glBlendFunc(uint32_t src, uint32_t dst)
344 {
345     m_curCtx->blendFunc(src, dst);
346 }
347 
glBlendFuncSeparate(uint32_t srcRGB,uint32_t dstRGB,uint32_t srcAlpha,uint32_t dstAlpha)348 void ContextWrapper::glBlendFuncSeparate(uint32_t srcRGB, uint32_t dstRGB, uint32_t srcAlpha, uint32_t dstAlpha)
349 {
350     m_curCtx->blendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
351 }
352 
glBlendColor(float red,float green,float blue,float alpha)353 void ContextWrapper::glBlendColor(float red, float green, float blue, float alpha)
354 {
355     m_curCtx->blendColor(red, green, blue, alpha);
356 }
357 
glColorMask(bool r,bool g,bool b,bool a)358 void ContextWrapper::glColorMask(bool r, bool g, bool b, bool a)
359 {
360     m_curCtx->colorMask(r, g, b, a);
361 }
362 
glDepthMask(bool mask)363 void ContextWrapper::glDepthMask(bool mask)
364 {
365     m_curCtx->depthMask(mask);
366 }
367 
glStencilMask(uint32_t mask)368 void ContextWrapper::glStencilMask(uint32_t mask)
369 {
370     m_curCtx->stencilMask(mask);
371 }
372 
glBlitFramebuffer(int srcX0,int srcY0,int srcX1,int srcY1,int dstX0,int dstY0,int dstX1,int dstY1,uint32_t mask,uint32_t filter)373 void ContextWrapper::glBlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1,
374                                        int dstY1, uint32_t mask, uint32_t filter)
375 {
376     m_curCtx->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
377 }
378 
glInvalidateSubFramebuffer(uint32_t target,int numAttachments,const uint32_t * attachments,int x,int y,int width,int height)379 void ContextWrapper::glInvalidateSubFramebuffer(uint32_t target, int numAttachments, const uint32_t *attachments, int x,
380                                                 int y, int width, int height)
381 {
382     m_curCtx->invalidateSubFramebuffer(target, numAttachments, attachments, x, y, width, height);
383 }
384 
glInvalidateFramebuffer(uint32_t target,int numAttachments,const uint32_t * attachments)385 void ContextWrapper::glInvalidateFramebuffer(uint32_t target, int numAttachments, const uint32_t *attachments)
386 {
387     m_curCtx->invalidateFramebuffer(target, numAttachments, attachments);
388 }
389 
glReadPixels(int x,int y,int width,int height,uint32_t format,uint32_t type,void * data)390 void ContextWrapper::glReadPixels(int x, int y, int width, int height, uint32_t format, uint32_t type, void *data)
391 {
392     m_curCtx->readPixels(x, y, width, height, format, type, data);
393 }
394 
glGetError(void)395 uint32_t ContextWrapper::glGetError(void)
396 {
397     return m_curCtx->getError();
398 }
399 
glGetIntegerv(uint32_t pname,int * params)400 void ContextWrapper::glGetIntegerv(uint32_t pname, int *params)
401 {
402     m_curCtx->getIntegerv(pname, params);
403 }
404 
405 } // namespace sglr
406