[Vulkan] Sampler and texture support - something is rendering
authoradam.b <jsr184@gmail.com>
Wed, 21 Mar 2018 15:59:02 +0000 (15:59 +0000)
committerFrancisco Santos <eggzcape@gmail.com>
Thu, 29 Mar 2018 16:37:23 +0000 (12:37 -0400)
- Textures are passed from the DALi side ( it's workaround )
- UVs are computed from vertex data so no atlasing ( text affected )
- Seems like there is a problem with RGB data ( working on it )
- The shader supports only one texture ( only first from texture set used )
- Only combined-image-sampler descriptor type supported at the moment
- Alpha transparency doesn't work yet
- Glitches in many textures
- Uploading is immediate and stalls the device, has to be improved
- The communication between core and graphics is a big workaround

Change-Id: I8a14807422681aa0ab8ea4c9dfe9a4437bbfae91

29 files changed:
dali/graphics-api/graphics-api-controller.h
dali/graphics/file.list
dali/graphics/graphics-texture.h
dali/graphics/vulkan/api/vulkan-texture-factory.cpp [new file with mode: 0644]
dali/graphics/vulkan/generated/spv-shaders-gen.cpp
dali/graphics/vulkan/generated/spv-shaders-gen.h
dali/graphics/vulkan/shaders/basic-shader.frag
dali/graphics/vulkan/shaders/basic-shader.vert
dali/graphics/vulkan/tests/texture-test.cpp
dali/graphics/vulkan/vulkan-command-buffer.cpp
dali/graphics/vulkan/vulkan-command-buffer.h
dali/graphics/vulkan/vulkan-descriptor-set.cpp
dali/graphics/vulkan/vulkan-descriptor-set.h
dali/graphics/vulkan/vulkan-graphics-controller.cpp
dali/graphics/vulkan/vulkan-graphics-controller.h
dali/graphics/vulkan/vulkan-graphics-texture.cpp [new file with mode: 0644]
dali/graphics/vulkan/vulkan-graphics-texture.h [new file with mode: 0644]
dali/graphics/vulkan/vulkan-image.cpp
dali/graphics/vulkan/vulkan-image.h
dali/graphics/vulkan/vulkan-pipeline.cpp
dali/graphics/vulkan/vulkan-sampler.cpp [new file with mode: 0644]
dali/graphics/vulkan/vulkan-sampler.h [new file with mode: 0644]
dali/graphics/vulkan/vulkan-types.h
dali/internal/event/rendering/texture-impl.cpp
dali/internal/render/renderers/render-texture.h
dali/internal/update/graphics/graphics-algorithms.cpp
dali/internal/update/manager/render-instruction-processor.cpp
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h

index 26a3df2..6f4667c 100644 (file)
@@ -90,6 +90,17 @@ public:
   virtual void GetRenderItemList() = 0;
 
   /**
+   * Temporary way of instantiating new texture through controller
+   * @param width
+   * @param height
+   * @return
+   */
+  virtual void* CreateTextureRGBA32( void* data, size_t sizeInBytes, uint32_t width, uint32_t height )
+  {
+    return 0;
+  }
+
+  /**
    * @brief Create a buffer
    */
   template<typename T>
index f4a0c43..a602549 100644 (file)
@@ -17,7 +17,9 @@ graphics_src_files = \
     $(graphics_src_dir)/vulkan/vulkan-graphics.cpp \
     $(graphics_src_dir)/vulkan/vulkan-shader.cpp \
     $(graphics_src_dir)/vulkan/vulkan-swapchain.cpp \
+    $(graphics_src_dir)/vulkan/vulkan-sampler.cpp \
     $(graphics_src_dir)/vulkan/vulkan-graphics-controller.cpp \
+    $(graphics_src_dir)/vulkan/vulkan-graphics-texture.cpp \
     $(graphics_src_dir)/vulkan/spirv/vulkan-spirv.cpp \
     $(graphics_src_dir)/graphics-controller.cpp
 
index 2a51df0..920330a 100644 (file)
@@ -49,7 +49,7 @@ public:
   /**
    * @brief Creates a new texture
    */
-  Texture CreateTeture();
+  API::Texture CreateTeture();
 };
 
 } // namespace Graphics
