• Main Page
  • Modules
  • Files
  • File List
  • Globals

NvFlowShader.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2014-2021, 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 #ifndef NV_FLOW_SHADER_H
00012 #define NV_FLOW_SHADER_H
00013 
00014 // --------------------------- NvFlow Shader Parameters -------------------------------
00017 
00018 #if (NV_FLOW_SHADER_UTILS != 0)
00019 
00020 int3 NvFlow_tableVal_to_coord(uint val)
00021 {
00022     uint valInv = ~val;
00023     return int3(
00024         (valInv >> 0) & 0x3FF,
00025         (valInv >> 10) & 0x3FF,
00026         (valInv >> 20) & 0x3FF);
00027 }
00028 
00029 #define NV_FLOW_DISPATCH_ID_TO_VIRTUAL(blockListSRV, params) \
00030     int3 DispatchIDToVirtual(uint3 tidx) \
00031     { \
00032         uint blockID = tidx.x >> params.blockDimBits.x; \
00033         int3 vBlockIdx = NvFlow_tableVal_to_coord(blockListSRV[blockID]); \
00034         int3 vidx = (vBlockIdx << params.blockDimBits.xyz) | (tidx & (params.blockDim.xyz - int3(1,1,1))); \
00035         return vidx; \
00036     }
00037 
00038 #define NV_FLOW_VIRTUAL_TO_REAL(name, blockTableSRV, params) \
00039     int3 name(int3 vidx) \
00040     { \
00041         if(params.isVTR.x != 0) \
00042         { \
00043             return vidx; \
00044         } \
00045         else \
00046         { \
00047             int3 vBlockIdx = vidx >> params.blockDimBits.xyz; \
00048             int3 rBlockIdx = NvFlow_tableVal_to_coord(blockTableSRV[vBlockIdx]); \
00049             int3 ridx = (rBlockIdx << params.blockDimBits.xyz) | (vidx & (params.blockDim.xyz - int3(1, 1, 1))); \
00050             return ridx; \
00051         } \
00052     }
00053 
00054 #define NV_FLOW_VIRTUAL_TO_REAL_LINEAR(name, blockTableSRV, params) \
00055     float3 name(float3 vidx) \
00056     { \
00057         if(params.isVTR.x != 0) \
00058         { \
00059             return vidx; \
00060         } \
00061         else \
00062         { \
00063             float3 vBlockIdxf = params.blockDimInv.xyz * vidx; \
00064             int3 vBlockIdx = int3(floor(vBlockIdxf)); \
00065             int3 rBlockIdx = NvFlow_tableVal_to_coord(blockTableSRV[vBlockIdx]); \
00066             float3 rBlockIdxf = float3(rBlockIdx); \
00067             float3 ridx = float3(params.linearBlockDim.xyz * rBlockIdx) + float3(params.blockDim.xyz) * (vBlockIdxf - float3(vBlockIdx)) + float3(params.linearBlockOffset.xyz); \
00068             return ridx; \
00069         } \
00070     }
00071 
00072 #endif
00073 
00075 struct NvFlowShaderPointParams
00076 {
00077     NvFlowUint4 isVTR;
00078     NvFlowUint4 blockDim;
00079     NvFlowUint4 blockDimBits;
00080     NvFlowUint4 poolGridDim;
00081     NvFlowUint4 gridDim;
00082 };
00083 
00085 struct NvFlowShaderLinearParams
00086 {
00087     NvFlowUint4 isVTR;
00088     NvFlowUint4 blockDim;
00089     NvFlowUint4 blockDimBits;
00090     NvFlowUint4 poolGridDim;
00091     NvFlowUint4 gridDim;
00092 
00093     NvFlowFloat4 blockDimInv;
00094     NvFlowUint4 linearBlockDim;
00095     NvFlowUint4 linearBlockOffset;
00096     NvFlowFloat4 dimInv;
00097     NvFlowFloat4 vdim;
00098     NvFlowFloat4 vdimInv;
00099 };
00100 
00102 
00103 #endif
Copyright © 2014-2016 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com