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=f6878ae7ca3be575470275cc0528ba2b3ecabfdc;hb=ca51ee97baf5f41ecf741e22d865ff6c9e0bf769;hp=b414084f4e682a49fe1dd0693fada84bdb1b2aec;hpb=bed9d1fafb2def9ec59d67277a4935a9f7fcbdd1;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 b414084..f6878ae 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) 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. @@ -38,6 +38,24 @@ namespace Dali { +struct UniformData +{ + std::string name; + Property::Type type; + UniformData(const std::string& name, Property::Type type = Property::Type::NONE) + : name(name), + type(type) + { + } +}; + +struct ActiveUniform +{ + std::string name; + GLenum type; + GLint size; +}; + class DALI_CORE_API TestGlAbstraction : public Dali::Integration::GlAbstraction { public: @@ -157,10 +175,10 @@ public: } std::stringstream out; - out << target << ", " << texture; + out << std::hex << target << ", " << std::dec << texture; TraceCallStack::NamedParams namedParams; - namedParams["target"] << target; + namedParams["target"] << std::hex << target; namedParams["texture"] << texture; mTextureTrace.PushCall("BindTexture", out.str(), namedParams); @@ -281,6 +299,21 @@ public: return mFramebufferColorAttachmentCount; } + inline GLuint CheckFramebufferDepthAttachmentCount() + { + return mFramebufferDepthAttachmentCount; + } + + inline GLuint CheckFramebufferStencilAttachmentCount() + { + return mFramebufferStencilAttachmentCount; + } + + inline GLuint CheckFramebufferDepthStencilAttachmentCount() + { + return mFramebufferDepthStencilAttachmentCount; + } + inline GLenum CheckFramebufferDepthAttachment() { return mFramebufferDepthAttached; @@ -291,6 +324,11 @@ public: return mFramebufferStencilAttached; } + inline GLenum CheckFramebufferDepthStencilAttachment() + { + return mFramebufferDepthStencilAttached; + } + inline void Clear(GLbitfield mask) override { mClearCount++; @@ -407,10 +445,10 @@ public: inline void CullFace(GLenum mode) override { std::stringstream out; - out << mode; + out << std::hex << mode; TraceCallStack::NamedParams namedParams; - namedParams["program"] << mode; + namedParams["mode"] << std::hex << mode; mCullFaceTrace.PushCall("CullFace", out.str(), namedParams); } @@ -498,7 +536,7 @@ public: inline void DepthFunc(GLenum func) override { std::stringstream out; - out << func; + out << std::hex << func; TraceCallStack::NamedParams namedParams; namedParams["func"] << std::hex << func; @@ -533,7 +571,7 @@ public: inline void Disable(GLenum cap) override { std::stringstream out; - out << cap; + out << std::hex << cap; TraceCallStack::NamedParams namedParams; namedParams["cap"] << std::hex << cap; mEnableDisableTrace.PushCall("Disable", out.str(), namedParams); @@ -576,7 +614,7 @@ public: inline void Enable(GLenum cap) override { std::stringstream out; - out << cap; + out << std::hex << cap; TraceCallStack::NamedParams namedParams; namedParams["cap"] << std::hex << cap; mEnableDisableTrace.PushCall("Enable", out.str(), namedParams); @@ -610,6 +648,12 @@ public: { 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 @@ -627,10 +671,25 @@ 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 { + // do nothing } inline void GenBuffers(GLsizei n, GLuint* buffers) override @@ -737,27 +796,18 @@ public: { } + inline void SetActiveUniforms(const std::vector& 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; } } @@ -825,11 +875,14 @@ public: *params = mProgramBinaryLength; break; case GL_ACTIVE_UNIFORMS: - *params = mNumberOfActiveUniforms; + *params = mActiveUniforms.size(); break; case GL_ACTIVE_UNIFORM_MAX_LENGTH: *params = 100; break; + case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: + *params = 100; + break; } } @@ -896,7 +949,7 @@ public: { // Uniform not found, so add it... uniformIDs[name] = ++mLastUniformIdUsed; - return mLastUniformIdUsed; + return uniformIDs[name]; } return it2->second; @@ -966,10 +1019,38 @@ public: namedParams["program"] << program; mShaderTrace.PushCall("LinkProgram", out.str(), namedParams); - mNumberOfActiveUniforms = 3; - GetUniformLocation(program, "sTexture"); - GetUniformLocation(program, "sEffect"); - GetUniformLocation(program, "sGloss"); + for(const auto& uniform : mActiveUniforms) + { + GetUniformLocation(program, uniform.name.c_str()); + } + + for(const auto& uniform : mCustomUniformData) + { + 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 PixelStorei(GLenum pname, GLint param) override @@ -1177,16 +1258,10 @@ public: out << std::hex << target << ", " << pname << ", " << param; std::string params = out.str(); - out.str(""); - out << std::hex << target; TraceCallStack::NamedParams namedParams; - namedParams["target"] << out.str(); - out.str(""); - out << std::hex << pname; - namedParams["pname"] << out.str(); - out.str(""); - out << std::hex << param; - namedParams["param"] << out.str(); + namedParams["target"] << std::hex << target; + namedParams["pname"] << std::hex << pname; + namedParams["param"] << param; mTexParameterTrace.PushCall("TexParameteri", params, namedParams); } @@ -1579,7 +1654,12 @@ public: inline GLboolean UnmapBuffer(GLenum target) override { - return false; + if(mMappedBuffer) + { + free(mMappedBuffer); + mMappedBuffer = nullptr; + } + return true; // false indicates corruption, nothing else. } inline void GetBufferPointerv(GLenum target, GLenum pname, GLvoid** params) override @@ -1628,7 +1708,8 @@ public: inline GLvoid* MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) override { - return NULL; + mMappedBuffer = reinterpret_cast(malloc(offset + length)); + return mMappedBuffer; } inline void FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length) override @@ -2266,7 +2347,7 @@ public: // TEST FUNCTIONS } } - fprintf(stderr, "Not found, printing possible values:\n"); + fprintf(stderr, "%s Not found, printing possible values:\n", name); for(ProgramUniformMap::const_iterator program_it = mUniforms.begin(); program_it != mUniforms.end(); ++program_it) @@ -2285,7 +2366,7 @@ public: // TEST FUNCTIONS if(mProgramUniforms.GetUniformValue(programId, uniformId, origValue)) { std::stringstream out; - out << uniform_it->first << ": " << origValue; + out << "Program: " << programId << ", " << uniform_it->first << ": " << origValue; fprintf(stderr, "%s\n", out.str().c_str()); } } @@ -2319,6 +2400,11 @@ public: // TEST FUNCTIONS return false; } + inline void SetCustomUniforms(std::vector& customUniformData) + { + mCustomUniformData = customUniformData; + } + inline GLuint GetLastShaderCompiled() const { return mLastShaderCompiled; @@ -2419,13 +2505,13 @@ public: // TEST FUNCTIONS 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; @@ -2440,8 +2526,12 @@ private: GLint mFramebufferStatus; GLenum mFramebufferDepthAttached; GLenum mFramebufferStencilAttached; + GLenum mFramebufferDepthStencilAttached; GLuint mFramebufferColorAttachmentCount; GLuint mFrameBufferColorStatus; + GLuint mFramebufferDepthAttachmentCount; + GLuint mFramebufferStencilAttachmentCount; + GLuint mFramebufferDepthStencilAttachmentCount; GLint mNumBinaryFormats; GLint mBinaryFormats; GLint mProgramBinaryLength; @@ -2495,11 +2585,13 @@ private: // Shaders & Uniforms GLuint mLastShaderIdUsed; - GLuint mLastProgramIdUsed; + GLuint mLastProgramIdUsed{0u}; GLuint mLastUniformIdUsed; typedef std::map UniformIDMap; typedef std::map ProgramUniformMap; ProgramUniformMap mUniforms; + std::vector mActiveUniforms; + std::vector mCustomUniformData{}; template struct ProgramUniformValue : public std::map >