src/third_party/angle/src/libANGLE/renderer/d3d/VertexDataManager.cpp
// Warning: you should ensure binding really matches attrib.bindingIndex before using this function.
you should ensure binding really matches attrib.bindingIndex before using this function.
you should ensure binding really matches attrib . bindingIndex before using this function .
bool DirectStoragePossible(const gl::Context *context,
                           const gl::VertexAttribute &attrib,
                           const gl::VertexBinding &binding)
{
    if (!attrib.enabled)
    {
        return false;
    }
    gl::Buffer *buffer = binding.getBuffer().get();
    if (!buffer)
    {
        return false;
    }
    BufferD3D *bufferD3D = GetImplAs<BufferD3D>(buffer);
    ASSERT(bufferD3D);
    if (!bufferD3D->supportsDirectBinding())
    {
        return false;
    }
    size_t alignment = 4;
    BufferFactoryD3D *factory = bufferD3D->getFactory();
    angle::FormatID vertexFormatID = attrib.format->id;
    if ((factory->getVertexConversionType(vertexFormatID) & VERTEX_CONVERT_CPU) != 0)
    {
        return false;
    }
    if (attrib.format->vertexAttribType != gl::VertexAttribType::Float)
    {
        unsigned int elementSize = 0;
        angle::Result error =
            factory->getVertexSpaceRequired(context, attrib, binding, 1, 0, 0, &elementSize);
        ASSERT(error == angle::Result::Continue);
        alignment = std::min<size_t>(elementSize, 4);
    }
    GLintptr offset = ComputeVertexAttributeOffset(attrib, binding);
    return (static_cast<size_t>(ComputeVertexAttributeStride(attrib, binding)) % alignment == 0) &&
           (static_cast<size_t>(offset) % alignment == 0);
}
bool DirectStoragePossible ( const gl :: Context * context , const gl :: VertexAttribute & attrib , const gl :: VertexBinding & binding ) { if ( ! attrib . enabled ) { return false ; } gl :: Buffer * buffer = binding . getBuffer ( ) . get ( ) ; if ( ! buffer ) { return false ; } BufferD3D * bufferD3D = GetImplAs < BufferD3D > ( buffer ) ; ASSERT ( bufferD3D ) ; if ( ! bufferD3D -> supportsDirectBinding ( ) ) { return false ; } size_t alignment = 4 ; BufferFactoryD3D * factory = bufferD3D -> getFactory ( ) ; angle :: FormatID vertexFormatID = attrib . format -> id ; if ( ( factory -> getVertexConversionType ( vertexFormatID ) & VERTEX_CONVERT_CPU ) != 0 ) { return false ; } if ( attrib . format -> vertexAttribType != gl :: VertexAttribType :: Float ) { unsigned int elementSize = 0 ; angle :: Result error = factory -> getVertexSpaceRequired ( context , attrib , binding , 1 , 0 , 0 , & elementSize ) ; ASSERT ( error == angle :: Result :: Continue ) ; alignment = std :: min < size_t > ( elementSize , 4 ) ; } GLintptr offset = ComputeVertexAttributeOffset ( attrib , binding ) ; return ( static_cast < size_t > ( ComputeVertexAttributeStride ( attrib , binding ) ) % alignment == 0 ) && ( static_cast < size_t > ( offset ) % alignment == 0 ) ; }
Warning: you should ensure binding really matches attrib.bindingIndex before using this function.
Warning : you should ensure binding really matches attrib . bindingIndex before using this function .
// Current value attribs may not use direct storage. // Alignment restrictions: In D3D, vertex data must be aligned to the format stride, or to a // 4-byte boundary, whichever is smaller. (Undocumented, and experimentally confirmed) // TODO(jmadill): add VertexFormatCaps // CPU-converted vertex data must be converted (naturally). // Final alignment check - unaligned data must be converted.