Skip to content

Commit 65625e2

Browse files
Enhance force shared physical memory flag.
- forces zero copy for all buffers created with this flag. Change-Id: Ib76b452e286dcbd3481f1c96f3a48db63fb5c4b5
1 parent 23fcbb3 commit 65625e2

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!groovy
22
dependenciesRevision='88b9b8081c963d105ae1815384e62d225a92ca51-1208'
33
strategy='EQUAL'
4-
allowedCD=268
4+
allowedCD=267
55
allowedF=4

runtime/mem_obj/buffer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,11 @@ void Buffer::checkMemory(cl_mem_flags flags,
336336
GraphicsAllocation::AllocationType Buffer::getGraphicsAllocationType(const MemoryProperties &properties, bool sharedContext,
337337
ContextType contextType, bool renderCompressedBuffers,
338338
bool isLocalMemoryEnabled) {
339-
if (is32bit || sharedContext) {
339+
if (is32bit || sharedContext || isValueSet(properties.flags, CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL)) {
340340
return GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
341341
}
342342

343-
if (isValueSet(properties.flags, CL_MEM_USE_HOST_PTR) && (isValueSet(properties.flags, CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL) || !isLocalMemoryEnabled)) {
343+
if (isValueSet(properties.flags, CL_MEM_USE_HOST_PTR) && !isLocalMemoryEnabled) {
344344
return GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY;
345345
}
346346

unit_tests/mem_obj/buffer_tests.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,21 @@ TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationAndZeroCopyH
471471
alignedFree(cacheAlignedHostPtr);
472472
}
473473

474+
TEST_F(RenderCompressedBuffersTests, givenAllocationCreatedWithForceSharedPhysicalMemoryWhenItIsCreatedItIsZeroCopy) {
475+
buffer.reset(Buffer::create(context.get(), CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL, 1u, nullptr, retVal));
476+
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
477+
EXPECT_TRUE(buffer->isMemObjZeroCopy());
478+
EXPECT_EQ(1u, buffer->getSize());
479+
}
480+
481+
TEST_F(RenderCompressedBuffersTests, givenRenderCompressedBuffersAndAllocationCreatedWithForceSharedPhysicalMemoryWhenItIsCreatedItIsZeroCopy) {
482+
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
483+
buffer.reset(Buffer::create(context.get(), CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL, 1u, nullptr, retVal));
484+
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
485+
EXPECT_TRUE(buffer->isMemObjZeroCopy());
486+
EXPECT_EQ(1u, buffer->getSize());
487+
}
488+
474489
TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationAndNoHostPtrWhenCheckingMemoryPropertiesThenForceDisableZeroCopy) {
475490
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
476491

0 commit comments

Comments
 (0)