src/third_party/angle/src/libANGLE/renderer/glslang_wrapper_utils.cpp
// Calculates XFB layout qualifier arguments for each tranform feedback varying.  Stores calculated
// values for the SPIR-V transformation.
Calculates XFB layout qualifier arguments for each tranform feedback varying.  Stores calculated
values for the SPIR-V transformation.
Calculates XFB layout qualifier arguments for each tranform feedback varying . Stores calculated values for the SPIR - V transformation .
void AssignTransformFeedbackExtensionQualifiers(const gl::ProgramExecutable &programExecutable,
                                                uint32_t locationsUsedForXfbExtension,
                                                const gl::ShaderType shaderType,
                                                ShaderInterfaceVariableInfoMap *variableInfoMapOut)
{
    const std::vector<gl::TransformFeedbackVarying> &tfVaryings =
        programExecutable.getLinkedTransformFeedbackVaryings();
    const std::vector<GLsizei> &varyingStrides = programExecutable.getTransformFeedbackStrides();
    const bool isInterleaved =
        programExecutable.getTransformFeedbackBufferMode() == GL_INTERLEAVED_ATTRIBS;
    std::string xfbDecl;
    std::string xfbOut;
    uint32_t currentOffset          = 0;
    uint32_t currentStride          = 0;
    uint32_t bufferIndex            = 0;
    uint32_t currentBuiltinLocation = 0;
    for (uint32_t varyingIndex = 0; varyingIndex < tfVaryings.size(); ++varyingIndex)
    {
        if (isInterleaved)
        {
            bufferIndex = 0;
            if (varyingIndex > 0)
            {
                const gl::TransformFeedbackVarying &prev = tfVaryings[varyingIndex - 1];
                currentOffset += prev.size() * gl::VariableExternalSize(prev.type);
            }
            currentStride = varyingStrides[0];
        }
        else
        {
            bufferIndex   = varyingIndex;
            currentOffset = 0;
            currentStride = varyingStrides[varyingIndex];
        }
        const gl::TransformFeedbackVarying &tfVarying = tfVaryings[varyingIndex];
        const std::string &tfVaryingName              = tfVarying.mappedName;
        if (tfVarying.isBuiltIn())
        {
            uint32_t xfbVaryingLocation = currentBuiltinLocation++;
            std::string xfbVaryingName  = kXfbBuiltInPrefix + tfVaryingName;
            ASSERT(xfbVaryingLocation < locationsUsedForXfbExtension);
            AddLocationInfo(variableInfoMapOut, xfbVaryingName, xfbVaryingLocation,
                            ShaderInterfaceVariableInfo::kInvalid, shaderType, 0, 0);
            SetXfbInfo(variableInfoMapOut, xfbVaryingName, bufferIndex, currentOffset,
                       currentStride);
        }
        else if (!tfVarying.isArray() || tfVarying.arrayIndex == GL_INVALID_INDEX)
        {
            const gl::PackedVarying *originalVarying = nullptr;
            for (const gl::PackedVaryingRegister &varyingReg :
                 programExecutable.getResources().varyingPacking.getRegisterList())
            {
                if (!IsFirstRegisterOfVarying(varyingReg))
                {
                    continue;
                }
                const gl::PackedVarying *varying = varyingReg.packedVarying;
                if (varying->frontVarying.varying->name == tfVarying.name)
                {
                    originalVarying = varying;
                    break;
                }
            }
            if (originalVarying)
            {
                const std::string &mappedName =
                    originalVarying->isStructField()
                        ? originalVarying->frontVarying.parentStructMappedName
                        : originalVarying->frontVarying.varying->mappedName;
                SetXfbInfo(variableInfoMapOut, mappedName, bufferIndex, currentOffset,
                           currentStride);
            }
        }
    }
}
void AssignTransformFeedbackExtensionQualifiers ( const gl :: ProgramExecutable & programExecutable , uint32_t locationsUsedForXfbExtension , const gl :: ShaderType shaderType , ShaderInterfaceVariableInfoMap * variableInfoMapOut ) { const std :: vector < gl :: TransformFeedbackVarying > & tfVaryings = programExecutable . getLinkedTransformFeedbackVaryings ( ) ; const std :: vector < GLsizei > & varyingStrides = programExecutable . getTransformFeedbackStrides ( ) ; const bool isInterleaved = programExecutable . getTransformFeedbackBufferMode ( ) == GL_INTERLEAVED_ATTRIBS ; std :: string xfbDecl ; std :: string xfbOut ; uint32_t currentOffset = 0 ; uint32_t currentStride = 0 ; uint32_t bufferIndex = 0 ; uint32_t currentBuiltinLocation = 0 ; for ( uint32_t varyingIndex = 0 ; varyingIndex < tfVaryings . size ( ) ; ++ varyingIndex ) { if ( isInterleaved ) { bufferIndex = 0 ; if ( varyingIndex > 0 ) { const gl :: TransformFeedbackVarying & prev = tfVaryings [ varyingIndex - 1 ] ; currentOffset += prev . size ( ) * gl :: VariableExternalSize ( prev . type ) ; } currentStride = varyingStrides [ 0 ] ; } else { bufferIndex = varyingIndex ; currentOffset = 0 ; currentStride = varyingStrides [ varyingIndex ] ; } const gl :: TransformFeedbackVarying & tfVarying = tfVaryings [ varyingIndex ] ; const std :: string & tfVaryingName = tfVarying . mappedName ; if ( tfVarying . isBuiltIn ( ) ) { uint32_t xfbVaryingLocation = currentBuiltinLocation ++ ; std :: string xfbVaryingName = kXfbBuiltInPrefix + tfVaryingName ; ASSERT ( xfbVaryingLocation < locationsUsedForXfbExtension ) ; AddLocationInfo ( variableInfoMapOut , xfbVaryingName , xfbVaryingLocation , ShaderInterfaceVariableInfo :: kInvalid , shaderType , 0 , 0 ) ; SetXfbInfo ( variableInfoMapOut , xfbVaryingName , bufferIndex , currentOffset , currentStride ) ; } else if ( ! tfVarying . isArray ( ) || tfVarying . arrayIndex == GL_INVALID_INDEX ) { const gl :: PackedVarying * originalVarying = nullptr ; for ( const gl :: PackedVaryingRegister & varyingReg : programExecutable . getResources ( ) . varyingPacking . getRegisterList ( ) ) { if ( ! IsFirstRegisterOfVarying ( varyingReg ) ) { continue ; } const gl :: PackedVarying * varying = varyingReg . packedVarying ; if ( varying -> frontVarying . varying -> name == tfVarying . name ) { originalVarying = varying ; break ; } } if ( originalVarying ) { const std :: string & mappedName = originalVarying -> isStructField ( ) ? originalVarying -> frontVarying . parentStructMappedName : originalVarying -> frontVarying . varying -> mappedName ; SetXfbInfo ( variableInfoMapOut , mappedName , bufferIndex , currentOffset , currentStride ) ; } } } }
Calculates XFB layout qualifier arguments for each tranform feedback varying.
Calculates XFB layout qualifier arguments for each tranform feedback varying .
// Note: capturing individual array elements using the Vulkan transform feedback // extension is not supported, and it unlikely to be ever supported (on the contrary, it // may be removed from the GLES spec).  http://anglebug.com/4140 // ANGLE should support capturing the whole array. // Find the varying with this name.  If a struct is captured, we would be iterating over // its fields, and the name of the varying is found through parentStructMappedName.  Not // only that, but also we should only do this for the first field of the struct. // Set xfb info for this varying.  AssignVaryingLocations should have already added // location information for these varyings.