[Tizen] Revert "Support for recognizing legacy shaders." 64/311364/1 accepted/tizen_unified accepted/tizen_unified_x tizen accepted/tizen/unified/20240520.131902 accepted/tizen/unified/x/20240521.022232
authorEunki, Hong <eunkiki.hong@samsung.com>
Mon, 20 May 2024 05:31:59 +0000 (14:31 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Mon, 20 May 2024 05:32:03 +0000 (14:32 +0900)
This reverts commit 45d64aa2c47f7c9a0a8a9a411ddf2924f7404e85.

Change-Id: I5a712a32733f010e31538886534b019872089fa3

automated-tests/src/dali-internal/CMakeLists.txt
automated-tests/src/dali-internal/utc-Dali-Internal-Shader.cpp [deleted file]
dali/graphics-api/graphics-shader-create-info.h
dali/integration-api/file.list
dali/integration-api/testing.cpp [deleted file]
dali/integration-api/testing.h [deleted file]
dali/internal/common/shader-data.h
dali/internal/event/rendering/shader-impl.cpp
dali/internal/event/rendering/shader-impl.h
dali/internal/render/renderers/render-renderer.cpp

index 8247542..1a85735 100644 (file)
@@ -28,7 +28,6 @@ SET(TC_SOURCES
         utc-Dali-Internal-PinchGestureProcessor.cpp
         utc-Dali-Internal-PipelineCache.cpp
         utc-Dali-Internal-RotationGesture.cpp
-        utc-Dali-Internal-Shader.cpp
         utc-Dali-Internal-TapGesture.cpp
         utc-Dali-Internal-TapGestureProcessor.cpp
         utc-Dali-Internal-Texture.cpp
diff --git a/automated-tests/src/dali-internal/utc-Dali-Internal-Shader.cpp b/automated-tests/src/dali-internal/utc-Dali-Internal-Shader.cpp
deleted file mode 100644 (file)
index ec9cfa9..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-* 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.
-* 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 <dali-test-suite-utils.h>
-#include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
-#include <dali/internal/event/common/thread-local-storage.h>
-#include <dali/internal/event/effects/shader-factory.h>
-#include <dali/internal/event/rendering/shader-impl.h>
-#include <dali/internal/update/manager/update-manager.h>
-#include <dali/public-api/dali-core.h>
-#include <dali/public-api/object/type-registry.h>
-
-using namespace Dali;
-
-int UtcDaliShaderTestVersion(void)
-{
-  TestApplication application;
-
-  std::string vertexShader =
-    "//@version 100\n"
-    "some code\n";
-  std::string fragmentShader =
-    "//@version 101\n"
-    "some code\n";
-
-  Dali::Shader shader = Dali::Shader::New(vertexShader, fragmentShader);
-  {
-    auto vertexPrefix   = Dali::Shader::GetVertexShaderPrefix();
-    auto fragmentPrefix = Dali::Shader::GetFragmentShaderPrefix();
-
-    DALI_TEST_EQUALS(vertexPrefix.substr(0, 20), "//@legacy-prefix-end", TEST_LOCATION);
-    DALI_TEST_EQUALS(fragmentPrefix.substr(0, 20), "//@legacy-prefix-end", TEST_LOCATION);
-  }
-
-  // Test version number in the shader data
-  Dali::Internal::ThreadLocalStorage& tls           = Dali::Internal::ThreadLocalStorage::Get();
-  Dali::Internal::ShaderFactory&      shaderFactory = tls.GetShaderFactory();
-  size_t                              shaderHash;
-  Internal::ShaderDataPtr             shaderData = shaderFactory.Load(vertexShader, fragmentShader, {}, {}, "", shaderHash);
-
-  bool dataValid = (shaderData != nullptr);
-  DALI_TEST_EQUALS(dataValid, true, TEST_LOCATION);
-
-  DALI_TEST_EQUALS(shaderData->GetVertexShaderVersion(), 100, TEST_LOCATION);
-  DALI_TEST_EQUALS(shaderData->GetFragmentShaderVersion(), 101, TEST_LOCATION);
-
-  END_TEST;
-}
-
-int UtcDaliShaderWithPrefixTestVersion(void)
-{
-  TestApplication application;
-
-  std::string vertexShader =
-    "//@version 100\n"
-    "some code\n";
-  std::string fragmentShader =
-    "//@version 101\n"
-    "some code\n";
-
-  auto vertexPrefix   = Dali::Shader::GetVertexShaderPrefix();
-  auto fragmentPrefix = Dali::Shader::GetFragmentShaderPrefix();
-
-  Dali::Shader shader = Dali::Shader::New(
-    vertexPrefix + vertexShader,
-    fragmentPrefix + fragmentShader);
-
-  DALI_TEST_EQUALS(vertexPrefix.substr(0, 20), "//@legacy-prefix-end", TEST_LOCATION);
-  DALI_TEST_EQUALS(fragmentPrefix.substr(0, 20), "//@legacy-prefix-end", TEST_LOCATION);
-
-  // Test version number in the shader data
-  Dali::Internal::ThreadLocalStorage& tls           = Dali::Internal::ThreadLocalStorage::Get();
-  Dali::Internal::ShaderFactory&      shaderFactory = tls.GetShaderFactory();
-  size_t                              shaderHash;
-  Internal::ShaderDataPtr             shaderData = shaderFactory.Load(vertexShader, fragmentShader, {}, {}, "", shaderHash);
-
-  bool dataValid = (shaderData != nullptr);
-  DALI_TEST_EQUALS(dataValid, true, TEST_LOCATION);
-
-  DALI_TEST_EQUALS(shaderData->GetVertexShaderVersion(), 100, TEST_LOCATION);
-  DALI_TEST_EQUALS(shaderData->GetFragmentShaderVersion(), 101, TEST_LOCATION);
-
-  END_TEST;
-}
\ No newline at end of file
index 24cbfcf..2476c79 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_GRAPHICS_SHADER_CREATE_INFO_H
 
 /*
- * Copyright (c) 2024 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.
@@ -117,18 +117,6 @@ struct ShaderCreateInfo
   }
 
   /**
-   * @brief Sets shader code DALi-specific version
-   *
-   * @param[in] value shader version
-   * @return reference to this structure
-   */
-  auto& SetShaderVersion(uint32_t value)
-  {
-    shaderVersion = value;
-    return *this;
-  }
-
-  /**
    * @brief Sets allocation callbacks which will be used when object is created
    * and destroyed.
    *
@@ -160,7 +148,6 @@ struct ShaderCreateInfo
   const void*      sourceData{nullptr};
   uint32_t         sourceSize{0u};
   ShaderSourceMode sourceMode{};
-  uint32_t         shaderVersion{};
 
   const AllocationCallbacks* allocationCallbacks{nullptr};
 };
index bf08a16..7b6dc9a 100644 (file)
@@ -13,7 +13,6 @@ SET( platform_abstraction_src_files
    ${platform_abstraction_src_dir}/profiling.cpp
    ${platform_abstraction_src_dir}/render-task-list-integ.cpp
    ${platform_abstraction_src_dir}/scene.cpp
-   ${platform_abstraction_src_dir}/testing.cpp
    ${platform_abstraction_src_dir}/texture-integ.cpp
    ${platform_abstraction_src_dir}/trace.cpp
 )
@@ -53,7 +52,6 @@ SET( platform_abstraction_header_files
    ${platform_abstraction_src_dir}/resource-policies.h
    ${platform_abstraction_src_dir}/resource-types.h
    ${platform_abstraction_src_dir}/scene.h
-   ${platform_abstraction_src_dir}/testing.h
    ${platform_abstraction_src_dir}/texture-integ.h
    ${platform_abstraction_src_dir}/trace.h
 )
diff --git a/dali/integration-api/testing.cpp b/dali/integration-api/testing.cpp
deleted file mode 100644 (file)
index 5b916b4..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-* 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.
-* 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 <dali/integration-api/testing.h>
-#include <dali/internal/event/rendering/shader-impl.h>
-
-namespace Dali
-{
-namespace Integration
-{
-namespace Test
-{
-std::string GenerateTaggedShaderPrefix(std::string prefix)
-{
-  return Internal::Shader::GenerateTaggedShaderPrefix(prefix);
-}
-} // Namespace Test
-} // Namespace Integration
-} // Namespace Dali
diff --git a/dali/integration-api/testing.h b/dali/integration-api/testing.h
deleted file mode 100644 (file)
index ea2c993..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef DALI_INTEGRATION_TESTING_H
-#define DALI_INTEGRATION_TESTING_H
-
-/*
- * 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.
- * 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 <string>
-
-namespace Dali
-{
-namespace Integration
-{
-/**
- * This functions should be used only within automated tests suit
- */
-namespace Test
-{
-/**
- * @brief Generates internal tag for shader prefix
- * @param[in] prefix Prefix to generate tag for
- * @return Tagged prefix
- */
-std::string GenerateTaggedShaderPrefix(std::string prefix);
-
-} // Namespace Test
-} // Namespace Integration
-} // Namespace Dali
-
-#endif
\ No newline at end of file
index f52accd..10e58b4 100644 (file)
@@ -72,8 +72,6 @@ public:
     mRenderPassTag(renderPassTag),
     mName(name)
   {
-    UpdateShaderVersion(mVertexShader, mVertexShaderVersion);
-    UpdateShaderVersion(mFragmentShader, mFragmentShaderVersion);
   }
 
   /**
@@ -93,8 +91,6 @@ public:
     mRenderPassTag(renderPassTag),
     mName(name)
   {
-    UpdateShaderVersion(mVertexShader, mVertexShaderVersion);
-    UpdateShaderVersion(mFragmentShader, mFragmentShaderVersion);
   }
 
   /**
@@ -114,8 +110,6 @@ public:
     mRenderPassTag(renderPassTag),
     mName(name)
   {
-    UpdateShaderVersion(mVertexShader, mVertexShaderVersion);
-    UpdateShaderVersion(mFragmentShader, mFragmentShaderVersion);
   }
 
   /**
@@ -282,66 +276,19 @@ public: // API
     return mName;
   }
 
-  /**
-   * Returns DALi specific vertex shader version
-   * @return valid version number
-   */
-  uint32_t GetVertexShaderVersion() const
-  {
-    return mVertexShaderVersion;
-  }
-
-  /**
-   * Returns DALi specific fragment shader version
-   * @return valid version number
-   */
-  uint32_t GetFragmentShaderVersion() const
-  {
-    return mFragmentShaderVersion;
-  }
-
 private:                                        // Not implemented
   ShaderData(const ShaderData& other);          ///< no copying of this object
   ShaderData& operator=(const ShaderData& rhs); ///< no copying of this object
 
