MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / execute

Method execute

Source/Falcor/Utils/Algorithm/ParallelReduction.cpp:76–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74
75template<typename T>
76void ParallelReduction::execute(
77 RenderContext* pRenderContext,
78 const ref<Texture>& pInput,
79 Type operation,
80 T* pResult,
81 ref<Buffer> pResultBuffer,
82 uint64_t resultOffset
83)
84{
85 FALCOR_PROFILE(pRenderContext, "ParallelReduction::execute");
86
87 // Check texture array/mip/sample count.
88 if (pInput->getArraySize() != 1 || pInput->getMipCount() != 1 || pInput->getSampleCount() != 1)
89 {
90 FALCOR_THROW("ParallelReduction::execute() - Input texture is unsupported.");
91 }
92
93 // Check texture format.
94 uint32_t formatType = FORMAT_TYPE_UNKNOWN;
95 switch (getFormatType(pInput->getFormat()))
96 {
97 case FormatType::Float:
98 case FormatType::Unorm:
99 case FormatType::Snorm:
100 formatType = FORMAT_TYPE_FLOAT;
101 break;
102 case FormatType::Sint:
103 formatType = FORMAT_TYPE_SINT;
104 break;
105 case FormatType::Uint:
106 formatType = FORMAT_TYPE_UINT;
107 break;
108 default:
109 FALCOR_THROW("ParallelReduction::execute() - Input texture format unsupported.");
110 }
111
112 // Check that reduction type T is compatible with the resource format.
113 if (sizeof(typename T::value_type) != 4 || // The shader is written for 32-bit types
114 (formatType == FORMAT_TYPE_FLOAT && !std::is_floating_point<typename T::value_type>::value) ||
115 (formatType == FORMAT_TYPE_SINT &&
116 (!std::is_integral<typename T::value_type>::value || !std::is_signed<typename T::value_type>::value)) ||
117 (formatType == FORMAT_TYPE_UINT &&
118 (!std::is_integral<typename T::value_type>::value || !std::is_unsigned<typename T::value_type>::value)))
119 {
120 FALCOR_THROW("ParallelReduction::execute() - Template type T is not compatible with resource format.");
121 }
122
123 uint32_t reductionType = REDUCTION_TYPE_UNKNOWN;
124 uint32_t elementSize = 0;
125 switch (operation)
126 {
127 case Type::Sum:
128 reductionType = REDUCTION_TYPE_SUM;
129 elementSize = 1;
130 break;
131 case Type::MinMax:
132 reductionType = REDUCTION_TYPE_MINMAX;
133 elementSize = 2;

Callers

nothing calls this directly

Calls 15

getFormatTypeFunction · 0.85
div_round_upFunction · 0.85
getFormatChannelCountFunction · 0.85
getFormatMethod · 0.80
getWidthMethod · 0.80
getHeightMethod · 0.80
addDefinesMethod · 0.80
getRootVarMethod · 0.80
copyBufferRegionMethod · 0.80
getBlobMethod · 0.80
allocateFunction · 0.50
to_stringFunction · 0.50

Tested by

no test coverage detected