Aux format support check for render compressed resources

Change-Id: Ief7c5cc436c781e5b90cf71b17bf7c15c63c5c14
This commit is contained in:
Dunajski, Bartosz
2018-01-16 09:34:31 +01:00
parent 111897132e
commit 3df51c3e88
3 changed files with 30 additions and 11 deletions

View File

@@ -176,7 +176,7 @@ void Gmm::queryImageParams(ImageInfo &imgInfo, const HardwareInfo &hwInfo) {
this->resourceParams.Flags.Info.AllowVirtualPadding = true;
}
if (hwInfo.capabilityTable.ftrCompression && imgInfo.preferRenderCompression) {
if (hwInfo.capabilityTable.ftrCompression && imgInfo.preferRenderCompression && auxFormatSupported(this->resourceParams.Format)) {
this->resourceParams.Flags.Info.Linear = 0;
this->resourceParams.Flags.Info.TiledY = 1;
this->resourceParams.Flags.Info.RenderCompressed = 1;
@@ -392,4 +392,9 @@ uint8_t Gmm::resourceCopyBlt(void *sys, void *gpu, uint32_t pitch, uint32_t heig
return this->gmmResourceInfo->cpuBlt(&gmmResourceCopyBLT);
}
bool Gmm::auxFormatSupported(GMM_RESOURCE_FORMAT &gmmFormat) {
const auto &formatInfo = pGmmGlobalContext->GetPlatformInfo().FormatTable[gmmFormat];
return !!formatInfo.AuxL1eFormat;
}
} // namespace OCLRT

View File

@@ -82,6 +82,7 @@ class Gmm {
uint32_t getRenderHAlignment();
uint32_t getRenderVAlignment();
static uint32_t getRenderAlignment(uint32_t alignment);
bool auxFormatSupported(GMM_RESOURCE_FORMAT &gmmFormat);
uint32_t queryQPitch(GFXCORE_FAMILY gfxFamily, GMM_RESOURCE_TYPE resType);

View File

@@ -31,23 +31,23 @@ struct GmmCompressionTests : public ::testing::Test {
void SetUp() override {
localPlatformDevice = **platformDevices;
localPlatformDevice.capabilityTable.ftrCompression = true;
setupImgInfo();
}
void setupImgDesc() {
void setupImgInfo() {
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
imgDesc.image_width = 2;
imgDesc.image_height = 2;
imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
imgInfo.preferRenderCompression = true;
}
HardwareInfo localPlatformDevice = {};
cl_image_desc imgDesc = {};
ImageInfo imgInfo = {};
};
TEST_F(GmmCompressionTests, givenPreferRenderCompressionAndCompressionFtrEnabledWhenQueryingThenSetAppropriateFlags) {
setupImgDesc();
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
imgInfo.preferRenderCompression = true;
auto queryGmm = MockGmm::queryImgParams(imgInfo, &localPlatformDevice);
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Info.Linear);
@@ -59,9 +59,6 @@ TEST_F(GmmCompressionTests, givenPreferRenderCompressionAndCompressionFtrEnabled
}
TEST_F(GmmCompressionTests, givenPreferRenderCompressionAndCompressionFtrDisabledWhenQueryingThenSetAppropriateFlags) {
setupImgDesc();
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
imgInfo.preferRenderCompression = true;
localPlatformDevice.capabilityTable.ftrCompression = false;
auto queryGmm = MockGmm::queryImgParams(imgInfo, &localPlatformDevice);
@@ -73,8 +70,6 @@ TEST_F(GmmCompressionTests, givenPreferRenderCompressionAndCompressionFtrDisable
}
TEST_F(GmmCompressionTests, givenPreferRenderCompressionDisabledAndCompressionFtrEnabledWhenQueryingThenSetAppropriateFlags) {
setupImgDesc();
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
imgInfo.preferRenderCompression = false;
auto queryGmm = MockGmm::queryImgParams(imgInfo, &localPlatformDevice);
@@ -84,3 +79,21 @@ TEST_F(GmmCompressionTests, givenPreferRenderCompressionDisabledAndCompressionFt
EXPECT_EQ(0u, queryGmm->resourceParams.Flags.Gpu.UnifiedAuxSurface);
EXPECT_FALSE(queryGmm->isRenderCompressed);
}
TEST_F(GmmCompressionTests, givenSupportedAuxL1FormatWhenQueryingThenAllow) {
auto queryGmm = MockGmm::queryImgParams(imgInfo, &localPlatformDevice);
auto resourceFormat = queryGmm->gmmResourceInfo->getResourceFormat();
EXPECT_TRUE(queryGmm->auxFormatSupported(resourceFormat));
EXPECT_TRUE(queryGmm->isRenderCompressed);
}
TEST_F(GmmCompressionTests, givenNotSupportedAuxL1FormatWhenQueryingThenDisallow) {
imgInfo.surfaceFormat = &readOnlyDepthSurfaceFormats[2];
auto queryGmm = MockGmm::queryImgParams(imgInfo, &localPlatformDevice);
auto resourceFormat = queryGmm->gmmResourceInfo->getResourceFormat();
EXPECT_FALSE(queryGmm->auxFormatSupported(resourceFormat));
EXPECT_FALSE(queryGmm->isRenderCompressed);
}