diff --git a/dali/graphics/vulkan/api/vulkan-texture-factory.cpp b/dali/graphics/vulkan/api/vulkan-texture-factory.cpp
new file mode 100644 (file)
index 0000000..726e481
--- /dev/null
@@ -0,0 +1,40 @@
+#include <dali/graphics-api/graphics-api-texture-factory.h>
+#include <dali/graphics-api/graphics-api-texture.h>
+#include <dali/graphics-api/graphics-api-texture-details.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace API
+{
+
+std::unique_ptr<Texture> TextureFactory::Create() const
+{
+
+}
+
+void TextureFactory::SetType(TextureDetails::Type type)
+{
+
+}
+
+void TextureFactory::SetSize(const RectSize& size)
+{
+
+}
+void TextureFactory::SetFormat(TextureDetails::Format format)
+{
+
+}
+
+void TextureFactory::SetMipMapFlag(TextureDetails::MipMapFlag mipMSapFlag)
+{
+
+}
+
+}
+
+}
+
+}
\ No newline at end of file
index 7cb07c3..3adbd5e 100644 (file)
 #pragma GCC diagnostic ignored "-Wlarger-than="
 std::vector<uint8_t> VSH_CODE = {
   0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00,
-  0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00,
+  0x3b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00,
   0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00,
   0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30,
   0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
-  0x0d, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00,
-  0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0xae, 0x01, 0x00, 0x00,
-  0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e,
-  0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78,
-  0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74,
-  0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x69, 0x6e, 0x74,
-  0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x43,
-  0x6c, 0x69, 0x70, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x00,
-  0x05, 0x00, 0x03, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x05, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x63, 0x6c, 0x69, 0x70,
-  0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x00, 0x06, 0x00, 0x05, 0x00,
-  0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x6c, 0x69, 0x70,
-  0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x13, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00,
-  0x77, 0x6f, 0x72, 0x6c, 0x64, 0x00, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00,
-  0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x76, 0x70, 0x00,
-  0x06, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00,
-  0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x73, 0x69, 0x7a, 0x65,
-  0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x1a, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x1f, 0x00, 0x00, 0x00,
-  0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00,
-  0x05, 0x00, 0x05, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x74, 0x72, 0x69, 0x43,
-  0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x48, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00,
-  0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
-  0x48, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00,
-  0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
-  0x10, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00,
-  0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00,
-  0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
-  0x13, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x48, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00,
+  0x0d, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00,
+  0x36, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00,
+  0xae, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00,
+  0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00,
+  0x0b, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65,
+  0x72, 0x74, 0x65, 0x78, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00,
+  0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50,
+  0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00,
+  0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50,
+  0x6f, 0x69, 0x6e, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00,
+  0x06, 0x00, 0x07, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+  0x67, 0x6c, 0x5f, 0x43, 0x6c, 0x69, 0x70, 0x44, 0x69, 0x73, 0x74, 0x61,
+  0x6e, 0x63, 0x65, 0x00, 0x05, 0x00, 0x03, 0x00, 0x0d, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00,
+  0x63, 0x6c, 0x69, 0x70, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x00,
+  0x06, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x63, 0x6c, 0x69, 0x70, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00,
+  0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00,
+  0x18, 0x00, 0x00, 0x00, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x00, 0x00, 0x00,
+  0x06, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x6d, 0x76, 0x70, 0x00, 0x06, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00,
+  0x06, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+  0x73, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00,
+  0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x73, 0x61, 0x6d, 0x70,
+  0x6c, 0x65, 0x72, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x00, 0x00, 0x00, 0x00,
+  0x05, 0x00, 0x03, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x05, 0x00, 0x05, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x61, 0x50, 0x6f, 0x73,
+  0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00,
+  0x30, 0x00, 0x00, 0x00, 0x75, 0x76, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x73,
+  0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x36, 0x00, 0x00, 0x00,
+  0x74, 0x72, 0x69, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00,
+  0x48, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00,
+  0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00,
+  0x02, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+  0x47, 0x00, 0x03, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+  0x48, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x48, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00,
-  0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00,
-  0x40, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00,
-  0x02, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
+  0x48, 0x00, 0x05, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00,
+  0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
+  0x13, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x47, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00,
+  0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+  0x48, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+  0x23, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00,
+  0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00,
+  0x50, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00,
+  0x03, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00,
   0x47, 0x00, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
   0x47, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x1a, 0x00, 0x00, 0x00,
   0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
   0x1f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x47, 0x00, 0x04, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00,
-  0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-  0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
-  0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
-  0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00,
-  0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
-  0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x1c, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
-  0x20, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00,
-  0x0d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00,
-  0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00,
-  0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00,
-  0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
-  0x12, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00,
-  0x3b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
-  0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00,
-  0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00,
-  0x17, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x1e, 0x00, 0x05, 0x00, 0x18, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
-  0x07, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
-  0x19, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00,
-  0x3b, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00,
-  0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
-  0x1e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
-  0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00,
-  0x02, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
-  0x06, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
-  0x20, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, 0x00,
-  0x2e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
-  0x0e, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-  0x20, 0x00, 0x04, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
-  0x07, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00,
-  0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00,
-  0x14, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
-  0x0f, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00,
-  0x16, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00,
-  0x14, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00,
-  0x0f, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00,
-  0x1c, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x92, 0x00, 0x05, 0x00,
-  0x10, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
-  0x1c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00,
-  0x20, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00,
-  0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00,
-  0x21, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00,
-  0x24, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00,
-  0x17, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
-  0x24, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00,
-  0x27, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
-  0x25, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00,
-  0x06, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
-  0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00,
-  0x2a, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00,
-  0x29, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x91, 0x00, 0x05, 0x00,
-  0x07, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00,
-  0x2a, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x2c, 0x00, 0x00, 0x00,
-  0x2d, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
-  0x3e, 0x00, 0x03, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00,
-  0x41, 0x00, 0x05, 0x00, 0x30, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00,
-  0x1a, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
-  0x07, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00,
-  0x3e, 0x00, 0x03, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00,
+  0x47, 0x00, 0x04, 0x00, 0x30, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x36, 0x00, 0x00, 0x00,
+  0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00,
+  0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00,
+  0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00,
+  0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00,
+  0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x2b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00,
+  0x06, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x05, 0x00,
+  0x0b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
+  0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00,
+  0x03, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
+  0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+  0x15, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00,
+  0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x04, 0x00,
+  0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+  0x1e, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+  0x11, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00,
+  0x13, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
+  0x14, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+  0x17, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
+  0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x06, 0x00, 0x18, 0x00, 0x00, 0x00,
+  0x10, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00,
+  0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00,
+  0x02, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
+  0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+  0x17, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x1e, 0x00, 0x00, 0x00,
+  0x1f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00,
+  0x0e, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+  0x17, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00,
+  0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x20, 0x00, 0x04, 0x00,
+  0x2c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+  0x17, 0x00, 0x04, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
+  0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x2f, 0x00, 0x00, 0x00,
+  0x03, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
+  0x2f, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+  0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x3f, 0x2c, 0x00, 0x05, 0x00, 0x2e, 0x00, 0x00, 0x00,
+  0x34, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00,
+  0x3b, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00,
+  0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00,
+  0x37, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
+  0x38, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+  0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00,
+  0x05, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x14, 0x00, 0x00, 0x00,
+  0x15, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
+  0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00,
+  0x15, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x14, 0x00, 0x00, 0x00,
+  0x1b, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
+  0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
+  0x1b, 0x00, 0x00, 0x00, 0x92, 0x00, 0x05, 0x00, 0x10, 0x00, 0x00, 0x00,
+  0x1d, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00,
+  0x3d, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+  0x1f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x22, 0x00, 0x00, 0x00,
+  0x23, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
+  0x3d, 0x00, 0x04, 0x00, 0x17, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
+  0x23, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x17, 0x00, 0x00, 0x00,
+  0x25, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
+  0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00,
+  0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00,
+  0x06, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00,
+  0x29, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+  0x50, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00,
+  0x27, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00,
+  0x26, 0x00, 0x00, 0x00, 0x91, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00,
+  0x2b, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00,
+  0x41, 0x00, 0x05, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00,
+  0x0d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00,
+  0x2d, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x17, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00,
+  0x4f, 0x00, 0x07, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00,
+  0x31, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x2e, 0x00, 0x00, 0x00,
+  0x35, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
+  0x3e, 0x00, 0x03, 0x00, 0x30, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00,
+  0x41, 0x00, 0x05, 0x00, 0x38, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00,
+  0x1a, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
+  0x07, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00,
+  0x3e, 0x00, 0x03, 0x00, 0x36, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00,
   0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00
 };
 std::vector<uint8_t> FSH_CODE = {
   0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00,
-  0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00,
+  0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00,
   0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00,
   0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30,
   0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00,
   0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00,
-  0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00,
-  0x02, 0x00, 0x00, 0x00, 0xae, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00,
-  0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00,
-  0x05, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x43,
-  0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x74, 0x72, 0x69, 0x43, 0x6f, 0x6c, 0x6f, 0x72,
-  0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00,
-  0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00,
-  0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00,
-  0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00,
-  0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
-  0x20, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00,
-  0x09, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
-  0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
-  0x3b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00,
-  0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00,
-  0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
-  0x3e, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
-  0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00
+  0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
+  0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+  0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0xae, 0x01, 0x00, 0x00,
+  0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e,
+  0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x6f, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00,
+  0x05, 0x00, 0x05, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x75, 0x54, 0x65, 0x78,
+  0x74, 0x75, 0x72, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00,
+  0x11, 0x00, 0x00, 0x00, 0x75, 0x76, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x73,
+  0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x15, 0x00, 0x00, 0x00,
+  0x74, 0x72, 0x69, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00,
+  0x47, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00,
+  0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00,
+  0x0d, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+  0x47, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x15, 0x00, 0x00, 0x00,
+  0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00,
+  0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00,
+  0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00,
+  0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00,
+  0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+  0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x03, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, 0x0a, 0x00, 0x00, 0x00,
+  0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x0b, 0x00, 0x00, 0x00,
+  0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
+  0x0c, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x17, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
+  0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00,
+  0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00,
+  0x10, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+  0x20, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+  0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x14, 0x00, 0x00, 0x00,
+  0x15, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00,
+  0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00,
+  0x3d, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
+  0x0d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00,
+  0x12, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x57, 0x00, 0x05, 0x00,
+  0x07, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
+  0x12, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00,
+  0x16, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00,
+  0x07, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
+  0x16, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00,
+  0x17, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00
 };
 #pragma GCC diagnostic pop
index 7297c75..656a8a8 100644 (file)
@@ -16,6 +16,7 @@ layout( set = 0, binding = 0, std140 ) uniform world
     mat4 mvp;
     vec4 color;
     vec3 size;
+    uint samplerIndex;
 };
 
 layout( set = 0, binding = 1, std140 ) uniform clipUniform
@@ -25,9 +26,12 @@ layout( set = 0, binding = 1, std140 ) uniform clipUniform
 
 layout( location = 0 ) out vec4 triColor;
 
+layout( location = 1 ) out vec2 uvCoords;
+
 void main()
 {
     gl_Position = clip * mvp * vec4( aPosition* size, 1.0 );
+    uvCoords = aPosition.xy + vec2( 0.5, 0.5 );
     triColor = color;
 }*/
 
@@ -37,11 +41,14 @@ extern std::vector<uint8_t> FSH_CODE;
 #version 430
 
 layout( location = 0 ) in vec4 triColor;
