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 "tcuTextureUtil.hpp"
28 #include "vkDefs.hpp"
29 #include "vkImageUtil.hpp"
30 #include "vktImageTestsUtil.hpp"
31 #include "vktImageTexture.hpp"
32 #include "tcuVector.hpp"
33 #include "deSharedPtr.hpp"
34
35 namespace vkt
36 {
37 namespace image
38 {
39
40 typedef de::SharedPtr<vk::Unique<vk::VkDescriptorSet> > SharedVkDescriptorSet;
41 typedef de::SharedPtr<vk::Unique<vk::VkImageView> > SharedVkImageView;
42
43 template<typename T>
makeVkSharedPtr(vk::Move<T> vkMove)44 inline de::SharedPtr<vk::Unique<T> > makeVkSharedPtr (vk::Move<T> vkMove)
45 {
46 return de::SharedPtr<vk::Unique<T> >(new vk::Unique<T>(vkMove));
47 }
48
computeStoreColorBias(const vk::VkFormat format)49 inline float computeStoreColorBias (const vk::VkFormat format)
50 {
51 return isSnormFormat(format) ? -1.0f : 0.0f;
52 }
53
isIntegerFormat(const vk::VkFormat format)54 inline bool isIntegerFormat (const vk::VkFormat format)
55 {
56 return isIntFormat(format) || isUintFormat(format);
57 }
58
isSignedFormat(const vk::VkFormat format)59 inline bool isSignedFormat (const vk::VkFormat format)
60 {
61 return isIntFormat(format) || isSnormFormat(format) || isSfloatFormat(format);
62 }
63
colorScaleAndBiasAreValid(const vk::VkFormat format,const float colorScale,const float colorBias)64 inline bool colorScaleAndBiasAreValid (const vk::VkFormat format, const float colorScale, const float colorBias)
65 {
66 // Only normalized (fixed-point) formats may have scale/bias
67 const bool integerOrFloatFormat = isIntFormat(format) || isUintFormat(format) || isFloatFormat(format);
68 return !integerOrFloatFormat || (colorScale == 1.0f && colorBias == 0.0f);
69 }
70
71 float computeStoreColorScale (const vk::VkFormat format, const tcu::IVec3 imageSize);
72 ImageType getImageTypeForSingleLayer (const ImageType imageType);
73 vk::VkImageCreateInfo makeImageCreateInfo (const Texture& texture, const vk::VkFormat format, const vk::VkImageUsageFlags usage, const vk::VkImageCreateFlags flags);
74 vk::VkDeviceSize getOptimalUniformBufferChunkSize (const vk::InstanceInterface& vki, const vk::VkPhysicalDevice physDevice, vk::VkDeviceSize minimumRequiredChunkSizeBytes);
75 bool isRepresentableIntegerValue (const tcu::Vector<deInt64, 4> value, tcu::TextureFormat format);
76
77 } // image
78 } // vkt
79
80 #endif // _VKTIMAGELOADSTOREUTIL_HPP
81