Home | History | Annotate | Download | only in spirv_assembly
      1 #ifndef _VKTSPVASMUTILS_HPP
      2 #define _VKTSPVASMUTILS_HPP
      3 /*-------------------------------------------------------------------------
      4  * Vulkan Conformance Tests
      5  * ------------------------
      6  *
      7  * Copyright (c) 2017 Google Inc.
      8  *
      9  * Licensed under the Apache License, Version 2.0 (the "License");
     10  * you may not use this file except in compliance with the License.
     11  * You may obtain a copy of the License at
     12  *
     13  *      http://www.apache.org/licenses/LICENSE-2.0
     14  *
     15  * Unless required by applicable law or agreed to in writing, software
     16  * distributed under the License is distributed on an "AS IS" BASIS,
     17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     18  * See the License for the specific language governing permissions and
     19  * limitations under the License.
     20  *
     21  *//*!
     22  * \file
     23  * \brief Utilities for Vulkan SPIR-V assembly tests
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "vkDefs.hpp"
     27 #include "vkMemUtil.hpp"
     28 #include "vkRef.hpp"
     29 #include "vkTypeUtil.hpp"
     30 #include "vktTestCase.hpp"
     31 
     32 #include <string>
     33 #include <vector>
     34 
     35 namespace vkt
     36 {
     37 namespace SpirVAssembly
     38 {
     39 
     40 enum Extension16BitStorageFeatureBits
     41 {
     42 	EXT16BITSTORAGEFEATURES_UNIFORM_BUFFER_BLOCK	= (1u << 1),
     43 	EXT16BITSTORAGEFEATURES_UNIFORM					= (1u << 2),
     44 	EXT16BITSTORAGEFEATURES_PUSH_CONSTANT			= (1u << 3),
     45 	EXT16BITSTORAGEFEATURES_INPUT_OUTPUT			= (1u << 4),
     46 };
     47 typedef deUint32 Extension16BitStorageFeatures;
     48 
     49 enum ExtensionVariablePointersFeaturesBits
     50 {
     51 	EXTVARIABLEPOINTERSFEATURES_VARIABLE_POINTERS_STORAGEBUFFER	= (1u << 1),
     52 	EXTVARIABLEPOINTERSFEATURES_VARIABLE_POINTERS				= (1u << 2),
     53 };
     54 typedef deUint32 ExtensionVariablePointersFeatures;
     55 
     56 struct VulkanFeatures
     57 {
     58 	Extension16BitStorageFeatures		ext16BitStorage;
     59 	ExtensionVariablePointersFeatures	extVariablePointers;
     60 	vk::VkPhysicalDeviceFeatures		coreFeatures;
     61 
     62 	VulkanFeatures				(void)
     63 		: ext16BitStorage		(0)
     64 		, extVariablePointers	(0)
     65 		, coreFeatures			(vk::VkPhysicalDeviceFeatures())
     66 	{}
     67 };
     68 
     69 // Returns true if the given 16bit storage extension features in `toCheck` are all supported.
     70 bool is16BitStorageFeaturesSupported (const deUint32 apiVersion,
     71 									  const vk::InstanceInterface&		vkInstance,
     72 									  vk::VkPhysicalDevice				device,
     73 									  const std::vector<std::string>&	instanceExtensions,
     74 									  Extension16BitStorageFeatures		toCheck);
     75 
     76 // Returns true if the given variable pointers extension features in `toCheck` are all supported.
     77 bool isVariablePointersFeaturesSupported (const deUint32 apiVersion,
     78 										  const vk::InstanceInterface&		vkInstance,
     79 										  vk::VkPhysicalDevice				device,
     80 										  const std::vector<std::string>&	instanceExtensions,
     81 										  ExtensionVariablePointersFeatures	toCheck);
     82 
     83 // Creates a Vulkan logical device with the requiredExtensions enabled and all other extensions disabled.
     84 // The logical device will be created from the instance and physical device in the given context.
     85 // A single queue will be created from the given queue family.
     86 vk::Move<vk::VkDevice> createDeviceWithExtensions (Context&							context,
     87 												   deUint32							queueFamilyIndex,
     88 												   const std::vector<std::string>&	supportedExtensions,
     89 												   const std::vector<std::string>&	requiredExtensions);
     90 
     91 // Creates a SimpleAllocator on the given device.
     92 vk::Allocator* createAllocator (const vk::InstanceInterface& instanceInterface,
     93 								const vk::VkPhysicalDevice physicalDevice,
     94 								const vk::DeviceInterface& deviceInterface,
     95 								const vk::VkDevice device);
     96 
     97 deUint32 getMinRequiredVulkanVersion (const vk::SpirvVersion version);
     98 
     99 std::string	getVulkanName (const deUint32 version);
    100 
    101 } // SpirVAssembly
    102 } // vkt
    103 
    104 #endif // _VKTSPVASMUTILS_HPP
    105