RenderDataFormat.h
00001 //
00002 // Redistribution and use in source and binary forms, with or without
00003 // modification, are permitted provided that the following conditions
00004 // are met:
00005 //  * Redistributions of source code must retain the above copyright
00006 //    notice, this list of conditions and the following disclaimer.
00007 //  * Redistributions in binary form must reproduce the above copyright
00008 //    notice, this list of conditions and the following disclaimer in the
00009 //    documentation and/or other materials provided with the distribution.
00010 //  * Neither the name of NVIDIA CORPORATION nor the names of its
00011 //    contributors may be used to endorse or promote products derived
00012 //    from this software without specific prior written permission.
00013 //
00014 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
00015 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017 // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00018 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 //
00026 // Copyright (c) 2018 NVIDIA Corporation. All rights reserved.
00027 
00028 
00029 
00030 #ifndef RENDER_DATA_FORMAT_H
00031 #define RENDER_DATA_FORMAT_H
00032 
00033 #include "ApexUsingNamespace.h"
00034 #include "foundation/PxAssert.h"
00035 #include "foundation/PxMat44.h"
00036 
00037 namespace nvidia
00038 {
00039 namespace apex
00040 {
00041 
00042 PX_PUSH_PACK_DEFAULT
00043 
00049 struct RenderDataFormat
00050 {
00052     enum Enum
00053     {
00054         UNSPECIFIED =           0,  
00055 
00057         UBYTE1 =                1,  
00058         UBYTE2 =                2,  
00059         UBYTE3 =                3,  
00060         UBYTE4 =                4,  
00061 
00062         USHORT1 =               5,  
00063         USHORT2 =               6,  
00064         USHORT3 =               7,  
00065         USHORT4 =               8,  
00066 
00067         SHORT1 =                9,  
00068         SHORT2 =                10, 
00069         SHORT3 =                11, 
00070         SHORT4 =                12, 
00071 
00072         UINT1 =                 13, 
00073         UINT2 =                 14, 
00074         UINT3 =                 15, 
00075         UINT4 =                 16, 
00076 
00078         R8G8B8A8 =              17, 
00079         B8G8R8A8 =              18, 
00080         R32G32B32A32_FLOAT =    19, 
00081         B32G32R32A32_FLOAT =    20, 
00082 
00084         BYTE_UNORM1 =           21, 
00085         BYTE_UNORM2 =           22, 
00086         BYTE_UNORM3 =           23, 
00087         BYTE_UNORM4 =           24, 
00088 
00089         SHORT_UNORM1 =          25, 
00090         SHORT_UNORM2 =          26, 
00091         SHORT_UNORM3 =          27, 
00092         SHORT_UNORM4 =          28, 
00093 
00094         BYTE_SNORM1 =           29, 
00095         BYTE_SNORM2 =           30, 
00096         BYTE_SNORM3 =           31, 
00097         BYTE_SNORM4 =           32, 
00098 
00099         SHORT_SNORM1 =          33, 
00100         SHORT_SNORM2 =          34, 
00101         SHORT_SNORM3 =          35, 
00102         SHORT_SNORM4 =          36, 
00103 
00105         HALF1 =                 37, 
00106         HALF2 =                 38, 
00107         HALF3 =                 39, 
00108         HALF4 =                 40, 
00109 
00110         FLOAT1 =                41, 
00111         FLOAT2 =                42, 
00112         FLOAT3 =                43, 
00113         FLOAT4 =                44, 
00114 
00115         FLOAT4x4 =              45, 
00116         FLOAT3x4 =              46, 
00117         FLOAT3x3 =              47, 
00118 
00119         FLOAT4_QUAT =           48, 
00120         BYTE_SNORM4_QUATXYZW =  49, 
00121         SHORT_SNORM4_QUATXYZW = 50, 
00122 
00123         NUM_FORMATS
00124     };
00125 
00127     static PX_INLINE uint32_t getFormatDataSize(Enum format)
00128     {
00129         switch (format)
00130         {
00131         default:
00132             PX_ALWAYS_ASSERT();
00133         case UNSPECIFIED:
00134             return 0;
00135 
00136         case UBYTE1:
00137         case BYTE_UNORM1:
00138         case BYTE_SNORM1:
00139             return sizeof(uint8_t);
00140         case UBYTE2:
00141         case BYTE_UNORM2:
00142         case BYTE_SNORM2:
00143             return sizeof(uint8_t) * 2;
00144         case UBYTE3:
00145         case BYTE_UNORM3:
00146         case BYTE_SNORM3:
00147             return sizeof(uint8_t) * 3;
00148         case UBYTE4:
00149         case BYTE_UNORM4:
00150         case BYTE_SNORM4:
00151         case BYTE_SNORM4_QUATXYZW:
00152             return sizeof(uint8_t) * 4;
00153 
00154         case USHORT1:
00155         case SHORT1:
00156         case HALF1:
00157         case SHORT_UNORM1:
00158         case SHORT_SNORM1:
00159             return sizeof(uint16_t);
00160         case USHORT2:
00161         case SHORT2:
00162         case HALF2:
00163         case SHORT_UNORM2:
00164         case SHORT_SNORM2:
00165             return sizeof(uint16_t) * 2;
00166         case USHORT3:
00167         case SHORT3:
00168         case HALF3:
00169         case SHORT_UNORM3:
00170         case SHORT_SNORM3:
00171             return sizeof(uint16_t) * 3;
00172         case USHORT4:
00173         case SHORT4:
00174         case HALF4:
00175         case SHORT_UNORM4:
00176         case SHORT_SNORM4:
00177         case SHORT_SNORM4_QUATXYZW:
00178             return sizeof(uint16_t) * 4;
00179 
00180         case UINT1:
00181             return sizeof(uint32_t);
00182         case UINT2:
00183             return sizeof(uint32_t) * 2;
00184         case UINT3:
00185             return sizeof(uint32_t) * 3;
00186         case UINT4:
00187             return sizeof(uint32_t) * 4;
00188 
00189         case R8G8B8A8:
00190         case B8G8R8A8:
00191             return sizeof(uint8_t) * 4;
00192 
00193         case R32G32B32A32_FLOAT:
00194         case B32G32R32A32_FLOAT:
00195             return sizeof(float) * 4;
00196 
00197         case FLOAT1:
00198             return sizeof(float);
00199         case FLOAT2:
00200             return sizeof(float) * 2;
00201         case FLOAT3:
00202             return sizeof(float) * 3;
00203         case FLOAT4:
00204             return sizeof(float) * 4;
00205 
00206         case FLOAT4x4:
00207             return sizeof(PxMat44);
00208 
00209         case FLOAT3x4:
00210             return sizeof(float) * 12;
00211 
00212         case FLOAT3x3:
00213             return sizeof(PxMat33);
00214 
00215         case FLOAT4_QUAT:
00216             return sizeof(PxQuat);
00217         }
00218     }
00219 };
00220 
00221 PX_POP_PACK
00222 
00223 }
00224 } // end namespace nvidia::apex
00225 
00226 #endif  // RENDER_DATA_FORMAT_H

Generated on Sat Dec 1 2018 15:52:06

Copyright © 2012-2018 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved.