[Vulkan] Graphics API cleanup
authoradam.b <jsr184@gmail.com>
Fri, 18 May 2018 12:07:04 +0000 (13:07 +0100)
committeradam.b <jsr184@gmail.com>
Fri, 25 May 2018 14:00:50 +0000 (15:00 +0100)
- Removed redundant API classes
- Simplified

Change-Id: Ibb5f1ecf4a6f15d7e40fe9a9076cf5e236110bd1

16 files changed:
dali/graphics-api/graphics-api-accessor.h
dali/graphics-api/graphics-api-controller.h
dali/graphics-api/graphics-api-dynamic-buffer.h [deleted file]
dali/graphics-api/graphics-api-frame.h [deleted file]
dali/graphics-api/graphics-api-generic-buffer.h [deleted file]
dali/graphics-api/graphics-api-render-command.h
dali/graphics-api/graphics-api-render-item-list.h [deleted file]
dali/graphics-api/graphics-api-render-list.h [deleted file]
dali/graphics-api/graphics-api-static-buffer.h [deleted file]
dali/graphics-api/graphics-api-texture-details.h
dali/graphics-api/graphics-api-texture-set.h [deleted file]
dali/graphics/graphics-controller.h [deleted file]
dali/graphics/vulkan/api/vulkan-api-render-command.cpp
dali/graphics/vulkan/api/vulkan-api-render-command.h
dali/graphics/vulkan/api/vulkan-api-texture.cpp
dali/graphics/vulkan/api/vulkan-api-texture.h

index 10c80f5..1f261d5 100644 (file)
@@ -47,6 +47,10 @@ public:
 
   bool Exists() const
   {
+    if( !mOwner )
+    {
+      return false;
+    }
     return GetOwner().Contains(mHandle);
   }
 
index c996efb..7251111 100644 (file)
 // INTERNAL INCLUDES
 #include <dali/graphics-api/graphics-api-accessor.h>
 #include <dali/graphics-api/graphics-api-base-factory.h>
-#include <dali/graphics-api/graphics-api-dynamic-buffer.h>
-#include <dali/graphics-api/graphics-api-frame.h>
 #include <dali/graphics-api/graphics-api-framebuffer.h>
-#include <dali/graphics-api/graphics-api-generic-buffer.h>
 #include <dali/graphics-api/graphics-api-render-command.h>
 #include <dali/graphics-api/graphics-api-sampler.h>
 #include <dali/graphics-api/graphics-api-shader.h>
 #include <dali/graphics-api/graphics-api-shader-details.h>
 #include <dali/graphics-api/graphics-api-shader-factory.h>
-#include <dali/graphics-api/graphics-api-static-buffer.h>
 #include <dali/graphics-api/graphics-api-texture-factory.h>
-#include <dali/graphics-api/graphics-api-texture-set.h>
 #include <dali/graphics-api/graphics-api-texture.h>
 #include <dali/graphics-api/graphics-api-buffer.h>
 #include <dali/graphics-api/graphics-api-buffer-factory.h>
@@ -67,26 +62,11 @@ public:
   /**
    * @brief Create a new object
    */
-  virtual Accessor<TextureSet> CreateTextureSet( const BaseFactory<TextureSet>& factory ) = 0;
-
-  /**
-   * @brief Create a new object
-   */
-  virtual Accessor<DynamicBuffer> CreateDynamicBuffer( const BaseFactory<DynamicBuffer>& factory ) = 0;
-
-  /**
-   * @brief Create a new object
-   */
   virtual Accessor<Buffer> CreateBuffer( const BaseFactory<Buffer>& factory ) = 0;
 
   /**
    * @brief Create a new object
    */
-  virtual Accessor<StaticBuffer> CreateStaticBuffer( const BaseFactory<StaticBuffer>& factory ) = 0;
-
-  /**
-   * @brief Create a new object
-   */
   virtual Accessor<Sampler> CreateSampler( const BaseFactory<Sampler>& factory ) = 0;
 
   /**
@@ -118,17 +98,6 @@ public:
   virtual BufferFactory& GetBufferFactory() const = 0;
 
   /**
-   * @brief Create a buffer
-   */
-  template<typename T>
-  std::unique_ptr<GenericBuffer<T>> CreateBuffer( size_t numberOfElements );
-
-  /**
-   * @brief Submit a render command
-   */
-  virtual void SubmitCommand( API::RenderCommand&& command ) = 0;
-
-  /**
    * @brief alAllocates render command ( depends on implementation );
    * @return
    */
