P4 to Git Change 1524071 by gandryey@gera-w8 on 2018/03/07 17:26:30

SWDEV-147487 - DX9/DX11 texture and OpenCL interop for YUY2
	- Enable YUY2 support for DX11 and DX9. YUY2 contains just one plane of interleaved Y0UY1V components and can be mapped to (CL_RGBA, CL_UNSIGNED_INT8) with image width reduced by 2. YUY2 provides better quality due to 16bit data per pixel

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d11.cpp#23 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_d3d9.cpp#33 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.cpp#241 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palresource.cpp#49 edit
This commit is contained in:
foreman
2018-03-07 17:35:30 -05:00
orang tua 01d0171196
melakukan ac8d2437d0
2 mengubah file dengan 22 tambahan dan 3 penghapusan
+10
Melihat File
@@ -600,6 +600,9 @@ cl_uint D3D11Object::getMiscFlag() {
if (objDesc_.dxgiFormat_ == DXGI_FORMAT_NV12) {
return 1;
}
else if (objDesc_.dxgiFormat_ == DXGI_FORMAT_YUY2) {
return 3;
}
return 0;
}
@@ -815,6 +818,10 @@ int D3D11Object::initD3D11Object(const Context& amdContext, ID3D11Resource* pRes
obj.objDesc_.objSize_.Height /= 2;
}
}
// RGBA8 covers 2 pixels, thus divide width by 2
if (desc.Format == DXGI_FORMAT_YUY2) {
obj.objDesc_.objSize_.Width /= 2;
}
} break;
case D3D11_RESOURCE_DIMENSION_TEXTURE3D: // = 4
@@ -1450,6 +1457,8 @@ size_t D3D11Object::getElementBytes(DXGI_FORMAT dxgiFmt, cl_uint plane) {
case DXGI_FORMAT_B8G8R8A8_UNORM:
case DXGI_FORMAT_B8G8R8X8_UNORM:
case DXGI_FORMAT_YUY2:
bytesPerPixel = 4;
break;
@@ -1651,6 +1660,7 @@ cl_image_format D3D11Object::getCLFormatFromDXGI(DXGI_FORMAT dxgiFmt, cl_uint pl
break;
case DXGI_FORMAT_R8G8B8A8_UINT:
case DXGI_FORMAT_YUY2:
fmt.image_channel_order = CL_RGBA;
fmt.image_channel_data_type = CL_UNSIGNED_INT8;
break;
+12 -3
Melihat File
@@ -16,6 +16,7 @@
#define D3DFMT_NV_12 static_cast<D3DFORMAT>(MAKEFOURCC('N', 'V', '1', '2'))
#define D3DFMT_YV_12 static_cast<D3DFORMAT>(MAKEFOURCC('Y', 'V', '1', '2'))
#define D3DFMT_YUY2 static_cast<D3DFORMAT>(MAKEFOURCC('Y', 'U', 'Y', '2'))
RUNTIME_ENTRY(cl_int, clGetDeviceIDsFromDX9MediaAdapterKHR,
@@ -306,7 +307,6 @@ size_t D3D9Object::getElementBytes(D3DFORMAT d3d9Format, cl_uint plane) {
switch (d3d9Format) {
case D3DFMT_UNKNOWN:
case D3DFMT_UYVY:
case D3DFMT_YUY2:
case D3DFMT_DXT1:
case D3DFMT_DXT2:
case D3DFMT_DXT3:
@@ -372,6 +372,7 @@ size_t D3D9Object::getElementBytes(D3DFORMAT d3d9Format, cl_uint plane) {
case D3DFMT_R8G8_B8G8:
case D3DFMT_G8R8_G8B8:
case D3DFMT_G16R16F:
case D3DFMT_YUY2:
bytesPerPixel = 4;
break;
@@ -459,6 +460,9 @@ void setObjDesc(amd::D3D9ObjDesc_t& objDesc, D3DSURFACE_DESC& resDesc, cl_uint p
objDesc.surfRect_.top = 0;
objDesc.surfRect_.right = resDesc.Width - 1;
objDesc.surfRect_.bottom = resDesc.Height - 1;
if (resDesc.Format == D3DFMT_YUY2) {
objDesc.objSize_.Width >>= 1;
}
break;
}
}
@@ -576,6 +580,9 @@ cl_uint D3D9Object::getMiscFlag() {
case D3DFMT_YV_12:
return 2;
break;
case D3DFMT_YUY2:
return 3;
break;
default:
return 0;
break;
@@ -684,7 +691,10 @@ cl_image_format D3D9Object::getCLFormatFromD3D9(D3DFORMAT d3d9Fmt, cl_uint plane
fmt.image_channel_order = CL_R;
fmt.image_channel_data_type = CL_UNORM_INT8;
break;
case D3DFMT_YUY2:
fmt.image_channel_order = CL_RGBA;
fmt.image_channel_data_type = CL_UNSIGNED_INT8;
break;
case D3DFMT_UNKNOWN:
case D3DFMT_R8G8B8:
case D3DFMT_R5G6B5:
@@ -707,7 +717,6 @@ cl_image_format D3D9Object::getCLFormatFromD3D9(D3DFORMAT d3d9Fmt, cl_uint plane
case D3DFMT_A2W10V10U10:
case D3DFMT_UYVY:
case D3DFMT_R8G8_B8G8:
case D3DFMT_YUY2:
case D3DFMT_G8R8_G8B8:
case D3DFMT_DXT1:
case D3DFMT_DXT2: