3 /*-------------------------------------------------------------------------
7 * Copyright (c) 2015 Google Inc.
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * \brief Utilities for creating commonly used Vulkan objects
24 *//*--------------------------------------------------------------------*/
28 #include "vkRefUtil.hpp"
32 Move<VkPipeline> makeComputePipeline (const DeviceInterface& vk,
33 const VkDevice device,
34 const VkPipelineLayout pipelineLayout,
35 const VkPipelineCreateFlags pipelineFlags,
36 const VkShaderModule shaderModule,
37 const VkPipelineShaderStageCreateFlags shaderFlags,
38 const VkSpecializationInfo* specializationInfo = DE_NULL,
39 const VkPipelineCache pipelineCache = DE_NULL);
41 Move<VkPipeline> makeComputePipeline (const DeviceInterface& vk,
43 VkPipelineLayout pipelineLayout,
44 VkShaderModule shaderModule);
46 Move<VkPipeline> makeGraphicsPipeline (const DeviceInterface& vk,
47 const VkDevice device,
48 const VkPipelineLayout pipelineLayout,
49 const VkShaderModule vertexShaderModule,
50 const VkShaderModule tessellationControlShaderModule,
51 const VkShaderModule tessellationEvalShaderModule,
52 const VkShaderModule geometryShaderModule,
53 const VkShaderModule fragmentShaderModule,
54 const VkRenderPass renderPass,
55 const std::vector<VkViewport>& viewports,
56 const std::vector<VkRect2D>& scissors,
57 const VkPrimitiveTopology topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
58 const deUint32 subpass = 0u,
59 const deUint32 patchControlPoints = 0u,
60 const VkPipelineVertexInputStateCreateInfo* vertexInputStateCreateInfo = DE_NULL,
61 const VkPipelineRasterizationStateCreateInfo* rasterizationStateCreateInfo = DE_NULL,
62 const VkPipelineMultisampleStateCreateInfo* multisampleStateCreateInfo = DE_NULL,
63 const VkPipelineDepthStencilStateCreateInfo* depthStencilStateCreateInfo = DE_NULL,
64 const VkPipelineColorBlendStateCreateInfo* colorBlendStateCreateInfo = DE_NULL,
65 const VkPipelineDynamicStateCreateInfo* dynamicStateCreateInfo = DE_NULL,
66 const void* pNext = DE_NULL);
68 Move<VkPipeline> makeGraphicsPipeline (const DeviceInterface& vk,
69 const VkDevice device,
70 const VkPipelineLayout pipelineLayout,
71 const VkShaderModule vertexShaderModule,
72 const VkShaderModule tessellationControlShaderModule,
73 const VkShaderModule tessellationEvalShaderModule,
74 const VkShaderModule geometryShaderModule,
75 const VkShaderModule fragmentShaderModule,
76 const VkRenderPass renderPass,
77 const deUint32 subpass = 0u,
78 const VkPipelineVertexInputStateCreateInfo* vertexInputStateCreateInfo = DE_NULL,
79 const VkPipelineInputAssemblyStateCreateInfo* inputAssemblyStateCreateInfo = DE_NULL,
80 const VkPipelineTessellationStateCreateInfo* tessStateCreateInfo = DE_NULL,
81 const VkPipelineViewportStateCreateInfo* viewportStateCreateInfo = DE_NULL,
82 const VkPipelineRasterizationStateCreateInfo* rasterizationStateCreateInfo = DE_NULL,
83 const VkPipelineMultisampleStateCreateInfo* multisampleStateCreateInfo = DE_NULL,
84 const VkPipelineDepthStencilStateCreateInfo* depthStencilStateCreateInfo = DE_NULL,
85 const VkPipelineColorBlendStateCreateInfo* colorBlendStateCreateInfo = DE_NULL,
86 const VkPipelineDynamicStateCreateInfo* dynamicStateCreateInfo = DE_NULL,
87 const void* pNext = DE_NULL);
89 Move<VkPipeline> makeGraphicsPipeline (const DeviceInterface& vk,
90 const VkDevice device,
91 const VkPipelineLayout pipelineLayout,
92 const VkShaderModule taskShaderModule,
93 const VkShaderModule meshShaderModule,
94 const VkShaderModule fragmentShaderModule,
95 const VkRenderPass renderPass,
96 const std::vector<VkViewport>& viewports,
97 const std::vector<VkRect2D>& scissors,
98 const deUint32 subpass = 0u,
99 const VkPipelineRasterizationStateCreateInfo* rasterizationStateCreateInfo = nullptr,
100 const VkPipelineMultisampleStateCreateInfo* multisampleStateCreateInfo = nullptr,
101 const VkPipelineDepthStencilStateCreateInfo* depthStencilStateCreateInfo = nullptr,
102 const VkPipelineColorBlendStateCreateInfo* colorBlendStateCreateInfo = nullptr,
103 const VkPipelineDynamicStateCreateInfo* dynamicStateCreateInfo = nullptr);
105 Move<VkRenderPass> makeRenderPass (const DeviceInterface& vk,
106 const VkDevice device,
107 const VkFormat colorFormat = VK_FORMAT_UNDEFINED,
108 const VkFormat depthStencilFormat = VK_FORMAT_UNDEFINED,
109 const VkAttachmentLoadOp loadOperation = VK_ATTACHMENT_LOAD_OP_CLEAR,
110 const VkImageLayout finalLayoutColor = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
111 const VkImageLayout finalLayoutDepthStencil = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
112 const VkImageLayout subpassLayoutColor = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
113 const VkImageLayout subpassLayoutDepthStencil = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
114 const VkAllocationCallbacks* const allocationCallbacks = DE_NULL);
116 Move<VkImageView> makeImageView (const DeviceInterface& vk,
117 const VkDevice vkDevice,
119 const VkImageViewType imageViewType,
120 const VkFormat format,
121 const VkImageSubresourceRange subresourceRange,
122 const vk::VkImageViewUsageCreateInfo* imageUsageCreateInfo = DE_NULL);
124 Move<VkBufferView> makeBufferView (const DeviceInterface& vk,
125 const VkDevice vkDevice,
126 const VkBuffer buffer,
127 const VkFormat format,
128 const VkDeviceSize offset,
129 const VkDeviceSize size);
131 Move<VkDescriptorSet> makeDescriptorSet (const DeviceInterface& vk,
132 const VkDevice device,
133 const VkDescriptorPool descriptorPool,
134 const VkDescriptorSetLayout setLayout,
135 const void* pNext = DE_NULL);
137 VkBufferCreateInfo makeBufferCreateInfo (const VkDeviceSize size,
138 const VkBufferUsageFlags usage);
140 VkBufferCreateInfo makeBufferCreateInfo (const VkDeviceSize size,
141 const VkBufferUsageFlags usage,
142 const std::vector<deUint32>& queueFamilyIndices);
144 Move<VkPipelineLayout> makePipelineLayout (const DeviceInterface& vk,
145 const VkDevice device,
146 const VkDescriptorSetLayout descriptorSetLayout = DE_NULL);
148 Move<VkPipelineLayout> makePipelineLayout (const DeviceInterface& vk,
149 const VkDevice device,
150 const std::vector<vk::Move<VkDescriptorSetLayout>> &descriptorSetLayouts);
152 Move<VkPipelineLayout> makePipelineLayout (const DeviceInterface& vk,
153 const VkDevice device,
154 const deUint32 setLayoutCount,
155 const VkDescriptorSetLayout* descriptorSetLayout);
157 Move<VkPipelineLayout> makePipelineLayout (const DeviceInterface& vk,
158 const VkDevice device,
159 const deUint32 setLayoutCount,
160 const VkDescriptorSetLayout* descriptorSetLayout,
161 const deUint32 pushConstantRangeCount,
162 const VkPushConstantRange* pPushConstantRanges);
164 Move<VkFramebuffer> makeFramebuffer (const DeviceInterface& vk,
165 const VkDevice device,
166 const VkRenderPass renderPass,
167 const VkImageView colorAttachment,
168 const deUint32 width,
169 const deUint32 height,
170 const deUint32 layers = 1u);
172 Move<VkFramebuffer> makeFramebuffer (const DeviceInterface& vk,
173 const VkDevice device,
174 const VkRenderPass renderPass,
175 const deUint32 attachmentCount,
176 const VkImageView* attachmentsArray,
177 const deUint32 width,
178 const deUint32 height,
179 const deUint32 layers = 1u);
181 Move<VkCommandPool> makeCommandPool (const DeviceInterface& vk,
182 const VkDevice device,
183 const deUint32 queueFamilyIndex);
185 inline Move<VkBuffer> makeBuffer (const DeviceInterface& vk,
186 const VkDevice device,
187 const VkDeviceSize bufferSize,
188 const VkBufferUsageFlags usage)
190 const VkBufferCreateInfo bufferCreateInfo = makeBufferCreateInfo(bufferSize, usage);
191 return createBuffer(vk, device, &bufferCreateInfo);
194 inline Move<VkBuffer> makeBuffer (const vk::DeviceInterface& vk,
195 const vk::VkDevice device,
196 const vk::VkBufferCreateInfo& createInfo)
198 return createBuffer(vk, device, &createInfo);
201 inline Move<VkImage> makeImage (const DeviceInterface& vk,
202 const VkDevice device,
203 const VkImageCreateInfo& createInfo)
205 return createImage(vk, device, &createInfo);
208 VkBufferImageCopy makeBufferImageCopy (const VkExtent3D extent,
209 const VkImageSubresourceLayers subresourceLayers);
213 #endif // _VKOBJUTIL_HPP