@@ -1392,7 +1392,7 @@ static VkResult HostSideDecompression(
13921392 wrapper_buffer * srcBuffer ,
13931393 VkDeviceMemory dstMemory ,
13941394 const VkBufferImageCopy * region ,
1395- VkFormat dstFormat
1395+ VkFormat in_format
13961396) {
13971397 // Map the source buffer
13981398 void * srcData ;
@@ -1413,9 +1413,8 @@ static VkResult HostSideDecompression(
14131413 VkMemoryMapInfoKHR mapInfoDst = {
14141414 .sType = VK_STRUCTURE_TYPE_MEMORY_MAP_INFO_KHR ,
14151415 .memory = dstMemory ,
1416- .offset = 0 , // Assuming dstMemory is large enough to hold the decompressed
1417- // TODO: FIX THIS for non rgba8 data
1418- .size = region -> imageExtent .width * region -> imageExtent .height * 4 , // 4 bytes per pixel for RGBA
1416+ .offset = 0 ,
1417+ .size = region -> imageExtent .width * region -> imageExtent .height * get_bc_target_size (_device -> physical , in_format ),
14191418 };
14201419 result = WCHECK (MapMemory2KHR ((VkDevice ) _device , & mapInfoDst , & dstData ));
14211420 if (result != VK_SUCCESS ) {
@@ -1424,7 +1423,7 @@ static VkResult HostSideDecompression(
14241423
14251424 // Decompress the data from srcData to dstData
14261425 BCnDecompression (
1427- dstFormat ,
1426+ in_format ,
14281427 srcData ,
14291428 dstData ,
14301429 region
@@ -1838,7 +1837,7 @@ WRAPPER_CmdCopyBufferToImage(VkCommandBuffer commandBuffer,
18381837 if (!use_image_view ) {
18391838 result = CreateStagingBuffer (
18401839 _device ,
1841- region -> imageExtent .width * region -> imageExtent .height * region -> imageExtent . depth * 4 ,
1840+ region -> imageExtent .width * region -> imageExtent .height * get_bc_target_size ( _device -> physical , wimg -> original_format ) ,
18421841 VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT ,
18431842 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT ,
18441843 & stagingBuffer , & stagingBufferMemory );
@@ -1848,6 +1847,7 @@ WRAPPER_CmdCopyBufferToImage(VkCommandBuffer commandBuffer,
18481847 }
18491848
18501849 // TODO: track these using the fence/semaphore for the submitted queue
1850+ // This should be safe to do now with the queue synchronization, check with vvl
18511851 WLOGD ("Tracking new staging buffer for image %d" , wimg -> obj_id );
18521852 TRACK_STAGING (_device , BUFFER , stagingBuffer , wimg );
18531853 TRACK_STAGING (_device , DEVICE_MEMORY , stagingBufferMemory , wimg );
0 commit comments