1 #ifndef DALI_GRAPHICS_VULKAN_API_RENDER_COMMAND_H
2 #define DALI_GRAPHICS_VULKAN_API_RENDER_COMMAND_H
5 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 #include <dali/graphics-api/graphics-api-render-command.h>
22 #include <dali/graphics-api/graphics-api-shader-details.h>
23 #include <dali/graphics/vulkan/vulkan-types.h>
39 * Render command stores internal command buffer per draw call
43 * - RenderCommand stores all the relevant data
44 * - Changing pipeline determines recreating certain resources
45 * - Currently each RC has own DescriptorSetPool
46 * - Currently each RC has a handle to UBOs
47 * - UBOs are assigned upon pipeline creation/assignment
48 * - Descriptor sets are allocated upon pipeline creation
49 * - Note: need resource "versioning"
51 class RenderCommand : public Graphics::API::RenderCommand
55 constexpr static uint32_t UPDATE_ALL = 0xffffffff;
57 RenderCommand( VulkanAPI::Controller& controller,
58 Vulkan::Graphics& graphics,
59 Vulkan::PipelineCache& pipelineCache );
61 ~RenderCommand() override;
64 * Forces pipeline compilation whenever something changed and
68 bool PreparePipeline();
71 * Updates uniform buffers
73 void UpdateUniformBuffers();
76 * Writes uniform buffers into descriptor set
78 void BindUniformBuffers();
81 * Writes texture/sample combo into descriptor set
83 void BindTexturesAndSamplers();
86 * Returns an array of updated descriptor sets
89 const std::vector<Vulkan::DescriptorSetRef>& GetDescriptorSets() const;
92 * Returns associated Vulkan command buffer
95 const Vulkan::CommandBufferRef& GetCommandBuffer() const;
98 * Returns pipeline cache
101 const Vulkan::PipelineCache& GetPipelineCache() const;
107 const Vulkan::PipelineRef& GetPipeline() const;
113 const vk::PipelineColorBlendStateCreateInfo* PrepareColorBlendStateCreateInfo();
115 const vk::PipelineDepthStencilStateCreateInfo* PrepareDepthStencilStateCreateInfo();
117 const vk::PipelineInputAssemblyStateCreateInfo* PrepareInputAssemblyStateCreateInfo();
119 const vk::PipelineMultisampleStateCreateInfo* PrepareMultisampleStateCreateInfo();
121 const vk::PipelineRasterizationStateCreateInfo* PrepareRasterizationStateCreateInfo();
123 const vk::PipelineTessellationStateCreateInfo* PrepareTesselationStateCreateInfo();
125 const vk::PipelineVertexInputStateCreateInfo* PrepareVertexInputStateCreateInfo();
127 const vk::PipelineViewportStateCreateInfo* PrepareViewportStateCreateInfo();
130 * Allocates UBO memory based on the pipeline. Executed only
133 void AllocateUniformBufferMemory();
138 * Describes assigned UBO buffers
141 struct VulkanPipelineState;
142 std::unique_ptr<VulkanPipelineState> mVulkanPipelineState;
144 VulkanAPI::Controller& mController;
145 Vulkan::Graphics& mGraphics;
146 Vulkan::PipelineCache& mPipelineCache;
147 Vulkan::CommandBufferRef mCommandBuffer;
148 Vulkan::PipelineRef mPipeline;
149 Vulkan::DescriptorPoolRef mDescriptorPool;
151 std::vector<vk::DescriptorSetLayout> mVkDescriptorSetLayouts;
153 std::vector<Vulkan::DescriptorSetRef> mDescriptorSets;
155 std::vector<std::unique_ptr<Ubo>> mUboBuffers;
157 uint32_t mUpdateFlags;
163 #endif //DALI_GRAPHICS_VULKAN_API_RENDER_COMMAND_H