X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftest-gl-abstraction.h;h=a70c21f40c50941975feeb75cb4aa03dbf9252fc;hb=HEAD;hp=aec9f5dad925c687d8fd2226115bcbf79fd5090c;hpb=dc96b027c0d06fae091bde3f877b32a379ca2894;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h index aec9f5d..a70c21f 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.h @@ -2,7 +2,7 @@ #define TEST_GL_ABSTRACTION_H /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -51,9 +51,10 @@ struct UniformData struct ActiveUniform { - std::string name; - GLenum type; - GLint size; + std::string name{}; + GLenum type{GL_FLOAT}; + GLint size{0}; + GLint offset{0}; }; class DALI_CORE_API TestGlAbstraction : public Dali::Integration::GlAbstraction @@ -72,8 +73,12 @@ public: bool IsAdvancedBlendEquationSupported() override; + bool IsMultisampledRenderToTextureSupported() override; + bool IsBlendEquationSupported(DevelBlendEquation::Type blendEquation) override; + uint32_t GetShaderLanguageVersion(); + std::string GetShaderVersionPrefix(); std::string GetVertexShaderPrefix(); @@ -299,6 +304,21 @@ public: return mFramebufferColorAttachmentCount; } + inline GLuint CheckFramebufferDepthAttachmentCount() + { + return mFramebufferDepthAttachmentCount; + } + + inline GLuint CheckFramebufferStencilAttachmentCount() + { + return mFramebufferStencilAttachmentCount; + } + + inline GLuint CheckFramebufferDepthStencilAttachmentCount() + { + return mFramebufferDepthStencilAttachmentCount; + } + inline GLenum CheckFramebufferDepthAttachment() { return mFramebufferDepthAttached; @@ -309,6 +329,11 @@ public: return mFramebufferStencilAttached; } + inline GLenum CheckFramebufferDepthStencilAttachment() + { + return mFramebufferDepthStencilAttached; + } + inline void Clear(GLbitfield mask) override { mClearCount++; @@ -435,6 +460,10 @@ public: inline void DeleteBuffers(GLsizei n, const GLuint* buffers) override { + TraceCallStack::NamedParams namedParams; + namedParams["n"] << n; + namedParams["id"] << buffers[0]; + mBufferTrace.PushCall("DeleteBuffers", namedParams.str(), namedParams); } inline void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) override @@ -630,8 +659,9 @@ public: } else if(attachment == GL_DEPTH_STENCIL_ATTACHMENT) { - mFramebufferStencilAttached = true; - mFramebufferDepthAttached = true; + mFramebufferStencilAttached = true; + mFramebufferDepthAttached = true; + mFramebufferDepthStencilAttached = true; } } @@ -650,6 +680,20 @@ public: ++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 @@ -660,13 +704,21 @@ public: inline void GenBuffers(GLsizei n, GLuint* buffers) override { // avoids an assert in GpuBuffers - *buffers = 1u; + static GLuint id = 1; - std::ostringstream o; - o << n; TraceCallStack::NamedParams namedParams; - namedParams["n"] << o.str(); - mBufferTrace.PushCall("GenBuffers", o.str(), namedParams); + namedParams["n"] << n; + + // Allocate some buffer names + bool first = true; + while(n) + { + namedParams["buffers"] << (first ? "" : ", ") << id; + first = false; + *buffers++ = id++; + --n; + } + mBufferTrace.PushCall("GenBuffers", namedParams.str(), namedParams); } inline void GenerateMipmap(GLenum target) override @@ -759,12 +811,11 @@ public: inline void GetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override { + strncpy(name, mAttribLocs[index].c_str(), 99); + *type = mAttribTypes[index]; } - inline void SetActiveUniforms(const std::vector& uniforms) - { - mActiveUniforms = uniforms; - } + void SetActiveUniforms(const std::vector& uniforms); inline void GetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) override { @@ -826,6 +877,9 @@ public: case GL_PROGRAM_BINARY_FORMATS_OES: *params = mBinaryFormats; break; + case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT: + *params = mUniformBufferOffsetAlignment; + break; } } @@ -848,6 +902,9 @@ public: case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: *params = 100; break; + case GL_ACTIVE_ATTRIBUTES: + *params = static_cast(mAttribLocs.size()); + break; } } @@ -913,8 +970,8 @@ public: if(it2 == uniformIDs.end()) { // Uniform not found, so add it... - uniformIDs[name] = mLastUniformIdUsed++; - return mLastUniformIdUsed; + uniformIDs[name] = ++mLastUniformIdUsed; + return uniformIDs[name]; } return it2->second; @@ -986,12 +1043,60 @@ public: for(const auto& uniform : mActiveUniforms) { - GetUniformLocation(program, uniform.name.c_str()); + std::string name = uniform.name; + if(uniform.size <= 1) + { + GetUniformLocation(program, name.c_str()); + } + else + { + // Convert single active uniform from "uBlah[0]" or "uStruct[0].element" to N versions of the same + std::string suffix; + auto iter = name.find("["); // Search for index operator + if(iter != std::string::npos) + { + name = uniform.name.substr(0, iter); // Strip off index operator + iter = uniform.name.find("]"); + if(iter != std::string::npos && iter + 1 != uniform.name.length()) + { + suffix = uniform.name.substr(iter + 1); + } + } + for(int i = 0; i < uniform.size; ++i) + { + std::stringstream nss; + nss << name << "[" << i << "]" << suffix; + GetUniformLocation(program, nss.str().c_str()); // Generate N uniforms in the uniform map + } + } } 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()); + } } } @@ -1527,6 +1632,18 @@ public: mBufferTrace.PushCall("VertexAttribPointer", namedParams.str(), namedParams); } + inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) override + { + TraceCallStack::NamedParams namedParams; + namedParams["index"] << index; + namedParams["size"] << size; + namedParams["type"] << std::hex << type; + namedParams["stride"] << stride; + namedParams["offset"] << std::to_string(reinterpret_cast(pointer)); + + mBufferTrace.PushCall("VertexAttribIPointer", namedParams.str(), namedParams); + } + inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) override { std::string commaString(", "); @@ -1644,6 +1761,12 @@ public: { } + 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 { } @@ -1703,10 +1826,6 @@ public: { } - inline void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) override - { - } - inline void GetVertexAttribIiv(GLuint index, GLenum pname, GLint* params) override { } @@ -1803,6 +1922,44 @@ public: inline void GetActiveUniformsiv(GLuint program, GLsizei uniformCount, const GLuint* uniformIndices, GLenum pname, GLint* params) override { + for(int i = 0; i < uniformCount; ++i) + { + if(i < int(mActiveUniforms.size())) + { + switch(pname) + { + case GL_UNIFORM_TYPE: + { + params[i] = mActiveUniforms[i].type; + break; + } + case GL_UNIFORM_SIZE: + { + params[i] = mActiveUniforms[i].size; + break; + } + case GL_UNIFORM_NAME_LENGTH: + { + params[i] = mActiveUniforms[i].name.length(); + break; + } + case GL_UNIFORM_BLOCK_INDEX: + { + params[i] = -1; + break; + } + case GL_UNIFORM_OFFSET: + { + params[i] = mActiveUniforms[i].offset; + break; + } + case GL_UNIFORM_MATRIX_STRIDE: + { + break; + } + } + } + } } inline GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName) override @@ -1824,10 +1981,26 @@ public: inline void DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei instanceCount) override { + std::stringstream out; + out << mode << ", " << first << ", " << count << ", " << instanceCount; + TraceCallStack::NamedParams namedParams; + namedParams["mode"] << std::hex << mode; + namedParams["first"] << first; + namedParams["count"] << count; + namedParams["instanceCount"] << instanceCount; + mDrawTrace.PushCall("DrawArraysInstanced", out.str(), namedParams); } inline void DrawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices, GLsizei instanceCount) override { + std::stringstream out; + out << mode << ", " << count << ", " << type << ", " << instanceCount; + TraceCallStack::NamedParams namedParams; + namedParams["mode"] << std::hex << mode; + namedParams["count"] << count; + namedParams["type"] << std::hex << type; + namedParams["indexCount"] << instanceCount; + mDrawTrace.PushCall("DrawElementsInstanced", out.str(), namedParams); } inline GLsync FenceSync(GLenum condition, GLbitfield flags) override @@ -1912,6 +2085,12 @@ public: inline void VertexAttribDivisor(GLuint index, GLuint divisor) override { + std::stringstream out; + out << index << ", " << divisor; + TraceCallStack::NamedParams namedParams; + namedParams["index"] << index; + namedParams["divisor"] << divisor; + mBufferTrace.PushCall("VertexAttribDivisor", out.str(), namedParams); } inline void BindTransformFeedback(GLenum target, GLuint id) override @@ -2008,10 +2187,14 @@ public: // TEST FUNCTIONS { mLinkStatus = value; } - inline void SetAttribLocations(std::vector locs) + inline void SetAttribLocations(std::vector& locs) { mAttribLocs = locs; } + inline void SetAttribTypes(std::vector& types) + { + mAttribTypes = types; + } inline void SetGetErrorResult(GLenum result) { mGetErrorResult = result; @@ -2064,7 +2247,10 @@ public: // TEST FUNCTIONS { mProgramBinaryLength = length; } - + inline void SetUniformBufferOffsetAlignment(GLint align) + { + mUniformBufferOffsetAlignment = align; + } inline bool GetVertexAttribArrayState(GLuint index) { if(index >= MAX_ATTRIBUTE_CACHE_SIZE) @@ -2468,17 +2654,23 @@ public: GLint mFramebufferStatus; GLenum mFramebufferDepthAttached; GLenum mFramebufferStencilAttached; + GLenum mFramebufferDepthStencilAttached; GLuint mFramebufferColorAttachmentCount; GLuint mFrameBufferColorStatus; + GLuint mFramebufferDepthAttachmentCount; + GLuint mFramebufferStencilAttachmentCount; + GLuint mFramebufferDepthStencilAttachmentCount; GLint mNumBinaryFormats; GLint mBinaryFormats; GLint mProgramBinaryLength; + GLint mUniformBufferOffsetAlignment{1}; bool mVertexAttribArrayState[MAX_ATTRIBUTE_CACHE_SIZE]; bool mVertexAttribArrayChanged; // whether the vertex attrib array has been changed bool mGetProgramBinaryCalled; typedef std::map ShaderSourceMap; ShaderSourceMap mShaderSources; - std::vector mAttribLocs; // should be bound to shader + std::vector mAttribLocs; // should be bound to shader + std::vector mAttribTypes; // should be bound to shader GLuint mLastShaderCompiled; GLbitfield mLastClearBitMask; Vector4 mLastClearColor; @@ -2522,6 +2714,8 @@ public: TraceCallStack mViewportTrace; // Shaders & Uniforms + uint32_t mShaderLanguageVersion{320u}; + GLuint mLastShaderIdUsed; GLuint mLastProgramIdUsed{0u}; GLuint mLastUniformIdUsed;