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 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and/or associated documentation files (the
12 * "Materials"), to deal in the Materials without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, sublicense, and/or sell copies of the Materials, and to
15 * permit persons to whom the Materials are furnished to do so, subject to
16 * the following conditions:
18 * The above copyright notice(s) and this permission notice shall be included
19 * in all copies or substantial portions of the Materials.
21 * The Materials are Confidential Information as defined by the
22 * Khronos Membership Agreement until designated non-confidential by Khronos,
23 * at which point this condition clause shall be removed.
25 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
28 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
29 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
30 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
31 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
35 * \brief CreateInfo utilities
36 *//*--------------------------------------------------------------------*/
39 #include "tcuVector.hpp"
41 #include "deSharedPtr.hpp"
47 namespace DynamicState
50 class ImageSubresourceRange : public vk::VkImageSubresourceRange
53 ImageSubresourceRange (vk::VkImageAspectFlags aspectMask,
54 deUint32 baseMipLevel = 0,
55 deUint32 levelCount = 1,
56 deUint32 baseArrayLayer = 0,
57 deUint32 layerCount = 1);
60 class ComponentMapping : public vk::VkComponentMapping
63 ComponentMapping (vk::VkComponentSwizzle r = vk::VK_COMPONENT_SWIZZLE_R,
64 vk::VkComponentSwizzle g = vk::VK_COMPONENT_SWIZZLE_G,
65 vk::VkComponentSwizzle b = vk::VK_COMPONENT_SWIZZLE_B,
66 vk::VkComponentSwizzle a = vk::VK_COMPONENT_SWIZZLE_A);
69 class ImageViewCreateInfo : public vk::VkImageViewCreateInfo
72 ImageViewCreateInfo (vk::VkImage image,
73 vk::VkImageViewType viewType,
75 const vk::VkImageSubresourceRange& subresourceRange,
76 const vk::VkComponentMapping& components = ComponentMapping(),
77 vk::VkImageViewCreateFlags flags = 0);
79 ImageViewCreateInfo (vk::VkImage image,
80 vk::VkImageViewType viewType,
82 const vk::VkComponentMapping& components = ComponentMapping(),
83 vk::VkImageViewCreateFlags flags = 0);
86 class BufferViewCreateInfo : public vk::VkBufferViewCreateInfo
89 BufferViewCreateInfo (vk::VkBuffer buffer,
91 vk::VkDeviceSize offset,
92 vk::VkDeviceSize range);
95 class BufferCreateInfo : public vk::VkBufferCreateInfo
98 BufferCreateInfo (vk::VkDeviceSize size,
99 vk::VkBufferCreateFlags usage,
100 vk::VkSharingMode sharingMode = vk::VK_SHARING_MODE_EXCLUSIVE,
101 deUint32 queueFamilyIndexCount = 0,
102 const deUint32* pQueueFamilyIndices = DE_NULL,
103 vk::VkBufferCreateFlags flags = 0);
105 BufferCreateInfo (const BufferCreateInfo& other);
106 BufferCreateInfo& operator= (const BufferCreateInfo& other);
109 std::vector<deUint32> m_queueFamilyIndices;
112 class ImageCreateInfo : public vk::VkImageCreateInfo
115 ImageCreateInfo (vk::VkImageType imageType,
117 vk::VkExtent3D extent,
119 deUint32 arrayLayers,
120 vk::VkSampleCountFlagBits samples,
121 vk::VkImageTiling tiling,
122 vk::VkImageUsageFlags usage,
123 vk::VkSharingMode sharingMode = vk::VK_SHARING_MODE_EXCLUSIVE,
124 deUint32 queueFamilyIndexCount = 0,
125 const deUint32* pQueueFamilyIndices = DE_NULL,
126 vk::VkImageCreateFlags flags = 0,
127 vk::VkImageLayout initialLayout = vk::VK_IMAGE_LAYOUT_UNDEFINED);
130 ImageCreateInfo (const ImageCreateInfo& other);
131 ImageCreateInfo& operator= (const ImageCreateInfo& other);
133 std::vector<deUint32> m_queueFamilyIndices;
136 class FramebufferCreateInfo : public vk::VkFramebufferCreateInfo
139 FramebufferCreateInfo (vk::VkRenderPass renderPass,
140 const std::vector<vk::VkImageView>& attachments,
146 class AttachmentDescription : public vk::VkAttachmentDescription
149 AttachmentDescription (vk::VkFormat format,
150 vk::VkSampleCountFlagBits samples,
151 vk::VkAttachmentLoadOp loadOp,
152 vk::VkAttachmentStoreOp storeOp,
153 vk::VkAttachmentLoadOp stencilLoadOp,
154 vk::VkAttachmentStoreOp stencilStoreOp,
155 vk::VkImageLayout initialLayout,
156 vk::VkImageLayout finalLayout);
158 AttachmentDescription (const vk::VkAttachmentDescription &);
161 class AttachmentReference : public vk::VkAttachmentReference
164 AttachmentReference (deUint32 attachment, vk::VkImageLayout layout);
165 AttachmentReference (void);
168 class SubpassDescription : public vk::VkSubpassDescription
171 SubpassDescription (vk::VkPipelineBindPoint pipelineBindPoint,
172 vk::VkSubpassDescriptionFlags flags,
173 deUint32 inputAttachmentCount,
174 const vk::VkAttachmentReference* inputAttachments,
175 deUint32 colorAttachmentCount,
176 const vk::VkAttachmentReference* colorAttachments,
177 const vk::VkAttachmentReference* resolveAttachments,
178 vk::VkAttachmentReference depthStencilAttachment,
179 deUint32 preserveAttachmentCount,
180 const deUint32* preserveAttachments);
182 SubpassDescription (const vk::VkSubpassDescription& other);
183 SubpassDescription (const SubpassDescription& other);
184 SubpassDescription& operator= (const SubpassDescription& other);
187 std::vector<vk::VkAttachmentReference> m_inputAttachments;
188 std::vector<vk::VkAttachmentReference> m_colorAttachments;
189 std::vector<vk::VkAttachmentReference> m_resolveAttachments;
190 std::vector<deUint32> m_preserveAttachments;
192 vk::VkAttachmentReference m_depthStencilAttachment;
195 class SubpassDependency : public vk::VkSubpassDependency
198 SubpassDependency ( deUint32 srcSubpass,
200 vk::VkPipelineStageFlags srcStageMask,
201 vk::VkPipelineStageFlags dstStageMask,
202 vk::VkAccessFlags srcAccessMask,
203 vk::VkAccessFlags dstAccessMask,
204 vk::VkDependencyFlags dependencyFlags);
206 SubpassDependency (const vk::VkSubpassDependency& other);
209 class RenderPassCreateInfo : public vk::VkRenderPassCreateInfo
212 RenderPassCreateInfo (const std::vector<vk::VkAttachmentDescription>& attachments,
213 const std::vector<vk::VkSubpassDescription>& subpasses,
214 const std::vector<vk::VkSubpassDependency>& dependiences = std::vector<vk::VkSubpassDependency>());
216 RenderPassCreateInfo (deUint32 attachmentCount = 0,
217 const vk::VkAttachmentDescription* pAttachments = DE_NULL,
218 deUint32 subpassCount = 0,
219 const vk::VkSubpassDescription* pSubpasses = DE_NULL,
220 deUint32 dependencyCount = 0,
221 const vk::VkSubpassDependency* pDependiences = DE_NULL);
223 void addAttachment (vk::VkAttachmentDescription attachment);
224 void addSubpass (vk::VkSubpassDescription subpass);
225 void addDependency (vk::VkSubpassDependency dependency);
228 std::vector<AttachmentDescription> m_attachments;
229 std::vector<SubpassDescription> m_subpasses;
230 std::vector<SubpassDependency> m_dependiences;
232 std::vector<vk::VkAttachmentDescription> m_attachmentsStructs;
233 std::vector<vk::VkSubpassDescription> m_subpassesStructs;
234 std::vector<vk::VkSubpassDependency> m_dependiencesStructs;
236 RenderPassCreateInfo (const RenderPassCreateInfo &other); //Not allowed!
237 RenderPassCreateInfo& operator= (const RenderPassCreateInfo &other); //Not allowed!
240 class RenderPassBeginInfo : public vk::VkRenderPassBeginInfo
243 RenderPassBeginInfo (vk::VkRenderPass renderPass,
244 vk::VkFramebuffer framebuffer,
245 vk::VkRect2D renderArea,
246 const std::vector<vk::VkClearValue>& clearValues = std::vector<vk::VkClearValue>());
249 std::vector<vk::VkClearValue> m_clearValues;
251 RenderPassBeginInfo (const RenderPassBeginInfo& other); //Not allowed!
252 RenderPassBeginInfo& operator= (const RenderPassBeginInfo& other); //Not allowed!
255 class CmdPoolCreateInfo : public vk::VkCommandPoolCreateInfo
258 CmdPoolCreateInfo (deUint32 queueFamilyIndex,
259 vk::VkCommandPoolCreateFlags flags = vk::VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
262 class CmdBufferBeginInfo : public vk::VkCommandBufferBeginInfo
265 CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags flags = 0);
268 class DescriptorPoolSize : public vk::VkDescriptorPoolSize
271 DescriptorPoolSize (vk::VkDescriptorType _type, deUint32 _descriptorCount)
274 descriptorCount = _descriptorCount;
278 class DescriptorPoolCreateInfo : public vk::VkDescriptorPoolCreateInfo
281 DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
282 vk::VkDescriptorPoolCreateFlags flags,
285 DescriptorPoolCreateInfo& addDescriptors (vk::VkDescriptorType type, deUint32 count);
288 std::vector<vk::VkDescriptorPoolSize> m_poolSizeCounts;
291 class DescriptorSetLayoutCreateInfo : public vk::VkDescriptorSetLayoutCreateInfo
294 DescriptorSetLayoutCreateInfo (deUint32 bindingCount, const vk::VkDescriptorSetLayoutBinding* pBindings);
297 class PipelineLayoutCreateInfo : public vk::VkPipelineLayoutCreateInfo
300 PipelineLayoutCreateInfo (deUint32 descriptorSetCount,
301 const vk::VkDescriptorSetLayout* pSetLayouts,
302 deUint32 pushConstantRangeCount = 0,
303 const vk::VkPushConstantRange* pPushConstantRanges = DE_NULL);
305 PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>& setLayouts = std::vector<vk::VkDescriptorSetLayout>(),
306 deUint32 pushConstantRangeCount = 0,
307 const vk::VkPushConstantRange* pPushConstantRanges = DE_NULL);
310 std::vector<vk::VkDescriptorSetLayout> m_setLayouts;
311 std::vector<vk::VkPushConstantRange> m_pushConstantRanges;
314 class PipelineCreateInfo : public vk::VkGraphicsPipelineCreateInfo
317 class VertexInputState : public vk::VkPipelineVertexInputStateCreateInfo
320 VertexInputState (deUint32 vertexBindingDescriptionCount = 0,
321 const vk::VkVertexInputBindingDescription* pVertexBindingDescriptions = NULL,
322 deUint32 vertexAttributeDescriptionCount = 0,
323 const vk::VkVertexInputAttributeDescription* pVertexAttributeDescriptions = NULL);
326 class InputAssemblerState : public vk::VkPipelineInputAssemblyStateCreateInfo
329 InputAssemblerState (vk::VkPrimitiveTopology topology, vk::VkBool32 primitiveRestartEnable = false);
332 class TessellationState : public vk::VkPipelineTessellationStateCreateInfo
335 TessellationState (deUint32 patchControlPoints = 0);
338 class ViewportState : public vk::VkPipelineViewportStateCreateInfo
341 ViewportState (deUint32 viewportCount,
342 std::vector<vk::VkViewport> viewports = std::vector<vk::VkViewport>(0),
343 std::vector<vk::VkRect2D> scissors = std::vector<vk::VkRect2D>(0));
345 ViewportState (const ViewportState& other);
346 ViewportState& operator= (const ViewportState& other);
348 std::vector<vk::VkViewport> m_viewports;
349 std::vector<vk::VkRect2D> m_scissors;
352 class RasterizerState : public vk::VkPipelineRasterizationStateCreateInfo
355 RasterizerState (vk::VkBool32 depthClampEnable = false,
356 vk::VkBool32 rasterizerDiscardEnable = false,
357 vk::VkPolygonMode polygonMode = vk::VK_POLYGON_MODE_FILL,
358 vk::VkCullModeFlags cullMode = vk::VK_CULL_MODE_NONE,
359 vk::VkFrontFace frontFace = vk::VK_FRONT_FACE_CLOCKWISE,
360 vk::VkBool32 depthBiasEnable = true,
361 float depthBiasConstantFactor = 0.0f,
362 float depthBiasClamp = 0.0f,
363 float depthBiasSlopeFactor = 0.0f,
364 float lineWidth = 1.0f);
367 class MultiSampleState : public vk::VkPipelineMultisampleStateCreateInfo
370 MultiSampleState (vk::VkSampleCountFlagBits rasterizationSamples = vk::VK_SAMPLE_COUNT_1_BIT,
371 vk::VkBool32 sampleShadingEnable = false,
372 float minSampleShading = 0.0f,
373 const std::vector<vk::VkSampleMask>& sampleMask = std::vector<vk::VkSampleMask>(1, 0xffffffff),
374 bool alphaToCoverageEnable = false,
375 bool alphaToOneEnable = false);
377 MultiSampleState (const MultiSampleState& other);
378 MultiSampleState& operator= (const MultiSampleState& other);
381 std::vector<vk::VkSampleMask> m_sampleMask;
384 class ColorBlendState : public vk::VkPipelineColorBlendStateCreateInfo
387 class Attachment : public vk::VkPipelineColorBlendAttachmentState
390 Attachment (vk::VkBool32 blendEnable = false,
391 vk::VkBlendFactor srcColorBlendFactor = vk::VK_BLEND_FACTOR_SRC_COLOR,
392 vk::VkBlendFactor dstColorBlendFactor = vk::VK_BLEND_FACTOR_DST_COLOR,
393 vk::VkBlendOp colorBlendOp = vk::VK_BLEND_OP_ADD,
394 vk::VkBlendFactor srcAlphaBlendFactor = vk::VK_BLEND_FACTOR_SRC_COLOR,
395 vk::VkBlendFactor dstAlphaBlendFactor = vk::VK_BLEND_FACTOR_DST_COLOR,
396 vk::VkBlendOp alphaBlendOp = vk::VK_BLEND_OP_ADD,
397 deUint8 colorWriteMask = 0xff);
400 ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>& attachments,
401 vk::VkBool32 alphaToCoverageEnable = false,
402 vk::VkLogicOp logicOp = vk::VK_LOGIC_OP_COPY);
404 ColorBlendState (deUint32 attachmentCount,
405 const vk::VkPipelineColorBlendAttachmentState* attachments,
406 vk::VkBool32 logicOpEnable = false,
407 vk::VkLogicOp logicOp = vk::VK_LOGIC_OP_COPY);
409 ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo);
410 ColorBlendState (const ColorBlendState& createInfo,
411 std::vector<float> blendConstants = std::vector<float>(4));
414 std::vector<vk::VkPipelineColorBlendAttachmentState> m_attachments;
417 class DepthStencilState : public vk::VkPipelineDepthStencilStateCreateInfo
420 class StencilOpState : public vk::VkStencilOpState
423 StencilOpState (vk::VkStencilOp failOp = vk::VK_STENCIL_OP_REPLACE,
424 vk::VkStencilOp passOp = vk::VK_STENCIL_OP_REPLACE,
425 vk::VkStencilOp depthFailOp = vk::VK_STENCIL_OP_REPLACE,
426 vk::VkCompareOp compareOp = vk::VK_COMPARE_OP_ALWAYS,
427 deUint32 compareMask = 0xffffffffu,
428 deUint32 writeMask = 0xffffffffu,
429 deUint32 reference = 0);
432 DepthStencilState (vk::VkBool32 depthTestEnable = false,
433 vk::VkBool32 depthWriteEnable = false,
434 vk::VkCompareOp depthCompareOp = vk::VK_COMPARE_OP_ALWAYS,
435 vk::VkBool32 depthBoundsTestEnable = false,
436 vk::VkBool32 stencilTestEnable = false,
437 StencilOpState front = StencilOpState(),
438 StencilOpState back = StencilOpState(),
439 float minDepthBounds = -1.0f,
440 float maxDepthBounds = 1.0f);
443 class PipelineShaderStage : public vk::VkPipelineShaderStageCreateInfo
446 PipelineShaderStage (vk::VkShaderModule shaderModule, const char* pName, vk::VkShaderStageFlagBits stage);
449 class DynamicState : public vk::VkPipelineDynamicStateCreateInfo
452 DynamicState (const std::vector<vk::VkDynamicState>& dynamicStates = std::vector<vk::VkDynamicState>(0));
454 DynamicState (const DynamicState& other);
455 DynamicState& operator= (const DynamicState& other);
457 std::vector<vk::VkDynamicState> m_dynamicStates;
460 PipelineCreateInfo (vk::VkPipelineLayout layout,
461 vk::VkRenderPass renderPass,
463 vk::VkPipelineCreateFlags flags);
465 PipelineCreateInfo& addShader (const vk::VkPipelineShaderStageCreateInfo& shader);
467 PipelineCreateInfo& addState (const vk::VkPipelineVertexInputStateCreateInfo& state);
468 PipelineCreateInfo& addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state);
469 PipelineCreateInfo& addState (const vk::VkPipelineColorBlendStateCreateInfo& state);
470 PipelineCreateInfo& addState (const vk::VkPipelineViewportStateCreateInfo& state);
471 PipelineCreateInfo& addState (const vk::VkPipelineDepthStencilStateCreateInfo& state);
472 PipelineCreateInfo& addState (const vk::VkPipelineTessellationStateCreateInfo& state);
473 PipelineCreateInfo& addState (const vk::VkPipelineRasterizationStateCreateInfo& state);
474 PipelineCreateInfo& addState (const vk::VkPipelineMultisampleStateCreateInfo& state);
475 PipelineCreateInfo& addState (const vk::VkPipelineDynamicStateCreateInfo& state);
478 std::vector<vk::VkPipelineShaderStageCreateInfo> m_shaders;
480 vk::VkPipelineVertexInputStateCreateInfo m_vertexInputState;
481 vk::VkPipelineInputAssemblyStateCreateInfo m_inputAssemblyState;
482 std::vector<vk::VkPipelineColorBlendAttachmentState> m_colorBlendStateAttachments;
483 vk::VkPipelineColorBlendStateCreateInfo m_colorBlendState;
484 vk::VkPipelineViewportStateCreateInfo m_viewportState;
485 vk::VkPipelineDepthStencilStateCreateInfo m_dynamicDepthStencilState;
486 vk::VkPipelineTessellationStateCreateInfo m_tessState;
487 vk::VkPipelineRasterizationStateCreateInfo m_rasterState;
488 vk::VkPipelineMultisampleStateCreateInfo m_multisampleState;
489 vk::VkPipelineDynamicStateCreateInfo m_dynamicState;
491 std::vector<vk::VkDynamicState> m_dynamicStates;
493 std::vector<vk::VkViewport> m_viewports;
494 std::vector<vk::VkRect2D> m_scissors;
496 std::vector<vk::VkSampleMask> m_multisampleStateSampleMask;
499 class SamplerCreateInfo : public vk::VkSamplerCreateInfo
502 SamplerCreateInfo (vk::VkFilter magFilter = vk::VK_FILTER_NEAREST,
503 vk::VkFilter minFilter = vk::VK_FILTER_NEAREST,
504 vk::VkSamplerMipmapMode mipmapMode = vk::VK_SAMPLER_MIPMAP_MODE_NEAREST,
505 vk::VkSamplerAddressMode addressU = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
506 vk::VkSamplerAddressMode addressV = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
507 vk::VkSamplerAddressMode addressW = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
508 float mipLodBias = 0.0f,
509 vk::VkBool32 anisotropyEnable = vk::VK_FALSE,
510 float maxAnisotropy = 1.0f,
511 vk::VkBool32 compareEnable = false,
512 vk::VkCompareOp compareOp = vk::VK_COMPARE_OP_ALWAYS,
514 float maxLod = 16.0f,
515 vk::VkBorderColor borderColor = vk::VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE,
516 vk::VkBool32 unnormalizedCoordinates = false);
522 #endif // _VKTDYNAMICSTATECREATEINFOUTIL_HPP