-private:
-  /**
-   * Updates shader version.
-   */
-  void UpdateShaderVersion(std::vector<char>& code, uint32_t& outVersion)
-  {
-    // The version may be updated only for GLSL language.
-    // If we support direct SPIRV this will be skipped
-    std::string_view strView = code.data();
-
-    // find first occurence of 'version' tag
-    // the tag is expected at the start of line
-    static const std::string VERSION_TAG = "//@version";
-
-    auto pos = strView.find(VERSION_TAG);
-    if(pos != std::string_view::npos && (pos == 0 || strView[pos - 1] == '\n'))
-    {
-      char* end;
-      // Update version
-      outVersion = std::strtoul(strView.data() + pos + VERSION_TAG.length(), &end, 10);
-    }
-    else
-    {
-      outVersion = 0;
-    }
-  }
-
-private:                                             // Data
-  std::size_t                mShaderHash;            ///< hash key created with vertex and fragment shader code
-  std::vector<char>          mVertexShader;          ///< source code for vertex program
-  std::vector<char>          mFragmentShader;        ///< source code for fragment program
-  Dali::Shader::Hint::Value  mHints;                 ///< take a hint
-  Dali::Vector<uint8_t>      mBuffer;                ///< buffer containing compiled binary bytecode
-  Graphics::ShaderSourceMode mSourceMode;            ///< Source mode of shader data ( text or binary )
-  uint32_t                   mRenderPassTag{0u};     ///< Render Pass Tag for this shader
-  std::string                mName{""};              ///< Name for this shader
-  uint32_t                   mVertexShaderVersion;   ///< Vertex shader version
-  uint32_t                   mFragmentShaderVersion; ///< Fragment shader version
+private:                                         // Data
+  std::size_t                mShaderHash;        ///< hash key created with vertex and fragment shader code
+  std::vector<char>          mVertexShader;      ///< source code for vertex program
+  std::vector<char>          mFragmentShader;    ///< source code for fragment program
+  Dali::Shader::Hint::Value  mHints;             ///< take a hint
+  Dali::Vector<uint8_t>      mBuffer;            ///< buffer containing compiled binary bytecode
+  Graphics::ShaderSourceMode mSourceMode;        ///< Source mode of shader data ( text or binary )
+  uint32_t                   mRenderPassTag{0u}; ///< Render Pass Tag for this shader
+  std::string                mName{""};          ///< Name for this shader
 };
 
 } // namespace Internal
