2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <GLES3/gl3.h>
23 // Flag to be set when we want shader compilation fail
24 bool gDirectRenderingFailCreateShader = false;
26 // Flag to be set when we want program linking fail
27 bool gDirectRenderingFailCreateProgram = false;
30 * To test the multithreaded variant we need override EGL api
32 * The Direct Rendering uses GL directly and it's needed to override certain funtions in order
33 * to force code execution.
35 EGLContext eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list)
37 return EGLContext(0x12345678);
40 EGLBoolean eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config)
42 static EGLConfig config;
55 GLuint glCreateProgram (void)
57 static uint32_t programId = 1;
61 GLuint glCreateShader(GLenum type)
63 static uint32_t shaderId = 1;
67 void glCompileShader(GLuint shader)
71 void glLinkProgram (GLuint program)
75 void glGenTextures(GLsizei n, GLuint *textures)
77 static GLuint texId = 1u;
78 for(auto i = 0; i < n; ++i)
80 textures[i] = texId++;
84 void glGetShaderiv(GLuint shader, GLenum pname, GLint *params)
86 if(pname == GL_COMPILE_STATUS)
88 params[0] = gDirectRenderingFailCreateShader ? GL_FALSE : GL_TRUE;
90 else if(pname == GL_INFO_LOG_LENGTH)
96 void glGetProgramiv(GLuint shader, GLenum pname, GLint *params)
98 if(pname == GL_LINK_STATUS)
100 params[0] = gDirectRenderingFailCreateProgram ? GL_FALSE : GL_TRUE;
102 else if(pname == GL_INFO_LOG_LENGTH)
108 void glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog)
114 void glGetProgramInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog)
120 void glDeleteSync (GLsync sync)
124 GLenum glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout)
126 return GL_CONDITION_SATISFIED;
129 GLsync glFenceSync (GLenum condition, GLbitfield flags)
131 static uint32_t syncId = 0;
132 return reinterpret_cast<GLsync>(++syncId);
135 GLenum glCheckFramebufferStatus (GLenum target)
137 return GL_FRAMEBUFFER_COMPLETE;