1 #ifndef _VKTDRAWCREATEINFO_UTIL_HPP
2 #define _VKTDRAWCREATEINFO_UTIL_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"
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;
113 class ImageCreateInfo : public vk::VkImageCreateInfo
116 ImageCreateInfo ( vk::VkImageType imageType,
118 vk::VkExtent3D extent,
120 deUint32 arrayLayers,
121 vk::VkSampleCountFlagBits samples,
122 vk::VkImageTiling tiling,
123 vk::VkImageUsageFlags usage,
124 vk::VkSharingMode sharingMode = vk::VK_SHARING_MODE_EXCLUSIVE,
125 deUint32 queueFamilyIndexCount = 0,
126 const deUint32* pQueueFamilyIndices = DE_NULL,
127 vk::VkImageCreateFlags flags = 0,
128 vk::VkImageLayout initialLayout = vk::VK_IMAGE_LAYOUT_UNDEFINED);
131 ImageCreateInfo (const ImageCreateInfo &other);
132 ImageCreateInfo &operator= (const ImageCreateInfo &other);
134 std::vector<deUint32> m_queueFamilyIndices;
137 class FramebufferCreateInfo : public vk::VkFramebufferCreateInfo
140 FramebufferCreateInfo ( vk::VkRenderPass renderPass,
141 const std::vector<vk::VkImageView>& attachments,
147 class AttachmentDescription : public vk::VkAttachmentDescription
150 AttachmentDescription ( vk::VkFormat format,
151 vk::VkSampleCountFlagBits samples,
152 vk::VkAttachmentLoadOp loadOp,
153 vk::VkAttachmentStoreOp storeOp,
154 vk::VkAttachmentLoadOp stencilLoadOp,
155 vk::VkAttachmentStoreOp stencilStoreOp,
156 vk::VkImageLayout initialLayout,
157 vk::VkImageLayout finalLayout);
159 AttachmentDescription (const vk::VkAttachmentDescription &);
162 class AttachmentReference : public vk::VkAttachmentReference
165 AttachmentReference (deUint32 attachment, vk::VkImageLayout layout);
166 AttachmentReference (void);
169 class SubpassDescription : public vk::VkSubpassDescription
172 SubpassDescription ( vk::VkPipelineBindPoint pipelineBindPoint,
173 vk::VkSubpassDescriptionFlags flags,
174 deUint32 inputAttachmentCount,
175 const vk::VkAttachmentReference* inputAttachments,
176 deUint32 colorAttachmentCount,
177 const vk::VkAttachmentReference* colorAttachments,
178 const vk::VkAttachmentReference* resolveAttachments,
179 vk::VkAttachmentReference depthStencilAttachment,
180 deUint32 preserveAttachmentCount,
181 const vk::VkAttachmentReference* preserveAttachments);
183 SubpassDescription (const vk::VkSubpassDescription& other);
184 SubpassDescription (const SubpassDescription& other);
185 SubpassDescription& operator= (const SubpassDescription& other);
188 std::vector<vk::VkAttachmentReference> m_inputAttachments;
189 std::vector<vk::VkAttachmentReference> m_colorAttachments;
190 std::vector<vk::VkAttachmentReference> m_resolveAttachments;
191 std::vector<vk::VkAttachmentReference> m_preserveAttachments;
193 vk::VkAttachmentReference m_depthStencilAttachment;
196 class SubpassDependency : public vk::VkSubpassDependency
199 SubpassDependency ( deUint32 srcSubpass,
201 vk::VkPipelineStageFlags srcStageMask,
202 vk::VkPipelineStageFlags dstStageMask,
203 vk::VkAccessFlags srcAccessMask,
204 vk::VkAccessFlags dstAccessMask,
205 vk::VkDependencyFlags dependencyFlags);
207 SubpassDependency (const vk::VkSubpassDependency& other);
210 class RenderPassCreateInfo : public vk::VkRenderPassCreateInfo
213 RenderPassCreateInfo ( const std::vector<vk::VkAttachmentDescription>& attachments,
214 const std::vector<vk::VkSubpassDescription>& subpasses,
215 const std::vector<vk::VkSubpassDependency>& dependiences = std::vector<vk::VkSubpassDependency>());
217 RenderPassCreateInfo ( deUint32 attachmentCount = 0,
218 const vk::VkAttachmentDescription* pAttachments = DE_NULL,
219 deUint32 subpassCount = 0,
220 const vk::VkSubpassDescription* pSubpasses = DE_NULL,
221 deUint32 dependencyCount = 0,
222 const vk::VkSubpassDependency* pDependiences = DE_NULL);
224 void addAttachment (vk::VkAttachmentDescription attachment);
225 void addSubpass (vk::VkSubpassDescription subpass);
226 void addDependency (vk::VkSubpassDependency dependency);
229 std::vector<AttachmentDescription> m_attachments;
230 std::vector<SubpassDescription> m_subpasses;
231 std::vector<SubpassDependency> m_dependiences;
233 std::vector<vk::VkAttachmentDescription> m_attachmentsStructs;
234 std::vector<vk::VkSubpassDescription> m_subpassesStructs;
235 std::vector<vk::VkSubpassDependency> m_dependiencesStructs;
237 RenderPassCreateInfo (const RenderPassCreateInfo &other); //Not allowed!
238 RenderPassCreateInfo &operator= (const RenderPassCreateInfo &other); //Not allowed!
241 class RenderPassBeginInfo : public vk::VkRenderPassBeginInfo
244 RenderPassBeginInfo ( vk::VkRenderPass renderPass,
245 vk::VkFramebuffer framebuffer,
246 vk::VkRect2D renderArea,
247 const std::vector<vk::VkClearValue>& clearValues = std::vector<vk::VkClearValue>());
250 std::vector<vk::VkClearValue> m_clearValues;
252 RenderPassBeginInfo (const RenderPassBeginInfo &other); //Not allowed!
253 RenderPassBeginInfo &operator= (const RenderPassBeginInfo &other); //Not allowed!
256 class CmdPoolCreateInfo : public vk::VkCommandPoolCreateInfo
259 CmdPoolCreateInfo (deUint32 queueFamilyIndex,
260 vk::VkCommandPoolCreateFlags flags = vk::VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT);
263 class CmdBufferBeginInfo : public vk::VkCommandBufferBeginInfo
266 CmdBufferBeginInfo (vk::VkCommandBufferUsageFlags flags = 0);
267 CmdBufferBeginInfo (vk::VkRenderPass renderPass,
269 vk::VkFramebuffer framebuffer,
270 vk::VkCommandBufferUsageFlags flags = 0,
271 bool occlusionQueryEnable = false,
272 vk::VkQueryControlFlags queryFlags = 0u,
273 vk::VkQueryPipelineStatisticFlags pipelineStatistics = 0u);
277 class DescriptorPoolSize : public vk::VkDescriptorPoolSize
280 DescriptorPoolSize (vk::VkDescriptorType _type, deUint32 _descriptorCount)
283 descriptorCount = _descriptorCount;
287 class DescriptorPoolCreateInfo : public vk::VkDescriptorPoolCreateInfo
290 DescriptorPoolCreateInfo ( const std::vector<vk::VkDescriptorPoolSize>& poolSizeCounts,
\r
291 vk::VkDescriptorPoolCreateFlags flags,
\r
294 DescriptorPoolCreateInfo& addDescriptors (vk::VkDescriptorType type, deUint32 count);
297 std::vector<vk::VkDescriptorPoolSize> m_poolSizeCounts;
301 class DescriptorSetLayoutCreateInfo : public vk::VkDescriptorSetLayoutCreateInfo
304 DescriptorSetLayoutCreateInfo (deUint32 bindingCount, const vk::VkDescriptorSetLayoutBinding* pBindings);
308 class PipelineLayoutCreateInfo : public vk::VkPipelineLayoutCreateInfo
311 PipelineLayoutCreateInfo ( deUint32 descriptorSetCount,
312 const vk::VkDescriptorSetLayout* pSetLayouts,
313 deUint32 pushConstantRangeCount = 0,
314 const vk::VkPushConstantRange* pPushConstantRanges = DE_NULL);
316 PipelineLayoutCreateInfo ( const std::vector<vk::VkDescriptorSetLayout>& setLayouts = std::vector<vk::VkDescriptorSetLayout>(),
317 deUint32 pushConstantRangeCount = 0,
318 const vk::VkPushConstantRange* pPushConstantRanges = DE_NULL);
321 std::vector<vk::VkDescriptorSetLayout> m_setLayouts;
322 std::vector<vk::VkPushConstantRange> m_pushConstantRanges;
325 class PipelineCreateInfo : public vk::VkGraphicsPipelineCreateInfo
328 class VertexInputState : public vk::VkPipelineVertexInputStateCreateInfo
331 VertexInputState ( deUint32 vertexBindingDescriptionCount = 0,
332 const vk::VkVertexInputBindingDescription* pVertexBindingDescriptions = NULL,
333 deUint32 vertexAttributeDescriptionCount = 0,
334 const vk::VkVertexInputAttributeDescription* pVertexAttributeDescriptions = NULL);
337 class InputAssemblerState : public vk::VkPipelineInputAssemblyStateCreateInfo
340 InputAssemblerState (vk::VkPrimitiveTopology topology, vk::VkBool32 primitiveRestartEnable = false);
343 class TesselationState : public vk::VkPipelineTessellationStateCreateInfo
346 TesselationState (deUint32 patchControlPoints = 0);
349 class ViewportState : public vk::VkPipelineViewportStateCreateInfo
352 ViewportState ( deUint32 viewportCount,
353 std::vector<vk::VkViewport> viewports = std::vector<vk::VkViewport>(0),
354 std::vector<vk::VkRect2D> scissors = std::vector<vk::VkRect2D>(0));
356 ViewportState (const ViewportState &other);
357 ViewportState &operator= (const ViewportState &other);
359 std::vector<vk::VkViewport> m_viewports;
360 std::vector<vk::VkRect2D> m_scissors;
363 class RasterizerState : public vk::VkPipelineRasterizationStateCreateInfo
366 RasterizerState ( vk::VkBool32 depthClampEnable = false,
367 vk::VkBool32 rasterizerDiscardEnable = false,
368 vk::VkPolygonMode polygonMode = vk::VK_POLYGON_MODE_FILL,
369 vk::VkCullModeFlags cullMode = vk::VK_CULL_MODE_NONE,
370 vk::VkFrontFace frontFace = vk::VK_FRONT_FACE_CLOCKWISE,
371 vk::VkBool32 depthBiasEnable = true,
\r
372 float depthBiasConstantFactor = 0.0f,
373 float depthBiasClamp = 0.0f,
374 float depthBiasSlopeFactor = 0.0f,
375 float lineWidth = 1.0f);
378 class MultiSampleState : public vk::VkPipelineMultisampleStateCreateInfo
381 MultiSampleState ( vk::VkSampleCountFlagBits rasterizationSamples = vk::VK_SAMPLE_COUNT_1_BIT,
382 vk::VkBool32 sampleShadingEnable = false,
383 float minSampleShading = 0.0f,
384 const std::vector<vk::VkSampleMask>& sampleMask = std::vector<vk::VkSampleMask>(1, 0xffffffff),
385 bool alphaToCoverageEnable = false,
386 bool alphaToOneEnable = false);
388 MultiSampleState (const MultiSampleState &other);
389 MultiSampleState &operator= (const MultiSampleState &other);
392 std::vector<vk::VkSampleMask> m_sampleMask;
395 class ColorBlendState : public vk::VkPipelineColorBlendStateCreateInfo
398 class Attachment : public vk::VkPipelineColorBlendAttachmentState
401 Attachment (vk::VkBool32 blendEnable = false,
402 vk::VkBlendFactor srcColorBlendFactor = vk::VK_BLEND_FACTOR_SRC_COLOR,
403 vk::VkBlendFactor dstColorBlendFactor = vk::VK_BLEND_FACTOR_DST_COLOR,
404 vk::VkBlendOp colorBlendOp = vk::VK_BLEND_OP_ADD,
405 vk::VkBlendFactor srcAlphaBlendFactor = vk::VK_BLEND_FACTOR_SRC_COLOR,
406 vk::VkBlendFactor dstAlphaBlendFactor = vk::VK_BLEND_FACTOR_DST_COLOR,
407 vk::VkBlendOp alphaBlendOp = vk::VK_BLEND_OP_ADD,
408 deUint8 colorWriteMask = 0xff);
411 ColorBlendState ( const std::vector<vk::VkPipelineColorBlendAttachmentState>& attachments,
412 vk::VkBool32 alphaToCoverageEnable = false,
413 vk::VkLogicOp logicOp = vk::VK_LOGIC_OP_COPY);
415 ColorBlendState ( deUint32 attachmentCount,
416 const vk::VkPipelineColorBlendAttachmentState* attachments,
417 vk::VkBool32 logicOpEnable = false,
418 vk::VkLogicOp logicOp = vk::VK_LOGIC_OP_COPY);
420 ColorBlendState (const vk::VkPipelineColorBlendStateCreateInfo &createInfo);
421 ColorBlendState (const ColorBlendState &createInfo, std::vector<float> blendConstants = std::vector<float>(4));
424 std::vector<vk::VkPipelineColorBlendAttachmentState> m_attachments;
427 class DepthStencilState : public vk::VkPipelineDepthStencilStateCreateInfo
430 class StencilOpState : public vk::VkStencilOpState
433 StencilOpState (vk::VkStencilOp failOp = vk::VK_STENCIL_OP_REPLACE,
434 vk::VkStencilOp passOp = vk::VK_STENCIL_OP_REPLACE,
435 vk::VkStencilOp depthFailOp = vk::VK_STENCIL_OP_REPLACE,
436 vk::VkCompareOp compareOp = vk::VK_COMPARE_OP_ALWAYS,
437 deUint32 compareMask = 0xffffffffu,
\r
438 deUint32 writeMask = 0xffffffffu,
\r
439 deUint32 reference = 0);
442 DepthStencilState ( vk::VkBool32 depthTestEnable = false,
443 vk::VkBool32 depthWriteEnable = false,
444 vk::VkCompareOp depthCompareOp = vk::VK_COMPARE_OP_ALWAYS,
445 vk::VkBool32 depthBoundsTestEnable = false,
446 vk::VkBool32 stencilTestEnable = false,
447 StencilOpState front = StencilOpState(),
448 StencilOpState back = StencilOpState(),
449 float minDepthBounds = -1.0f,
450 float maxDepthBounds = 1.0f);
453 class PipelineShaderStage : public vk::VkPipelineShaderStageCreateInfo
456 PipelineShaderStage (vk::VkShaderModule shaderModule, const char* _pName, vk::VkShaderStageFlagBits stage);
459 class DynamicState : public vk::VkPipelineDynamicStateCreateInfo
462 DynamicState (const std::vector<vk::VkDynamicState>& dynamicStates = std::vector<vk::VkDynamicState>(0));
464 DynamicState (const DynamicState &other);
465 DynamicState &operator= (const DynamicState &other);
467 std::vector<vk::VkDynamicState> m_dynamicStates;
470 PipelineCreateInfo(vk::VkPipelineLayout layout, vk::VkRenderPass renderPass, int subpass, 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 // _VKTDRAWCREATEINFO_UTIL_HPP