index 76e1e04..de3c95e 100644 (file)
@@ -343,33 +343,13 @@ std::string Shader::GetShaderVersionPrefix()
 std::string Shader::GetVertexShaderPrefix()
 {
   Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get();
-  return GenerateTaggedShaderPrefix(tls.GetVertexShaderPrefix());
+  return tls.GetVertexShaderPrefix();
 }
 
 std::string Shader::GetFragmentShaderPrefix()
 {
   Dali::Internal::ThreadLocalStorage& tls = Dali::Internal::ThreadLocalStorage::Get();
-  return GenerateTaggedShaderPrefix(tls.GetFragmentShaderPrefix());
-}
-
-std::string Shader::GenerateTaggedShaderPrefix(const std::string& shaderPrefix)
-{
-  // The tag is added at the top of vertex/fragment shader and
-  // contains an offset where the source code starts after
-  // the prefix.
-  // This offset is used later by the graphics backend to ignore
-  // the legacy prefix if provided with new versioned shader.
-  // When shader contains tagged prefix, then it starts with:
-  // "//@legacy-prefix-end <offset>" tag.
-  static const std::string TAG           = "//@legacy-prefix-end ";
-  const uint32_t           OFFSET_DIGITS = 5; // offset allocates 5 digits
-
-  auto prefix       = std::string(TAG + "00000\n") + shaderPrefix;
-  auto prefixLength = prefix.length();
-  char tmp          = *(prefix.data() + TAG.length() + OFFSET_DIGITS);
-  std::snprintf(prefix.data() + TAG.size(), OFFSET_DIGITS + 1, "%05d", int(prefixLength));
-  *(prefix.data() + TAG.length() + OFFSET_DIGITS) = tmp;
-  return prefix;
+  return tls.GetFragmentShaderPrefix();
 }
 
 } // namespace Internal