@@ -165,8 +134,6 @@ protected:
    */
   Controller() = default;
 
-
-
   /**
    * @brief create an element for the given number of elements and element size
    */
@@ -175,12 +142,6 @@ protected:
 private:
 };
 
-template<typename T>
-std::unique_ptr<GenericBuffer<T>> Controller::CreateBuffer( size_t numberOfElements )
-{
-    return std::make_unique<GenericBuffer<T>>(numberOfElements, std::move(CreateBuffer( numberOfElements, sizeof( T ) )));
-}
-
 } // namespace API
 } // namespace Graphics
 } // namespace Dali
diff --git a/dali/graphics-api/graphics-api-dynamic-buffer.h b/dali/graphics-api/graphics-api-dynamic-buffer.h
deleted file mode 100644 (file)
index d276609..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef DALI_GRAPHICS_API_DYNAMIC_BUFFER_H
-#define DALI_GRAPHICS_API_DYNAMIC_BUFFER_H
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-namespace Dali
-{
-namespace Graphics
-{
-namespace API
-{
-
-/**
- * @brief Interface class for DynamicBuffer types in the graphics API.
- */
-class DynamicBuffer
-{
-public:
-  // not copyable
-  DynamicBuffer(const DynamicBuffer&) = delete;
-  DynamicBuffer& operator=(const DynamicBuffer&) = delete;
-
-  virtual ~DynamicBuffer() = default;
-
-protected:
-  // derived types should not be moved direcly to prevent slicing
-  DynamicBuffer(DynamicBuffer&&) = default;
-  DynamicBuffer& operator=(DynamicBuffer&&) = default;
-
-  /**
-   * Objects of this type should not directly.
-   */
-  DynamicBuffer() = default;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_DYNAMIC_BUFFER_H
diff --git a/dali/graphics-api/graphics-api-frame.h b/dali/graphics-api/graphics-api-frame.h
deleted file mode 100644 (file)
index e151941..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef DALI_GRAPHICS_API_FRAME_H
-#define DALI_GRAPHICS_API_FRAME_H
-
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-namespace Dali
-{
-namespace Graphics
-{
-namespace API
-{
-/**
- * @brief Interface class for Frame types in the graphics API.
- *
- * A frame is used to mark the beginning and end of a presentation cycle.
- */
-class Frame
-{
-public:
-
-  // not copyable
-  Frame(const Frame&) = delete;
-  Frame& operator=(const Frame&) = delete;
-
-  virtual ~Frame() = default;
-
-//TODO: @todo this should be protected
-
-
-  // derived types should not be moved direcly to prevent slicing
-  Frame(Frame&&) = default;
-  Frame& operator=(Frame&&) = default;
-
-  /**
-   * Objects of this type should not directly.
-   */
-  Frame() = default;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_FRAME_H
diff --git a/dali/graphics-api/graphics-api-generic-buffer.h b/dali/graphics-api/graphics-api-generic-buffer.h
deleted file mode 100644 (file)
index dada456..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifndef DALI_GRAPHICS_API_GENERIC_BUFFER_H
-#define DALI_GRAPHICS_API_GENERIC_BUFFER_H
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <cstddef>
-#include <memory>
-
-namespace Dali
-{
-namespace Graphics
-{
-namespace API
-{
-class GenericBufferBase
-{
-public:
-  enum class UsageHint
-  {
-    FRAME_CONSTANTS,
-    PRIMITIVE_UNIFORMS,
-    ATTRIBUTES,
-    INSTANCE,
-    INDEX_BUFFER,
-  };
-
-  GenericBufferBase( size_t size, std::unique_ptr<char>&& data ) : mSize{size}, mData( std::move( data ) )
-  {
-  }
-
-  size_t GetSize() const
-  {
-    return mSize;
-  }
-
-  virtual ~GenericBufferBase() = default;
-
-  char* GetDataBase()
-  {
-    return mData.get();
-  }
-
-protected:
-  // derived types should not be moved direcly to prevent slicing
-  GenericBufferBase( GenericBufferBase&& ) = default;
-  GenericBufferBase& operator=( GenericBufferBase&& ) = default;
-
-  // not copyable
-  GenericBufferBase( const GenericBufferBase& ) = delete;
-  GenericBufferBase& operator=( const GenericBufferBase& ) = delete;
-
-private:
-  size_t                mSize;
-  std::unique_ptr<char> mData;
-};
-
-/**
- * @brief Interface class for GenericBuffer types in the graphics API.
- */
-template<typename T>
-class GenericBuffer final : public GenericBufferBase
-{
-public:
-  GenericBuffer( size_t numberOfElements, std::unique_ptr<char>&& data )
-  : GenericBufferBase( numberOfElements * sizeof( T ), std::move( data ) ){};
-
-  virtual ~GenericBuffer() = default;
-
-  GenericBuffer( GenericBuffer&& ) = default;
-  GenericBuffer& operator=( GenericBuffer&& ) = default;
-
-  // not copyable
-  GenericBuffer( const GenericBuffer& ) = delete;
-  GenericBuffer& operator=( const GenericBuffer& ) = delete;
-
-  T* GetData()
-  {
-    return reinterpret_cast<T*>( GenericBufferBase::GetDataBase() );
-  }
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_GENERIC_BUFFER_H
index ab81c21..60382d4 100644 (file)
@@ -24,9 +24,6 @@
 #include <vector>
 
 // INTERNAL INCLUDES
-#include <dali/graphics-api/graphics-api-generic-buffer.h>
-#include <dali/graphics-api/utility/utility-builder.h>
-#include <dali/graphics-api/utility/utility-strong-type.h>
 #include <dali/graphics-api/graphics-api-shader-details.h>
 #include <dali/graphics-api/graphics-api-accessor.h>
 #include <dali/graphics-api/graphics-api-framebuffer.h>
@@ -42,6 +39,8 @@ class Shader;
 class Texture;
 class Buffer;
 class Sampler;
+class Pipeline;
+
 
 /**
  * @brief Interface class for RenderCommand types in the graphics API.
@@ -347,15 +346,28 @@ public:
    */
   struct RenderState
   {
+    struct BlendState
+    {
+      bool blendingEnabled { false };
+    };
+
     RenderState() = default;
 
     Accessor<Shader> shader { nullptr };
+    BlendState blendState {};
 
     RenderState& SetShader( Accessor<Shader> value )
     {
       shader = value;
       return *this;
     }
+
+    RenderState& SetBlendState( BlendState value )
+    {
+      blendState = value;
+      return *this;
+    }
+
     void*    pNext{ nullptr };
   };
 
@@ -367,7 +379,8 @@ public:
     mRenderTargetBinding(),
     mDrawCommand(),
     mPushConstantsBindings(),
-    mRenderState()
+    mRenderState(),
+    mPipeline( nullptr )
   {
   }
 
@@ -414,18 +427,36 @@ public:
     return *this;
   }
 
-  RenderCommand& BindRenderState( RenderState&& renderState )
+  RenderCommand& BindRenderState( RenderState& renderState )
   {
     mRenderState = renderState;
     return *this;
   }
 
+  RenderCommand& BindRenderTarget( const RenderTargetBinding& binding )
+  {
+    mRenderTargetBinding = binding;
+    return *this;
+  }
+
+  RenderCommand& BindRenderTarget( RenderTargetBinding&& binding )
+  {
+    mRenderTargetBinding = std::move(binding);
+    return *this;
+  }
+
   RenderCommand& Draw( DrawCommand&& drawCommand )
   {
     mDrawCommand = drawCommand;
     return *this;
   }
 
+  RenderCommand& BindPipeline( const Accessor<Pipeline>& pipeline )
+  {
+    mPipeline = pipeline;
+    return *this;
+  }
+
   static std::vector<VertexAttributeBufferBinding> NewVertexAttributeBufferBindings()
   {
     return std::vector<VertexAttributeBufferBinding>{};
@@ -499,6 +530,11 @@ public:
     return mRenderState;
   }
 
+  Accessor<Pipeline> GetPipeline() const
+  {
+    return mPipeline;
+  }
+
 protected:
 
   std::vector<VertexAttributeBufferBinding> mVertexBufferBindings;
@@ -510,13 +546,154 @@ protected:
   DrawCommand                               mDrawCommand;
   std::vector<PushConstantsBinding>         mPushConstantsBindings;
   RenderState                               mRenderState;
+  Accessor<Pipeline>                        mPipeline;
 
 };
 
-using RenderCommandBuilder = Utility::Builder<RenderCommand>;
-
 } // namespace API
 } // namespace Graphics
 } // namespace Dali
 
 #endif // DALI_GRAPHICS_API_RENDER_COMMAND_H
+
+
+/**
+ * @brief Interface class for RenderCommand types in the graphics API.
+ *
+ * @startuml
+ *
+ * skinparam defaultFontName Ubuntu Mono
+ * class RenderCommand {
+ *  -- protected --
+ *  #VertexAttributeBufferBinding[]  mVertexBufferBindings
+ *  #UniformBufferBinding[]          mUniformBufferBindings
+ *  #TextureBinding[]                mTextureBindings
+ *  #SamplerBinding[]                mSamplerBindings
+ *  #IndexBufferBinding              mIndexBufferBinding
+ *  #RenderTargetBinding             mRenderTargetBinding
+ *  #DrawCommand                     mDrawCommand
+ *  #PushConstantsBinding[]          mPushConstantsBindings
+ *  #RenderState                     mRenderState
+ *
+ * -- public API --
+ *  +RenderCommand& BindVertextBuffers()
+ *  +RenderCommand& BindUniformBuffers()
+ *  +RenderCommand& BindTextures()
+ *  +RenderCommand& BindSamplers()
+ *  +RenderCommand& PushConstants()
+ *  +RenderCommand& BindRenderState()
+ *  +RenderCommand& Draw()
+ *  -- static API ( helper functions )--
+ *  {static} NewVertexAttributeBufferBindings()
+ *  {static} NewVertexAttributeBufferBindings()
+ *  {static} NewVertexAttributeBufferBindings()
+ *  {static} NewTextureBindings()
+ *  {static} NewPushConstantsBindings()
+ * }
+ *
+ * class VertexAttributeBufferBinding {
+ * Accessor<Buffer>   buffer
+ * uint32_t           location
+ * uint32_t           offset
+ * uint32_t           stride
+ * InputAttributeRate rate
+ * void*              pNext
+ * }
+ *
+ * class UniformBufferBinding {
+ *   #Accessor<Buffer> buffer
+ *   #uint32_t         offset
+ *   #uint32_t         dataSize
+ *   #uint32_t         binding
+ *   #void*            pNext
+ * }
+ *
+  class IndexBufferBinding {
+    #Accessor<Buffer> buffer
+    #uint32_t         offset
+    #IndexType        type
+    #void*            pNext
+  }
+
+  class RenderTargetBinding {
+    #Accessor<Framebuffer>                 framebuffer
+    #std::vector<Framebuffer::ClearColor>  clearColors
+    #Framebuffer::DepthStencilClearColor   dsClearColor
+    #void*                                 pNext
+  }
+
+  class DrawCommand {
+      #DrawType drawType;
+      #uint32_t firstVertex
+      #uint32_t firstIndex
+      #uint32_t vertexCount
+      #uint32_t indicesCount
+      #uint32_t firstInstance
+      #uint32_t instanceCount
+      #void*    pNext
+  }
+
+  class PushConstantsBinding {
+    #void*     data
+    #uint32_t  size
+    #uint32_t  binding
+    #void*    pNext
+  }
+
+  class RenderState {
+    #Accessor<Shader> shader
+    #void*    pNext
+  }
+
+  class TextureBinding {
+    #Accessor<Texture> texture
+    #Accessor<Sampler> sampler
+    #uint32_t          binding
+    #void*             pNext
+  }
+
+  class SamplerBinding {
+    #Accessor<Sampler> sampler
+    #uint32_t binding
+    #void*    pNext
+  }
+
+ note as RenderStateWIP
+ Other render states like
+ blending etc. should be added
+ as public fields of this structure.
+ end note
+
+ RenderStateWIP .. RenderState
+
+ * note as N1
+ * Each state is described as POD
+ * structure which is a Vulkan
+ * approach.
+ * end note
+ *
+ * note as N2
+ * Field pNext may be used by the
+ * implementation to pass additional
+ * data.
+ * end note
+ *
+ * N2 .. VertexAttributeBufferBinding::pNext
+ * N1 .. VertexAttributeBufferBinding
+ * N1 .. UniformBufferBinding
+ * N1 .. IndexBufferBinding
+ * N1 .. RenderTargetBinding
+ *
+
+ *
+ * RenderCommand *-right- VertexAttributeBufferBinding
+ * RenderCommand *-right- UniformBufferBinding
+ * RenderCommand *-left- IndexBufferBinding
+ * RenderCommand *-left- RenderTargetBinding
+ * RenderCommand *-up- RenderState
+ * RenderCommand *-up- DrawCommand
+ * RenderCommand *-down- PushConstantsBinding
+ * RenderCommand *-down- SamplerBinding
+ * RenderCommand *-down- TextureBinding
+ * @enduml
+ */
\ No newline at end of file
diff --git a/dali/graphics-api/graphics-api-render-item-list.h b/dali/graphics-api/graphics-api-render-item-list.h
deleted file mode 100644 (file)
index d7a6ed8..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef DALI_GRAPHICS_API_RENDER_ITEM_LIST_H
-#define DALI_GRAPHICS_API_RENDER_ITEM_LIST_H
-
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-namespace Dali
-{
-namespace Graphics
-{
-namespace API
-{
-
-/**
- * @brief Class that represents a list of RenderItems
- */
-class RenderItemList
-{
-public:
-  template< typename Structure >
-  void CreateInstanceBuffer();
-
-  // not copyable
-  RenderItemList(const RenderItemList&) = delete;
-  RenderItemList& operator=(const RenderItemList&) = delete;
-
-  virtual ~RenderItemList() = default;
-
-protected:
-  // derived types should not be moved direcly to prevent slicing
-  RenderItemList(RenderItemList&&) = default;
-  RenderItemList& operator=(RenderItemList&&) = default;
-
-  /**
-   * Objects of this type should not directly.
-   */
-  RenderItemList() = default;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_RENDER_ITEM_LIST_H
diff --git a/dali/graphics-api/graphics-api-render-list.h b/dali/graphics-api/graphics-api-render-list.h
deleted file mode 100644 (file)
index b62feff..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef DALI_GRAPHICS_API_RENDER_LIST_H
-#define DALI_GRAPHICS_API_RENDER_LIST_H
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-namespace Dali
-{
-namespace Graphics
-{
-namespace API
-{
-
-/**
- * @brief Interface class for RenderList types in the graphics API.
- */
-class RenderList
-{
-public:
-  using Handle = size_t;
-
-  virtual void SetRenderItemData(size_t index) = 0;
-
-  // not copyable
-  RenderList(const RenderList&) = delete;
-  RenderList& operator=(const RenderList&) = delete;
-
-  virtual ~RenderList() = default;
-
-protected:
-  // derived types should not be moved direcly to prevent slicing
-  RenderList(RenderList&&) = default;
-  RenderList& operator=(RenderList&&) = default;
-
-  /**
-   * Objects of this type should not directly.
-   */
-  RenderList() = default;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_RENDER_LIST_H
diff --git a/dali/graphics-api/graphics-api-static-buffer.h b/dali/graphics-api/graphics-api-static-buffer.h
deleted file mode 100644 (file)
index 65ca04a..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef DALI_GRAPHICS_API_STATIC_BUFFER_H
-#define DALI_GRAPHICS_API_STATIC_BUFFER_H
-
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-namespace Dali
-{
-namespace Graphics
-{
-namespace API
-{
-
-/**
- * @brief Interface class for Texture types in the graphics API.
- */
-class StaticBuffer
-{
-public:
-  // not copyable
-  StaticBuffer(const StaticBuffer&) = delete;
-  StaticBuffer& operator=(const StaticBuffer&) = delete;
-
-  virtual ~StaticBuffer() = default;
-
-protected:
-  // derived types should not be moved directly to prevent slicing
-  StaticBuffer(StaticBuffer&&) = default;
-  StaticBuffer& operator=(StaticBuffer&&) = default;
-
-  /**
-   * Objects of this type should not directly.
-   */
-  StaticBuffer() = default;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_STATIC_BUFFER_H
index 2110a38..62efb33 100644 (file)
@@ -41,6 +41,7 @@ enum class Format {
 
   // texture color formats
   RGBA8,
+  L8,
   ETC2_RGBA8,
 
   // compressed color formats
diff --git a/dali/graphics-api/graphics-api-texture-set.h b/dali/graphics-api/graphics-api-texture-set.h
deleted file mode 100644 (file)
index e039808..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef DALI_GRAPHICS_API_TEXTURE_SET_H
-#define DALI_GRAPHICS_API_TEXTURE_SET_H
-
-/*
- * Copyright (c) 2016 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-api/graphics-api-texture.h>
-
-namespace Dali
-{
-namespace Graphics
-{
-namespace API
-{
-
-/**
- * @brief Interface class for TextureSet types in the graphics API.
- */
-class TextureSet
-{
-public:
-  virtual void AddTexture(const Accessor< Texture >& texture) = 0;
-
-  // not copyable
-  TextureSet(const TextureSet&) = delete;
-  TextureSet& operator=(const TextureSet&) = delete;
-
-  virtual ~TextureSet() = default;
-
-protected:
-  // derived types should not be moved direcly to prevent slicing
-  TextureSet(TextureSet&&) = default;
-  TextureSet& operator=(TextureSet&&) = default;
-
-  /**
-   * Objects of this type should not directly.
-   */
-  TextureSet() = default;
-};
-
-} // namespace API
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_API_TEXTURE_SET_H
diff --git a/dali/graphics/graphics-controller.h b/dali/graphics/graphics-controller.h
deleted file mode 100644 (file)
index 270e257..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef DALI_GRAPHICS_CONTROLLER_H
-#define DALI_GRAPHICS_CONTROLLER_H
-
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <dali/graphics-api/graphics-api-controller.h>
-#include <dali/graphics/graphics-object-owner.h>
-
-namespace Dali
-{
-namespace Graphics
-{
-
-/**
- * @brief Controller implementation of the graphics API
- */
-class Controller : public API::Controller
-{
-public:
-  virtual API::Accessor< API::Shader > CreateShader(
-      const API::BaseFactory< API::Shader >& factory) override;
-
-  virtual API::Accessor< API::Texture > CreateTexture(
-      const API::BaseFactory< API::Texture >& factory) override;
-
-  virtual API::Accessor< API::TextureSet > CreateTextureSet(
-      const API::BaseFactory< API::TextureSet >& factory) override;
-
-  virtual API::Accessor< API::DynamicBuffer > CreateDynamicBuffer(
-      const API::BaseFactory< API::DynamicBuffer >& factory) override;
-
-  virtual API::Accessor< API::StaticBuffer > CreateStaticBuffer(
-      const API::BaseFactory< API::StaticBuffer >& factory) override;
-
-  virtual API::Accessor< API::Sampler > CreateSampler(
-      const API::BaseFactory< API::Sampler >& factory) override;
-
-  virtual API::Accessor< API::Framebuffer > CreateFramebuffer(
-      const API::BaseFactory< API::Framebuffer >& factory) override;
-
-  virtual void GetRenderItemList() override;
-
-public:
-  Controller();
-
-  Controller(const Controller&) = delete;
-  Controller& operator=(const Controller&) = delete;
-
-  Controller(Controller&&);
-  Controller& operator=(Controller&&) = default;
-
-  ~Controller() override;
-
-protected:
-  ObjectOwner< API::Shader >        mShaders;
-  ObjectOwner< API::Texture >       mTextures;
-  ObjectOwner< API::TextureSet >    mTextureSets;
-  ObjectOwner< API::DynamicBuffer > mDynamicBuffers;
-  ObjectOwner< API::StaticBuffer >  mStaticBuffers;
-  ObjectOwner< API::Sampler >       mSamplers;
-  ObjectOwner< API::Framebuffer >   mFramebuffers;
-};
-
-} // namespace Graphics
-} // namespace Dali
-
-#endif // DALI_GRAPHICS_CONTROLLER_H
index dd898a5..72dbf18 100644 (file)
@@ -92,7 +92,7 @@ bool RenderCommand::PreparePipeline()
     auto vertexShader   = shader.GetShader(vk::ShaderStageFlagBits::eVertex);
     auto fragmentShader = shader.GetShader(vk::ShaderStageFlagBits::eFragment);
 
-    auto pipelineRef = pipelineCache.GetPipeline({vertexShader, fragmentShader, {}});
+    auto pipelineRef = pipelineCache.GetPipeline({vertexShader, fragmentShader, renderState.blendState, {}});
 
     if (!pipelineRef)
     {
@@ -107,27 +107,37 @@ bool RenderCommand::PreparePipeline()
       std::vector<vk::VertexInputBindingDescription> bindingDescriptions{};
 
       uint32_t  currentBuffer{0xffffffff};
-      for (auto &&vb : GetVertexBufferBindings())
+      if( !attribs.empty() && attribs.size() == GetVertexBufferBindings().size() )
       {
-        if (currentBuffer != vb.buffer
-                               .GetHandle())
+        for (auto &&vb : GetVertexBufferBindings())
         {
-          bindingDescriptions.emplace_back(vk::VertexInputBindingDescription{}
-                                             .setBinding(bindingIndex)
-                                             .setInputRate(vb.rate == API::RenderCommand::InputAttributeRate::PER_VERTEX
-                                                           ? vk::VertexInputRate::eVertex
-                                                           : vk::VertexInputRate::eInstance)
-                                             .setStride(vb.stride));
-          bindingIndex++;
-          currentBuffer = Vulkan::U32(vb.buffer
-                                        .GetHandle());
+          if (currentBuffer != vb.buffer
+                                 .GetHandle())
+          {
+            bindingDescriptions.emplace_back(vk::VertexInputBindingDescription{}
+                                               .setBinding(bindingIndex)
+                                               .setInputRate(
+                                                 vb.rate == API::RenderCommand::InputAttributeRate::PER_VERTEX
+                                                 ? vk::VertexInputRate::eVertex
+                                                 : vk::VertexInputRate::eInstance)
+                                               .setStride(vb.stride));
+            bindingIndex++;
+            currentBuffer = Vulkan::U32(vb.buffer
+                                          .GetHandle());
+          }
+
+
+          attributeDescriptions.emplace_back(vk::VertexInputAttributeDescription{}
+                                               .setBinding(bindingDescriptions.back()
+                                                                              .binding)
+                                               .setFormat(attribs[vb.location].format)
+                                               .setOffset(vb.offset));
         }
-
-        attributeDescriptions.emplace_back(vk::VertexInputAttributeDescription{}
-                                             .setBinding(bindingDescriptions.back()
-                                                                            .binding)
-                                             .setFormat(attribs[vb.location].format)
-                                             .setOffset(vb.offset));
+      }
+      else // incompatible pipeline
+      {
+        mUpdateFlags = 0;
+        return false;
       }
 
       auto vertexInputState = vk::PipelineVertexInputStateCreateInfo{}
@@ -224,7 +234,7 @@ bool RenderCommand::PreparePipeline()
 
       pipeline->Compile();
 
-      pipelineCache.AddPipeline(pipeline, Vulkan::PipelineDescription{vertexShader, fragmentShader, dsLayouts});
+      pipelineCache.AddPipeline(pipeline, Vulkan::PipelineDescription{vertexShader, fragmentShader, renderState.blendState, dsLayouts});
 
       pipelineRef = pipeline;
 
@@ -279,9 +289,12 @@ bool RenderCommand::PreparePipeline()
 void RenderCommand::UpdateUniformBuffers()
 {
   uint32_t uboIndex = 0u;
-  for( auto&& pc : mPushConstantsBindings )
+  if(!mUboBuffers.empty() && mUboBuffers.size() == mPushConstantsBindings.size())
   {
-    mUboBuffers[uboIndex++]->WriteKeepMapped( pc.data, 0, pc.size );
+    for (auto &&pc : mPushConstantsBindings)
+    {
+      mUboBuffers[uboIndex++]->WriteKeepMapped(pc.data, 0, pc.size);
+    }
   }
 }
 
@@ -290,15 +303,15 @@ const vk::PipelineColorBlendStateCreateInfo* RenderCommand::PrepareColorBlendSta
   //@todo support more attachments
   //@todo use data from render state
   auto blendAttachmentState = vk::PipelineColorBlendAttachmentState{}
-    .setBlendEnable( true )
+    .setBlendEnable( vk::Bool32(mRenderState.blendState.blendingEnabled) )
     .setColorWriteMask( vk::ColorComponentFlagBits::eR |
                         vk::ColorComponentFlagBits::eG |
                         vk::ColorComponentFlagBits::eB |
                         vk::ColorComponentFlagBits::eA )
     .setSrcColorBlendFactor( vk::BlendFactor::eSrcAlpha )
-    .setDstColorBlendFactor( vk::BlendFactor::eOneMinusSrc1Alpha )
+    .setDstColorBlendFactor( vk::BlendFactor::eOneMinusSrcAlpha )
     .setSrcAlphaBlendFactor( vk::BlendFactor::eOne )
-    .setDstAlphaBlendFactor( vk::BlendFactor::eOneMinusSrc1Alpha )
+    .setDstAlphaBlendFactor( vk::BlendFactor::eOneMinusSrcAlpha )
     .setColorBlendOp( vk::BlendOp::eAdd )
     .setAlphaBlendOp( vk::BlendOp::eAdd );
 
@@ -459,6 +472,7 @@ const std::vector<Vulkan::DescriptorSetRef>& RenderCommand::GetDescriptorSets()
   return mDescriptorSets;
 }
 
+
 } // namespace VulkanAPI
 } // namespace Graphics
 } // namespace Dali
\ No newline at end of file
index 8049f59..61f3252 100644 (file)
@@ -112,6 +112,7 @@ public:
   const Vulkan::PipelineRef& GetPipeline() const;
 
 
+
 private:
 
   const vk::PipelineColorBlendStateCreateInfo*      PrepareColorBlendStateCreateInfo();
index c91b01f..8c0fb5d 100644 (file)
@@ -51,28 +51,42 @@ struct Texture::Impl
     auto sizeInBytes = mTextureFactory.GetDataSize();
     auto data = mTextureFactory.GetData();
 
-    auto textureRef = Dali::Graphics::Vulkan::Texture::New( mGraphics, U32(size.width), U32(size.height), vk::Format::eR8G8B8A8Unorm );
+    auto format = vk::Format::eR8G8B8A8Unorm;
 
-    // check bpp, if 24bpp convert
-    if( sizeInBytes == width*height*3 )
+    if(mTextureFactory.GetFormat() == API::TextureDetails::Format::RGBA8 )
     {
-
-      auto inData = reinterpret_cast<const uint8_t*>(data);
-      auto outData = new uint8_t[width*height*4];
-
-      auto outIdx = 0u;
-      for( auto i = 0u; i < sizeInBytes; i+= 3 )
+      // check bpp, if 24bpp convert
+      if (sizeInBytes == width * height * 3)
       {
-        outData[outIdx] = inData[i];
-        outData[outIdx+1] = inData[i+1];
-        outData[outIdx+2] = inData[i+2];
-        outData[outIdx+3] = 0xff;
-        outIdx += 4;
+
+        auto inData  = reinterpret_cast<const uint8_t *>(data);
+        auto 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 = U32(width * height * 4);
       }
 
-      data = outData;
-      sizeInBytes = U32(width*height*4);
     }
+    else if(mTextureFactory.GetFormat() == API::TextureDetails::Format::L8 )
+    {
+      format = vk::Format::eR8Unorm;
+    }
+
+    auto textureRef = Dali::Graphics::Vulkan::Texture::New( mGraphics,
+                                                            U32(size.width),
+                                                            U32(size.height),
+                                                            format );
+
 
     // Upload data immediately. Will stall the queue :(
     textureRef->UploadData( data, sizeInBytes, TextureUploadMode::eImmediate );
index a72e721..4f10748 100644 (file)
@@ -21,7 +21,6 @@
 // INTERNAL INCLUDES
 #include <dali/graphics-api/graphics-api-texture-factory.h>
 #include <dali/graphics-api/graphics-api-texture.h>
-#include <dali/graphics/graphics-controller.h>
 #include <dali/graphics/vulkan/vulkan-types.h>
 #include <dali/graphics/vulkan/vulkan-graphics-texture.h>