1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2016 The Khronos Group Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Pipeline specialization constants test utilities
22 *//*--------------------------------------------------------------------*/
23
24 #include "vktPipelineSpecConstantUtil.hpp"
25 #include "vkTypeUtil.hpp"
26 #include <vector>
27
28 namespace vkt
29 {
30 namespace pipeline
31 {
32 using namespace vk;
33
makeImageCreateInfo(const tcu::IVec2 & size,const VkFormat format,const VkImageUsageFlags usage)34 VkImageCreateInfo makeImageCreateInfo (const tcu::IVec2& size, const VkFormat format, const VkImageUsageFlags usage)
35 {
36 const VkImageCreateInfo imageInfo =
37 {
38 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // VkStructureType sType;
39 DE_NULL, // const void* pNext;
40 (VkImageCreateFlags)0, // VkImageCreateFlags flags;
41 VK_IMAGE_TYPE_2D, // VkImageType imageType;
42 format, // VkFormat format;
43 makeExtent3D(size.x(), size.y(), 1), // VkExtent3D extent;
44 1u, // uint32_t mipLevels;
45 1u, // uint32_t arrayLayers;
46 VK_SAMPLE_COUNT_1_BIT, // VkSampleCountFlagBits samples;
47 VK_IMAGE_TILING_OPTIMAL, // VkImageTiling tiling;
48 usage, // VkImageUsageFlags usage;
49 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode sharingMode;
50 0u, // uint32_t queueFamilyIndexCount;
51 DE_NULL, // const uint32_t* pQueueFamilyIndices;
52 VK_IMAGE_LAYOUT_UNDEFINED, // VkImageLayout initialLayout;
53 };
54 return imageInfo;
55 }
56
requireFeatures(Context & context,const FeatureFlags flags)57 void requireFeatures (Context& context, const FeatureFlags flags)
58 {
59 if (flags & FEATURE_TESSELLATION_SHADER)
60 context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_TESSELLATION_SHADER);
61
62 if (flags & FEATURE_GEOMETRY_SHADER)
63 context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_GEOMETRY_SHADER);
64
65 if (flags & FEATURE_SHADER_FLOAT_64)
66 context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_SHADER_FLOAT64);
67
68 if (flags & FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS)
69 context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_VERTEX_PIPELINE_STORES_AND_ATOMICS);
70
71 if (flags & FEATURE_FRAGMENT_STORES_AND_ATOMICS)
72 context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_FRAGMENT_STORES_AND_ATOMICS);
73
74 if (flags & FEATURE_SHADER_INT_64)
75 context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_SHADER_INT64);
76
77 if (flags & FEATURE_SHADER_INT_16)
78 context.requireDeviceCoreFeature(DEVICE_CORE_FEATURE_SHADER_INT16);
79
80 if (flags & (FEATURE_SHADER_FLOAT_16 | FEATURE_SHADER_INT_8))
81 {
82 const auto extraFeatures = context.getShaderFloat16Int8Features();
83
84 if ((flags & FEATURE_SHADER_INT_8) != 0u && !extraFeatures.shaderInt8)
85 TCU_THROW(NotSupportedError, "8-bit integers not supported in shaders");
86
87 if ((flags & FEATURE_SHADER_FLOAT_16) != 0u && !extraFeatures.shaderFloat16)
88 TCU_THROW(NotSupportedError, "16-bit floats not supported in shaders");
89 }
90
91 // Check needed storage features.
92 if (flags & (FEATURE_SHADER_INT_16 | FEATURE_SHADER_FLOAT_16))
93 {
94 const auto features = context.get16BitStorageFeatures();
95 if (!features.storageBuffer16BitAccess)
96 TCU_THROW(NotSupportedError, "16-bit access in storage buffers not supported");
97 }
98
99 if (flags & FEATURE_SHADER_INT_8)
100 {
101 const auto features = context.get8BitStorageFeatures();
102 if (!features.storageBuffer8BitAccess)
103 TCU_THROW(NotSupportedError, "8-bit access in storage buffers not supported");
104 }
105 }
106
107 } // pipeline
108 } // vkt
109