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.
18 #include "test-gl-abstraction.h"
19 #include "test-trace-call-stack.h"
21 static const bool TRACE{
26 TestGlAbstraction::TestGlAbstraction()
27 : mBufferTrace(TRACE, std::string("gl")),
28 mCullFaceTrace(TRACE, "gl"),
29 mEnableDisableTrace(TRACE, "gl"),
30 mShaderTrace(TRACE, "gl"),
31 mTextureTrace(TRACE, std::string("gl")),
32 mTexParameterTrace(TRACE, "gl"),
33 mDrawTrace(TRACE, "gl"),
34 mDepthFunctionTrace(TRACE, "gl"),
35 mStencilFunctionTrace(TRACE, "gl"),
36 mScissorTrace(TRACE, "gl"),
37 mSetUniformTrace(TRACE, "Uniform "),
38 mViewportTrace(TRACE, "gl")
43 TestGlAbstraction::~TestGlAbstraction()
47 void TestGlAbstraction::Initialize()
50 mCompileStatus = GL_TRUE;
51 mLinkStatus = GL_TRUE;
53 mGetStringResult = NULL;
56 mIsFramebufferResult = 0;
58 mIsRenderbufferResult = 0;
61 mActiveTextureUnit = 0;
62 mCheckFramebufferStatusResult = 0;
63 mFramebufferStatus = 0;
64 mFramebufferDepthAttached = 0;
65 mFramebufferStencilAttached = 0;
66 mFramebufferColorAttachmentCount = 0;
67 mFrameBufferColorStatus = 0;
68 mNumBinaryFormats = 0;
70 mProgramBinaryLength = 0;
72 mVertexAttribArrayChanged = false;
73 mGetProgramBinaryCalled = false;
75 mLastShaderCompiled = 0;
76 mLastClearBitMask = 0;
77 mLastClearColor = Color::TRANSPARENT;
80 mLastBlendEquationRgb = 0;
81 mLastBlendEquationAlpha = 0;
82 mLastBlendFuncSrcRgb = 0;
83 mLastBlendFuncDstRgb = 0;
84 mLastBlendFuncSrcAlpha = 0;
85 mLastBlendFuncDstAlpha = 0;
86 mLastAutoTextureIdUsed = 0;
87 mNumGeneratedTextures = 0;
88 mLastShaderIdUsed = 0;
89 mLastProgramIdUsed = 0;
90 mLastUniformIdUsed = 0;
91 mLastDepthMask = false;
94 mProgramUniforms1i.clear();
95 mProgramUniforms1f.clear();
96 mProgramUniforms2f.clear();
97 mProgramUniforms3f.clear();
98 mProgramUniforms4f.clear();
101 mAttribLocs.push_back("aPosition");
102 mAttribLocs.push_back("aTexCoord");
103 mCullFaceTrace.Reset();
104 mDepthFunctionTrace.Reset();
105 mEnableDisableTrace.Reset();
106 mShaderTrace.Reset();
107 mStencilFunctionTrace.Reset();
108 mScissorTrace.Reset();
109 mTextureTrace.Reset();
110 mTexParameterTrace.Reset();
113 for(unsigned int i = 0; i < MAX_ATTRIBUTE_CACHE_SIZE; ++i)
115 mVertexAttribArrayState[i] = false;
118 mActiveUniforms = std::vector<ActiveUniform>{
119 {"uRendererColor", GL_FLOAT, 1},
120 {"uCustom", GL_FLOAT_VEC3, 1},
121 {"uCustom3", GL_FLOAT_VEC3, 1},
122 {"uFadeColor", GL_FLOAT_VEC4, 1},
123 {"uUniform1", GL_FLOAT_VEC4, 1},
124 {"uUniform2", GL_FLOAT_VEC4, 1},
125 {"uUniform3", GL_FLOAT_VEC4, 1},
126 {"uFadeProgress", GL_FLOAT, 1},
127 {"uANormalMatrix", GL_FLOAT_MAT3, 1},
128 {"sEffect", GL_SAMPLER_2D, 1},
129 {"sTexture", GL_SAMPLER_2D, 1},
130 {"sTextureRect", GL_SAMPLER_2D, 1},
131 {"sGloss", GL_SAMPLER_2D, 1},
132 {"uColor", GL_FLOAT_VEC4, 1},
133 {"uActorColor", GL_FLOAT_VEC4, 1},
134 {"uModelMatrix", GL_FLOAT_MAT4, 1},
135 {"uModelView", GL_FLOAT_MAT4, 1},
136 {"uMvpMatrix", GL_FLOAT_MAT4, 1},
137 {"uNormalMatrix", GL_FLOAT_MAT4, 1},
138 {"uProjection", GL_FLOAT_MAT4, 1},
139 {"uSize", GL_FLOAT_VEC3, 1},
140 {"uViewMatrix", GL_FLOAT_MAT4, 1},
141 {"uLightCameraProjectionMatrix", GL_FLOAT_MAT4, 1},
142 {"uLightCameraViewMatrix", GL_FLOAT_MAT4, 1}};
144 // WARNING: IF YOU CHANGE THIS LIST, ALSO CHANGE UNIFORMS IN test-graphics-reflection.cpp
147 void TestGlAbstraction::PreRender()
151 void TestGlAbstraction::PostRender()
155 bool TestGlAbstraction::IsSurfacelessContextSupported() const
160 bool TestGlAbstraction::IsAdvancedBlendEquationSupported()
165 bool TestGlAbstraction::IsBlendEquationSupported(DevelBlendEquation::Type blendEquation)
170 std::string TestGlAbstraction::GetShaderVersionPrefix()
172 return std::string("");
175 std::string TestGlAbstraction::GetVertexShaderPrefix()
177 return std::string("");
180 std::string TestGlAbstraction::GetFragmentShaderPrefix()
182 return std::string("");
185 bool TestGlAbstraction::TextureRequiresConverting(const GLenum imageGlFormat, const GLenum textureGlFormat, const bool isSubImage) const
187 return ((imageGlFormat == GL_RGB) && (textureGlFormat == GL_RGBA));
192 bool BlendEnabled(const Dali::TraceCallStack& callStack)
194 std::stringstream out;
196 bool blendEnabled = callStack.FindMethodAndParams("Enable", out.str());
200 bool BlendDisabled(const Dali::TraceCallStack& callStack)
202 std::stringstream out;
204 bool blendEnabled = callStack.FindMethodAndParams("Disable", out.str());