1 /*------------------------------------------------------------------------
2 * Vulkan Conformance Tests
3 * ------------------------
4 *
5 * Copyright (c) 2023 LunarG, Inc.
6 * Copyright (c) 2023 Nintendo
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 *//*!
21 * \file
22 * \brief Shader Object Test Case Utilities
23 *//*--------------------------------------------------------------------*/
24
25 #include "vkShaderObjectUtil.hpp"
26 #include "vkQueryUtil.hpp"
27
28 namespace vk
29 {
30
31 #ifndef CTS_USES_VULKANSC
createShader(const DeviceInterface & vk,VkDevice device,const vk::VkShaderCreateInfoEXT & shaderCreateInfo)32 inline Move<VkShaderEXT> createShader(const DeviceInterface& vk, VkDevice device, const vk::VkShaderCreateInfoEXT& shaderCreateInfo)
33 {
34 VkShaderEXT object;
35 VK_CHECK(vk.createShadersEXT(device, 1u, &shaderCreateInfo, DE_NULL, &object));
36 return Move<VkShaderEXT>(check<VkShaderEXT>(object), Deleter<VkShaderEXT>(vk, device, DE_NULL));
37 }
38
removeUnsupportedShaderObjectExtensions(const vk::InstanceInterface & vki,const vk::VkPhysicalDevice physicalDevice,const std::vector<std::string> & deviceExtensions)39 std::vector<std::string> removeUnsupportedShaderObjectExtensions (const vk::InstanceInterface& vki, const vk::VkPhysicalDevice physicalDevice, const std::vector<std::string>& deviceExtensions)
40 {
41 std::vector<std::string> extensions = deviceExtensions;
42
43 const auto extensionProperties = vk::enumerateDeviceExtensionProperties(vki, physicalDevice, DE_NULL);
44
45 deUint32 discardRectanglesVersion = 0;
46 deUint32 scissorExclusiveVersion = 0;
47 for (const auto& extProp : extensionProperties)
48 {
49 if (strcmp(extProp.extensionName, "VK_EXT_discard_rectangles") == 0)
50 discardRectanglesVersion = extProp.specVersion;
51
52 if (strcmp(extProp.extensionName, "VK_NV_scissor_exclusive") == 0)
53 scissorExclusiveVersion = extProp.specVersion;
54 }
55
56 if (discardRectanglesVersion < 2 && std::find(extensions.begin(), extensions.end(), "VK_EXT_discard_rectangles") != extensions.end())
57 extensions.erase(std::remove(extensions.begin(), extensions.end(), "VK_EXT_discard_rectangles"), extensions.end());
58 if (scissorExclusiveVersion < 2 && std::find(extensions.begin(), extensions.end(), "VK_NV_scissor_exclusive") != extensions.end())
59 extensions.erase(std::remove(extensions.begin(), extensions.end(), "VK_NV_scissor_exclusive"), extensions.end());
60
61 return extensions;
62 }
63 #endif
64
65 } // vk
66