@@ -66,7 +66,7 @@ namespace Ogre
6666
6767 PixelBox VulkanHardwarePixelBuffer::lockImpl (const Box &lockBox, LockOptions options)
6868 {
69- PixelBox ret (lockBox, mParent ->getFormat ());
69+ PixelBox ret (lockBox. getWidth (), lockBox. getHeight (), lockBox. getDepth () , mParent ->getFormat ());
7070
7171 auto textureManager = static_cast <VulkanTextureGpuManager*>(mParent ->getCreator ());
7272 VulkanDevice* device = textureManager->getDevice ();
@@ -105,7 +105,8 @@ namespace Ogre
105105 device->mGraphicsQueue .commitAndNextCommandBuffer ();
106106 }
107107
108- return PixelBox (lockBox, mParent ->getFormat (), mStagingBuffer ->lock (options));
108+ ret.data = (uchar*)mStagingBuffer ->lock (options);
109+ return ret;
109110 }
110111
111112 void VulkanHardwarePixelBuffer::unlockImpl ()
@@ -129,16 +130,16 @@ namespace Ogre
129130 region.imageSubresource .baseArrayLayer = mFace ;
130131 region.imageSubresource .layerCount = 1 ;
131132
132- region.imageOffset .x = mCurrentLock .left ;
133- region.imageOffset .y = mCurrentLock .top ;
134- region.imageOffset .z = mCurrentLock .front ;
135- region.imageExtent .width = mCurrentLock .getWidth ();
136- region.imageExtent .height = mCurrentLock .getHeight ();
137- region.imageExtent .depth = mCurrentLock .getDepth ();
133+ region.imageOffset .x = mLockedBox .left ;
134+ region.imageOffset .y = mLockedBox .top ;
135+ region.imageOffset .z = mLockedBox .front ;
136+ region.imageExtent .width = mLockedBox .getWidth ();
137+ region.imageExtent .height = mLockedBox .getHeight ();
138+ region.imageExtent .depth = mLockedBox .getDepth ();
138139
139140 if (mParent ->getTextureType () == TEX_TYPE_2D_ARRAY)
140141 {
141- region.imageSubresource .baseArrayLayer = mCurrentLock .front ;
142+ region.imageSubresource .baseArrayLayer = mLockedBox .front ;
142143 region.imageOffset .z = 0 ;
143144 }
144145
@@ -155,21 +156,8 @@ namespace Ogre
155156 void VulkanHardwarePixelBuffer::blitFromMemory (const PixelBox& src, const Box& dstBox)
156157 {
157158 OgreAssert (src.getSize () == dstBox.getSize (), " scaling currently not supported" );
158- // convert to image native format if necessary
159- if (src.format != mFormat )
160- {
161- std::vector<uint8> buffer;
162- buffer.resize (PixelUtil::getMemorySize (src.getWidth (), src.getHeight (), src.getDepth (), mFormat ));
163- PixelBox converted = PixelBox (src.getWidth (), src.getHeight (), src.getDepth (), mFormat , buffer.data ());
164- PixelUtil::bulkPixelConversion (src, converted);
165- blitFromMemory (converted, dstBox); // recursive call
166- return ;
167- }
168-
169- auto ptr = lock (dstBox, HBL_WRITE_ONLY).data ;
170-
171- memcpy (ptr, src.data , src.getConsecutiveSize ());
172-
159+ lock (dstBox, HBL_WRITE_ONLY);
160+ PixelUtil::bulkPixelConversion (src, mCurrentLock );
173161 unlock ();
174162 }
175163 void VulkanHardwarePixelBuffer::blitToMemory (const Box& srcBox, const PixelBox& dst)
0 commit comments