Disable CPU operations for renderCompressed GMM resources

Change-Id: I4396460cab1e030717ea85590775eea0ea92f9db
This commit is contained in:
Dunajski, Bartosz
2018-07-09 15:03:42 +02:00
committed by sys_ocldev
parent 821f31b398
commit e527a439cd
5 changed files with 59 additions and 8 deletions

View File

@@ -22,6 +22,7 @@
#include "runtime/mem_obj/mem_obj.h"
#include "runtime/device/device.h"
#include "runtime/gmm_helper/gmm.h"
#include "runtime/helpers/properties_helper.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_deferred_deleter.h"
@@ -297,10 +298,34 @@ TEST(MemObj, givenTiledObjectWhenAskedForCpuMappingThenReturnFalse) {
EXPECT_FALSE(memObj.mappingOnCpuAllowed());
}
TEST(MemObj, givenRenderCompressedGmmWhenAskingForMappingOnCpuThenDisallow) {
MockMemoryManager memoryManager;
MockContext context;
context.setMemoryManager(&memoryManager);
auto allocation = memoryManager.allocateGraphicsMemory(1, 1);
allocation->gmm = new Gmm(nullptr, 1, false);
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_READ_WRITE,
1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false);
allocation->gmm->isRenderCompressed = false;
EXPECT_TRUE(memObj.mappingOnCpuAllowed());
allocation->gmm->isRenderCompressed = true;
EXPECT_FALSE(memObj.mappingOnCpuAllowed());
}
TEST(MemObj, givenDefaultWhenAskedForCpuMappingThenReturnTrue) {
char mem[64];
MemObj memObj(nullptr, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR,
MemoryConstants::pageSize, mem, nullptr, nullptr, true, false, false);
MockMemoryManager memoryManager;
MockContext context;
context.setMemoryManager(&memoryManager);
auto allocation = memoryManager.allocateGraphicsMemory(64, 1);
MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, CL_MEM_COPY_HOST_PTR,
64, allocation->getUnderlyingBuffer(), nullptr, allocation, true, false, false);
EXPECT_FALSE(memObj.allowTiling());
EXPECT_FALSE(memObj.peekSharingHandler());