diff --git a/include/Refresh.h b/include/Refresh.h index 5dc5cc1..19b888e 100644 --- a/include/Refresh.h +++ b/include/Refresh.h @@ -778,15 +778,18 @@ REFRESHAPI void Refresh_SetTextureData( /* Uploads YUV image data to three R8 texture objects. * - * y: The texture storing the Y data. - * u: The texture storing the U (Cb) data. - * v: The texture storing the V (Cr) data. - * yWidth: The width of the Y plane. - * yHeight: The height of the Y plane. - * uvWidth: The width of the U/V planes. - * uvHeight: The height of the U/V planes. - * data: A pointer to the raw YUV image data. - * dataLength: The size of the image data in bytes. + * y: The texture storing the Y data. + * u: The texture storing the U (Cb) data. + * v: The texture storing the V (Cr) data. + * yWidth: The width of the Y plane. + * yHeight: The height of the Y plane. + * uvWidth: The width of the U/V planes. + * uvHeight: The height of the U/V planes. + * yData: A pointer to the raw Y image data. + * uData: A pointer to the raw U image data. + * vData: A pointer to the raw V image data. + * yDataLength: The size of the Y image data in bytes. + * uvDataLength: The size of the UV image data in bytes. */ REFRESHAPI void Refresh_SetTextureDataYUV( Refresh_Device *driverData, @@ -798,8 +801,13 @@ REFRESHAPI void Refresh_SetTextureDataYUV( uint32_t yHeight, uint32_t uvWidth, uint32_t uvHeight, - void* data, - uint32_t dataLength + void *yDataPtr, + void *uDataPtr, + void *vDataPtr, + uint32_t yDataLength, + uint32_t uvDataLength, + uint32_t yStride, + uint32_t uvStride ); /* Performs an asynchronous texture-to-texture copy. diff --git a/src/Refresh.c b/src/Refresh.c index 2f9c0bf..1893954 100644 --- a/src/Refresh.c +++ b/src/Refresh.c @@ -438,8 +438,13 @@ void Refresh_SetTextureDataYUV( uint32_t yHeight, uint32_t uvWidth, uint32_t uvHeight, - void* data, - uint32_t dataLength + void *yDataPtr, + void *uDataPtr, + void *vDataPtr, + uint32_t yDataLength, + uint32_t uvDataLength, + uint32_t yStride, + uint32_t uvStride ) { NULL_RETURN(device); device->SetTextureDataYUV( @@ -452,8 +457,13 @@ void Refresh_SetTextureDataYUV( yHeight, uvWidth, uvHeight, - data, - dataLength + yDataPtr, + uDataPtr, + vDataPtr, + yDataLength, + uvDataLength, + yStride, + uvStride ); } diff --git a/src/Refresh_Driver.h b/src/Refresh_Driver.h index 2d483f7..2b3c6c0 100644 --- a/src/Refresh_Driver.h +++ b/src/Refresh_Driver.h @@ -286,8 +286,13 @@ struct Refresh_Device uint32_t yHeight, uint32_t uvWidth, uint32_t uvHeight, - void* data, - uint32_t dataLength + void *yDataPtr, + void *uDataPtr, + void *vDataPtr, + uint32_t yDataLength, + uint32_t uvDataLength, + uint32_t yStride, + uint32_t uvStride ); void(*CopyTextureToTexture)( diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index 8e98ce2..581153e 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -7335,17 +7335,19 @@ static void VULKAN_SetTextureDataYUV( uint32_t yHeight, uint32_t uvWidth, uint32_t uvHeight, - void* data, - uint32_t dataLength + void *yDataPtr, + void *uDataPtr, + void *vDataPtr, + uint32_t yDataLength, + uint32_t uvDataLength, + uint32_t yStride, + uint32_t uvStride ) { VulkanRenderer *renderer = (VulkanRenderer*) driverData; VulkanTexture *tex = ((VulkanTextureContainer*) y)->vulkanTexture; VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*)commandBuffer; VulkanTransferBuffer *transferBuffer; - uint8_t *dataPtr = (uint8_t*) data; - int32_t yDataLength = BytesPerImage(yWidth, yHeight, REFRESH_TEXTUREFORMAT_R8); - int32_t uvDataLength = BytesPerImage(uvWidth, uvHeight, REFRESH_TEXTUREFORMAT_R8); VkBufferImageCopy imageCopy; uint8_t * stagingBufferPointer; @@ -7381,7 +7383,7 @@ static void VULKAN_SetTextureDataYUV( SDL_memcpy( stagingBufferPointer, - dataPtr, + yDataPtr, yDataLength ); @@ -7403,7 +7405,7 @@ static void VULKAN_SetTextureDataYUV( imageCopy.imageExtent.width = yWidth; imageCopy.imageExtent.height = yHeight; imageCopy.bufferOffset = transferBuffer->offset; - imageCopy.bufferRowLength = yWidth; + imageCopy.bufferRowLength = yStride; imageCopy.bufferImageHeight = yHeight; renderer->vkCmdCopyBufferToImage( @@ -7439,7 +7441,7 @@ static void VULKAN_SetTextureDataYUV( imageCopy.imageExtent.width = uvWidth; imageCopy.imageExtent.height = uvHeight; - imageCopy.bufferRowLength = uvWidth; + imageCopy.bufferRowLength = uvStride; imageCopy.bufferImageHeight = uvHeight; /* U */ @@ -7450,7 +7452,7 @@ static void VULKAN_SetTextureDataYUV( SDL_memcpy( stagingBufferPointer + yDataLength, - dataPtr + yDataLength, + uDataPtr, uvDataLength ); @@ -7505,7 +7507,7 @@ static void VULKAN_SetTextureDataYUV( SDL_memcpy( stagingBufferPointer + yDataLength + uvDataLength, - dataPtr + yDataLength + uvDataLength, + vDataPtr, uvDataLength );