From 6df593de965f8f73aadb5edcb3e891c27270c2ce Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Mon, 15 Mar 2021 14:45:26 -0400 Subject: [PATCH] SWDEV-276569 - Add P010 support for DX9 Change-Id: I652debccc0fabad89eff3052b884a59d44ee8233 [ROCm/clr commit: 89791c14f94d3c8c083628e1761f07138f92f654] --- projects/clr/opencl/amdocl/cl_d3d9.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/projects/clr/opencl/amdocl/cl_d3d9.cpp b/projects/clr/opencl/amdocl/cl_d3d9.cpp index ca313c3948..23db3ad194 100644 --- a/projects/clr/opencl/amdocl/cl_d3d9.cpp +++ b/projects/clr/opencl/amdocl/cl_d3d9.cpp @@ -29,6 +29,7 @@ #include #define D3DFMT_NV_12 static_cast(MAKEFOURCC('N', 'V', '1', '2')) +#define D3DFMT_P010 static_cast(MAKEFOURCC('P', '0', '1', '0')) #define D3DFMT_YV_12 static_cast(MAKEFOURCC('Y', 'V', '1', '2')) #define D3DFMT_YUY2 static_cast(MAKEFOURCC('Y', 'U', 'Y', '2')) @@ -187,7 +188,9 @@ RUNTIME_ENTRY_RET(cl_mem, clCreateFromDX9MediaSurfaceKHR, D3DSURFACE_DESC Desc; pD3D9Resource->GetDesc(&Desc); - if ((Desc.Format != D3DFMT_NV_12) && (Desc.Format != D3DFMT_YV_12) && (plane != 0)) { + if ((Desc.Format != D3DFMT_NV_12) && + (Desc.Format != D3DFMT_P010) && + (Desc.Format != D3DFMT_YV_12) && (plane != 0)) { *not_null(errcode_ret) = CL_INVALID_VALUE; LogWarning("The plane has to be Zero if the surface format is non-planar !"); return clMemObj; @@ -409,6 +412,13 @@ size_t D3D9Object::getElementBytes(D3DFORMAT d3d9Format, cl_uint plane) { bytesPerPixel = 2; } // plane != 0 or != 1 shouldn't happen here break; + case D3DFMT_P010: + if (plane == 0) { + bytesPerPixel = 2; + } else if (plane == 1) { + bytesPerPixel = 4; + } // plane != 0 or != 1 shouldn't happen here + break; case D3DFMT_YV_12: bytesPerPixel = 1; break; @@ -428,6 +438,7 @@ void setObjDesc(amd::D3D9ObjDesc_t& objDesc, D3DSURFACE_DESC& resDesc, cl_uint p objDesc.d3dFormat_ = resDesc.Format; switch (resDesc.Format) { case D3DFMT_NV_12: + case D3DFMT_P010: objDesc.surfRect_.left = 0; objDesc.surfRect_.top = 0; if (plane == 0) { @@ -586,6 +597,7 @@ int D3D9Object::initD3D9Object(const Context& amdContext, cl_uint D3D9Object::getMiscFlag() { switch (objDescOrig_.d3dFormat_) { case D3DFMT_NV_12: + case D3DFMT_P010: return 1; break; case D3DFMT_YV_12: @@ -698,6 +710,14 @@ cl_image_format D3D9Object::getCLFormatFromD3D9(D3DFORMAT d3d9Fmt, cl_uint plane fmt.image_channel_order = CL_RG; } break; + case D3DFMT_P010: + fmt.image_channel_data_type = CL_UNORM_INT16; + if (plane == 0) { + fmt.image_channel_order = CL_R; + } else if (plane == 1) { + fmt.image_channel_order = CL_RG; + } + break; case D3DFMT_YV_12: fmt.image_channel_order = CL_R; fmt.image_channel_data_type = CL_UNORM_INT8;