1 #ifndef _VKTDYNAMICSTATECREATEINFOUTIL_HPP
2 #define _VKTDYNAMICSTATECREATEINFOUTIL_HPP
3 /*------------------------------------------------------------------------
4 * Vulkan Conformance Tests
5 * ------------------------
7 * Copyright (c) 2015 The Khronos Group Inc.
8 * Copyright (c) 2015 Intel Corporation
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 * \brief CreateInfo utilities
25 *//*--------------------------------------------------------------------*/
28 #include "tcuVector.hpp"
30 #include "deSharedPtr.hpp"
36 namespace DynamicState
39 class ImageSubresourceRange : public vk::VkImageSubresourceRange
42 ImageSubresourceRange (vk::VkImageAspectFlags aspectMask,
43 deUint32 baseMipLevel = 0,
44 deUint32 levelCount = 1,
45 deUint32 baseArrayLayer = 0,
46 deUint32 layerCount = 1);
49 class ComponentMapping : public vk::VkComponentMapping
52 ComponentMapping (vk::VkComponentSwizzle r = vk::VK_COMPONENT_SWIZZLE_R,
53 vk::VkComponentSwizzle g = vk::VK_COMPONENT_SWIZZLE_G,
54 vk::VkComponentSwizzle b = vk::VK_COMPONENT_SWIZZLE_B,
55 vk::VkComponentSwizzle a = vk::VK_COMPONENT_SWIZZLE_A);
58 class ImageViewCreateInfo : public vk::VkImageViewCreateInfo
61 ImageViewCreateInfo (vk::VkImage image,
62 vk::VkImageViewType viewType,
64 const vk::VkImageSubresourceRange& subresourceRange,
65 const vk::VkComponentMapping& components = ComponentMapping(),
66 vk::VkImageViewCreateFlags flags = 0);
68 ImageViewCreateInfo (vk::VkImage image,
69 vk::VkImageViewType viewType,
71 const vk::VkComponentMapping& components = ComponentMapping(),
72 vk::VkImageViewCreateFlags flags = 0);
75 class BufferViewCreateInfo : public vk::VkBufferViewCreateInfo
78 BufferViewCreateInfo (vk::VkBuffer buffer,
80 vk::VkDeviceSize offset,
81 vk::VkDeviceSize range);
84 class BufferCreateInfo : public vk::VkBufferCreateInfo
87 BufferCreateInfo (vk::VkDeviceSize size,
88 vk::VkBufferCreateFlags usage,
89 vk::VkSharingMode sharingMode = vk::VK_SHARING_MODE_EXCLUSIVE,
90 deUint32 queueFamilyIndexCount = 0,
91 const deUint32* pQueueFamilyIndices = DE_NULL,
92 vk::VkBufferCreateFlags flags = 0);
94 BufferCreateInfo (const BufferCreateInfo& other);
95 BufferCreateInfo& operator= (const BufferCreateInfo& other);
98 std::vector<deUint32> m_queueFamilyIndices;
101 class ImageCreateInfo : public vk::VkImageCreateInfo
104 ImageCreateInfo (vk::VkImageType imageType,
106 vk::VkExtent3D extent,
108 deUint32 arrayLayers,
109 vk::VkSampleCountFlagBits samples,
110 vk::VkImageTiling tiling,
111 vk::VkImageUsageFlags usage,
112 vk::VkSharingMode sharingMode = vk::VK_SHARING_MODE_EXCLUSIVE,
113 deUint32 queueFamilyIndexCount = 0,
114 const deUint32* pQueueFamilyIndices = DE_NULL,
115 vk::VkImageCreateFlags flags = 0,
116 vk::VkImageLayout initialLayout = vk::VK_IMAGE_LAYOUT_UNDEFINED);
119 ImageCreateInfo (const ImageCreateInfo& other);
120 ImageCreateInfo& operator= (const ImageCreateInfo& other);
122 std::vector<deUint32> m_queueFamilyIndices;
125 class FramebufferCreateInfo : public vk::VkFramebufferCreateInfo
128 FramebufferCreateInfo (vk::VkRenderPass renderPass,
129 const std::vector<vk::VkImageView>& attachments,
135 class AttachmentDescription : public vk::VkAttachmentDescription
138 AttachmentDescription (vk::VkFormat format,
139 vk::VkSampleCountFlagBits samples,
140 vk::VkAttachmentLoadOp loadOp,
141 vk::VkAttachmentStoreOp storeOp,
142 vk::VkAttachmentLoadOp stencilLoadOp,
143 vk::VkAttachmentStoreOp stencilStoreOp,
144 vk::VkImageLayout initialLayout,
145 vk::VkImageLayout finalLayout);
147 AttachmentDescription (const vk::VkAttachmentDescription &);
150 class AttachmentReference : public vk::VkAttachmentReference
153 AttachmentReference (deUint32 attachment, vk::VkImageLayout layout);
154 AttachmentReference (void);
157 class SubpassDescription : public vk::VkSubpassDescription
160 SubpassDescription (vk::VkPipelineBindPoint pipelineBindPoint,
161 vk::VkSubpassDescriptionFlags flags,
162 deUint32 inputAttachmentCount,
163 const vk::VkAttachmentReference* inputAttachments,
164 deUint32 colorAttachmentCount,
165 const vk::VkAttachmentReference* colorAttachments,
166 const vk::VkAttachmentReference* resolveAttachments,
167 vk::VkAttachmentReference depthStencilAttachment,
168 deUint32 preserveAttachmentCount,
169 const deUint32* preserveAttachments);
171 SubpassDescription (const vk::VkSubpassDescription& other);
172 SubpassDescription (const SubpassDescription& other);
173 SubpassDescription& operator= (const SubpassDescription& other);
176 std::vector<vk::VkAttachmentReference> m_inputAttachments;
177 std::vector<vk::VkAttachmentReference> m_colorAttachments;
178 std::vector<vk::VkAttachmentReference> m_resolveAttachments;
179 std::vector<deUint32> m_preserveAttachments;
181 vk::VkAttachmentReference m_depthStencilAttachment;
184 class SubpassDependency : public vk::VkSubpassDependency
187 SubpassDependency ( deUint32 srcSubpass,
189 vk::VkPipelineStageFlags srcStageMask,
190 vk::VkPipelineStageFlags dstStageMask,
191 vk::VkAccessFlags srcAccessMask,
192 vk::VkAccessFlags dstAccessMask,
193 vk::VkDependencyFlags dependencyFlags);
195 SubpassDependency (const vk::VkSubpassDependency& other);
198 class RenderPassCreateInfo : public vk::VkRenderPassCreateInfo
201 RenderPassCreateInfo (const std::vector<vk::VkAttachmentDescription>& attachments,
202 const std::vector<vk::VkSubpassDescription>& subpasses,
203 const std::vector<vk::VkSubpassDependency>& dependiences = std::vector<vk::VkSubpassDependency>());
205 RenderPassCreateInfo (deUint32 attachmentCount = 0,
206 const vk::VkAttachmentDescription* pAttachments = DE_NULL,
207 deUint32 subpassCount = 0,
208 const vk::VkSubpassDescription* pSubpasses = DE_NULL,
209 deUint32 dependencyCount = 0,
210 const vk::VkSubpassDependency* pDependiences = DE_NULL);
212 void addAttachment (vk::VkAttachmentDescription attachment);
213 void addSubpass (vk::VkSubpassDescription subpass);
214 void addDependency (vk::VkSubpassDependency dependency);
217 std::vector<AttachmentDescription> m_attachments;
218 std::vector<SubpassDescription> m_subpasses;
219 std::vector<SubpassDependency> m_dependiences;
221 std::vector<vk::VkAttachmentDescription> m_attachmentsStructs;
222 std::vector<vk::VkSubpassDescription> m_subpassesStructs;
223 std::vector<vk::VkSubpassDependency> m_dependiencesStructs;
225 RenderPassCreateInfo (const RenderPassCreateInfo &other); //Not allowed!
226 RenderPassCreateInfo& operator= (const RenderPassCreateInfo &other); //Not allowed!
229 class RenderPassBeginInfo : public vk::VkRenderPassBeginInfo
232 RenderPassBeginInfo (vk::VkRenderPass renderPass,
233 vk::VkFramebuffer framebuffer,
234 vk::VkRect2D renderArea,
235 const std::vector<vk::VkClearValue>& clearValues = std::vector<vk::VkClearValue>());
238 std::vector<vk::VkClearValue> m_clearValues;
240 RenderPassBeginInfo (const RenderPassBeginInfo& other); //Not allowed!
241 RenderPassBeginInfo& operator= (const RenderPassBeginInfo& other); //Not allowed!
244 class CmdPoolCreateInfo : public vk::VkCommandPoolCreateInfo
247 CmdPoolCreateInfo (deUint32 queueFamilyIndex,
248 vk::VkCommandPoolCreateFlags flags = vk::VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
251 class CmdBufferBeginInfo : public vk::VkCommandBufferBeginInfo
254 CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags flags = 0);
257 class DescriptorPoolSize : public vk::VkDescriptorPoolSize
260 DescriptorPoolSize (vk::VkDescriptorType _type, deUint32 _descriptorCount)
263 descriptorCount = _descriptorCount;
267 class DescriptorPoolCreateInfo : public vk::VkDescriptorPoolCreateInfo
270 DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
271 vk::VkDescriptorPoolCreateFlags flags,
274 DescriptorPoolCreateInfo& addDescriptors (vk::VkDescriptorType type, deUint32 count);
277 std::vector<vk::VkDescriptorPoolSize> m_poolSizeCounts;
280 class DescriptorSetLayoutCreateInfo : public vk::VkDescriptorSetLayoutCreateInfo
283 DescriptorSetLayoutCreateInfo (deUint32 bindingCount, const vk::VkDescriptorSetLayoutBinding* pBindings);
286 class PipelineLayoutCreateInfo : public vk::VkPipelineLayoutCreateInfo
289 PipelineLayoutCreateInfo (deUint32 descriptorSetCount,
290 const vk::VkDescriptorSetLayout* pSetLayouts,
291 deUint32 pushConstantRangeCount = 0,
292 const vk::VkPushConstantRange* pPushConstantRanges = DE_NULL);
294 PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>& setLayouts = std::vector<vk::VkDescriptorSetLayout>(),
295 deUint32 pushConstantRangeCount = 0,
296 const vk::VkPushConstantRange* pPushConstantRanges = DE_NULL);
299 std::vector<vk::VkDescriptorSetLayout> m_setLayouts;
300 std::vector<vk::VkPushConstantRange> m_pushConstantRanges;
303 class PipelineCreateInfo : public vk::VkGraphicsPipelineCreateInfo
306 class VertexInputState : public vk::VkPipelineVertexInputStateCreateInfo
309 VertexInputState (deUint32 vertexBindingDescriptionCount = 0,
310 const vk::VkVertexInputBindingDescription* pVertexBindingDescriptions = NULL,
311 deUint32 vertexAttributeDescriptionCount = 0,
312 const vk::VkVertexInputAttributeDescription* pVertexAttributeDescriptions = NULL);
315 class InputAssemblerState : public vk::VkPipelineInputAssemblyStateCreateInfo
318 InputAssemblerState (vk::VkPrimitiveTopology topology, vk::VkBool32 primitiveRestartEnable = false);
321 class TessellationState : public vk::VkPipelineTessellationStateCreateInfo
324 TessellationState (deUint32 patchControlPoints = 0);
327 class ViewportState : public vk::VkPipelineViewportStateCreateInfo
330 ViewportState (deUint32 viewportCount,
331 std::vector<vk::VkViewport> viewports = std::vector<vk::VkViewport>(0),
332 std::vector<vk::VkRect2D> scissors = std::vector<vk::VkRect2D>(0));
334 ViewportState (const ViewportState& other);
335 ViewportState& operator= (const ViewportState& other);
337 std::vector<vk::VkViewport> m_viewports;
338 std::vector<vk::VkRect2D> m_scissors;
341 class RasterizerState : public vk::VkPipelineRasterizationStateCreateInfo
344 RasterizerState (vk::VkBool32 depthClampEnable = false,
345 vk::VkBool32 rasterizerDiscardEnable = false,
346 vk::VkPolygonMode polygonMode = vk::VK_POLYGON_MODE_FILL,
347 vk::VkCullModeFlags cullMode = vk::VK_CULL_MODE_NONE,
348 vk::VkFrontFace frontFace = vk::VK_FRONT_FACE_CLOCKWISE,
349 vk::VkBool32 depthBiasEnable = true,
350 float depthBiasConstantFactor = 0.0f,
351 float depthBiasClamp = 0.0f,
352 float depthBiasSlopeFactor = 0.0f,
353 float lineWidth = 1.0f);
356 class MultiSampleState : public vk::VkPipelineMultisampleStateCreateInfo
359 MultiSampleState (vk::VkSampleCountFlagBits rasterizationSamples = vk::VK_SAMPLE_COUNT_1_BIT,
360 vk::VkBool32 sampleShadingEnable = false,
361 float minSampleShading = 0.0f,
362 const std::vector<vk::VkSampleMask>& sampleMask = std::vector<vk::VkSampleMask>(1, 0xffffffff),
363 bool alphaToCoverageEnable = false,
364 bool alphaToOneEnable = false);
366 MultiSampleState (const MultiSampleState& other);
367 MultiSampleState& operator= (const MultiSampleState& other);
370 std::vector<vk::VkSampleMask> m_sampleMask;
373 class ColorBlendState : public vk::VkPipelineColorBlendStateCreateInfo
376 class Attachment : public vk::VkPipelineColorBlendAttachmentState
379 Attachment (vk::VkBool32 blendEnable = false,
380 vk::VkBlendFactor srcColorBlendFactor = vk::VK_BLEND_FACTOR_SRC_COLOR,
381 vk::VkBlendFactor dstColorBlendFactor = vk::VK_BLEND_FACTOR_DST_COLOR,
382 vk::VkBlendOp colorBlendOp = vk::VK_BLEND_OP_ADD,
383 vk::VkBlendFactor srcAlphaBlendFactor = vk::VK_BLEND_FACTOR_SRC_COLOR,
384 vk::VkBlendFactor dstAlphaBlendFactor = vk::VK_BLEND_FACTOR_DST_COLOR,
385 vk::VkBlendOp alphaBlendOp = vk::VK_BLEND_OP_ADD,
386 deUint8 colorWriteMask = 0xff);
389 ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>& attachments,
390 vk::VkBool32 alphaToCoverageEnable = false,
391 vk::VkLogicOp logicOp = vk::VK_LOGIC_OP_COPY);
393 ColorBlendState (deUint32 attachmentCount,
394 const vk::VkPipelineColorBlendAttachmentState* attachments,
395 vk::VkBool32 logicOpEnable = false,
396 vk::VkLogicOp logicOp = vk::VK_LOGIC_OP_COPY);
398 ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo);
399 ColorBlendState (const ColorBlendState& createInfo,
400 std::vector<float> blendConstants = std::vector<float>(4));
403 std::vector<vk::VkPipelineColorBlendAttachmentState> m_attachments;
406 class DepthStencilState : public vk::VkPipelineDepthStencilStateCreateInfo
409 class StencilOpState : public vk::VkStencilOpState
412 StencilOpState (vk::VkStencilOp failOp = vk::VK_STENCIL_OP_REPLACE,
413 vk::VkStencilOp passOp = vk::VK_STENCIL_OP_REPLACE,
414 vk::VkStencilOp depthFailOp = vk::VK_STENCIL_OP_REPLACE,
415 vk::VkCompareOp compareOp = vk::VK_COMPARE_OP_ALWAYS,
416 deUint32 compareMask = 0xffffffffu,
417 deUint32 writeMask = 0xffffffffu,
418 deUint32 reference = 0);
421 DepthStencilState (vk::VkBool32 depthTestEnable = false,
422 vk::VkBool32 depthWriteEnable = false,
423 vk::VkCompareOp depthCompareOp = vk::VK_COMPARE_OP_ALWAYS,
424 vk::VkBool32 depthBoundsTestEnable = false,
425 vk::VkBool32 stencilTestEnable = false,
426 StencilOpState front = StencilOpState(),
427 StencilOpState back = StencilOpState(),
428 float minDepthBounds = -1.0f,
429 float maxDepthBounds = 1.0f);
432 class PipelineShaderStage : public vk::VkPipelineShaderStageCreateInfo
435 PipelineShaderStage (vk::VkShaderModule shaderModule, const char* pName, vk::VkShaderStageFlagBits stage);
438 class DynamicState : public vk::VkPipelineDynamicStateCreateInfo
441 DynamicState (const std::vector<vk::VkDynamicState>& dynamicStates = std::vector<vk::VkDynamicState>(0));
443 DynamicState (const DynamicState& other);
444 DynamicState& operator= (const DynamicState& other);
446 std::vector<vk::VkDynamicState> m_dynamicStates;
449 PipelineCreateInfo (vk::VkPipelineLayout layout,
450 vk::VkRenderPass renderPass,
452 vk::VkPipelineCreateFlags flags);
454 PipelineCreateInfo& addShader (const vk::VkPipelineShaderStageCreateInfo& shader);
456 PipelineCreateInfo& addState (const vk::VkPipelineVertexInputStateCreateInfo& state);
457 PipelineCreateInfo& addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state);
458 PipelineCreateInfo& addState (const vk::VkPipelineColorBlendStateCreateInfo& state);
459 PipelineCreateInfo& addState (const vk::VkPipelineViewportStateCreateInfo& state);
460 PipelineCreateInfo& addState (const vk::VkPipelineDepthStencilStateCreateInfo& state);
461 PipelineCreateInfo& addState (const vk::VkPipelineTessellationStateCreateInfo& state);
462 PipelineCreateInfo& addState (const vk::VkPipelineRasterizationStateCreateInfo& state);
463 PipelineCreateInfo& addState (const vk::VkPipelineMultisampleStateCreateInfo& state);
464 PipelineCreateInfo& addState (const vk::VkPipelineDynamicStateCreateInfo& state);
467 std::vector<vk::VkPipelineShaderStageCreateInfo> m_shaders;
469 vk::VkPipelineVertexInputStateCreateInfo m_vertexInputState;
470 vk::VkPipelineInputAssemblyStateCreateInfo m_inputAssemblyState;
471 std::vector<vk::VkPipelineColorBlendAttachmentState> m_colorBlendStateAttachments;
472 vk::VkPipelineColorBlendStateCreateInfo m_colorBlendState;
473 vk::VkPipelineViewportStateCreateInfo m_viewportState;
474 vk::VkPipelineDepthStencilStateCreateInfo m_dynamicDepthStencilState;
475 vk::VkPipelineTessellationStateCreateInfo m_tessState;
476 vk::VkPipelineRasterizationStateCreateInfo m_rasterState;
477 vk::VkPipelineMultisampleStateCreateInfo m_multisampleState;
478 vk::VkPipelineDynamicStateCreateInfo m_dynamicState;
480 std::vector<vk::VkDynamicState> m_dynamicStates;
482 std::vector<vk::VkViewport> m_viewports;
483 std::vector<vk::VkRect2D> m_scissors;
485 std::vector<vk::VkSampleMask> m_multisampleStateSampleMask;
488 class SamplerCreateInfo : public vk::VkSamplerCreateInfo
491 SamplerCreateInfo (vk::VkFilter magFilter = vk::VK_FILTER_NEAREST,
492 vk::VkFilter minFilter = vk::VK_FILTER_NEAREST,
493 vk::VkSamplerMipmapMode mipmapMode = vk::VK_SAMPLER_MIPMAP_MODE_NEAREST,
494 vk::VkSamplerAddressMode addressU = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
495 vk::VkSamplerAddressMode addressV = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
496 vk::VkSamplerAddressMode addressW = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
497 float mipLodBias = 0.0f,
498 vk::VkBool32 anisotropyEnable = VK_FALSE,
499 float maxAnisotropy = 1.0f,
500 vk::VkBool32 compareEnable = false,
501 vk::VkCompareOp compareOp = vk::VK_COMPARE_OP_ALWAYS,
503 float maxLod = 16.0f,
504 vk::VkBorderColor borderColor = vk::VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE,
505 vk::VkBool32 unnormalizedCoordinates = false);
511 #endif // _VKTDYNAMICSTATECREATEINFOUTIL_HPP