| 2641 | } |
| 2642 | |
| 2643 | void |
| 2644 | HdSt_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 = |
nothing calls this directly
no test coverage detected