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>
40 * Render command stores internal command buffer per draw call
44 * - RenderCommand stores all the relevant data
45 * - Changing pipeline determines recreating certain resources
46 * - Currently each RC has own DescriptorSetPool
47 * - Currently each RC has a handle to UBOs
48 * - UBOs are assigned upon pipeline creation/assignment
49 * - Descriptor sets are allocated upon pipeline creation
50 * - Note: need resource "versioning"
52 class RenderCommand : public Graphics::API::RenderCommand
56 constexpr static uint32_t UPDATE_ALL = 0xffffffff;
58 RenderCommand( VulkanAPI::Controller& controller,
59 Vulkan::Graphics& graphics,
60 Vulkan::PipelineCache& pipelineCache );
62 ~RenderCommand() override;
65 * Forces pipeline compilation whenever something changed and
69 bool PreparePipeline();
72 * Updates uniform buffers
74 void UpdateUniformBuffers();
77 * Writes uniform buffers into descriptor set
79 void BindUniformBuffers();
82 * Writes texture/sample combo into descriptor set
84 void BindTexturesAndSamplers();
87 * Returns an array of updated descriptor sets
90 const std::vector<Vulkan::DescriptorSetRef>& GetDescriptorSets() const;
93 * Returns associated Vulkan command buffer
96 const Vulkan::CommandBufferRef& GetCommandBuffer() const;
99 * Returns pipeline cache
102 const Vulkan::PipelineCache& GetPipelineCache() const;
108 const Vulkan::PipelineRef& GetPipeline() const;
114 const vk::PipelineColorBlendStateCreateInfo* PrepareColorBlendStateCreateInfo();
116 const vk::PipelineDepthStencilStateCreateInfo* PrepareDepthStencilStateCreateInfo();
118 const vk::PipelineInputAssemblyStateCreateInfo* PrepareInputAssemblyStateCreateInfo();
120 const vk::PipelineMultisampleStateCreateInfo* PrepareMultisampleStateCreateInfo();
122 const vk::PipelineRasterizationStateCreateInfo* PrepareRasterizationStateCreateInfo();
124 const vk::PipelineTessellationStateCreateInfo* PrepareTesselationStateCreateInfo();
126 const vk::PipelineVertexInputStateCreateInfo* PrepareVertexInputStateCreateInfo();
128 const vk::PipelineViewportStateCreateInfo* PrepareViewportStateCreateInfo();
131 * Allocates UBO memory based on the pipeline. Executed only
134 void AllocateUniformBufferMemory();
139 * Describes assigned UBO buffers
142 struct VulkanPipelineState;
143 std::unique_ptr<VulkanPipelineState> mVulkanPipelineState;
145 VulkanAPI::Controller& mController;
146 Vulkan::Graphics& mGraphics;
147 Vulkan::PipelineCache& mPipelineCache;
148 Vulkan::CommandBufferRef mCommandBuffer;
149 Vulkan::PipelineRef mPipeline;
150 Vulkan::DescriptorPoolRef mDescriptorPool;
152 std::vector<vk::DescriptorSetLayout> mVkDescriptorSetLayouts;
154 std::vector<Vulkan::DescriptorSetRef> mDescriptorSets;
156 std::vector<std::unique_ptr<Ubo>> mUboBuffers;
158 uint32_t mUpdateFlags;
164 #endif //DALI_GRAPHICS_VULKAN_API_RENDER_COMMAND_H