Home | History | Annotate | Download | only in vulkan
      1 #ifndef _VKTYPEUTIL_HPP
      2 #define _VKTYPEUTIL_HPP
      3 /*-------------------------------------------------------------------------
      4  * Vulkan CTS Framework
      5  * --------------------
      6  *
      7  * Copyright (c) 2015 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 creating commonly used composite types.
     24  *//*--------------------------------------------------------------------*/
     25 
     26 #include "vkDefs.hpp"
     27 #include "tcuVector.hpp"
     28 
     29 namespace vk
     30 {
     31 
     32 #include "vkTypeUtil.inl"
     33 
     34 inline VkClearValue makeClearValueColorF32 (float r, float g, float b, float a)
     35 {
     36 	VkClearValue v;
     37 	v.color.float32[0] = r;
     38 	v.color.float32[1] = g;
     39 	v.color.float32[2] = b;
     40 	v.color.float32[3] = a;
     41 	return v;
     42 }
     43 
     44 inline VkClearValue makeClearValueColorU32 (deUint32 r, deUint32 g, deUint32 b, deUint32 a)
     45 {
     46 	VkClearValue v;
     47 	v.color.uint32[0] = r;
     48 	v.color.uint32[1] = g;
     49 	v.color.uint32[2] = b;
     50 	v.color.uint32[3] = a;
     51 	return v;
     52 }
     53 
     54 inline VkClearValue makeClearValueColorI32 (deInt32 r, deInt32 g, deInt32 b, deInt32 a)
     55 {
     56 	VkClearValue v;
     57 	v.color.int32[0] = r;
     58 	v.color.int32[1] = g;
     59 	v.color.int32[2] = b;
     60 	v.color.int32[3] = a;
     61 	return v;
     62 }
     63 
     64 inline VkClearValue makeClearValueColor (const tcu::Vec4& color)
     65 {
     66 	VkClearValue v;
     67 	v.color.float32[0] = color[0];
     68 	v.color.float32[1] = color[1];
     69 	v.color.float32[2] = color[2];
     70 	v.color.float32[3] = color[3];
     71 	return v;
     72 }
     73 
     74 inline VkClearValue makeClearValueDepthStencil (float depth, deUint32 stencil)
     75 {
     76 	VkClearValue v;
     77 	v.depthStencil.depth	= depth;
     78 	v.depthStencil.stencil	= stencil;
     79 	return v;
     80 }
     81 
     82 inline VkClearValue makeClearValue (VkClearColorValue color)
     83 {
     84 	VkClearValue v;
     85 	v.color = color;
     86 	return v;
     87 }
     88 
     89 inline VkComponentMapping makeComponentMappingRGBA (void)
     90 {
     91 	return makeComponentMapping(VK_COMPONENT_SWIZZLE_R,
     92 								VK_COMPONENT_SWIZZLE_G,
     93 								VK_COMPONENT_SWIZZLE_B,
     94 								VK_COMPONENT_SWIZZLE_A);
     95 }
     96 
     97 inline VkExtent3D makeExtent3D(const tcu::IVec3& vec)
     98 {
     99 	return makeExtent3D((deUint32)vec.x(), (deUint32)vec.y(), (deUint32)vec.z());
    100 }
    101 
    102 inline VkExtent3D makeExtent3D(const tcu::UVec3& vec)
    103 {
    104 	return makeExtent3D(vec.x(), vec.y(), vec.z());
    105 }
    106 
    107 } // vk
    108 
    109 #endif // _VKTYPEUTIL_HPP
    110