namespace Dali
{
+std::ostream& operator<<(std::ostream& o, const Graphics::BufferCreateInfo& bufferCreateInfo);
+std::ostream& operator<<(std::ostream& o, const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo);
+std::ostream& operator<<(std::ostream& o, const Graphics::TextureType& textureType);
+std::ostream& operator<<(std::ostream& o, const Graphics::Extent2D extent);
+std::ostream& operator<<(std::ostream& o, const Graphics::TextureCreateInfo& createInfo);
+std::ostream& operator<<(std::ostream& o, Graphics::SamplerAddressMode addressMode);
+std::ostream& operator<<(std::ostream& o, Graphics::SamplerFilter filterMode);
+std::ostream& operator<<(std::ostream& o, Graphics::SamplerMipmapMode mipmapMode);
+std::ostream& operator<<(std::ostream& o, const Graphics::SamplerCreateInfo& createInfo);
+
class TestGraphicsController : public Dali::Graphics::Controller
{
public:
- TestGraphicsController() = default;
+ TestGraphicsController()
+ {
+ }
+
virtual ~TestGraphicsController() = default;
void Initialize()
return mGlContextHelperAbstraction;
}
-private:
+ void SubmitCommandBuffers(const Graphics::SubmitInfo& submitInfo) override
+ {
+ }
+
+ /**
+ * @brief Presents render target
+ * @param renderTarget render target to present
+ */
+ void PresentRenderTarget(Graphics::RenderTarget* renderTarget) override
+ {
+ }
+
+ /**
+ * @brief Waits until the GPU is idle
+ */
+ void WaitIdle() override
+ {
+ }
+
+ /**
+ * @brief Lifecycle pause event
+ */
+ void Pause() override
+ {
+ }
+
+ /**
+ * @brief Lifecycle resume event
+ */
+ void Resume() override
+ {
+ }
+
+ /**
+ * @brief Executes batch update of textures
+ *
+ * This function may perform full or partial update of many textures.
+ * The data source may come from:
+ * - CPU memory (client side)
+ * - GPU memory (another Texture or Buffer)
+ *
+ * UpdateTextures() is the only way to update unmappable Texture objects.
+ * It is recommended to batch updates as it may help with optimizing
+ * memory transfers based on dependencies.
+ *
+ */
+ void UpdateTextures(const std::vector<Graphics::TextureUpdateInfo>& updateInfoList,
+ const std::vector<Graphics::TextureUpdateSourceInfo>& sourceList) override
+ {
+ }
+
+ /**
+ * TBD: do we need those functions in the new implementation?
+ */
+ bool EnableDepthStencilBuffer(bool enableDepth, bool enableStencil) override
+ {
+ return {};
+ }
+
+ void RunGarbageCollector(size_t numberOfDiscardedRenderers) override
+ {
+ }
+
+ void DiscardUnusedResources() override
+ {
+ }
+
+ bool IsDiscardQueueEmpty() override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Test if the graphics subsystem has resumed & should force a draw
+ *
+ * @return true if the graphics subsystem requires a re-draw
+ */
+ bool IsDrawOnResumeRequired() override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Creates new Buffer object
+ *
+ * The Buffer object is created with underlying memory. The Buffer
+ * specification is immutable. Based on the BufferCreateInfo::usage,
+ * the memory may be client-side mappable or not.
+ *
+ * The old buffer may be passed as BufferCreateInfo::oldbuffer, however,
+ * it's up to the implementation whether the object will be reused or
+ * discarded and replaced by the new one.
+ *
+ * @param[in] bufferCreateInfo The valid BufferCreateInfo structure
+ * @return pointer to the Buffer object
+ */
+ std::unique_ptr<Graphics::Buffer> CreateBuffer(const Graphics::BufferCreateInfo& bufferCreateInfo, std::unique_ptr<Graphics::Buffer>&& oldBuffer) override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Creates new CommandBuffer object
+ *
+ * @param[in] bufferCreateInfo The valid BufferCreateInfo structure
+ * @return pointer to the CommandBuffer object
+ */
+ std::unique_ptr<Graphics::CommandBuffer> CreateCommandBuffer(const Graphics::CommandBufferCreateInfo& commandBufferCreateInfo, std::unique_ptr<Graphics::CommandBuffer>&& oldCommandBuffer) override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Creates new RenderPass object
+ *
+ * @param[in] renderPassCreateInfo The valid RenderPassCreateInfo structure
+ * @return pointer to the RenderPass object
+ */
+ std::unique_ptr<Graphics::RenderPass> CreateRenderPass(const Graphics::RenderPassCreateInfo& renderPassCreateInfo, std::unique_ptr<Graphics::RenderPass>&& oldRenderPass) override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Creates new Texture object
+ *
+ * @param[in] textureCreateInfo The valid TextureCreateInfo structure
+ * @return pointer to the TextureCreateInfo object
+ */
+ std::unique_ptr<Graphics::Texture> CreateTexture(const Graphics::TextureCreateInfo& textureCreateInfo, std::unique_ptr<Graphics::Texture>&& oldTexture) override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Creates new Framebuffer object
+ *
+ * @param[in] framebufferCreateInfo The valid FramebufferCreateInfo structure
+ * @return pointer to the Framebuffer object
+ */
+ std::unique_ptr<Graphics::Framebuffer> CreateFramebuffer(const Graphics::FramebufferCreateInfo& framebufferCreateInfo, std::unique_ptr<Graphics::Framebuffer>&& oldFramebuffer) override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Creates new Pipeline object
+ *
+ * @param[in] pipelineCreateInfo The valid PipelineCreateInfo structure
+ * @return pointer to the Pipeline object
+ */
+ std::unique_ptr<Graphics::Pipeline> CreatePipeline(const Graphics::PipelineCreateInfo& pipelineCreateInfo, std::unique_ptr<Graphics::Pipeline>&& oldPipeline) override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Creates new Shader object
+ *
+ * @param[in] shaderCreateInfo The valid ShaderCreateInfo structure
+ * @return pointer to the Shader object
+ */
+ std::unique_ptr<Graphics::Shader> CreateShader(const Graphics::ShaderCreateInfo& shaderCreateInfo, std::unique_ptr<Graphics::Shader>&& oldShader) override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Creates new Sampler object
+ *
+ * @param[in] samplerCreateInfo The valid SamplerCreateInfo structure
+ * @return pointer to the Sampler object
+ */
+ std::unique_ptr<Graphics::Sampler> CreateSampler(const Graphics::SamplerCreateInfo& samplerCreateInfo, std::unique_ptr<Graphics::Sampler>&& oldSampler) override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Creates new RenderTarget object
+ *
+ * @param[in] renderTargetCreateInfo The valid RenderTargetCreateInfo structure
+ * @return pointer to the RenderTarget object
+ */
+ std::unique_ptr<Graphics::RenderTarget> CreateRenderTarget(const Graphics::RenderTargetCreateInfo& renderTargetCreateInfo, std::unique_ptr<Graphics::RenderTarget>&& oldRenderTarget) override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Maps memory associated with Buffer object
+ *
+ * @param[in] mapInfo Filled details of mapped resource
+ *
+ * @return Returns pointer to Memory object or Graphicsnullptr on error
+ */
+ std::unique_ptr<Graphics::Memory> MapBufferRange(const Graphics::MapBufferInfo& mapInfo) override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Maps memory associated with the texture.
+ *
+ * Only Texture objects that are backed with linear memory (staging memory) can be mapped.
+ * Example:
+ * 1) GLES implementation may create PBO object as staging memory and couple it
+ * with the texture. Texture can be mapped and the memory can be read/write on demand.
+ *
+ * 2) Vulkan implementation may allocate DeviceMemory and use linear layout.
+ *
+ * @param[in] mapInfo Filled details of mapped resource
+ *
+ * @return Valid Memory object or nullptr on error
+ */
+ std::unique_ptr<Graphics::Memory> MapTextureRange(const Graphics::MapTextureInfo& mapInfo) override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Unmaps memory and discards Memory object
+ *
+ * This function automatically removes lock if Memory has been
+ * previously locked.
+ *
+ * @param[in] memory Valid and previously mapped Memory object
+ */
+ void UnmapMemory(std::unique_ptr<Graphics::Memory> memory) override
+ {
+ }
+
+ /**
+ * @brief Returns memory requirements of the Texture object.
+ *
+ * Call this function whenever it's necessary to know how much memory
+ * is needed to store all the texture data and what memory alignment
+ * the data should follow.
+ *
+ * @return Returns memory requirements of Texture
+ */
+ Graphics::MemoryRequirements GetTextureMemoryRequirements(Graphics::Texture& texture) const override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Returns memory requirements of the Buffer object.
+ *
+ * Call this function whenever it's necessary to know how much memory
+ * is needed to store all the buffer data and what memory alignment
+ * the data should follow.
+ *
+ * @return Returns memory requirements of Buffer
+ */
+ Graphics::MemoryRequirements GetBufferMemoryRequirements(Graphics::Buffer& buffer) const override
+ {
+ return {};
+ }
+
+ /**
+ * @brief Returns specification of the Texture object
+ *
+ * Function obtains specification of the Texture object. It may retrieve
+ * implementation dependent details like ie. whether the texture is
+ * emulated (for example, RGB emulated on RGBA), compressed etc.
+ *
+ * @return Returns the TextureProperties object
+ */
+ const Graphics::TextureProperties& GetTextureProperties(const Graphics::Texture& texture) override
+ {
+ static Graphics::TextureProperties properties{};
+ return properties;
+ }
+
+ /**
+ * @brief Tests whether two Pipelines are the same.
+ *
+ * On the higher level, this function may help wit creating pipeline cache.
+ *
+ * @return true if pipeline objects match
+ */
+ bool PipelineEquals(const Graphics::Pipeline& pipeline0, const Graphics::Pipeline& pipeline1) const override
+ {
+ return {};
+ }
+
+public:
+
TestGlAbstraction mGlAbstraction;
TestGlSyncAbstraction mGlSyncAbstraction;
TestGlContextHelperAbstraction mGlContextHelperAbstraction;
+
+ bool isDiscardQueueEmptyResult{true};
+ bool isDrawOnResumeRequiredResult{true};
};
} // namespace Dali
SET( GRAPHICS_API_HEADERS ${GRAPHICS_API_HEADERS}
${graphics_src_dir}/graphics-controller.h
+ ${graphics_src_dir}/graphics-buffer-create-info.h
+ ${graphics_src_dir}/graphics-buffer.h
+ ${graphics_src_dir}/graphics-command-buffer-create-info.h
+ ${graphics_src_dir}/graphics-command-buffer.h
+ ${graphics_src_dir}/graphics-controller.h
+ ${graphics_src_dir}/graphics-debug.h
+ ${graphics_src_dir}/graphics-framebuffer-create-info.h
+ ${graphics_src_dir}/graphics-framebuffer.h
+ ${graphics_src_dir}/graphics-memory.h
+ ${graphics_src_dir}/graphics-pipeline-create-info.h
+ ${graphics_src_dir}/graphics-pipeline.h
+ ${graphics_src_dir}/graphics-render-pass-create-info.h
+ ${graphics_src_dir}/graphics-render-pass.h
+ ${graphics_src_dir}/graphics-render-target-create-info.h
+ ${graphics_src_dir}/graphics-render-target.h
+ ${graphics_src_dir}/graphics-sampler-create-info.h
+ ${graphics_src_dir}/graphics-sampler.h
+ ${graphics_src_dir}/graphics-shader-create-info.h
+ ${graphics_src_dir}/graphics-shader.h
+ ${graphics_src_dir}/graphics-texture-create-info.h
+ ${graphics_src_dir}/graphics-texture.h
+ ${graphics_src_dir}/graphics-types.h
)
--- /dev/null
+#ifndef DALI_GRAPHICS_API_BUFFER_CREATE_INFO
+#define DALI_GRAPHICS_API_BUFFER_CREATE_INFO
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+
+// INTERNAL INCLUDES
+#include "graphics-buffer.h"
+#include "graphics-types.h"
+
+namespace Dali
+{
+namespace Graphics
+{
+/**
+ * BufferCreateInfo describes new buffer
+ */
+struct BufferCreateInfo
+{
+ /**
+ * @brief Sets pointer to the extension
+ *
+ * The pointer to the extension must be set either to nullptr
+ * or to the valid structure. The structures may create
+ * a chain. The last structure in a chain must point at
+ * nullptr.
+ *
+ * @param[in] value pointer to the valid extension structure
+ * @return reference to this structure
+ */
+ auto& SetNextExtension(ExtensionCreateInfo* value)
+ {
+ nextExtension = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets the expected buffer usage
+ *
+ * The buffer usage should be explicitly set. It cannot be modified
+ * later so in case of changing the usage, the new buffer
+ * should be created. Based on Usage the implementation may
+ * execute certain optimizations.
+ *
+ * @param[in] value Usage flags
+ * @return reference to this structure
+ */
+ auto& SetUsage(BufferUsageFlags value)
+ {
+ usage = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets size of buffer in bytes
+ *
+ * @param[in] value Size of the buffer in bytes
+ * @return reference to this structure
+ */
+ auto& SetSize(uint32_t value)
+ {
+ size = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets allocation callbacks which will be used when object is created
+ * and destroyed.
+ *
+ * @param[in] value Valid reference to AllocationCallbacksStructure
+ * @return reference to this structure
+ */
+ auto& SetAllocationCallbacks(const AllocationCallbacks& value)
+ {
+ allocationCallbacks = &value;
+ return *this;
+ }
+
+ GraphicsStructureType type{GraphicsStructureType::BUFFER_CREATE_INFO_STRUCT};
+ ExtensionCreateInfo* nextExtension{nullptr};
+ BufferUsageFlags usage{};
+ uint32_t size{0u};
+
+ const AllocationCallbacks* allocationCallbacks{nullptr};
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_BUFFER_H
+#define DALI_GRAPHICS_BUFFER_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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
+{
+/**
+ * Buffer class represents a GPU buffer object. It may represent
+ * vertex buffer, index buffer, pixel buffer, uniform buffer and
+ * any other.
+ */
+class Buffer
+{
+public:
+ Buffer() = default;
+ virtual ~Buffer() = default;
+
+ // not copyable
+ Buffer(const Buffer&) = delete;
+ Buffer& operator=(const Buffer&) = delete;
+
+protected:
+ Buffer(Buffer&&) = default;
+ Buffer& operator=(Buffer&&) = default;
+};
+
+} // Namespace Graphics
+} // Namespace Dali
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_BUFFER_CREATE_INFO_H
+#define DALI_GRAPHICS_BUFFER_CREATE_INFO_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+
+// INTERNAL INCLUDES
+#include "graphics-command-buffer.h"
+#include "graphics-types.h"
+
+namespace Dali
+{
+namespace Graphics
+{
+/**
+ * @brief CommandBufferCreateInfo describes new command buffer
+ */
+struct CommandBufferCreateInfo
+{
+ /**
+ * @brief Sets pointer to the extension
+ *
+ * The pointer to the extension must be set either to nullptr
+ * or to the valid structure. The structures may create
+ * a chain. The last structure in a chain must point at
+ * nullptr.
+ *
+ * @param[in] value pointer to the valid extension structure
+ * @return reference to this structure
+ */
+ auto& SetNextExtension(ExtensionCreateInfo* value)
+ {
+ nextExtension = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets command buffer level
+ *
+ * The command buffer level can be set to primary or secondary. Primary buffers
+ * are able to execute content of secondary buffers. This way, certain commands
+ * can be reused within multiple primary buffers by executing them. The pipeline
+ * state may be inherited from the primary buffer.
+ *
+ * @param[in] value Level of buffer
+ * @return reference to this structure
+ */
+ auto& SetLevel(CommandBufferLevel value)
+ {
+ level = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets fixed capacity of buffer
+ *
+ * Using fixed capacity buffer the memory for the commands may be pre-allocated.
+ * Fixed capacity buffers may use different memory allocation strategy from dynamic
+ * buffers (default behaviour). Buffers of known size and often re-recorded should
+ * use fixed capacity.
+ *
+ * @param[in] value number of commands to be allocated
+ * @return reference to this structure
+ */
+ auto& SetFixedCapacity(uint32_t value)
+ {
+ fixedCapacity = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets allocation callbacks which will be used when object is created
+ * and destroyed.
+ *
+ * @param[in] value Valid reference to AllocationCallbacksStructure
+ * @return reference to this structure
+ */
+ auto& SetAllocationCallbacks(const AllocationCallbacks& value)
+ {
+ allocationCallbacks = &value;
+ return *this;
+ }
+
+ GraphicsStructureType type{GraphicsStructureType::COMMAND_BUFFER_CREATE_INFO_STRUCT};
+ ExtensionCreateInfo* nextExtension{nullptr};
+ CommandBufferLevel level{};
+ uint32_t fixedCapacity{0u};
+
+ const AllocationCallbacks* allocationCallbacks{nullptr};
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_BUFFER_CREATE_INFO_H
--- /dev/null
+#ifndef DALI_GRAPHICS_COMMAND_BUFFER_H
+#define DALI_GRAPHICS_COMMAND_BUFFER_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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 "graphics-types.h"
+
+namespace Dali
+{
+namespace Graphics
+{
+class Buffer;
+class Pipeline;
+class Texture;
+class Sampler;
+class RenderTarget;
+class RenderPass;
+
+/**
+ * @brief Uniform buffer bindings.
+ */
+struct UniformBufferBinding
+{
+ Buffer* buffer; // Buffer
+ union
+ {
+ void* offsetPtr; // pointer to the client-side memory
+ uint32_t offset; // Offset within buffer
+ };
+ uint32_t dataSize; // Size of data to bind
+ uint32_t binding; // Binding index
+};
+
+/**
+ * @brief Texture bindings
+ *
+ * Additionally, sampler may be used in case of having combined
+ * image and sampler.
+ *
+ */
+struct TextureBinding
+{
+ const Texture* texture; // texture to be bound
+ const Sampler* sampler; // sampler to be bound
+ uint32_t binding; // binding index
+};
+
+/**
+ * @brief Sampler binding
+ */
+struct SamplerBinding
+{
+ Sampler* sampler; // sampler to be bound
+ uint32_t binding; // binding index
+};
+
+/**
+ * @brief ClearValue contains an union of RGBA and depthStencil values.
+ */
+struct ClearValue
+{
+ union
+ {
+ struct
+ {
+ float r, g, b, a;
+ } color;
+ struct
+ {
+ float depth;
+ uint32_t stencil;
+ } depthStencil;
+ };
+};
+
+/**
+ * @brief CommandBuffer contains a stream of commands to be executed
+ * by the controller.
+ */
+class CommandBuffer
+{
+public:
+ CommandBuffer() = default;
+ virtual ~CommandBuffer() = default;
+
+ // not copyable
+ CommandBuffer(const CommandBuffer&) = delete;
+ CommandBuffer& operator=(const CommandBuffer&) = delete;
+
+ /**
+ * @brief Binds vertex buffers
+ *
+ * The buffers and offsets arrays must be same length
+ *
+ * @param[in] firstBinding First binding index
+ * @param[in] buffers List of buffers to bind
+ * @param[in] offsets List of offsets for each buffer
+ */
+ virtual void BindVertexBuffers(uint32_t firstBinding,
+ std::vector<const Buffer*> buffers,
+ std::vector<uint32_t> offsets) = 0;
+
+ /**
+ * @brief Binds uniform buffers
+ *
+ * @param[in] bindings List of uniform buffer bindings
+ */
+ virtual void BindUniformBuffers(const std::vector<UniformBufferBinding>& bindings) = 0;
+
+ /**
+ * @brief Binds pipeline
+ *
+ * @param[in] pipeline valid pipeline
+ */
+ virtual void BindPipeline(const Pipeline& pipeline) = 0;
+
+ /**
+ * @brief Binds textures
+ *
+ * @param[in] textureBindings List of texture bindings
+ */
+ virtual void BindTextures(std::vector<TextureBinding>& textureBindings) = 0;
+
+ /**
+ * @brief Binds samplers
+ *
+ * @param[in] samplerBindings List of sampler bindings
+ */
+ virtual void BindSamplers(std::vector<SamplerBinding>& samplerBindings) = 0;
+
+ /**
+ * @brief Binds buffer containing push constants
+ *
+ * @param[in] data pointer to the buffer
+ * @param[in] size size of data in bytes
+ * @param[in] binding push constants binding index
+ */
+ virtual void BindPushConstants(void* data,
+ uint32_t size,
+ uint32_t binding) = 0;
+
+ /**
+ * @brief Binds index buffer
+ *
+ * Most commonly used formats:
+ * R32_UINT,
+ * R16_UINT
+ *
+ * @param[in] buffer Valid buffer
+ * @param[in] offset offset within buffer
+ * @param[in] format Format of index buffer
+ */
+ virtual void BindIndexBuffer(const Buffer& buffer,
+ uint32_t offset,
+ Format format) = 0;
+ /**
+ * @brief Begins render pass
+ *
+ * The function initialises rendering for specified RenderPass object
+ * onto renderTarget. renderArea defines the scissor rect. Depends on the
+ * renderPass spec, the clearValues may be used.
+ *
+ * Calling EndRenderPass() is necessary to finalize the render pass.
+ *
+ * @param[in] renderPass valid render pass object
+ * @param[in] renderTarget valid render target
+ * @param[in] renderArea area to draw
+ * @param[in] clearValues clear values (compatible with renderpass spec)
+ */
+ virtual void BeginRenderPass(
+ RenderPass& renderPass,
+ RenderTarget& renderTarget,
+ Extent2D renderArea,
+ std::vector<ClearValue> clearValues) = 0;
+
+ /**
+ * @brief Ends current render pass
+ *
+ * This command must be issued in order to finalize the render pass.
+ * It's up to the implementation whether anything has to be done but
+ * the Controller may use end RP marker in order to resolve resource
+ * dependencies (for example, to know when target texture is ready
+ * before passing it to another render pass).
+ */
+ virtual void EndRenderPass() = 0;
+
+ /**
+ * @brief Draw primitives
+ *
+ * @param[in] vertexCount number of vertices
+ * @param[in] instanceCount number of instances
+ * @param[in] firstVertex index of first vertex
+ * @param[in] firstInstance index of first instance
+ */
+ virtual void Draw(
+ uint32_t vertexCount,
+ uint32_t instanceCount,
+ uint32_t firstVertex,
+ uint32_t firstInstance) = 0;
+
+ /**
+ * @brief Draws indexed primitives
+ *
+ * @param[in] indexCount Number of indices
+ * @param[in] instanceCount Number of instances
+ * @param[in] firstIndex first index
+ * @param[in] vertexOffset offset of first vertex
+ * @param[in] firstInstance first instance
+ */
+ virtual void DrawIndexed(
+ uint32_t indexCount,
+ uint32_t instanceCount,
+ uint32_t firstIndex,
+ int32_t vertexOffset,
+ uint32_t firstInstance) = 0;
+
+ /**
+ * @brief Draws indexed primitives indirectly
+ *
+ * Indirect draw uses additional buffer that holds render data.
+ *
+ * Indirect draw support depends on the hardware (most of modern hardware
+ * supports this drawing technique).
+ *
+ * @param[in] buffer Buffer containing draw parameters
+ * @param[in] offset Offset in bytes where parameters begin
+ * @param[in] drawCount number of draws to execute
+ * @param[in] stride stride between draw parameters
+ */
+ virtual void DrawIndexedIndirect(
+ Buffer& buffer,
+ uint32_t offset,
+ uint32_t drawCount,
+ uint32_t stride) = 0;
+
+ /**
+ * @brief Resets CommandBuffer
+ *
+ * This function resets the command buffer and discards all previously
+ * recorded commands.
+ *
+ * Since the allocation may use internal memory pool of the CommandBuffer,
+ * resetting doesn't have to discard all the resources (for example, it doesn't
+ * need to destroy command but only move the pointer to the beginning of
+ * the command buffer).
+ *
+ * It is useful if the command buffer has to be re-recorded frequently, for example,
+ * every frame.
+ */
+ virtual void Reset(CommandBuffer& commandBuffer) = 0;
+
+ /**
+ * @brief Changes scissor rect
+ *
+ * @param[in] value 2D scissor area
+ */
+ virtual void SetScissor(Extent2D value) = 0;
+
+ /**
+ * @brief Enables/disables scissor test
+ *
+ * @param[in] value State of scissor test
+ */
+ virtual void SetScissorTestEnable(bool value) = 0;
+
+ /**
+ * @brief Sets viewport
+ *
+ * @param[in] value 2D viewport area
+ */
+ virtual void SetViewport(Viewport value) = 0;
+
+ /**
+ * @brief Sets whether the viewport should be changed
+ * @param[in] value state of viewport
+ */
+ virtual void SetViewportEnable(bool value) = 0;
+
+protected:
+ CommandBuffer(CommandBuffer&&) = default;
+ CommandBuffer& operator=(CommandBuffer&&) = default;
+};
+} // Namespace Graphics
+} // Namespace Dali
+
+#endif
\ No newline at end of file
*
*/
+// EXTERNAL INCLUDES
+#include <memory>
+#include <vector>
+
// INTERNAL INCLUDES
+#include "graphics-buffer-create-info.h"
+#include "graphics-command-buffer-create-info.h"
+#include "graphics-framebuffer-create-info.h"
+#include "graphics-memory.h"
+#include "graphics-pipeline-create-info.h"
+#include "graphics-render-pass-create-info.h"
+#include "graphics-render-target-create-info.h"
+#include "graphics-sampler-create-info.h"
+#include "graphics-shader-create-info.h"
+#include "graphics-texture-create-info.h"
namespace Dali
{
namespace Graphics
{
+class CommandBuffer;
+class Command;
+class RenderTarget;
+class RenderPass;
+class Buffer;
+class Texture;
+class Shader;
+class Framebuffer;
+class Pipeline;
+class Sampler;
+class Memory;
+
/**
- * @brief The main controller for creating graphics objects and submitting render commands.
+ * @brief Controller class controls render loop
+ *
+ * Controller class is responsible for executing render calls
+ * and controlling pipeline state.
*/
class Controller
{
public:
- virtual ~Controller() = default;
-
// Temporary until graphics api is complete
virtual Integration::GlAbstraction& GetGlAbstraction() = 0;
virtual Integration::GlSyncAbstraction& GetGlSyncAbstraction() = 0;
virtual Integration::GlContextHelperAbstraction& GetGlContextHelperAbstraction() = 0;
-public:
- // not copyable
- Controller(const Controller&) = delete;
- Controller& operator=(const Controller&) = delete;
+ /**
+ * @brief Destroys controller
+ */
+ virtual ~Controller() = default;
-protected:
- // derived types should not be moved direcly to prevent slicing
- Controller(Controller&&) = default;
- Controller& operator=(Controller&&) = default;
+ /**
+ * @brief Submits array of command buffers
+ *
+ * Submits command buffers to the graphics pipeline. Submitted commands
+ * may be executed instantly or postponed.
+ *
+ * @param[in] submitInfo Valid SubmitInfo structure
+ */
+ virtual void SubmitCommandBuffers(const SubmitInfo& submitInfo) = 0;
+
+ /**
+ * @brief Presents render target
+ * @param renderTarget render target to present
+ */
+ virtual void PresentRenderTarget(RenderTarget* renderTarget) = 0;
+
+ /**
+ * @brief Waits until the GPU is idle
+ */
+ virtual void WaitIdle() = 0;
+
+ /**
+ * @brief Lifecycle pause event
+ */
+ virtual void Pause() = 0;
+
+ /**
+ * @brief Lifecycle resume event
+ */
+ virtual void Resume() = 0;
+
+ /**
+ * @brief Executes batch update of textures
+ *
+ * This function may perform full or partial update of many textures.
+ * The data source may come from:
+ * - CPU memory (client side)
+ * - GPU memory (another Texture or Buffer)
+ *
+ * UpdateTextures() is the only way to update unmappable Texture objects.
+ * It is recommended to batch updates as it may help with optimizing
+ * memory transfers based on dependencies.
+ *
+ */
+ virtual void UpdateTextures(const std::vector<TextureUpdateInfo>& updateInfoList,
+ const std::vector<TextureUpdateSourceInfo>& sourceList) = 0;
+
+ /**
+ * @brief Enables depth/stencil buffer
+ *
+ * @param[in] enableDepth True to enable depth
+ * @param[in] enableStencil True to enable stencil
+ * @return True on success
+ */
+ virtual bool EnableDepthStencilBuffer(bool enableDepth, bool enableStencil) = 0;
+
+ /**
+ * @brief Runs garbage collector (if supported)
+ *
+ * @param[in] numberOfDiscardedRenderers number of discarded renderers
+ */
+ virtual void RunGarbageCollector(size_t numberOfDiscardedRenderers) = 0;
+
+ /**
+ * @brief Discards unused resources
+ */
+ virtual void DiscardUnusedResources() = 0;
+
+ /**
+ * @brief Tests whether discard queue is empty
+ *
+ * @return True if empty
+ */
+ virtual bool IsDiscardQueueEmpty() = 0;
+
+ /**
+ * @brief Test if the graphics subsystem has resumed & should force a draw
+ *
+ * @return true if the graphics subsystem requires a re-draw
+ */
+ virtual bool IsDrawOnResumeRequired() = 0;
+
+ /**
+ * @brief Creates new Buffer object
+ *
+ * The Buffer object is created with underlying memory. The Buffer
+ * specification is immutable. Based on the BufferCreateInfo::usage,
+ * the memory may be client-side mappable or not.
+ *
+ * The old buffer may be passed as BufferCreateInfo::oldbuffer, however,
+ * it's up to the implementation whether the object will be reused or
+ * discarded and replaced by the new one.
+ *
+ * @param[in] bufferCreateInfo The valid BufferCreateInfo structure
+ * @param[in] oldBuffer The valid pointer to the old object or nullptr. The object will be reused or destroyed.
+ * @return pointer to the Buffer object
+ */
+ virtual std::unique_ptr<Buffer> CreateBuffer(const BufferCreateInfo& bufferCreateInfo, std::unique_ptr<Buffer>&& oldBuffer) = 0;
+
+ /**
+ * @brief Creates new CommandBuffer object
+ *
+ * @param[in] bufferCreateInfo The valid BufferCreateInfo structure
+ * @param[in] oldCommandBuffer The valid pointer to the old object or nullptr. The object will be reused or destroyed.
+ * @return pointer to the CommandBuffer object
+ */
+ virtual std::unique_ptr<CommandBuffer> CreateCommandBuffer(const CommandBufferCreateInfo& commandBufferCreateInfo, std::unique_ptr<CommandBuffer>&& oldCommandBuffer) = 0;
+
+ /**
+ * @brief Creates new RenderPass object
+ *
+ * @param[in] renderPassCreateInfo The valid RenderPassCreateInfo structure
+ * @param[in] oldRenderPass The valid pointer to the old object or nullptr. The object will be reused or destroyed.
+ * @return pointer to the RenderPass object
+ */
+ virtual std::unique_ptr<RenderPass> CreateRenderPass(const RenderPassCreateInfo& renderPassCreateInfo, std::unique_ptr<RenderPass>&& oldRenderPass) = 0;
+
+ /**
+ * @brief Creates new Texture object
+ *
+ * @param[in] textureCreateInfo The valid TextureCreateInfo structure
+ * @param[in] oldTexture The valid pointer to the old object or nullptr. The object will be reused or destroyed.
+ * @return pointer to the TextureCreateInfo object
+ */
+ virtual std::unique_ptr<Texture> CreateTexture(const TextureCreateInfo& textureCreateInfo, std::unique_ptr<Texture>&& oldTexture) = 0;
+
+ /**
+ * @brief Creates new Framebuffer object
+ *
+ * @param[in] framebufferCreateInfo The valid FramebufferCreateInfo structure
+ * @param[in] oldFramebuffer The valid pointer to the old object or nullptr. The object will be reused or destroyed.
+ * @return pointer to the Framebuffer object
+ */
+ virtual std::unique_ptr<Framebuffer> CreateFramebuffer(const FramebufferCreateInfo& framebufferCreateInfo, std::unique_ptr<Framebuffer>&& oldFramebuffer) = 0;
+
+ /**
+ * @brief Creates new Pipeline object
+ *
+ * @param[in] pipelineCreateInfo The valid PipelineCreateInfo structure
+ * @param[in] oldPipeline The valid pointer to the old object or nullptr. The object will be reused or destroyed.
+ * @return pointer to the Pipeline object
+ */
+ virtual std::unique_ptr<Pipeline> CreatePipeline(const PipelineCreateInfo& pipelineCreateInfo, std::unique_ptr<Pipeline>&& oldPipeline) = 0;
+
+ /**
+ * @brief Creates new Shader object
+ *
+ * @param[in] shaderCreateInfo The valid ShaderCreateInfo structure
+ * @param[in] oldShader The valid pointer to the old object or nullptr. The object will be reused or destroyed.
+ * @return pointer to the Shader object
+ */
+ virtual std::unique_ptr<Shader> CreateShader(const ShaderCreateInfo& shaderCreateInfo, std::unique_ptr<Shader>&& oldShader) = 0;
+
+ /**
+ * @brief Creates new Sampler object
+ *
+ * @param[in] samplerCreateInfo The valid SamplerCreateInfo structure
+ * @param[in] oldSampler The valid pointer to the old object or nullptr. The object will be reused or destroyed.
+ * @return pointer to the Sampler object
+ */
+ virtual std::unique_ptr<Sampler> CreateSampler(const SamplerCreateInfo& samplerCreateInfo, std::unique_ptr<Sampler>&& oldSampler) = 0;
+
+ /**
+ * @brief Creates new RenderTarget object
+ *
+ * @param[in] renderTargetCreateInfo The valid RenderTargetCreateInfo structure
+ * @param[in] oldRenderTarget The valid pointer to the old object or nullptr. The object will be reused or destroyed.
+ * @return pointer to the RenderTarget object
+ */
+ virtual std::unique_ptr<RenderTarget> CreateRenderTarget(const RenderTargetCreateInfo& renderTargetCreateInfo, std::unique_ptr<RenderTarget>&& oldRenderTarget) = 0;
/**
- * Objects of this type should not be directly instantiated.
+ * @brief Maps memory associated with Buffer object
+ *
+ * @param[in] mapInfo Filled details of mapped resource
+ * @return Returns pointer to Memory object or nullptr on error
+ */
+ virtual std::unique_ptr<Memory> MapBufferRange(const MapBufferInfo& mapInfo) = 0;
+
+ /**
+ * @brief Maps memory associated with the texture.
+ *
+ * Only Texture objects that are backed with linear memory (staging memory) can be mapped.
+ * Example:
+ * 1) GLES implementation may create PBO object as staging memory and couple it
+ * with the texture. Texture can be mapped and the memory can be read/write on demand.
+ *
+ * 2) Vulkan implementation may allocate DeviceMemory and use linear layout.
+ *
+ * @param[in] mapInfo Filled details of mapped resource
+ *
+ * @return Valid Memory object or nullptr on error
+ */
+ virtual std::unique_ptr<Memory> MapTextureRange(const MapTextureInfo& mapInfo) = 0;
+
+ /**
+ * @brief Unmaps memory and discards Memory object
+ *
+ * This function automatically removes lock if Memory has been
+ * previously locked.
+ *
+ * @param[in] memory Valid and previously mapped Memory object
+ */
+ virtual void UnmapMemory(std::unique_ptr<Memory> memory) = 0;
+
+ /**
+ * @brief Returns memory requirements of the Texture object.
+ *
+ * Call this function whenever it's necessary to know how much memory
+ * is needed to store all the texture data and what memory alignment
+ * the data should follow.
+ *
+ * @return Returns memory requirements of Texture
+ */
+ virtual MemoryRequirements GetTextureMemoryRequirements(Texture& texture) const = 0;
+
+ /**
+ * @brief Returns memory requirements of the Buffer object.
+ *
+ * Call this function whenever it's necessary to know how much memory
+ * is needed to store all the buffer data and what memory alignment
+ * the data should follow.
+ *
+ * @return Returns memory requirements of Buffer
+ */
+ virtual MemoryRequirements GetBufferMemoryRequirements(Buffer& buffer) const = 0;
+
+ /**
+ * @brief Returns specification of the Texture object
+ *
+ * Function obtains specification of the Texture object. It may retrieve
+ * implementation dependent details like ie. whether the texture is
+ * emulated (for example, RGB emulated on RGBA), compressed etc.
+ *
+ * @return Returns the TextureProperties object
+ */
+ virtual const TextureProperties& GetTextureProperties(const Texture& texture) = 0;
+
+ /**
+ * @brief Tests whether two Pipelines are the same.
+ *
+ * On the higher level, this function may help wit creating pipeline cache.
+ *
+ * @return true if pipeline objects match
+ */
+ virtual bool PipelineEquals(const Pipeline& pipeline0, const Pipeline& pipeline1) const = 0;
+
+protected:
+ /**
+ * Creates controller
*/
Controller() = default;
};
-
} // namespace Graphics
} // namespace Dali
-#endif // DALI_GRAPHICS_CONTROLLER_H
+#endif
--- /dev/null
+#ifndef DALI_GRAPHICS_API_DEBUG_H
+#define DALI_GRAPHICS_API_DEBUG_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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
+{
+// TODO:
+}
+} // namespace Dali
+
+#endif
--- /dev/null
+#ifndef DALI_GRAPHICS_FRAMEBUFFER_CREATE_INFO_H
+#define DALI_GRAPHICS_FRAMEBUFFER_CREATE_INFO_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+
+// INTERNAL INCLUDES
+#include "graphics-framebuffer.h"
+#include "graphics-types.h"
+
+namespace Dali
+{
+namespace Graphics
+{
+/**
+ * @brief Interface class for FramebufferCreateInfo types in the graphics API.
+ */
+struct FramebufferCreateInfo
+{
+ /**
+ * @brief Sets pointer to the extension
+ *
+ * The pointer to the extension must be set either to nullptr
+ * or to the valid structure. The structures may create
+ * a chain. The last structure in a chain must point at
+ * nullptr.
+ *
+ * @param[in] value pointer to the valid extension structure
+ * @return reference to this structure
+ */
+ auto& SetNextExtension(ExtensionCreateInfo* value)
+ {
+ nextExtension = value;
+ return *this;
+ }
+
+ /**
+ * @brief Adds color attachments to the framebuffer
+ *
+ * The color attachments are provided as a list. The number
+ * of color attachments depends on the driver capability. It may be
+ * a single attachment allowed for old hardware and multiple attachments
+ * for the modern one (MRT).
+ *
+ * @param[in] value List of attachment descriptors
+ * @return reference to this structure
+ */
+ auto& SetColorAttachments(std::vector<ColorAttachment> value)
+ {
+ colorAttachments = value;
+ return *this;
+ }
+
+ /**
+ * @brief Adds depth/stencil attachment to the framebuffer
+ *
+ * The depth/stencil attachment may be supported only by certain (modern)
+ * hardware. The hardware capabilities should be checked before using
+ * the depth/stencil attachment.
+ *
+ * @param[in] value Depth/stencil attachment descriptor
+ * @return reference to this structure
+ */
+ auto& SetDepthStencilAttachment(DepthStencilAttachment value)
+ {
+ depthStencilAttachment = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets size of framebuffer
+ *
+ * @param[in] value size of framebuffer
+ * @return reference to this structure
+ */
+ auto& SetSize(Extent2D value)
+ {
+ size = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets allocation callbacks which will be used when object is created
+ * and destroyed.
+ *
+ * @param[in] value Valid reference to AllocationCallbacksStructure
+ * @return reference to this structure
+ */
+ auto& SetAllocationCallbacks(const AllocationCallbacks& value)
+ {
+ allocationCallbacks = &value;
+ return *this;
+ }
+
+ GraphicsStructureType type{GraphicsStructureType::FRAMEBUFFER_CREATE_INFO_STRUCT};
+ ExtensionCreateInfo* nextExtension{nullptr};
+ std::vector<ColorAttachment> colorAttachments{};
+ DepthStencilAttachment depthStencilAttachment{};
+ Extent2D size{};
+
+ const AllocationCallbacks* allocationCallbacks{nullptr};
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_FRAMEBUFFER_CREATE_INFO_H
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_FRAMEBUFFER_H
+#define DALI_GRAPHICS_FRAMEBUFFER_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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
+{
+/**
+ * @brief Class represents a frambuffer object.
+ */
+class Framebuffer
+{
+public:
+ Framebuffer() = default;
+ virtual ~Framebuffer() = default;
+
+ // not copyable
+ Framebuffer(const Framebuffer&) = delete;
+ Framebuffer& operator=(const Framebuffer&) = delete;
+
+protected:
+ Framebuffer(Framebuffer&&) = default;
+ Framebuffer& operator=(Framebuffer&&) = default;
+};
+
+} // Namespace Graphics
+} // Namespace Dali
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_MEMORY_H
+#define DALI_GRAPHICS_MEMORY_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <cstdint>
+
+namespace Dali
+{
+namespace Graphics
+{
+/**
+ * @brief Memory object represents a GPU memory that can be
+ * read and/or written.
+ *
+ * It depends on the usage when creating objects such as
+ * buffers and textures.
+ *
+ * The Memory must be mapped first, however, to obtain the direct
+ * pointer the memory must be locked. Locking mechanism enables
+ * synchronisation and prevents driver from using the memory
+ * until the client unlocks it. The memory may be still used
+ * while being mapped (it's ok to keep memory mapped persistently).
+ *
+ */
+class Memory
+{
+public:
+ Memory() = default;
+ virtual ~Memory() = default;
+
+ // not copyable
+ Memory(const Memory&) = delete;
+ Memory& operator=(const Memory&) = delete;
+
+ /**
+ * @brief Locks region of memory for client-side operation
+ *
+ * @param[in] offset Offset of mapped memory
+ * @param[in] size Size of the region to be locked
+ * @return returns valid memory pointer or nullptr on failure
+ */
+ virtual void* LockRegion(uint32_t offset, uint32_t size) = 0;
+
+ /**
+ * @brief Unlocks previously locked memory region
+ *
+ * @param[in] flush If true, region will be flushed immediately and visible to GPU
+ */
+ virtual void Unlock(bool flush) = 0;
+
+ /**
+ * @brief Flushes memory
+ *
+ * Flushing makes a memory object instantly visible by the GPU.
+ *
+ * Example:
+ * Large Buffer object divided in two halves. Every frame only one half
+ * is being updated (permanently mapped, locked, written, unlocked). Calling
+ * FlushMemory() we can update the GPU without unmapping the Buffer object.
+ *
+ * In the scenario when the Memory is being unmapped, flushing is redundant.
+ */
+ virtual void Flush() = 0;
+
+protected:
+ Memory(Memory&&) = default;
+ Memory& operator=(Memory&&) = default;
+};
+
+} // Namespace Graphics
+} // Namespace Dali
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_PIPELINE_CREATE_INFO_H
+#define DALI_GRAPHICS_PIPELINE_CREATE_INFO_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+
+// INTERNAL INCLUDES
+#include "graphics-pipeline.h"
+#include "graphics-types.h"
+
+namespace Dali
+{
+namespace Graphics
+{
+/**
+ * @brief Interface class for generating Pipeline types in the graphics API.
+ *
+ * Pipeline after creation stays immutable unless the dynamic states flag is set.
+ * Dynamic states are set as a bitmask indicating which pipeline states will
+ * be changed dynamically by issuing a command in from the command buffer.
+ *
+ * The dynamic states are listed in Dali::Graphics::PipelineDynamicStateBits.
+ */
+struct PipelineCreateInfo
+{
+ /**
+ * @brief Sets pointer to the extension
+ *
+ * The pointer to the extension must be set either to nullptr
+ * or to the valid structure. The structures may create
+ * a chain. The last structure in a chain must point at
+ * nullptr.
+ *
+ * @param[in] value pointer to the valid extension structure
+ * @return reference to this structure
+ */
+ auto& SetNextExtension(ExtensionCreateInfo* value)
+ {
+ nextExtension = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets the color blend state
+ * param[in] pointer to valid color blend state structure
+ * @return reference to this structure
+ */
+ auto& SetColorBlendState(ColorBlendState* value)
+ {
+ colorBlendState = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets the shader state for the pipeline
+ *
+ * The function takes an array of shader states in order to compile
+ * the pipeline. Each ShaderState structure determines the pipeline stage
+ * the shader should be executed on. The Shader object may be already created
+ * with a specific stage. Then the ShaderState::inheritPipelineStage must be
+ * set to true.
+ *
+ * Sample:
+ * SetShaderState( { ShaderState().SetShader( vertexShader)
+ * .SetPipelineStage( PipelineStage::VERTEX_SHADER ),
+ * ShaderState().SetShader( fragmentShader )
+ * .SetPipelineStage( PipelineStage::FRAGMENT_SHADER )
+ * } );
+ *
+ * In modern graphics API it is possible to attach more than one Shader to a single
+ * stage. For example, one Shader may be just a library of functions:
+ * SetShaderState( { ShaderState().SetShader( vertexShader)
+ * .SetPipelineStage( PipelineStage::VERTEX_SHADER ),
+ * ShaderState().SetShader( shaderCommons )
+ * .SetPipelineStage( PipelineStage::VERTEX_SHADER ),
+ * ShaderState().SetShader( fragmentShader )
+ * .SetPipelineStage( PipelineStage::FRAGMENT_SHADER )
+ * } );
+ *
+ * The Pipeline will compile and link all given shaders.
+ *
+ * param[in] value Valid array of shder states
+ * @return reference to this structure
+ */
+ auto& SetShaderState(const std::vector<ShaderState>& value)
+ {
+ shaderState = &value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets the viewport state
+ * param[in] pointer to valid viewport state structure
+ * @return reference to this structure
+ */
+ auto& SetViewportState(ViewportState* value)
+ {
+ viewportState = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets the framebuffer state
+ * param[in] pointer to valid framebuffer state structure
+ * @return reference to this structure
+ */
+ auto& SetFramebufferState(FramebufferState* value)
+ {
+ framebufferState = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets the base pipeline
+ *
+ * Setting base pipeline allows inheriting that pipeline state
+ * and build the new pipeline from it. The base pipeline
+ * must stay valid until derived pipeline needs it.
+ *
+ * param[in] pointer to valid pipeline object
+ * @return reference to this structure
+ */
+ auto& SetBasePipeline(Pipeline* value)
+ {
+ basePipeline = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets the depth/stencil state
+ * param[in] pointer to valid depth/stencil state structure
+ * @return reference to this structure
+ */
+ auto& SetDepthStencilState(DepthStencilState* value)
+ {
+ depthStencilState = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets the rasterization state
+ * param[in] pointer to valid rasterization state structure
+ * @return reference to this structure
+ */
+ auto& SetRasterizationState(RasterizationState* value)
+ {
+ rasterizationState = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets the vertex input state
+ *
+ * Vertex input state describes format of vertices and must
+ * be compatible with attached shaders.
+ *
+ * param[in] pointer to vertex input state structure
+ * @return reference to this structure
+ */
+ auto& SetVertexInputState(VertexInputState* value)
+ {
+ vertexInputState = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets the input assembly state
+ *
+ * This state describes the topology of the pipeline.
+ *
+ * param[in] pointer to valid input assembly state structure
+ * @return reference to this structure
+ */
+ auto& SetInputAssemblyState(InputAssemblyState* value)
+ {
+ inputAssemblyState = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets the dynamic state mask
+ *
+ * Certain states can be modified on fly without a need of
+ * creating new pipeline. The commands which modify particular
+ * states may be issued later by executing command buffers.
+ *
+ * param[in] pointer to valid color blend state structure
+ * @return reference to this structure
+ */
+ auto& SetDynamicStateMask(PipelineDynamicStateMask value)
+ {
+ dynamicStateMask = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets allocation callbacks which will be used when object is created
+ * and destroyed.
+ *
+ * @param[in] value Valid reference to AllocationCallbacksStructure
+ * @return reference to this structure
+ */
+ auto& SetAllocationCallbacks(const AllocationCallbacks& value)
+ {
+ allocationCallbacks = &value;
+ return *this;
+ }
+
+ GraphicsStructureType type{GraphicsStructureType::PIPELINE_CREATE_INFO_STRUCT};
+ ExtensionCreateInfo* nextExtension{nullptr};
+
+ ColorBlendState* colorBlendState{nullptr};
+ const std::vector<ShaderState>* shaderState{nullptr};
+ ViewportState* viewportState{nullptr};
+ FramebufferState* framebufferState{nullptr};
+ Pipeline* basePipeline{nullptr};
+ DepthStencilState* depthStencilState{nullptr};
+ RasterizationState* rasterizationState{nullptr};
+ VertexInputState* vertexInputState{nullptr};
+ InputAssemblyState* inputAssemblyState{nullptr};
+ PipelineDynamicStateMask dynamicStateMask{0u};
+
+ const AllocationCallbacks* allocationCallbacks{nullptr};
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_PIPELINE_CREATE_INFO_H
--- /dev/null
+#ifndef DALI_GRAPHICS_PIPELINE_H
+#define DALI_GRAPHICS_PIPELINE_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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
+{
+/**
+ * @brief Pipeline object represents a single full graphics pipeline state.
+ *
+ * The state involves compiled and linked shaders as well as state parameters
+ * like blending, stencil, scissors, viewport etc.
+ *
+ * Some of the parameters can be modified by issuing commands but
+ * the Pipeline must mark those states
+ * as dynamic.
+ *
+ */
+class Pipeline
+{
+public:
+ Pipeline() = default;
+ virtual ~Pipeline() = default;
+
+ // not copyable
+ Pipeline(const Pipeline&) = delete;
+ Pipeline& operator=(const Pipeline&) = delete;
+
+protected:
+ Pipeline(Pipeline&&) = default;
+ Pipeline& operator=(Pipeline&&) = default;
+};
+
+} // Namespace Graphics
+} // Namespace Dali
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_RENDERPASS_CREATE_INFO_H
+#define DALI_GRAPHICS_RENDERPASS_CREATE_INFO_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+
+// INTERNAL INCLUDES
+#include "graphics-render-pass.h"
+#include "graphics-types.h"
+
+namespace Dali
+{
+namespace Graphics
+{
+class RenderTarget;
+/**
+ * @brief Interface class for RenderPassCreateInfo types in the graphics API.
+ *
+ * This class describes RenderPass properties (TBD)
+ */
+struct RenderPassCreateInfo
+{
+ /**
+ * @brief Sets pointer to the extension
+ *
+ * The pointer to the extension must be set either to nullptr
+ * or to the valid structure. The structures may create
+ * a chain. The last structure in a chain must point at
+ * nullptr.
+ *
+ * @param[in] value pointer to the valid extension structure
+ * @return reference to this structure
+ */
+ auto& SetNextExtension(ExtensionCreateInfo* value)
+ {
+ nextExtension = value;
+ return *this;
+ }
+
+ /**
+ * @brief Binds render target to render pass
+ *
+ * @param[in] value valid RenderTarget object
+ * @return reference to this structure
+ */
+ auto& SetRenderTarget(RenderTarget* value)
+ {
+ renderTarget = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets allocation callbacks which will be used when object is created
+ * and destroyed.
+ *
+ * @param[in] value Valid reference to AllocationCallbacksStructure
+ * @return reference to this structure
+ */
+ auto& SetAllocationCallbacks(const AllocationCallbacks& value)
+ {
+ allocationCallbacks = &value;
+ return *this;
+ }
+
+ GraphicsStructureType type{GraphicsStructureType::RENDERPASS_CREATE_INFO_STRUCT};
+ ExtensionCreateInfo* nextExtension{nullptr};
+ RenderTarget* renderTarget{nullptr};
+
+ const AllocationCallbacks* allocationCallbacks{nullptr};
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_FRAMEBUFFER_FACTORY_H
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_RENDER_PASS_H
+#define DALI_GRAPHICS_RENDER_PASS_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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
+{
+/**
+ * @brief RenderPass is very similar to the the Vulkan equivalent VkRenderPass.
+ *
+ * In general, the RenderPass object carries all the information on:
+ * - the render target (framebuffer, textures)
+ * - clear colors setup
+ * - inputs/outputs to build dependencies
+ *
+ */
+class RenderPass
+{
+public:
+ RenderPass() = default;
+ virtual ~RenderPass() = default;
+
+ // not copyable
+ RenderPass(const RenderPass&) = delete;
+ RenderPass& operator=(const RenderPass&) = delete;
+
+protected:
+ RenderPass(RenderPass&&) = default;
+ RenderPass& operator=(RenderPass&&) = default;
+};
+
+} // Namespace Graphics
+} // Namespace Dali
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_RENDER_TARGET_CREATE_INFO
+#define DALI_GRAPHICS_RENDER_TARGET_CREATE_INFO
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+
+// INTERNAL INCLUDES
+#include "graphics-render-target.h"
+#include "graphics-types.h"
+
+namespace Dali
+{
+namespace Graphics
+{
+/**
+ * @brief Describes specification of new render target.
+ *
+ * RenderTarget represents any presentable graphics output.
+ */
+struct RenderTargetCreateInfo
+{
+ /**
+ * @brief Sets pointer to the extension
+ *
+ * The pointer to the extension must be set either to nullptr
+ * or to the valid structure. The structures may create
+ * a chain. The last structure in a chain must point at
+ * nullptr.
+ *
+ * @param[in] value pointer to the valid extension structure
+ * @return reference to this structure
+ */
+ auto& SetNextExtension(ExtensionCreateInfo* value)
+ {
+ nextExtension = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets allocation callbacks which will be used when object is created
+ * and destroyed.
+ *
+ * @param[in] value Valid reference to AllocationCallbacksStructure
+ * @return reference to this structure
+ */
+ auto& SetAllocationCallbacks(const AllocationCallbacks& value)
+ {
+ allocationCallbacks = &value;
+ return *this;
+ }
+
+ GraphicsStructureType type{GraphicsStructureType::RENDER_TARGET_CREATE_INFO_STRUCT};
+ ExtensionCreateInfo* nextExtension{nullptr};
+
+ const AllocationCallbacks* allocationCallbacks{nullptr};
+};
+
+} // namespace Graphics
+} // namespace Dali
+#endif //DALI_GRAPHICS_RENDER_TARGET_CREATE_INFO
--- /dev/null
+#ifndef DALI_GRAPHICS_RENDER_TARGET_H
+#define DALI_GRAPHICS_RENDER_TARGET_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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 "graphics-types.h"
+
+namespace Dali
+{
+namespace Graphics
+{
+/**
+ * @brief RenderTarget object binds to any presentable graphics output.
+ */
+class RenderTarget
+{
+public:
+ RenderTarget() = default;
+ virtual ~RenderTarget() = default;
+
+ // not copyable
+ RenderTarget(const RenderTarget&) = delete;
+ RenderTarget& operator=(const RenderTarget&) = delete;
+
+protected:
+ RenderTarget(RenderTarget&&) = default;
+ RenderTarget& operator=(RenderTarget&&) = default;
+};
+
+} // Namespace Graphics
+} // Namespace Dali
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_SAMPLER_CREATE_INFO_H
+#define DALI_GRAPHICS_SAMPLER_CREATE_INFO_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+
+// INTERNAL INCLUDES
+#include "graphics-sampler.h"
+#include "graphics-types.h"
+
+namespace Dali
+{
+namespace Graphics
+{
+/**
+ * @brief Interface class for SamplerCreateInfo types in the graphics API.
+ */
+struct SamplerCreateInfo
+{
+ /**
+ * @brief Sets pointer to the extension
+ *
+ * The pointer to the extension must be set either to nullptr
+ * or to the valid structure. The structures may create
+ * a chain. The last structure in a chain must point at
+ * nullptr.
+ *
+ * @param[in] value pointer to the valid extension structure
+ * @return reference to this structure
+ */
+ auto& SetNextExtension(ExtensionCreateInfo* value)
+ {
+ nextExtension = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets address mode U
+ *
+ * @param[in] value Address mode
+ * @return reference to this structure
+ */
+ auto& SetAddressModeU(SamplerAddressMode value)
+ {
+ addressModeU = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets address mode V
+ *
+ * @param[in] value Address mode
+ * @return reference to this structure
+ */
+ auto& SetAddressModeV(SamplerAddressMode value)
+ {
+ addressModeV = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets address mode W
+ *
+ * @param[in] value Address mode
+ * @return reference to this structure
+ */
+ auto& SetAddressModeW(SamplerAddressMode value)
+ {
+ addressModeW = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets minification filter
+ *
+ * @param[in] value filter mode
+ * @return reference to this structure
+ */
+ auto& SetMinFilter(SamplerFilter value)
+ {
+ minFilter = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets magnification filter
+ *
+ * @param[in] value filter mode
+ * @return reference to this structure
+ */
+ auto& SetMagFilter(SamplerFilter value)
+ {
+ magFilter = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets mipmap mode
+ *
+ * @param[in] value mipmap mode
+ * @return reference to this structure
+ */
+ auto& SetMipMapMode(SamplerMipmapMode value)
+ {
+ mipMapMode = value;
+ return *this;
+ }
+
+ /**
+ * @brief Enables/disables anisotropy
+ *
+ * @param[in] value true to enable, false otherwise
+ * @return reference to this structure
+ */
+ auto& SetAnisotropyEnable(bool value)
+ {
+ anisotropyEnable = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets maximum anisotropy level
+ *
+ * @param[in] value maximum anisotropy level
+ * @return reference to this structure
+ */
+ auto& SetMaxAnisotropy(float value)
+ {
+ maxAnisotropy = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets minimum LOD
+ *
+ * @param[in] value LOD value
+ * @return reference to this structure
+ */
+ auto& SetMinLod(float value)
+ {
+ minLod = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets maximum LOD
+ *
+ * @param[in] value LOD value
+ * @return reference to this structure
+ */
+ auto& SetMaxLod(float value)
+ {
+ maxLod = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets using unnormalized coordinates
+ *
+ * @param[in] value true to use unnormalized coordinates
+ * @return reference to this structure
+ */
+ auto& SetUnnormalizeCoordinates(bool value)
+ {
+ unnormalizeCoordinates = value;
+ return *this;
+ }
+
+ /**
+ * @brief Enables sample compare operations
+ *
+ * @param[in] value true to enable
+ * @return reference to this structure
+ */
+ auto& SetCompareEnable(bool value)
+ {
+ compareEnable = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets allocation callbacks which will be used when object is created
+ * and destroyed.
+ *
+ * @param[in] value Valid reference to AllocationCallbacksStructure
+ * @return reference to this structure
+ */
+ auto& SetAllocationCallbacks(const AllocationCallbacks& value)
+ {
+ allocationCallbacks = &value;
+ return *this;
+ }
+
+ GraphicsStructureType type{GraphicsStructureType::SAMPLER_CREATE_INFO_STRUCT};
+ ExtensionCreateInfo* nextExtension{nullptr};
+
+ SamplerAddressMode addressModeU{};
+ SamplerAddressMode addressModeV{};
+ SamplerAddressMode addressModeW{};
+ SamplerFilter minFilter{};
+ SamplerFilter magFilter{};
+ SamplerMipmapMode mipMapMode{};
+ bool anisotropyEnable{false};
+ float maxAnisotropy{0.0f};
+ float minLod{0.0f};
+ float maxLod{0.0f};
+ bool unnormalizeCoordinates{false};
+ bool compareEnable{false};
+ CompareOp compareOp{};
+
+ const AllocationCallbacks* allocationCallbacks{nullptr};
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_SAMPLER_CREATE_INFO
--- /dev/null
+#ifndef DALI_GRAPHICS_SAMPLER_H
+#define DALI_GRAPHICS_SAMPLER_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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
+{
+/**
+ * @brief Sampler represents GPU sampler object
+ */
+class Sampler
+{
+public:
+ Sampler() = default;
+ virtual ~Sampler() = default;
+
+ // not copyable
+ Sampler(const Sampler&) = delete;
+ Sampler& operator=(const Sampler&) = delete;
+
+protected:
+ Sampler(Sampler&&) = default;
+ Sampler& operator=(Sampler&&) = default;
+};
+
+} // Namespace Graphics
+} // Namespace Dali
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_SHADER_CREATE_INFO_H
+#define DALI_GRAPHICS_SHADER_CREATE_INFO_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <memory>
+
+// INTERNAL INCLUDES
+#include "graphics-shader.h"
+#include "graphics-types.h"
+
+namespace Dali
+{
+namespace Graphics
+{
+/**
+ * @brief ShaderCreateInfo contains details of a single shader (not a GL program!)
+ * attached to a specified pipeline stage (ie. vertex shader, fragment shader etc.)
+ */
+struct ShaderCreateInfo
+{
+ /**
+ * @brief Sets pointer to the extension
+ *
+ * The pointer to the extension must be set either to nullptr
+ * or to the valid structure. The structures may create
+ * a chain. The last structure in a chain must point at
+ * nullptr.
+ *
+ * @param[in] value pointer to the valid extension structure
+ * @return reference to this structure
+ */
+ auto& SetNextExtension(ExtensionCreateInfo* value)
+ {
+ nextExtension = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets pipeline stage the shader will be executed in
+ *
+ * @param[in] value valid pipeline stage
+ * @return reference to this structure
+ */
+ auto& SetPipelineStage(PipelineStage value)
+ {
+ pipelineStage = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets shader source language
+ *
+ * @param[in] value valid source language
+ * @return reference to this structure
+ */
+ auto& SetShaderlanguage(ShaderLanguage value)
+ {
+ shaderlanguage = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets pointer to the source data
+ *
+ * @param[in] value pointer to the source data
+ * @return reference to this structure
+ */
+ auto& SetSourceData(const void* value)
+ {
+ sourceData = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets size of the source data (in bytes)
+ *
+ * If the shader mode is TEXT, the size must include
+ * null-terminator.
+ *
+ * @param[in] value size in bytes
+ * @return reference to this structure
+ */
+ auto& SetSourceSize(uint32_t value)
+ {
+ sourceSize = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets shader source mode
+ *
+ * @param[in] value shader mode
+ * @return reference to this structure
+ */
+ auto& SetSourceMode(ShaderSourceMode value)
+ {
+ sourceMode = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets allocation callbacks which will be used when object is created
+ * and destroyed.
+ *
+ * @param[in] value Valid reference to AllocationCallbacksStructure
+ * @return reference to this structure
+ */
+ auto& SetAllocationCallbacks(const AllocationCallbacks& value)
+ {
+ allocationCallbacks = &value;
+ return *this;
+ }
+
+ GraphicsStructureType type{GraphicsStructureType::SHADER_CREATE_INFO_STRUCT};
+ ExtensionCreateInfo* nextExtension{nullptr};
+
+ PipelineStage pipelineStage{};
+ ShaderLanguage shaderlanguage{};
+ const void* sourceData{nullptr};
+ uint32_t sourceSize{0u};
+ ShaderSourceMode sourceMode{};
+
+ const AllocationCallbacks* allocationCallbacks{nullptr};
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_SHADER_CREATE_INFO_H
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_SHADER_H
+#define DALI_GRAPHICS_SHADER_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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
+{
+/**
+ * @brief The Shader class represents a single shader.
+ *
+ * The shader can be bound to the specific stage of pipeline
+ * (vertex, fragment, compute etc.).
+ *
+ * Shaders are linked together when pipeline is created.
+ *
+ */
+class Shader
+{
+public:
+ Shader() = default;
+ virtual ~Shader() = default;
+
+ // not copyable
+ Shader(const Shader&) = delete;
+ Shader& operator=(const Shader&) = delete;
+
+protected:
+ Shader(Shader&&) = default;
+ Shader& operator=(Shader&&) = default;
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_SHADER_H
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_TEXTURE_CREATE_INFO_H
+#define DALI_GRAPHICS_TEXTURE_CREATE_INFO_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/images/native-image-interface.h>
+#include <memory>
+
+// INTERNAL INCLUDES
+#include "graphics-texture.h"
+#include "graphics-types.h"
+
+namespace Dali
+{
+namespace Graphics
+{
+/**
+ * @brief Interface class for TextureCreateInfo types in the graphics API.
+ */
+struct TextureCreateInfo
+{
+ /**
+ * @brief Sets pointer to the extension
+ *
+ * The pointer to the extension must be set either to nullptr
+ * or to the valid structure. The structures may create
+ * a chain. The last structure in a chain must point at
+ * nullptr.
+ *
+ * @param[in] value pointer to the valid extension structure
+ * @return reference to this structure
+ */
+ auto& SetNextExtension(ExtensionCreateInfo* value)
+ {
+ nextExtension = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets type of the texture
+ *
+ * @param[in] value type of the texture
+ * @return reference to this structure
+ */
+ auto& SetTextureType(TextureType value)
+ {
+ textureType = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets size of the texture
+ *
+ * @param[in] value size of the texture
+ * @return reference to this structure
+ */
+ auto& SetSize(Extent2D value)
+ {
+ size = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets the texture format
+ *
+ * Not all texture formats are supported, some are emulated.
+ *
+ * @param[in] value valid texture format
+ * @return reference to this structure
+ */
+ auto& SetFormat(Format value)
+ {
+ format = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets mipmap state
+ *
+ * @param[in] value The mipmap state flag
+ * @return reference to this structure
+ */
+ auto& SetMipMapFlag(TextureMipMapFlag value)
+ {
+ mipMapFlag = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets pointer to the data
+ *
+ * The data of texture can be uploaded upon texture creation.
+ *
+ * @param[in] value pointer to valid data
+ * @return reference to this structure
+ */
+ auto& SetData(void* value)
+ {
+ data = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets size of the data
+ *
+ * @param[in] value size of data in bytes
+ * @return reference to this structure
+ */
+ auto& SetDataSize(uint32_t value)
+ {
+ dataSize = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets texture data layout
+ *
+ * By choosing LINEAR layout the texture can be accessed
+ * directly via mapped memory. This may mean allocating
+ * extra staging buffer if necessary (layout may be emulated).
+ *
+ * @param[in] value texture layout
+ * @return reference to this structure
+ */
+ auto& SetLayout(TextureLayout value)
+ {
+ layout = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets texture usage flags
+ *
+ * The usage flags may affect the way the texture is
+ * allocated and stored in the memory. It may also affect
+ * the way how data is writen/read.
+ *
+ * @param[in] value Flags of usage
+ * @return reference to this structure
+ */
+ auto& SetUsageFlags(TextureUsageFlags value)
+ {
+ usageFlags = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets native image interface pointer
+ *
+ * @param[in] value valid native image interface pointer
+ * @return reference to this structure
+ */
+ auto& SetNativeImage(NativeImageInterfacePtr value)
+ {
+ nativeImagePtr = value;
+ return *this;
+ }
+
+ /**
+ * @brief Sets allocation callbacks which will be used when object is created
+ * and destroyed.
+ *
+ * @param[in] value Valid reference to AllocationCallbacksStructure
+ * @return reference to this structure
+ */
+ auto& SetAllocationCallbacks(const AllocationCallbacks& value)
+ {
+ allocationCallbacks = &value;
+ return *this;
+ }
+
+ GraphicsStructureType type{GraphicsStructureType::TEXTURE_CREATE_INFO_STRUCT};
+ ExtensionCreateInfo* nextExtension{nullptr};
+
+ TextureType textureType{};
+ Extent2D size{};
+ Format format{};
+ TextureMipMapFlag mipMapFlag{};
+ TextureLayout layout{};
+ TextureUsageFlags usageFlags{};
+ void* data{};
+ uint32_t dataSize{0u};
+ NativeImageInterfacePtr nativeImagePtr{};
+
+ const AllocationCallbacks* allocationCallbacks{nullptr};
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif // DALI_GRAPHICS_API_TEXTURE_CREATE_INFO_H
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_TEXTURE_H
+#define DALI_GRAPHICS_TEXTURE_H
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * 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
+{
+/**
+ * @brief The Texture class represents a GPU texture object.
+ *
+ * It's slightly higher level than the Vulkan VkImage (more like
+ * combined image sampler).
+ */
+class Texture
+{
+public:
+ Texture() = default;
+ virtual ~Texture() = default;
+
+ // not copyable
+ Texture(const Texture&) = delete;
+ Texture& operator=(const Texture&) = delete;
+
+protected:
+ Texture(Texture&&) = default;
+ Texture& operator=(Texture&&) = default;
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif
\ No newline at end of file
--- /dev/null
+#ifndef DALI_GRAPHICS_API_TYPES
+#define DALI_GRAPHICS_API_TYPES
+
+/*
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <string>
+#include <utility>
+#include <vector>
+
+namespace Dali
+{
+namespace Graphics
+{
+class CommandBuffer;
+class Texture;
+class Buffer;
+class Shader;
+class Framebuffer;
+
+/**
+ * @brief Structure describes 2D offset
+ */
+struct Offset2D
+{
+ int32_t x = 0;
+ int32_t y = 0;
+};
+
+/**
+ * @brief Structure describes 2D dimensions
+ */
+struct Extent2D
+{
+ uint32_t width;
+ uint32_t height;
+};
+
+/**
+ * @brief Structure describes 2D rectangle (offset, extent)
+ */
+struct Rect2D
+{
+ int32_t x = 0;
+ int32_t y = 0;
+ uint32_t width = 0;
+ uint32_t height = 0;
+};
+
+/**
+ * @brief Structure represents area of viewport
+ */
+struct Viewport
+{
+ float x = 0.0f;
+ float y = 0.0f;
+ float width = 0.0f;
+ float height = 0.0f;
+ float minDepth = 0.0f;
+ float maxDepth = 0.0f;
+};
+
+/**
+ * @brief Describes vertex attribute input rate
+ */
+enum class VertexInputRate
+{
+ PER_VERTEX, ///< Attribute read per vertex
+ PER_INSTANCE ///< Attribute read per instance
+};
+
+/**
+ * @brief Vertex input format
+ *
+ * When UNDEFINED, the reflection is used to determine what
+ * the actual format is.
+ */
+enum class VertexInputFormat
+{
+ UNDEFINED,
+ FVECTOR2,
+ FVECTOR3,
+ FVECTOR4,
+ IVECTOR2,
+ IVECTOR3,
+ IVECTOR4,
+ FLOAT,
+ INTEGER,
+};
+
+/**
+ * @brief Logic operators used by color blending state
+ * when logicOpEnable is set.
+ */
+enum class LogicOp
+{
+ CLEAR = 0,
+ AND = 1,
+ AND_REVERSE = 2,
+ COPY = 3,
+ AND_INVERTED = 4,
+ NO_OP = 5,
+ XOR = 6,
+ OR = 7,
+ NOR = 8,
+ EQUIVALENT = 9,
+ INVERT = 10,
+ OR_REVERSE = 11,
+ COPY_INVERTED = 12,
+ OR_INVERTED = 13,
+ NAND = 14,
+ SET = 15,
+};
+
+/**
+ * @brief Blend factors
+ */
+enum class BlendFactor
+{
+ ZERO = 0,
+ ONE = 1,
+ SRC_COLOR = 2,
+ ONE_MINUS_SRC_COLOR = 3,
+ DST_COLOR = 4,
+ ONE_MINUS_DST_COLOR = 5,
+ SRC_ALPHA = 6,
+ ONE_MINUS_SRC_ALPHA = 7,
+ DST_ALPHA = 8,
+ ONE_MINUS_DST_ALPHA = 9,
+ CONSTANT_COLOR = 10,
+ ONE_MINUS_CONSTANT_COLOR = 11,
+ CONSTANT_ALPHA = 12,
+ ONE_MINUS_CONSTANT_ALPHA = 13,
+ SRC_ALPHA_SATURATE = 14,
+ SRC1_COLOR = 15,
+ ONE_MINUS_SRC1_COLOR = 16,
+ SRC1_ALPHA = 17,
+ ONE_MINUS_SRC1_ALPHA = 18,
+};
+
+/**
+ * @brief Blend operators
+ */
+enum class BlendOp
+{
+ ADD = 0,
+ SUBTRACT = 1,
+ REVERSE_SUBTRACT = 2,
+ MIN = 3,
+ MAX = 4,
+};
+
+/**
+ * @brief Compare operators
+ */
+enum class CompareOp
+{
+ NEVER,
+ LESS,
+ EQUAL,
+ LESS_OR_EQUAL,
+ GREATER,
+ NOT_EQUAL,
+ GREATER_OR_EQUAL,
+ ALWAYS
+};
+
+/**
+ * @brief Stencil operators
+ */
+enum class StencilOp
+{
+ KEEP,
+ ZERO,
+ REPLACE,
+ INCREMENT_AND_CLAMP,
+ DECREMENT_AND_CLAMP,
+ INVERT,
+ INCREMENT_AND_WRAP,
+ DECREMENT_AND_WRAP
+};
+
+/**
+ * @brief Backface culling modes
+ */
+enum class CullMode
+{
+ NONE,
+ FRONT,
+ BACK,
+ FRONT_AND_BACK
+};
+
+/**
+ * @brief Polygon drawing modes
+ */
+enum class PolygonMode
+{
+ FILL,
+ LINE,
+ POINT
+};
+
+/**
+ * @brief Front face direction
+ */
+enum class FrontFace
+{
+ COUNTER_CLOCKWISE,
+ CLOCKWISE
+};
+
+/**
+ * @brief Primitive geometry topology
+ */
+enum class PrimitiveTopology
+{
+ POINT_LIST,
+ LINE_LIST,
+ LINE_STRIP,
+ TRIANGLE_LIST,
+ TRIANGLE_STRIP,
+ TRIANGLE_FAN
+};
+
+/**
+ * @brief Sampler address ( wrapping ) mode
+ */
+enum class SamplerAddressMode
+{
+ REPEAT,
+ MIRRORED_REPEAT,
+ CLAMP_TO_EDGE,
+ CLAMP_TO_BORDER,
+ MIRROR_CLAMP_TO_EDGE
+};
+
+/**
+ * @brief Filtering mode
+ */
+enum class SamplerFilter
+{
+ NEAREST,
+ LINEAR
+};
+
+/**
+ * @brief Mipmap mode
+ */
+enum class SamplerMipmapMode
+{
+ NONE,
+ NEAREST,
+ LINEAR
+};
+
+/**
+ * @brief Describes pipeline's color blend state
+ */
+struct ColorBlendState
+{
+ bool logicOpEnable = false;
+ LogicOp logicOp = {};
+ float blendConstants[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+ bool blendEnable = false;
+ BlendFactor srcColorBlendFactor = BlendFactor::ZERO;
+ BlendFactor dstColorBlendFactor = BlendFactor::ZERO;
+ BlendOp colorBlendOp = {};
+ BlendFactor srcAlphaBlendFactor = BlendFactor::ZERO;
+ BlendFactor dstAlphaBlendFactor = BlendFactor::ZERO;
+ BlendOp alphaBlendOp = {};
+ uint32_t colorComponentWriteBits = {0u};
+
+ auto& SetLogicOpEnable(bool value)
+ {
+ logicOpEnable = value;
+ return *this;
+ }
+
+ auto& SetLogicOp(LogicOp value)
+ {
+ logicOp = value;
+ return *this;
+ }
+
+ auto& SetBlendConstants(float value[4])
+ {
+ std::copy(value, value + 4, blendConstants);
+ return *this;
+ }
+
+ auto& SetBlendEnable(bool value)
+ {
+ blendEnable = value;
+ return *this;
+ }
+
+ auto& SetSrcColorBlendFactor(BlendFactor value)
+ {
+ srcColorBlendFactor = value;
+ return *this;
+ }
+
+ auto& SetDstColorBlendFactor(BlendFactor value)
+ {
+ dstColorBlendFactor = value;
+ return *this;
+ }
+
+ auto& SetColorBlendOp(BlendOp value)
+ {
+ colorBlendOp = value;
+ return *this;
+ }
+
+ auto& SetSrcAlphaBlendFactor(BlendFactor value)
+ {
+ srcAlphaBlendFactor = value;
+ return *this;
+ }
+
+ auto& SetDstAlphaBlendFactor(BlendFactor value)
+ {
+ dstAlphaBlendFactor = value;
+ return *this;
+ }
+
+ auto& SetAlphaBlendOp(BlendOp value)
+ {
+ alphaBlendOp = value;
+ return *this;
+ }
+
+ auto& SetColorComponentsWriteBits(uint32_t value)
+ {
+ colorComponentWriteBits = value;
+ return *this;
+ }
+};
+
+/**
+ * @brief Framebuffer state
+ */
+struct FramebufferState
+{
+ const Framebuffer* framebuffer{nullptr};
+
+ auto& SetFramebuffer(const Framebuffer& value)
+ {
+ framebuffer = &value;
+ return *this;
+ }
+};
+
+/**
+ * @brief Describes pipeline's viewport and scissor state
+ */
+struct ViewportState
+{
+ Viewport viewport{0.0, 0.0, 0.0, 0.0};
+ Rect2D scissor{0, 0, 0, 0};
+ bool scissorTestEnable{false};
+
+ auto& SetViewport(const Viewport& value)
+ {
+ viewport = value;
+ return *this;
+ }
+
+ auto& SetScissor(const Rect2D& value)
+ {
+ scissor = value;
+ return *this;
+ }
+
+ auto& SetScissorTestEnable(bool value)
+ {
+ scissorTestEnable = value;
+ return *this;
+ }
+};
+
+/**
+ * @brief Describes stencil operation state
+ */
+struct StencilOpState
+{
+ StencilOp failOp{};
+ StencilOp passOp{};
+ StencilOp depthFailOp{};
+ CompareOp compareOp{};
+ uint32_t compareMask{0u};
+ uint32_t writeMask{0u};
+ uint32_t reference{0u};
+
+ auto& SetFailOp(StencilOp value)
+ {
+ failOp = value;
+ return *this;
+ }
+
+ auto& SetPassOp(StencilOp value)
+ {
+ failOp = value;
+ return *this;
+ }
+
+ auto& SetDepthFailOp(StencilOp value)
+ {
+ failOp = value;
+ return *this;
+ }
+
+ auto& SetCompareOp(CompareOp value)
+ {
+ compareOp = value;
+ return *this;
+ }
+
+ auto& SetCompareMask(uint32_t value)
+ {
+ compareMask = value;
+ return *this;
+ }
+
+ auto& SetWriteMask(uint32_t value)
+ {
+ writeMask = value;
+ return *this;
+ }
+
+ auto& SetReference(uint32_t value)
+ {
+ reference = value;
+ return *this;
+ }
+};
+
+/**
+ * @brief Describes pipeline's viewport and scissor state
+ */
+struct DepthStencilState
+{
+ bool depthTestEnable{false};
+ bool depthWriteEnable{false};
+ CompareOp depthCompareOp{};
+
+ bool stencilTestEnable{false};
+ StencilOpState front{};
+ StencilOpState back{};
+
+ auto& SetDepthTestEnable(bool value)
+ {
+ depthTestEnable = value;
+ return *this;
+ }
+
+ auto& SetDepthWriteEnable(bool value)
+ {
+ depthWriteEnable = value;
+ return *this;
+ }
+
+ auto& SetDepthCompareOp(CompareOp value)
+ {
+ depthCompareOp = value;
+ return *this;
+ }
+
+ auto& SetFront(StencilOpState value)
+ {
+ front = value;
+ return *this;
+ }
+
+ auto& SetBack(StencilOpState value)
+ {
+ back = value;
+ return *this;
+ }
+
+ auto& SetStencilTestEnable(bool value)
+ {
+ stencilTestEnable = value;
+ return *this;
+ }
+};
+
+/**
+ * @brief Rasterization state descriptor
+ */
+struct RasterizationState
+{
+ CullMode cullMode{};
+ PolygonMode polygonMode{};
+ FrontFace frontFace{};
+
+ auto& SetCullMode(CullMode value)
+ {
+ cullMode = value;
+ return *this;
+ }
+
+ auto& SetPolygonMode(PolygonMode value)
+ {
+ polygonMode = value;
+ return *this;
+ }
+
+ auto& SetFrontFace(FrontFace value)
+ {
+ frontFace = value;
+ return *this;
+ }
+};
+
+/**
+ * @brief Input assembly state descriptor.
+ *
+ * Structure describes the topology for submitted
+ * geometry.
+ */
+struct InputAssemblyState
+{
+ PrimitiveTopology topology{};
+ bool primitiveRestartEnable{true};
+
+ auto& SetTopology(PrimitiveTopology value)
+ {
+ topology = value;
+ return *this;
+ }
+
+ auto& SetPrimitiveRestartEnable(bool value)
+ {
+ primitiveRestartEnable = true;
+ return *this;
+ }
+};
+
+/**
+ * @brief Pipeline dynamic state bits
+ */
+namespace PipelineDynamicStateBits
+{
+const uint32_t VIEWPORT_BIT = 1 << 0;
+const uint32_t SCISSOR_BIT = 1 << 1;
+const uint32_t LINE_WIDTH_BIT = 1 << 2;
+const uint32_t DEPTH_BIAS_BIT = 1 << 3;
+const uint32_t BLEND_CONSTANTS_BIT = 1 << 4;
+const uint32_t DEPTH_BOUNDS_BIT = 1 << 5;
+const uint32_t STENCIL_COMPARE_MASK_BIT = 1 << 6;
+const uint32_t STENCIL_WRITE_MASK_BIT = 1 << 7;
+const uint32_t STENCIL_REFERENCE_BIT = 1 << 8;
+} // namespace PipelineDynamicStateBits
+
+const uint32_t PIPELINE_DYNAMIC_STATE_COUNT(9u);
+
+using PipelineDynamicStateMask = uint32_t;
+
+/**
+ * @brief Structure describes vertex input state of the pipeline.
+ * It specifies buffer binding and attribute format to be used.
+ */
+struct VertexInputState
+{
+ VertexInputState() = default;
+
+ /**
+ * @brief Vertex buffer binding
+ */
+ struct Binding
+ {
+ Binding(uint32_t _stride, VertexInputRate _inputRate)
+ : stride(_stride),
+ inputRate(_inputRate)
+ {
+ }
+ uint32_t stride;
+ VertexInputRate inputRate;
+ };
+
+ /**
+ * @brief Attribute description
+ */
+ struct Attribute
+ {
+ Attribute(uint32_t _location, uint32_t _binding, uint32_t _offset, VertexInputFormat _format)
+ : location(_location),
+ binding(_binding),
+ offset(_offset),
+ format(_format)
+ {
+ }
+
+ uint32_t location;
+ uint32_t binding;
+ uint32_t offset;
+ VertexInputFormat format;
+ };
+
+ VertexInputState(std::vector<Binding> _bufferBindings, std::vector<Attribute> _attributes)
+ : bufferBindings(std::move(_bufferBindings)),
+ attributes(std::move(_attributes))
+ {
+ }
+
+ std::vector<Binding> bufferBindings{};
+ std::vector<Attribute> attributes{};
+};
+
+/**
+ * @brief List of all possible formats
+ * Not all formats may be supported
+ */
+enum class Format
+{
+ UNDEFINED,
+ // GLES compatible, luminance doesn't exist in Vulkan
+ L8,
+ L8A8,
+
+ // Vulkan compatible
+ R4G4_UNORM_PACK8,
+ R4G4B4A4_UNORM_PACK16,
+ B4G4R4A4_UNORM_PACK16,
+ R5G6B5_UNORM_PACK16,
+ B5G6R5_UNORM_PACK16,
+ R5G5B5A1_UNORM_PACK16,
+ B5G5R5A1_UNORM_PACK16,
+ A1R5G5B5_UNORM_PACK16,
+ R8_UNORM,
+ R8_SNORM,
+ R8_USCALED,
+ R8_SSCALED,
+ R8_UINT,
+ R8_SINT,
+ R8_SRGB,
+ R8G8_UNORM,
+ R8G8_SNORM,
+ R8G8_USCALED,
+ R8G8_SSCALED,
+ R8G8_UINT,
+ R8G8_SINT,
+ R8G8_SRGB,
+ R8G8B8_UNORM,
+ R8G8B8_SNORM,
+ R8G8B8_USCALED,
+ R8G8B8_SSCALED,
+ R8G8B8_UINT,
+ R8G8B8_SINT,
+ R8G8B8_SRGB,
+ B8G8R8_UNORM,
+ B8G8R8_SNORM,
+ B8G8R8_USCALED,
+ B8G8R8_SSCALED,
+ B8G8R8_UINT,
+ B8G8R8_SINT,
+ B8G8R8_SRGB,
+ R8G8B8A8_UNORM,
+ R8G8B8A8_SNORM,
+ R8G8B8A8_USCALED,
+ R8G8B8A8_SSCALED,
+ R8G8B8A8_UINT,
+ R8G8B8A8_SINT,
+ R8G8B8A8_SRGB,
+ B8G8R8A8_UNORM,
+ B8G8R8A8_SNORM,
+ B8G8R8A8_USCALED,
+ B8G8R8A8_SSCALED,
+ B8G8R8A8_UINT,
+ B8G8R8A8_SINT,
+ B8G8R8A8_SRGB,
+ A8B8G8R8_UNORM_PACK32,
+ A8B8G8R8_SNORM_PACK32,
+ A8B8G8R8_USCALED_PACK32,
+ A8B8G8R8_SSCALED_PACK32,
+ A8B8G8R8_UINT_PACK32,
+ A8B8G8R8_SINT_PACK32,
+ A8B8G8R8_SRGB_PACK32,
+ A2R10G10B10_UNORM_PACK32,
+ A2R10G10B10_SNORM_PACK32,
+ A2R10G10B10_USCALED_PACK32,
+ A2R10G10B10_SSCALED_PACK32,
+ A2R10G10B10_UINT_PACK32,
+ A2R10G10B10_SINT_PACK32,
+ A2B10G10R10_UNORM_PACK32,
+ A2B10G10R10_SNORM_PACK32,
+ A2B10G10R10_USCALED_PACK32,
+ A2B10G10R10_SSCALED_PACK32,
+ A2B10G10R10_UINT_PACK32,
+ A2B10G10R10_SINT_PACK32,
+ R16_UNORM,
+ R16_SNORM,
+ R16_USCALED,
+ R16_SSCALED,
+ R16_UINT,
+ R16_SINT,
+ R16_SFLOAT,
+ R16G16_UNORM,
+ R16G16_SNORM,
+ R16G16_USCALED,
+ R16G16_SSCALED,
+ R16G16_UINT,
+ R16G16_SINT,
+ R16G16_SFLOAT,
+ R16G16B16_UNORM,
+ R16G16B16_SNORM,
+ R16G16B16_USCALED,
+ R16G16B16_SSCALED,
+ R16G16B16_UINT,
+ R16G16B16_SINT,
+ R16G16B16_SFLOAT,
+ R16G16B16A16_UNORM,
+ R16G16B16A16_SNORM,
+ R16G16B16A16_USCALED,
+ R16G16B16A16_SSCALED,
+ R16G16B16A16_UINT,
+ R16G16B16A16_SINT,
+ R16G16B16A16_SFLOAT,
+ R32_UINT,
+ R32_SINT,
+ R32_SFLOAT,
+ R32G32_UINT,
+ R32G32_SINT,
+ R32G32_SFLOAT,
+ R32G32B32_UINT,
+ R32G32B32_SINT,
+ R32G32B32_SFLOAT,
+ R32G32B32A32_UINT,
+ R32G32B32A32_SINT,
+ R32G32B32A32_SFLOAT,
+ R64_UINT,
+ R64_SINT,
+ R64_SFLOAT,
+ R64G64_UINT,
+ R64G64_SINT,
+ R64G64_SFLOAT,
+ R64G64B64_UINT,
+ R64G64B64_SINT,
+ R64G64B64_SFLOAT,
+ R64G64B64A64_UINT,
+ R64G64B64A64_SINT,
+ R64G64B64A64_SFLOAT,
+ B10G11R11_UFLOAT_PACK32,
+ E5B9G9R9_UFLOAT_PACK32,
+ D16_UNORM,
+ X8_D24_UNORM_PACK32,
+ D32_SFLOAT,
+ S8_UINT,
+ D16_UNORM_S8_UINT,
+ D24_UNORM_S8_UINT,
+ D32_SFLOAT_S8_UINT,
+ BC1_RGB_UNORM_BLOCK,
+ BC1_RGB_SRGB_BLOCK,
+ BC1_RGBA_UNORM_BLOCK,
+ BC1_RGBA_SRGB_BLOCK,
+ BC2_UNORM_BLOCK,
+ BC2_SRGB_BLOCK,
+ BC3_UNORM_BLOCK,
+ BC3_SRGB_BLOCK,
+ BC4_UNORM_BLOCK,
+ BC4_SNORM_BLOCK,
+ BC5_UNORM_BLOCK,
+ BC5_SNORM_BLOCK,
+ BC6H_UFLOAT_BLOCK,
+ BC6H_SFLOAT_BLOCK,
+ BC7_UNORM_BLOCK,
+ BC7_SRGB_BLOCK,
+ ETC2_R8G8B8_UNORM_BLOCK,
+ ETC2_R8G8B8_SRGB_BLOCK,
+ ETC2_R8G8B8A1_UNORM_BLOCK,
+ ETC2_R8G8B8A1_SRGB_BLOCK,
+ ETC2_R8G8B8A8_UNORM_BLOCK,
+ ETC2_R8G8B8A8_SRGB_BLOCK,
+ EAC_R11_UNORM_BLOCK,
+ EAC_R11_SNORM_BLOCK,
+ EAC_R11G11_UNORM_BLOCK,
+ EAC_R11G11_SNORM_BLOCK,
+ ASTC_4x4_UNORM_BLOCK,
+ ASTC_4x4_SRGB_BLOCK,
+ ASTC_5x4_UNORM_BLOCK,
+ ASTC_5x4_SRGB_BLOCK,
+ ASTC_5x5_UNORM_BLOCK,
+ ASTC_5x5_SRGB_BLOCK,
+ ASTC_6x5_UNORM_BLOCK,
+ ASTC_6x5_SRGB_BLOCK,
+ ASTC_6x6_UNORM_BLOCK,
+ ASTC_6x6_SRGB_BLOCK,
+ ASTC_8x5_UNORM_BLOCK,
+ ASTC_8x5_SRGB_BLOCK,
+ ASTC_8x6_UNORM_BLOCK,
+ ASTC_8x6_SRGB_BLOCK,
+ ASTC_8x8_UNORM_BLOCK,
+ ASTC_8x8_SRGB_BLOCK,
+ ASTC_10x5_UNORM_BLOCK,
+ ASTC_10x5_SRGB_BLOCK,
+ ASTC_10x6_UNORM_BLOCK,
+ ASTC_10x6_SRGB_BLOCK,
+ ASTC_10x8_UNORM_BLOCK,
+ ASTC_10x8_SRGB_BLOCK,
+ ASTC_10x10_UNORM_BLOCK,
+ ASTC_10x10_SRGB_BLOCK,
+ ASTC_12x10_UNORM_BLOCK,
+ ASTC_12x10_SRGB_BLOCK,
+ ASTC_12x12_UNORM_BLOCK,
+ ASTC_12x12_SRGB_BLOCK,
+ PVRTC1_2BPP_UNORM_BLOCK_IMG,
+ PVRTC1_4BPP_UNORM_BLOCK_IMG,
+ PVRTC2_2BPP_UNORM_BLOCK_IMG,
+ PVRTC2_4BPP_UNORM_BLOCK_IMG,
+ PVRTC1_2BPP_SRGB_BLOCK_IMG,
+ PVRTC1_4BPP_SRGB_BLOCK_IMG,
+ PVRTC2_2BPP_SRGB_BLOCK_IMG,
+ PVRTC2_4BPP_SRGB_BLOCK_IMG,
+};
+
+/**
+ * @brief Flags specifying a buffer usage
+ */
+enum class BufferUsage
+{
+ TRANSFER_SRC = 1 << 0,
+ TRANSFER_DST = 1 << 1,
+ UNIFORM_TEXEL_BUFFER = 1 << 2,
+ STORAGE_TEXEL_BUFFER = 1 << 3,
+ UNIFORM_BUFFER = 1 << 4,
+ STORAGE_BUFFER = 1 << 5,
+ INDEX_BUFFER = 1 << 6,
+ VERTEX_BUFFER = 1 << 7,
+ INDIRECT_BUFFER = 1 << 8,
+};
+
+using BufferUsageFlags = uint32_t;
+
+inline BufferUsageFlags operator|(BufferUsageFlags flags, BufferUsage usage)
+{
+ flags |= static_cast<uint32_t>(usage);
+ return flags;
+}
+
+/**
+ * @brief The structure describes memory requirements of GPU resource (texture, buffer)
+ */
+struct MemoryRequirements
+{
+ size_t size;
+ size_t alignment;
+};
+
+using TextureUpdateFlags = uint32_t;
+enum class TextureUpdateFlagBits
+{
+ KEEP_SOURCE = 1 << 0,
+};
+
+/**
+ * @brief Texture update info
+ *
+ * Describes the texture update to be executed by
+ * Controller::UpdateTextures()
+ */
+struct TextureUpdateInfo
+{
+ Texture* dstTexture{};
+ Offset2D dstOffset2D;
+ uint32_t layer{};
+ uint32_t level{};
+
+ uint32_t srcReference{};
+ Extent2D srcExtent2D{};
+ uint32_t srcOffset{};
+ uint32_t srcSize{};
+};
+
+/**
+ * @brief Texture update source info
+ *
+ * Describes the source of data (memory, buffer or another texture)
+ * to be used when updating textures using Controller::UpdateTextures().
+ */
+struct TextureUpdateSourceInfo
+{
+ enum class Type
+ {
+ BUFFER,
+ MEMORY,
+ TEXTURE
+ };
+
+ Type sourceType;
+
+ struct BufferSource
+ {
+ Buffer* buffer;
+ } bufferSource;
+
+ struct MemorySource
+ {
+ void* memory;
+ } memorySource;
+
+ struct TextureSource
+ {
+ Texture* texture;
+ } textureSource;
+};
+
+/**
+ * @brief Properties of texture
+ */
+struct TextureProperties
+{
+ Format format; ///< Texture format
+ Format format1; ///< Texture format (if emulated)
+ bool emulated; ///< Format is emulated (for example RGB as RGBA)
+ bool compressed; ///< Texture is compressed
+ bool packed; ///< Texture is packed
+ Extent2D extent2D; ///< Size of texture
+ bool directWriteAccessEnabled; ///< Direct write access (mappable textures)
+};
+
+/**
+ * @brief Texture tiling that directly refers to the tiling
+ * mode supported by the Vulkan. Other implementations
+ * of the backend may ignore the value.
+ */
+enum class TextureTiling
+{
+ OPTIMAL,
+ LINEAR
+};
+
+/**
+ * @brief Texture color attachment used by FramebufferCreateInfo
+ */
+struct ColorAttachment
+{
+ uint32_t attachmentId;
+ Texture* texture;
+ uint32_t layerId;
+ uint32_t levelId;
+};
+
+/**
+ * @brief Depth stencil attachment used by FramebufferCreateInfo
+ */
+struct DepthStencilAttachment
+{
+ // TODO:
+};
+
+/**
+ * @brief Submit flags
+ */
+using SubmitFlags = uint32_t;
+
+/**
+ * Submit flag bits
+ */
+enum class SubmitFlagBits : uint32_t
+{
+ FLUSH = 1 << 0, // Flush immediately
+ DONT_OPTIMIZE = 1 << 1 // Tells controller not to optimize commands
+};
+
+template<typename T>
+inline SubmitFlags operator|(T flags, SubmitFlagBits bit)
+{
+ return static_cast<SubmitFlags>(flags) | static_cast<SubmitFlags>(bit);
+}
+
+/**
+ * @brief Describes command buffers submission
+ */
+struct SubmitInfo
+{
+ std::vector<CommandBuffer*> cmdBuffer;
+ SubmitFlags flags;
+};
+
+/**
+ * @brief Shader language enum
+ */
+enum class ShaderLanguage
+{
+ GLSL_1,
+ GLSL_3_1,
+ GLSL_3_2,
+ SPIRV_1_0,
+ SPIRV_1_1,
+};
+
+/**
+ * @brief Pipeline stages
+ */
+enum class PipelineStage
+{
+ TOP_OF_PIPELINE,
+ VERTEX_SHADER,
+ GEOMETRY_SHADER,
+ FRAGMENT_SHADER,
+ COMPUTE_SHADER,
+ TESSELATION_CONTROL,
+ TESSELATION_EVALUATION,
+ BOTTOM_OF_PIPELINE
+};
+
+/**
+ * @brief Vertex attribute format
+ *
+ * TODO: to be replaced with Format
+ */
+enum class VertexInputAttributeFormat
+{
+ UNDEFINED,
+ FLOAT,
+ INTEGER,
+ VEC2,
+ VEC3,
+ VEC4
+};
+
+/**
+ * @brief Type of texture
+ */
+enum class TextureType
+{
+ TEXTURE_2D,
+ TEXTURE_3D,
+ TEXTURE_CUBEMAP,
+};
+
+/**
+ * @brief Describes pipeline's shading stages
+ *
+ * Shader state binds shader and pipeline stage that the
+ * shader will be executed. The shader may be created with
+ * pipeline stage and the pipelineStage member may be ignored
+ * by setting inheritPipelineStage to true.
+ */
+struct ShaderState
+{
+ const Shader* shader{nullptr}; // shader to attach
+ PipelineStage pipelineStage{}; // pipeline stage to execute the shader
+ bool inheritPipelineStage{false}; // stage inheritance
+
+ auto& SetShader(const Shader& value)
+ {
+ shader = &value;
+ return *this;
+ }
+
+ auto& SetPipelineStage(PipelineStage value)
+ {
+ pipelineStage = value;
+ return *this;
+ }
+
+ auto& SetInheritPipelineStage(bool value)
+ {
+ inheritPipelineStage = value;
+ return *this;
+ }
+};
+
+/**
+ * @brief Flag determining usage of texture
+ */
+using TextureUsageFlags = uint32_t;
+enum class TextureUsageFlagBits : uint32_t
+{
+ SAMPLE = 1 << 0,
+ COLOR_ATTACHMENT = 1 << 1,
+ DEPTH_STENCIL_ATTACHMENT = 1 << 2,
+ DONT_CARE = 1 << 4,
+};
+
+template<typename T>
+inline TextureUsageFlags operator|(T flags, TextureUsageFlagBits bit)
+{
+ return static_cast<TextureUsageFlags>(flags) | static_cast<TextureUsageFlags>(bit);
+}
+
+using TextureFormat = Dali::Graphics::Format;
+
+/**
+ * @brief Texture mipmap disable/enable enum
+ */
+enum class TextureMipMapFlag
+{
+ ENABLED,
+ DISABLED,
+};
+
+/**
+ * @brief Depth/stencil attachment flag
+ */
+enum class TextureDepthStencilFlag
+{
+ NONE,
+ DEPTH,
+ STENCIL,
+ DEPTH_STENCIL,
+};
+
+/**
+ * @brief Layout of texture
+ *
+ * Specifies how the memory will be allocated, organized and accessed.
+ */
+enum class TextureLayout
+{
+ LINEAR, ///< Creates linear memory, mapping possible
+ OPTIMAL ///< Usually, read-only memory, driver-optimal layout
+};
+
+/**
+ * @brief Level of command buffer
+ */
+enum class CommandBufferLevel
+{
+ PRIMARY, ///< Primary buffer can be executed on its own
+ SECONDARY ///< Secondary buffer must be executed within scope of Primary buffer
+};
+
+/**
+ * @brief Enum indicating whether shader source
+ * is text-based or binary.
+ */
+enum class ShaderSourceMode
+{
+ TEXT,
+ BINARY
+};
+
+/**
+ * @brief Memory usage flags to be set when mapping the buffer
+ */
+using MemoryUsageFlags = uint32_t;
+enum class MemoryUsageFlagBits : uint32_t
+{
+ WRITE = 1 << 0,
+ READ = 1 << 1,
+ PERSISTENT = 1 << 2,
+ ASYNCHRONOUS = 1 << 3,
+ DONT_CARE = 1 << 4,
+};
+
+template<typename T>
+inline MemoryUsageFlags operator|(T flags, MemoryUsageFlagBits bit)
+{
+ return static_cast<MemoryUsageFlags>(flags) | static_cast<MemoryUsageFlags>(bit);
+}
+
+/**
+ * @brief Describes buffer mapping details
+ */
+struct MapBufferInfo
+{
+ Buffer* buffer;
+ MemoryUsageFlags usage;
+ uint32_t offset;
+ uint32_t size;
+};
+
+/**
+ * @brief Describes buffer mapping details
+ * TODO: mapping by texture level and layer
+ */
+struct MapTextureInfo
+{
+ Texture* texture;
+ MemoryUsageFlags usage;
+ uint32_t offset;
+ uint32_t size;
+};
+
+/**
+ * @brief GraphicsStructureType enum is used by all create info structures
+ * in order to identify by the implementation which structure it is
+ * dealing with.
+ */
+enum class GraphicsStructureType : uint32_t
+{
+ BUFFER_CREATE_INFO_STRUCT,
+ COMMAND_BUFFER_CREATE_INFO_STRUCT,
+ FRAMEBUFFER_CREATE_INFO_STRUCT,
+ PIPELINE_CREATE_INFO_STRUCT,
+ RENDERPASS_CREATE_INFO_STRUCT,
+ SAMPLER_CREATE_INFO_STRUCT,
+ SHADER_CREATE_INFO_STRUCT,
+ TEXTURE_CREATE_INFO_STRUCT,
+ RENDER_TARGET_CREATE_INFO_STRUCT
+};
+
+/**
+ * @brief Helper function to be used by the extension developers
+ *
+ * The value of custom type must be unique and recognizable by the
+ * implementation.
+ *
+ * @param customValue Custom value of GraphicsStructureType
+ * @return Integer converted to GraphicsStructureType
+ */
+inline GraphicsStructureType GraphicsExtensionType(uint32_t customValue)
+{
+ return static_cast<GraphicsStructureType>(customValue);
+}
+
+/**
+ * @brief The allocation callbacks may be passed when the object is created.
+ */
+struct AllocationCallbacks
+{
+ void* userData = nullptr; ///< User data passed to the allocator
+ void* (*allocCallback)(size_t size, size_t alignment, void* userData) = nullptr;
+ void* (*reallocCallback)(void* original, size_t size, size_t alignment, void* userData) = nullptr;
+ void (*freeCallback)(void* memory, void* userData) = nullptr;
+};
+
+/**
+ * @brief The ExtensionCreateInfo structure should be a base of any
+ * extension create info structure. The structure isn't virtual
+ * so the implementation must prevent slicing it.
+ */
+struct ExtensionCreateInfo
+{
+ GraphicsStructureType type{};
+ ExtensionCreateInfo* nextExtension{};
+};
+
+} // namespace Graphics
+} // namespace Dali
+
+#endif //DALI_GRAPHICS_API_TYPES_H