+layout( location = 1 ) in vec2 uvCoords;
 layout( location = 0 ) out vec4 outColor;
 
+layout( set = 0, binding = 2 ) uniform sampler2D uTexture;
+
 void main()
 {
-    outColor = triColor;
+    outColor = texture( uTexture, uvCoords) * triColor;
 }*/
 
 
index 63e6c1c..4e087ac 100644 (file)
@@ -1,9 +1,12 @@
 #version 430
 
 layout( location = 0 ) in vec4 triColor;
+layout( location = 1 ) in vec2 uvCoords;
 layout( location = 0 ) out vec4 outColor;
 
+layout( set = 0, binding = 2 ) uniform sampler2D uTexture;
+
 void main()
 {
-    outColor = triColor;
+    outColor = texture( uTexture, uvCoords) * triColor;
 }
\ No newline at end of file
index 20ac3f7..8742031 100644 (file)
@@ -7,6 +7,7 @@ layout( set = 0, binding = 0, std140 ) uniform world
     mat4 mvp;
     vec4 color;
     vec3 size;
+    uint samplerIndex;
 };
 
 layout( set = 0, binding = 1, std140 ) uniform clipUniform
@@ -16,8 +17,11 @@ layout( set = 0, binding = 1, std140 ) uniform clipUniform
 
 layout( location = 0 ) out vec4 triColor;
 
+layout( location = 1 ) out vec2 uvCoords;
+
 void main()
 {
     gl_Position = clip * mvp * vec4( aPosition* size, 1.0 );
+    uvCoords = aPosition.xy + vec2( 0.5, 0.5 );
     triColor = color;
 }
\ No newline at end of file
index b7152a3..edc458a 100644 (file)
@@ -13,6 +13,8 @@
 #include <dali/graphics/vulkan/vulkan-fence.h>
 #include <dali/graphics/vulkan/vulkan-queue.h>
 
