Skip to content

Commit bb7f8d9

Browse files
Disable compression when using hostPtr
Change-Id: Ifa066a3824f51b4ad5957de9fe8590853c620587 Signed-off-by: Maciej Plewka <[email protected]>
1 parent 6a1a28c commit bb7f8d9

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

runtime/mem_obj/buffer.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@ Buffer *Buffer::create(Context *context,
143143
if (allocationType == GraphicsAllocation::AllocationType::BUFFER_COMPRESSED) {
144144
zeroCopyAllowed = false;
145145
allocateMemory = true;
146-
if (properties.flags & CL_MEM_USE_HOST_PTR) {
147-
copyMemoryFromHostPtr = true;
148-
}
149146
}
150147

151148
if (allocationType == GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY) {
@@ -322,9 +319,11 @@ void Buffer::checkMemory(cl_mem_flags flags,
322319

323320
GraphicsAllocation::AllocationType Buffer::getGraphicsAllocationType(cl_mem_flags flags, bool sharedContext, bool renderCompressedBuffers) {
324321
GraphicsAllocation::AllocationType type = GraphicsAllocation::AllocationType::BUFFER;
325-
if (renderCompressedBuffers) {
322+
if (flags & CL_MEM_USE_HOST_PTR) {
323+
type = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
324+
} else if (renderCompressedBuffers) {
326325
type = GraphicsAllocation::AllocationType::BUFFER_COMPRESSED;
327-
} else if ((flags & CL_MEM_USE_HOST_PTR) || (flags & CL_MEM_ALLOC_HOST_PTR)) {
326+
} else if (flags & CL_MEM_ALLOC_HOST_PTR) {
328327
type = GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
329328
}
330329

unit_tests/mem_obj/buffer_tests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,10 @@ TEST(Buffer, givenAllocHostPtrFlagWhenAllocationTypeIsQueriedThenBufferHostMemor
334334
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
335335
}
336336

337-
TEST(Buffer, givenUseHostPtrFlagAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferCompressedTypeIsReturned) {
337+
TEST(Buffer, givenUseHostPtrFlagAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
338338
cl_mem_flags flags = CL_MEM_USE_HOST_PTR;
339339
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(flags, false, true);
340-
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, type);
340+
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
341341
}
342342

343343
TEST(Buffer, givenAllocHostPtrFlagAndRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenBufferCompressedTypeIsReturned) {
@@ -395,7 +395,7 @@ struct RenderCompressedBuffersTests : public ::testing::Test {
395395
std::unique_ptr<Buffer> buffer;
396396
};
397397

398-
TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationAndZeroCopyHostPtrWhenCheckingMemoryPropertiesThenForceDisableZeroCopyAndAllocateStorage) {
398+
TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationAndZeroCopyHostPtrWhenCheckingMemoryPropertiesThenUseHostPtrAndDontAllocateStorage) {
399399
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
400400

401401
void *cacheAlignedHostPtr = alignedMalloc(MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize);
@@ -419,9 +419,9 @@ TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationAndZeroCopyH
419419

420420
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
421421
buffer.reset(Buffer::create(context.get(), CL_MEM_USE_HOST_PTR, MemoryConstants::cacheLineSize, cacheAlignedHostPtr, retVal));
422-
EXPECT_NE(cacheAlignedHostPtr, buffer->getGraphicsAllocation()->getUnderlyingBuffer());
423-
EXPECT_FALSE(buffer->isMemObjZeroCopy());
424-
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
422+
EXPECT_EQ(cacheAlignedHostPtr, buffer->getGraphicsAllocation()->getUnderlyingBuffer());
423+
EXPECT_TRUE(buffer->isMemObjZeroCopy());
424+
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
425425

426426
EXPECT_THAT(buffer->getGraphicsAllocation()->getUnderlyingBuffer(), MemCompare(&pattern[0], sizeof(pattern)));
427427

0 commit comments

Comments
 (0)