Edit

kc3-lang/angle/src/libANGLE/renderer/vulkan/CLPlatformVk.cpp

Branch :

  • Show log

    Commit

  • Author : John Plate
    Date : 2021-06-11 19:12:11
    Hash : 69562546
    Message : CL: Refactor info structs and fix conformance bug - Remove variable name prefix from Info structs to be more consistent with other ANGLE structs. - Fix CL object validation check with magics, since the Mesa solution doesn't work without RTTI. - Add support for some extensions required by OpenCL 1.1 and for some optional extensions. - Fix more conformance bugs. Bug: angleproject:6015 Change-Id: I41b1c45d95059a9994f5dc78bf9b74476cc6f2d4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2956349 Commit-Queue: John Plate <jplate@google.com> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>

  • src/libANGLE/renderer/vulkan/CLPlatformVk.cpp
  • //
    // Copyright 2021 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    // CLPlatformVk.cpp: Implements the class methods for CLPlatformVk.
    
    #include "libANGLE/renderer/vulkan/CLPlatformVk.h"
    
    #include "libANGLE/renderer/vulkan/CLDeviceVk.h"
    
    #include "libANGLE/CLPlatform.h"
    
    #include "anglebase/no_destructor.h"
    #include "common/angle_version.h"
    
    namespace rx
    {
    
    namespace
    {
    
    std::string CreateExtensionString(const NameVersionVector &extList)
    {
        std::string extensions;
        for (const cl_name_version &ext : extList)
        {
            extensions += ext.name;
            extensions += ' ';
        }
        if (!extensions.empty())
        {
            extensions.pop_back();
        }
        return extensions;
    }
    
    }  // namespace
    
    CLPlatformVk::~CLPlatformVk() = default;
    
    CLPlatformImpl::Info CLPlatformVk::createInfo() const
    {
        NameVersionVector extList = {
            cl_name_version{CL_MAKE_VERSION(1, 0, 0), "cl_khr_icd"},
            cl_name_version{CL_MAKE_VERSION(1, 0, 0), "cl_khr_extended_versioning"}};
    
        Info info;
        info.initializeExtensions(CreateExtensionString(extList));
        info.profile.assign("FULL_PROFILE");
        info.versionStr.assign(GetVersionString());
        info.version = GetVersion();
        info.name.assign("ANGLE Vulkan");
        info.extensionsWithVersion = std::move(extList);
        info.hostTimerRes          = 0u;
        return info;
    }
    
    CLDeviceImpl::CreateDatas CLPlatformVk::createDevices() const
    {
        cl::DeviceType type;  // TODO(jplate) Fetch device type from Vulkan
        CLDeviceImpl::CreateDatas createDatas;
        createDatas.emplace_back(
            type, [](const cl::Device &device) { return CLDeviceVk::Ptr(new CLDeviceVk(device)); });
        return createDatas;
    }
    
    CLContextImpl::Ptr CLPlatformVk::createContext(cl::Context &context,
                                                   const cl::DevicePtrs &devices,
                                                   bool userSync,
                                                   cl_int &errorCode)
    {
        CLContextImpl::Ptr contextImpl;
        return contextImpl;
    }
    
    CLContextImpl::Ptr CLPlatformVk::createContextFromType(cl::Context &context,
                                                           cl::DeviceType deviceType,
                                                           bool userSync,
                                                           cl_int &errorCode)
    {
        CLContextImpl::Ptr contextImpl;
        return contextImpl;
    }
    
    cl_int CLPlatformVk::unloadCompiler()
    {
        return CL_SUCCESS;
    }
    
    void CLPlatformVk::Initialize(CreateFuncs &createFuncs)
    {
        createFuncs.emplace_back(
            [](const cl::Platform &platform) { return Ptr(new CLPlatformVk(platform)); });
    }
    
    const std::string &CLPlatformVk::GetVersionString()
    {
        static const angle::base::NoDestructor<const std::string> sVersion(
            "OpenCL " + std::to_string(CL_VERSION_MAJOR(GetVersion())) + "." +
            std::to_string(CL_VERSION_MINOR(GetVersion())) + " ANGLE " ANGLE_VERSION_STRING);
        return *sVersion;
    }
    
    CLPlatformVk::CLPlatformVk(const cl::Platform &platform) : CLPlatformImpl(platform) {}
    
    }  // namespace rx