APEX Framework: RenderDataFormat.h Source File

NVIDIA APEX

RenderDataFormat.h
00001 /*
00002  * Copyright (c) 2008-2017, NVIDIA CORPORATION.  All rights reserved.
00003  *
00004  * NVIDIA CORPORATION and its licensors retain all intellectual property
00005  * and proprietary rights in and to this software, related documentation
00006  * and any modifications thereto.  Any use, reproduction, disclosure or
00007  * distribution of this software and related documentation without an express
00008  * license agreement from NVIDIA CORPORATION is strictly prohibited.
00009  */
00010 
00011 
00012 #ifndef RENDER_DATA_FORMAT_H
00013 #define RENDER_DATA_FORMAT_H
00014 
00015 #include "ApexUsingNamespace.h"
00016 #include "foundation/PxAssert.h"
00017 #include "foundation/PxMat44.h"
00018 
00019 namespace nvidia
00020 {
00021 namespace apex
00022 {
00023 
00024 PX_PUSH_PACK_DEFAULT
00025 
00031 struct RenderDataFormat
00032 {
00034     enum Enum
00035     {
00036         UNSPECIFIED =           0,  
00037 
00039         UBYTE1 =                1,  
00040         UBYTE2 =                2,  
00041         UBYTE3 =                3,  
00042         UBYTE4 =                4,  
00043 
00044         USHORT1 =               5,  
00045         USHORT2 =               6,  
00046         USHORT3 =               7,  
00047         USHORT4 =               8,  
00048 
00049         SHORT1 =                9,  
00050         SHORT2 =                10, 
00051         SHORT3 =                11, 
00052         SHORT4 =                12, 
00053 
00054         UINT1 =                 13, 
00055         UINT2 =                 14, 
00056         UINT3 =                 15, 
00057         UINT4 =                 16, 
00058 
00060         R8G8B8A8 =              17, 
00061         B8G8R8A8 =              18, 
00062         R32G32B32A32_FLOAT =    19, 
00063         B32G32R32A32_FLOAT =    20, 
00064 
00066         BYTE_UNORM1 =           21, 
00067         BYTE_UNORM2 =           22, 
00068         BYTE_UNORM3 =           23, 
00069         BYTE_UNORM4 =           24, 
00070 
00071         SHORT_UNORM1 =          25, 
00072         SHORT_UNORM2 =          26, 
00073         SHORT_UNORM3 =          27, 
00074         SHORT_UNORM4 =          28, 
00075 
00076         BYTE_SNORM1 =           29, 
00077         BYTE_SNORM2 =           30, 
00078         BYTE_SNORM3 =           31, 
00079         BYTE_SNORM4 =           32, 
00080 
00081         SHORT_SNORM1 =          33, 
00082         SHORT_SNORM2 =          34, 
00083         SHORT_SNORM3 =          35, 
00084         SHORT_SNORM4 =          36, 
00085 
00087         HALF1 =                 37, 
00088         HALF2 =                 38, 
00089         HALF3 =                 39, 
00090         HALF4 =                 40, 
00091 
00092         FLOAT1 =                41, 
00093         FLOAT2 =                42, 
00094         FLOAT3 =                43, 
00095         FLOAT4 =                44, 
00096 
00097         FLOAT4x4 =              45, 
00098         FLOAT3x4 =              46, 
00099         FLOAT3x3 =              47, 
00100 
00101         FLOAT4_QUAT =           48, 
00102         BYTE_SNORM4_QUATXYZW =  49, 
00103         SHORT_SNORM4_QUATXYZW = 50, 
00104 
00105         NUM_FORMATS
00106     };
00107 
00109     static PX_INLINE uint32_t getFormatDataSize(Enum format)
00110     {
00111         switch (format)
00112         {
00113         default:
00114             PX_ALWAYS_ASSERT();
00115         case UNSPECIFIED:
00116             return 0;
00117 
00118         case UBYTE1:
00119         case BYTE_UNORM1:
00120         case BYTE_SNORM1:
00121             return sizeof(uint8_t);
00122         case UBYTE2:
00123         case BYTE_UNORM2:
00124         case BYTE_SNORM2:
00125             return sizeof(uint8_t) * 2;
00126         case UBYTE3:
00127         case BYTE_UNORM3:
00128         case BYTE_SNORM3:
00129             return sizeof(uint8_t) * 3;
00130         case UBYTE4:
00131         case BYTE_UNORM4:
00132         case BYTE_SNORM4:
00133         case BYTE_SNORM4_QUATXYZW:
00134             return sizeof(uint8_t) * 4;
00135 
00136         case USHORT1:
00137         case SHORT1:
00138         case HALF1:
00139         case SHORT_UNORM1:
00140         case SHORT_SNORM1:
00141             return sizeof(uint16_t);
00142         case USHORT2:
00143         case SHORT2:
00144         case HALF2:
00145         case SHORT_UNORM2:
00146         case SHORT_SNORM2:
00147             return sizeof(uint16_t) * 2;
00148         case USHORT3:
00149         case SHORT3:
00150         case HALF3:
00151         case SHORT_UNORM3:
00152         case SHORT_SNORM3:
00153             return sizeof(uint16_t) * 3;
00154         case USHORT4:
00155         case SHORT4:
00156         case HALF4:
00157         case SHORT_UNORM4:
00158         case SHORT_SNORM4:
00159         case SHORT_SNORM4_QUATXYZW:
00160             return sizeof(uint16_t) * 4;
00161 
00162         case UINT1:
00163             return sizeof(uint32_t);
00164         case UINT2:
00165             return sizeof(uint32_t) * 2;
00166         case UINT3:
00167             return sizeof(uint32_t) * 3;
00168         case UINT4:
00169             return sizeof(uint32_t) * 4;
00170 
00171         case R8G8B8A8:
00172         case B8G8R8A8:
00173             return sizeof(uint8_t) * 4;
00174 
00175         case R32G32B32A32_FLOAT:
00176         case B32G32R32A32_FLOAT:
00177             return sizeof(float) * 4;
00178 
00179         case FLOAT1:
00180             return sizeof(float);
00181         case FLOAT2:
00182             return sizeof(float) * 2;
00183         case FLOAT3:
00184             return sizeof(float) * 3;
00185         case FLOAT4:
00186             return sizeof(float) * 4;
00187 
00188         case FLOAT4x4:
00189             return sizeof(PxMat44);
00190 
00191         case FLOAT3x4:
00192             return sizeof(float) * 12;
00193 
00194         case FLOAT3x3:
00195             return sizeof(PxMat33);
00196 
00197         case FLOAT4_QUAT:
00198             return sizeof(PxQuat);
00199         }
00200     }
00201 };
00202 
00203 PX_POP_PACK
00204 
00205 }
00206 } // end namespace nvidia::apex
00207 
00208 #endif  // RENDER_DATA_FORMAT_H

Generated on Fri Dec 15 2017 13:58:35
Copyright © 2012-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved.