Submit render calls from update to graphics
authoradam.b <jsr184@gmail.com>
Wed, 31 Jan 2018 16:37:25 +0000 (16:37 +0000)
committeradam.b <jsr184@gmail.com>
Wed, 14 Feb 2018 15:25:57 +0000 (15:25 +0000)
Change-Id: I78631d0e481e8543578336c73dd873b9ca71b49f

34 files changed:
automated-tests/src/dali-graphics/CMakeLists.txt
build/tizen-cmake/CMakeLists.txt
build/tizen-cmake/dali-core.pc.in
build/tizen/configure.ac
build/tizen/dali-core-cxx03.pc.in
build/tizen/dali-core.pc.in
dali/graphics-api/graphics-api-buffer.h [new file with mode: 0644]
dali/graphics-api/graphics-api-controller.h
dali/graphics-api/graphics-api-frame.h [new file with mode: 0644]
dali/graphics-api/graphics-api-generic-buffer.h
dali/graphics-api/graphics-api-render-command.h [new file with mode: 0644]
dali/graphics-api/utility/graphics-asserts.h [moved from dali/graphics/utility/graphics-asserts.h with 96% similarity]
dali/graphics-api/utility/utility-builder.h [new file with mode: 0644]
dali/graphics-api/utility/utility-queue.h [moved from dali/graphics/utility/utility-queue.h with 99% similarity]
dali/graphics-api/utility/utility-strong-type.h [new file with mode: 0644]
dali/graphics-api/utility/utility-synchronized.h [moved from dali/graphics/utility/utility-synchronized.h with 96% similarity]
dali/graphics-api/utility/utility-traits.h [new file with mode: 0644]
dali/graphics/file.list
dali/graphics/graphics-controller.h
dali/graphics/vulkan/vulkan-framebuffer.cpp
dali/graphics/vulkan/vulkan-framebuffer.h
dali/graphics/vulkan/vulkan-graphics-controller.cpp [new file with mode: 0644]
dali/graphics/vulkan/vulkan-graphics-controller.h [new file with mode: 0644]
dali/graphics/vulkan/vulkan-image.cpp
dali/graphics/vulkan/vulkan-image.h
dali/graphics/vulkan/vulkan-standalone-test.cpp
dali/integration-api/graphics/graphics.cpp
dali/integration-api/graphics/graphics.h
dali/internal/common/core-impl.cpp
dali/internal/file.list
dali/internal/update/graphics/graphics-algorithms.cpp [new file with mode: 0644]
dali/internal/update/graphics/graphics-algorithms.h [new file with mode: 0644]
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h

index 97d0e80..82c94a2 100644 (file)
@@ -34,7 +34,7 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
      dali-core
 )
 
-SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${${CAPI_LIB}_CFLAGS_OTHER} -O0 -ggdb --coverage -Wall -Werror -std=c++11 ")
+SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${${CAPI_LIB}_CFLAGS_OTHER} -O0 -ggdb --coverage -Wall -Werror -std=c++14 ")
 
 FOREACH(directory ${${CAPI_LIB}_LIBRARY_DIRS})
     SET(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -L${directory}")
index baf23b0..ee54822 100644 (file)
@@ -70,8 +70,8 @@ if(CMAKE_BUILD_TYPE MATCHES Debug)
 ENDIF()
 
 # Set up compiler flags and warnings
-#ADD_COMPILE_OPTIONS( -std=c++11 -ggdb )
-ADD_COMPILE_OPTIONS( -std=c++11 -gdwarf-4 )
+#ADD_COMPILE_OPTIONS( -std=c++14 -ggdb )
+ADD_COMPILE_OPTIONS( -std=c++14 -gdwarf-4 )
 ADD_COMPILE_OPTIONS( -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast )
 ADD_COMPILE_OPTIONS( -Werror -Wall -Wextra -Wno-unused-parameter -Wfloat-equal )
 
index b6ff02d..7075465 100644 (file)
@@ -9,4 +9,4 @@ Description: Cross platform 3D Engine
 Version: ${apiversion}
 Requires:
 Libs: -L${libdir} -ldali-core
-Cflags: -I${includedir} -std=c++11
+Cflags: -I${includedir} -std=c++14
index a71ef82..2d6ba55 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2017 Samsung Electronics Co., Ltd.
+# Copyright (c) 2018 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.
@@ -33,7 +33,7 @@ AC_SUBST(DALI_VERSION)
 DALI_CFLAGS=-DPLATFORM_TIZEN
 
 # Use C++ 11
-DALI_CFLAGS="$DALI_CFLAGS -std=c++11 -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast -Werror -Wall -Wextra -Wno-unused-parameter -Wfloat-equal"
+DALI_CFLAGS="$DALI_CFLAGS -std=c++14 -Wnon-virtual-dtor -Woverloaded-virtual -Wold-style-cast -Werror -Wall -Wextra -Wno-unused-parameter -Wfloat-equal"
 
 AC_ARG_ENABLE(exportall,
               [AC_HELP_STRING([--enable-exportall],
index 31f09d2..e4a43d5 100644 (file)
@@ -9,4 +9,4 @@ Description: Cross platform 3D Engine
 Version: ${apiversion}
 Requires:
 Libs: -L${libdir} -ldali-core-cxx03
-Cflags: -I${includedir} -std=c++11
+Cflags: -I${includedir} -std=c++14
index f04c7b6..e974fdd 100644 (file)
@@ -9,4 +9,4 @@ Description: Cross platform 3D Engine
 Version: ${apiversion}
 Requires:
 Libs: -L${libdir} -ldali-core
-Cflags: -I${includedir} -std=c++11
+Cflags: -I${includedir} -std=c++14
diff --git a/dali/graphics-api/graphics-api-buffer.h b/dali/graphics-api/graphics-api-buffer.h
new file mode 100644 (file)
index 0000000..8885a15
--- /dev/null
@@ -0,0 +1,71 @@
+#ifndef DALI_GRAPHICS_API_BUFFER_H
+#define DALI_GRAPHICS_API_BUFFER_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+/**
+ * @brief Interface class for Buffer types in the graphics API.
+ */
+class Buffer
+{
+public:
+  /**
+   * @brief Usage of the buffer
+   */
+  enum class UsageHint
+  {
+    FRAME_CONSTANTS,
+    PRIMITIVE_UNIFORMS,
+    ATTRIBUTES,
+    INSTANCE,
+    INDEX_BUFFER,
+  };
+
+  // not copyable
+  Buffer(const Buffer&) = delete;
+  Buffer& operator=(const Buffer&) = delete;
+
+  virtual ~Buffer() = default;
+
+ // TODO: @todo GetHints
+  size_t GetSize() const;
+  void* GetData();
+
+protected:
+  // derived types should not be moved direcly to prevent slicing
+  Buffer(Buffer&&) = default;
+  Buffer& operator=(Buffer&&) = default;
+
+  /**
+   * Objects of this type should not directly.
+   */
+  Buffer() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_BUFFER_H
index cfb48d0..0bd9690 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_GRAPHICS_API_CONTROLLER_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
  *
  */
 
+// INTERNAL INCLUDES
 #include <dali/graphics-api/graphics-api-accessor.h>
 #include <dali/graphics-api/graphics-api-base-factory.h>
 #include <dali/graphics-api/graphics-api-dynamic-buffer.h>
+#include <dali/graphics-api/graphics-api-frame.h>
 #include <dali/graphics-api/graphics-api-framebuffer.h>
+#include <dali/graphics-api/graphics-api-generic-buffer.h>
+#include <dali/graphics-api/graphics-api-render-command.h>
 #include <dali/graphics-api/graphics-api-sampler.h>
 #include <dali/graphics-api/graphics-api-shader.h>
 #include <dali/graphics-api/graphics-api-static-buffer.h>
+#include <dali/graphics-api/graphics-api-texture-factory.h>
 #include <dali/graphics-api/graphics-api-texture-set.h>
 #include <dali/graphics-api/graphics-api-texture.h>
-#include <dali/graphics-api/graphics-api-texture-factory.h>
+#include <dali/graphics-api/utility/utility-builder.h>
 
 namespace Dali
 {
@@ -35,7 +40,6 @@ namespace Graphics
 {
 namespace API
 {
-
 /**
  * @brief Interface class for Manager types in the graphics API.
  */
@@ -45,63 +49,95 @@ public:
   /**
    * @brief Create a new object
    */
-  virtual Accessor< Shader > CreateShader(const BaseFactory< Shader >& factory) = 0;
+  virtual Accessor<Shader> CreateShader( const BaseFactory<Shader>& factory ) = 0;
 
   /**
    * @brief Create a new object
    */
-  virtual Accessor< Texture > CreateTexture(const BaseFactory< Texture >& factory) = 0;
+  virtual Accessor<Texture> CreateTexture( const BaseFactory<Texture>& factory ) = 0;
 
   /**
    * @brief Create a new object
    */
-  virtual Accessor< TextureSet > CreateTextureSet(const BaseFactory< TextureSet >& factory) = 0;
+  virtual Accessor<TextureSet> CreateTextureSet( const BaseFactory<TextureSet>& factory ) = 0;
 
   /**
    * @brief Create a new object
    */
-  virtual Accessor< DynamicBuffer > CreateDynamicBuffer(
-      const BaseFactory< DynamicBuffer >& factory) = 0;
+  virtual Accessor<DynamicBuffer> CreateDynamicBuffer( const BaseFactory<DynamicBuffer>& factory ) = 0;
 
   /**
    * @brief Create a new object
    */
-  virtual Accessor< StaticBuffer > CreateStaticBuffer(
-      const BaseFactory< StaticBuffer >& factory) = 0;
+  virtual Accessor<StaticBuffer> CreateStaticBuffer( const BaseFactory<StaticBuffer>& factory ) = 0;
 
   /**
    * @brief Create a new object
    */
-  virtual Accessor< Sampler > CreateSampler(const BaseFactory< Sampler >& factory) = 0;
+  virtual Accessor<Sampler> CreateSampler( const BaseFactory<Sampler>& factory ) = 0;
 
   /**
    * @brief Create a new object
    */
-  virtual Accessor< Framebuffer > CreateFramebuffer(const BaseFactory< Framebuffer >& factory) = 0;
+  virtual Accessor<Framebuffer> CreateFramebuffer( const BaseFactory<Framebuffer>& factory ) = 0;
 
   /**
    * @brief Get a render list
    */
   virtual void GetRenderItemList() = 0;
 
+  /**
+   * @brief Create a buffer
+   */
+  template<typename T>
+  std::unique_ptr<GenericBuffer<T>> CreateBuffer( size_t numberOfElements );
+
+  /**
+   * @brief Submit a render command
+   */
+  virtual void SubmitCommand( API::RenderCommand&& command ) = 0;
+
+  /**
+   * @brief Mark the beginning of a frame
+   */
+  virtual void BeginFrame() = 0;
+
+  /**
+   * @brief Mark the end of a frame
+   */
+  virtual void EndFrame() = 0;
+
 public:
   // not copyable
-  Controller(const Controller&) = delete;
-  Controller& operator=(const Controller&) = delete;
+  Controller( const Controller& ) = delete;
+  Controller& operator=( const Controller& ) = delete;
 
   virtual ~Controller() = default;
 
 protected:
   // derived types should not be moved direcly to prevent slicing
-  Controller(Controller&&) = default;
-  Controller& operator=(Controller&&) = default;
+  Controller( Controller&& ) = default;
+  Controller& operator=( Controller&& ) = default;
 
   /**
    * Objects of this type should not directly.
    */
   Controller() = default;
+
+  /**
+   * @brief create an element for the given number of elements and element size
+   */
+  virtual std::unique_ptr<char> CreateBuffer( size_t numberOfElements, size_t elementSize ) = 0;
+
+private:
 };
 
+template<typename T>
+std::unique_ptr<GenericBuffer<T>> Controller::CreateBuffer( size_t numberOfElements )
+{
+    return std::make_unique<GenericBuffer<T>>(numberOfElements, std::move(CreateBuffer( numberOfElements, sizeof( T ) )));
+}
+
 } // namespace API
 } // namespace Graphics
 } // namespace Dali
diff --git a/dali/graphics-api/graphics-api-frame.h b/dali/graphics-api/graphics-api-frame.h
new file mode 100644 (file)
index 0000000..e151941
--- /dev/null
@@ -0,0 +1,59 @@
+#ifndef DALI_GRAPHICS_API_FRAME_H
+#define DALI_GRAPHICS_API_FRAME_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+/**
+ * @brief Interface class for Frame types in the graphics API.
+ *
+ * A frame is used to mark the beginning and end of a presentation cycle.
+ */
+class Frame
+{
+public:
+
+  // not copyable
+  Frame(const Frame&) = delete;
+  Frame& operator=(const Frame&) = delete;
+
+  virtual ~Frame() = default;
+
+//TODO: @todo this should be protected
+
+
+  // derived types should not be moved direcly to prevent slicing
+  Frame(Frame&&) = default;
+  Frame& operator=(Frame&&) = default;
+
+  /**
+   * Objects of this type should not directly.
+   */
+  Frame() = default;
+};
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_FRAME_H
index 65b11d8..28a2726 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef DALI_GRAPHICS_API_GENERIC_BUFFER_H
 #define DALI_GRAPHICS_API_GENERIC_BUFFER_H
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
@@ -17,7 +17,8 @@
  *
  */
 
-#include <vector>
+#include <cstddef>
+#include <memory>
 
 namespace Dali
 {
@@ -25,30 +26,71 @@ namespace Graphics
 {
 namespace API
 {
+class GenericBufferBase
+{
+public:
+  enum class UsageHint
+  {
+    FRAME_CONSTANTS,
+    PRIMITIVE_UNIFORMS,
+    ATTRIBUTES,
+    INSTANCE,
+    INDEX_BUFFER,
+  };
+
+  GenericBufferBase( size_t size, std::unique_ptr<char>&& data ) : mSize{size}, mData( std::move( data ) )
+  {
+  }
+
+  size_t GetSize() const
+  {
+    return mSize;
+  }
+
+  virtual ~GenericBufferBase() = default;
+
+protected:
+  char* GetDataBase()
+  {
+    return mData.get();
+  }
+
+  // derived types should not be moved direcly to prevent slicing
+  GenericBufferBase( GenericBufferBase&& ) = default;
+  GenericBufferBase& operator=( GenericBufferBase&& ) = default;
+
+  // not copyable
+  GenericBufferBase( const GenericBufferBase& ) = delete;
+  GenericBufferBase& operator=( const GenericBufferBase& ) = delete;
+
+private:
+  size_t                mSize;
+  std::unique_ptr<char> mData;
+};
 
 /**
  * @brief Interface class for GenericBuffer types in the graphics API.
  */
-template< typename Base, typename Structure >
-class GenericBuffer final : public Base
+template<typename T>
+class GenericBuffer final : public GenericBufferBase
 {
 public:
-  GenericBuffer(size_t size) = default;
-
-  // not copyable
-  GenericBuffer(const GenericBuffer&) = delete;
-  GenericBuffer& operator=(const GenericBuffer&) = delete;
+  GenericBuffer( size_t numberOfElements, std::unique_ptr<char>&& data )
+  : GenericBufferBase( numberOfElements * sizeof( T ), std::move( data ) ){};
 
   virtual ~GenericBuffer() = default;
 
-protected:
-  // derived types should not be moved direcly to prevent slicing
-  GenericBuffer(GenericBuffer&&) = default;
-  GenericBuffer& operator=(GenericBuffer&&) = default;
+  GenericBuffer( GenericBuffer&& ) = default;
+  GenericBuffer& operator=( GenericBuffer&& ) = default;
 
-private:
+  // not copyable
+  GenericBuffer( const GenericBuffer& ) = delete;
+  GenericBuffer& operator=( const GenericBuffer& ) = delete;
 
-  std::vector< Structure > mData;
+  T* GetData()
+  {
+    return reinterpret_cast<T*>( GenericBufferBase::GetDataBase() );
+  }
 };
 
 } // namespace API
diff --git a/dali/graphics-api/graphics-api-render-command.h b/dali/graphics-api/graphics-api-render-command.h
new file mode 100644 (file)
index 0000000..493b6ff
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef DALI_GRAPHICS_API_RENDER_COMMAND_H
+#define DALI_GRAPHICS_API_RENDER_COMMAND_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <tuple>
+#include <utility>
+#include <vector>
+
+// INTERNAL INCLUDES
+#include <dali/graphics-api/graphics-api-generic-buffer.h>
+#include <dali/graphics-api/utility/utility-builder.h>
+#include <dali/graphics-api/utility/utility-strong-type.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+using PrimitiveCount = Utility::StrongType<size_t, struct PrimitiveCountTag>;
+using BufferInfo     = std::unique_ptr<GenericBufferBase>;
+using BufferList     = Utility::StrongType<std::vector<BufferInfo>, struct BufferListTag>;
+
+/**
+ * @brief Interface class for RenderCommand types in the graphics API.
+ */
+class RenderCommand final
+{
+public:
+  RenderCommand( PrimitiveCount primitiveCount, BufferList&& bufferList )
+  : mPrimitiveCount{primitiveCount}, mBufferList{std::move( bufferList )}
+  {
+  }
+
+  // derived types should not be moved direcly to prevent slicing
+  RenderCommand( RenderCommand&& ) = default;
+  RenderCommand& operator=( RenderCommand&& ) = default;
+
+  // not copyable
+  RenderCommand( const RenderCommand& ) = delete;
+  RenderCommand& operator=( const RenderCommand& ) = delete;
+
+  ~RenderCommand() = default;
+
+private:
+  PrimitiveCount mPrimitiveCount;
+  BufferList     mBufferList;
+};
+
+using RenderCommandBuilder = Utility::Builder<RenderCommand, PrimitiveCount, BufferList>;
+
+} // namespace API
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_RENDER_COMMAND_H
similarity index 96%
rename from dali/graphics/utility/graphics-asserts.h
rename to dali/graphics-api/utility/graphics-asserts.h
index 015fc5b..5af6829 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_GRAPHICS_ASSERTS_H
 
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
diff --git a/dali/graphics-api/utility/utility-builder.h b/dali/graphics-api/utility/utility-builder.h
new file mode 100644 (file)
index 0000000..9a8b3bd
--- /dev/null
@@ -0,0 +1,93 @@
+#ifndef DALI_GRAPHICS_UTILITY_BUILDER_H
+#define DALI_GRAPHICS_UTILITY_BUILDER_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <cstddef>
+#include <utility>
+#include <tuple>
+
+// INTERNAL INCLUDES
+#include <dali/graphics-api/utility/utility-traits.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Utility
+{
+
+template<typename T, typename... Params>
+class Builder
+{
+public:
+  template<typename... Values>
+  Builder( Values&&... values ) : mParameters{}
+  {
+    SetParameters( values... );
+  }
+
+  template<typename Return>
+  operator Return() const
+  {
+    return Build( std::index_sequence_for<Params...>{} );
+  }
+
+  auto Build() const
+  {
+    return Build( std::index_sequence_for<Params...>{} );
+  }
+
+  template<typename V>
+  void Set( V&& value )
+  {
+    SetParameters( std::forward<V>( value ) );
+  }
+
+private:
+  void SetParameters() const {};
+
+  template<typename V>
+  void SetParameters( V&& value )
+  {
+    std::get<std::remove_reference_t<V>>( mParameters ) = std::forward<V>( value );
+  }
+
+  template<typename Head, typename... Tail>
+  void SetParameters( Head&& head, Tail&&... tail )
+  {
+    SetParameters( std::forward<Head>( head ) );
+    SetParameters( std::forward<Tail...>( tail... ) );
+  }
+
+  template<size_t... Is>
+  T Build( std::index_sequence<Is...> ) const
+  {
+    return T(std::forward<Params>(std::get<Is>(std::forward<std::tuple<Params...>>( mParameters ) ))...);
+  }
+
+private: // data
+  std::tuple<Params...> mParameters;
+};
+
+} // namespace Utility
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_UTILITY_BUILDER_H
\ No newline at end of file
similarity index 99%
rename from dali/graphics/utility/utility-queue.h
rename to dali/graphics-api/utility/utility-queue.h
index 631d586..a31f0ed 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_GRAPHICS_UTILITY_QUEUE_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
diff --git a/dali/graphics-api/utility/utility-strong-type.h b/dali/graphics-api/utility/utility-strong-type.h
new file mode 100644 (file)
index 0000000..4c74dfe
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef DALI_GRAPHICS_UTILITY_STRONG_TYPE_H
+#define DALI_GRAPHICS_UTILITY_STRONG_TYPE_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <utility>
+#include <ostream>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Utility
+{
+
+/**
+ * @brief Type wrapper to enforce scemantics in other types
+ */
+template<typename T, typename Tag>
+class StrongType final
+{
+public:
+  explicit StrongType( T value ) noexcept : mValue( std::move( value ) )
+  {
+  }
+
+  StrongType() = default;
+
+  const T& Get() const noexcept
+  {
+    return mValue;
+  }
+
+  T& Get() noexcept
+  {
+    return mValue;
+  }
+
+  const T& operator*() const noexcept
+  {
+    return mValue;
+  }
+
+  T& operator*() noexcept
+  {
+    return mValue;
+  }
+
+private:
+  T mValue;
+};
+
+template<typename T, typename Tag>
+std::ostream& operator<<( std::ostream& os, const StrongType<T, Tag>& value )
+{
+  os << value.Get();
+  return os;
+}
+
+} // namespace Utility
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_UTILITY_STRONG_TYPE_H
\ No newline at end of file
@@ -2,7 +2,7 @@
 #define DALI_GRAPHICS_SYNCHRONIZED_H
 
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
diff --git a/dali/graphics-api/utility/utility-traits.h b/dali/graphics-api/utility/utility-traits.h
new file mode 100644 (file)
index 0000000..6343a3e
--- /dev/null
@@ -0,0 +1,92 @@
+#ifndef DALI_GRAPHICS_UTILITY_TRAITS_H
+#define DALI_GRAPHICS_UTILITY_TRAITS_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+#include <type_traits>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Utility
+{
+
+template<typename T>
+struct BasicType
+{
+  using StorageT = T;
+  using AccessT  = T;
+  using ValueT   = T;
+};
+
+template<typename T>
+struct ComplexType
+{
+  using StorageT = T;
+  using AccessT  = const T&;
+  using ValueT   = T;
+};
+
+template<typename T, template<typename...> class Ptr, typename...Ts>
+struct SmartPointerType
+{
+  using StorageT = Ptr<T, Ts...>;
+  using AccessT  = T&;
+  using ValueT   = T;
+};
+
+// Default types
+template<typename T> struct TraitsType : ComplexType<T> {};
+
+// Pointer types
+template<typename T, typename D>
+struct TraitsType<std::unique_ptr<T, D>> : SmartPointerType<T, std::unique_ptr, D>
+{
+};
+template<typename T>
+struct TraitsType<std::shared_ptr<T>> : SmartPointerType<T, std::shared_ptr>
+{
+};
+
+// Basic types
+template<> struct TraitsType<signed char> : BasicType<signed char> { };
+template<> struct TraitsType<unsigned char> : BasicType<unsigned char> { };
+template<> struct TraitsType<signed short> : BasicType<signed short> { };
+template<> struct TraitsType<unsigned short> : BasicType<unsigned short> { };
+template<> struct TraitsType<signed long> : BasicType<signed long> { };
+template<> struct TraitsType<unsigned long> : BasicType<unsigned long> { };
+template<> struct TraitsType<signed long long> : BasicType<signed long long> { };
+template<> struct TraitsType<unsigned long long> : BasicType<unsigned long long> { };
+template<> struct TraitsType<float> : BasicType<float> { };
+template<> struct TraitsType<double> : BasicType<double> { };
+
+// Invalid tyoes
+
+template<typename T> struct TraitsType<T*> {};
+template<typename T> struct TraitsType<const T*> {};
+template<typename T> struct TraitsType<T&> {};
+template<typename T> struct TraitsType<const T&> {};
+
+} // namespace Utility
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_UTILITY_TRAITS_H
\ No newline at end of file
index edb00b2..d963341 100644 (file)
@@ -15,6 +15,7 @@ graphics_src_files = \
     $(graphics_src_dir)/vulkan/vulkan-pipeline.cpp \
     $(graphics_src_dir)/vulkan/vulkan-buffer.cpp \
     $(graphics_src_dir)/vulkan/vulkan-graphics.cpp \
-    $(graphics_src_dir)/vulkan/vulkan-shader.cpp
+    $(graphics_src_dir)/vulkan/vulkan-shader.cpp \
+    $(graphics_src_dir)/vulkan/vulkan-graphics-controller.cpp
 
 
index 00637ad..dff955e 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_GRAPHICS_CONTROLLER_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
@@ -29,7 +29,7 @@ namespace Graphics
 /**
  * @brief Controller implementation of the graphics API
  */
-class Controller final : public API::Controller
+class Controller : public API::Controller
 {
 public:
   virtual API::Accessor< API::Shader > CreateShader(
@@ -66,7 +66,8 @@ public:
 
   virtual ~Controller() = default;
 
-private:
+
+protected:
   ObjectOwner< API::Shader >        mShaders;
   ObjectOwner< API::Texture >       mTextures;
   ObjectOwner< API::TextureSet >    mTextureSets;
index dc36c7c..0456313 100644 (file)
@@ -28,7 +28,7 @@ namespace Vulkan
 struct Framebuffer::Impl
 {
   Impl( Framebuffer& owner, Graphics& graphics, uint32_t width, uint32_t height )
-  : mInterface( owner ), mGraphics( graphics )
+  : mInterface( owner ), mGraphics( graphics ), mColorImageViewAttachments{}, mDepthStencilImageViewAttachment()
   {
   }
 
@@ -152,25 +152,44 @@ struct Framebuffer::Impl
     mVkFramebuffer = VkAssert( mGraphics.GetDevice().createFramebuffer( info, mGraphics.GetAllocator() ) );
   }
 
-  void SetAttachment( Handle<Image> image, Framebuffer::AttachmentType type, uint32_t index )
+  void SetAttachment( ImageViewRef imageViewRef, Framebuffer::AttachmentType type, uint32_t index )
   {
-    std::vector<Handle<Image>>& attachments =
-      type == AttachmentType::COLOR ? mColorAttachments : mDepthStencilAttachments;
-
-    if( attachments.size() <= index )
+    // TODO: all array-type atyachments
+    if( type == AttachmentType::COLOR )
     {
-      attachments.resize( index + 1 );
+      auto& attachments = mColorImageViewAttachments;
+      if( attachments.size() <= index )
+      {
+        attachments.resize( index + 1 );
+      }
+      attachments[index] = imageViewRef;
+    }
+    else if( type == AttachmentType::DEPTH_STENCIL )
+    {
+      mDepthStencilImageViewAttachment = imageViewRef;
     }
-    attachments[index] = image;
-  }
-
-  ImageRef GetAttachmentImage( AttachmentType type, uint32_t index ) const
-  {
-    return ImageRef();
   }
 
   ImageViewRef GetAttachmentImageView( AttachmentType type, uint32_t index ) const
   {
+    switch( type )
+    {
+      case AttachmentType::COLOR:
+      {
+        return mColorImageViewAttachments[index];
+      }
+      case AttachmentType::DEPTH_STENCIL:
+      {
+        return mDepthStencilImageViewAttachment;
+      }
+      case AttachmentType::DEPTH:
+      case AttachmentType::INPUT:
+      case AttachmentType::RESOLVE:
+      case AttachmentType::PRESERVE:
+      {
+        return ImageViewRef();
+      }
+    }
     return ImageViewRef();
   }
 
@@ -199,26 +218,25 @@ struct Framebuffer::Impl
   Framebuffer& mInterface;
   Graphics&    mGraphics;
 
-  uint32_t                   mWidth;
-  uint32_t                   mHeight;
-  std::vector<Handle<Image>> mColorAttachments;
-  std::vector<Handle<Image>> mDepthStencilAttachments;
+  uint32_t mWidth;
+  uint32_t mHeight;
 
-  std::vector<ImageView> mImageViewAttachments;
-  vk::Framebuffer        mVkFramebuffer;
-  vk::RenderPass         mVkRenderPass;
+  std::vector<ImageViewRef> mColorImageViewAttachments;
+  ImageViewRef              mDepthStencilImageViewAttachment;
+  vk::Framebuffer           mVkFramebuffer;
+  vk::RenderPass            mVkRenderPass;
 
   bool mInitialised{false};
 };
 
-Handle<Framebuffer> Framebuffer::New( Graphics& graphics, uint32_t width, uint32_t height )
+FramebufferRef Framebuffer::New( Graphics& graphics, uint32_t width, uint32_t height )
 {
   return FramebufferRef();
 }
 
-void Framebuffer::SetAttachment( Handle<Image> image, Framebuffer::AttachmentType type, uint32_t index )
+void Framebuffer::SetAttachment( ImageViewRef imageViewRef, Framebuffer::AttachmentType type, uint32_t index )
 {
-  mImpl->SetAttachment( image, type, index );
+  mImpl->SetAttachment( imageViewRef, type, index );
 }
 
 uint32_t Framebuffer::GetWidth() const
@@ -231,11 +249,6 @@ uint32_t Framebuffer::GetHeight() const
   return mImpl->mHeight;
 }
 
-Handle<Image> Framebuffer::GetAttachmentImage( AttachmentType type, uint32_t index ) const
-{
-  return mImpl->GetAttachmentImage( type, index );
-}
-
 Handle<ImageView> Framebuffer::GetAttachmentImageView( AttachmentType type, uint32_t index ) const
 {
   return mImpl->GetAttachmentImageView( type, index );
index 3cb5918..64ecf53 100644 (file)
@@ -42,22 +42,23 @@ public:
   {
     COLOR,
     DEPTH_STENCIL,
+    DEPTH,
     INPUT,
     RESOLVE,
     PRESERVE
   };
 
-  static Handle<Framebuffer> New( Graphics& graphics, uint32_t width, uint32_t height );
+  static FramebufferRef New( Graphics& graphics, uint32_t width, uint32_t height );
 
   uint32_t GetWidth() const;
 
   uint32_t GetHeight() const;
 
-  Handle<Image> GetAttachmentImage( AttachmentType type, uint32_t index ) const;
+  ImageViewRef GetAttachmentImageView( AttachmentType type, uint32_t index ) const;
+
+  void SetAttachment( ImageViewRef imageViewRef, Framebuffer::AttachmentType type, uint32_t index );
 
-  Handle<ImageView> GetAttachmentImageView( AttachmentType type, uint32_t index ) const;
 
-  void SetAttachment( Handle<Image> image, Framebuffer::AttachmentType type, uint32_t index );
 
 private:
 
diff --git a/dali/graphics/vulkan/vulkan-graphics-controller.cpp b/dali/graphics/vulkan/vulkan-graphics-controller.cpp
new file mode 100644 (file)
index 0000000..3d3364e
--- /dev/null
@@ -0,0 +1,59 @@
+#include <dali/graphics/vulkan/vulkan-graphics-controller.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+// TODO: @todo temporarily ignore missing return type, will be fixed later
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wreturn-type"
+API::Accessor<API::Shader> Controller::CreateShader( const API::BaseFactory<API::Shader>& factory )
+{
+}
+
+API::Accessor<API::Texture> Controller::CreateTexture( const API::BaseFactory<API::Texture>& factory )
+{
+}
+
+API::Accessor<API::TextureSet> Controller::CreateTextureSet( const API::BaseFactory<API::TextureSet>& factory )
+{
+}
+
+API::Accessor<API::DynamicBuffer> Controller::CreateDynamicBuffer( const API::BaseFactory<API::DynamicBuffer>& factory )
+{
+}
+
+API::Accessor<API::StaticBuffer> Controller::CreateStaticBuffer( const API::BaseFactory<API::StaticBuffer>& factory )
+{
+}
+
+API::Accessor<API::Sampler> Controller::CreateSampler( const API::BaseFactory<API::Sampler>& factory )
+{
+}
+
+API::Accessor<API::Framebuffer> Controller::CreateFramebuffer( const API::BaseFactory<API::Framebuffer>& factory )
+{
+}
+#pragma GCC diagnostic pop
+
+void Controller::GetRenderItemList()
+{
+}
+
+void Controller::SubmitCommand( API::RenderCommand&& command )
+{
+}
+
+void Controller::BeginFrame()
+{
+}
+
+void Controller::EndFrame()
+{
+}
+
+} // namespace Vulkan
+} // namespace Graphics
+} // namespace Dali
diff --git a/dali/graphics/vulkan/vulkan-graphics-controller.h b/dali/graphics/vulkan/vulkan-graphics-controller.h
new file mode 100644 (file)
index 0000000..69e41a7
--- /dev/null
@@ -0,0 +1,110 @@
+#ifndef DALI_GRAPHICS_VULAKN_GRAPHICS_CONTROLLER_H
+#define DALI_GRAPHICS_VULAKN_GRAPHICS_CONTROLLER_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/graphics/graphics-controller.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+/**
+ * @brief Interface class for Manager types in the graphics API.
+ */
+class Controller : public Graphics::Controller
+{
+public:
+  /**
+   * @brief Create a new object
+   */
+  API::Accessor<API::Shader> CreateShader( const API::BaseFactory<API::Shader>& factory ) override;
+
+  /**
+   * @brief Create a new object
+   */
+  API::Accessor<API::Texture> CreateTexture( const API::BaseFactory<API::Texture>& factory ) override;
+
+  /**
+   * @brief Create a new object
+   */
+  API::Accessor<API::TextureSet> CreateTextureSet( const API::BaseFactory<API::TextureSet>& factory ) override;
+
+  /**
+   * @brief Create a new object
+   */
+  API::Accessor<API::DynamicBuffer> CreateDynamicBuffer( const API::BaseFactory<API::DynamicBuffer>& factory ) override;
+
+  /**
+   * @brief Create a new object
+   */
+  API::Accessor<API::StaticBuffer> CreateStaticBuffer( const API::BaseFactory<API::StaticBuffer>& factory ) override;
+
+  /**
+   * @brief Create a new object
+   */
+  API::Accessor<API::Sampler> CreateSampler( const API::BaseFactory<API::Sampler>& factory ) override;
+
+  /**
+   * @brief Create a new object
+   */
+  API::Accessor<API::Framebuffer> CreateFramebuffer( const API::BaseFactory<API::Framebuffer>& factory ) override;
+
+  /**
+   * @brief Get a render list
+   */
+  void GetRenderItemList() override;
+
+  void SubmitCommand(API::RenderCommand&& command) override;
+
+  void BeginFrame() override;
+
+  void EndFrame() override;
+
+public:
+  // not copyable
+  Controller( const Controller& ) = delete;
+  Controller& operator=( const Controller& ) = delete;
+
+  virtual ~Controller() = default;
+
+protected:
+  // derived types should not be moved direcly to prevent slicing
+  Controller( Controller&& ) = default;
+  Controller& operator=( Controller&& ) = default;
+
+  /**
+   * Objects of this type should not directly.
+   */
+  Controller() = default;
+
+private:
+
+  struct Impl;
+  std::unique_ptr<Impl> mImpl;
+
+};
+
+} // namespace Vulkan
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_VULAKN_GRAPHICS_CONTROLLER_H
index 3a4a184..99aa995 100644 (file)
@@ -194,6 +194,17 @@ ImageViewRef ImageView::New( Graphics& graphics, ImageRef image, vk::ImageViewCr
   return retval;
 }
 
+ImageViewRef ImageView::New( Graphics& graphics, ImageRef image )
+{
+  // create reference, image may be null
+  auto retval = ImageViewRef( new ImageView( graphics, image, vk::ImageViewCreateInfo{} ) );
+  if(image)
+  {
+
+  }
+  return retval;
+}
+
 ImageView::ImageView( Graphics& graphics, ImageRef image, const VkImageViewCreateInfo& createInfo )
 {
   mImpl = MakeUnique<Impl>( *this, graphics, image, createInfo );
index b566e27..deb574c 100644 (file)
@@ -134,8 +134,25 @@ class ImageView : public VkManaged
 {
 public:
 
+  /**
+   * Creates ImageView according to the given spec
+   * @param graphics
+   * @param image
+   * @param info
+   * @return
+   */
   static ImageViewRef New( Graphics& graphics, ImageRef image, vk::ImageViewCreateInfo info );
 
+  /**
+   * Creates default image view which includes single layer and level, aspect
+   * based on image format, whole area, always 2D
+   * @param graphics
+   * @param image
+   * @return
+   */
+  static ImageViewRef New( Graphics& graphics, ImageRef image = ImageRef() );
+
+
   virtual ~ImageView() override;
 
   /**
@@ -150,6 +167,92 @@ public:
    */
   ImageRef GetImage() const;
 
+  /**
+   *
+   * @param format
+   */
+  void SetFormat( vk::Format format );
+
+  /**
+   *
+   * @param componentMapping
+   */
+  void SetComponents( vk::ComponentMapping componentMapping );
+
+  /**
+   *
+   * @param viewType
+   */
+  void SetViewType( vk::ImageViewType viewType );
+
+  /**
+   *
+   * @param layerCount
+   */
+  void SetLayerCount( uint32_t layerCount );
+
+  /**
+   *
+   * @param layerCount
+   */
+  void SetLevelCount( uint32_t layerCount );
+
+  /**
+   *
+   * @param layerCount
+   */
+  void SetBaseMipmapLevel( uint32_t layerCount );
+
+  /**
+   *
+   * @param layer
+   */
+  void SetBaseArrayLayer( uint32_t layer );
+
+  /**
+   *
+   * @param aspectMask
+   */
+  void SetImageAspectMask( vk::ImageAspectFlags aspectMask );
+
+  /**
+   *
+   * @return
+   */
+  uint32_t GetLayerCount() const;
+
+  /**
+   *
+   * @return
+   */
+  uint32_t GetLevelCount() const;
+
+  /**
+   *
+   * @return
+   */
+  uint32_t GetBaseMipmapLevel() const;
+
+  /**
+   *
+   * @return
+   */
+  uint32_t GetBaseArrayLayer() const;
+
+  /**
+   *
+   * @return
+   */
+  vk::ImageAspectFlags GetImageAspectMask() const;
+
+  /**
+   * Creates immediately the image view. Otherwise implementation will
+   * pick the right time to create the object. All setters are disabled
+   * once the view has been created
+   * @return
+   */
+  bool Create();
+
 private:
 
   ImageView( Graphics& graphics, ImageRef image, const VkImageViewCreateInfo& createInfo );
index b7491d1..8c6bded 100644 (file)
 #endif
 
 #include <glm/glm.hpp>
+#include <glm/gtc/matrix_transform.hpp>
 #include <glm/matrix.hpp>
 #include <glm/vector_relational.hpp>
-#include <glm/gtc/matrix_transform.hpp>
 
 using namespace glm;
 
+#include <dali/integration-api/graphics/graphics.h>
+#include <dali/integration-api/graphics/vulkan/vk-surface-factory.h>
 #include <dali/integration-api/graphics/vulkan/vulkan-hpp-wrapper.h>
 
-#include <dali/integration-api/graphics/vulkan/vk-surface-factory.h>
-#include <dali/integration-api/graphics/graphics.h>
-#include <xcb/xcb.h>
 #include <unistd.h>
+#include <xcb/xcb.h>
 
 // internals
-#include <dali/graphics/vulkan/vulkan-buffer.h>
-#include <dali/graphics/vulkan/vulkan-graphics.h>
-#include <dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-manager.h>
-#include <dali/graphics/vulkan/vulkan-shader.h>
-#include <dali/graphics/vulkan/vulkan-descriptor-set.h>
-#include <dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-manager.h>
+#include "generated/spv-shaders-gen.h"
+
 #include <dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-allocator.h>
 #include <dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-handle.h>
-#include <dali/graphics/vulkan/vulkan-pipeline.h>
-#include <dali/graphics/vulkan/vulkan-command-pool.h>
+#include <dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-manager.h>
+#include <dali/graphics/vulkan/vulkan-buffer.h>
 #include <dali/graphics/vulkan/vulkan-command-buffer.h>
-#include <dali/graphics/vulkan/vulkan-surface.h>
+#include <dali/graphics/vulkan/vulkan-command-pool.h>
 #include <dali/graphics/vulkan/vulkan-descriptor-set.h>
-
-#include "generated/spv-shaders-gen.h"
+#include <dali/graphics/vulkan/vulkan-framebuffer.h>
+#include <dali/graphics/vulkan/vulkan-graphics.h>
+#include <dali/graphics/vulkan/vulkan-image.h>
+#include <dali/graphics/vulkan/vulkan-pipeline.h>
+#include <dali/graphics/vulkan/vulkan-shader.h>
+#include <dali/graphics/vulkan/vulkan-surface.h>
 
 #define USE_XLIB 0
 #include <iostream>
 
-using Dali::Integration::Graphics::Graphics;
-using Dali::Integration::Graphics::Vulkan::VkSurfaceFactory;
 using Dali::Graphics::Vulkan::Buffer;
-using Dali::Graphics::Vulkan::Shader;
+using Dali::Graphics::Vulkan::CommandBuffer;
+using Dali::Graphics::Vulkan::CommandPool;
+using Dali::Graphics::Vulkan::DescriptorPool;
 using Dali::Graphics::Vulkan::DescriptorSetLayout;
-using Dali::Graphics::Vulkan::GpuMemoryManager;
 using Dali::Graphics::Vulkan::GpuMemoryAllocator;
-using Dali::Graphics::Vulkan::Shader;
-using Dali::Graphics::Vulkan::ShaderRef;
+using Dali::Graphics::Vulkan::GpuMemoryManager;
 using Dali::Graphics::Vulkan::Pipeline;
 using Dali::Graphics::Vulkan::PipelineRef;
-using Dali::Graphics::Vulkan::CommandPool;
-using Dali::Graphics::Vulkan::CommandBuffer;
-using Dali::Graphics::Vulkan::DescriptorPool;
+using Dali::Graphics::Vulkan::Shader;
+using Dali::Graphics::Vulkan::ShaderRef;
+using Dali::Integration::Graphics::Graphics;
+using Dali::Integration::Graphics::Vulkan::VkSurfaceFactory;
 
 extern std::vector<uint8_t> VSH;
 extern std::vector<uint8_t> FSH;
 
-template< typename T, typename... Args >
-std::unique_ptr< T > MakeUnique(Args&&... args)
+template<typename T, typename... Args>
+std::unique_ptr<T> MakeUnique( Args&&... args )
 {
-  return std::unique_ptr< T >(new T(std::forward< Args >(args)...));
+  return std::unique_ptr<T>( new T( std::forward<Args>( args )... ) );
 }
 
-
 class VkSurfaceXlib : public Dali::Integration::Graphics::Vulkan::VkSurfaceFactory
 {
 public:
@@ -79,17 +77,17 @@ public:
    * @param display
    * @param window
    */
-  VkSurfaceXlib(Display* display, Window window)
-    : VkSurfaceFactory(), mDisplay(display), mWindow(window)
+  VkSurfaceXlib( Display* display, Window window ) : VkSurfaceFactory(), mDisplay( display ), mWindow( window )
   {
   }
 
-  virtual vk::SurfaceKHR Create(vk::Instance instance, vk::AllocationCallbacks* allocCallbacks,
-                                vk::PhysicalDevice physicalDevice) const override
+  virtual vk::SurfaceKHR Create( vk::Instance             instance,
+                                 vk::AllocationCallbacks* allocCallbacks,
+                                 vk::PhysicalDevice       physicalDevice ) const override
   {
     vk::XlibSurfaceCreateInfoKHR info;
-    info.setDpy(mDisplay).setWindow(mWindow);
-    auto retval = instance.createXlibSurfaceKHR(info, allocCallbacks).value;
+    info.setDpy( mDisplay ).setWindow( mWindow );
+    auto retval = instance.createXlibSurfaceKHR( info, allocCallbacks ).value;
     return retval;
   }
 
@@ -107,17 +105,18 @@ public:
    * @param display
    * @param window
    */
-  VkSurfaceXcb(xcb_connection_t* connection, xcb_window_t window)
-    : VkSurfaceFactory{}, mConnection(connection), mWindow(window)
+  VkSurfaceXcb( xcb_connection_t* connection, xcb_window_t window )
+  : VkSurfaceFactory{}, mConnection( connection ), mWindow( window )
   {
   }
 
-  virtual vk::SurfaceKHR Create(vk::Instance instance, vk::AllocationCallbacks* allocCallbacks,
-                                vk::PhysicalDevice physicalDevice) const override
+  virtual vk::SurfaceKHR Create( vk::Instance             instance,
+                                 vk::AllocationCallbacks* allocCallbacks,
+                                 vk::PhysicalDevice       physicalDevice ) const override
   {
     vk::XcbSurfaceCreateInfoKHR info;
-    info.setConnection(mConnection).setWindow(mWindow);
-    auto retval = instance.createXcbSurfaceKHR(info, allocCallbacks).value;
+    info.setConnection( mConnection ).setWindow( mWindow );
+    auto retval = instance.createXcbSurfaceKHR( info, allocCallbacks ).value;
     return retval;
   }
 
@@ -138,27 +137,32 @@ struct xlib_window_t
 
   ~xlib_window_t()
   {
-    XDestroyWindow(display, window);
+    XDestroyWindow( display, window );
   }
 };
 
-std::unique_ptr< xlib_window_t > create_xlib_window(int width, int height)
+std::unique_ptr<xlib_window_t> create_xlib_window( int width, int height )
 {
-  std::unique_ptr< xlib_window_t > wnd{new xlib_window_t};
+  std::unique_ptr<xlib_window_t> wnd{new xlib_window_t};
   // 1. Create Window ( done by DALI
 
   wnd->width         = width;
   wnd->height        = height;
-  wnd->display       = XOpenDisplay(nullptr);
-  auto defaultScreen = DefaultScreen(wnd->display);
-  wnd->window =
-    XCreateSimpleWindow(wnd->display, RootWindow(wnd->display, defaultScreen), 0, 0, wnd->width,
-                        wnd->height, 1, BlackPixel(wnd->display, defaultScreen),
-                        WhitePixel(wnd->display, defaultScreen));
-
-  XSelectInput(wnd->display, wnd->window, ExposureMask | KeyPressMask);
-  XMapWindow(wnd->display, wnd->window);
-  XSync(wnd->display, false);
+  wnd->display       = XOpenDisplay( nullptr );
+  auto defaultScreen = DefaultScreen( wnd->display );
+  wnd->window        = XCreateSimpleWindow( wnd->display,
+                                     RootWindow( wnd->display, defaultScreen ),
+                                     0,
+                                     0,
+                                     wnd->width,
+                                     wnd->height,
+                                     1,
+                                     BlackPixel( wnd->display, defaultScreen ),
+                                     WhitePixel( wnd->display, defaultScreen ) );
+
+  XSelectInput( wnd->display, wnd->window, ExposureMask | KeyPressMask );
+  XMapWindow( wnd->display, wnd->window );
+  XSync( wnd->display, false );
 
   return wnd;
 }
@@ -172,56 +176,66 @@ struct xcb_window_t
 
   ~xcb_window_t()
   {
-    xcb_destroy_window(connection, window);
+    xcb_destroy_window( connection, window );
   }
 };
 
-std::unique_ptr< Test::xcb_window_t > create_xcb_window(int width, int height)
+std::unique_ptr<Test::xcb_window_t> create_xcb_window( int width, int height )
 {
-  std::unique_ptr< Test::xcb_window_t > wnd{new Test::xcb_window_t};
+  std::unique_ptr<Test::xcb_window_t> wnd{new Test::xcb_window_t};
   // 1. Create Window ( done by DALI
 
   wnd->width  = width;
   wnd->height = height;
 
-  int screenNum(0);
+  int screenNum( 0 );
 
-  xcb_connection_t*     connection = xcb_connect(NULL, &screenNum);
-  const xcb_setup_t*    setup      = xcb_get_setup(connection);
-  xcb_screen_iterator_t iter       = xcb_setup_roots_iterator(setup);
-  for(int i = 0; i < screenNum; ++i)
-    xcb_screen_next(&iter);
+  xcb_connection_t*     connection = xcb_connect( NULL, &screenNum );
+  const xcb_setup_t*    setup      = xcb_get_setup( connection );
+  xcb_screen_iterator_t iter       = xcb_setup_roots_iterator( setup );
+  for( int i = 0; i < screenNum; ++i )
+    xcb_screen_next( &iter );
 
-  xcb_screen_t* screen = iter.data;
-  ::xcb_window_t  window = xcb_generate_id(connection);
+  xcb_screen_t*  screen = iter.data;
+  ::xcb_window_t window = xcb_generate_id( connection );
 
   uint32_t mask     = XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK;
   uint32_t values[] = {screen->white_pixel, XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_KEY_PRESS};
 
-  xcb_create_window(connection, XCB_COPY_FROM_PARENT, window, screen->root, 0, 0, wnd->width,
-                    wnd->height, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, screen->root_visual, mask,
-                    values);
-
-  xcb_map_window(connection, window);
+  xcb_create_window( connection,
+                     XCB_COPY_FROM_PARENT,
+                     window,
+                     screen->root,
+                     0,
+                     0,
+                     wnd->width,
+                     wnd->height,
+                     0,
+                     XCB_WINDOW_CLASS_INPUT_OUTPUT,
+                     screen->root_visual,
+                     mask,
+                     values );
+
+  xcb_map_window( connection, window );
   const uint32_t coords[] = {100, 100};
-  xcb_configure_window(connection, window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords);
-  xcb_flush(connection);
+  xcb_configure_window( connection, window, XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, coords );
+  xcb_flush( connection );
 
   wnd->connection = connection;
   wnd->window     = window;
 
   return wnd;
 }
-}
+} // namespace Test
 
 namespace VulkanTest
 {
-
-Dali::Graphics::Vulkan::GpuMemoryBlockRef test_gpu_memory_manager( Dali::Graphics::Vulkan::Graphics& graphics,
-                                         GpuMemoryManager& gpuManager,
-                                         const Dali::Graphics::Vulkan::Handle<Buffer>& buffer )
+Dali::Graphics::Vulkan::GpuMemoryBlockRef test_gpu_memory_manager(
+  Dali::Graphics::Vulkan::Graphics&             graphics,
+  GpuMemoryManager&                             gpuManager,
+  const Dali::Graphics::Vulkan::Handle<Buffer>& buffer )
 {
-  auto device = graphics.GetDevice();
+  auto  device    = graphics.GetDevice();
   auto& allocator = graphics.GetAllocator();
 
   auto& gpuAllocator = gpuManager.GetDefaultAllocator();
@@ -234,19 +248,15 @@ struct UniformData
   mat4 viewMat;
   mat4 projMat;
   vec4 color;
-} __attribute__((aligned(16)));
-
+} __attribute__( ( aligned( 16 ) ) );
 
 mat4 MVP;
 
-
-
-
-template <class T>
+template<class T>
 void update_buffer( Dali::Graphics::Vulkan::BufferRef buffer, T& value )
 {
-  auto ptr = reinterpret_cast<T*>(buffer->GetMemoryHandle()->Map());
-  *ptr = value;
+  auto ptr = reinterpret_cast<T*>( buffer->GetMemoryHandle()->Map() );
+  *ptr     = value;
   buffer->GetMemoryHandle()->Unmap();
 }
 
@@ -257,50 +267,40 @@ void update_translation( Dali::Graphics::Vulkan::BufferRef buffer )
 
   UniformData ub;
   ub.modelMat = mat4{1.0f};
-  ub.modelMat = glm::translate( ub.modelMat, vec3( x, x, 0.0f ));
-  ub.modelMat = glm::rotate( ub.modelMat, glm::radians( x ), glm::vec3( 0.0f, 0.0f, 1.0f) );
-  ub.viewMat = lookAt( vec3( 0.0f, 0.0f, 10.0f ),
-                        vec3( 0.0f, 0.0f, 0.0f ),
-                        vec3( 0.0f, 1.0f, 0.0f ) );
+  ub.modelMat = glm::translate( ub.modelMat, vec3( x, x, 0.0f ) );
+  ub.modelMat = glm::rotate( ub.modelMat, glm::radians( x ), glm::vec3( 0.0f, 0.0f, 1.0f ) );
+  ub.viewMat  = lookAt( vec3( 0.0f, 0.0f, 10.0f ), vec3( 0.0f, 0.0f, 0.0f ), vec3( 0.0f, 1.0f, 0.0f ) );
 
-  glm::mat4 clip( 1.0f, 0.0f, 0.0f, 0.0f,
-                  0.0f, -1.0f, 0.0f, 0.0f,
-                  0.0f, 0.0f, 0.5f, 0.0f,
-                  0.0f, 0.0f, 0.5f, 1.0f );
+  glm::mat4 clip( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 1.0f );
 
   ub.projMat = clip * ortho( 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 100.0f );
-  ub.color = vec4( x / 640.0f, x / 480.0f, 1.0f, 1.0f );
+  ub.color   = vec4( x / 640.0f, x / 480.0f, 1.0f, 1.0f );
   update_buffer( buffer, ub );
 }
 
 Dali::Graphics::Vulkan::BufferRef create_uniform_buffer( Dali::Graphics::Vulkan::Graphics& gr )
 {
   // create uniform buffer
-  auto uniformBuffer = Buffer::New( gr, sizeof(UniformData), Buffer::Type::UNIFORM );
+  auto uniformBuffer = Buffer::New( gr, sizeof( UniformData ), Buffer::Type::UNIFORM );
 
   // allocate memory
-  auto memory = gr.GetDeviceMemoryManager().GetDefaultAllocator().Allocate( uniformBuffer, vk::MemoryPropertyFlagBits::eHostVisible );
+  auto memory = gr.GetDeviceMemoryManager().GetDefaultAllocator().Allocate( uniformBuffer,
+                                                                            vk::MemoryPropertyFlagBits::eHostVisible );
 
   // bind memory
   uniformBuffer->BindMemory( memory );
 
-  auto ub = reinterpret_cast<UniformData*>(memory->Map());
+  auto ub = reinterpret_cast<UniformData*>( memory->Map() );
 
   ub->modelMat = mat4{1.0f};
   //ub->modelMat = glm::translate( ub->modelMat, vec3( 0.0f, 0.0f, 0.0f ));
 
-  ub->viewMat = lookAt( vec3( 0.0f, 0.0f, 10.0f ),
-                        vec3( 0.0f, 0.0f, 0.0f ),
-                        vec3( 0.0f, 1.0f, 0.0f ) );
+  ub->viewMat = lookAt( vec3( 0.0f, 0.0f, 10.0f ), vec3( 0.0f, 0.0f, 0.0f ), vec3( 0.0f, 1.0f, 0.0f ) );
 
-  glm::mat4 clip( 1.0f, 0.0f, 0.0f, 0.0f,
-                  0.0f, -1.0f, 0.0f, 0.0f,
-                  0.0f, 0.0f, 0.5f, 0.0f,
-                  0.0f, 0.0f, 0.5f, 1.0f );
+  glm::mat4 clip( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.5f, 1.0f );
 
   ub->projMat = clip * ortho( 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 100.0f );
-  ub->color = vec4( 0.0f, 1.0f, 1.0f, 1.0f );
-
+  ub->color   = vec4( 0.0f, 1.0f, 1.0f, 1.0f );
 
   MVP = ub->projMat * ub->viewMat * ub->modelMat;
 
@@ -309,20 +309,60 @@ Dali::Graphics::Vulkan::BufferRef create_uniform_buffer( Dali::Graphics::Vulkan:
   return uniformBuffer;
 }
 
-Dali::Graphics::Vulkan::Handle<DescriptorPool>
-create_descriptor_pool( Dali::Graphics::Vulkan::Graphics& gr )
+Dali::Graphics::Vulkan::Handle<DescriptorPool> create_descriptor_pool( Dali::Graphics::Vulkan::Graphics& gr )
 {
   vk::DescriptorPoolSize size;
   size.setDescriptorCount( 1024 ).setType( vk::DescriptorType::eUniformBuffer );
 
   // TODO: how to organize this???
-  auto pool = DescriptorPool::New( gr,
-    vk::DescriptorPoolCreateInfo{}.
-      setMaxSets( 1024 ).
-      setPoolSizeCount(1).setPPoolSizes(&size));
+  auto pool = DescriptorPool::New(
+    gr, vk::DescriptorPoolCreateInfo{}.setMaxSets( 1024 ).setPoolSizeCount( 1 ).setPPoolSizes( &size ) );
   return pool;
 }
 
+void test_framebuffer( Dali::Graphics::Vulkan::Graphics& graphics )
+{
+  using namespace Dali::Graphics::Vulkan;
+  // framebuffer
+  auto fb = NewRef<Framebuffer>( graphics, 640, 480 );
+
+  // attachment
+  auto image = NewRef<Image>( graphics,
+                              vk::ImageCreateInfo{}
+                                .setFormat( vk::Format::eR32G32B32A32Sfloat )
+                                .setTiling( vk::ImageTiling::eOptimal )
+                                .setMipLevels( 1 )
+                                .setImageType( vk::ImageType::e2D )
+                                .setExtent( vk::Extent3D( 640, 480, 1 ) )
+                                .setArrayLayers( 1 )
+                                .setUsage( vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eColorAttachment )
+                                .setSharingMode( vk::SharingMode::eExclusive )
+                                .setInitialLayout( vk::ImageLayout::eUndefined )
+                                .setSamples( vk::SampleCountFlagBits::e1 ) );
+
+  auto imageView = NewRef<ImageView>(
+    graphics,
+    image,
+    vk::ImageViewCreateInfo{}
+      .setFormat( vk::Format::eR32G32B32A32Sfloat )
+      .setComponents( vk::ComponentMapping(
+        vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eA ) )
+      .setImage( image->GetVkImage() )
+      .setSubresourceRange( vk::ImageSubresourceRange{}
+                              .setLayerCount( 1 )
+                              .setLevelCount( 1 )
+                              .setBaseMipLevel( 0 )
+                              .setBaseArrayLayer( 0 )
+                              .setAspectMask( vk::ImageAspectFlagBits::eColor ) )
+      .setViewType( vk::ImageViewType::e2D ) );
+
+  fb->SetAttachment( imageView, Framebuffer::AttachmentType::COLOR, 0u );
+
+  //fb->GetRenderPass();
+
+  //fb->SetAttachment( )
+}
+
 void test_handle()
 {
   /*
@@ -333,30 +373,25 @@ void test_handle()
   handle.GetRefCount();*/
 }
 
-PipelineRef
-create_pipeline( Dali::Graphics::Vulkan::Graphics& graphics,
-                      Dali::Graphics::Vulkan::ShaderRef vertexShader,
-                      Dali::Graphics::Vulkan::ShaderRef fragmentShader
-                      )
+PipelineRef create_pipeline( Dali::Graphics::Vulkan::Graphics& graphics,
+                             Dali::Graphics::Vulkan::ShaderRef vertexShader,
+                             Dali::Graphics::Vulkan::ShaderRef fragmentShader )
 {
   using namespace Dali::Graphics::Vulkan;
   auto pipelineInfo = vk::GraphicsPipelineCreateInfo{};
-  auto pipeline = Pipeline::New( graphics, pipelineInfo );
+  auto pipeline     = Pipeline::New( graphics, pipelineInfo );
 
   pipeline->SetShader( vertexShader, Shader::Type::VERTEX );
   pipeline->SetShader( fragmentShader, Shader::Type::FRAGMENT );
   pipeline->SetViewport( 0, 0, 640, 480 );
   pipeline->SetVertexInputState(
-    std::vector<vk::VertexInputAttributeDescription>{vk::VertexInputAttributeDescription{}.
-                                           setBinding( 0 ).
-                                           setOffset( 0 ).
-                                           setLocation( 0 ).
-                                           setFormat( vk::Format::eR32G32B32Sfloat )},
-    std::vector<vk::VertexInputBindingDescription>{vk::VertexInputBindingDescription{}.
-                                           setBinding( 0 ).
-                                           setStride( sizeof(float)*3  ).
-                                           setInputRate( vk::VertexInputRate::eVertex)}
-  );
+    std::vector<vk::VertexInputAttributeDescription>{
+      vk::VertexInputAttributeDescription{}.setBinding( 0 ).setOffset( 0 ).setLocation( 0 ).setFormat(
+        vk::Format::eR32G32B32Sfloat )},
+    std::vector<vk::VertexInputBindingDescription>{vk::VertexInputBindingDescription{}
+                                                     .setBinding( 0 )
+                                                     .setStride( sizeof( float ) * 3 )
+                                                     .setInputRate( vk::VertexInputRate::eVertex )} );
   pipeline->SetInputAssemblyState( vk::PrimitiveTopology::eTriangleList, false );
 
   if( !pipeline->Compile() )
@@ -368,20 +403,16 @@ create_pipeline( Dali::Graphics::Vulkan::Graphics& graphics,
 
 int RunTestMain()
 {
-
 #if USE_XLIB == 1
-  auto window = Test::create_xlib_window(640, 480);
-  auto surfaceFactory =
-      std::unique_ptr< VkSurfaceXlib >{new VkSurfaceXlib{window->display, window->window}};
+  auto window         = Test::create_xlib_window( 640, 480 );
+  auto surfaceFactory = std::unique_ptr<VkSurfaceXlib>{new VkSurfaceXlib{window->display, window->window}};
 #else
-  auto window         = Test::create_xcb_window(640, 480);
-  auto surfaceFactory =
-         std::unique_ptr<VkSurfaceXcb>{new VkSurfaceXcb{window->connection, window->window}};
+  auto window         = Test::create_xcb_window( 640, 480 );
+  auto surfaceFactory = std::unique_ptr<VkSurfaceXcb>{new VkSurfaceXcb{window->connection, window->window}};
 #endif
 
-
   auto graphics = MakeUnique<Graphics>();
-  auto fbid = graphics->Create( std::move(surfaceFactory) );
+  auto fbid     = graphics->Create( std::move( surfaceFactory ) );
 
   // access internal implementation
   auto& gr = graphics->GetImplementation<Dali::Graphics::Vulkan::Graphics>();
@@ -389,48 +420,44 @@ int RunTestMain()
   // GPU memory manager
   auto& memmgr = gr.GetDeviceMemoryManager();
 
-  const vec3 VERTICES[] =
-          {
-            {0.0f, 0.0f, 0.0f},
-            {320.0f, 0.0f, 0.0f},
-            {0.0f, 160.0f, 0.0f},
-          };
-
-
-
+  const vec3 VERTICES[] = {
+    {0.0f, 0.0f, 0.0f},
+    {320.0f, 0.0f, 0.0f},
+    {0.0f, 160.0f, 0.0f},
+  };
 
   // shaders
   auto vertexShader = Shader::New( gr, VSH_CODE.data(), VSH_CODE.size() );
-  vertexShader->SetDescriptorSetLayout( 0, vk::DescriptorSetLayoutCreateInfo{}.
-    setBindingCount( 1 ).
-    setPBindings( std::vector<vk::DescriptorSetLayoutBinding>{
-                    vk::DescriptorSetLayoutBinding{}.
-                                                      setBinding( 0 ).
-                                                      setStageFlags( vk::ShaderStageFlagBits::eVertex ).
-                                                      setDescriptorType( vk::DescriptorType::eUniformBuffer ).
-                                                      setDescriptorCount( 1 )
-                  }.data()
-    ));
+  vertexShader->SetDescriptorSetLayout(
+    0,
+    vk::DescriptorSetLayoutCreateInfo{}.setBindingCount( 1 ).setPBindings(
+      std::vector<vk::DescriptorSetLayoutBinding>{vk::DescriptorSetLayoutBinding{}
+                                                    .setBinding( 0 )
+                                                    .setStageFlags( vk::ShaderStageFlagBits::eVertex )
+                                                    .setDescriptorType( vk::DescriptorType::eUniformBuffer )
+                                                    .setDescriptorCount( 1 )}
+        .data() ) );
 
   auto fragmentShader = Shader::New( gr, FSH_CODE.data(), FSH_CODE.size() );
 
   // buffer
-  auto vertexBuffer = Buffer::New( gr, sizeof(float)*3*3, Buffer::Type::VERTEX );
+  auto vertexBuffer = Buffer::New( gr, sizeof( float ) * 3 * 3, Buffer::Type::VERTEX );
 
   auto descriptorPool = create_descriptor_pool( gr );
-  auto descriptorSet = descriptorPool->AllocateDescriptorSets( vk::DescriptorSetAllocateInfo{}
-  .setPSetLayouts( vertexShader->GetDescriptorSetLayouts().data() )
-  .setDescriptorSetCount( static_cast<uint32_t>(vertexShader->GetDescriptorSetLayouts().size())));
-
-
+  auto descriptorSet  = descriptorPool->AllocateDescriptorSets(
+    vk::DescriptorSetAllocateInfo{}
+      .setPSetLayouts( vertexShader->GetDescriptorSetLayouts().data() )
+      .setDescriptorSetCount( static_cast<uint32_t>( vertexShader->GetDescriptorSetLayouts().size() ) ) );
 
   auto& gpuManager = gr.GetDeviceMemoryManager();
 
   auto bufferMemory = test_gpu_memory_manager( gr, gpuManager, vertexBuffer );
   vertexBuffer->BindMemory( bufferMemory );
 
-  auto ptr = static_cast<uint8_t*>(bufferMemory->Map());
-  std::copy( reinterpret_cast<const uint8_t*>(VERTICES), reinterpret_cast<const uint8_t*>(VERTICES)+(sizeof(float)*9), ptr);
+  auto ptr = static_cast<uint8_t*>( bufferMemory->Map() );
+  std::copy( reinterpret_cast<const uint8_t*>( VERTICES ),
+             reinterpret_cast<const uint8_t*>( VERTICES ) + ( sizeof( float ) * 9 ),
+             ptr );
   bufferMemory->Unmap();
 
   auto pipeline = create_pipeline( gr, vertexShader, fragmentShader );
@@ -445,7 +472,7 @@ int RunTestMain()
   auto cmdDraw = commandPool->NewCommandBuffer( false );
 
   // begin recording
-  cmdDraw->Begin( vk::CommandBufferUsageFlagBits::eRenderPassContinue);
+  cmdDraw->Begin( vk::CommandBufferUsageFlagBits::eRenderPassContinue );
 
   // vertex buffer
   cmdDraw->BindVertexBuffer( 0, vertexBuffer, 0 );
@@ -462,8 +489,6 @@ int RunTestMain()
   // finish
   cmdDraw->End();
 
-
-
   bool running = true;
 
   while( running )
@@ -474,8 +499,7 @@ int RunTestMain()
     auto cmdbuf = gr.GetSurface( fbid ).GetCurrentCommandBuffer();
 
     // get command buffer for current frame and execute the draw call
-    cmdbuf->ExecuteCommands( { cmdDraw } );
-
+    cmdbuf->ExecuteCommands( {cmdDraw} );
 
     graphics->PostRender( fbid );
 
@@ -483,7 +507,7 @@ int RunTestMain()
   }
   return 0;
 }
-}
+} // namespace VulkanTest
 
 int main()
 {
index 9db5d47..e674292 100644 (file)
@@ -78,6 +78,12 @@ void Graphics::PreRender(Dali::Graphics::FBID framebufferId)
   surface.AcquireNextImage();
 }
 
