[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles / gles3-implementation.h
1 #ifndef DALI_INTERNAL_GLES3_IMPLEMENTATION_H
2 #define DALI_INTERNAL_GLES3_IMPLEMENTATION_H
3
4 /*
5  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
21 // EXTERNAL INCLUDES
22 #include <GLES3/gl3.h>
23 #include <GLES3/gl32.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/internal/graphics/gles/gles-abstraction.h>
27
28 namespace Dali
29 {
30 namespace Internal
31 {
32 namespace Adaptor
33 {
34 class Gles3Implementation : public GlesAbstraction
35 {
36 public:
37   Gles3Implementation()
38   {
39   }
40
41   ~Gles3Implementation() override
42   {
43   }
44
45   void ReadBuffer(GLenum mode) override
46   {
47     glReadBuffer(mode);
48   }
49
50   void DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid* indices) override
51   {
52     glDrawRangeElements(mode, start, end, count, type, indices);
53   }
54
55   void TexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels) override
56   {
57     glTexImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels);
58   }
59
60   void TexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels) override
61   {
62     glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
63   }
64
65   void CopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height) override
66   {
67     glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
68   }
69
70   void CompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data) override
71   {
72     glCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, data);
73   }
74
75   void CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data) override
76   {
77     glCompressedTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
78   }
79
80   void GenQueries(GLsizei n, GLuint* ids) override
81   {
82     glGenQueries(n, ids);
83   }
84
85   void DeleteQueries(GLsizei n, const GLuint* ids) override
86   {
87     glDeleteQueries(n, ids);
88   }
89
90   GLboolean IsQuery(GLuint id) override
91   {
92     return glIsQuery(id);
93   }
94
95   void BeginQuery(GLenum target, GLuint id) override
96   {
97     glBeginQuery(target, id);
98   }
99
100   void EndQuery(GLenum target) override
101   {
102     glEndQuery(target);
103   }
104
105   void GetQueryiv(GLenum target, GLenum pname, GLint* params) override
106   {
107     glGetQueryiv(target, pname, params);
108   }
109
110   void GetQueryObjectuiv(GLuint id, GLenum pname, GLuint* params) override
111   {
112     glGetQueryObjectuiv(id, pname, params);
113   }
114
115   GLboolean UnmapBuffer(GLenum target) override
116   {
117     return glUnmapBuffer(target);
118   }
119
120   void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) override
121   {
122     glGetBufferPointerv(target, pname, params);
123   }
124
125   void DrawBuffers(GLsizei n, const GLenum* bufs) override
126   {
127     glDrawBuffers(n, bufs);
128   }
129
130   void UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
131   {
132     glUniformMatrix2x3fv(location, count, transpose, value);
133   }
134
135   void UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
136   {
137     glUniformMatrix3x2fv(location, count, transpose, value);
138   }
139
140   void UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
141   {
142     glUniformMatrix2x4fv(location, count, transpose, value);
143   }
144
145   void UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
146   {
147     glUniformMatrix4x2fv(location, count, transpose, value);
148   }
149
150   void UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
151   {
152     glUniformMatrix3x4fv(location, count, transpose, value);
153   }
154
155   void UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override
156   {
157     glUniformMatrix4x3fv(location, count, transpose, value);
158   }
159
160   void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) override
161   {
162     glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
163   }
164
165   void RenderbufferStorageMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) override
166   {
167     // @note even gles 3.0 support glRenderbufferStorageMultisample, We cannot use that API with FramebufferTexture2DMultisampleEXT cause vendor issue.
168     // Since dali only use RenderbufferStorageMultisample API for FBO MSAA, just keep to use extension API.
169     mGlExtensions.RenderbufferStorageMultisampleEXT(target, samples, internalformat, width, height);
170   }
171
172   void FramebufferTexture2DMultisample(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) override
173   {
174     mGlExtensions.FramebufferTexture2DMultisampleEXT(target, attachment, textarget, texture, level, samples);
175   }
176
177   void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) override
178   {
179     glFramebufferTextureLayer(target, attachment, texture, level, layer);
180   }
181
182   GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) override
183   {
184     return glMapBufferRange(target, offset, length, access);
185   }
186
187   void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) override
188   {
189     glFlushMappedBufferRange(target, offset, length);
190   }
191
192   void BindVertexArray(GLuint array) override
193   {
194     glBindVertexArray(array);
195   }
196
197   void DeleteVertexArrays(GLsizei n, const GLuint* arrays) override
198   {
199     glDeleteVertexArrays(n, arrays);
200   }
201
202   void GenVertexArrays(GLsizei n, GLuint* arrays) override
203   {
204     glGenVertexArrays(n, arrays);
205   }
206
207   GLboolean IsVertexArray(GLuint array) override
208   {
209     return glIsVertexArray(array);
210   }
211
212   void GetIntegeri_v(GLenum target, GLuint index, GLint* data) override
213   {
214     glGetIntegeri_v(target, index, data);
215   }
216
217   void BeginTransformFeedback(GLenum primitiveMode) override
218   {
219     glBeginTransformFeedback(primitiveMode);
220   }
221
222   void EndTransformFeedback(void) override
223   {
224     glEndTransformFeedback();
225   }
226
227   void BindBufferRange(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size) override
228   {
229     glBindBufferRange(target, index, buffer, offset, size);
230   }
231
232   void BindBufferBase(GLenum target, GLuint index, GLuint buffer) override
233   {
234     glBindBufferBase(target, index, buffer);
235   }
236
237   void TransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar* const* varyings, GLenum bufferMode) override
238   {
239     glTransformFeedbackVaryings(program, count, varyings, bufferMode);
240   }
241
242   void GetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei* length, GLsizei* size, GLenum* type, GLchar* name) override
243   {
244     glGetTransformFeedbackVarying(program, index, bufSize, length, size, type, name);
245   }
246
247   void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) override
248   {
249     glVertexAttribIPointer(index, size, type, stride, pointer);
250   }
251
252   void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) override
253   {
254     glGetVertexAttribIiv(index, pname, params);
255   }
256
257   void GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint* params) override
258   {
259     glGetVertexAttribIuiv(index, pname, params);
260   }
261
262   void VertexAttribI4i(GLuint index, GLint x, GLint y, GLint z, GLint w) override
263   {
264     glVertexAttribI4i(index, x, y, z, w);
265   }
266
267   void VertexAttribI4ui(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w) override
268   {
269     glVertexAttribI4ui(index, x, y, z, w);
270   }
271
272   void VertexAttribI4iv(GLuint index, const GLint* v) override
273   {
274     glVertexAttribI4iv(index, v);
275   }
276
277   void VertexAttribI4uiv(GLuint index, const GLuint* v) override
278   {
279     glVertexAttribI4uiv(index, v);
280   }
281
282   void GetUniformuiv(GLuint program, GLint location, GLuint* params) override
283   {
284     glGetUniformuiv(program, location, params);
285   }
286
287   GLint GetFragDataLocation(GLuint program, const GLchar* name) override
288   {
289     return glGetFragDataLocation(program, name);
290   }
291
292   void Uniform1ui(GLint location, GLuint v0) override
293   {
294     glUniform1ui(location, v0);
295   }
296
297   void Uniform2ui(GLint location, GLuint v0, GLuint v1) override
298   {
299     glUniform2ui(location, v0, v1);
300   }
301
302   void Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) override
303   {
304     glUniform3ui(location, v0, v1, v2);
305   }
306
307   void Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) override
308   {
309     glUniform4ui(location, v0, v1, v2, v3);
310   }
311
312   void Uniform1uiv(GLint location, GLsizei count, const GLuint* value) override
313   {
314     glUniform1uiv(location, count, value);
315   }
316
317   void Uniform2uiv(GLint location, GLsizei count, const GLuint* value) override
318   {
319     glUniform2uiv(location, count, value);
320   }
321
322   void Uniform3uiv(GLint location, GLsizei count, const GLuint* value) override
323   {
324     glUniform3uiv(location, count, value);
325   }
326
327   void Uniform4uiv(GLint location, GLsizei count, const GLuint* value) override
328   {
329     glUniform4uiv(location, count, value);
330   }
331
332   void ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint* value) override
333   {
334     glClearBufferiv(buffer, drawbuffer, value);
335   }
336
337   void ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint* value) override
338   {
339     glClearBufferuiv(buffer, drawbuffer, value);
340   }
341
342   void ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat* value) override
343   {
344     glClearBufferfv(buffer, drawbuffer, value);
345   }
346
347   void ClearBufferfi(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil) override
348   {
349     glClearBufferfi(buffer, drawbuffer, depth, stencil);
350   }
351
352   const GLubyte* GetStringi(GLenum name, GLuint index) override
353   {
354     return glGetStringi(name, index);
355   }
356
357   void CopyBufferSubData(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size) override
358   {
359     glCopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
360   }
361
362   void GetUniformIndices(GLuint program, GLsizei uniformCount, const GLchar* const* uniformNames, GLuint* uniformIndices) override
363   {
364     glGetUniformIndices(program, uniformCount, uniformNames, uniformIndices);
365   }
366
367   void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) override
368   {
369     glGetActiveUniformsiv(program, uniformCount, uniformIndices, pname, params);
370   }
371
372   GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) override
373   {
374     return glGetUniformBlockIndex(program, uniformBlockName);
375   }
376
377   void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params) override
378   {
379     glGetActiveUniformBlockiv(program, uniformBlockIndex, pname, params);
380   }
381
382   void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName) override
383   {
384     glGetActiveUniformBlockName(program, uniformBlockIndex, bufSize, length, uniformBlockName);
385   }
386
387   void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) override
388   {
389     glUniformBlockBinding(program, uniformBlockIndex, uniformBlockBinding);
390   }
391
392   void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) override
393   {
394     glDrawArraysInstanced(mode, first, count, instanceCount);
395   }
396
397   void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) override
398   {
399     glDrawElementsInstanced(mode, count, type, indices, instanceCount);
400   }
401
402   GLsync FenceSync(GLenum condition, GLbitfield flags) override
403   {
404     return glFenceSync(condition, flags);
405   }
406
407   GLboolean IsSync(GLsync sync) override
408   {
409     return glIsSync(sync);
410   }
411
412   void DeleteSync(GLsync sync) override
413   {
414     glDeleteSync(sync);
415   }
416
417   GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
418   {
419     return glClientWaitSync(sync, flags, timeout);
420   }
421
422   void WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) override
423   {
424     glWaitSync(sync, flags, timeout);
425   }
426
427   void GetInteger64v(GLenum pname, GLint64* params) override
428   {
429     glGetInteger64v(pname, params);
430   }
431
432   void GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* length, GLint* values) override
433   {
434     glGetSynciv(sync, pname, bufSize, length, values);
435   }
436
437   void GetInteger64i_v(GLenum target, GLuint index, GLint64* data) override
438   {
439     glGetInteger64i_v(target, index, data);
440   }
441
442   void GetBufferParameteri64v(GLenum target, GLenum pname, GLint64* params) override
443   {
444     glGetBufferParameteri64v(target, pname, params);
445   }
446
447   void GenSamplers(GLsizei count, GLuint* samplers) override
448   {
449     glGenSamplers(count, samplers);
450   }
451
452   void DeleteSamplers(GLsizei count, const GLuint* samplers) override
453   {
454     glDeleteSamplers(count, samplers);
455   }
456
457   GLboolean IsSampler(GLuint sampler) override
458   {
459     return glIsSampler(sampler);
460   }
461
462   void BindSampler(GLuint unit, GLuint sampler) override
463   {
464     glBindSampler(unit, sampler);
465   }
466
467   void SamplerParameteri(GLuint sampler, GLenum pname, GLint param) override
468   {
469     glSamplerParameteri(sampler, pname, param);
470   }
471
472   void SamplerParameteriv(GLuint sampler, GLenum pname, const GLint* param) override
473   {
474     glSamplerParameteriv(sampler, pname, param);
475   }
476
477   void SamplerParameterf(GLuint sampler, GLenum pname, GLfloat param) override
478   {
479     glSamplerParameterf(sampler, pname, param);
480   }
481
482   void SamplerParameterfv(GLuint sampler, GLenum pname, const GLfloat* param) override
483   {
484     glSamplerParameterfv(sampler, pname, param);
485   }
486
487   void GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint* params) override
488   {
489     glGetSamplerParameteriv(sampler, pname, params);
490   }
491
492   void GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat* params) override
493   {
494     glGetSamplerParameterfv(sampler, pname, params);
495   }
496
497   void VertexAttribDivisor(GLuint index, GLuint divisor) override
498   {
499     glVertexAttribDivisor(index, divisor);
500   }
501
502   void BindTransformFeedback(GLenum target, GLuint id) override
503   {
504     glBindTransformFeedback(target, id);
505   }
506
507   void DeleteTransformFeedbacks(GLsizei n, const GLuint* ids) override
508   {
509     glDeleteTransformFeedbacks(n, ids);
510   }
511
512   void GenTransformFeedbacks(GLsizei n, GLuint* ids) override
513   {
514     glGenTransformFeedbacks(n, ids);
515   }
516
517   GLboolean IsTransformFeedback(GLuint id) override
518   {
519     return glIsTransformFeedback(id);
520   }
521
522   void PauseTransformFeedback(void) override
523   {
524     glPauseTransformFeedback();
525   }
526
527   void ResumeTransformFeedback(void) override
528   {
529     glResumeTransformFeedback();
530   }
531
532   void GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei* length, GLenum* binaryFormat, GLvoid* binary) override
533   {
534     glGetProgramBinary(program, bufSize, length, binaryFormat, binary);
535   }
536
537   void ProgramBinary(GLuint program, GLenum binaryFormat, const GLvoid* binary, GLsizei length) override
538   {
539     glProgramBinary(program, binaryFormat, binary, length);
540   }
541
542   void ProgramParameteri(GLuint program, GLenum pname, GLint value) override
543   {
544     glProgramParameteri(program, pname, value);
545   }
546
547   void InvalidateFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments) override
548   {
549     glInvalidateFramebuffer(target, numAttachments, attachments);
550   }
551
552   void InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments, const GLenum* attachments, GLint x, GLint y, GLsizei width, GLsizei height) override
553   {
554     glInvalidateSubFramebuffer(target, numAttachments, attachments, x, y, width, height);
555   }
556
557   void TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) override
558   {
559     glTexStorage2D(target, levels, internalformat, width, height);
560   }
561
562   void TexStorage3D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) override
563   {
564     glTexStorage3D(target, levels, internalformat, width, height, depth);
565   }
566
567   void GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint* params) override
568   {
569     glGetInternalformativ(target, internalformat, pname, bufSize, params);
570   }
571
572   void BlendBarrier(void) override
573   {
574     if(!mGlExtensions.BlendBarrierKHR())
575     {
576       glBlendBarrier();
577     }
578   }
579
580 private:
581   GlExtensions mGlExtensions;
582 };
583
584 } // namespace Adaptor
585
586 } // namespace Internal
587
588 } // namespace Dali
589
590 #endif // DALI_INTERNAL_GLES3_IMPLEMENTATION_H