| 1 |
/* |
| 2 |
* Copyright (C) 2018-2024 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
|
| 10 |
#include "opencl/source/sharings/gl/gl_sharing.h" |
| 11 |
|
| 12 |
#include "CL/cl_gl.h" |
| 13 |
|
| 14 |
struct _tagCLGLBufferInfo; |
| 15 |
|
| 16 |
namespace NEO { |
| 17 |
class Buffer; |
| 18 |
class Context; |
| 19 |
|
| 20 |
class GlBuffer : public GlSharing { |
| 21 |
public: |
| 22 |
static Buffer *createSharedGlBuffer(Context *context, cl_mem_flags flags, unsigned int bufferId, cl_int *errcodeRet); |
| 23 |
void synchronizeObject(UpdateData &updateData) override; |
| 24 |
void releaseReusedGraphicsAllocation() override; |
| 25 |
|
| 26 |
protected: |
| 27 |
GlBuffer(GLSharingFunctions *sharingFunctions, unsigned int glObjectId) |
| 28 |
: GlSharing(sharingFunctions, CL_GL_OBJECT_BUFFER, glObjectId){}; |
| 29 |
~GlBuffer() override { |
| 30 |
callReleaseResource(true); |
| 31 |
} |
| 32 |
GlBuffer(const GlBuffer &other) = delete; |
| 33 |
GlBuffer &operator=(const GlBuffer &other) = delete; |
| 34 |
void releaseResource(MemObj *memObject, uint32_t rootDeviceIndex) override; |
| 35 |
void callReleaseResource(bool createOrDestroy); |
| 36 |
|
| 37 |
void resolveGraphicsAllocationChange(osHandle currentSharedHandle, UpdateData *updateData) override; |
| 38 |
void popGraphicsAllocationFromReuse(GraphicsAllocation *graphicsAllocation); |
| 39 |
|
| 40 |
static GraphicsAllocation *createGraphicsAllocation(Context *context, unsigned int bufferId, _tagCLGLBufferInfo &bufferInfo); |
| 41 |
}; |
| 42 |
} // namespace NEO |