#define TEST_GL_ABSTRACTION_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
};
+struct ActiveUniform
+{
+ std::string name;
+ GLenum type;
+ GLint size;
+};
+
class DALI_CORE_API TestGlAbstraction : public Dali::Integration::GlAbstraction
{
public:
bool IsAdvancedBlendEquationSupported() override;
+ bool IsMultisampledRenderToTextureSupported() override;
+
bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation) override;
std::string GetShaderVersionPrefix();
return mFramebufferColorAttachmentCount;
}
+ inline GLuint CheckFramebufferDepthAttachmentCount()
+ {
+ return mFramebufferDepthAttachmentCount;
+ }
+
+ inline GLuint CheckFramebufferStencilAttachmentCount()
+ {
+ return mFramebufferStencilAttachmentCount;
+ }
+
+ inline GLuint CheckFramebufferDepthStencilAttachmentCount()
+ {
+ return mFramebufferDepthStencilAttachmentCount;
+ }
+
inline GLenum CheckFramebufferDepthAttachment()
{
return mFramebufferDepthAttached;
return mFramebufferStencilAttached;
}
+ inline GLenum CheckFramebufferDepthStencilAttachment()
+ {
+ return mFramebufferDepthStencilAttached;
+ }
+
inline void Clear(GLbitfield mask) override
{
mClearCount++;
{
mFramebufferStencilAttached = true;
}
+ else if(attachment == GL_DEPTH_STENCIL_ATTACHMENT)
+ {
+ mFramebufferStencilAttached = true;
+ mFramebufferDepthAttached = true;
+ mFramebufferDepthStencilAttached = true;
+ }
}
inline void FramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) override
++mFramebufferColorAttachmentCount;
}
}
+ else if(attachment == GL_DEPTH_ATTACHMENT)
+ {
+ ++mFramebufferDepthAttachmentCount;
+ }
+ else if(attachment == GL_STENCIL_ATTACHMENT)
+ {
+ ++mFramebufferStencilAttachmentCount;
+ }
+ else if(attachment == GL_DEPTH_STENCIL_ATTACHMENT)
+ {
+ ++mFramebufferDepthAttachmentCount;
+ ++mFramebufferStencilAttachmentCount;
+ ++mFramebufferDepthStencilAttachmentCount;
+ }
}
inline void FrontFace(GLenum mode) override
{
}
+ inline void SetActiveUniforms(const std::vector<ActiveUniform>& uniforms)
+ {
+ mActiveUniforms = uniforms;
+ }
+
inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override
{
- switch(index)
+ if(index < mActiveUniforms.size())
{
- case 0:
- *length = snprintf(name, bufsize, "sTexture");
- *type = GL_SAMPLER_2D;
- *size = 1;
- break;
- case 1:
- *length = snprintf(name, bufsize, "sEffect");
- *type = GL_SAMPLER_2D;
- *size = 1;
- break;
- case 2:
- *length = snprintf(name, bufsize, "sGloss");
- *type = GL_SAMPLER_2D;
- *size = 1;
- break;
- default:
- break;
+ *length = snprintf(name, bufsize, "%s", mActiveUniforms[index].name.c_str());
+ *type = mActiveUniforms[index].type;
+ *size = mActiveUniforms[index].size;
}
}
*params = mProgramBinaryLength;
break;
case GL_ACTIVE_UNIFORMS:
- *params = mNumberOfActiveUniforms;
+ *params = mActiveUniforms.size();
break;
case GL_ACTIVE_UNIFORM_MAX_LENGTH:
*params = 100;
if(it2 == uniformIDs.end())
{
// Uniform not found, so add it...
- uniformIDs[name] = mLastUniformIdUsed++;
- return mLastUniformIdUsed;
+ uniformIDs[name] = ++mLastUniformIdUsed;
+ return uniformIDs[name];
}
return it2->second;
namedParams["program"] << program;
mShaderTrace.PushCall("LinkProgram", out.str(), namedParams);
- mNumberOfActiveUniforms = 3;
-
- GetUniformLocation(program, "uRendererColor");
- GetUniformLocation(program, "uCustom");
- GetUniformLocation(program, "uCustom3");
- GetUniformLocation(program, "uFadeColor");
- GetUniformLocation(program, "uUniform1");
- GetUniformLocation(program, "uUniform2");
- GetUniformLocation(program, "uUniform3");
- GetUniformLocation(program, "uFadeProgress");
- GetUniformLocation(program, "uANormalMatrix");
- GetUniformLocation(program, "sEffect");
- GetUniformLocation(program, "sTexture");
- GetUniformLocation(program, "sTextureRect");
- GetUniformLocation(program, "sGloss");
- GetUniformLocation(program, "uColor");
- GetUniformLocation(program, "uModelMatrix");
- GetUniformLocation(program, "uModelView");
- GetUniformLocation(program, "uMvpMatrix");
- GetUniformLocation(program, "uNormalMatrix");
- GetUniformLocation(program, "uProjection");
- GetUniformLocation(program, "uSize");
- GetUniformLocation(program, "uViewMatrix");
- GetUniformLocation(program, "uLightCameraProjectionMatrix");
- GetUniformLocation(program, "uLightCameraViewMatrix");
+ for(const auto& uniform : mActiveUniforms)
+ {
+ GetUniformLocation(program, uniform.name.c_str());
+ }
for(const auto& uniform : mCustomUniformData)
{
- GetUniformLocation(program, uniform.name.c_str());
+ auto iter = uniform.name.find("[");
+ auto name = uniform.name;
+ if(iter != std::string::npos)
+ {
+ name = uniform.name.substr(0, iter);
+ auto arrayCount = std::stoi(uniform.name.substr(iter + 1));
+ iter = uniform.name.find("]");
+ std::string suffix;
+ if(iter != std::string::npos && iter + 1 != uniform.name.length())
+ {
+ suffix = uniform.name.substr(iter + 1); // If there is a suffix, it means its an element of an array of struct
+ }
+
+ for(int i = 0; i < arrayCount; ++i)
+ {
+ std::stringstream nss;
+ nss << name << "[" << i << "]" << suffix;
+ GetUniformLocation(program, nss.str().c_str()); // Generate a GL loc per element
+ }
+ }
+ else
+ {
+ GetUniformLocation(program, name.c_str());
+ }
}
}
{
}
+ inline void FramebufferTexture2DMultisample(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples) override
+ {
+ // TODO : Check it if need
+ FramebufferTexture2D(target, attachment, textarget, texture, level);
+ }
+
inline void FramebufferTextureLayer(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer) override
{
}
mBufferSubDataCalls.clear();
}
-private:
+public:
GLuint mCurrentProgram;
GLuint mCompileStatus;
BufferDataCalls mBufferDataCalls;
BufferSubDataCalls mBufferSubDataCalls;
GLvoid* mMappedBuffer{nullptr};
GLuint mLinkStatus;
- GLint mNumberOfActiveUniforms;
GLenum mGetErrorResult;
GLubyte* mGetStringResult;
GLboolean mIsBufferResult;
GLint mFramebufferStatus;
GLenum mFramebufferDepthAttached;
GLenum mFramebufferStencilAttached;
+ GLenum mFramebufferDepthStencilAttached;
GLuint mFramebufferColorAttachmentCount;
GLuint mFrameBufferColorStatus;
+ GLuint mFramebufferDepthAttachmentCount;
+ GLuint mFramebufferStencilAttachmentCount;
+ GLuint mFramebufferDepthStencilAttachmentCount;
GLint mNumBinaryFormats;
GLint mBinaryFormats;
GLint mProgramBinaryLength;
typedef std::map<std::string, GLint> UniformIDMap;
typedef std::map<GLuint, UniformIDMap> ProgramUniformMap;
ProgramUniformMap mUniforms;
-
- std::vector<UniformData> mCustomUniformData{};
+ std::vector<ActiveUniform> mActiveUniforms;
+ std::vector<UniformData> mCustomUniformData{};
template<typename T>
struct ProgramUniformValue : public std::map<GLuint, std::map<GLint, T> >