From: adam.b Date: Wed, 21 Mar 2018 15:59:02 +0000 (+0000) Subject: [Vulkan] Sampler and texture support - something is rendering X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0deaaee3dc5990ae0a1bdac353826e8bdd60f021;p=platform%2Fcore%2Fuifw%2Fdali-core.git [Vulkan] Sampler and texture support - something is rendering - 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 --- diff --git a/dali/graphics-api/graphics-api-controller.h b/dali/graphics-api/graphics-api-controller.h index 26a3df2..6f4667c 100644 --- a/dali/graphics-api/graphics-api-controller.h +++ b/dali/graphics-api/graphics-api-controller.h @@ -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 diff --git a/dali/graphics/file.list b/dali/graphics/file.list index f4a0c43..a602549 100644 --- a/dali/graphics/file.list +++ b/dali/graphics/file.list @@ -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 diff --git a/dali/graphics/graphics-texture.h b/dali/graphics/graphics-texture.h index 2a51df0..920330a 100644 --- a/dali/graphics/graphics-texture.h +++ b/dali/graphics/graphics-texture.h @@ -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 index 0000000..726e481 --- /dev/null +++ b/dali/graphics/vulkan/api/vulkan-texture-factory.cpp @@ -0,0 +1,40 @@ +#include +#include +#include + +namespace Dali +{ +namespace Graphics +{ +namespace API +{ + +std::unique_ptr 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 diff --git a/dali/graphics/vulkan/generated/spv-shaders-gen.cpp b/dali/graphics/vulkan/generated/spv-shaders-gen.cpp index 7cb07c3..3adbd5e 100644 --- a/dali/graphics/vulkan/generated/spv-shaders-gen.cpp +++ b/dali/graphics/vulkan/generated/spv-shaders-gen.cpp @@ -3,173 +3,218 @@ #pragma GCC diagnostic ignored "-Wlarger-than=" std::vector 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 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 diff --git a/dali/graphics/vulkan/generated/spv-shaders-gen.h b/dali/graphics/vulkan/generated/spv-shaders-gen.h index 7297c75..656a8a8 100644 --- a/dali/graphics/vulkan/generated/spv-shaders-gen.h +++ b/dali/graphics/vulkan/generated/spv-shaders-gen.h @@ -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 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; }*/ diff --git a/dali/graphics/vulkan/shaders/basic-shader.frag b/dali/graphics/vulkan/shaders/basic-shader.frag index 63e6c1c..4e087ac 100644 --- a/dali/graphics/vulkan/shaders/basic-shader.frag +++ b/dali/graphics/vulkan/shaders/basic-shader.frag @@ -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 diff --git a/dali/graphics/vulkan/shaders/basic-shader.vert b/dali/graphics/vulkan/shaders/basic-shader.vert index 20ac3f7..8742031 100644 --- a/dali/graphics/vulkan/shaders/basic-shader.vert +++ b/dali/graphics/vulkan/shaders/basic-shader.vert @@ -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 diff --git a/dali/graphics/vulkan/tests/texture-test.cpp b/dali/graphics/vulkan/tests/texture-test.cpp index b7152a3..edc458a 100644 --- a/dali/graphics/vulkan/tests/texture-test.cpp +++ b/dali/graphics/vulkan/tests/texture-test.cpp @@ -13,6 +13,8 @@ #include #include +#include + namespace VulkanTest { @@ -47,7 +49,7 @@ struct Pixel struct Pixmap { explicit Pixmap( std::vector _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 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{ - 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; } diff --git a/dali/graphics/vulkan/vulkan-command-buffer.cpp b/dali/graphics/vulkan/vulkan-command-buffer.cpp index db38136..6b96904 100644 --- a/dali/graphics/vulkan/vulkan-command-buffer.cpp +++ b/dali/graphics/vulkan/vulkan-command-buffer.cpp @@ -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: diff --git a/dali/graphics/vulkan/vulkan-command-buffer.h b/dali/graphics/vulkan/vulkan-command-buffer.h index 9deb97a..c312294 100644 --- a/dali/graphics/vulkan/vulkan-command-buffer.h +++ b/dali/graphics/vulkan/vulkan-command-buffer.h @@ -236,6 +236,7 @@ public: * @return */ vk::ImageMemoryBarrier ImageLayoutTransitionBarrier( ImageRef image, + vk::ImageLayout olsLayout, vk::ImageLayout newLayout, vk::ImageAspectFlags aspectMask ) const; diff --git a/dali/graphics/vulkan/vulkan-descriptor-set.cpp b/dali/graphics/vulkan/vulkan-descriptor-set.cpp index d51a23b..40dfe11 100644 --- a/dali/graphics/vulkan/vulkan-descriptor-set.cpp +++ b/dali/graphics/vulkan/vulkan-descriptor-set.cpp @@ -19,6 +19,7 @@ #include #include #include +#include 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() ); + mResources.emplace_back( imageView.StaticCast() ); + + 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, uint32_t offset, uint32_t size ) { mResources.emplace_back( buffer.StaticCast() ); @@ -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 diff --git a/dali/graphics/vulkan/vulkan-descriptor-set.h b/dali/graphics/vulkan/vulkan-descriptor-set.h index c42c3fc..7d4decc 100644 --- a/dali/graphics/vulkan/vulkan-descriptor-set.h +++ b/dali/graphics/vulkan/vulkan-descriptor-set.h @@ -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 diff --git a/dali/graphics/vulkan/vulkan-graphics-controller.cpp b/dali/graphics/vulkan/vulkan-graphics-controller.cpp index ac89fc1..e7d856e 100644 --- a/dali/graphics/vulkan/vulkan-graphics-controller.cpp +++ b/dali/graphics/vulkan/vulkan-graphics-controller.cpp @@ -18,6 +18,9 @@ #include #include #include +#include +#include +#include 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(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(&index); + } + + // resources + std::vector mTextures; + Graphics& mGraphics; Controller& mOwner; GpuMemoryAllocator& mDefaultAllocator; @@ -301,6 +351,11 @@ API::Accessor 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 Controller::CreateBuffer( size_t numberOfElements, size_t elementSize ) { return std::unique_ptr( new char[numberOfElements * elementSize] ); diff --git a/dali/graphics/vulkan/vulkan-graphics-controller.h b/dali/graphics/vulkan/vulkan-graphics-controller.h index 7713c03..de59270 100644 --- a/dali/graphics/vulkan/vulkan-graphics-controller.h +++ b/dali/graphics/vulkan/vulkan-graphics-controller.h @@ -82,6 +82,8 @@ public: std::unique_ptr 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 index 0000000..7018ce2 --- /dev/null +++ b/dali/graphics/vulkan/vulkan-graphics-texture.cpp @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +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 _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 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(); + std::copy( reinterpret_cast(data), + reinterpret_cast(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{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 index 0000000..6962aa9 --- /dev/null +++ b/dali/graphics/vulkan/vulkan-graphics-texture.h @@ -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 +#include + +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 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 mImpl; +}; + +using TextureRef = Handle; +} +} // namespace Graphics +} // namespace Dali +#endif // DALI_GRAPHICS_VULKAN_GRAPHICS_TEXTURE_H diff --git a/dali/graphics/vulkan/vulkan-image.cpp b/dali/graphics/vulkan/vulkan-image.cpp index 0c4d9c4..51447b5 100644 --- a/dali/graphics/vulkan/vulkan-image.cpp +++ b/dali/graphics/vulkan/vulkan-image.cpp @@ -34,6 +34,7 @@ struct Image::Impl mCreateInfo( std::move( createInfo ) ), mIsExternal( static_cast( 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()) { diff --git a/dali/graphics/vulkan/vulkan-image.h b/dali/graphics/vulkan/vulkan-image.h index 7d081bf..7d53eac 100644 --- a/dali/graphics/vulkan/vulkan-image.h +++ b/dali/graphics/vulkan/vulkan-image.h @@ -265,6 +265,8 @@ public: */ bool Create(); + + private: ImageView( Graphics& graphics, ImageRef image, const VkImageViewCreateInfo& createInfo ); diff --git a/dali/graphics/vulkan/vulkan-pipeline.cpp b/dali/graphics/vulkan/vulkan-pipeline.cpp index 00b0bbd..48c98fb 100644 --- a/dali/graphics/vulkan/vulkan-pipeline.cpp +++ b/dali/graphics/vulkan/vulkan-pipeline.cpp @@ -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 index 0000000..3f44ec2 --- /dev/null +++ b/dali/graphics/vulkan/vulkan-sampler.cpp @@ -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 +#include + +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 index 0000000..a327d03 --- /dev/null +++ b/dali/graphics/vulkan/vulkan-sampler.h @@ -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 + +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 mImpl; + +}; +} // namespace Vulkan +} // namespace Graphics +} // namespace Dali +#endif //DALI_GRAPHICS_VULKAN_SAMPLER_H diff --git a/dali/graphics/vulkan/vulkan-types.h b/dali/graphics/vulkan/vulkan-types.h index 6e7c1a4..6e75215 100644 --- a/dali/graphics/vulkan/vulkan-types.h +++ b/dali/graphics/vulkan/vulkan-types.h @@ -319,7 +319,7 @@ using GpuMemoryBlockRef = Handle; using DescriptorSetRef = Handle; using SwapchainRef = Handle; using SurfaceRef = Handle; - +using SamplerRef = Handle; /* #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wframe-larger-than=" diff --git a/dali/internal/event/rendering/texture-impl.cpp b/dali/internal/event/rendering/texture-impl.cpp index 3c3bbbd..a75aa6d 100644 --- a/dali/internal/event/rendering/texture-impl.cpp +++ b/dali/internal/event/rendering/texture-impl.cpp @@ -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 ); diff --git a/dali/internal/render/renderers/render-texture.h b/dali/internal/render/renderers/render-texture.h index d9192e0..81299e0 100644 --- a/dali/internal/render/renderers/render-texture.h +++ b/dali/internal/render/renderers/render-texture.h @@ -136,6 +136,11 @@ public: return mNativeImage; } + void SetId( void* textureId ) + { + mId = *reinterpret_cast(&textureId); + } + private: /** diff --git a/dali/internal/update/graphics/graphics-algorithms.cpp b/dali/internal/update/graphics/graphics-algorithms.cpp index 2f53a40..a6a7dd8 100644 --- a/dali/internal/update/graphics/graphics-algorithms.cpp +++ b/dali/internal/update/graphics/graphics-algorithms.cpp @@ -17,7 +17,8 @@ // CLASS HEADER #include - +#include +#include // EXTERNAL INCLUDES #include @@ -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( 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(reinterpret_cast(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} ); diff --git a/dali/internal/update/manager/render-instruction-processor.cpp b/dali/internal/update/manager/render-instruction-processor.cpp index b4035e8..e64fb71 100644 --- a/dali/internal/update/manager/render-instruction-processor.cpp +++ b/dali/internal/update/manager/render-instruction-processor.cpp @@ -193,6 +193,7 @@ inline void AddRendererToRenderList( BufferIndex updateBufferIndex, else { item.mRenderer = nullptr; + item.mTextureSet = nullptr; } // Save ModelView matrix onto the item. diff --git a/dali/internal/update/manager/update-manager.cpp b/dali/internal/update/manager/update-manager.cpp index f6e960d..c55f1fd 100644 --- a/dali/internal/update/manager/update-manager.cpp +++ b/dali/internal/update/manager/update-manager.cpp @@ -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; diff --git a/dali/internal/update/manager/update-manager.h b/dali/internal/update/manager/update-manager.h index 41e3eda..efbb11a 100644 --- a/dali/internal/update/manager/update-manager.h +++ b/dali/internal/update/manager/update-manager.h @@ -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;