+#include <dali/graphics/vulkan/vulkan-graphics-texture.h>
+
 
 namespace VulkanTest
 {
@@ -47,7 +49,7 @@ struct Pixel
 struct Pixmap
 {
   explicit Pixmap( std::vector<Pixel> _data, uint32_t _width, uint32_t _height ) :
-  data(_data), width(_width), height(_height), bytesPerPixel(4), pixelFormat( vk::Format::eR32G32B32A32Uint )
+  data(_data), width(_width), height(_height), bytesPerPixel(4), pixelFormat( vk::Format::eR8G8B8A8Unorm )
   {
   }
   std::vector<Pixel> data;
@@ -84,11 +86,12 @@ struct Texture
     mImage->BindMemory( allocator.Allocate( mImage, vk::MemoryPropertyFlagBits::eDeviceLocal ) );
 
     // create transient buffer to copy data
+    auto size = mPixmap.data.size()*sizeof(mPixmap.data[0]);
     auto buffer = Buffer::New( mGraphics,
                                vk::BufferCreateInfo{}
                                  .setUsage( vk::BufferUsageFlagBits::eTransferSrc )
                                  .setSharingMode( vk::SharingMode::eExclusive )
-                                 .setSize( mPixmap.data.size()*sizeof(mPixmap.data[0]) ) );
+                                 .setSize( size ) );
 
     buffer->BindMemory( allocator.Allocate( buffer, vk::MemoryPropertyFlagBits::eHostVisible ) );
 
@@ -101,8 +104,7 @@ struct Texture
     auto copy = vk::BufferImageCopy{}.setImageExtent( { mPixmap.width, mPixmap.height, 1 } )
                          .setBufferImageHeight( mPixmap.height )
                          .setBufferOffset( 0 )
-                         .setBufferRowLength( mPixmap.width * mPixmap.bytesPerPixel )
-                         .setImageExtent( { mPixmap.width, mPixmap.height, 1 } )
+                         .setBufferRowLength( mPixmap.width )
                          .setImageOffset( { 0, 0, 0 } )
                          .setImageSubresource(
                            vk::ImageSubresourceLayers{}
@@ -117,7 +119,7 @@ struct Texture
 
     // change layout
     auto barrier = std::vector<vk::ImageMemoryBarrier>{
-      mCommandBuffer->ImageLayoutTransitionBarrier( mImage, vk::ImageLayout::eTransferDstOptimal, vk::ImageAspectFlagBits::eColor )
+      mCommandBuffer->ImageLayoutTransitionBarrier( mImage, vk::ImageLayout::ePreinitialized, vk::ImageLayout::eTransferDstOptimal, vk::ImageAspectFlagBits::eColor )
     };
 
     // change layout to prepare image to transfer data
@@ -125,12 +127,12 @@ struct Texture
                                      {}, {}, {}, { barrier } );
 
     // copy image
-    mCommandBuffer->CopyBufferToImage( buffer, mImage, vk::ImageLayout::ePreinitialized, { copy } );
+    mCommandBuffer->CopyBufferToImage( buffer, mImage, vk::ImageLayout::eTransferDstOptimal, { copy } );
 
     // change layout to shader read-only optimal
     mCommandBuffer->PipelineBarrier( vk::PipelineStageFlagBits::eVertexShader, vk::PipelineStageFlagBits::eVertexShader,
                                      {}, {}, {}, {
-                                       mCommandBuffer->ImageLayoutTransitionBarrier( mImage, vk::ImageLayout::eShaderReadOnlyOptimal, vk::ImageAspectFlagBits::eColor )
+                                       mCommandBuffer->ImageLayoutTransitionBarrier( mImage, vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eShaderReadOnlyOptimal, vk::ImageAspectFlagBits::eColor )
                                      } );
 
     mCommandBuffer->End();
@@ -203,8 +205,8 @@ Texture CreateTexture( Graphics& graphics, Pixmap pixmap )
 int TextureTestMain( Dali::Graphics::Vulkan::Graphics& graphics )
 {
   auto pixmap = GenerateTexture32BPPRGBA( 1024, 1024 );
-  auto texture = Texture( graphics, pixmap );
-  texture.Initialise();
+  auto texture = Dali::Graphics::Vulkan::Texture::New( graphics, 1024, 1024, vk::Format::eR8G8B8A8Unorm);
+
   return 0;
 }
 
index db38136..6b96904 100644 (file)
@@ -535,6 +535,7 @@ vk::ImageMemoryBarrier CommandBuffer::ImageLayoutTransitionBarrier( ImageRef ima
 }
 
 vk::ImageMemoryBarrier CommandBuffer::ImageLayoutTransitionBarrier( ImageRef image,
+                                                     vk::ImageLayout        oldLayout,
                                                      vk::ImageLayout        newLayout,
                                                      vk::ImageAspectFlags   aspectMask
 ) const
@@ -543,8 +544,6 @@ vk::ImageMemoryBarrier CommandBuffer::ImageLayoutTransitionBarrier( ImageRef ima
   vk::AccessFlags  srcAccessMask, dstAccessMask;
   vk::PipelineStageFlags srcStageMask, dstStageMask;
 
-  auto oldLayout = image->GetVkImageLayout();
-
   switch( oldLayout )
   {
     case vk::ImageLayout::ePreinitialized:
index 9deb97a..c312294 100644 (file)
@@ -236,6 +236,7 @@ public:
    * @return
    */
   vk::ImageMemoryBarrier ImageLayoutTransitionBarrier( ImageRef image,
+                                                       vk::ImageLayout        olsLayout,
                                                        vk::ImageLayout        newLayout,
                                                        vk::ImageAspectFlags   aspectMask
   ) const;
index d51a23b..40dfe11 100644 (file)
@@ -19,6 +19,7 @@
 #include <dali/graphics/vulkan/vulkan-graphics.h>
 #include <dali/graphics/vulkan/vulkan-buffer.h>
 #include <dali/graphics/vulkan/vulkan-image.h>
+#include <dali/graphics/vulkan/vulkan-sampler.h>
 
 namespace Dali
 {
@@ -163,6 +164,28 @@ struct DescriptorSet::Impl
     mGraphics.GetDevice().updateDescriptorSets( 1, &write, 0, nullptr  );
   }
 
+  void WriteCombinedImageSampler( uint32_t binding, SamplerRef sampler, ImageViewRef imageView )
+  {
+    // add resource to the list
+    mResources.emplace_back( sampler.StaticCast<VkManaged>() );
+    mResources.emplace_back( imageView.StaticCast<VkManaged>() );
+
+    auto imageViewInfo = vk::DescriptorImageInfo{}
+         .setImageLayout( vk::ImageLayout::eShaderReadOnlyOptimal )
+         .setImageView( imageView->GetVkImageView() )
+         .setSampler( sampler->GetVkSampler() );
+
+    auto write = vk::WriteDescriptorSet{}.setPImageInfo( &imageViewInfo )
+                                         .setDescriptorType( vk::DescriptorType::eCombinedImageSampler )
+                                         .setDescriptorCount( 1 )
+                                         .setDstSet( mVkDescriptorSet )
+                                         .setDstBinding( binding )
+                                         .setDstArrayElement( 0 );
+
+    // write descriptor set
+    mGraphics.GetDevice().updateDescriptorSets( 1, &write, 0, nullptr  );
+  }
+
   void WriteStorageBuffer( Handle<Buffer> buffer, uint32_t offset, uint32_t size )
   {
     mResources.emplace_back( buffer.StaticCast<VkManaged>() );
@@ -197,6 +220,10 @@ vk::DescriptorSet DescriptorSet::GetVkDescriptorSet() const
   return mImpl->mVkDescriptorSet;
 }
 
+void DescriptorSet::WriteCombinedImageSampler( uint32_t binding, SamplerRef sampler, ImageViewRef imageView )
+{
+  mImpl->WriteCombinedImageSampler( binding, sampler, imageView );
+}
 
 #if 0
 struct DescriptorSetLayout::Impl
index c42c3fc..7d4decc 100644 (file)
@@ -49,6 +49,13 @@ public:
 
   /**
    *
+   * @param binding
+   * @param sampler
+   * @param imageView
+   */
+  void WriteCombinedImageSampler( uint32_t binding, SamplerRef sampler, ImageViewRef imageView );
+  /**
+   *
    * @param buffer
    * @param offset
    * @param size
index ac89fc1..e7d856e 100644 (file)
@@ -18,6 +18,9 @@
 #include <dali/graphics/vulkan/vulkan-shader.h>
 #include <dali/graphics/vulkan/vulkan-framebuffer.h>
 #include <dali/graphics/vulkan/vulkan-surface.h>
+#include <dali/graphics/vulkan/vulkan-sampler.h>
+#include <dali/graphics/vulkan/vulkan-image.h>
+#include <dali/graphics/vulkan/vulkan-graphics-texture.h>
 
 using namespace glm;
 
@@ -140,6 +143,8 @@ struct Controller::Impl
                                                        .setInputRate( vk::VertexInputRate::eVertex )} );
     pipeline->SetInputAssemblyState( vk::PrimitiveTopology::eTriangleStrip, false );
 
+
+
     if( !pipeline->Compile() )
     {
       pipeline.Reset();
@@ -193,6 +198,7 @@ struct Controller::Impl
         mat4 mvp;
         vec4 color;
         vec3 size;
+        uint samplerId;
       } __attribute__( ( aligned( 16 ) ) );
 
       auto memory = state.uniformBuffer0->GetMemoryHandle();
@@ -210,6 +216,11 @@ struct Controller::Impl
 
         descriptorSets[0]->WriteUniformBuffer( 0, state.uniformBuffer0, i * uniformBlockOffsetStride, stride );
         descriptorSets[0]->WriteUniformBuffer( 1, state.uniformBuffer1, 0, state.uniformBuffer1->GetSize() );
+        if(inputData->samplerId > 0)
+        {
+          descriptorSets[0]->WriteCombinedImageSampler(2, mTextures[inputData->samplerId - 1]->GetSampler(),
+                                                       mTextures[inputData->samplerId - 1]->GetImageView());
+        }
 
         // record draw call
         auto cmdbuf = state.commandPool->NewCommandBuffer( false );
@@ -263,6 +274,45 @@ struct Controller::Impl
     return pool;
   }
 
+  void* CreateTexture( void* data, size_t sizeInBytes, uint32_t width, uint32_t height )
+  {
+    // AB: yup, yet another hack
+    auto texture = Dali::Graphics::Vulkan::Texture::New( mGraphics, width, height, vk::Format::eR8G8B8A8Unorm );
+
+    // check bpp, if 24bpp convert
+    if( sizeInBytes == width*height*3 )
+    {
+      uint8_t* inData = reinterpret_cast<uint8_t*>(data);
+      uint8_t* outData = new uint8_t[width*height*4];
+
+      auto outIdx = 0u;
+      for( auto i = 0u; i < sizeInBytes; i+= 3 )
+      {
+        outData[outIdx] = inData[i];
+        outData[outIdx+1] = inData[i+1];
+        outData[outIdx+2] = inData[i+2];
+        outData[outIdx+3] = 0xff;
+        outIdx += 4;
+      }
+
+      data = outData;
+      sizeInBytes = width*height*4;
+    }
+
+    // Upload data immediately. Will stall the queue :(
+    texture->UploadData( data, sizeInBytes, TextureUploadMode::eImmediate );
+
+    // push texture to the stack, return the buffer
+    mTextures.push_back( texture );
+
+    // return index for quick lookup
+    auto index = mTextures.size();
+    return *reinterpret_cast<void**>(&index);
+  }
+
+  // resources
+  std::vector<TextureRef> mTextures;
+
   Graphics&           mGraphics;
   Controller&         mOwner;
   GpuMemoryAllocator& mDefaultAllocator;
@@ -301,6 +351,11 @@ API::Accessor<API::Framebuffer> Controller::CreateFramebuffer( const API::BaseFa
 {
 }
 
+void* Controller::CreateTextureRGBA32( void* data, size_t sizeInBytes, uint32_t width, uint32_t height )
+{
+  return mImpl->CreateTexture( data, sizeInBytes, width, height );
+}
+
 std::unique_ptr<char> Controller::CreateBuffer( size_t numberOfElements, size_t elementSize )
 {
   return std::unique_ptr<char>( new char[numberOfElements * elementSize] );
index 7713c03..de59270 100644 (file)
@@ -82,6 +82,8 @@ public:
 
   std::unique_ptr<char> CreateBuffer( size_t numberOfElements, size_t elementSize ) override;
 
+  void* CreateTextureRGBA32( void* data, size_t sizeInBytes, uint32_t width, uint32_t height ) override;
+
   /**
    * @brief Get a render list
    */
diff --git a/dali/graphics/vulkan/vulkan-graphics-texture.cpp b/dali/graphics/vulkan/vulkan-graphics-texture.cpp
new file mode 100644 (file)
index 0000000..7018ce2
--- /dev/null
@@ -0,0 +1,317 @@
+/*
+ * 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.
+ *
+ */
+
+#include <dali/graphics/vulkan/vulkan-graphics-texture.h>
+#include <dali/graphics/vulkan/gpu-memory/vulkan-gpu-memory-allocator.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-command-pool.h>
+#include <dali/graphics/vulkan/vulkan-graphics.h>
+#include <dali/graphics/vulkan/vulkan-image.h>
+#include <dali/graphics/vulkan/vulkan-fence.h>
+#include <dali/graphics/vulkan/vulkan-queue.h>
+#include <dali/graphics/vulkan/vulkan-sampler.h>
+#include <thread>
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+using namespace Dali::Graphics::Vulkan;
+
+/**
+ * Helper structure, temporary
+ */
+struct Pixel
+{
+  Pixel() = default;
+
+  explicit Pixel( uint32_t _color ) : color( _color )
+  {
+  }
+
+  explicit Pixel( uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a )
+  {
+    components.r = _r;
+    components.g = _g;
+    components.b = _b;
+    components.a = _a;
+  }
+
+  union
+  {
+    uint32_t color;
+    struct
+    {
+      uint8_t r, g, b, a;
+    } components;
+  };
+
+  /*
+  uint8_t& r = components.r;
+  uint8_t& g = components.g;
+  uint8_t& b = components.b;
+  uint8_t& a = components.a;
+   */
+};
+
+struct Pixmap
+{
+  explicit Pixmap( std::vector<Pixel> _data, uint32_t _width, uint32_t _height )
+  : data( _data ), width( _width ), height( _height ), bytesPerPixel( 4 ), pixelFormat( vk::Format::eR8G8B8A8Unorm )
+  {
+  }
+
+  explicit Pixmap( uint32_t _width, uint32_t _height )
+  : width( _width ), height( _height ), bytesPerPixel( 4 ), pixelFormat( vk::Format::eR8G8B8A8Unorm )
+  {
+    data.resize( _width * _height );
+  }
+
+  std::vector<Pixel> data;
+  uint32_t           width;
+  uint32_t           height;
+  uint32_t           bytesPerPixel;
+  vk::Format         pixelFormat;
+};
+
+/**
+ * Texture::Impl
+ * Responsible for creating an image, basic image view, allocating texture memory,
+ * transfering the data into into the texture
+ *
+ */
+struct Texture::Impl
+{
+  Impl( Graphics& graphics, Pixmap pixmap ) : mGraphics( graphics ), mPixmap( pixmap )
+  {
+  }
+
+  Impl( Texture& owner, Graphics& graphics, uint32_t width, uint32_t height, vk::Format format ) : mGraphics( graphics ),
+                                                                                                   mPixmap( width, height )
+  {
+    mWidth = width;
+    mHeight = height;
+  }
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wframe-larger-than="
+  bool UploadData( void* data, uint32_t offsetInBytes, uint32_t sizeInBytes )
+  {
+    // create buffer
+    auto& allocator = mGraphics.GetDeviceMemoryManager().GetDefaultAllocator();
+    auto size   = mPixmap.data.size() * sizeof( mPixmap.data[0] );
+    auto buffer = Buffer::New( mGraphics,
+                               vk::BufferCreateInfo{}
+                                 .setUsage( vk::BufferUsageFlagBits::eTransferSrc )
+                                 .setSharingMode( vk::SharingMode::eExclusive )
+                                 .setSize( size ) );
+
+    buffer->BindMemory( allocator.Allocate( buffer, vk::MemoryPropertyFlagBits::eHostVisible ) );
+
+    // copy pixels to the buffer
+    auto ptr = buffer->GetMemoryHandle()->MapTyped<char>();
+    std::copy( reinterpret_cast<char*>(data),
+               reinterpret_cast<char*>(data) + sizeInBytes,
+               ptr );
+    buffer->GetMemoryHandle()->Unmap();
+
+    // record copy and layout change
+    auto copy = vk::BufferImageCopy{}
+      .setImageExtent( { mWidth, mHeight, 1} )
+      .setBufferImageHeight( mHeight )
+      .setBufferOffset( 0 )
+      .setBufferRowLength( mWidth )
+      .setImageOffset( {0, 0, 0} )
+      .setImageSubresource( vk::ImageSubresourceLayers{}
+                              .setMipLevel( 0 )
+                              .setAspectMask( vk::ImageAspectFlagBits::eColor )
+                              .setLayerCount( 1 )
+                              .setBaseArrayLayer( 0 ) );
+
+    if(!mCommandPool)
+    {
+      mCommandPool   = CommandPool::New(mGraphics);
+      mCommandBuffer = mCommandPool->NewCommandBuffer(true);
+    }
+    else
+    {
+      mCommandBuffer->Reset();
+    }
+
+    mCommandBuffer->Begin(vk::CommandBufferUsageFlagBits::eOneTimeSubmit);
+
+    // change layout
+    auto barrier = std::vector<vk::ImageMemoryBarrier>{mCommandBuffer->ImageLayoutTransitionBarrier(
+      mImage, vk::ImageLayout::ePreinitialized, vk::ImageLayout::eTransferDstOptimal, vk::ImageAspectFlagBits::eColor )};
+
+    // change layout to prepare image to transfer data
+    mCommandBuffer->PipelineBarrier(
+      vk::PipelineStageFlagBits::eTopOfPipe, vk::PipelineStageFlagBits::eTransfer, {}, {}, {}, {barrier} );
+
+    // copy image
+    mCommandBuffer->CopyBufferToImage( buffer, mImage, vk::ImageLayout::eTransferDstOptimal, {copy} );
+
+    // change layout to shader read-only optimal
+    mCommandBuffer->PipelineBarrier(
+      vk::PipelineStageFlagBits::eVertexShader,
+      vk::PipelineStageFlagBits::eVertexShader,
+      {},
+      {},
+      {},
+      {mCommandBuffer->ImageLayoutTransitionBarrier(
+        mImage, vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eShaderReadOnlyOptimal, vk::ImageAspectFlagBits::eColor )} );
+
+    mCommandBuffer->End();
+
+    // submit and wait till image is uploaded so temporary buffer can be destroyed safely
+    auto fence = Fence::New( mGraphics );
+    mGraphics.GetGraphicsQueue( 0u ).Submit( mCommandBuffer, fence );
+    fence->Wait();
+    return true;
+  }
+
+  // creates image with preallocated memory and default sampler, no data
+  // uploaded at this point
+  bool Initialise()
+  {
+    // create image
+    mImage = Image::New( mGraphics,
+                         vk::ImageCreateInfo{}
+                           .setFormat( mPixmap.pixelFormat )
+                           .setInitialLayout( vk::ImageLayout::ePreinitialized )
+                           .setSamples( vk::SampleCountFlagBits::e1 )
+                           .setSharingMode( vk::SharingMode::eExclusive )
+                           .setUsage( vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst )
+                           .setExtent( {mPixmap.width, mPixmap.height, 1} )
+                           .setArrayLayers( 1 )
+                           .setImageType( vk::ImageType::e2D )
+                           .setTiling( vk::ImageTiling::eOptimal )
+                           .setMipLevels( 1 ) );
+    // allocate memory and bind to the image
+    auto& allocator = mGraphics.GetDeviceMemoryManager().GetDefaultAllocator();
+    mImage->BindMemory( allocator.Allocate( mImage, vk::MemoryPropertyFlagBits::eDeviceLocal ) );
+
+    // create default image view
+    mImageView = ImageView::New( mGraphics, mImage );
+
+    // create basic sampler
+    CreateSampler();
+
+    return true;
+  }
+#pragma GCC diagnostic pop
+  void CreateSampler()
+  {
+    // mutable sampler creation will be deferred until it's used
+    mSampler = Sampler::New( mGraphics );
+    mSampler->SetAddressMode( vk::SamplerAddressMode::eClampToEdge,
+                              vk::SamplerAddressMode::eClampToEdge,
+                              vk::SamplerAddressMode::eClampToEdge );
+    mSampler->SetBorderColor( vk::BorderColor::eFloatOpaqueBlack );
+    mSampler->SetCompareOp( vk::CompareOp::eNever );
+    mSampler->SetFilter( vk::Filter::eLinear, vk::Filter::eLinear );
+    mSampler->SetMipmapMode( vk::SamplerMipmapMode::eLinear );
+
+    mSampler->GetVkSampler();
+  }
+
+  SamplerRef GetSampler() const
+  {
+    return mSampler;
+  }
+
+  Graphics&    mGraphics;
+  ImageRef     mImage;
+  ImageViewRef mImageView;
+  SamplerRef   mSampler;
+
+  // command pools should be 'per-thread' so they can be safely
+  // used withing one single thread before submitting them
+  CommandPoolRef   mCommandPool;
+  CommandBufferRef mCommandBuffer; // primary buffer, executed independent
+
+  // layouts
+  vk::ImageLayout mOldLayout;
+  vk::ImageLayout mNewLayout;
+
+  uint32_t mWidth { 0u }, mHeight { 0u };
+  // Command pool
+  Pixmap mPixmap;
+};
+
+/**
+ * Texture
+ *
+ */
+
+TextureRef Texture::New( Graphics& graphics, uint32_t width, uint32_t height, vk::Format format )
+{
+  auto result = TextureRef( new Texture( graphics, width, height, format ));
+  if( !result->mImpl->Initialise() )
+  {
+    result.Reset();
+  }
+  return result;
+}
+
+Texture::Texture( Graphics& graphics, uint32_t width, uint32_t height, vk::Format format )
+{
+  mImpl.reset( new Impl( *this, graphics, width, height, format ) );
+}
+
+
+/**
+ * Schedules data upload from CPU
+ * @param data
+ * @param size
+ * @param mode
+ */
+void Texture::UploadData( void* data, size_t size, TextureUploadMode mode )
+{
+  mImpl->UploadData( data, 0, U32(size) );
+}
+
+/**
+ *
+ * @param buffer
+ * @param mode
+ */
+void Texture::UploadFromBuffer( BufferRef buffer, TextureUploadMode mode )
+{
+
+}
+
+ImageRef Texture::GetImage() const
+{
+  return mImpl->mImage;
+}
+
+ImageViewRef Texture::GetImageView() const
+{
+  return mImpl->mImageView;
+}
+
+SamplerRef Texture::GetSampler() const
+{
+  return mImpl->mSampler;
+}
+
+} // namespace Vulkan
+} // namespace Graphics
+} // namespace Dali
\ No newline at end of file
diff --git a/dali/graphics/vulkan/vulkan-graphics-texture.h b/dali/graphics/vulkan/vulkan-graphics-texture.h
new file mode 100644 (file)
index 0000000..6962aa9
--- /dev/null
@@ -0,0 +1,104 @@
+#ifndef DALI_GRAPHICS_VULKAN_GRAPHICS_TEXTURE_H
+#define DALI_GRAPHICS_VULKAN_GRAPHICS_TEXTURE_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/vulkan/vulkan-types.h>
+#include <dali/graphics/graphics-controller.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+
+/**
+ *
+ */
+enum class TextureUploadMode
+{
+  eLazy,
+  eImmediate
+};
+
+/**
+ * This is temporary implementation. It should be using graphics-texture as base
+ * interface.
+ */
+class Texture : public VkManaged
+{
+public:
+
+  /**
+   * Creates new texture
+   * @param width
+   * @param height
+   * @param format
+   * @return
+   */
+  static Handle<Texture> New( Graphics& graphics, uint32_t width, uint32_t height, vk::Format format );
+
+  /**
+   * Schedules data upload from CPU
+   * @param data
+   * @param size
+   * @param mode
+   */
+  void UploadData( void* data, size_t size, TextureUploadMode mode );
+
+  /**
+   *
+   * @param buffer
+   * @param mode
+   */
+  void UploadFromBuffer( BufferRef buffer, TextureUploadMode mode );
+
+  /**
+   * Returns Image object
+   * @return
+   */
+  ImageRef GetImage() const;
+
+  /**
+   * Returns image view
+   * @return
+   */
+  ImageViewRef GetImageView() const;
+
+  /**
+   * Returns sampler
+   * @return
+   */
+  SamplerRef GetSampler() const;
+
+private:
+
+  explicit Texture( Graphics& graphics, uint32_t width, uint32_t height, vk::Format format );
+
+
+  struct Impl;
+  std::unique_ptr<Impl> mImpl;
+};
+
+using TextureRef = Handle<Texture>;
+}
+} // namespace Graphics
+} // namespace Dali
+#endif // DALI_GRAPHICS_VULKAN_GRAPHICS_TEXTURE_H
index 0c4d9c4..51447b5 100644 (file)
@@ -34,6 +34,7 @@ struct Image::Impl
     mCreateInfo( std::move( createInfo ) ),
     mIsExternal( static_cast<bool>( externalImage ) )
   {
+    mVkImageLayout = mCreateInfo.initialLayout;
   }
 
   ~Impl()
