--- /dev/null
+/*-------------------------------------------------------------------------
+ * Vulkan CTS Framework
+ * --------------------
+ *
+ * Copyright (c) 2015 Google Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice(s) and this permission notice shall be
+ * included in all copies or substantial portions of the Materials.
+ *
+ * The Materials are Confidential Information as defined by the
+ * Khronos Membership Agreement until designated non-confidential by
+ * Khronos, at which point this condition clause shall be removed.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//*!
+ * \file
+ * \brief Utilities for creating commonly used composite types.
+ *//*--------------------------------------------------------------------*/
+
+#include "vkTypeUtil.hpp"
+
+DE_EMPTY_CPP_FILE
--- /dev/null
+#ifndef _VKTYPEUTIL_HPP
+#define _VKTYPEUTIL_HPP
+/*-------------------------------------------------------------------------
+ * Vulkan CTS Framework
+ * --------------------
+ *
+ * Copyright (c) 2015 Google Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and/or associated documentation files (the
+ * "Materials"), to deal in the Materials without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Materials, and to
+ * permit persons to whom the Materials are furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice(s) and this permission notice shall be
+ * included in all copies or substantial portions of the Materials.
+ *
+ * The Materials are Confidential Information as defined by the
+ * Khronos Membership Agreement until designated non-confidential by
+ * Khronos, at which point this condition clause shall be removed.
+ *
+ * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+ *
+ *//*!
+ * \file
+ * \brief Utilities for creating commonly used composite types.
+ *//*--------------------------------------------------------------------*/
+
+#include "vkDefs.hpp"
+
+namespace vk
+{
+
+#include "vkTypeUtil.inl"
+
+inline VkClearValue makeClearValueColorF32 (float r, float g, float b, float a)
+{
+ VkClearValue v;
+ v.color.f32[0] = r;
+ v.color.f32[1] = g;
+ v.color.f32[2] = b;
+ v.color.f32[3] = a;
+ return v;
+}
+
+inline VkChannelMapping makeChannelMappingRGBA (void)
+{
+ return makeChannelMapping(VK_CHANNEL_SWIZZLE_R, VK_CHANNEL_SWIZZLE_G, VK_CHANNEL_SWIZZLE_B, VK_CHANNEL_SWIZZLE_A);
+}
+
+} // vk
+
+#endif // _VKTYPEUTIL_HPP
--- /dev/null
+/* WARNING: This is auto-generated file. Do not modify, since changes will
+ * be lost! Modify the generating script instead.
+ */
+
+inline VkAllocCallbacks makeAllocCallbacks (void* pUserData, PFN_vkAllocFunction pfnAlloc, PFN_vkFreeFunction pfnFree)
+{
+ VkAllocCallbacks res;
+ res.pUserData = pUserData;
+ res.pfnAlloc = pfnAlloc;
+ res.pfnFree = pfnFree;
+ return res;
+}
+
+inline VkPhysicalDeviceQueueProperties makePhysicalDeviceQueueProperties (VkQueueFlags queueFlags, deUint32 queueCount, VkBool32 supportsTimestamps)
+{
+ VkPhysicalDeviceQueueProperties res;
+ res.queueFlags = queueFlags;
+ res.queueCount = queueCount;
+ res.supportsTimestamps = supportsTimestamps;
+ return res;
+}
+
+inline VkDeviceQueueCreateInfo makeDeviceQueueCreateInfo (deUint32 queueFamilyIndex, deUint32 queueCount)
+{
+ VkDeviceQueueCreateInfo res;
+ res.queueFamilyIndex = queueFamilyIndex;
+ res.queueCount = queueCount;
+ return res;
+}
+
+inline VkMemoryRequirements makeMemoryRequirements (VkDeviceSize size, VkDeviceSize alignment, deUint32 memoryTypeBits)
+{
+ VkMemoryRequirements res;
+ res.size = size;
+ res.alignment = alignment;
+ res.memoryTypeBits = memoryTypeBits;
+ return res;
+}
+
+inline VkExtent3D makeExtent3D (deInt32 width, deInt32 height, deInt32 depth)
+{
+ VkExtent3D res;
+ res.width = width;
+ res.height = height;
+ res.depth = depth;
+ return res;
+}
+
+inline VkSparseMemoryBindInfo makeSparseMemoryBindInfo (VkDeviceSize rangeOffset, VkDeviceSize rangeSize, VkDeviceSize memOffset, VkDeviceMemory mem, VkSparseMemoryBindFlags flags)
+{
+ VkSparseMemoryBindInfo res;
+ res.rangeOffset = rangeOffset;
+ res.rangeSize = rangeSize;
+ res.memOffset = memOffset;
+ res.mem = mem;
+ res.flags = flags;
+ return res;
+}
+
+inline VkImageSubresource makeImageSubresource (VkImageAspect aspect, deUint32 mipLevel, deUint32 arraySlice)
+{
+ VkImageSubresource res;
+ res.aspect = aspect;
+ res.mipLevel = mipLevel;
+ res.arraySlice = arraySlice;
+ return res;
+}
+
+inline VkOffset3D makeOffset3D (deInt32 x, deInt32 y, deInt32 z)
+{
+ VkOffset3D res;
+ res.x = x;
+ res.y = y;
+ res.z = z;
+ return res;
+}
+
+inline VkSubresourceLayout makeSubresourceLayout (VkDeviceSize offset, VkDeviceSize size, VkDeviceSize rowPitch, VkDeviceSize depthPitch)
+{
+ VkSubresourceLayout res;
+ res.offset = offset;
+ res.size = size;
+ res.rowPitch = rowPitch;
+ res.depthPitch = depthPitch;
+ return res;
+}
+
+inline VkChannelMapping makeChannelMapping (VkChannelSwizzle r, VkChannelSwizzle g, VkChannelSwizzle b, VkChannelSwizzle a)
+{
+ VkChannelMapping res;
+ res.r = r;
+ res.g = g;
+ res.b = b;
+ res.a = a;
+ return res;
+}
+
+inline VkImageSubresourceRange makeImageSubresourceRange (VkImageAspect aspect, deUint32 baseMipLevel, deUint32 mipLevels, deUint32 baseArraySlice, deUint32 arraySize)
+{
+ VkImageSubresourceRange res;
+ res.aspect = aspect;
+ res.baseMipLevel = baseMipLevel;
+ res.mipLevels = mipLevels;
+ res.baseArraySlice = baseArraySlice;
+ res.arraySize = arraySize;
+ return res;
+}
+
+inline VkSpecializationMapEntry makeSpecializationMapEntry (deUint32 constantId, deUintptr size, deUint32 offset)
+{
+ VkSpecializationMapEntry res;
+ res.constantId = constantId;
+ res.size = size;
+ res.offset = offset;
+ return res;
+}
+
+inline VkSpecializationInfo makeSpecializationInfo (deUint32 mapEntryCount, const VkSpecializationMapEntry* pMap, deUintptr dataSize, const void* pData)
+{
+ VkSpecializationInfo res;
+ res.mapEntryCount = mapEntryCount;
+ res.pMap = pMap;
+ res.dataSize = dataSize;
+ res.pData = pData;
+ return res;
+}
+
+inline VkVertexInputBindingDescription makeVertexInputBindingDescription (deUint32 binding, deUint32 strideInBytes, VkVertexInputStepRate stepRate)
+{
+ VkVertexInputBindingDescription res;
+ res.binding = binding;
+ res.strideInBytes = strideInBytes;
+ res.stepRate = stepRate;
+ return res;
+}
+
+inline VkVertexInputAttributeDescription makeVertexInputAttributeDescription (deUint32 location, deUint32 binding, VkFormat format, deUint32 offsetInBytes)
+{
+ VkVertexInputAttributeDescription res;
+ res.location = location;
+ res.binding = binding;
+ res.format = format;
+ res.offsetInBytes = offsetInBytes;
+ return res;
+}
+
+inline VkStencilOpState makeStencilOpState (VkStencilOp stencilFailOp, VkStencilOp stencilPassOp, VkStencilOp stencilDepthFailOp, VkCompareOp stencilCompareOp)
+{
+ VkStencilOpState res;
+ res.stencilFailOp = stencilFailOp;
+ res.stencilPassOp = stencilPassOp;
+ res.stencilDepthFailOp = stencilDepthFailOp;
+ res.stencilCompareOp = stencilCompareOp;
+ return res;
+}
+
+inline VkPipelineColorBlendAttachmentState makePipelineColorBlendAttachmentState (VkBool32 blendEnable, VkBlend srcBlendColor, VkBlend destBlendColor, VkBlendOp blendOpColor, VkBlend srcBlendAlpha, VkBlend destBlendAlpha, VkBlendOp blendOpAlpha, VkChannelFlags channelWriteMask)
+{
+ VkPipelineColorBlendAttachmentState res;
+ res.blendEnable = blendEnable;
+ res.srcBlendColor = srcBlendColor;
+ res.destBlendColor = destBlendColor;
+ res.blendOpColor = blendOpColor;
+ res.srcBlendAlpha = srcBlendAlpha;
+ res.destBlendAlpha = destBlendAlpha;
+ res.blendOpAlpha = blendOpAlpha;
+ res.channelWriteMask = channelWriteMask;
+ return res;
+}
+
+inline VkPushConstantRange makePushConstantRange (VkShaderStageFlags stageFlags, deUint32 start, deUint32 length)
+{
+ VkPushConstantRange res;
+ res.stageFlags = stageFlags;
+ res.start = start;
+ res.length = length;
+ return res;
+}
+
+inline VkDescriptorSetLayoutBinding makeDescriptorSetLayoutBinding (VkDescriptorType descriptorType, deUint32 arraySize, VkShaderStageFlags stageFlags, const VkSampler* pImmutableSamplers)
+{
+ VkDescriptorSetLayoutBinding res;
+ res.descriptorType = descriptorType;
+ res.arraySize = arraySize;
+ res.stageFlags = stageFlags;
+ res.pImmutableSamplers = pImmutableSamplers;
+ return res;
+}
+
+inline VkDescriptorTypeCount makeDescriptorTypeCount (VkDescriptorType type, deUint32 count)
+{
+ VkDescriptorTypeCount res;
+ res.type = type;
+ res.count = count;
+ return res;
+}
+
+inline VkDescriptorInfo makeDescriptorInfo (VkBufferView bufferView, VkSampler sampler, VkImageView imageView, VkAttachmentView attachmentView, VkImageLayout imageLayout)
+{
+ VkDescriptorInfo res;
+ res.bufferView = bufferView;
+ res.sampler = sampler;
+ res.imageView = imageView;
+ res.attachmentView = attachmentView;
+ res.imageLayout = imageLayout;
+ return res;
+}
+
+inline VkViewport makeViewport (float originX, float originY, float width, float height, float minDepth, float maxDepth)
+{
+ VkViewport res;
+ res.originX = originX;
+ res.originY = originY;
+ res.width = width;
+ res.height = height;
+ res.minDepth = minDepth;
+ res.maxDepth = maxDepth;
+ return res;
+}
+
+inline VkOffset2D makeOffset2D (deInt32 x, deInt32 y)
+{
+ VkOffset2D res;
+ res.x = x;
+ res.y = y;
+ return res;
+}
+
+inline VkExtent2D makeExtent2D (deInt32 width, deInt32 height)
+{
+ VkExtent2D res;
+ res.width = width;
+ res.height = height;
+ return res;
+}
+
+inline VkAttachmentBindInfo makeAttachmentBindInfo (VkAttachmentView view, VkImageLayout layout)
+{
+ VkAttachmentBindInfo res;
+ res.view = view;
+ res.layout = layout;
+ return res;
+}
+
+inline VkAttachmentReference makeAttachmentReference (deUint32 attachment, VkImageLayout layout)
+{
+ VkAttachmentReference res;
+ res.attachment = attachment;
+ res.layout = layout;
+ return res;
+}
+
+inline VkBufferCopy makeBufferCopy (VkDeviceSize srcOffset, VkDeviceSize destOffset, VkDeviceSize copySize)
+{
+ VkBufferCopy res;
+ res.srcOffset = srcOffset;
+ res.destOffset = destOffset;
+ res.copySize = copySize;
+ return res;
+}
+
+inline VkClearDepthStencilValue makeClearDepthStencilValue (float depth, deUint32 stencil)
+{
+ VkClearDepthStencilValue res;
+ res.depth = depth;
+ res.stencil = stencil;
+ return res;
+}
+
+inline VkDispatchIndirectCmd makeDispatchIndirectCmd (deUint32 x, deUint32 y, deUint32 z)
+{
+ VkDispatchIndirectCmd res;
+ res.x = x;
+ res.y = y;
+ res.z = z;
+ return res;
+}
+
+inline VkDrawIndexedIndirectCmd makeDrawIndexedIndirectCmd (deUint32 indexCount, deUint32 instanceCount, deUint32 firstIndex, deInt32 vertexOffset, deUint32 firstInstance)
+{
+ VkDrawIndexedIndirectCmd res;
+ res.indexCount = indexCount;
+ res.instanceCount = instanceCount;
+ res.firstIndex = firstIndex;
+ res.vertexOffset = vertexOffset;
+ res.firstInstance = firstInstance;
+ return res;
+}
+
+inline VkDrawIndirectCmd makeDrawIndirectCmd (deUint32 vertexCount, deUint32 instanceCount, deUint32 firstVertex, deUint32 firstInstance)
+{
+ VkDrawIndirectCmd res;
+ res.vertexCount = vertexCount;
+ res.instanceCount = instanceCount;
+ res.firstVertex = firstVertex;
+ res.firstInstance = firstInstance;
+ return res;
+}
writeInlFile(filename, INL_HEADER, genNullDriverImpl())
+def writeTypeUtil (api, filename):
+ # Structs filled by API queries are not often used in test code
+ QUERY_RESULT_TYPES = set([
+ "VkPhysicalDeviceFeatures",
+ "VkPhysicalDeviceLimits",
+ "VkFormatProperties",
+ "VkImageFormatProperties",
+ "VkPhysicalDeviceSparseProperties",
+ "VkQueueFamilyProperties",
+ "VkMemoryType",
+ "VkMemoryHeap",
+ ])
+ COMPOSITE_TYPES = set([t.name for t in api.compositeTypes])
+
+ def isSimpleStruct (type):
+ def hasArrayMember (type):
+ for member in type.members:
+ if "[" in member.name:
+ return True
+ return False
+
+ def hasCompositeMember (type):
+ for member in type.members:
+ if member.type in COMPOSITE_TYPES:
+ return True
+ return False
+
+ return type.typeClass == CompositeType.CLASS_STRUCT and \
+ type.members[0].type != "VkStructureType" and \
+ not type.name in QUERY_RESULT_TYPES and \
+ not hasArrayMember(type) and \
+ not hasCompositeMember(type)
+
+ def gen ():
+ for type in api.compositeTypes:
+ if not isSimpleStruct(type):
+ continue
+
+ yield ""
+ yield "inline %s make%s (%s)" % (type.name, type.name[2:], argListToStr(type.members))
+ yield "{"
+ yield "\t%s res;" % type.name
+ for line in indentLines(["\tres.%s\t= %s;" % (m.name, m.name) for m in type.members]):
+ yield line
+ yield "\treturn res;"
+ yield "}"
+
+ writeInlFile(filename, INL_HEADER, gen())
+
if __name__ == "__main__":
src = readFile(sys.argv[1])
api = parseAPI(src)
writeRefUtilProto (api, os.path.join(VULKAN_DIR, "vkRefUtil.inl"))
writeRefUtilImpl (api, os.path.join(VULKAN_DIR, "vkRefUtilImpl.inl"))
writeNullDriverImpl (api, os.path.join(VULKAN_DIR, "vkNullDriverImpl.inl"))
+ writeTypeUtil (api, os.path.join(VULKAN_DIR, "vkTypeUtil.inl"))