| 1 |
/* |
| 2 |
* Copyright (C) 2018-2023 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#pragma once |
| 9 |
#include "opencl/source/sharings/d3d/d3d_sharing.h" |
| 10 |
|
| 11 |
#include "CL/cl_dx9_media_sharing.h" |
| 12 |
|
| 13 |
#include <map> |
| 14 |
|
| 15 |
struct ErrorCodeHelper; |
| 16 |
namespace NEO { |
| 17 |
enum class ImagePlane; |
| 18 |
class Image; |
| 19 |
class Context; |
| 20 |
|
| 21 |
class D3DSurface : public D3DSharing<D3DTypesHelper::D3D9> { |
| 22 |
typedef typename D3DTypesHelper::D3D9::D3DTexture2dDesc D3D9SurfaceDesc; |
| 23 |
typedef typename D3DTypesHelper::D3D9::D3DTexture2d D3D9Surface; |
| 24 |
typedef typename D3DTypesHelper::D3D9::D3DResource D3DResource; |
| 25 |
typedef typename D3DTypesHelper::D3D9::D3DDevice D3DDevice; |
| 26 |
|
| 27 |
public: |
| 28 |
static Image *create(Context *context, cl_dx9_surface_info_khr *surfaceInfo, cl_mem_flags flags, |
| 29 |
cl_dx9_media_adapter_type_khr adapterType, cl_uint plane, cl_int *retCode); |
| 30 |
static const std::map<const D3DFORMAT, const cl_image_format> D3DtoClFormatConversions; |
| 31 |
static const std::vector<D3DFORMAT> D3DPlane1Formats; |
| 32 |
static const std::vector<D3DFORMAT> D3DPlane2Formats; |
| 33 |
static cl_int findImgFormat(D3DFORMAT d3dFormat, cl_image_format &imgFormat, cl_uint plane, ImagePlane &imagePlane); |
| 34 |
void synchronizeObject(UpdateData &updateData) override; |
| 35 |
void releaseResource(MemObj *memObject, uint32_t rootDeviceIndex) override; |
| 36 |
int validateUpdateData(UpdateData &updateData) override; |
| 37 |
|
| 38 |
cl_dx9_surface_info_khr &getSurfaceInfo() { return surfaceInfo; } |
| 39 |
cl_dx9_media_adapter_type_khr &getAdapterType() { return adapterType; } |
| 40 |
cl_uint &getPlane() { return plane; } |
| 41 |
|
| 42 |
~D3DSurface() override = default; |
| 43 |
const bool lockable = false; |
| 44 |
|
| 45 |
protected: |
| 46 |
D3DSurface(Context *context, cl_dx9_surface_info_khr *surfaceInfo, D3D9Surface *surfaceStaging, cl_uint plane, |
| 47 |
ImagePlane imagePlane, cl_dx9_media_adapter_type_khr adapterType, bool sharedResource, bool lockable); |
| 48 |
cl_dx9_media_adapter_type_khr adapterType = 0u; |
| 49 |
cl_dx9_surface_info_khr surfaceInfo = {}; |
| 50 |
cl_uint plane = 0; |
| 51 |
ImagePlane imagePlane; |
| 52 |
|
| 53 |
D3D9Surface *d3d9Surface = nullptr; |
| 54 |
D3D9Surface *d3d9SurfaceStaging = nullptr; |
| 55 |
D3DDevice *resourceDevice = nullptr; |
| 56 |
}; |
| 57 |
} // namespace NEO |