From 6097ddb9d7420625872d371cd5f44939d5240be8 Mon Sep 17 00:00:00 2001 From: David Steele Date: Fri, 5 Feb 2021 12:09:46 +0000 Subject: [PATCH] Updated test files to match dali-core Pipeline VtxFmt Change-Id: I819d9a5588faf1d230c3c34dd7209c771237bdcf --- .../src/dali-scene-loader-internal/CMakeLists.txt | 1 + .../src/dali-scene-loader/CMakeLists.txt | 1 + .../src/dali-toolkit-internal/CMakeLists.txt | 1 + .../src/dali-toolkit-styling/CMakeLists.txt | 1 + .../src/dali-toolkit-third-party/CMakeLists.txt | 1 + automated-tests/src/dali-toolkit/CMakeLists.txt | 1 + .../dali-toolkit-test-utils/mesh-builder.cpp | 6 +- .../test-gl-abstraction.cpp | 12 +- .../dali-toolkit-test-utils/test-gl-abstraction.h | 337 +++++++++++---------- .../test-graphics-buffer.cpp | 6 +- .../test-graphics-command-buffer.cpp | 18 ++ .../test-graphics-command-buffer.h | 53 +++- .../test-graphics-controller.cpp | 233 +++++++++++--- .../test-graphics-controller.h | 10 +- .../test-graphics-pipeline.cpp | 54 ++++ .../test-graphics-pipeline.h | 47 +++ .../test-trace-call-stack.cpp | 28 +- .../test-trace-call-stack.h | 94 +++++- .../src/dali-toolkit/utc-Dali-ImageAtlas.cpp | 52 ++-- .../src/dali-toolkit/utc-Dali-ImageView.cpp | 20 +- .../src/dali-toolkit/utc-Dali-ImageVisual.cpp | 4 +- 21 files changed, 717 insertions(+), 263 deletions(-) create mode 100644 automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-pipeline.cpp create mode 100644 automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-pipeline.h diff --git a/automated-tests/src/dali-scene-loader-internal/CMakeLists.txt b/automated-tests/src/dali-scene-loader-internal/CMakeLists.txt index 086a750..f9de035 100755 --- a/automated-tests/src/dali-scene-loader-internal/CMakeLists.txt +++ b/automated-tests/src/dali-scene-loader-internal/CMakeLists.txt @@ -48,6 +48,7 @@ SET(TEST_HARNESS_SOURCES ${TEST_HARNESS_DIR}/test-graphics-controller.cpp ${TEST_HARNESS_DIR}/test-graphics-texture.cpp ${TEST_HARNESS_DIR}/test-graphics-sampler.cpp + ${TEST_HARNESS_DIR}/test-graphics-pipeline.cpp ${TEST_HARNESS_DIR}/test-platform-abstraction.cpp ${TEST_HARNESS_DIR}/test-render-controller.cpp ${TEST_HARNESS_DIR}/test-trace-call-stack.cpp diff --git a/automated-tests/src/dali-scene-loader/CMakeLists.txt b/automated-tests/src/dali-scene-loader/CMakeLists.txt index 0c17d41..55ba896 100755 --- a/automated-tests/src/dali-scene-loader/CMakeLists.txt +++ b/automated-tests/src/dali-scene-loader/CMakeLists.txt @@ -62,6 +62,7 @@ SET(TEST_HARNESS_SOURCES ${TEST_HARNESS_DIR}/test-graphics-controller.cpp ${TEST_HARNESS_DIR}/test-graphics-texture.cpp ${TEST_HARNESS_DIR}/test-graphics-sampler.cpp + ${TEST_HARNESS_DIR}/test-graphics-pipeline.cpp ${TEST_HARNESS_DIR}/test-platform-abstraction.cpp ${TEST_HARNESS_DIR}/test-render-controller.cpp ${TEST_HARNESS_DIR}/test-trace-call-stack.cpp diff --git a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt index e75b848..7d26e43 100755 --- a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt @@ -84,6 +84,7 @@ SET(TEST_HARNESS_SOURCES ../dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp ../dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp ../dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.cpp + ../dali-toolkit/dali-toolkit-test-utils/test-graphics-pipeline.cpp ../dali-toolkit/dali-toolkit-test-utils/test-graphics-sampler.cpp ../dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp ../dali-toolkit/dali-toolkit-test-utils/test-render-controller.cpp diff --git a/automated-tests/src/dali-toolkit-styling/CMakeLists.txt b/automated-tests/src/dali-toolkit-styling/CMakeLists.txt index fa86caf..4c179b8 100644 --- a/automated-tests/src/dali-toolkit-styling/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-styling/CMakeLists.txt @@ -50,6 +50,7 @@ SET(TEST_HARNESS_SOURCES ../dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp ../dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp ../dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.cpp + ../dali-toolkit/dali-toolkit-test-utils/test-graphics-pipeline.cpp ../dali-toolkit/dali-toolkit-test-utils/test-graphics-sampler.cpp ../dali-toolkit/dali-toolkit-test-utils/test-render-controller.cpp ../dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp diff --git a/automated-tests/src/dali-toolkit-third-party/CMakeLists.txt b/automated-tests/src/dali-toolkit-third-party/CMakeLists.txt index ec88375..a4055b9 100644 --- a/automated-tests/src/dali-toolkit-third-party/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-third-party/CMakeLists.txt @@ -37,6 +37,7 @@ SET(TEST_HARNESS_SOURCES ../dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp ../dali-toolkit/dali-toolkit-test-utils/test-graphics-texture.cpp ../dali-toolkit/dali-toolkit-test-utils/test-graphics-sampler.cpp + ../dali-toolkit/dali-toolkit-test-utils/test-graphics-pipeline.cpp ../dali-toolkit/dali-toolkit-test-utils/test-platform-abstraction.cpp ../dali-toolkit/dali-toolkit-test-utils/test-render-controller.cpp ../dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp diff --git a/automated-tests/src/dali-toolkit/CMakeLists.txt b/automated-tests/src/dali-toolkit/CMakeLists.txt index 832a04b..072fecc 100755 --- a/automated-tests/src/dali-toolkit/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit/CMakeLists.txt @@ -114,6 +114,7 @@ SET(TEST_HARNESS_SOURCES dali-toolkit-test-utils/test-graphics-command-buffer.cpp dali-toolkit-test-utils/test-graphics-controller.cpp dali-toolkit-test-utils/test-graphics-texture.cpp + dali-toolkit-test-utils/test-graphics-pipeline.cpp dali-toolkit-test-utils/test-graphics-sampler.cpp dali-toolkit-test-utils/test-platform-abstraction.cpp dali-toolkit-test-utils/test-render-controller.cpp diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/mesh-builder.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/mesh-builder.cpp index 0693c43..e678074 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/mesh-builder.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/mesh-builder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -40,8 +40,8 @@ TextureSet CreateTextureSet(Texture texture) VertexBuffer CreateVertexBuffer() { Property::Map texturedQuadVertexFormat; - texturedQuadVertexFormat["aPosition"] = Property::VECTOR2; - texturedQuadVertexFormat["aVertexCoord"] = Property::VECTOR2; + texturedQuadVertexFormat["aPosition"] = Property::VECTOR2; + texturedQuadVertexFormat["aTexCoord"] = Property::VECTOR2; VertexBuffer vertexData = VertexBuffer::New(texturedQuadVertexFormat); return vertexData; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp index 9e8c7a8..eac9db5 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-gl-abstraction.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -20,6 +20,10 @@ namespace Dali { TestGlAbstraction::TestGlAbstraction() +: mBufferTrace(true, "gl"), + mTextureTrace(true, "gl"), + mTexParameterTrace(true, "gl"), + mDrawTrace(true, "gl") { Initialize(); } @@ -34,7 +38,6 @@ void TestGlAbstraction::Initialize() mCompileStatus = GL_TRUE; mLinkStatus = GL_TRUE; mNumberOfActiveUniforms = 0; - mGetAttribLocationResult = 0; mGetErrorResult = 0; mGetStringResult = NULL; mIsBufferResult = 0; @@ -83,6 +86,9 @@ void TestGlAbstraction::Initialize() mProgramUniforms3f.clear(); mProgramUniforms4f.clear(); + mAttribLocs.clear(); + mAttribLocs.push_back("aPosition"); + mAttribLocs.push_back("aTexCoord"); mCullFaceTrace.Reset(); mDepthFunctionTrace.Reset(); mEnableDisableTrace.Reset(); @@ -90,7 +96,7 @@ void TestGlAbstraction::Initialize() mStencilFunctionTrace.Reset(); mScissorTrace.Reset(); mTextureTrace.Reset(); - mTexParamaterTrace.Reset(); + mTexParameterTrace.Reset(); mDrawTrace.Reset(); for(unsigned int i = 0; i < MAX_ATTRIBUTE_CACHE_SIZE; ++i) 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 4e14dd9..b414084 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 @@ -38,20 +38,11 @@ namespace Dali { -static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 64; -static const char* mStdAttribs[MAX_ATTRIBUTE_CACHE_SIZE] = - { - "aPosition", // ATTRIB_POSITION - "aNormal", // ATTRIB_NORMAL - "aTexCoord", // ATTRIB_TEXCOORD - "aColor", // ATTRIB_COLOR - "aBoneWeights", // ATTRIB_BONE_WEIGHTS - "aBoneIndices" // ATTRIB_BONE_INDICES -}; - class DALI_CORE_API TestGlAbstraction : public Dali::Integration::GlAbstraction { public: + static const int MAX_ATTRIBUTE_CACHE_SIZE{64}; + TestGlAbstraction(); ~TestGlAbstraction() override; void Initialize(); @@ -91,8 +82,8 @@ public: out << program << ", " << shader; TraceCallStack::NamedParams namedParams; - namedParams["program"] = ToString(program); - namedParams["shader"] = ToString(shader); + namedParams["program"] << program; + namedParams["shader"] << shader; mShaderTrace.PushCall("AttachShader", out.str(), namedParams); } @@ -105,8 +96,8 @@ public: std::ostringstream o; o << std::hex << target << ", " << buffer; TraceCallStack::NamedParams namedParams; - namedParams["target"] = target; - namedParams["buffer"] = buffer; + namedParams["target"] << target; + namedParams["buffer"] << buffer; mBufferTrace.PushCall("BindBuffer", o.str(), namedParams); } @@ -169,8 +160,8 @@ public: out << target << ", " << texture; TraceCallStack::NamedParams namedParams; - namedParams["target"] = ToString(target); - namedParams["texture"] = ToString(texture); + namedParams["target"] << target; + namedParams["texture"] << texture; mTextureTrace.PushCall("BindTexture", out.str(), namedParams); } @@ -251,9 +242,9 @@ public: std::ostringstream o; o << std::hex << target << ", " << size << ", " << data << ", " << usage; TraceCallStack::NamedParams namedParams; - namedParams["target"] = target; - namedParams["size"] = size; - namedParams["usage"] = usage; + namedParams["target"] << std::hex << target; + namedParams["size"] << size; + namedParams["usage"] << usage; mBufferTrace.PushCall("BufferData", o.str(), namedParams); @@ -265,9 +256,9 @@ public: std::ostringstream o; o << std::hex << target << ", " << offset << ", " << size << ", " << data; TraceCallStack::NamedParams namedParams; - namedParams["target"] = target; - namedParams["offset"] = offset; - namedParams["size"] = size; + namedParams["target"] << std::hex << target; + namedParams["offset"] << offset; + namedParams["size"] << size; mBufferTrace.PushCall("BufferSubData", o.str()); mBufferSubDataCalls.push_back(size); @@ -329,7 +320,7 @@ public: out << s; TraceCallStack::NamedParams namedParams; - namedParams["s"] = ToString(s); + namedParams["s"] << s; mStencilFunctionTrace.PushCall("ClearStencil", out.str(), namedParams); } @@ -347,7 +338,7 @@ public: std::stringstream out; out << shader; TraceCallStack::NamedParams namedParams; - namedParams["shader"] = ToString(shader); + namedParams["shader"] << shader; mShaderTrace.PushCall("CompileShader", out.str(), namedParams); } @@ -358,13 +349,13 @@ public: out << target << ", " << level << ", " << width << ", " << height; TraceCallStack::NamedParams namedParams; - namedParams["target"] = ToString(target); - namedParams["level"] = ToString(level); - namedParams["internalformat"] = ToString(internalformat); - namedParams["width"] = ToString(width); - namedParams["height"] = ToString(height); - namedParams["border"] = ToString(border); - namedParams["size"] = ToString(imageSize); + namedParams["target"] << std::hex << target; + namedParams["level"] << level; + namedParams["internalformat"] << internalformat; + namedParams["width"] << width; + namedParams["height"] << height; + namedParams["border"] << border; + namedParams["size"] << imageSize; mTextureTrace.PushCall("CompressedTexImage2D", out.str(), namedParams); } @@ -375,12 +366,12 @@ public: out << target << ", " << level << ", " << xoffset << ", " << yoffset << ", " << width << ", " << height; TraceCallStack::NamedParams namedParams; - namedParams["target"] = ToString(target); - namedParams["level"] = ToString(level); - namedParams["xoffset"] = ToString(xoffset); - namedParams["yoffset"] = ToString(yoffset); - namedParams["width"] = ToString(width); - namedParams["height"] = ToString(height); + namedParams["target"] << std::hex << target; + namedParams["level"] << level; + namedParams["xoffset"] << xoffset; + namedParams["yoffset"] << yoffset; + namedParams["width"] << width; + namedParams["height"] << height; mTextureTrace.PushCall("CompressedTexSubImage2D", out.str(), namedParams); } @@ -407,7 +398,7 @@ public: out << type; TraceCallStack::NamedParams namedParams; - namedParams["type"] = ToString(type); + namedParams["type"] << std::hex << type; mShaderTrace.PushCall("CreateShader", out.str(), namedParams); return ++mLastShaderIdUsed; @@ -419,7 +410,7 @@ public: out << mode; TraceCallStack::NamedParams namedParams; - namedParams["program"] = ToString(mode); + namedParams["program"] << mode; mCullFaceTrace.PushCall("CullFace", out.str(), namedParams); } @@ -438,7 +429,7 @@ public: out << program; TraceCallStack::NamedParams namedParams; - namedParams["program"] = ToString(program); + namedParams["program"] << program; mShaderTrace.PushCall("DeleteProgram", out.str(), namedParams); } @@ -453,7 +444,7 @@ public: out << shader; TraceCallStack::NamedParams namedParams; - namedParams["shader"] = ToString(shader); + namedParams["shader"] << shader; mShaderTrace.PushCall("DeleteShader", out.str(), namedParams); } @@ -470,7 +461,7 @@ public: out << (i > 0 ? ", " : "") << textures[i]; std::stringstream paramName; paramName << "texture[" << i << "]"; - namedParams[paramName.str()] = ToString(textures[i]); + namedParams[paramName.str()] << textures[i]; mDeletedTextureIds.push_back(textures[i]); mNumGeneratedTextures--; } @@ -510,7 +501,7 @@ public: out << func; TraceCallStack::NamedParams namedParams; - namedParams["func"] = ToString(func); + namedParams["func"] << std::hex << func; mDepthFunctionTrace.PushCall("DepthFunc", out.str(), namedParams); } @@ -534,8 +525,8 @@ public: std::stringstream out; out << program << ", " << shader; TraceCallStack::NamedParams namedParams; - namedParams["program"] = ToString(program); - namedParams["shader"] = ToString(shader); + namedParams["program"] << program; + namedParams["shader"] << shader; mShaderTrace.PushCall("DetachShader", out.str(), namedParams); } @@ -544,12 +535,17 @@ public: std::stringstream out; out << cap; TraceCallStack::NamedParams namedParams; - namedParams["cap"] = ToString(cap); + namedParams["cap"] << std::hex << cap; mEnableDisableTrace.PushCall("Disable", out.str(), namedParams); } inline void DisableVertexAttribArray(GLuint index) override { + std::stringstream out; + out << index; + TraceCallStack::NamedParams namedParams; + namedParams["index"] << index; + mBufferTrace.PushCall("DisableVertexAttribArray", out.str(), namedParams); SetVertexAttribArray(index, false); } @@ -558,9 +554,9 @@ public: std::stringstream out; out << mode << ", " << first << ", " << count; TraceCallStack::NamedParams namedParams; - namedParams["mode"] = ToString(mode); - namedParams["first"] = ToString(first); - namedParams["count"] = ToString(count); + namedParams["mode"] << std::hex << mode; + namedParams["first"] << first; + namedParams["count"] << count; mDrawTrace.PushCall("DrawArrays", out.str(), namedParams); } @@ -570,9 +566,9 @@ public: out << mode << ", " << count << ", " << type << ", indices"; TraceCallStack::NamedParams namedParams; - namedParams["mode"] = ToString(mode); - namedParams["count"] = ToString(count); - namedParams["type"] = ToString(type); + namedParams["mode"] << std::hex << mode; + namedParams["count"] << count; + namedParams["type"] << type; // Skip void pointers - are they of any use? mDrawTrace.PushCall("DrawElements", out.str(), namedParams); } @@ -582,12 +578,17 @@ public: std::stringstream out; out << cap; TraceCallStack::NamedParams namedParams; - namedParams["cap"] = ToString(cap); + namedParams["cap"] << std::hex << cap; mEnableDisableTrace.PushCall("Enable", out.str(), namedParams); } inline void EnableVertexAttribArray(GLuint index) override { + std::stringstream out; + out << index; + TraceCallStack::NamedParams namedParams; + namedParams["index"] << index; + mBufferTrace.PushCall("EnableVertexAttribArray", out.str(), namedParams); SetVertexAttribArray(index, true); } @@ -640,7 +641,7 @@ public: std::ostringstream o; o << n; TraceCallStack::NamedParams namedParams; - namedParams["n"] = o.str(); + namedParams["n"] << o.str(); mBufferTrace.PushCall("GenBuffers", o.str(), namedParams); } @@ -649,7 +650,7 @@ public: std::stringstream out; out << target; TraceCallStack::NamedParams namedParams; - namedParams["target"] = ToString(target); + namedParams["target"] << std::hex << target; mTextureTrace.PushCall("GenerateMipmap", out.str(), namedParams); } @@ -704,7 +705,7 @@ public: } TraceCallStack::NamedParams namedParams; - namedParams["count"] = ToString(count); + namedParams["count"] << count; std::stringstream out; for(int i = 0; i < count; i++) @@ -716,7 +717,7 @@ public: } std::ostringstream oss; oss << "indices[" << i << "]"; - namedParams[oss.str()] = ToString(textures[i]); + namedParams[oss.str()] << textures[i]; } mTextureTrace.PushCall("GenTextures", out.str(), namedParams); @@ -766,18 +767,11 @@ public: inline int GetAttribLocation(GLuint program, const char* name) override { - std::string attribName(name); - - for(unsigned int i = 0; i < ATTRIB_TYPE_LAST; ++i) - { - if(mStdAttribs[i] == attribName) - { - return i; - } - } - - // 0 is a valid location - return 0; + std::string check(name); + auto iter = std::find(mAttribLocs.begin(), mAttribLocs.end(), check); + if(iter == mAttribLocs.end()) + return -1; + return iter - mAttribLocs.begin(); } inline void GetBooleanv(GLenum pname, GLboolean* params) override @@ -969,7 +963,7 @@ public: out << program; TraceCallStack::NamedParams namedParams; - namedParams["program"] = ToString(program); + namedParams["program"] << program; mShaderTrace.PushCall("LinkProgram", out.str(), namedParams); mNumberOfActiveUniforms = 3; @@ -1012,10 +1006,10 @@ public: std::stringstream out; out << x << ", " << y << ", " << width << ", " << height; TraceCallStack::NamedParams namedParams; - namedParams["x"] = ToString(x); - namedParams["y"] = ToString(y); - namedParams["width"] = ToString(width); - namedParams["height"] = ToString(height); + namedParams["x"] << x; + namedParams["y"] << y; + namedParams["width"] << width; + namedParams["height"] << height; mScissorTrace.PushCall("Scissor", out.str(), namedParams); } @@ -1062,9 +1056,9 @@ public: out << func << ", " << ref << ", " << mask; TraceCallStack::NamedParams namedParams; - namedParams["func"] = ToString(func); - namedParams["ref"] = ToString(ref); - namedParams["mask"] = ToString(mask); + namedParams["func"] << std::hex << func; + namedParams["ref"] << ref; + namedParams["mask"] << mask; mStencilFunctionTrace.PushCall("StencilFunc", out.str(), namedParams); } @@ -1075,10 +1069,10 @@ public: out << face << ", " << func << ", " << ref << ", " << mask; TraceCallStack::NamedParams namedParams; - namedParams["face"] = ToString(face); - namedParams["func"] = ToString(func); - namedParams["ref"] = ToString(ref); - namedParams["mask"] = ToString(mask); + namedParams["face"] << std::hex << face; + namedParams["func"] << std::hex << func; + namedParams["ref"] << ref; + namedParams["mask"] << mask; mStencilFunctionTrace.PushCall("StencilFuncSeparate", out.str(), namedParams); } @@ -1089,7 +1083,7 @@ public: out << mask; TraceCallStack::NamedParams namedParams; - namedParams["mask"] = ToString(mask); + namedParams["mask"] << mask; mStencilFunctionTrace.PushCall("StencilMask", out.str(), namedParams); } @@ -1100,8 +1094,8 @@ public: out << face << ", " << mask; TraceCallStack::NamedParams namedParams; - namedParams["face"] = ToString(face); - namedParams["mask"] = ToString(mask); + namedParams["face"] << std::hex << face; + namedParams["mask"] << mask; mStencilFunctionTrace.PushCall("StencilMaskSeparate", out.str(), namedParams); } @@ -1112,9 +1106,9 @@ public: out << fail << ", " << zfail << ", " << zpass; TraceCallStack::NamedParams namedParams; - namedParams["fail"] = ToString(fail); - namedParams["zfail"] = ToString(zfail); - namedParams["zpass"] = ToString(zpass); + namedParams["fail"] << std::hex << fail; + namedParams["zfail"] << std::hex << zfail; + namedParams["zpass"] << std::hex << zpass; mStencilFunctionTrace.PushCall("StencilOp", out.str(), namedParams); } @@ -1125,10 +1119,10 @@ public: out << face << ", " << fail << ", " << zfail << "," << zpass; TraceCallStack::NamedParams namedParams; - namedParams["face"] = ToString(face); - namedParams["fail"] = ToString(fail); - namedParams["zfail"] = ToString(zfail); - namedParams["zpass"] = ToString(zpass); + namedParams["face"] << std::hex << face; + namedParams["fail"] << std::hex << fail; + namedParams["zfail"] << std::hex << zfail; + namedParams["zpass"] << std::hex << zpass; mStencilFunctionTrace.PushCall("StencilOpSeparate", out.str(), namedParams); } @@ -1139,14 +1133,14 @@ public: out << target << ", " << level << ", " << width << ", " << height; TraceCallStack::NamedParams namedParams; - namedParams["target"] = ToString(target); - namedParams["level"] = ToString(level); - namedParams["internalformat"] = ToString(internalformat); - namedParams["width"] = ToString(width); - namedParams["height"] = ToString(height); - namedParams["border"] = ToString(border); - namedParams["format"] = ToString(format); - namedParams["type"] = ToString(type); + namedParams["target"] << std::hex << target; + namedParams["level"] << level; + namedParams["internalformat"] << internalformat; + namedParams["width"] << width; + namedParams["height"] << height; + namedParams["border"] << border; + namedParams["format"] << std::hex << format; + namedParams["type"] << std::hex << type; mTextureTrace.PushCall("TexImage2D", out.str(), namedParams); } @@ -1157,11 +1151,11 @@ public: out << target << ", " << pname << ", " << param; TraceCallStack::NamedParams namedParams; - namedParams["target"] = ToString(target); - namedParams["pname"] = ToString(pname); - namedParams["param"] = ToString(param); + namedParams["target"] << std::hex << target; + namedParams["pname"] << std::hex << pname; + namedParams["param"] << param; - mTexParamaterTrace.PushCall("TexParameterf", out.str(), namedParams); + mTexParameterTrace.PushCall("TexParameterf", out.str(), namedParams); } inline void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) override @@ -1170,11 +1164,11 @@ public: out << target << ", " << pname << ", " << params[0]; TraceCallStack::NamedParams namedParams; - namedParams["target"] = ToString(target); - namedParams["pname"] = ToString(pname); - namedParams["params[0]"] = ToString(params[0]); + namedParams["target"] << std::hex << target; + namedParams["pname"] << std::hex << pname; + namedParams["params[0]"] << params[0]; - mTexParamaterTrace.PushCall("TexParameterfv", out.str(), namedParams); + mTexParameterTrace.PushCall("TexParameterfv", out.str(), namedParams); } inline void TexParameteri(GLenum target, GLenum pname, GLint param) override @@ -1186,14 +1180,14 @@ public: out.str(""); out << std::hex << target; TraceCallStack::NamedParams namedParams; - namedParams["target"] = out.str(); + namedParams["target"] << out.str(); out.str(""); out << std::hex << pname; - namedParams["pname"] = out.str(); + namedParams["pname"] << out.str(); out.str(""); out << std::hex << param; - namedParams["param"] = out.str(); - mTexParamaterTrace.PushCall("TexParameteri", params, namedParams); + namedParams["param"] << out.str(); + mTexParameterTrace.PushCall("TexParameteri", params, namedParams); } inline void TexParameteriv(GLenum target, GLenum pname, const GLint* params) override @@ -1201,10 +1195,10 @@ public: std::stringstream out; out << target << ", " << pname << ", " << params[0]; TraceCallStack::NamedParams namedParams; - namedParams["target"] = ToString(target); - namedParams["pname"] = ToString(pname); - namedParams["params[0]"] = ToString(params[0]); - mTexParamaterTrace.PushCall("TexParameteriv", out.str(), namedParams); + namedParams["target"] << std::hex << target; + namedParams["pname"] << std::hex << pname; + namedParams["params[0]"] << params[0]; + mTexParameterTrace.PushCall("TexParameteriv", out.str(), namedParams); } inline void TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void* pixels) override @@ -1213,18 +1207,18 @@ public: out << target << ", " << level << ", " << xoffset << ", " << yoffset << ", " << width << ", " << height; TraceCallStack::NamedParams namedParams; - namedParams["target"] = ToString(target); - namedParams["level"] = ToString(level); - namedParams["xoffset"] = ToString(xoffset); - namedParams["yoffset"] = ToString(yoffset); - namedParams["width"] = ToString(width); - namedParams["height"] = ToString(height); + namedParams["target"] << std::hex << target; + namedParams["level"] << level; + namedParams["xoffset"] << xoffset; + namedParams["yoffset"] << yoffset; + namedParams["width"] << width; + namedParams["height"] << height; mTextureTrace.PushCall("TexSubImage2D", out.str(), namedParams); } inline void Uniform1f(GLint location, GLfloat value) override { - std::string params = ToString(value); + std::string params = std::to_string(value); AddUniformCallToTraceStack(location, params); if(!mProgramUniforms1f.SetUniformValue(mCurrentProgram, location, value)) @@ -1238,7 +1232,7 @@ public: std::string params; for(int i = 0; i < count; ++i) { - params = params + ToString(v[i]) + ","; + params = params + std::to_string(v[i]) + ","; } AddUniformCallToTraceStack(location, params); @@ -1255,7 +1249,7 @@ public: inline void Uniform1i(GLint location, GLint x) override { - std::string params = ToString(x); + std::string params = std::to_string(x); AddUniformCallToTraceStack(location, params); @@ -1267,8 +1261,9 @@ public: inline void Uniform1iv(GLint location, GLsizei count, const GLint* v) override { - std::string params = ToString(v); - AddUniformCallToTraceStack(location, params); + std::ostringstream out; + for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i]; + AddUniformCallToTraceStack(location, out.str()); for(int i = 0; i < count; ++i) { @@ -1284,7 +1279,7 @@ public: inline void Uniform2f(GLint location, GLfloat x, GLfloat y) override { - std::string params = ToString(x) + "," + ToString(y); + std::string params = std::to_string(x) + "," + std::to_string(y); AddUniformCallToTraceStack(location, params); if(!mProgramUniforms2f.SetUniformValue(mCurrentProgram, @@ -1297,8 +1292,9 @@ public: inline void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) override { - std::string params = ToString(v); - AddUniformCallToTraceStack(location, params); + std::ostringstream out; + for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i]; + AddUniformCallToTraceStack(location, out.str()); for(int i = 0; i < count; ++i) { @@ -1314,19 +1310,20 @@ public: inline void Uniform2i(GLint location, GLint x, GLint y) override { - std::string params = ToString(x) + "," + ToString(y); + std::string params = std::to_string(x) + "," + std::to_string(y); AddUniformCallToTraceStack(location, params); } inline void Uniform2iv(GLint location, GLsizei count, const GLint* v) override { - std::string params = ToString(v); - AddUniformCallToTraceStack(location, params); + std::ostringstream out; + for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i]; + AddUniformCallToTraceStack(location, out.str()); } inline void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) override { - std::string params = ToString(x) + "," + ToString(y) + "," + ToString(z); + std::string params = std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z); AddUniformCallToTraceStack(location, params); if(!mProgramUniforms3f.SetUniformValue(mCurrentProgram, @@ -1339,8 +1336,9 @@ public: inline void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) override { - std::string params = ToString(v); - AddUniformCallToTraceStack(location, params); + std::ostringstream out; + for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i]; + AddUniformCallToTraceStack(location, out.str()); for(int i = 0; i < count; ++i) { @@ -1357,19 +1355,20 @@ public: inline void Uniform3i(GLint location, GLint x, GLint y, GLint z) override { - std::string params = ToString(x) + "," + ToString(y) + "," + ToString(z); + std::string params = std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z); AddUniformCallToTraceStack(location, params); } inline void Uniform3iv(GLint location, GLsizei count, const GLint* v) override { - std::string params = ToString(v); - AddUniformCallToTraceStack(location, params); + std::ostringstream out; + for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i]; + AddUniformCallToTraceStack(location, out.str()); } inline void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) override { - std::string params = ToString(x) + "," + ToString(y) + "," + ToString(z) + "," + ToString(w); + std::string params = std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z) + "," + std::to_string(w); AddUniformCallToTraceStack(location, params); if(!mProgramUniforms4f.SetUniformValue(mCurrentProgram, @@ -1382,8 +1381,9 @@ public: inline void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) override { - std::string params = ToString(v); - AddUniformCallToTraceStack(location, params); + std::ostringstream out; + for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i]; + AddUniformCallToTraceStack(location, out.str()); for(int i = 0; i < count; ++i) { @@ -1400,26 +1400,29 @@ public: inline void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) override { - std::string params = ToString(x) + "," + ToString(y) + "," + ToString(z) + "," + ToString(w); + std::string params = std::to_string(x) + "," + std::to_string(y) + "," + std::to_string(z) + "," + std::to_string(w); AddUniformCallToTraceStack(location, params); } inline void Uniform4iv(GLint location, GLsizei count, const GLint* v) override { - std::string params = ToString(v); - AddUniformCallToTraceStack(location, params); + std::ostringstream out; + for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << v[i]; + AddUniformCallToTraceStack(location, out.str()); } inline void UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override { - std::string params = ToString(value); - AddUniformCallToTraceStack(location, params); + std::ostringstream out; + for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << value[i]; + AddUniformCallToTraceStack(location, out.str()); } inline void UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override { - std::string params = ToString(value); - AddUniformCallToTraceStack(location, params); + std::ostringstream out; + for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << value[i]; + AddUniformCallToTraceStack(location, out.str()); for(int i = 0; i < count; ++i) { @@ -1436,8 +1439,9 @@ public: inline void UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) override { - std::string params = ToString(value); - AddUniformCallToTraceStack(location, params); + std::ostringstream out; + for(GLsizei i = 0; i < count; ++i) out << (!i ? "" : ", ") << value[i]; + AddUniformCallToTraceStack(location, out.str()); for(int i = 0; i < count; ++i) { @@ -1493,8 +1497,17 @@ public: { } - inline void VertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) override + inline void VertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr) override { + TraceCallStack::NamedParams namedParams; + namedParams["index"] << index; + namedParams["size"] << size; + namedParams["type"] << std::hex << type; + namedParams["normalized"] << (normalized ? "T" : "F"); + namedParams["stride"] << stride; + namedParams["offset"] << std::to_string(reinterpret_cast(ptr)); + + mBufferTrace.PushCall("VertexAttribPointer", namedParams.str(), namedParams); } inline void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) override @@ -1941,7 +1954,7 @@ public: } private: - inline void AddUniformCallToTraceStack(GLint location, std::string& value) + inline void AddUniformCallToTraceStack(GLint location, const std::string& value) { std::string name = ""; bool matched = false; @@ -1972,9 +1985,9 @@ public: // TEST FUNCTIONS { mLinkStatus = value; } - inline void SetGetAttribLocationResult(int result) + inline void SetAttribLocations(std::vector locs) { - mGetAttribLocationResult = result; + mAttribLocs = locs; } inline void SetGetErrorResult(GLenum result) { @@ -2106,15 +2119,15 @@ public: // TEST FUNCTIONS //Methods for Texture verification inline void EnableTexParameterCallTrace(bool enable) { - mTexParamaterTrace.Enable(enable); + mTexParameterTrace.Enable(enable); } inline void ResetTexParameterCallStack() { - mTexParamaterTrace.Reset(); + mTexParameterTrace.Reset(); } inline TraceCallStack& GetTexParameterTrace() { - return mTexParamaterTrace; + return mTexParameterTrace; } //Methods for Draw verification @@ -2413,7 +2426,6 @@ private: BufferSubDataCalls mBufferSubDataCalls; GLuint mLinkStatus; GLint mNumberOfActiveUniforms; - GLint mGetAttribLocationResult; GLenum mGetErrorResult; GLubyte* mGetStringResult; GLboolean mIsBufferResult; @@ -2438,6 +2450,7 @@ private: bool mGetProgramBinaryCalled; typedef std::map ShaderSourceMap; ShaderSourceMap mShaderSources; + std::vector mAttribLocs; // should be bound to shader GLuint mLastShaderCompiled; GLbitfield mLastClearBitMask; Vector4 mLastClearColor; @@ -2467,12 +2480,12 @@ private: ActiveTextureType mActiveTextures[MIN_TEXTURE_UNIT_LIMIT]; - TraceCallStack mBufferTrace{"gl"}; + TraceCallStack mBufferTrace; TraceCallStack mCullFaceTrace; TraceCallStack mEnableDisableTrace; TraceCallStack mShaderTrace; - TraceCallStack mTextureTrace{"gl"}; - TraceCallStack mTexParamaterTrace; + TraceCallStack mTextureTrace; + TraceCallStack mTexParameterTrace; TraceCallStack mDrawTrace; TraceCallStack mDepthFunctionTrace; TraceCallStack mStencilFunctionTrace; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp index 2696078..90640e5 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-buffer.cpp @@ -15,8 +15,8 @@ */ #include "test-graphics-buffer.h" - #include +#include "dali-test-suite-utils.h" namespace Dali { @@ -53,8 +53,8 @@ void TestGraphicsBuffer::Upload(uint32_t offset, uint32_t size) std::ostringstream o; o << offset << ", " << size; TraceCallStack::NamedParams namedParams; - namedParams["offset"] = offset; - namedParams["size"] = size; + namedParams["offset"] << offset; + namedParams["size"] << size; mCallStack.PushCall("Buffer::Upload", o.str(), namedParams); if(size <= memory.size() && mCreated) { diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp index a32eeef..a0dee4a 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.cpp @@ -28,6 +28,9 @@ void TestGraphicsCommandBuffer::BindVertexBuffers(uint32_t std::vector buffers, std::vector offsets) { + mVertexBufferBindings.firstBinding = firstBinding; + mVertexBufferBindings.buffers = buffers; // Copy + mVertexBufferBindings.offsets = offsets; // Copy mCallStack.PushCall("BindVertexBuffers", ""); } @@ -38,6 +41,7 @@ void TestGraphicsCommandBuffer::BindUniformBuffers(const std::vector(const_cast(&pipeline)); mCallStack.PushCall("BindPipeline", ""); } @@ -66,6 +70,9 @@ void TestGraphicsCommandBuffer::BindIndexBuffer(const Graphics::Buffer& buffer, uint32_t offset, Graphics::Format format) { + mIndexBufferBinding.buffer = &buffer; + mIndexBufferBinding.offset = offset; + mIndexBufferBinding.format = format; mCallStack.PushCall("BindIndexBuffer", ""); } @@ -89,6 +96,11 @@ void TestGraphicsCommandBuffer::Draw( uint32_t firstVertex, uint32_t firstInstance) { + drawCommand.drawType = Draw::DrawType::Unindexed; + drawCommand.u.unindexedDraw.vertexCount = vertexCount; + drawCommand.u.unindexedDraw.instanceCount = instanceCount; + drawCommand.u.unindexedDraw.firstVertex = firstVertex; + drawCommand.u.unindexedDraw.firstInstance = firstInstance; mCallStack.PushCall("Draw", ""); } @@ -99,6 +111,12 @@ void TestGraphicsCommandBuffer::DrawIndexed( int32_t vertexOffset, uint32_t firstInstance) { + drawCommand.drawType = TestGraphicsCommandBuffer::Draw::DrawType::Indexed; + drawCommand.u.indexedDraw.indexCount = indexCount; + drawCommand.u.indexedDraw.instanceCount = instanceCount; + drawCommand.u.indexedDraw.firstIndex = firstIndex; + drawCommand.u.indexedDraw.vertexOffset = vertexOffset; + drawCommand.u.indexedDraw.firstInstance = firstInstance; mCallStack.PushCall("DrawIndexed", ""); } diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.h index bd6c83a..151a9df 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-command-buffer.h @@ -19,10 +19,12 @@ #include #include +#include #include #include #include #include "test-gl-abstraction.h" +#include "test-graphics-pipeline.h" #include "test-trace-call-stack.h" namespace Dali @@ -89,10 +91,53 @@ public: void SetViewportEnable(bool value); public: - TraceCallStack mCallStack; - TestGlAbstraction& mGlAbstraction; - - std::vector mTextureBindings; + TraceCallStack& mCallStack; + TestGlAbstraction& mGlAbstraction; + TestGraphicsPipeline* mPipeline{nullptr}; + std::vector mTextureBindings{}; + + struct VertexBuffersBinding + { + uint32_t firstBinding; + std::vector buffers; + std::vector offsets; + }; + VertexBuffersBinding mVertexBufferBindings{}; + + struct IndexBufferBinding + { + const Graphics::Buffer* buffer; + uint32_t offset; + Graphics::Format format; + }; + IndexBufferBinding mIndexBufferBinding{}; + + struct Draw + { + enum class DrawType + { + Indexed, + Unindexed + } drawType; + union + { + struct IndexedDraw + { + uint32_t indexCount; + uint32_t instanceCount; + uint32_t firstIndex; + int32_t vertexOffset; + uint32_t firstInstance; + } indexedDraw; + struct UnindexedDraw + { + uint32_t vertexCount; + uint32_t instanceCount; + uint32_t firstVertex; + uint32_t firstInstance; + } unindexedDraw; + } u; + } drawCommand; }; } // namespace Dali diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp index e7f80cd..578285b 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.cpp @@ -16,18 +16,42 @@ #include "test-graphics-controller.h" -#include "dali-test-suite-utils.h" #include "test-graphics-buffer.h" #include "test-graphics-command-buffer.h" #include "test-graphics-sampler.h" #include "test-graphics-texture.h" #include +#include #include #include namespace Dali { +template +T* Uncast(const Graphics::CommandBuffer* object) +{ + return const_cast(static_cast(object)); +} + +template +T* Uncast(const Graphics::Texture* object) +{ + return const_cast(static_cast(object)); +} + +template +T* Uncast(const Graphics::Sampler* object) +{ + return const_cast(static_cast(object)); +} + +template +T* Uncast(const Graphics::Buffer* object) +{ + return const_cast(static_cast(object)); +} + std::ostream& operator<<(std::ostream& o, const Graphics::BufferCreateInfo& bufferCreateInfo) { return o << "usage:" << std::hex << bufferCreateInfo.usage << ", size:" << std::dec << bufferCreateInfo.size; @@ -161,7 +185,7 @@ public: if(offset > mMappedOffset + mMappedSize || size + offset > mMappedOffset + mMappedSize) { - tet_infoline("TestGraphics.Memory::LockRegion() Out of bounds"); + fprintf(stderr, "TestGraphics.Memory::LockRegion() Out of bounds"); mBuffer.memory.resize(mMappedOffset + offset + size); // Grow to prevent memcpy from crashing } mLockedOffset = offset; @@ -195,38 +219,127 @@ public: }; TestGraphicsController::TestGraphicsController() +: mCallStack(true, "TestGraphicsController."), + mCommandBufferCallStack(true, "TestCommandBuffer.") { mCallStack.Enable(true); - mCallStack.EnableLogging(true); mCommandBufferCallStack.Enable(true); - mCommandBufferCallStack.EnableLogging(true); - auto& trace = mGlAbstraction.GetTextureTrace(); + auto& trace = mGl.GetTextureTrace(); trace.Enable(true); trace.EnableLogging(true); } +int GetNumComponents(Graphics::VertexInputFormat vertexFormat) +{ + switch(vertexFormat) + { + case Graphics::VertexInputFormat::UNDEFINED: + case Graphics::VertexInputFormat::FLOAT: + case Graphics::VertexInputFormat::INTEGER: + return 1; + case Graphics::VertexInputFormat::IVECTOR2: + case Graphics::VertexInputFormat::FVECTOR2: + return 2; + case Graphics::VertexInputFormat::IVECTOR3: + case Graphics::VertexInputFormat::FVECTOR3: + return 3; + case Graphics::VertexInputFormat::FVECTOR4: + case Graphics::VertexInputFormat::IVECTOR4: + return 4; + } + return 1; +} + +GLint GetSize(Graphics::VertexInputFormat vertexFormat) +{ + switch(vertexFormat) + { + case Graphics::VertexInputFormat::UNDEFINED: + return 1u; + case Graphics::VertexInputFormat::INTEGER: + case Graphics::VertexInputFormat::IVECTOR2: + case Graphics::VertexInputFormat::IVECTOR3: + case Graphics::VertexInputFormat::IVECTOR4: + return 2u; + case Graphics::VertexInputFormat::FLOAT: + case Graphics::VertexInputFormat::FVECTOR2: + case Graphics::VertexInputFormat::FVECTOR3: + case Graphics::VertexInputFormat::FVECTOR4: + return 4u; + } + return 1u; +} + +GLint GetGlType(Graphics::VertexInputFormat vertexFormat) +{ + switch(vertexFormat) + { + case Graphics::VertexInputFormat::UNDEFINED: + return GL_BYTE; + case Graphics::VertexInputFormat::INTEGER: + case Graphics::VertexInputFormat::IVECTOR2: + case Graphics::VertexInputFormat::IVECTOR3: + case Graphics::VertexInputFormat::IVECTOR4: + return GL_SHORT; + case Graphics::VertexInputFormat::FLOAT: + case Graphics::VertexInputFormat::FVECTOR2: + case Graphics::VertexInputFormat::FVECTOR3: + case Graphics::VertexInputFormat::FVECTOR4: + return GL_FLOAT; + } + return GL_BYTE; +} + +GLenum GetTopology(Graphics::PrimitiveTopology topology) +{ + switch(topology) + { + case Graphics::PrimitiveTopology::POINT_LIST: + return GL_POINTS; + + case Graphics::PrimitiveTopology::LINE_LIST: + return GL_LINES; + + case Graphics::PrimitiveTopology::LINE_LOOP: + return GL_LINE_LOOP; + + case Graphics::PrimitiveTopology::LINE_STRIP: + return GL_LINE_STRIP; + + case Graphics::PrimitiveTopology::TRIANGLE_LIST: + return GL_TRIANGLES; + + case Graphics::PrimitiveTopology::TRIANGLE_STRIP: + return GL_TRIANGLE_STRIP; + + case Graphics::PrimitiveTopology::TRIANGLE_FAN: + return GL_TRIANGLE_FAN; + } + return GL_TRIANGLES; +} + void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo) { - std::ostringstream out; TraceCallStack::NamedParams namedParams; - out << "cmdBuffer[" << submitInfo.cmdBuffer.size() << "], flags:" << std::hex << submitInfo.flags; - namedParams["submitInfo"] = out.str(); + namedParams["submitInfo"] << "cmdBuffer[" << submitInfo.cmdBuffer.size() + << "], flags:" << std::hex << submitInfo.flags; mCallStack.PushCall("Controller::SubmitCommandBuffers", "", namedParams); - for(auto& commandBuffer : submitInfo.cmdBuffer) + for(auto& graphicsCommandBuffer : submitInfo.cmdBuffer) { - for(auto& binding : (static_cast(commandBuffer))->mTextureBindings) + auto commandBuffer = Uncast(graphicsCommandBuffer); + for(auto& binding : commandBuffer->mTextureBindings) { if(binding.texture) { - auto texture = const_cast(static_cast(binding.texture)); + auto texture = Uncast(binding.texture); texture->Bind(binding.binding); if(binding.sampler) { - auto sampler = const_cast(static_cast(binding.sampler)); + auto sampler = Uncast(binding.sampler); if(sampler) { sampler->Apply(texture->GetTarget()); @@ -236,6 +349,58 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su texture->Prepare(); // Ensure native texture is ready } } + + // IndexBuffer binding, + auto& indexBufferBinding = commandBuffer->mIndexBufferBinding; + if(indexBufferBinding.buffer) + { + auto buffer = Uncast(indexBufferBinding.buffer); + buffer->Bind(); + } + + // VertexBuffer binding, + for(auto graphicsBuffer : commandBuffer->mVertexBufferBindings.buffers) + { + auto vertexBuffer = Uncast(graphicsBuffer); + vertexBuffer->Bind(); + } + + // Pipeline attribute setup + auto& vi = commandBuffer->mPipeline->vertexInputState; + for(auto& attribute : vi.attributes) + { + mGl.EnableVertexAttribArray(attribute.location); + uint32_t attributeOffset = attribute.offset; + GLsizei stride = vi.bufferBindings[attribute.binding].stride; + + mGl.VertexAttribPointer(attribute.location, + GetNumComponents(attribute.format), + GetGlType(attribute.format), + GL_FALSE, // Not normalized + stride, + reinterpret_cast(attributeOffset)); + } + + // draw call + auto topology = commandBuffer->mPipeline->inputAssemblyState.topology; + + if(commandBuffer->drawCommand.drawType == TestGraphicsCommandBuffer::Draw::DrawType::Indexed) + { + mGl.DrawElements(GetTopology(topology), + static_cast(commandBuffer->drawCommand.u.indexedDraw.indexCount), + GL_UNSIGNED_SHORT, + reinterpret_cast(commandBuffer->drawCommand.u.indexedDraw.firstIndex)); + } + else + { + mGl.DrawArrays(GetTopology(topology), 0, commandBuffer->drawCommand.u.unindexedDraw.vertexCount); + } + + // attribute clear + for(auto& attribute : vi.attributes) + { + mGl.DisableVertexAttribArray(attribute.location); + } } } @@ -245,10 +410,8 @@ void TestGraphicsController::SubmitCommandBuffers(const Graphics::SubmitInfo& su */ void TestGraphicsController::PresentRenderTarget(Graphics::RenderTarget* renderTarget) { - std::ostringstream out; TraceCallStack::NamedParams namedParams; - out << std::hex << renderTarget; - namedParams["renderTarget"] = out.str(); + namedParams["renderTarget"] << std::hex << renderTarget; mCallStack.PushCall("Controller::PresentRenderTarget", "", namedParams); } @@ -279,13 +442,9 @@ void TestGraphicsController::Resume() void TestGraphicsController::UpdateTextures(const std::vector& updateInfoList, const std::vector& sourceList) { - std::ostringstream out; TraceCallStack::NamedParams namedParams; - out << "[" << updateInfoList.size() << "]:"; - namedParams["updateInfoList"] = out.str(); - out.str(""); - out << "[" << sourceList.size() << "]:"; - namedParams["sourceList"] = out.str(); + namedParams["updateInfoList"] << "[" << updateInfoList.size() << "]:"; + namedParams["sourceList"] << "[" << sourceList.size() << "]:"; mCallStack.PushCall("Controller::UpdateTextures", "", namedParams); @@ -304,18 +463,16 @@ void TestGraphicsController::UpdateTextures(const std::vector TestGraphicsController::CreateBuffer(const std::ostringstream oss; oss << "bufferCreateInfo:" << createInfo; mCallStack.PushCall("Controller::CreateBuffer", oss.str()); - return Graphics::MakeUnique(mCallStack, mGlAbstraction, createInfo.size, createInfo.usage); + return Graphics::MakeUnique(mCallStack, mGl, createInfo.size, createInfo.usage); } Graphics::UniquePtr TestGraphicsController::CreateCommandBuffer(const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo, Graphics::UniquePtr&& oldCommandBuffer) @@ -354,7 +511,7 @@ Graphics::UniquePtr TestGraphicsController::CreateComma std::ostringstream oss; oss << "commandBufferCreateInfo:" << commandBufferCreateInfo; mCallStack.PushCall("Controller::CreateCommandBuffer", oss.str()); - return Graphics::MakeUnique(mCommandBufferCallStack, mGlAbstraction); + return Graphics::MakeUnique(mCommandBufferCallStack, mGl); } Graphics::UniquePtr TestGraphicsController::CreateRenderPass(const Graphics::RenderPassCreateInfo& renderPassCreateInfo, Graphics::UniquePtr&& oldRenderPass) @@ -365,14 +522,11 @@ Graphics::UniquePtr TestGraphicsController::CreateRenderPa Graphics::UniquePtr TestGraphicsController::CreateTexture(const Graphics::TextureCreateInfo& textureCreateInfo, Graphics::UniquePtr&& oldTexture) { - std::ostringstream params, oss; - params << "textureCreateInfo:" << textureCreateInfo; TraceCallStack::NamedParams namedParams; - oss << textureCreateInfo; - namedParams["textureCreateInfo"] = oss.str(); - mCallStack.PushCall("Controller::CreateTexture", params.str(), namedParams); + namedParams["textureCreateInfo"] << textureCreateInfo; + mCallStack.PushCall("Controller::CreateTexture", namedParams.str(), namedParams); - return Graphics::MakeUnique(mGlAbstraction, textureCreateInfo); + return Graphics::MakeUnique(mGl, textureCreateInfo); } Graphics::UniquePtr TestGraphicsController::CreateFramebuffer(const Graphics::FramebufferCreateInfo& framebufferCreateInfo, Graphics::UniquePtr&& oldFramebuffer) @@ -384,7 +538,7 @@ Graphics::UniquePtr TestGraphicsController::CreateFramebu Graphics::UniquePtr TestGraphicsController::CreatePipeline(const Graphics::PipelineCreateInfo& pipelineCreateInfo, Graphics::UniquePtr&& oldPipeline) { mCallStack.PushCall("Controller::CreatePipeline", ""); - return nullptr; + return std::make_unique(mGl, pipelineCreateInfo); } Graphics::UniquePtr TestGraphicsController::CreateShader(const Graphics::ShaderCreateInfo& shaderCreateInfo, Graphics::UniquePtr&& oldShader) @@ -395,14 +549,11 @@ Graphics::UniquePtr TestGraphicsController::CreateShader(const Graphics::UniquePtr TestGraphicsController::CreateSampler(const Graphics::SamplerCreateInfo& samplerCreateInfo, Graphics::UniquePtr&& oldSampler) { - std::ostringstream params, oss; - params << "samplerCreateInfo:" << samplerCreateInfo; TraceCallStack::NamedParams namedParams; - oss << samplerCreateInfo; - namedParams["samplerCreateInfo"] = oss.str(); - mCallStack.PushCall("Controller::CreateSampler", params.str(), namedParams); + namedParams["samplerCreateInfo"] << samplerCreateInfo; + mCallStack.PushCall("Controller::CreateSampler", namedParams.str(), namedParams); - return Graphics::MakeUnique(mGlAbstraction, samplerCreateInfo); + return Graphics::MakeUnique(mGl, samplerCreateInfo); } Graphics::UniquePtr TestGraphicsController::CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, Graphics::UniquePtr&& oldRenderTarget) diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h index f218134..e39c1a5 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-controller.h @@ -43,12 +43,12 @@ public: void Initialize() { - mGlAbstraction.Initialize(); + mGl.Initialize(); } Integration::GlAbstraction& GetGlAbstraction() override { - return mGlAbstraction; + return mGl; } Integration::GlSyncAbstraction& GetGlSyncAbstraction() override @@ -276,10 +276,10 @@ public: bool PipelineEquals(const Graphics::Pipeline& pipeline0, const Graphics::Pipeline& pipeline1) const override; public: - mutable TraceCallStack mCallStack{"TestGraphics:"}; - mutable TraceCallStack mCommandBufferCallStack{"TestCommandBuffer:"}; + mutable TraceCallStack mCallStack; + mutable TraceCallStack mCommandBufferCallStack; - TestGlAbstraction mGlAbstraction; + TestGlAbstraction mGl; TestGlSyncAbstraction mGlSyncAbstraction; TestGlContextHelperAbstraction mGlContextHelperAbstraction; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-pipeline.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-pipeline.cpp new file mode 100644 index 0000000..0cc4194 --- /dev/null +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-pipeline.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2021 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "test-graphics-pipeline.h" + +namespace Dali +{ +TestGraphicsPipeline::TestGraphicsPipeline(TestGlAbstraction& gl, const Graphics::PipelineCreateInfo& createInfo) +: mGl(gl) +{ + // Need to deep copy, otherwise pointed at memory will go out of scope. Probably should do something about this. + + if(createInfo.colorBlendState) + colorBlendState = *createInfo.colorBlendState; + + if(createInfo.shaderState) + shaderState = *createInfo.shaderState; + + if(createInfo.viewportState) + viewportState = *createInfo.viewportState; + + if(createInfo.framebufferState) + framebufferState = *createInfo.framebufferState; + + if(createInfo.depthStencilState) + depthStencilState = *createInfo.depthStencilState; + + if(createInfo.rasterizationState) + rasterizationState = *createInfo.rasterizationState; + + if(createInfo.vertexInputState) + vertexInputState = *createInfo.vertexInputState; + + if(createInfo.inputAssemblyState) + inputAssemblyState = *createInfo.inputAssemblyState; + + if(createInfo.dynamicStateMask) + dynamicStateMask = createInfo.dynamicStateMask; +} + +} // namespace Dali diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-pipeline.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-pipeline.h new file mode 100644 index 0000000..666e0d4 --- /dev/null +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-graphics-pipeline.h @@ -0,0 +1,47 @@ +#ifndef DALI_TEST_GRAPHICS_PIPELINE_H +#define DALI_TEST_GRAPHICS_PIPELINE_H + +/* + * Copyright (c) 2021 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "test-gl-abstraction.h" + +namespace Dali +{ +class TestGraphicsPipeline : public Graphics::Pipeline +{ +public: + TestGraphicsPipeline(TestGlAbstraction& gl, const Graphics::PipelineCreateInfo& createInfo); + + TestGlAbstraction& mGl; + + Graphics::ColorBlendState colorBlendState; + std::vector shaderState; + Graphics::ViewportState viewportState; + Graphics::FramebufferState framebufferState; + Graphics::Pipeline basePipeline; + Graphics::DepthStencilState depthStencilState; + Graphics::RasterizationState rasterizationState; + Graphics::VertexInputState vertexInputState; + Graphics::InputAssemblyState inputAssemblyState; + Graphics::PipelineDynamicStateMask dynamicStateMask{0u}; +}; + +} // namespace Dali + +#endif //DALI_TEST_GRAPHICS_PIPELINE_H diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp index dd063ed..9e4efe8 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.cpp @@ -48,6 +48,14 @@ std::string ToString(float x) */ TraceCallStack::TraceCallStack(std::string prefix) : mTraceActive(false), + mLogging(false), + mPrefix(prefix) +{ +} + +TraceCallStack::TraceCallStack(bool logging, std::string prefix) +: mTraceActive(false), + mLogging(logging), mPrefix(prefix) { } @@ -209,6 +217,10 @@ int32_t TraceCallStack::FindIndexFromMethodAndParams(std::string method, std::st break; } } + if(index == -1) + { + fprintf(stderr, "Search for %s(%s) failed\n", method.c_str(), params.c_str()); + } return index; } @@ -221,10 +233,14 @@ int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const Trace { // Test each of the passed in parameters: bool match = true; - for(NamedParams::const_iterator iter = params.begin(); iter != params.end(); ++iter) + + for(auto iter = params.mParams.begin(); iter != params.mParams.end(); ++iter) { - NamedParams::const_iterator paramIter = mCallStack[i].namedParams.find(iter->first); - if(paramIter == params.end() || paramIter->second.compare(iter->second) != 0) + auto paramIter = mCallStack[i].namedParams.find(iter->parameterName); + std::string value = paramIter->value.str(); + std::string iValue = iter->value.str(); + + if(paramIter == mCallStack[i].namedParams.end() || value.compare(iValue)) { match = false; break; @@ -237,6 +253,12 @@ int TraceCallStack::FindIndexFromMethodAndParams(std::string method, const Trace } } } + + if(index == -1) + { + fprintf(stderr, "Search for %s(%s) failed\n", method.c_str(), params.str().c_str()); + } + return index; } diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h index cbbdd14..6b78c86 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-trace-call-stack.h @@ -42,12 +42,102 @@ class TraceCallStack { public: /// Typedef for passing and storing named parameters - typedef std::map NamedParams; + class NamedParams + { + public: + struct NameValue + { + std::string parameterName; + std::ostringstream value; + NameValue(std::string pname, std::string aValue) + : parameterName(pname), + value(aValue) + { + } + NameValue(const NameValue& rhs) + : parameterName(rhs.parameterName), + value(rhs.value.str()) + { + } + NameValue& operator=(const NameValue& rhs) + { + if(this != &rhs) + { + this->parameterName = rhs.parameterName; + this->value.str(rhs.value.str()); + } + return *this; + } + + bool operator==(const NameValue& rhs) + { + return !parameterName.compare(rhs.parameterName) && !value.str().compare(rhs.value.str()); + } + }; + + auto find(const std::string& param) const + { + auto iter = mParams.begin(); + for(; iter != mParams.end(); ++iter) + { + if(!iter->parameterName.compare(param)) + { + break; + } + } + return iter; + } + + auto begin() const + { + return mParams.begin(); + } + auto end() const + { + return mParams.end(); + } + + std::ostringstream& operator[](std::string name) + { + auto iter = mParams.begin(); + for(; iter != mParams.end(); ++iter) + { + if(!iter->parameterName.compare(name)) + { + break; + } + } + + if(iter != mParams.end()) + { + return iter->value; + } + else + { + mParams.push_back(NameValue(name, "")); + return mParams.back().value; + } + } + + std::string str() const + { + std::ostringstream out; + bool first = true; + for(auto& elem : mParams) + { + out << (first ? "" : " ") << elem.parameterName << ": " << elem.value.str(); + first = false; + } + return out.str(); + } + std::vector mParams{}; + }; /** * Constructor */ - TraceCallStack(std::string prefix = ""); + TraceCallStack(std::string prefix = "gl"); + TraceCallStack(bool logging, std::string prefix = "gl"); /** * Destructor diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp index 25d83ba..9276f50 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageAtlas.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -241,30 +241,32 @@ int UtcDaliImageAtlasUploadP(void) DALI_TEST_EQUALS( pixelArea1.height, 34, TEST_LOCATION ); TraceCallStack::NamedParams params; - params["width"] = ToString(pixelArea1.width); - params["height"] = ToString(pixelArea1.height); - params["xoffset"] = ToString(pixelArea1.x); - params["yoffset"] = ToString(pixelArea1.y); + params["width"] < pixelArea2 = TextureCoordinateToPixelArea(textureRect2, size); DALI_TEST_EQUALS( pixelArea2.width, 50, TEST_LOCATION ); DALI_TEST_EQUALS( pixelArea2.height, 50, TEST_LOCATION ); - params["width"] = ToString(pixelArea2.width); - params["height"] = ToString(pixelArea2.height); - params["xoffset"] = ToString(pixelArea2.x); - params["yoffset"] = ToString(pixelArea2.y); + params.mParams.clear(); + params["width"] < pixelArea3 = TextureCoordinateToPixelArea(textureRect3, size); DALI_TEST_EQUALS( pixelArea3.width, 128, TEST_LOCATION ); DALI_TEST_EQUALS( pixelArea3.height, 128, TEST_LOCATION ); - params["width"] = ToString(pixelArea3.width); - params["height"] = ToString(pixelArea3.height); - params["xoffset"] = ToString(pixelArea3.x); - params["yoffset"] = ToString(pixelArea3.y); + params.mParams.clear(); + params["width"] <