SetTextureDataYUV rework #43

Closed
cosmonaut wants to merge 2 commits from yuv_refactor into main
4 changed files with 54 additions and 27 deletions

View File

@ -785,8 +785,13 @@ REFRESHAPI void Refresh_SetTextureData(
* yHeight: The height of the Y plane. * yHeight: The height of the Y plane.
* uvWidth: The width of the U/V planes. * uvWidth: The width of the U/V planes.
* uvHeight: The height of the U/V planes. * uvHeight: The height of the U/V planes.
* data: A pointer to the raw YUV image data. * yData: A pointer to the raw Y image data.
* dataLength: The size of the image data in bytes. * 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.
* yStride: The length of a Y image data row in bytes.
* uvStride: The length of a UV image data row in bytes.
*/ */
REFRESHAPI void Refresh_SetTextureDataYUV( REFRESHAPI void Refresh_SetTextureDataYUV(
Refresh_Device *driverData, Refresh_Device *driverData,
@ -798,8 +803,13 @@ REFRESHAPI void Refresh_SetTextureDataYUV(
uint32_t yHeight, uint32_t yHeight,
uint32_t uvWidth, uint32_t uvWidth,
uint32_t uvHeight, uint32_t uvHeight,
void* data, void *yDataPtr,
uint32_t dataLength void *uDataPtr,
void *vDataPtr,
uint32_t yDataLength,
uint32_t uvDataLength,
uint32_t yStride,
uint32_t uvStride
); );
/* Performs an asynchronous texture-to-texture copy. /* Performs an asynchronous texture-to-texture copy.

View File

@ -438,8 +438,13 @@ void Refresh_SetTextureDataYUV(
uint32_t yHeight, uint32_t yHeight,
uint32_t uvWidth, uint32_t uvWidth,
uint32_t uvHeight, uint32_t uvHeight,
void* data, void *yDataPtr,
uint32_t dataLength void *uDataPtr,
void *vDataPtr,
uint32_t yDataLength,
uint32_t uvDataLength,
uint32_t yStride,
uint32_t uvStride
) { ) {
NULL_RETURN(device); NULL_RETURN(device);
device->SetTextureDataYUV( device->SetTextureDataYUV(
@ -452,8 +457,13 @@ void Refresh_SetTextureDataYUV(
yHeight, yHeight,
uvWidth, uvWidth,
uvHeight, uvHeight,
data, yDataPtr,
dataLength uDataPtr,
vDataPtr,
yDataLength,
uvDataLength,
yStride,
uvStride
); );
} }

View File

@ -286,8 +286,13 @@ struct Refresh_Device
uint32_t yHeight, uint32_t yHeight,
uint32_t uvWidth, uint32_t uvWidth,
uint32_t uvHeight, uint32_t uvHeight,
void* data, void *yDataPtr,
uint32_t dataLength void *uDataPtr,
void *vDataPtr,
uint32_t yDataLength,
uint32_t uvDataLength,
uint32_t yStride,
uint32_t uvStride
); );
void(*CopyTextureToTexture)( void(*CopyTextureToTexture)(

View File

@ -7335,17 +7335,19 @@ static void VULKAN_SetTextureDataYUV(
uint32_t yHeight, uint32_t yHeight,
uint32_t uvWidth, uint32_t uvWidth,
uint32_t uvHeight, uint32_t uvHeight,
void* data, void *yDataPtr,
uint32_t dataLength void *uDataPtr,
void *vDataPtr,
uint32_t yDataLength,
uint32_t uvDataLength,
uint32_t yStride,
uint32_t uvStride
) { ) {
VulkanRenderer *renderer = (VulkanRenderer*) driverData; VulkanRenderer *renderer = (VulkanRenderer*) driverData;
VulkanTexture *tex = ((VulkanTextureContainer*) y)->vulkanTexture; VulkanTexture *tex = ((VulkanTextureContainer*) y)->vulkanTexture;
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*)commandBuffer; VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*)commandBuffer;
VulkanTransferBuffer *transferBuffer; 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; VkBufferImageCopy imageCopy;
uint8_t * stagingBufferPointer; uint8_t * stagingBufferPointer;
@ -7381,7 +7383,7 @@ static void VULKAN_SetTextureDataYUV(
SDL_memcpy( SDL_memcpy(
stagingBufferPointer, stagingBufferPointer,
dataPtr, yDataPtr,
yDataLength yDataLength
); );
@ -7403,7 +7405,7 @@ static void VULKAN_SetTextureDataYUV(
imageCopy.imageExtent.width = yWidth; imageCopy.imageExtent.width = yWidth;
imageCopy.imageExtent.height = yHeight; imageCopy.imageExtent.height = yHeight;
imageCopy.bufferOffset = transferBuffer->offset; imageCopy.bufferOffset = transferBuffer->offset;
imageCopy.bufferRowLength = yWidth; imageCopy.bufferRowLength = yStride;
imageCopy.bufferImageHeight = yHeight; imageCopy.bufferImageHeight = yHeight;
renderer->vkCmdCopyBufferToImage( renderer->vkCmdCopyBufferToImage(
@ -7439,7 +7441,7 @@ static void VULKAN_SetTextureDataYUV(
imageCopy.imageExtent.width = uvWidth; imageCopy.imageExtent.width = uvWidth;
imageCopy.imageExtent.height = uvHeight; imageCopy.imageExtent.height = uvHeight;
imageCopy.bufferRowLength = uvWidth; imageCopy.bufferRowLength = uvStride;
imageCopy.bufferImageHeight = uvHeight; imageCopy.bufferImageHeight = uvHeight;
/* U */ /* U */
@ -7450,7 +7452,7 @@ static void VULKAN_SetTextureDataYUV(
SDL_memcpy( SDL_memcpy(
stagingBufferPointer + yDataLength, stagingBufferPointer + yDataLength,
dataPtr + yDataLength, uDataPtr,
uvDataLength uvDataLength
); );
@ -7505,7 +7507,7 @@ static void VULKAN_SetTextureDataYUV(
SDL_memcpy( SDL_memcpy(
stagingBufferPointer + yDataLength + uvDataLength, stagingBufferPointer + yDataLength + uvDataLength,
dataPtr + yDataLength + uvDataLength, vDataPtr,
uvDataLength uvDataLength
); );