1 #ifndef _VKTDRAWCREATEINFOUTIL_HPP
2 #define _VKTDRAWCREATEINFOUTIL_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 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
25 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
31 * \brief CreateInfo utilities
32 *//*--------------------------------------------------------------------*/
35 #include "tcuVector.hpp"
36 #include "deSharedPtr.hpp"
44 class ImageSubresourceRange : public vk::VkImageSubresourceRange
47 ImageSubresourceRange (vk::VkImageAspectFlags aspectMask,
48 deUint32 baseMipLevel = 0,
49 deUint32 levelCount = 1,
50 deUint32 baseArrayLayer = 0,
51 deUint32 layerCount = 1);
54 class ComponentMapping : public vk::VkComponentMapping
57 ComponentMapping (vk::VkComponentSwizzle r = vk::VK_COMPONENT_SWIZZLE_R,
58 vk::VkComponentSwizzle g = vk::VK_COMPONENT_SWIZZLE_G,
59 vk::VkComponentSwizzle b = vk::VK_COMPONENT_SWIZZLE_B,
60 vk::VkComponentSwizzle a = vk::VK_COMPONENT_SWIZZLE_A);
63 class ImageViewCreateInfo : public vk::VkImageViewCreateInfo
66 ImageViewCreateInfo (vk::VkImage image,
67 vk::VkImageViewType viewType,
69 const vk::VkImageSubresourceRange& subresourceRange,
70 const vk::VkComponentMapping& components = ComponentMapping(),
71 vk::VkImageViewCreateFlags flags = 0);
73 ImageViewCreateInfo (vk::VkImage image,
74 vk::VkImageViewType viewType,
76 const vk::VkComponentMapping& components = ComponentMapping(),
77 vk::VkImageViewCreateFlags flags = 0);
80 class BufferViewCreateInfo : public vk::VkBufferViewCreateInfo
83 BufferViewCreateInfo (vk::VkBuffer buffer,
85 vk::VkDeviceSize offset,
86 vk::VkDeviceSize range);
89 class BufferCreateInfo : public vk::VkBufferCreateInfo
92 BufferCreateInfo (vk::VkDeviceSize size,
93 vk::VkBufferCreateFlags usage,
94 vk::VkSharingMode sharingMode = vk::VK_SHARING_MODE_EXCLUSIVE,
95 deUint32 queueFamilyIndexCount = 0,
96 const deUint32* pQueueFamilyIndices = DE_NULL,
97 vk::VkBufferCreateFlags flags = 0);
99 BufferCreateInfo (const BufferCreateInfo& other);
100 BufferCreateInfo& operator= (const BufferCreateInfo& other);
103 std::vector<deUint32> m_queueFamilyIndices;
106 class ImageCreateInfo : public vk::VkImageCreateInfo
109 ImageCreateInfo (vk::VkImageType imageType,
111 vk::VkExtent3D extent,
113 deUint32 arrayLayers,
114 vk::VkSampleCountFlagBits samples,
115 vk::VkImageTiling tiling,
116 vk::VkImageUsageFlags usage,
117 vk::VkSharingMode sharingMode = vk::VK_SHARING_MODE_EXCLUSIVE,
118 deUint32 queueFamilyIndexCount = 0,
119 const deUint32* pQueueFamilyIndices = DE_NULL,
120 vk::VkImageCreateFlags flags = 0,
121 vk::VkImageLayout initialLayout = vk::VK_IMAGE_LAYOUT_UNDEFINED);
124 ImageCreateInfo (const ImageCreateInfo& other);
125 ImageCreateInfo& operator= (const ImageCreateInfo& other);
127 std::vector<deUint32> m_queueFamilyIndices;
130 class FramebufferCreateInfo : public vk::VkFramebufferCreateInfo
133 FramebufferCreateInfo (vk::VkRenderPass renderPass,
134 const std::vector<vk::VkImageView>& attachments,
140 class AttachmentDescription : public vk::VkAttachmentDescription
143 AttachmentDescription (vk::VkFormat format,
144 vk::VkSampleCountFlagBits samples,
145 vk::VkAttachmentLoadOp loadOp,
146 vk::VkAttachmentStoreOp storeOp,
147 vk::VkAttachmentLoadOp stencilLoadOp,
148 vk::VkAttachmentStoreOp stencilStoreOp,
149 vk::VkImageLayout initialLayout,
150 vk::VkImageLayout finalLayout);
152 AttachmentDescription (const vk::VkAttachmentDescription &);
155 class AttachmentReference : public vk::VkAttachmentReference
158 AttachmentReference (deUint32 attachment, vk::VkImageLayout layout);
159 AttachmentReference (void);
162 class SubpassDescription : public vk::VkSubpassDescription
165 SubpassDescription (vk::VkPipelineBindPoint pipelineBindPoint,
166 vk::VkSubpassDescriptionFlags flags,
167 deUint32 inputAttachmentCount,
168 const vk::VkAttachmentReference* inputAttachments,
169 deUint32 colorAttachmentCount,
170 const vk::VkAttachmentReference* colorAttachments,
171 const vk::VkAttachmentReference* resolveAttachments,
172 vk::VkAttachmentReference depthStencilAttachment,
173 deUint32 preserveAttachmentCount,
174 const deUint32* preserveAttachments);
176 SubpassDescription (const vk::VkSubpassDescription& other);
177 SubpassDescription (const SubpassDescription& other);
178 SubpassDescription& operator= (const SubpassDescription& other);
181 std::vector<vk::VkAttachmentReference> m_inputAttachments;
182 std::vector<vk::VkAttachmentReference> m_colorAttachments;
183 std::vector<vk::VkAttachmentReference> m_resolveAttachments;
184 std::vector<deUint32> m_preserveAttachments;
186 vk::VkAttachmentReference m_depthStencilAttachment;
189 class SubpassDependency : public vk::VkSubpassDependency
192 SubpassDependency ( deUint32 srcSubpass,
194 vk::VkPipelineStageFlags srcStageMask,
195 vk::VkPipelineStageFlags dstStageMask,
196 vk::VkAccessFlags srcAccessMask,
197 vk::VkAccessFlags dstAccessMask,
198 vk::VkDependencyFlags dependencyFlags);
200 SubpassDependency (const vk::VkSubpassDependency& other);
203 class RenderPassCreateInfo : public vk::VkRenderPassCreateInfo
206 RenderPassCreateInfo (const std::vector<vk::VkAttachmentDescription>& attachments,
207 const std::vector<vk::VkSubpassDescription>& subpasses,
208 const std::vector<vk::VkSubpassDependency>& dependiences = std::vector<vk::VkSubpassDependency>());
210 RenderPassCreateInfo (deUint32 attachmentCount = 0,
211 const vk::VkAttachmentDescription* pAttachments = DE_NULL,
212 deUint32 subpassCount = 0,
213 const vk::VkSubpassDescription* pSubpasses = DE_NULL,
214 deUint32 dependencyCount = 0,
215 const vk::VkSubpassDependency* pDependiences = DE_NULL);
217 void addAttachment (vk::VkAttachmentDescription attachment);
218 void addSubpass (vk::VkSubpassDescription subpass);
219 void addDependency (vk::VkSubpassDependency dependency);
222 std::vector<AttachmentDescription> m_attachments;
223 std::vector<SubpassDescription> m_subpasses;
224 std::vector<SubpassDependency> m_dependiences;
226 std::vector<vk::VkAttachmentDescription> m_attachmentsStructs;
227 std::vector<vk::VkSubpassDescription> m_subpassesStructs;
228 std::vector<vk::VkSubpassDependency> m_dependiencesStructs;
230 RenderPassCreateInfo (const RenderPassCreateInfo &other); //Not allowed!
231 RenderPassCreateInfo& operator= (const RenderPassCreateInfo &other); //Not allowed!
234 class RenderPassBeginInfo : public vk::VkRenderPassBeginInfo
237 RenderPassBeginInfo (vk::VkRenderPass renderPass,
238 vk::VkFramebuffer framebuffer,
239 vk::VkRect2D renderArea,
240 const std::vector<vk::VkClearValue>& clearValues = std::vector<vk::VkClearValue>());
243 std::vector<vk::VkClearValue> m_clearValues;
245 RenderPassBeginInfo (const RenderPassBeginInfo& other); //Not allowed!
246 RenderPassBeginInfo& operator= (const RenderPassBeginInfo& other); //Not allowed!
249 class CmdPoolCreateInfo : public vk::VkCommandPoolCreateInfo
252 CmdPoolCreateInfo (deUint32 queueFamilyIndex,
253 vk::VkCommandPoolCreateFlags flags = vk::VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
256 class CmdBufferBeginInfo : public vk::VkCommandBufferBeginInfo
259 CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags flags = 0);
262 class DescriptorPoolSize : public vk::VkDescriptorPoolSize
265 DescriptorPoolSize (vk::VkDescriptorType _type, deUint32 _descriptorCount)
268 descriptorCount = _descriptorCount;
272 class DescriptorPoolCreateInfo : public vk::VkDescriptorPoolCreateInfo
275 DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
276 vk::VkDescriptorPoolCreateFlags flags,
279 DescriptorPoolCreateInfo& addDescriptors (vk::VkDescriptorType type, deUint32 count);
282 std::vector<vk::VkDescriptorPoolSize> m_poolSizeCounts;
285 class DescriptorSetLayoutCreateInfo : public vk::VkDescriptorSetLayoutCreateInfo
288 DescriptorSetLayoutCreateInfo (deUint32 bindingCount, const vk::VkDescriptorSetLayoutBinding* pBindings);
291 class PipelineLayoutCreateInfo : public vk::VkPipelineLayoutCreateInfo
294 PipelineLayoutCreateInfo (deUint32 descriptorSetCount,
295 const vk::VkDescriptorSetLayout* pSetLayouts,
296 deUint32 pushConstantRangeCount = 0,
297 const vk::VkPushConstantRange* pPushConstantRanges = DE_NULL);
299 PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>& setLayouts = std::vector<vk::VkDescriptorSetLayout>(),
300 deUint32 pushConstantRangeCount = 0,
301 const vk::VkPushConstantRange* pPushConstantRanges = DE_NULL);
304 std::vector<vk::VkDescriptorSetLayout> m_setLayouts;
305 std::vector<vk::VkPushConstantRange> m_pushConstantRanges;
308 class PipelineCreateInfo : public vk::VkGraphicsPipelineCreateInfo
311 class VertexInputState : public vk::VkPipelineVertexInputStateCreateInfo
314 VertexInputState (deUint32 vertexBindingDescriptionCount = 0,
315 const vk::VkVertexInputBindingDescription* pVertexBindingDescriptions = NULL,
316 deUint32 vertexAttributeDescriptionCount = 0,
317 const vk::VkVertexInputAttributeDescription* pVertexAttributeDescriptions = NULL);
320 class InputAssemblerState : public vk::VkPipelineInputAssemblyStateCreateInfo
323 InputAssemblerState (vk::VkPrimitiveTopology topology, vk::VkBool32 primitiveRestartEnable = false);
326 class TessellationState : public vk::VkPipelineTessellationStateCreateInfo
329 TessellationState (deUint32 patchControlPoints = 0);
332 class ViewportState : public vk::VkPipelineViewportStateCreateInfo
335 ViewportState (deUint32 viewportCount,
336 std::vector<vk::VkViewport> viewports = std::vector<vk::VkViewport>(0),
337 std::vector<vk::VkRect2D> scissors = std::vector<vk::VkRect2D>(0));
339 ViewportState (const ViewportState& other);
340 ViewportState& operator= (const ViewportState& other);
342 std::vector<vk::VkViewport> m_viewports;
343 std::vector<vk::VkRect2D> m_scissors;
346 class RasterizerState : public vk::VkPipelineRasterizationStateCreateInfo
349 RasterizerState (vk::VkBool32 depthClampEnable = false,
350 vk::VkBool32 rasterizerDiscardEnable = false,
351 vk::VkPolygonMode polygonMode = vk::VK_POLYGON_MODE_FILL,
352 vk::VkCullModeFlags cullMode = vk::VK_CULL_MODE_NONE,
353 vk::VkFrontFace frontFace = vk::VK_FRONT_FACE_CLOCKWISE,
354 vk::VkBool32 depthBiasEnable = true,
355 float depthBiasConstantFactor = 0.0f,
356 float depthBiasClamp = 0.0f,
357 float depthBiasSlopeFactor = 0.0f,
358 float lineWidth = 1.0f);
361 class MultiSampleState : public vk::VkPipelineMultisampleStateCreateInfo
364 MultiSampleState (vk::VkSampleCountFlagBits rasterizationSamples = vk::VK_SAMPLE_COUNT_1_BIT,
365 vk::VkBool32 sampleShadingEnable = false,
366 float minSampleShading = 0.0f,
367 const std::vector<vk::VkSampleMask>& sampleMask = std::vector<vk::VkSampleMask>(1, 0xffffffff),
368 bool alphaToCoverageEnable = false,
369 bool alphaToOneEnable = false);
371 MultiSampleState (const MultiSampleState& other);
372 MultiSampleState& operator= (const MultiSampleState& other);
375 std::vector<vk::VkSampleMask> m_sampleMask;
378 class ColorBlendState : public vk::VkPipelineColorBlendStateCreateInfo
381 class Attachment : public vk::VkPipelineColorBlendAttachmentState
384 Attachment (vk::VkBool32 blendEnable = false,
385 vk::VkBlendFactor srcColorBlendFactor = vk::VK_BLEND_FACTOR_SRC_COLOR,
386 vk::VkBlendFactor dstColorBlendFactor = vk::VK_BLEND_FACTOR_DST_COLOR,
387 vk::VkBlendOp colorBlendOp = vk::VK_BLEND_OP_ADD,
388 vk::VkBlendFactor srcAlphaBlendFactor = vk::VK_BLEND_FACTOR_SRC_COLOR,
389 vk::VkBlendFactor dstAlphaBlendFactor = vk::VK_BLEND_FACTOR_DST_COLOR,
390 vk::VkBlendOp alphaBlendOp = vk::VK_BLEND_OP_ADD,
391 deUint8 colorWriteMask = 0xff);
394 ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>& attachments,
395 vk::VkBool32 alphaToCoverageEnable = false,
396 vk::VkLogicOp logicOp = vk::VK_LOGIC_OP_COPY);
398 ColorBlendState (deUint32 attachmentCount,
399 const vk::VkPipelineColorBlendAttachmentState* attachments,
400 vk::VkBool32 logicOpEnable = false,
401 vk::VkLogicOp logicOp = vk::VK_LOGIC_OP_COPY);
403 ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo);
404 ColorBlendState (const ColorBlendState& createInfo,
405 std::vector<float> blendConstants = std::vector<float>(4));
408 std::vector<vk::VkPipelineColorBlendAttachmentState> m_attachments;
411 class DepthStencilState : public vk::VkPipelineDepthStencilStateCreateInfo
414 class StencilOpState : public vk::VkStencilOpState
417 StencilOpState (vk::VkStencilOp failOp = vk::VK_STENCIL_OP_REPLACE,
418 vk::VkStencilOp passOp = vk::VK_STENCIL_OP_REPLACE,
419 vk::VkStencilOp depthFailOp = vk::VK_STENCIL_OP_REPLACE,
420 vk::VkCompareOp compareOp = vk::VK_COMPARE_OP_ALWAYS,
421 deUint32 compareMask = 0xffffffffu,
422 deUint32 writeMask = 0xffffffffu,
423 deUint32 reference = 0);
426 DepthStencilState (vk::VkBool32 depthTestEnable = false,
427 vk::VkBool32 depthWriteEnable = false,
428 vk::VkCompareOp depthCompareOp = vk::VK_COMPARE_OP_ALWAYS,
429 vk::VkBool32 depthBoundsTestEnable = false,
430 vk::VkBool32 stencilTestEnable = false,
431 StencilOpState front = StencilOpState(),
432 StencilOpState back = StencilOpState(),
433 float minDepthBounds = -1.0f,
434 float maxDepthBounds = 1.0f);
437 class PipelineShaderStage : public vk::VkPipelineShaderStageCreateInfo
440 PipelineShaderStage (vk::VkShaderModule shaderModule, const char* pName, vk::VkShaderStageFlagBits stage);
443 class DynamicState : public vk::VkPipelineDynamicStateCreateInfo
446 DynamicState (const std::vector<vk::VkDynamicState>& dynamicStates = std::vector<vk::VkDynamicState>(0));
448 DynamicState (const DynamicState& other);
449 DynamicState& operator= (const DynamicState& other);
451 std::vector<vk::VkDynamicState> m_dynamicStates;
454 PipelineCreateInfo (vk::VkPipelineLayout layout,
455 vk::VkRenderPass renderPass,
457 vk::VkPipelineCreateFlags flags);
459 PipelineCreateInfo& addShader (const vk::VkPipelineShaderStageCreateInfo& shader);
461 PipelineCreateInfo& addState (const vk::VkPipelineVertexInputStateCreateInfo& state);
462 PipelineCreateInfo& addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state);
463 PipelineCreateInfo& addState (const vk::VkPipelineColorBlendStateCreateInfo& state);
464 PipelineCreateInfo& addState (const vk::VkPipelineViewportStateCreateInfo& state);
465 PipelineCreateInfo& addState (const vk::VkPipelineDepthStencilStateCreateInfo& state);
466 PipelineCreateInfo& addState (const vk::VkPipelineTessellationStateCreateInfo& state);
467 PipelineCreateInfo& addState (const vk::VkPipelineRasterizationStateCreateInfo& state);
468 PipelineCreateInfo& addState (const vk::VkPipelineMultisampleStateCreateInfo& state);
469 PipelineCreateInfo& addState (const vk::VkPipelineDynamicStateCreateInfo& state);
472 std::vector<vk::VkPipelineShaderStageCreateInfo> m_shaders;
474 vk::VkPipelineVertexInputStateCreateInfo m_vertexInputState;
475 vk::VkPipelineInputAssemblyStateCreateInfo m_inputAssemblyState;
476 std::vector<vk::VkPipelineColorBlendAttachmentState> m_colorBlendStateAttachments;
477 vk::VkPipelineColorBlendStateCreateInfo m_colorBlendState;
478 vk::VkPipelineViewportStateCreateInfo m_viewportState;
479 vk::VkPipelineDepthStencilStateCreateInfo m_dynamicDepthStencilState;
480 vk::VkPipelineTessellationStateCreateInfo m_tessState;
481 vk::VkPipelineRasterizationStateCreateInfo m_rasterState;
482 vk::VkPipelineMultisampleStateCreateInfo m_multisampleState;
483 vk::VkPipelineDynamicStateCreateInfo m_dynamicState;
485 std::vector<vk::VkDynamicState> m_dynamicStates;
487 std::vector<vk::VkViewport> m_viewports;
488 std::vector<vk::VkRect2D> m_scissors;
490 std::vector<vk::VkSampleMask> m_multisampleStateSampleMask;
493 class SamplerCreateInfo : public vk::VkSamplerCreateInfo
496 SamplerCreateInfo (vk::VkFilter magFilter = vk::VK_FILTER_NEAREST,
497 vk::VkFilter minFilter = vk::VK_FILTER_NEAREST,
498 vk::VkSamplerMipmapMode mipmapMode = vk::VK_SAMPLER_MIPMAP_MODE_NEAREST,
499 vk::VkSamplerAddressMode addressU = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
500 vk::VkSamplerAddressMode addressV = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
501 vk::VkSamplerAddressMode addressW = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
502 float mipLodBias = 0.0f,
503 vk::VkBool32 anisotropyEnable = vk::VK_FALSE,
504 float maxAnisotropy = 1.0f,
505 vk::VkBool32 compareEnable = false,
506 vk::VkCompareOp compareOp = vk::VK_COMPARE_OP_ALWAYS,
508 float maxLod = 16.0f,
509 vk::VkBorderColor borderColor = vk::VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE,
510 vk::VkBool32 unnormalizedCoordinates = false);
516 #endif // _VKTDRAWCREATEINFOUTIL_HPP