Home | History | Annotate | Download | only in image
      1 #ifndef _VKTIMAGELOADSTOREUTIL_HPP
      2 #define _VKTIMAGELOADSTOREUTIL_HPP
      3 /*------------------------------------------------------------------------
      4  * Vulkan Conformance Tests
      5  * ------------------------
      6  *
      7  * Copyright (c) 2016 The Khronos Group 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 Image load/store utilities
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "tcuDefs.hpp"
     27 #include "vkDefs.hpp"
     28 #include "vkImageUtil.hpp"
     29 #include "vktImageTestsUtil.hpp"
     30 #include "vktImageTexture.hpp"
     31 #include "tcuVector.hpp"
     32 #include "deSharedPtr.hpp"
     33 
     34 namespace vkt
     35 {
     36 namespace image
     37 {
     38 
     39 typedef de::SharedPtr<vk::Unique<vk::VkDescriptorSet> >	SharedVkDescriptorSet;
     40 typedef de::SharedPtr<vk::Unique<vk::VkImageView> >		SharedVkImageView;
     41 
     42 template<typename T>
     43 inline de::SharedPtr<vk::Unique<T> > makeVkSharedPtr (vk::Move<T> vkMove)
     44 {
     45 	return de::SharedPtr<vk::Unique<T> >(new vk::Unique<T>(vkMove));
     46 }
     47 
     48 inline float computeStoreColorBias (const vk::VkFormat format)
     49 {
     50 	return isSnormFormat(format) ? -1.0f : 0.0f;
     51 }
     52 
     53 inline bool isIntegerFormat (const vk::VkFormat format)
     54 {
     55 	return isIntFormat(format) || isUintFormat(format);
     56 }
     57 
     58 inline bool colorScaleAndBiasAreValid (const vk::VkFormat format, const float colorScale, const float colorBias)
     59 {
     60 	// Only normalized (fixed-point) formats may have scale/bias
     61 	const bool integerOrFloatFormat = isIntFormat(format) || isUintFormat(format) || isFloatFormat(format);
     62 	return !integerOrFloatFormat || (colorScale == 1.0f && colorBias == 0.0f);
     63 }
     64 
     65 float					computeStoreColorScale				(const vk::VkFormat format, const tcu::IVec3 imageSize);
     66 ImageType				getImageTypeForSingleLayer			(const ImageType imageType);
     67 vk::VkImageCreateInfo	makeImageCreateInfo					(const Texture& texture, const vk::VkFormat format, const vk::VkImageUsageFlags usage, const vk::VkImageCreateFlags flags);
     68 vk::VkDeviceSize		getOptimalUniformBufferChunkSize	(const vk::InstanceInterface& vki, const vk::VkPhysicalDevice physDevice, vk::VkDeviceSize minimumRequiredChunkSizeBytes);
     69 
     70 } // image
     71 } // vkt
     72 
     73 #endif // _VKTIMAGELOADSTOREUTIL_HPP
     74