+Dali::Graphics::API::Controller& Graphics::GetController()
+{
+  auto ptr = this;
+  return *reinterpret_cast<Dali::Graphics::API::Controller*>(ptr);
+}
+
 /*
  * Postrender
  */
index 03e29e4..597f2df 100644 (file)
@@ -27,7 +27,10 @@ namespace Dali
 {
 namespace Graphics
 {
-
+namespace API
+{
+class Controller;
+}
 // frame buffer id
 using FBID = uint32_t;
 
@@ -77,6 +80,12 @@ public:
    */
   void PostRender( Dali::Graphics::FBID framebufferId = 0u );
 
+  /**
+   * Returns controller object
+   * @return
+   */
+  Dali::Graphics::API::Controller& GetController();
+
   // this function is used only by the standalone test
   template <class T>
   T& GetImplementation() const
index ca0b671..8350f2b 100644 (file)
@@ -124,7 +124,8 @@ Core::Core( RenderController& renderController,
                                        renderController,
                                       *mRenderManager,
                                        renderQueue,
-                                      *mRenderTaskProcessor );
+                                      *mRenderTaskProcessor,
+                                       graphics );
 
   mRenderManager->SetShaderSaver( *mUpdateManager );
 
index 4b98598..bb006c2 100644 (file)
@@ -126,6 +126,7 @@ internal_src_files = \
   $(internal_src_dir)/update/controllers/scene-controller-impl.cpp \
   $(internal_src_dir)/update/gestures/pan-gesture-profiling.cpp \
   $(internal_src_dir)/update/gestures/scene-graph-pan-gesture.cpp \
+  $(internal_src_dir)/update/graphics/graphics-algorithms.cpp \
   $(internal_src_dir)/update/queue/update-message-queue.cpp \
   $(internal_src_dir)/update/manager/render-instruction-processor.cpp \
   $(internal_src_dir)/update/manager/render-task-processor.cpp \
diff --git a/dali/internal/update/graphics/graphics-algorithms.cpp b/dali/internal/update/graphics/graphics-algorithms.cpp
new file mode 100644 (file)
index 0000000..41d8cd5
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+// CLASS HEADER
+#include <dali/internal/update/graphics/graphics-algorithms.h>
+
+// EXTERNAL INCLUDES
+
+#include <dali/graphics-api/graphics-api-controller.h>
+#include <dali/graphics-api/graphics-api-frame.h>
+#include <dali/graphics-api/graphics-api-render-command.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/common/buffer-index.h>
+#include <dali/internal/render/common/render-instruction-container.h>
+#include <dali/internal/render/common/render-instruction.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+namespace
+{
+void SubmitRenderItemList( Graphics::API::Controller&           graphics,
+                           Graphics::API::Frame&                frame,
+                           BufferIndex                          bufferIndex,
+                           Graphics::API::RenderCommandBuilder& commandBuilder,
+                           Matrix                               viewProjection,
+                           const RenderList&                    renderItemList )
+{
+  // TODO: @todo Set shaders and other properties
+  //commandBuilder.Set( );
+
+  // TODO: @todo Clipping...
+
+  auto numberOfRenderItems = renderItemList.Count();
+
+  using DataT = struct
+  {
+    Matrix  world;
+    Vector4 color;
+    Vector3 size;
+  } __attribute__((aligned(16)));
+
+  auto uniformBuffer = graphics.CreateBuffer<DataT>( numberOfRenderItems );
+  auto data = uniformBuffer->GetData();
+  for( auto i = 0u; i < numberOfRenderItems; ++i )
+  {
+    auto& item = renderItemList.GetItem( i );
+    Matrix::Multiply( data[i].world, item.mModelMatrix, viewProjection );
+    data[i].color = item.mNode->GetWorldColor( bufferIndex );
+    data[i].size  = item.mSize;
+  }
+  commandBuilder.Set( Graphics::API::PrimitiveCount{numberOfRenderItems} );
+
+  auto buffers = std::vector<Graphics::API::BufferInfo>{};
+  buffers.emplace_back(std::move(uniformBuffer));
+
+  commandBuilder.Set( Graphics::API::BufferList{std::move(buffers)} );
+ // auto cmd = commandBuilder.Build();
+ // graphics.SubmitCommand( std::move(cmd) );
+}
+
+void SubmitInstruction( Graphics::API::Controller& graphics,
+                        Graphics::API::Frame&      frame,
+                        BufferIndex                bufferIndex,
+                        RenderInstruction&         instruction )
+{
+  using namespace Graphics::API;
+
+  // Create constant buffer with static uniforms: view matrix, progrjection matrix
+
+  // TODO: @todo: buffer for constant uniforms
+  /*
+  auto contantUniforms = BuildBuffer<ProjectionMatrix, ViewMatrix>();
+  constantUniforms["uProjection"] = projectionMatrix;
+  constantUniforms["uViewMatrix"] = viewMatrix;
+  */
+
+  const Matrix* viewMatrix       = instruction.GetViewMatrix( bufferIndex );
+  const Matrix* projectionMatrix = instruction.GetProjectionMatrix( bufferIndex );
+  Matrix        viewProjection;
+  Matrix::Multiply( viewProjection, *viewMatrix, *projectionMatrix );
+
+  auto commandBuilder = RenderCommandBuilder{};
+
+  auto numberOfRenderLists = instruction.RenderListCount();
+  for( auto i = 0u; i < numberOfRenderLists; ++i )
+  {
+    SubmitRenderItemList(
+      graphics, frame, bufferIndex, commandBuilder, viewProjection, *instruction.GetRenderList( i ) );
+  }
+}
+} // namespace
+
+void SubmitRenderInstructions( Graphics::API::Controller&  graphics,
+                               RenderInstructionContainer& renderInstructions,
+                               BufferIndex                 bufferIndex )
+{
+  auto frame = Graphics::API::Frame{};
+  graphics.BeginFrame();
+
+  auto numberOfInstructions = renderInstructions.Count( bufferIndex );
+  for( size_t i = 0; i < numberOfInstructions; ++i )
+  {
+    RenderInstruction& instruction = renderInstructions.At( bufferIndex, i );
+
+    SubmitInstruction( graphics, frame, bufferIndex, instruction );
+  }
+
+  graphics.EndFrame( );
+}
+
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
diff --git a/dali/internal/update/graphics/graphics-algorithms.h b/dali/internal/update/graphics/graphics-algorithms.h
new file mode 100644 (file)
index 0000000..11cfc4d
--- /dev/null
@@ -0,0 +1,42 @@
+#ifndef DALI_INTERNAL_GRAPHICS_ALGORITHMS_H
+#define DALI_INTERNAL_GRAPHICS_ALGORITHMS_H
+
+/*
+ * Copyright (c) 2018 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.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/graphics-api/graphics-api-controller.h>
+
+// INTERNAL INCLUDES
+#include <dali/internal/render/common/render-instruction-container.h>
+#include <dali/internal/common/buffer-index.h>
+
+namespace Dali
+{
+namespace Internal
+{
+namespace SceneGraph
+{
+void SubmitRenderInstructions( Graphics::API::Controller& graphics,
+                               SceneGraph::RenderInstructionContainer& renderInstructions,
+                               BufferIndex                 bufferIndex );
+
+} // namespace SceneGraph
+} // namespace Internal
+} // namespace Dali
+
+#endif // DALI_INTERNAL_GRAPHICS_ALGORITHMS_H
\ No newline at end of file
index 63515d2..82942fc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
 // CLASS HEADER
 #include <dali/internal/update/manager/update-manager.h>
 
+// EXTERNAL INCLUDES
+#include <dali/graphics/graphics-controller.h>
+
 // INTERNAL INCLUDES
 #include <dali/public-api/common/stage.h>
-#include <dali/devel-api/common/owner-container.h>
-#include <dali/devel-api/threading/mutex.h>
 
 #include <dali/integration-api/core.h>
-#include <dali/integration-api/render-controller.h>
-#include <dali/internal/common/shader-data.h>
 #include <dali/integration-api/debug.h>
+#include <dali/integration-api/render-controller.h>
+#include <dali/integration-api/graphics/graphics.h>
 
+#include <dali/devel-api/common/owner-container.h>
+#include <dali/devel-api/threading/mutex.h>
 #include <dali/internal/common/core-impl.h>
 #include <dali/internal/common/message.h>
-
+#include <dali/internal/common/shader-data.h>
+#include <dali/internal/event/animation/animation-playlist.h>
 #include <dali/internal/event/common/notification-manager.h>
 #include <dali/internal/event/common/property-notification-impl.h>
 #include <dali/internal/event/common/property-notifier.h>
 #include <dali/internal/event/effects/shader-factory.h>
-#include <dali/internal/event/animation/animation-playlist.h>
-
-#include <dali/internal/update/animation/scene-graph-animator.h>
+#include <dali/internal/render/common/render-instruction-container.h>
+#include <dali/internal/render/common/render-manager.h>
+#include <dali/internal/render/queue/render-queue.h>
+#include <dali/internal/render/shaders/scene-graph-shader.h>
 #include <dali/internal/update/animation/scene-graph-animation.h>
+#include <dali/internal/update/animation/scene-graph-animator.h>
 #include <dali/internal/update/common/discard-queue.h>
 #include <dali/internal/update/common/scene-graph-buffers.h>
 #include <dali/internal/update/controllers/render-message-dispatcher.h>
 #include <dali/internal/update/controllers/scene-controller-impl.h>
 #include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
+#include <dali/internal/update/graphics/graphics-algorithms.h>
 #include <dali/internal/update/manager/render-task-processor.h>
 #include <dali/internal/update/manager/sorted-layers.h>
+#include <dali/internal/update/manager/transform-manager.h>
 #include <dali/internal/update/manager/update-algorithms.h>
 #include <dali/internal/update/manager/update-manager-debug.h>
-#include <dali/internal/update/manager/transform-manager.h>
 #include <dali/internal/update/nodes/node.h>
 #include <dali/internal/update/nodes/scene-graph-layer.h>
 #include <dali/internal/update/queue/update-message-queue.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
 #include <dali/internal/update/render-tasks/scene-graph-camera.h>
-
-#include <dali/internal/render/common/render-instruction-container.h>
-#include <dali/internal/render/common/render-manager.h>
-#include <dali/internal/render/queue/render-queue.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>
-
-#include <dali/graphics/graphics-controller.h>
+#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
+#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
 
 // Un-comment to enable node tree debug logging
 //#define NODE_TREE_LOGGING 1
@@ -173,7 +173,8 @@ struct UpdateManager::Impl
         RenderManager& renderManager,
         RenderQueue& renderQueue,
         SceneGraphBuffers& sceneGraphBuffers,
-        RenderTaskProcessor& renderTaskProcessor )
+        RenderTaskProcessor& renderTaskProcessor,
+        Integration::Graphics::Graphics& graphics )
   : renderMessageDispatcher( renderManager, renderQueue, sceneGraphBuffers ),
     notificationManager( notificationManager ),
     transformManager(),
@@ -187,6 +188,7 @@ struct UpdateManager::Impl
     renderQueue( renderQueue ),
     renderInstructions( renderManager.GetRenderInstructionContainer() ),
     renderTaskProcessor( renderTaskProcessor ),
+    graphics( graphics ),
     backgroundColor( Dali::Stage::DEFAULT_BACKGROUND_COLOR ),
     taskList( renderMessageDispatcher ),
     systemLevelTaskList( renderMessageDispatcher ),
@@ -270,6 +272,7 @@ struct UpdateManager::Impl
   RenderQueue&                         renderQueue;                   ///< Used to queue messages for the next render
   RenderInstructionContainer&          renderInstructions;            ///< Used to prepare the render instructions
   RenderTaskProcessor&                 renderTaskProcessor;           ///< Handles RenderTasks and RenderInstrucitons
+  Integration::Graphics::Graphics&     graphics;                      ///< Graphics
 
   Vector4                              backgroundColor;               ///< The glClear color used at the beginning of each frame.
 
@@ -309,41 +312,41 @@ struct UpdateManager::Impl
   bool                                 renderTaskWaiting;             ///< A REFRESH_ONCE render task is waiting to be rendered
   bool                                 renderersAdded;                ///< Flag to keep track when renderers have been added to avoid unnecessary processing
 
+
 private:
 
   Impl( const Impl& ); ///< Undefined
   Impl& operator=( const Impl& ); ///< Undefined
 };
 
-UpdateManager::UpdateManager( NotificationManager& notificationManager,
-                              CompleteNotificationInterface& animationFinishedNotifier,
-                              PropertyNotifier& propertyNotifier,
-                              DiscardQueue& discardQueue,
-                              RenderController& controller,
-                              RenderManager& renderManager,
-                              RenderQueue& renderQueue,
-                              RenderTaskProcessor& renderTaskProcessor )
-  : mImpl(NULL)
+UpdateManager::UpdateManager( NotificationManager&             notificationManager,
+                              CompleteNotificationInterface&   animationFinishedNotifier,
+                              PropertyNotifier&                propertyNotifier,
+                              DiscardQueue&                    discardQueue,
+                              RenderController&                controller,
+                              RenderManager&                   renderManager,
+                              RenderQueue&                     renderQueue,
+                              RenderTaskProcessor&             renderTaskProcessor,
+                              Integration::Graphics::Graphics& graphics )
+: mImpl( new Impl( notificationManager,
+                   animationFinishedNotifier,
+                   propertyNotifier,
+                   discardQueue,
+                   controller,
+                   renderManager,
+                   renderQueue,
+                   mSceneGraphBuffers,
+                   renderTaskProcessor,
+                   graphics) )
 {
-  mImpl = new Impl( notificationManager,
-                    animationFinishedNotifier,
-                    propertyNotifier,
-                    discardQueue,
-                    controller,
-                    renderManager,
-                    renderQueue,
-                    mSceneGraphBuffers,
-                    renderTaskProcessor );
-
-
-  Dali::Graphics::Controller gfxController;
 }
 
 UpdateManager::~UpdateManager()
 {
-  delete mImpl;
+  // required due to unique_ptr to mImpl
 }
 
+
 void UpdateManager::InstallRoot( OwnerPointer<Layer>& layer, bool systemLevel )
 {
   DALI_ASSERT_DEBUG( layer->IsLayer() );
@@ -895,8 +898,9 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
     //reset the update buffer index and make sure there is enough room in the instruction container
     if( mImpl->renderersAdded )
     {
-      mImpl->renderInstructions.ResetAndReserve( bufferIndex,
-                                                 mImpl->taskList.GetTasks().Count() + mImpl->systemLevelTaskList.GetTasks().Count() );
+      mImpl->renderInstructions.ResetAndReserve(bufferIndex,
+                                                mImpl->taskList.GetTasks().Count() +
+                                                    mImpl->systemLevelTaskList.GetTasks().Count());
 
       if ( NULL != mImpl->root )
       {
@@ -920,6 +924,8 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
                                               isRenderingToFbo );
         }
       }
+      // generate graphics objects
+      SubmitRenderInstructions( mImpl->graphics.GetController(), mImpl->renderInstructions, bufferIndex );
     }
   }
 
index d603eb6..41e3eda 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H
 
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
  *
  */
 
+//EXTERNAL INCLUDES
+#include <iostream>
+#include <memory>
+
 // INTERNAL INCLUDES
-#include <dali/public-api/common/vector-wrapper.h>
 #include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/vector-wrapper.h>
 
 #include <dali/internal/common/message.h>
-#include <dali/internal/common/type-abstraction-enums.h>
 #include <dali/internal/common/shader-saver.h>
+#include <dali/internal/common/type-abstraction-enums.h>
 #include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/event/rendering/texture-impl.h>
+#include <dali/internal/render/renderers/render-property-buffer.h>
+#include <dali/internal/render/shaders/scene-graph-shader.h> // for OwnerPointer< Shader >
 #include <dali/internal/update/animation/scene-graph-animation.h>
 #include <dali/internal/update/common/scene-graph-buffers.h>
 #include <dali/internal/update/common/scene-graph-property-notification.h>
+#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
 #include <dali/internal/update/nodes/node.h>
 #include <dali/internal/update/nodes/scene-graph-layer.h>
-#include <dali/internal/update/rendering/scene-graph-renderer.h>  // for OwnerPointer< Renderer >
-#include <dali/internal/update/rendering/scene-graph-texture-set.h> // for OwnerPointer< TextureSet >
-#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
 #include <dali/internal/update/render-tasks/scene-graph-camera.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>   // for OwnerPointer< Shader >
-#include <dali/internal/render/renderers/render-property-buffer.h>
-#include <dali/internal/event/rendering/texture-impl.h>
+#include <dali/internal/update/rendering/scene-graph-renderer.h>    // for OwnerPointer< Renderer >
+#include <dali/internal/update/rendering/scene-graph-texture-set.h> // for OwnerPointer< TextureSet >
 
 namespace Dali
 {
@@ -46,7 +50,10 @@ namespace Integration
 {
 class GlSyncAbstraction;
 class RenderController;
-
+namespace Graphics
+{
+class Graphics;
+}
 } // namespace Integration
 
 namespace Internal
@@ -133,7 +140,8 @@ public:
                  Integration::RenderController& controller,
                  RenderManager& renderManager,
                  RenderQueue& renderQueue,
-                 RenderTaskProcessor& renderTaskProcessor );
+                 RenderTaskProcessor& renderTaskProcessor,
+                 Dali::Integration::Graphics::Graphics& graphics);
 
   /**
    * Destructor.
@@ -673,7 +681,7 @@ private:
   SceneGraphBuffers mSceneGraphBuffers;
 
   struct Impl;
-  Impl* mImpl;
+  std::unique_ptr<Impl> mImpl;
 
 };