1717namespace NEO {
1818BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer (BlitterConstants::BlitDirection blitDirection,
1919 CommandStreamReceiver &commandStreamReceiver,
20- GraphicsAllocation *memObjAllocation, size_t memObjOffset,
21- GraphicsAllocation *mapAllocation,
22- void *hostPtr, size_t hostPtrOffset,
20+ GraphicsAllocation *memObjAllocation,
21+ GraphicsAllocation *preallocatedHostAllocation,
22+ void *hostPtr, uint64_t memObjGpuVa,
23+ uint64_t hostAllocGpuVa, size_t hostPtrOffset,
2324 size_t copyOffset, uint64_t copySize) {
2425
2526 GraphicsAllocation *hostAllocation = nullptr ;
2627
27- if (mapAllocation) {
28- hostAllocation = mapAllocation;
29- if (hostPtr) {
30- hostPtrOffset += ptrDiff (hostPtr, mapAllocation->getGpuAddress ());
31- }
28+ if (preallocatedHostAllocation) {
29+ hostAllocation = preallocatedHostAllocation;
30+ UNRECOVERABLE_IF (hostAllocGpuVa == 0 );
3231 } else {
3332 HostPtrSurface hostPtrSurface (hostPtr, static_cast <size_t >(copySize), true );
3433 bool success = commandStreamReceiver.createAllocationForHostSurface (hostPtrSurface, false );
3534 UNRECOVERABLE_IF (!success);
3635 hostAllocation = hostPtrSurface.getAllocation ();
36+ hostAllocGpuVa = hostAllocation->getGpuAddress ();
3737 }
3838
39- auto offset = copyOffset + memObjOffset;
4039 if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection) {
41- return {nullptr , blitDirection, {}, AuxTranslationDirection::None, memObjAllocation, hostAllocation, offset, hostPtrOffset, copySize};
40+ return {
41+ nullptr , // outputTimestampPacket
42+ blitDirection, // blitDirection
43+ {}, // csrDependencies
44+ AuxTranslationDirection::None, // auxTranslationDirection
45+ memObjAllocation, // dstAllocation
46+ hostAllocation, // srcAllocation
47+ memObjGpuVa, // dstGpuAddress
48+ hostAllocGpuVa, // srcGpuAddress
49+ copySize, // copySize
50+ copyOffset, // dstOffset
51+ hostPtrOffset}; // srcOffset
4252 } else {
43- return {nullptr , blitDirection, {}, AuxTranslationDirection::None, hostAllocation, memObjAllocation, hostPtrOffset, offset, copySize};
53+ return {
54+ nullptr , // outputTimestampPacket
55+ blitDirection, // blitDirection
56+ {}, // csrDependencies
57+ AuxTranslationDirection::None, // auxTranslationDirection
58+ hostAllocation, // dstAllocation
59+ memObjAllocation, // srcAllocation
60+ hostAllocGpuVa, // dstGpuAddress
61+ memObjGpuVa, // srcGpuAddress
62+ copySize, // copySize
63+ hostPtrOffset, // dstOffset
64+ copyOffset}; // srcOffset
4465 }
4566}
4667
@@ -59,61 +80,94 @@ BlitProperties BlitProperties::constructProperties(BlitterConstants::BlitDirecti
5980
6081 GraphicsAllocation *gpuAllocation = nullptr ;
6182 size_t copyOffset = 0 ;
62- size_t memObjOffset = 0 ;
6383
6484 void *hostPtr = nullptr ;
6585 size_t hostPtrOffset = 0 ;
6686
87+ uint64_t memObjGpuVa = 0 ;
88+ uint64_t hostAllocGpuVa = 0 ;
89+
6790 GraphicsAllocation *hostAllocation = builtinOpParams.transferAllocation ;
6891
6992 if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection) {
7093 // write buffer
94+ hostPtr = builtinOpParams.srcPtr ;
95+ hostPtrOffset = builtinOpParams.srcOffset .x ;
96+ copyOffset = builtinOpParams.dstOffset .x ;
97+
98+ memObjGpuVa = castToUint64 (builtinOpParams.dstPtr );
99+ hostAllocGpuVa = castToUint64 (builtinOpParams.srcPtr );
100+
71101 if (builtinOpParams.dstSvmAlloc ) {
72102 gpuAllocation = builtinOpParams.dstSvmAlloc ;
73103 hostAllocation = builtinOpParams.srcSvmAlloc ;
74104 } else {
75105 gpuAllocation = builtinOpParams.dstMemObj ->getGraphicsAllocation ();
76- memObjOffset = builtinOpParams.dstMemObj ->getOffset ();
77- hostPtr = builtinOpParams.srcPtr ;
106+ memObjGpuVa = (gpuAllocation->getGpuAddress () + builtinOpParams.dstMemObj ->getOffset ());
78107 }
79-
80- hostPtrOffset = builtinOpParams.srcOffset .x ;
81- copyOffset = builtinOpParams.dstOffset .x ;
82108 }
83109
84110 if (BlitterConstants::BlitDirection::BufferToHostPtr == blitDirection) {
85111 // read buffer
112+ hostPtr = builtinOpParams.dstPtr ;
113+
114+ hostPtrOffset = builtinOpParams.dstOffset .x ;
115+ copyOffset = builtinOpParams.srcOffset .x ;
116+
117+ memObjGpuVa = castToUint64 (builtinOpParams.srcPtr );
118+ hostAllocGpuVa = castToUint64 (builtinOpParams.dstPtr );
119+
86120 if (builtinOpParams.srcSvmAlloc ) {
87121 gpuAllocation = builtinOpParams.srcSvmAlloc ;
88122 hostAllocation = builtinOpParams.dstSvmAlloc ;
89123 } else {
90124 gpuAllocation = builtinOpParams.srcMemObj ->getGraphicsAllocation ();
91- memObjOffset = builtinOpParams.srcMemObj ->getOffset ();
92- hostPtr = builtinOpParams.dstPtr ;
125+ memObjGpuVa = (gpuAllocation->getGpuAddress () + builtinOpParams.srcMemObj ->getOffset ());
93126 }
94-
95- hostPtrOffset = builtinOpParams.dstOffset .x ;
96- copyOffset = builtinOpParams.srcOffset .x ;
97127 }
98128
99129 UNRECOVERABLE_IF (BlitterConstants::BlitDirection::HostPtrToBuffer != blitDirection &&
100130 BlitterConstants::BlitDirection::BufferToHostPtr != blitDirection);
101131
102- return constructPropertiesForReadWriteBuffer (blitDirection, commandStreamReceiver, gpuAllocation, memObjOffset,
103- hostAllocation, hostPtr, hostPtrOffset, copyOffset ,
104- builtinOpParams.size .x );
132+ return constructPropertiesForReadWriteBuffer (blitDirection, commandStreamReceiver, gpuAllocation,
133+ hostAllocation, hostPtr, memObjGpuVa, hostAllocGpuVa ,
134+ hostPtrOffset, copyOffset, builtinOpParams.size .x );
105135}
106136
107137BlitProperties BlitProperties::constructPropertiesForCopyBuffer (GraphicsAllocation *dstAllocation, GraphicsAllocation *srcAllocation,
108138 size_t dstOffset, size_t srcOffset, uint64_t copySize) {
109139
110- return {nullptr , BlitterConstants::BlitDirection::BufferToBuffer, {}, AuxTranslationDirection::None, dstAllocation, srcAllocation, dstOffset, srcOffset, copySize};
140+ return {
141+ nullptr , // outputTimestampPacket
142+ BlitterConstants::BlitDirection::BufferToBuffer, // blitDirection
143+ {}, // csrDependencies
144+ AuxTranslationDirection::None, // auxTranslationDirection
145+ dstAllocation, // dstAllocation
146+ srcAllocation, // srcAllocation
147+ dstAllocation->getGpuAddress (), // dstGpuAddress
148+ srcAllocation->getGpuAddress (), // srcGpuAddress
149+ copySize, // copySize
150+ dstOffset, // dstOffset
151+ srcOffset}; // srcOffset
111152}
112153
113154BlitProperties BlitProperties::constructPropertiesForAuxTranslation (AuxTranslationDirection auxTranslationDirection,
114155 GraphicsAllocation *allocation) {
156+
115157 auto allocationSize = allocation->getUnderlyingBufferSize ();
116- return {nullptr , BlitterConstants::BlitDirection::BufferToBuffer, {}, auxTranslationDirection, allocation, allocation, 0 , 0 , allocationSize};
158+ return {
159+ nullptr , // outputTimestampPacket
160+ BlitterConstants::BlitDirection::BufferToBuffer, // blitDirection
161+ {}, // csrDependencies
162+ auxTranslationDirection, // auxTranslationDirection
163+ allocation, // dstAllocation
164+ allocation, // srcAllocation
165+ allocation->getGpuAddress (), // dstGpuAddress
166+ allocation->getGpuAddress (), // srcGpuAddress
167+ allocationSize, // copySize
168+ 0 , // dstOffset
169+ 0 // srcOffset
170+ };
117171}
118172
119173BlitterConstants::BlitDirection BlitProperties::obtainBlitDirection (uint32_t commandType) {
0 commit comments