Skip to content

Commit 82613a0

Browse files
Return buffer compressed when render buffer compressed is enable
Change-Id: I62fde1573849139ca16ff9d7e5d5672eab7ccd2b
1 parent 802eb37 commit 82613a0

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

runtime/mem_obj/buffer.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,8 @@ GraphicsAllocation::AllocationType Buffer::getGraphicsAllocationType(const Memor
340340
return GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
341341
}
342342

343-
if (isValueSet(properties.flags, CL_MEM_USE_HOST_PTR)) {
344-
if (isValueSet(properties.flags, CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL) || !isLocalMemoryEnabled) {
345-
return GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
346-
}
347-
return GraphicsAllocation::AllocationType::BUFFER;
343+
if (isValueSet(properties.flags, CL_MEM_USE_HOST_PTR) && (isValueSet(properties.flags, CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL) || !isLocalMemoryEnabled)) {
344+
return GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
348345
}
349346

350347
if (MemObjHelper::isSuitableForRenderCompression(renderCompressedBuffers, properties, contextType)) {

unit_tests/mem_obj/buffer_tests.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,16 @@ TEST(Buffer, givenRenderCompressedBuffersEnabledWhenAllocationTypeIsQueriedThenB
300300
}
301301
}
302302

303+
TEST(Buffer, givenRenderCompressedBuffersDisabledLocalMemoryEnabledWhenAllocationTypeIsQueriedThenBufferTypeIsReturnedIn64Bit) {
304+
MemoryProperties properties;
305+
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, false, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, false, true);
306+
if (is32bit) {
307+
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
308+
} else {
309+
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER, type);
310+
}
311+
}
312+
303313
TEST(Buffer, givenSharedContextWhenAllocationTypeIsQueriedThenBufferHostMemoryTypeIsReturned) {
304314
MemoryProperties properties;
305315
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, true, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, false, false);
@@ -353,7 +363,7 @@ TEST(Buffer, givenUseHostPtrFlagAndLocalMemoryEnabledAndRenderCompressedBuffersE
353363
properties.flags = CL_MEM_USE_HOST_PTR;
354364
auto type = MockPublicAccessBuffer::getGraphicsAllocationType(properties, false, ContextType::CONTEXT_TYPE_UNRESTRICTIVE, true, true);
355365
if (is64bit) {
356-
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER, type);
366+
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, type);
357367
} else {
358368
EXPECT_EQ(GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, type);
359369
}

0 commit comments

Comments
 (0)