Adding support to packed formats
Related-To: NEO-4949 Change-Id: I5cbff44d6463fa6c7aa71f641e11b593a1dcf11e Signed-off-by: Andrzej Koska <andrzej.koska@intel.com>
This commit is contained in:
parent
4ec90b2a56
commit
0cc717b1b4
|
@ -103,6 +103,11 @@ const ClSurfaceFormatInfo SurfaceFormats::planarYuvSurfaceFormats[] = {
|
|||
{{CL_NV12_INTEL, CL_UNORM_INT8}, {GMM_FORMAT_NV12, GFX3DSTATE_SURFACEFORMAT_NV12 , 0, 1, 1, 1}}
|
||||
};
|
||||
|
||||
const ClSurfaceFormatInfo SurfaceFormats::packedSurfaceFormats[] = {
|
||||
{{CL_RG, CL_UNORM_INT16}, {GMM_FORMAT_Y210, GFX3DSTATE_SURFACEFORMAT_PACKED_422_16 , 0, 2, 2, 4}},
|
||||
{{CL_RG, CL_UNORM_INT16}, {GMM_FORMAT_YUY2_2x1, GFX3DSTATE_SURFACEFORMAT_R10G10B10A2_UNORM , 0, 2, 2, 4}}
|
||||
};
|
||||
|
||||
const ClSurfaceFormatInfo SurfaceFormats::readOnlyDepthSurfaceFormats[] = { DEPTHFORMATS, DEPTHSTENCILFORMATS };
|
||||
|
||||
const ClSurfaceFormatInfo SurfaceFormats::readWriteDepthSurfaceFormats[] = { DEPTHFORMATS };
|
||||
|
@ -131,6 +136,11 @@ ArrayRef<const ClSurfaceFormatInfo> SurfaceFormats::planarYuv() noexcept {
|
|||
return ArrayRef<const ClSurfaceFormatInfo>(planarYuvSurfaceFormats);
|
||||
}
|
||||
|
||||
ArrayRef<const ClSurfaceFormatInfo> SurfaceFormats::packed() noexcept
|
||||
{
|
||||
return ArrayRef<const ClSurfaceFormatInfo>(packedSurfaceFormats);
|
||||
}
|
||||
|
||||
ArrayRef<const ClSurfaceFormatInfo> SurfaceFormats::readOnlyDepth() noexcept {
|
||||
return ArrayRef<const ClSurfaceFormatInfo>(readOnlyDepthSurfaceFormats);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ class SurfaceFormats {
|
|||
|
||||
static const ClSurfaceFormatInfo packedYuvSurfaceFormats[];
|
||||
static const ClSurfaceFormatInfo planarYuvSurfaceFormats[];
|
||||
static const ClSurfaceFormatInfo packedSurfaceFormats[];
|
||||
|
||||
public:
|
||||
static ArrayRef<const ClSurfaceFormatInfo> readOnly12() noexcept;
|
||||
|
@ -38,6 +39,7 @@ class SurfaceFormats {
|
|||
static ArrayRef<const ClSurfaceFormatInfo> readWrite() noexcept;
|
||||
static ArrayRef<const ClSurfaceFormatInfo> packedYuv() noexcept;
|
||||
static ArrayRef<const ClSurfaceFormatInfo> planarYuv() noexcept;
|
||||
static ArrayRef<const ClSurfaceFormatInfo> packed() noexcept;
|
||||
static ArrayRef<const ClSurfaceFormatInfo> readOnlyDepth() noexcept;
|
||||
static ArrayRef<const ClSurfaceFormatInfo> readWriteDepth() noexcept;
|
||||
|
||||
|
|
|
@ -82,13 +82,22 @@ void D3DSharing<D3D>::updateImgInfoAndDesc(Gmm *gmm, ImageInfo &imgInfo, ImagePl
|
|||
}
|
||||
|
||||
template <typename D3D>
|
||||
const ClSurfaceFormatInfo *D3DSharing<D3D>::findSurfaceFormatInfo(GMM_RESOURCE_FORMAT_ENUM gmmFormat, cl_mem_flags flags, bool supportsOcl20Features) {
|
||||
const ClSurfaceFormatInfo *D3DSharing<D3D>::findSurfaceFormatInfo(GMM_RESOURCE_FORMAT_ENUM gmmFormat, cl_mem_flags flags, bool supportsOcl20Features, bool packedSupported) {
|
||||
ArrayRef<const ClSurfaceFormatInfo> formats = SurfaceFormats::surfaceFormats(flags, supportsOcl20Features);
|
||||
for (auto &format : formats) {
|
||||
if (gmmFormat == format.surfaceFormat.GMMSurfaceFormat) {
|
||||
return &format;
|
||||
}
|
||||
}
|
||||
if (packedSupported) {
|
||||
formats = SurfaceFormats::packed();
|
||||
for (auto &format : formats) {
|
||||
if (gmmFormat == format.surfaceFormat.GMMSurfaceFormat) {
|
||||
return &format;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class D3DSharing : public SharingHandler {
|
|||
unsigned int &getSubresource() { return subresource; }
|
||||
typename D3DQuery *getQuery() { return d3dQuery; }
|
||||
bool isSharedResource() { return sharedResource; }
|
||||
static const ClSurfaceFormatInfo *findSurfaceFormatInfo(GMM_RESOURCE_FORMAT_ENUM gmmFormat, cl_mem_flags flags, bool supportsOcl20Features);
|
||||
static const ClSurfaceFormatInfo *findSurfaceFormatInfo(GMM_RESOURCE_FORMAT_ENUM gmmFormat, cl_mem_flags flags, bool supportsOcl20Features, bool packedSupported);
|
||||
static bool isFormatWithPlane1(DXGI_FORMAT format);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -99,17 +99,17 @@ Image *D3DTexture<D3D>::create2d(Context *context, D3DTexture2d *d3dTexture, cl_
|
|||
|
||||
auto d3dTextureObj = new D3DTexture<D3D>(context, d3dTexture, subresource, textureStaging, sharedResource);
|
||||
|
||||
auto hwInfo = memoryManager->peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
||||
auto &hwHelper = HwHelper::get(hwInfo->platform.eRenderCoreFamily);
|
||||
const ClSurfaceFormatInfo *clSurfaceFormat = nullptr;
|
||||
if ((textureDesc.Format == DXGI_FORMAT_NV12) || (textureDesc.Format == DXGI_FORMAT_P010) || (textureDesc.Format == DXGI_FORMAT_P016)) {
|
||||
clSurfaceFormat = findYuvSurfaceFormatInfo(textureDesc.Format, imagePlane, flags);
|
||||
imgInfo.surfaceFormat = &clSurfaceFormat->surfaceFormat;
|
||||
} else {
|
||||
clSurfaceFormat = findSurfaceFormatInfo(alloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat(), flags, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
|
||||
clSurfaceFormat = findSurfaceFormatInfo(alloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat(), flags, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features, hwHelper.packedFormatsSupported());
|
||||
imgInfo.surfaceFormat = &clSurfaceFormat->surfaceFormat;
|
||||
}
|
||||
|
||||
auto hwInfo = memoryManager->peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
||||
auto &hwHelper = HwHelper::get(hwInfo->platform.eRenderCoreFamily);
|
||||
if (alloc->getDefaultGmm()->unifiedAuxTranslationCapable()) {
|
||||
alloc->getDefaultGmm()->isRenderCompressed = hwHelper.isPageTableManagerSupported(*hwInfo) ? memoryManager->mapAuxGpuVA(alloc)
|
||||
: true;
|
||||
|
@ -182,14 +182,14 @@ Image *D3DTexture<D3D>::create3d(Context *context, D3DTexture3d *d3dTexture, cl_
|
|||
|
||||
updateImgInfoAndDesc(alloc->getDefaultGmm(), imgInfo, ImagePlane::NO_PLANE, 0u);
|
||||
|
||||
auto hwInfo = memoryManager->peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
||||
auto &hwHelper = HwHelper::get(hwInfo->platform.eRenderCoreFamily);
|
||||
auto d3dTextureObj = new D3DTexture<D3D>(context, d3dTexture, subresource, textureStaging, sharedResource);
|
||||
auto *clSurfaceFormat = findSurfaceFormatInfo(alloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat(), flags, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
|
||||
auto *clSurfaceFormat = findSurfaceFormatInfo(alloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat(), flags, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features, hwHelper.packedFormatsSupported());
|
||||
imgInfo.qPitch = alloc->getDefaultGmm()->queryQPitch(GMM_RESOURCE_TYPE::RESOURCE_3D);
|
||||
|
||||
imgInfo.surfaceFormat = &clSurfaceFormat->surfaceFormat;
|
||||
|
||||
auto hwInfo = memoryManager->peekExecutionEnvironment().rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
||||
auto &hwHelper = HwHelper::get(hwInfo->platform.eRenderCoreFamily);
|
||||
if (alloc->getDefaultGmm()->unifiedAuxTranslationCapable()) {
|
||||
alloc->getDefaultGmm()->isRenderCompressed = hwHelper.isPageTableManagerSupported(*hwInfo) ? memoryManager->mapAuxGpuVA(alloc)
|
||||
: true;
|
||||
|
|
|
@ -680,6 +680,26 @@ TYPED_TEST_P(D3DTests, givenInvalidSubresourceWhenCreateTexture3dIsCalledThenFai
|
|||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
}
|
||||
|
||||
TYPED_TEST_P(D3DTests, givenPackedFormatWhenLookingForSurfaceFormatWithPackedNotSupportedThenReturnNull) {
|
||||
EXPECT_GT(SurfaceFormats::packed().size(), 0u);
|
||||
for (auto &format : SurfaceFormats::packed()) {
|
||||
auto surfaceFormat = D3DSharing<TypeParam>::findSurfaceFormatInfo(format.surfaceFormat.GMMSurfaceFormat, CL_MEM_READ_ONLY, false /* supportsOcl20Features */, false /* packedSupported */);
|
||||
ASSERT_EQ(nullptr, surfaceFormat);
|
||||
}
|
||||
}
|
||||
|
||||
TYPED_TEST_P(D3DTests, givenPackedFormatWhenLookingForSurfaceFormatWithPackedSupportedThenReturnValidFormat) {
|
||||
EXPECT_GT(SurfaceFormats::packed().size(), 0u);
|
||||
uint32_t counter = 0;
|
||||
for (auto &format : SurfaceFormats::packed()) {
|
||||
auto surfaceFormat = D3DSharing<TypeParam>::findSurfaceFormatInfo(format.surfaceFormat.GMMSurfaceFormat, CL_MEM_READ_ONLY, false /* supportsOcl20Features */, true /* packedSupported */);
|
||||
ASSERT_NE(nullptr, surfaceFormat);
|
||||
counter++;
|
||||
EXPECT_EQ(&format, surfaceFormat);
|
||||
}
|
||||
EXPECT_NE(counter, 0U);
|
||||
}
|
||||
|
||||
TYPED_TEST_P(D3DTests, givenReadonlyFormatWhenLookingForSurfaceFormatThenReturnValidFormat) {
|
||||
EXPECT_GT(SurfaceFormats::readOnly12().size(), 0u);
|
||||
for (auto &format : SurfaceFormats::readOnly12()) {
|
||||
|
@ -688,7 +708,7 @@ TYPED_TEST_P(D3DTests, givenReadonlyFormatWhenLookingForSurfaceFormatThenReturnV
|
|||
format.OCLImageFormat.image_channel_order == CL_BGRA ||
|
||||
format.OCLImageFormat.image_channel_order == CL_RG ||
|
||||
format.OCLImageFormat.image_channel_order == CL_R) {
|
||||
auto surfaceFormat = D3DSharing<TypeParam>::findSurfaceFormatInfo(format.surfaceFormat.GMMSurfaceFormat, CL_MEM_READ_ONLY, false /* supportsOcl20Features */);
|
||||
auto surfaceFormat = D3DSharing<TypeParam>::findSurfaceFormatInfo(format.surfaceFormat.GMMSurfaceFormat, CL_MEM_READ_ONLY, false /* supportsOcl20Features */, true);
|
||||
ASSERT_NE(nullptr, surfaceFormat);
|
||||
EXPECT_EQ(&format, surfaceFormat);
|
||||
}
|
||||
|
@ -703,7 +723,7 @@ TYPED_TEST_P(D3DTests, givenWriteOnlyFormatWhenLookingForSurfaceFormatThenReturn
|
|||
format.OCLImageFormat.image_channel_order == CL_BGRA ||
|
||||
format.OCLImageFormat.image_channel_order == CL_RG ||
|
||||
format.OCLImageFormat.image_channel_order == CL_R) {
|
||||
auto surfaceFormat = D3DSharing<TypeParam>::findSurfaceFormatInfo(format.surfaceFormat.GMMSurfaceFormat, CL_MEM_WRITE_ONLY, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
|
||||
auto surfaceFormat = D3DSharing<TypeParam>::findSurfaceFormatInfo(format.surfaceFormat.GMMSurfaceFormat, CL_MEM_WRITE_ONLY, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features, true);
|
||||
ASSERT_NE(nullptr, surfaceFormat);
|
||||
EXPECT_EQ(&format, surfaceFormat);
|
||||
}
|
||||
|
@ -718,7 +738,7 @@ TYPED_TEST_P(D3DTests, givenReadWriteFormatWhenLookingForSurfaceFormatThenReturn
|
|||
format.OCLImageFormat.image_channel_order == CL_BGRA ||
|
||||
format.OCLImageFormat.image_channel_order == CL_RG ||
|
||||
format.OCLImageFormat.image_channel_order == CL_R) {
|
||||
auto surfaceFormat = D3DSharing<TypeParam>::findSurfaceFormatInfo(format.surfaceFormat.GMMSurfaceFormat, CL_MEM_READ_WRITE, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
|
||||
auto surfaceFormat = D3DSharing<TypeParam>::findSurfaceFormatInfo(format.surfaceFormat.GMMSurfaceFormat, CL_MEM_READ_WRITE, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features, true);
|
||||
ASSERT_NE(nullptr, surfaceFormat);
|
||||
EXPECT_EQ(&format, surfaceFormat);
|
||||
}
|
||||
|
@ -756,7 +776,9 @@ REGISTER_TYPED_TEST_CASE_P(D3DTests,
|
|||
givenP016FormatAndEvenPlaneWhen2dCreatedThenSetPlaneParams,
|
||||
givenNV12FormatAndOddPlaneWhen2dCreatedThenSetPlaneParams,
|
||||
givenP010FormatAndOddPlaneWhen2dCreatedThenSetPlaneParams,
|
||||
givenP016FormatAndOddPlaneWhen2dCreatedThenSetPlaneParams);
|
||||
givenP016FormatAndOddPlaneWhen2dCreatedThenSetPlaneParams,
|
||||
givenPackedFormatWhenLookingForSurfaceFormatWithPackedNotSupportedThenReturnNull,
|
||||
givenPackedFormatWhenLookingForSurfaceFormatWithPackedSupportedThenReturnValidFormat);
|
||||
|
||||
INSTANTIATE_TYPED_TEST_CASE_P(D3DSharingTests, D3DTests, D3DTypes);
|
||||
|
||||
|
|
|
@ -364,3 +364,8 @@ GEN12LPTEST_F(HwHelperTestGen12Lp, givenUnknownProductFamilyWhenGettingIsWorkaro
|
|||
EXPECT_FALSE(hwHelper.isWorkaroundRequired(REVISION_B, REVISION_A0, hardwareInfo));
|
||||
}
|
||||
}
|
||||
|
||||
GEN12LPTEST_F(HwHelperTestGen12Lp, givenGen12WhenCallIsPackedSupportedThenReturnTrue) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
EXPECT_TRUE(helper.packedFormatsSupported());
|
||||
}
|
||||
|
|
|
@ -17,6 +17,11 @@ GEN9TEST_F(HwHelperTestGen9, getMaxBarriersPerSliceReturnsCorrectSize) {
|
|||
EXPECT_EQ(32u, helper.getMaxBarrierRegisterPerSlice());
|
||||
}
|
||||
|
||||
GEN9TEST_F(HwHelperTestGen9, givenGen9WhenCallIsPackedSupportedThenReturnFalse) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
EXPECT_FALSE(helper.packedFormatsSupported());
|
||||
}
|
||||
|
||||
GEN9TEST_F(HwHelperTestGen9, setCapabilityCoherencyFlag) {
|
||||
auto &helper = HwHelper::get(renderCoreFamily);
|
||||
|
||||
|
|
|
@ -117,6 +117,7 @@ void MockGmmResourceInfo::setSurfaceFormat() {
|
|||
|
||||
iterate(SurfaceFormats::packedYuv());
|
||||
iterate(SurfaceFormats::planarYuv());
|
||||
iterate(SurfaceFormats::packed());
|
||||
|
||||
iterate(SurfaceFormats::readOnlyDepth());
|
||||
iterate(SurfaceFormats::readWriteDepth());
|
||||
|
|
|
@ -125,6 +125,7 @@ class HwHelper {
|
|||
virtual bool heapInLocalMem(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool useOnlyGlobalTimestamps() const = 0;
|
||||
virtual bool useSystemMemoryPlacementForISA(const HardwareInfo &hwInfo) const = 0;
|
||||
virtual bool packedFormatsSupported() const = 0;
|
||||
|
||||
static uint32_t getSubDevicesCount(const HardwareInfo *pHwInfo);
|
||||
static uint32_t getEnginesCount(const HardwareInfo &hwInfo);
|
||||
|
@ -309,6 +310,8 @@ class HwHelperHw : public HwHelper {
|
|||
|
||||
bool useSystemMemoryPlacementForISA(const HardwareInfo &hwInfo) const override;
|
||||
|
||||
bool packedFormatsSupported() const override;
|
||||
|
||||
protected:
|
||||
LocalMemoryAccessMode getDefaultLocalMemoryAccessMode(const HardwareInfo &hwInfo) const override;
|
||||
|
||||
|
|
|
@ -496,4 +496,10 @@ template <typename GfxFamily>
|
|||
bool HwHelperHw<GfxFamily>::useSystemMemoryPlacementForISA(const HardwareInfo &hwInfo) const {
|
||||
return !hwInfo.featureTable.ftrLocalMemory;
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
bool HwHelperHw<GfxFamily>::packedFormatsSupported() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
|
|
@ -27,4 +27,9 @@ void LriHelper<Family>::program(LinearStream *cmdStream, uint32_t address, uint3
|
|||
*lri = cmd;
|
||||
}
|
||||
|
||||
template <>
|
||||
bool HwHelperHw<Family>::packedFormatsSupported() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
|
|
@ -177,6 +177,7 @@ enum GFX3DSTATE_SURFACEFORMAT : unsigned short {
|
|||
GFX3DSTATE_SURFACEFORMAT_BC6H_UF16 = 0x1A4,
|
||||
GFX3DSTATE_SURFACEFORMAT_NV12 = 0x1A5,
|
||||
GFX3DSTATE_SURFACEFORMAT_PLANAR_420_16 = 0x1a6,
|
||||
GFX3DSTATE_SURFACEFORMAT_PACKED_422_16 = 0x1a7,
|
||||
GFX3DSTATE_SURFACEFORMAT_R10G10B10A2_SINT = 0x1b6,
|
||||
GFX3DSTATE_SURFACEFORMAT_R10G10B10A2_SNORM = 0x1b3,
|
||||
GFX3DSTATE_SURFACEFORMAT_RAW = 0x1FF,
|
||||
|
|
Loading…
Reference in New Issue