MCPcopy Create free account
hub / github.com/PixarAnimationStudios/OpenUSD / _GenerateComputeParameters

Method _GenerateComputeParameters

pxr/imaging/hdSt/codeGen.cpp:2643–2747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2641}
2642
2643void
2644HdSt_CodeGen::_GenerateComputeParameters(HgiShaderFunctionDesc * const csDesc)
2645{
2646 std::stringstream accessors;
2647
2648 bool const hasComputeData =
2649 !_metaData->computeReadWriteData.empty() ||
2650 !_metaData->computeReadOnlyData.empty();
2651 if (hasComputeData) {
2652 HgiShaderFunctionAddConstantParam(
2653 csDesc, "vertexOffset", _tokens->_int);
2654 }
2655
2656 accessors << "// Read-Write Accessors & Mutators\n";
2657 TF_FOR_ALL(it, _metaData->computeReadWriteData) {
2658 TfToken const &name = it->second.name;
2659 HdStBinding const &binding = it->first;
2660 TfToken const &dataType = it->second.dataType;
2661
2662 // For now, SSBO bindings use a flat type encoding.
2663 TfToken declDataType =
2664 (binding.GetType() == HdStBinding::SSBO
2665 ? _GetFlatType(dataType) : dataType);
2666
2667 HgiShaderFunctionAddConstantParam(
2668 csDesc, name.GetString() + "Offset", _tokens->_int);
2669 HgiShaderFunctionAddConstantParam(
2670 csDesc, name.GetString() + "Stride", _tokens->_int);
2671
2672 _genDefines << "#define HD_HAS_" << name << " 1\n";
2673
2674 _EmitDeclaration(&_resCommon,
2675 name,
2676 declDataType,
2677 binding,
2678 /*isWritable=*/true);
2679
2680 // getter & setter
2681 {
2682 std::stringstream indexing;
2683 indexing << "(localIndex + vertexOffset)"
2684 << " * " << name << "Stride"
2685 << " + " << name << "Offset";
2686 _EmitComputeAccessor(accessors, name, dataType, binding,
2687 indexing.str().c_str());
2688 _EmitComputeMutator(accessors, name, dataType, binding,
2689 indexing.str().c_str());
2690 }
2691 }
2692 accessors << "// Read-Only Accessors\n";
2693 // no vertex offset for constant data
2694 TF_FOR_ALL(it, _metaData->computeReadOnlyData) {
2695 TfToken const &name = it->second.name;
2696 HdStBinding const &binding = it->first;
2697 TfToken const &dataType = it->second.dataType;
2698
2699 // For now, SSBO bindings use a flat type encoding.
2700 TfToken declDataType =

Callers

nothing calls this directly

Calls 10

_EmitDeclarationFunction · 0.85
_EmitComputeAccessorFunction · 0.85
_EmitComputeMutatorFunction · 0.85
TF_FOR_ALLFunction · 0.70
emptyMethod · 0.45
GetTypeMethod · 0.45
GetStringMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected