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 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"
40 #include "deSharedPtr.hpp"
48 class ImageSubresourceRange : public vk::VkImageSubresourceRange
51 ImageSubresourceRange (vk::VkImageAspectFlags aspectMask,
52 deUint32 baseMipLevel = 0,
53 deUint32 levelCount = 1,
54 deUint32 baseArrayLayer = 0,
55 deUint32 layerCount = 1);
58 class ComponentMapping : public vk::VkComponentMapping
61 ComponentMapping (vk::VkComponentSwizzle r = vk::VK_COMPONENT_SWIZZLE_R,
62 vk::VkComponentSwizzle g = vk::VK_COMPONENT_SWIZZLE_G,
63 vk::VkComponentSwizzle b = vk::VK_COMPONENT_SWIZZLE_B,
64 vk::VkComponentSwizzle a = vk::VK_COMPONENT_SWIZZLE_A);
67 class ImageViewCreateInfo : public vk::VkImageViewCreateInfo
70 ImageViewCreateInfo (vk::VkImage image,
71 vk::VkImageViewType viewType,
73 const vk::VkImageSubresourceRange& subresourceRange,
74 const vk::VkComponentMapping& components = ComponentMapping(),
75 vk::VkImageViewCreateFlags flags = 0);
77 ImageViewCreateInfo (vk::VkImage image,
78 vk::VkImageViewType viewType,
80 const vk::VkComponentMapping& components = ComponentMapping(),
81 vk::VkImageViewCreateFlags flags = 0);
84 class BufferViewCreateInfo : public vk::VkBufferViewCreateInfo
87 BufferViewCreateInfo (vk::VkBuffer buffer,
89 vk::VkDeviceSize offset,
90 vk::VkDeviceSize range);
93 class BufferCreateInfo : public vk::VkBufferCreateInfo
96 BufferCreateInfo (vk::VkDeviceSize size,
97 vk::VkBufferCreateFlags usage,
98 vk::VkSharingMode sharingMode = vk::VK_SHARING_MODE_EXCLUSIVE,
99 deUint32 queueFamilyIndexCount = 0,
100 const deUint32* pQueueFamilyIndices = DE_NULL,
101 vk::VkBufferCreateFlags flags = 0);
103 BufferCreateInfo (const BufferCreateInfo& other);
104 BufferCreateInfo& operator= (const BufferCreateInfo& other);
107 std::vector<deUint32> m_queueFamilyIndices;
110 class ImageCreateInfo : public vk::VkImageCreateInfo
113 ImageCreateInfo (vk::VkImageType imageType,
115 vk::VkExtent3D extent,
117 deUint32 arrayLayers,
118 vk::VkSampleCountFlagBits samples,
119 vk::VkImageTiling tiling,
120 vk::VkImageUsageFlags usage,
121 vk::VkSharingMode sharingMode = vk::VK_SHARING_MODE_EXCLUSIVE,
122 deUint32 queueFamilyIndexCount = 0,
123 const deUint32* pQueueFamilyIndices = DE_NULL,
124 vk::VkImageCreateFlags flags = 0,
125 vk::VkImageLayout initialLayout = vk::VK_IMAGE_LAYOUT_UNDEFINED);
128 ImageCreateInfo (const ImageCreateInfo& other);
129 ImageCreateInfo& operator= (const ImageCreateInfo& other);
131 std::vector<deUint32> m_queueFamilyIndices;
134 class FramebufferCreateInfo : public vk::VkFramebufferCreateInfo
137 FramebufferCreateInfo (vk::VkRenderPass renderPass,
138 const std::vector<vk::VkImageView>& attachments,
144 class AttachmentDescription : public vk::VkAttachmentDescription
147 AttachmentDescription (vk::VkFormat format,
148 vk::VkSampleCountFlagBits samples,
149 vk::VkAttachmentLoadOp loadOp,
150 vk::VkAttachmentStoreOp storeOp,
151 vk::VkAttachmentLoadOp stencilLoadOp,
152 vk::VkAttachmentStoreOp stencilStoreOp,
153 vk::VkImageLayout initialLayout,
154 vk::VkImageLayout finalLayout);
156 AttachmentDescription (const vk::VkAttachmentDescription &);
159 class AttachmentReference : public vk::VkAttachmentReference
162 AttachmentReference (deUint32 attachment, vk::VkImageLayout layout);
163 AttachmentReference (void);
166 class SubpassDescription : public vk::VkSubpassDescription
169 SubpassDescription (vk::VkPipelineBindPoint pipelineBindPoint,
170 vk::VkSubpassDescriptionFlags flags,
171 deUint32 inputAttachmentCount,
172 const vk::VkAttachmentReference* inputAttachments,
173 deUint32 colorAttachmentCount,
174 const vk::VkAttachmentReference* colorAttachments,
175 const vk::VkAttachmentReference* resolveAttachments,
176 vk::VkAttachmentReference depthStencilAttachment,
177 deUint32 preserveAttachmentCount,
178 const deUint32* preserveAttachments);
180 SubpassDescription (const vk::VkSubpassDescription& other);
181 SubpassDescription (const SubpassDescription& other);
182 SubpassDescription& operator= (const SubpassDescription& other);
185 std::vector<vk::VkAttachmentReference> m_inputAttachments;
186 std::vector<vk::VkAttachmentReference> m_colorAttachments;
187 std::vector<vk::VkAttachmentReference> m_resolveAttachments;
188 std::vector<deUint32> m_preserveAttachments;
190 vk::VkAttachmentReference m_depthStencilAttachment;
193 class SubpassDependency : public vk::VkSubpassDependency
196 SubpassDependency ( deUint32 srcSubpass,
198 vk::VkPipelineStageFlags srcStageMask,
199 vk::VkPipelineStageFlags dstStageMask,
200 vk::VkAccessFlags srcAccessMask,
201 vk::VkAccessFlags dstAccessMask,
202 vk::VkDependencyFlags dependencyFlags);
204 SubpassDependency (const vk::VkSubpassDependency& other);
207 class RenderPassCreateInfo : public vk::VkRenderPassCreateInfo
210 RenderPassCreateInfo (const std::vector<vk::VkAttachmentDescription>& attachments,
211 const std::vector<vk::VkSubpassDescription>& subpasses,
212 const std::vector<vk::VkSubpassDependency>& dependiences = std::vector<vk::VkSubpassDependency>());
214 RenderPassCreateInfo (deUint32 attachmentCount = 0,
215 const vk::VkAttachmentDescription* pAttachments = DE_NULL,
216 deUint32 subpassCount = 0,
217 const vk::VkSubpassDescription* pSubpasses = DE_NULL,
218 deUint32 dependencyCount = 0,
219 const vk::VkSubpassDependency* pDependiences = DE_NULL);
221 void addAttachment (vk::VkAttachmentDescription attachment);
222 void addSubpass (vk::VkSubpassDescription subpass);
223 void addDependency (vk::VkSubpassDependency dependency);
226 std::vector<AttachmentDescription> m_attachments;
227 std::vector<SubpassDescription> m_subpasses;
228 std::vector<SubpassDependency> m_dependiences;
230 std::vector<vk::VkAttachmentDescription> m_attachmentsStructs;
231 std::vector<vk::VkSubpassDescription> m_subpassesStructs;
232 std::vector<vk::VkSubpassDependency> m_dependiencesStructs;
234 RenderPassCreateInfo (const RenderPassCreateInfo &other); //Not allowed!
235 RenderPassCreateInfo& operator= (const RenderPassCreateInfo &other); //Not allowed!
238 class RenderPassBeginInfo : public vk::VkRenderPassBeginInfo
241 RenderPassBeginInfo (vk::VkRenderPass renderPass,
242 vk::VkFramebuffer framebuffer,
243 vk::VkRect2D renderArea,
244 const std::vector<vk::VkClearValue>& clearValues = std::vector<vk::VkClearValue>());
247 std::vector<vk::VkClearValue> m_clearValues;
249 RenderPassBeginInfo (const RenderPassBeginInfo& other); //Not allowed!
250 RenderPassBeginInfo& operator= (const RenderPassBeginInfo& other); //Not allowed!
253 class CmdPoolCreateInfo : public vk::VkCommandPoolCreateInfo
256 CmdPoolCreateInfo (deUint32 queueFamilyIndex,
257 vk::VkCommandPoolCreateFlags flags = vk::VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
260 class CmdBufferBeginInfo : public vk::VkCommandBufferBeginInfo
263 CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags flags = 0);
266 class DescriptorPoolSize : public vk::VkDescriptorPoolSize
269 DescriptorPoolSize (vk::VkDescriptorType _type, deUint32 _descriptorCount)
272 descriptorCount = _descriptorCount;
276 class DescriptorPoolCreateInfo : public vk::VkDescriptorPoolCreateInfo
279 DescriptorPoolCreateInfo (const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
280 vk::VkDescriptorPoolCreateFlags flags,
283 DescriptorPoolCreateInfo& addDescriptors (vk::VkDescriptorType type, deUint32 count);
286 std::vector<vk::VkDescriptorPoolSize> m_poolSizeCounts;
289 class DescriptorSetLayoutCreateInfo : public vk::VkDescriptorSetLayoutCreateInfo
292 DescriptorSetLayoutCreateInfo (deUint32 bindingCount, const vk::VkDescriptorSetLayoutBinding* pBindings);
295 class PipelineLayoutCreateInfo : public vk::VkPipelineLayoutCreateInfo
298 PipelineLayoutCreateInfo (deUint32 descriptorSetCount,
299 const vk::VkDescriptorSetLayout* pSetLayouts,
300 deUint32 pushConstantRangeCount = 0,
301 const vk::VkPushConstantRange* pPushConstantRanges = DE_NULL);
303 PipelineLayoutCreateInfo (const std::vector<vk::VkDescriptorSetLayout>& setLayouts = std::vector<vk::VkDescriptorSetLayout>(),
304 deUint32 pushConstantRangeCount = 0,
305 const vk::VkPushConstantRange* pPushConstantRanges = DE_NULL);
308 std::vector<vk::VkDescriptorSetLayout> m_setLayouts;
309 std::vector<vk::VkPushConstantRange> m_pushConstantRanges;
312 class PipelineCreateInfo : public vk::VkGraphicsPipelineCreateInfo
315 class VertexInputState : public vk::VkPipelineVertexInputStateCreateInfo
318 VertexInputState (deUint32 vertexBindingDescriptionCount = 0,
319 const vk::VkVertexInputBindingDescription* pVertexBindingDescriptions = NULL,
320 deUint32 vertexAttributeDescriptionCount = 0,
321 const vk::VkVertexInputAttributeDescription* pVertexAttributeDescriptions = NULL);
324 class InputAssemblerState : public vk::VkPipelineInputAssemblyStateCreateInfo
327 InputAssemblerState (vk::VkPrimitiveTopology topology, vk::VkBool32 primitiveRestartEnable = false);
330 class TessellationState : public vk::VkPipelineTessellationStateCreateInfo
333 TessellationState (deUint32 patchControlPoints = 0);
336 class ViewportState : public vk::VkPipelineViewportStateCreateInfo
339 ViewportState (deUint32 viewportCount,
340 std::vector<vk::VkViewport> viewports = std::vector<vk::VkViewport>(0),
341 std::vector<vk::VkRect2D> scissors = std::vector<vk::VkRect2D>(0));
343 ViewportState (const ViewportState& other);
344 ViewportState& operator= (const ViewportState& other);
346 std::vector<vk::VkViewport> m_viewports;
347 std::vector<vk::VkRect2D> m_scissors;
350 class RasterizerState : public vk::VkPipelineRasterizationStateCreateInfo
353 RasterizerState (vk::VkBool32 depthClampEnable = false,
354 vk::VkBool32 rasterizerDiscardEnable = false,
355 vk::VkPolygonMode polygonMode = vk::VK_POLYGON_MODE_FILL,
356 vk::VkCullModeFlags cullMode = vk::VK_CULL_MODE_NONE,
357 vk::VkFrontFace frontFace = vk::VK_FRONT_FACE_CLOCKWISE,
358 vk::VkBool32 depthBiasEnable = true,
359 float depthBiasConstantFactor = 0.0f,
360 float depthBiasClamp = 0.0f,
361 float depthBiasSlopeFactor = 0.0f,
362 float lineWidth = 1.0f);
365 class MultiSampleState : public vk::VkPipelineMultisampleStateCreateInfo
368 MultiSampleState (vk::VkSampleCountFlagBits rasterizationSamples = vk::VK_SAMPLE_COUNT_1_BIT,
369 vk::VkBool32 sampleShadingEnable = false,
370 float minSampleShading = 0.0f,
371 const std::vector<vk::VkSampleMask>& sampleMask = std::vector<vk::VkSampleMask>(1, 0xffffffff),
372 bool alphaToCoverageEnable = false,
373 bool alphaToOneEnable = false);
375 MultiSampleState (const MultiSampleState& other);
376 MultiSampleState& operator= (const MultiSampleState& other);
379 std::vector<vk::VkSampleMask> m_sampleMask;
382 class ColorBlendState : public vk::VkPipelineColorBlendStateCreateInfo
385 class Attachment : public vk::VkPipelineColorBlendAttachmentState
388 Attachment (vk::VkBool32 blendEnable = false,
389 vk::VkBlendFactor srcColorBlendFactor = vk::VK_BLEND_FACTOR_SRC_COLOR,
390 vk::VkBlendFactor dstColorBlendFactor = vk::VK_BLEND_FACTOR_DST_COLOR,
391 vk::VkBlendOp colorBlendOp = vk::VK_BLEND_OP_ADD,
392 vk::VkBlendFactor srcAlphaBlendFactor = vk::VK_BLEND_FACTOR_SRC_COLOR,
393 vk::VkBlendFactor dstAlphaBlendFactor = vk::VK_BLEND_FACTOR_DST_COLOR,
394 vk::VkBlendOp alphaBlendOp = vk::VK_BLEND_OP_ADD,
395 deUint8 colorWriteMask = 0xff);
398 ColorBlendState (const std::vector<vk::VkPipelineColorBlendAttachmentState>& attachments,
399 vk::VkBool32 alphaToCoverageEnable = false,
400 vk::VkLogicOp logicOp = vk::VK_LOGIC_OP_COPY);
402 ColorBlendState (deUint32 attachmentCount,
403 const vk::VkPipelineColorBlendAttachmentState* attachments,
404 vk::VkBool32 logicOpEnable = false,
405 vk::VkLogicOp logicOp = vk::VK_LOGIC_OP_COPY);
407 ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo& createInfo);
408 ColorBlendState (const ColorBlendState& createInfo,
409 std::vector<float> blendConstants = std::vector<float>(4));
412 std::vector<vk::VkPipelineColorBlendAttachmentState> m_attachments;
415 class DepthStencilState : public vk::VkPipelineDepthStencilStateCreateInfo
418 class StencilOpState : public vk::VkStencilOpState
421 StencilOpState (vk::VkStencilOp failOp = vk::VK_STENCIL_OP_REPLACE,
422 vk::VkStencilOp passOp = vk::VK_STENCIL_OP_REPLACE,
423 vk::VkStencilOp depthFailOp = vk::VK_STENCIL_OP_REPLACE,
424 vk::VkCompareOp compareOp = vk::VK_COMPARE_OP_ALWAYS,
425 deUint32 compareMask = 0xffffffffu,
426 deUint32 writeMask = 0xffffffffu,
427 deUint32 reference = 0);
430 DepthStencilState (vk::VkBool32 depthTestEnable = false,
431 vk::VkBool32 depthWriteEnable = false,
432 vk::VkCompareOp depthCompareOp = vk::VK_COMPARE_OP_ALWAYS,
433 vk::VkBool32 depthBoundsTestEnable = false,
434 vk::VkBool32 stencilTestEnable = false,
435 StencilOpState front = StencilOpState(),
436 StencilOpState back = StencilOpState(),
437 float minDepthBounds = -1.0f,
438 float maxDepthBounds = 1.0f);
441 class PipelineShaderStage : public vk::VkPipelineShaderStageCreateInfo
444 PipelineShaderStage (vk::VkShaderModule shaderModule, const char* pName, vk::VkShaderStageFlagBits stage);
447 class DynamicState : public vk::VkPipelineDynamicStateCreateInfo
450 DynamicState (const std::vector<vk::VkDynamicState>& dynamicStates = std::vector<vk::VkDynamicState>(0));
452 DynamicState (const DynamicState& other);
453 DynamicState& operator= (const DynamicState& other);
455 std::vector<vk::VkDynamicState> m_dynamicStates;
458 PipelineCreateInfo (vk::VkPipelineLayout layout,
459 vk::VkRenderPass renderPass,
461 vk::VkPipelineCreateFlags flags);
463 PipelineCreateInfo& addShader (const vk::VkPipelineShaderStageCreateInfo& shader);
465 PipelineCreateInfo& addState (const vk::VkPipelineVertexInputStateCreateInfo& state);
466 PipelineCreateInfo& addState (const vk::VkPipelineInputAssemblyStateCreateInfo& state);
467 PipelineCreateInfo& addState (const vk::VkPipelineColorBlendStateCreateInfo& state);
468 PipelineCreateInfo& addState (const vk::VkPipelineViewportStateCreateInfo& state);
469 PipelineCreateInfo& addState (const vk::VkPipelineDepthStencilStateCreateInfo& state);
470 PipelineCreateInfo& addState (const vk::VkPipelineTessellationStateCreateInfo& state);
471 PipelineCreateInfo& addState (const vk::VkPipelineRasterizationStateCreateInfo& state);
472 PipelineCreateInfo& addState (const vk::VkPipelineMultisampleStateCreateInfo& state);
473 PipelineCreateInfo& addState (const vk::VkPipelineDynamicStateCreateInfo& state);
476 std::vector<vk::VkPipelineShaderStageCreateInfo> m_shaders;
478 vk::VkPipelineVertexInputStateCreateInfo m_vertexInputState;
479 vk::VkPipelineInputAssemblyStateCreateInfo m_inputAssemblyState;
480 std::vector<vk::VkPipelineColorBlendAttachmentState> m_colorBlendStateAttachments;
481 vk::VkPipelineColorBlendStateCreateInfo m_colorBlendState;
482 vk::VkPipelineViewportStateCreateInfo m_viewportState;
483 vk::VkPipelineDepthStencilStateCreateInfo m_dynamicDepthStencilState;
484 vk::VkPipelineTessellationStateCreateInfo m_tessState;
485 vk::VkPipelineRasterizationStateCreateInfo m_rasterState;
486 vk::VkPipelineMultisampleStateCreateInfo m_multisampleState;
487 vk::VkPipelineDynamicStateCreateInfo m_dynamicState;
489 std::vector<vk::VkDynamicState> m_dynamicStates;
491 std::vector<vk::VkViewport> m_viewports;
492 std::vector<vk::VkRect2D> m_scissors;
494 std::vector<vk::VkSampleMask> m_multisampleStateSampleMask;
497 class SamplerCreateInfo : public vk::VkSamplerCreateInfo
500 SamplerCreateInfo (vk::VkFilter magFilter = vk::VK_FILTER_NEAREST,
501 vk::VkFilter minFilter = vk::VK_FILTER_NEAREST,
502 vk::VkSamplerMipmapMode mipmapMode = vk::VK_SAMPLER_MIPMAP_MODE_NEAREST,
503 vk::VkSamplerAddressMode addressU = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
504 vk::VkSamplerAddressMode addressV = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
505 vk::VkSamplerAddressMode addressW = vk::VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT,
506 float mipLodBias = 0.0f,
507 vk::VkBool32 anisotropyEnable = vk::VK_FALSE,
508 float maxAnisotropy = 1.0f,
509 vk::VkBool32 compareEnable = false,
510 vk::VkCompareOp compareOp = vk::VK_COMPARE_OP_ALWAYS,
512 float maxLod = 16.0f,
513 vk::VkBorderColor borderColor = vk::VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE,
514 vk::VkBool32 unnormalizedCoordinates = false);
520 #endif // _VKTDRAWCREATEINFOUTIL_HPP