Hash :
c62c0c25
Author :
Date :
2024-01-24T17:29:45
CL/VK: Implement initial enqueueRead/WriteBuffer Bug: angleproject:8638 Change-Id: I1d5b3b15fab24ce35c243a3eb27bcac2104d7f5d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5409250 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Austin Annestrand <a.annestrand@samsung.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
//
// 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.
//
// CLContextVk.h: Defines the class interface for CLContextVk, implementing CLContextImpl.
#ifndef LIBANGLE_RENDERER_VULKAN_CLCONTEXTVK_H_
#define LIBANGLE_RENDERER_VULKAN_CLCONTEXTVK_H_
#include "libANGLE/renderer/vulkan/CLPlatformVk.h"
#include "libANGLE/renderer/vulkan/cl_types.h"
#include "libANGLE/renderer/vulkan/vk_utils.h"
#include "libANGLE/renderer/CLContextImpl.h"
#include <libANGLE/CLContext.h>
#include "libANGLE/CLDevice.h"
namespace rx
{
class CLContextVk : public CLContextImpl, public vk::Context
{
public:
CLContextVk(const cl::Context &context, const cl::DevicePtrs devicePtrs);
~CLContextVk() override;
void handleError(VkResult errorCode,
const char *file,
const char *function,
unsigned int line) override;
bool hasMemory(cl_mem memory) const;
angle::Result getDevices(cl::DevicePtrs *devicePtrsOut) const override;
angle::Result createCommandQueue(const cl::CommandQueue &commandQueue,
CLCommandQueueImpl::Ptr *commandQueueOut) override;
angle::Result createBuffer(const cl::Buffer &buffer,
void *hostPtr,
CLMemoryImpl::Ptr *bufferOut) override;
angle::Result createImage(const cl::Image &image,
cl::MemFlags flags,
const cl_image_format &format,
const cl::ImageDescriptor &desc,
void *hostPtr,
CLMemoryImpl::Ptr *imageOut) override;
angle::Result getSupportedImageFormats(cl::MemFlags flags,
cl::MemObjectType imageType,
cl_uint numEntries,
cl_image_format *imageFormats,
cl_uint *numImageFormats) override;
angle::Result createSampler(const cl::Sampler &sampler,
CLSamplerImpl::Ptr *samplerOut) override;
angle::Result createProgramWithSource(const cl::Program &program,
const std::string &source,
CLProgramImpl::Ptr *programOut) override;
angle::Result createProgramWithIL(const cl::Program &program,
const void *il,
size_t length,
CLProgramImpl::Ptr *programOut) override;
angle::Result createProgramWithBinary(const cl::Program &program,
const size_t *lengths,
const unsigned char **binaries,
cl_int *binaryStatus,
CLProgramImpl::Ptr *programOut) override;
angle::Result createProgramWithBuiltInKernels(const cl::Program &program,
const char *kernel_names,
CLProgramImpl::Ptr *programOut) override;
angle::Result linkProgram(const cl::Program &program,
const cl::DevicePtrs &devices,
const char *options,
const cl::ProgramPtrs &inputPrograms,
cl::Program *notify,
CLProgramImpl::Ptr *programOut) override;
angle::Result createUserEvent(const cl::Event &event, CLEventImpl::Ptr *eventOut) override;
angle::Result waitForEvents(const cl::EventPtrs &events) override;
CLPlatformVk *getPlatform() { return &mContext.getPlatform().getImpl<CLPlatformVk>(); }
cl::Context &getFrontendObject() { return const_cast<cl::Context &>(mContext); }
private:
void handleDeviceLost() const;
// Have the CL Context keep tabs on associated CL objects
struct Mutable
{
std::unordered_set<const _cl_mem *> mMemories;
};
using MutableData = angle::SynchronizedValue<Mutable>;
MutableData mAssociatedObjects;
const cl::DevicePtrs mAssociatedDevices;
friend class CLMemoryVk;
};
inline bool CLContextVk::hasMemory(cl_mem memory) const
{
const auto data = mAssociatedObjects.synchronize();
return data->mMemories.find(memory) != data->mMemories.cend();
}
} // namespace rx
#endif // LIBANGLE_RENDERER_VULKAN_CLCONTEXTVK_H_