MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / PartitionGPUOps

Function PartitionGPUOps

src/OpenColorIO/ops/noop/NoOps.cpp:208–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208void PartitionGPUOps(OpRcPtrVec & gpuPreOps,
209 OpRcPtrVec & gpuLatticeOps,
210 OpRcPtrVec & gpuPostOps,
211 const OpRcPtrVec & ops)
212{
213 //
214 // Partition the original, raw opvec into 3 segments for GPU Processing
215 //
216 // gpuLatticeOps need not support analytical gpu shader generation
217 // the pre and post ops must support analytical generation.
218 // Additional ops will be inserted to take into account allocations
219 // transformations.
220
221
222 // This is used to bound our analytical shader text generation
223 // start index and end index are inclusive.
224
225 int gpuLut3DOpStartIndex = 0;
226 int gpuLut3DOpEndIndex = 0;
227 GetGpuUnsupportedIndexRange(&gpuLut3DOpStartIndex,
228 &gpuLut3DOpEndIndex,
229 ops);
230
231 // Write the entire shader using only shader text (3D LUT is unused)
232 if(gpuLut3DOpStartIndex == -1 && gpuLut3DOpEndIndex == -1)
233 {
234 for(unsigned int i=0; i<ops.size(); ++i)
235 {
236 gpuPreOps.push_back( ops[i]->clone() );
237 }
238 }
239 // Analytical -> 3D LUT -> analytical
240 else
241 {
242 // Handle analytical shader block before start index.
243 for(int i=0; i<gpuLut3DOpStartIndex; ++i)
244 {
245 gpuPreOps.push_back( ops[i]->clone() );
246 }
247
248 // Get the GPU Allocation at the cross-over point
249 // Create 2 symmetrically canceling allocation ops,
250 // where the shader text moves to a nicely allocated LDR
251 // (low dynamic range color space), and the lattice processing
252 // does the inverse (making the overall operation a no-op
253 // color-wise
254
255 AllocationData allocation;
256 if(gpuLut3DOpStartIndex<0 || gpuLut3DOpStartIndex>=(int)ops.size())
257 {
258 std::ostringstream error;
259 error << "Invalid GpuUnsupportedIndexRange: ";
260 error << "gpuLut3DOpStartIndex: " << gpuLut3DOpStartIndex << " ";
261 error << "gpuLut3DOpEndIndex: " << gpuLut3DOpEndIndex << " ";
262 error << "cpuOps.size: " << ops.size();
263 throw Exception(error.str().c_str());
264 }
265

Callers 2

OCIO_ADD_TESTFunction · 0.85

Calls 6

GetGpuAllocationFunction · 0.85
CreateAllocationOpsFunction · 0.85
sizeMethod · 0.45
push_backMethod · 0.45
cloneMethod · 0.45

Tested by 1

OCIO_ADD_TESTFunction · 0.68