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 vk::VkAttachmentReference* 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<vk::VkAttachmentReference> 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);
266 CmdBufferBeginInfo (vk::VkRenderPass renderPass,
268 vk::VkFramebuffer framebuffer,
269 vk::VkCommandBufferUsageFlags flags = 0,
270 bool occlusionQueryEnable = false,
271 vk::VkQueryControlFlags queryFlags = 0u,
272 vk::VkQueryPipelineStatisticFlags pipelineStatistics = 0u);
275 class DescriptorPoolSize : public vk::VkDescriptorPoolSize
278 DescriptorPoolSize (vk::VkDescriptorType _type, deUint32 _descriptorCount)
281 descriptorCount = _descriptorCount;
285 class DescriptorPoolCreateInfo : public vk::VkDescriptorPoolCreateInfo
288 DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
289 vk::VkDescriptorPoolCreateFlags flags,
292 DescriptorPoolCreateInfo& addDescriptors (vk::VkDescriptorType type, deUint32 count);
295 std::vector<vk::VkDescriptorPoolSize> m_poolSizeCounts;
298 class DescriptorSetLayoutCreateInfo : public vk::VkDescriptorSetLayoutCreateInfo
301 DescriptorSetLayoutCreateInfo (deUint32 bindingCount, const vk::VkDescriptorSetLayoutBinding* pBindings);
304 class PipelineLayoutCreateInfo : public vk::VkPipelineLayoutCreateInfo
307 PipelineLayoutCreateInfo (deUint32 descriptorSetCount,
308 const vk::VkDescriptorSetLayout* pSetLayouts,
309 deUint32 pushConstantRangeCount = 0,
310 const vk::VkPushConstantRange* pPushConstantRanges = DE_NULL);
312 PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>& setLayouts = std::vector<vk::VkDescriptorSetLayout>(),
313 deUint32 pushConstantRangeCount = 0,
314 const vk::VkPushConstantRange* pPushConstantRanges = DE_NULL);
317 std::vector<vk::VkDescriptorSetLayout> m_setLayouts;
318 std::vector<vk::VkPushConstantRange> m_pushConstantRanges;
321 class PipelineCreateInfo : public vk::VkGraphicsPipelineCreateInfo
324 class VertexInputState : public vk::VkPipelineVertexInputStateCreateInfo
327 VertexInputState (deUint32 vertexBindingDescriptionCount = 0,
328 const vk::VkVertexInputBindingDescription* pVertexBindingDescriptions = NULL,
329 deUint32 vertexAttributeDescriptionCount = 0,
330 const vk::VkVertexInputAttributeDescription* pVertexAttributeDescriptions = NULL);
333 class InputAssemblerState : public vk::VkPipelineInputAssemblyStateCreateInfo
336 InputAssemblerState (vk::VkPrimitiveTopology topology, vk::VkBool32 primitiveRestartEnable = false);
339 class TesselationState : public vk::VkPipelineTessellationStateCreateInfo
342 TesselationState (deUint32 patchControlPoints = 0);
345 class ViewportState : public vk::VkPipelineViewportStateCreateInfo
348 ViewportState (deUint32 viewportCount,
349 std::vector<vk::VkViewport> viewports = std::vector<vk::VkViewport>(0),
350 std::vector<vk::VkRect2D> scissors = std::vector<vk::VkRect2D>(0));
352 ViewportState (const ViewportState& other);
353 ViewportState& operator= (const ViewportState& other);
355 std::vector<vk::VkViewport> m_viewports;
356 std::vector<vk::VkRect2D> m_scissors;
359 class RasterizerState : public vk::VkPipelineRasterizationStateCreateInfo
362 RasterizerState (vk::VkBool32 depthClampEnable = false,
363 vk::VkBool32 rasterizerDiscardEnable = false,
364 vk::VkPolygonMode polygonMode = vk::VK_POLYGON_MODE_FILL,
365 vk::VkCullModeFlags cullMode = vk::VK_CULL_MODE_NONE,
366 vk::VkFrontFace frontFace = vk::VK_FRONT_FACE_CLOCKWISE,
367 vk::VkBool32 depthBiasEnable = true,
368 float depthBiasConstantFactor = 0.0f,
369 float depthBiasClamp = 0.0f,
370 float depthBiasSlopeFactor = 0.0f,
371 float lineWidth = 1.0f);
374 class MultiSampleState : public vk::VkPipelineMultisampleStateCreateInfo
377 MultiSampleState (vk::VkSampleCountFlagBits rasterizationSamples = vk::VK_SAMPLE_COUNT_1_BIT,
378 vk::VkBool32 sampleShadingEnable = false,
379 float minSampleShading = 0.0f,
380 const std::vector<vk::VkSampleMask>& sampleMask = std::vector<vk::VkSampleMask>(1, 0xffffffff),
381 bool alphaToCoverageEnable = false,
382 bool alphaToOneEnable = false);
384 MultiSampleState (const MultiSampleState& other);
385 MultiSampleState& operator= (const MultiSampleState& other);
388 std::vector<vk::VkSampleMask> m_sampleMask;
391 class ColorBlendState : public vk::VkPipelineColorBlendStateCreateInfo
394 class Attachment : public vk::VkPipelineColorBlendAttachmentState
397 Attachment (vk::VkBool32 blendEnable = false,
398 vk::VkBlendFactor srcColorBlendFactor = vk::VK_BLEND_FACTOR_SRC_COLOR,
399 vk::VkBlendFactor dstColorBlendFactor = vk::VK_BLEND_FACTOR_DST_COLOR,
400 vk::VkBlendOp colorBlendOp = vk::VK_BLEND_OP_ADD,
401 vk::VkBlendFactor srcAlphaBlendFactor = vk::VK_BLEND_FACTOR_SRC_COLOR,
402 vk::VkBlendFactor dstAlphaBlendFactor = vk::VK_BLEND_FACTOR_DST_COLOR,
403 vk::VkBlendOp alphaBlendOp = vk::VK_BLEND_OP_ADD,
404 deUint8 colorWriteMask = 0xff);
407 ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>& attachments,
408 vk::VkBool32 alphaToCoverageEnable = false,
409 vk::VkLogicOp logicOp = vk::VK_LOGIC_OP_COPY);
411 ColorBlendState (deUint32 attachmentCount,
412 const vk::VkPipelineColorBlendAttachmentState* attachments,
413 vk::VkBool32 logicOpEnable = false,
414 vk::VkLogicOp logicOp = vk::VK_LOGIC_OP_COPY);
416 ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo);
417 ColorBlendState (const ColorBlendState& createInfo,
418 std::vector<float> blendConstants = std::vector<float>(4));
421 std::vector<vk::VkPipelineColorBlendAttachmentState> m_attachments;
424 class DepthStencilState : public vk::VkPipelineDepthStencilStateCreateInfo
427 class StencilOpState : public vk::VkStencilOpState
430 StencilOpState (vk::VkStencilOp failOp = vk::VK_STENCIL_OP_REPLACE,
431 vk::VkStencilOp passOp = vk::VK_STENCIL_OP_REPLACE,
432 vk::VkStencilOp depthFailOp = vk::VK_STENCIL_OP_REPLACE,
433 vk::VkCompareOp compareOp = vk::VK_COMPARE_OP_ALWAYS,
434 deUint32 compareMask = 0xffffffffu,
435 deUint32 writeMask = 0xffffffffu,
436 deUint32 reference = 0);
439 DepthStencilState (vk::VkBool32 depthTestEnable = false,
440 vk::VkBool32 depthWriteEnable = false,
441 vk::VkCompareOp depthCompareOp = vk::VK_COMPARE_OP_ALWAYS,
442 vk::VkBool32 depthBoundsTestEnable = false,
443 vk::VkBool32 stencilTestEnable = false,
444 StencilOpState front = StencilOpState(),
445 StencilOpState back = StencilOpState(),
446 float minDepthBounds = -1.0f,
447 float maxDepthBounds = 1.0f);
450 class PipelineShaderStage : public vk::VkPipelineShaderStageCreateInfo
453 PipelineShaderStage (vk::VkShaderModule shaderModule, const char* pName, vk::VkShaderStageFlagBits stage);
456 class DynamicState : public vk::VkPipelineDynamicStateCreateInfo
459 DynamicState (const std::vector<vk::VkDynamicState>& dynamicStates = std::vector<vk::VkDynamicState>(0));
461 DynamicState (const DynamicState& other);
462 DynamicState& operator= (const DynamicState& other);
464 std::vector<vk::VkDynamicState> m_dynamicStates;
467 PipelineCreateInfo (vk::VkPipelineLayout layout,
468 vk::VkRenderPass renderPass,
470 vk::VkPipelineCreateFlags flags);
472 PipelineCreateInfo& addShader (const vk::VkPipelineShaderStageCreateInfo& shader);
474 PipelineCreateInfo& addState (const vk::VkPipelineVertexInputStateCreateInfo& state);
475 PipelineCreateInfo& addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state);
476 PipelineCreateInfo& addState (const vk::VkPipelineColorBlendStateCreateInfo& state);
477 PipelineCreateInfo& addState (const vk::VkPipelineViewportStateCreateInfo& state);
478 PipelineCreateInfo& addState (const vk::VkPipelineDepthStencilStateCreateInfo& state);
479 PipelineCreateInfo& addState (const vk::VkPipelineTessellationStateCreateInfo& state);
480 PipelineCreateInfo& addState (const vk::VkPipelineRasterizationStateCreateInfo& state);
481 PipelineCreateInfo& addState (const vk::VkPipelineMultisampleStateCreateInfo& state);
482 PipelineCreateInfo& addState (const vk::VkPipelineDynamicStateCreateInfo& state);
485 std::vector<vk::VkPipelineShaderStageCreateInfo> m_shaders;
487 vk::VkPipelineVertexInputStateCreateInfo m_vertexInputState;
488 vk::VkPipelineInputAssemblyStateCreateInfo m_inputAssemblyState;
489 std::vector<vk::VkPipelineColorBlendAttachmentState> m_colorBlendStateAttachments;
490 vk::VkPipelineColorBlendStateCreateInfo m_colorBlendState;
491 vk::VkPipelineViewportStateCreateInfo m_viewportState;
492 vk::VkPipelineDepthStencilStateCreateInfo m_dynamicDepthStencilState;
493 vk::VkPipelineTessellationStateCreateInfo m_tessState;
494 vk::VkPipelineRasterizationStateCreateInfo m_rasterState;
495 vk::VkPipelineMultisampleStateCreateInfo m_multisampleState;
496 vk::VkPipelineDynamicStateCreateInfo m_dynamicState;
498 std::vector<vk::VkDynamicState> m_dynamicStates;
500 std::vector<vk::VkViewport> m_viewports;
501 std::vector<vk::VkRect2D> m_scissors;
503 std::vector<vk::VkSampleMask> m_multisampleStateSampleMask;
506 class SamplerCreateInfo : public vk::VkSamplerCreateInfo
509 SamplerCreateInfo (vk::VkFilter magFilter = vk::VK_FILTER_NEAREST,
510 vk::VkFilter minFilter = vk::VK_FILTER_NEAREST,
511 vk::VkSamplerMipmapMode mipmapMode = vk::VK_SAMPLER_MIPMAP_MODE_NEAREST,
512 vk::VkSamplerAddressMode addressU = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
513 vk::VkSamplerAddressMode addressV = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
514 vk::VkSamplerAddressMode addressW = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
515 float mipLodBias = 0.0f,
516 float maxAnisotropy = 1.0f,
517 vk::VkBool32 compareEnable = false,
518 vk::VkCompareOp compareOp = vk::VK_COMPARE_OP_ALWAYS,
520 float maxLod = 16.0f,
521 vk::VkBorderColor borderColor = vk::VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE,
522 vk::VkBool32 unnormalizedCoordinates = false);
528 #endif // _VKTDYNAMICSTATECREATEINFOUTIL_HPP