@@ -212,16 +213,22 @@ ImageViewRef ImageView::New( Graphics& graphics, ImageRef image, vk::ImageViewCr
 #pragma GCC diagnostic ignored "-Wframe-larger-than="
 ImageViewRef ImageView::New( Graphics& graphics, ImageRef image )
 {
+  vk::ComponentMapping componentsMapping = { vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB,vk::ComponentSwizzle::eA };
   vk::ImageAspectFlags aspectFlags{};
   if( image->GetVkImageUsageFlags() & vk::ImageUsageFlagBits::eColorAttachment )
   {
     aspectFlags |= vk::ImageAspectFlagBits::eColor;
+    //componentsMapping = { vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eB,vk::ComponentSwizzle::eA };
   }
   if( image->GetVkImageUsageFlags() & vk::ImageUsageFlagBits::eDepthStencilAttachment )
   {
     aspectFlags |= (vk::ImageAspectFlagBits::eDepth | vk::ImageAspectFlagBits::eStencil);
   }
-
+  if( image->GetVkImageUsageFlags() & vk::ImageUsageFlagBits::eSampled )
+  {
+    aspectFlags |= (vk::ImageAspectFlagBits::eColor);
+    //componentsMapping = { vk::ComponentSwizzle::eB, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eR,vk::ComponentSwizzle::eA };
+  }
   auto subresourceRange = vk::ImageSubresourceRange{}
     .setAspectMask( aspectFlags )
     .setBaseArrayLayer( 0 )
@@ -236,7 +243,7 @@ ImageViewRef ImageView::New( Graphics& graphics, ImageRef image )
                                                .setViewType( vk::ImageViewType::e2D )
                                                .setFormat( image->GetVkFormat() )
                                                .setSubresourceRange(subresourceRange)
-                                               .setComponents( { vk::ComponentSwizzle::eR, vk::ComponentSwizzle::eG, vk::ComponentSwizzle::eB,vk::ComponentSwizzle::eA } )
+                                               .setComponents( componentsMapping )
                                                 .setImage( image->GetVkImage() )));
   if(!retval->mImpl->Initialise())
   {
index 7d081bf..7d53eac 100644 (file)
@@ -265,6 +265,8 @@ public:
    */
   bool Create();
 
+
+
 private:
 
   ImageView( Graphics& graphics, ImageRef image, const VkImageViewCreateInfo& createInfo );
index 00b0bbd..48c98fb 100644 (file)
@@ -199,11 +199,17 @@ struct Pipeline::Impl
   void SetColorBlendState()
   {
     mAttachementNoBlendState = vk::PipelineColorBlendAttachmentState{};
-    //mAttachementNoBlendState.setBlendEnable( true );
+    mAttachementNoBlendState.setBlendEnable( true );
     mAttachementNoBlendState.setColorWriteMask( vk::ColorComponentFlagBits::eR |
                                                   vk::ColorComponentFlagBits::eG |
                                                   vk::ColorComponentFlagBits::eB |
                                                   vk::ColorComponentFlagBits::eA );
+    mAttachementNoBlendState.setSrcColorBlendFactor( vk::BlendFactor::eSrcAlpha );
+    mAttachementNoBlendState.setDstColorBlendFactor( vk::BlendFactor::eOneMinusSrc1Alpha );
+    mAttachementNoBlendState.setSrcAlphaBlendFactor( vk::BlendFactor::eOne );
+    mAttachementNoBlendState.setDstAlphaBlendFactor( vk::BlendFactor::eOneMinusSrc1Alpha );
+    mAttachementNoBlendState.setColorBlendOp( vk::BlendOp::eAdd );
+    mAttachementNoBlendState.setAlphaBlendOp( vk::BlendOp::eAdd );
 
     mColorBlendState.setBlendConstants( { 1.0f, 1.0f, 1.0f, 1.0f });
     mColorBlendState = vk::PipelineColorBlendStateCreateInfo{};
diff --git a/dali/graphics/vulkan/vulkan-sampler.cpp b/dali/graphics/vulkan/vulkan-sampler.cpp
new file mode 100644 (file)
index 0000000..3f44ec2
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * 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/vulkan/vulkan-sampler.h>
+#include <dali/graphics/vulkan/vulkan-graphics.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+
+struct Sampler::Impl
+{
+  Impl( Sampler& owner, Graphics& graphics, vk::SamplerCreateInfo info, bool immutable )
+  : mOwner( owner ), mGraphics( graphics ), mCreateInfo( info ), mImmutable( immutable ), mModified( true )
+  {
+
+  }
+
+  ~Impl()
+  {
+    DestroySafe();
+  }
+
+  bool CreateSampler()
+  {
+    if( !mModified )
+    {
+      return true;
+    }
+
+    if( mVkSampler )
+    {
+      DestroySafe();
+    }
+    mVkSampler = VkAssert( mGraphics.GetDevice().createSampler( mCreateInfo, mGraphics.GetAllocator()));
+
+    // push to the resource list in graphics
+
+    mModified = false;
+
+    return true;
+  }
+
+  void DestroySafe()
+  {
+    // fixme: push sampler to the destroy queue, will be destroyed with the end of the frame
+    mGraphics.GetDevice().destroySampler( mVkSampler );
+  }
+
+  Impl( const Impl& ) = delete;
+  Impl& operator=( const Impl& ) = delete;
+
+  Sampler&              mOwner;
+  Graphics&             mGraphics;
+  vk::SamplerCreateInfo mCreateInfo;
+  vk::Sampler           mVkSampler;
+  bool                  mImmutable;
+  bool                  mModified;
+};
+
+
+
+/**
+ * Sampler
+ */
+
+/**
+ * Creates new mutable sampler
+ * @param graphics
+ * @return
+ */
+SamplerRef Sampler::New( Graphics& graphics )
+{
+  return SamplerRef(new Sampler(graphics, vk::SamplerCreateInfo{}, false));
+}
+
+/**
+ * Creates new immutable sampler
+ * @param graphics
+ * @param createInfo
+ * @return
+ */
+SamplerRef Sampler::NewImmutable( Graphics& graphics, vk::SamplerCreateInfo createInfo )
+{
+  auto retval = SamplerRef(new Sampler(graphics, createInfo, true));
+  if( retval->mImpl->CreateSampler() )
+  {
+    return retval;
+  }
+  return SamplerRef();
+}
+
+Sampler::Sampler( Graphics& graphics, vk::SamplerCreateInfo createInfo, bool immutable )
+{
+  mImpl.reset(new Impl( *this, graphics, createInfo, immutable ));
+}
+
+Sampler::~Sampler() = default;
+
+/**
+ * Sets minification and magnifcation filters
+ * @param minFilter
+ * @param magFilter
+ */
+void Sampler::SetFilter( vk::Filter minFilter, vk::Filter magFilter )
+{
+  mImpl->mCreateInfo.setMinFilter( minFilter );
+  mImpl->mCreateInfo.setMagFilter( magFilter );
+  mImpl->mModified = true;
+}
+
+/**
+ * Sets UVW address mode
+ * @param addressModeU
+ * @param addressModeV
+ * @param addressModeW
+ */
+void Sampler::SetAddressMode( vk::SamplerAddressMode addressModeU,
+                     vk::SamplerAddressMode addressModeV,
+                     vk::SamplerAddressMode addressModeW )
+{
+  mImpl->mCreateInfo.setAddressModeU( addressModeU );
+  mImpl->mCreateInfo.setAddressModeV( addressModeV );
+  mImpl->mCreateInfo.setAddressModeW( addressModeW );
+  mImpl->mModified = true;
+}
+
+void Sampler::SetLod( float minLod, float maxLod )
+{
+  mImpl->mCreateInfo.setMinLod( minLod ).setMaxLod( maxLod );
+  mImpl->mModified = true;
+}
+
+void Sampler::EnableAnisotropy( bool enabled )
+{
+  mImpl->mCreateInfo.setAnisotropyEnable( enabled );
+  mImpl->mModified = true;
+}
+
+void Sampler::SetMipmapMode( vk::SamplerMipmapMode mode )
+{
+  mImpl->mCreateInfo.setMipmapMode( mode );
+  mImpl->mModified = true;
+}
+
+void Sampler::SetMaxAnisotropy( float maxAnisotropy )
+{
+  mImpl->mCreateInfo.setMaxAnisotropy( maxAnisotropy );
+  mImpl->mModified = true;
+}
+
+void Sampler::EnableCompare( bool enabled )
+{
+  mImpl->mCreateInfo.setCompareEnable( enabled );
+  mImpl->mModified = true;
+}
+
+void Sampler::SetBorderColor( vk::BorderColor color )
+{
+  mImpl->mCreateInfo.setBorderColor( color );
+  mImpl->mModified = true;
+}
+
+void Sampler::UseUnnormalizedCoordinates( bool enabled )
+{
+  mImpl->mCreateInfo.setUnnormalizedCoordinates( enabled );
+  mImpl->mModified = true;
+}
+
+void Sampler::SetCompareOp( vk::CompareOp compareOp )
+{
+  mImpl->mCreateInfo.setCompareOp( compareOp );
+  mImpl->mModified = true;
+}
+
+vk::Sampler Sampler::GetVkSampler() const
+{
+  // if no sampler yet, create it now
+  if( mImpl->mModified )
+  {
+    mImpl->CreateSampler();
+  }
+  return mImpl->mVkSampler;
+}
+
+} // namespace Vulkan
+} // namespace Graphics
+} // namespace Dali
\ No newline at end of file
diff --git a/dali/graphics/vulkan/vulkan-sampler.h b/dali/graphics/vulkan/vulkan-sampler.h
new file mode 100644 (file)
index 0000000..a327d03
--- /dev/null
@@ -0,0 +1,135 @@
+#ifndef DALI_GRAPHICS_VULKAN_SAMPLER_H
+#define DALI_GRAPHICS_VULKAN_SAMPLER_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/vulkan/vulkan-types.h>
+
+namespace Dali
+{
+namespace Graphics
+{
+namespace Vulkan
+{
+class Graphics;
+class Sampler : public VkManaged
+{
+public:
+
+  /**
+   * Creates new mutable sampler
+   * @param graphics
+   * @return
+   */
+  static SamplerRef New( Graphics& graphics );
+
+  /**
+   * Creates new immutable sampler
+   * @param graphics
+   * @param createInfo
+   * @return
+   */
+  static SamplerRef NewImmutable( Graphics& graphics, vk::SamplerCreateInfo createInfo );
+
+  /**
+   * Sets minification and magnifcation filters
+   * @param minFilter
+   * @param magFilter
+   */
+  void SetFilter( vk::Filter minFilter, vk::Filter magFilter );
+
+  /**
+   * Sets UVW address mode
+   * @param addressModeU
+   * @param addressModeV
+   * @param addressModeW
+   */
+  void SetAddressMode( vk::SamplerAddressMode addressModeU,
+                       vk::SamplerAddressMode addressModeV,
+                       vk::SamplerAddressMode addressModeW );
+
+  /**
+   * Sets minimum and maximum LOD
+   * @param minLod
+   * @param maxLod
+   */
+  void SetLod( float minLod, float maxLod );
+
+  /**
+   * Enables anisotropy
+   * @param enabled
+   */
+  void EnableAnisotropy( bool enabled );
+
+  /**
+   * Sets mipmap mode
+   * @param mode
+   */
+  void SetMipmapMode( vk::SamplerMipmapMode mode );
+
+  /**
+   * Sets maximum anisotropy
+   * @param maxAnisotropy
+   */
+  void SetMaxAnisotropy( float maxAnisotropy );
+
+  /**
+   * Turns on/off comparison with reference value when sampling
+   * @param enabled
+   */
+  void EnableCompare( bool enabled );
+
+  /**
+   * Specifies predefined border color to use
+   * @param color
+   */
+  void SetBorderColor( vk::BorderColor color );
+
+  /**
+   * Enables/disables use of unnormalized texture coordinates
+   * @param enabled
+   */
+  void UseUnnormalizedCoordinates( bool enabled );
+
+  /**
+   * Specifies comparison function used when comparing with reference value
+   * @param compareOp
+   */
+  void SetCompareOp( vk::CompareOp compareOp );
+
+  /**
+   * Returns VkSampler object
+   * @return
+   */
+  vk::Sampler GetVkSampler() const;
+
+private:
+
+  explicit Sampler( Graphics& graphics, vk::SamplerCreateInfo createInfo, bool immutable );
+
+  ~Sampler() override;
+
+  struct Impl;
+  std::unique_ptr<Impl> mImpl;
+
+};
+} // namespace Vulkan
+} // namespace Graphics
+} // namespace Dali
+#endif //DALI_GRAPHICS_VULKAN_SAMPLER_H
index 6e7c1a4..6e75215 100644 (file)
@@ -319,7 +319,7 @@ using GpuMemoryBlockRef = Handle<class GpuMemoryBlock>;
 using DescriptorSetRef = Handle<class DescriptorSet>;
 using SwapchainRef = Handle<class Swapchain>;
 using SurfaceRef = Handle<class Surface>;
