SetTextureDataYUV rework (#44)

Reviewed-on: MoonsideGames/Refresh#44
remotes/1695145649051507776/main
cosmonaut 2023-06-07 20:59:55 +00:00
parent 1f9f7e0939
commit 5a2b07097a
4 changed files with 54 additions and 27 deletions

View File

@ -778,15 +778,20 @@ 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.
* 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(
Refresh_Device *driverData,
@ -798,8 +803,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.

View File

@ -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
);
}

View File

@ -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)(

View File

@ -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
);