index 0f597d1..ccde312 100644 (file)
@@ -141,14 +141,6 @@ public:
    * @copydoc Dali::Shader::GetFragmentShaderPrefix()
    */
   static std::string GetFragmentShaderPrefix();
-
-public:
-  /**
-   * Generates tag 'legacy-prefix-end' with end position of
-   * prefix text to make shader code parsing easier.
-   * Function is public to be testable
-   */
-  static std::string GenerateTaggedShaderPrefix(const std::string& shaderPrefix);
 };
 
 } // namespace Internal
index 975664a..4320a43 100644 (file)
@@ -421,7 +421,6 @@ Program* Renderer::PrepareProgram(const SceneGraph::RenderInstruction& instructi
     const std::vector<char>& vertexShaderSrc = shaderData->GetShaderForPipelineStage(Graphics::PipelineStage::VERTEX_SHADER);
     vertexShaderCreateInfo.SetSourceSize(vertexShaderSrc.size());
     vertexShaderCreateInfo.SetSourceData(static_cast<const void*>(vertexShaderSrc.data()));
-    vertexShaderCreateInfo.SetShaderVersion(shaderData->GetVertexShaderVersion());
     auto vertexShader = mGraphicsController->CreateShader(vertexShaderCreateInfo, nullptr);
 
     Graphics::ShaderCreateInfo fragmentShaderCreateInfo;
@@ -430,7 +429,6 @@ Program* Renderer::PrepareProgram(const SceneGraph::RenderInstruction& instructi
     const std::vector<char>& fragmentShaderSrc = shaderData->GetShaderForPipelineStage(Graphics::PipelineStage::FRAGMENT_SHADER);
     fragmentShaderCreateInfo.SetSourceSize(fragmentShaderSrc.size());
     fragmentShaderCreateInfo.SetSourceData(static_cast<const void*>(fragmentShaderSrc.data()));
-    fragmentShaderCreateInfo.SetShaderVersion(shaderData->GetFragmentShaderVersion());
     auto fragmentShader = mGraphicsController->CreateShader(fragmentShaderCreateInfo, nullptr);
 
     std::vector<Graphics::ShaderState> shaderStates{
@@ -492,8 +490,9 @@ bool Renderer::Render(Graphics::CommandBuffer&                             comma
     mRenderCallbackInput->usingOwnEglContext = isolatedNotDirect;
     // Set storage for the context to be used
     info.glesNativeInfo.eglSharedContextStoragePointer = &mRenderCallbackInput->eglContext;
-    info.executionMode                                 = isolatedNotDirect ? Graphics::DrawNativeExecutionMode::ISOLATED : Graphics::DrawNativeExecutionMode::DIRECT;
-    info.reserved                                      = nullptr;
+    info.executionMode = isolatedNotDirect ?
+                         Graphics::DrawNativeExecutionMode::ISOLATED : Graphics::DrawNativeExecutionMode::DIRECT;
+    info.reserved = nullptr;
 
     auto& textureResources = mRenderCallback->GetTextureResources();