-
+using SamplerRef = Handle<class Sampler>;
 /*
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wframe-larger-than="
index 3c3bbbd..a75aa6d 100644 (file)
@@ -151,7 +151,8 @@ bool Texture::Upload( PixelDataPtr pixelData,
                                     static_cast< uint16_t >( yOffset ),
                                     static_cast< uint16_t >( width ),
                                     static_cast< uint16_t >( height ) };
-            UploadTextureMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, pixelData, params );
+            //UploadTextureMessage( mEventThreadServices.GetUpdateManager(), *mRenderObject, pixelData, params );
+            UploadTextureMessageV2( mEventThreadServices.GetUpdateManager(), *mRenderObject, pixelData, params );
 
             // Request event processing and update forcely
             mEventThreadServices.GetRenderController().RequestProcessEventsOnIdle( true );
index d9192e0..81299e0 100644 (file)
@@ -136,6 +136,11 @@ public:
     return mNativeImage;
   }
 
+  void SetId( void* textureId )
+  {
+    mId = *reinterpret_cast<GLuint*>(&textureId);
+  }
+
 private:
 
   /**
index 2f53a40..a6a7dd8 100644 (file)
@@ -17,7 +17,8 @@
 
 // CLASS HEADER
 #include <dali/internal/update/graphics/graphics-algorithms.h>
-
+#include <dali/internal/update/rendering/scene-graph-texture-set.h>
+#include <glm/glm.hpp>
 // EXTERNAL INCLUDES
 
 #include <dali/graphics-api/graphics-api-controller.h>
@@ -48,7 +49,7 @@ void SubmitRenderItemList( Graphics::API::Controller&           graphics,
   //commandBuilder.Set( );
 
   // TODO: @todo Clipping...
-
+  using InternalTextureSet = Dali::Internal::SceneGraph::TextureSet;
   auto numberOfRenderItems = renderItemList.Count();
 
   using DataT = struct
@@ -56,16 +57,40 @@ void SubmitRenderItemList( Graphics::API::Controller&           graphics,
     Matrix  world;
     Vector4 color;
     Vector3 size;
+    uint32_t samplerId;
   } __attribute__((aligned(16)));
 
   auto uniformBuffer = graphics.CreateBuffer<DataT>( numberOfRenderItems );
   auto data = uniformBuffer->GetData();
+
+  // TODO: for now texture id is passed through the buffer however
+  // it isn't used by shader but only used to extract which texture
+  // should be used during rendering an item.
+  uint32_t opaqueTextureId = 0;
   for( auto i = 0u; i < numberOfRenderItems; ++i )
   {
     auto& item = renderItemList.GetItem( i );
+
+    if(item.mTextureSet)
+    {
+
+      InternalTextureSet* textureSet = const_cast<InternalTextureSet*>(reinterpret_cast<const InternalTextureSet*>(item.mTextureSet));
+
+      auto textureId = textureSet->GetTexture(0)->GetId();
+
+      std::cout << "TextureCount: " << textureSet->GetTextureCount() <<
+                ", texture id: " << textureId <<
+      std::endl;
+      opaqueTextureId = textureId;
+    }
+    else
+    {
+      std::cout << "TextureCount: 0";
+    }
     Matrix::Multiply( data[i].world, item.mModelMatrix, viewProjection );
     data[i].color = item.mNode->GetWorldColor( bufferIndex );
     data[i].size  = item.mSize;
+    data[i].samplerId = opaqueTextureId;
   }
   commandBuilder.Set( Graphics::API::PrimitiveCount{numberOfRenderItems} );
 
index b4035e8..e64fb71 100644 (file)
@@ -193,6 +193,7 @@ inline void AddRendererToRenderList( BufferIndex updateBufferIndex,
       else
       {
         item.mRenderer = nullptr;
+        item.mTextureSet = nullptr;
       }
 
       // Save ModelView matrix onto the item.
index f6e960d..c55f1fd 100644 (file)
@@ -926,6 +926,7 @@ unsigned int UpdateManager::Update( float elapsedSeconds,
         }
       }
       // generate graphics objects
+      (*mImpl);
       SubmitRenderInstructions( mImpl->graphics.GetController(), mImpl->renderInstructions, bufferIndex );
     }
   }
@@ -1254,6 +1255,22 @@ void UpdateManager::UploadTexture( Render::Texture* texture, PixelDataPtr pixelD
   new (slot) DerivedType( &mImpl->renderManager, &RenderManager::UploadTexture, texture, pixelData, params );
 }
 
+void UpdateManager::UploadTextureV2( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
+{
+  //fixme: AB: This is temporary solution to create a texture object on the Graphics API side
+  //fixme:     using controller directly in the update thread
+  auto& controller = mImpl->graphics.GetController();
+
+  // function returns an opaque object which has to be stored in the texture implementation
+  auto textureId = controller.CreateTextureRGBA32( pixelData->GetBuffer(), pixelData->GetBufferSize(),
+  pixelData->GetWidth(), pixelData->GetHeight());
+
+  // AB: workaround, assigning instantly texture Id to the render object
+  texture->SetId( textureId );
+
+  std::cout << textureId << std::endl;
+}
+
 void UpdateManager::GenerateMipmaps( Render::Texture* texture )
 {
   typedef MessageValue1< RenderManager, Render::Texture* > DerivedType;
index 41e3eda..efbb11a 100644 (file)
@@ -521,6 +521,8 @@ public:
    */
   void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params );
 
+  void UploadTextureV2( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params );
+
   /**
    * Generates mipmaps for a texture owned by the RenderManager
    * @param[in] texture The texture
@@ -1246,6 +1248,17 @@ inline void UploadTextureMessage( UpdateManager& manager, Render::Texture& textu
   new (slot) LocalType( &manager, &UpdateManager::UploadTexture, &texture, pixelData, params );
 }
 
+inline void UploadTextureMessageV2( UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params )
+{
+  typedef MessageValue3< UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &manager, &UpdateManager::UploadTextureV2, &texture, pixelData, params );
+}
+
 inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& texture )
 {
   typedef MessageValue1< UpdateManager, Render::Texture*  > LocalType;