@@ -150,9 +150,27 @@ namespace nbl
150
150
151
151
auto destinationBoundMemory = destinationBuffer->getBoundMemory ();
152
152
destinationBoundMemory->mapMemoryRange (video::IDriverMemoryAllocation::EMCAF_READ, { 0u , memoryRequirements.vulkanReqs .size });
153
- auto texelBuffer = core::make_smart_refctd_ptr<asset::CCustomAllocatorCPUBuffer<core::null_allocator<uint8_t >>>(memoryRequirements.vulkanReqs .size , destinationBoundMemory->getMappedPointer (), core::adopt_memory);
154
153
155
- image->setBufferAndRegions (std::move (texelBuffer), regions);
154
+ auto correctedScreenShotTexelBuffer = core::make_smart_refctd_ptr<asset::ICPUBuffer>(memoryRequirements.vulkanReqs .size );
155
+ bool flipImage = true ;
156
+ if (flipImage)
157
+ {
158
+ auto extent = gpuImage->getMipSize (0u );
159
+ uint32_t rowByteSize = extent.x * asset::getTexelOrBlockBytesize (gpuImage->getCreationParameters ().format );
160
+ for (uint32_t y = 0 ; y < extent.y ; ++y)
161
+ {
162
+ uint32_t flipped_y = extent.y - y - 1 ;
163
+ memcpy (reinterpret_cast <uint8_t *>(correctedScreenShotTexelBuffer->getPointer ()) + rowByteSize * y, reinterpret_cast <uint8_t *>(destinationBoundMemory->getMappedPointer ()) + rowByteSize * flipped_y, rowByteSize);
164
+ }
165
+ }
166
+ else
167
+ {
168
+ memcpy (correctedScreenShotTexelBuffer->getPointer (), destinationBoundMemory->getMappedPointer (), memoryRequirements.vulkanReqs .size );
169
+ }
170
+
171
+ destinationBoundMemory->unmapMemory ();
172
+
173
+ image->setBufferAndRegions (std::move (correctedScreenShotTexelBuffer), regions);
156
174
157
175
while (mapPointerGetterFence->waitCPU (1000ull , mapPointerGetterFence->canDeferredFlush ()) == video::EDFR_TIMEOUT_EXPIRED) {}
158
176
@@ -231,7 +249,6 @@ namespace nbl
231
249
if (!status)
232
250
status = tryToWrite (imageView.get ());
233
251
234
- destinationBoundMemory->unmapMemory ();
235
252
return status;
236
253
237
254
}
0 commit comments