2 * Copyright (c) 2023 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>
22 // Flag to be set when we want shader compilation fail
23 bool gDirectRenderingFailCreateShader = false;
25 // Flag to be set when we want program linking fail
26 bool gDirectRenderingFailCreateProgram = false;
29 * To test the multithreaded variant we need override EGL api
31 * The Direct Rendering uses GL directly and it's needed to override certain funtions in order
32 * to force code execution.
34 EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint* attrib_list)
36 return EGLContext(0x12345678);
39 EGLBoolean eglGetConfigs(EGLDisplay dpy, EGLConfig* configs, EGLint config_size, EGLint* num_config)
41 static EGLConfig config;
54 GLuint glCreateProgram(void)
56 static uint32_t programId = 1;
60 GLuint glCreateShader(GLenum type)
62 static uint32_t shaderId = 1;
66 void glCompileShader(GLuint shader)
70 void glLinkProgram(GLuint program)
74 void glGenTextures(GLsizei n, GLuint* textures)
76 static GLuint texId = 1u;
77 for(auto i = 0; i < n; ++i)
79 textures[i] = texId++;
83 void glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
85 if(pname == GL_COMPILE_STATUS)
87 params[0] = gDirectRenderingFailCreateShader ? GL_FALSE : GL_TRUE;
89 else if(pname == GL_INFO_LOG_LENGTH)
95 void glGetProgramiv(GLuint shader, GLenum pname, GLint* params)
97 if(pname == GL_LINK_STATUS)
99 params[0] = gDirectRenderingFailCreateProgram ? GL_FALSE : GL_TRUE;
101 else if(pname == GL_INFO_LOG_LENGTH)
107 void glGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog)
113 void glGetProgramInfoLog(GLuint shader, GLsizei bufSize, GLsizei* length, GLchar* infoLog)
119 void glDeleteSync(GLsync sync)
123 GLenum glClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
125 return GL_CONDITION_SATISFIED;
128 GLsync glFenceSync(GLenum condition, GLbitfield flags)
130 static uint32_t syncId = 0;
131 return reinterpret_cast<GLsync>(++syncId);
134 GLenum glCheckFramebufferStatus(GLenum target)
136 return GL_FRAMEBUFFER_COMPLETE;