Skip to content

Commit 06111df

Browse files
Rename transfer parameters to source and destination (#48)
This should clarify the usage of the parameters in the Upload/Download functions.
1 parent 8835184 commit 06111df

File tree

6 files changed

+143
-143
lines changed

6 files changed

+143
-143
lines changed

include/SDL3/SDL_gpu.h

+18-18
Original file line numberDiff line numberDiff line change
@@ -1705,17 +1705,17 @@ extern SDL_DECLSPEC SDL_GpuCopyPass *SDLCALL SDL_GpuBeginCopyPass(
17051705
* the texel size of the texture format.
17061706
*
17071707
* \param copyPass a copy pass handle
1708-
* \param transferBuffer a transfer buffer
1709-
* \param textureRegion a struct containing parameters specifying the texture region to upload data to
1710-
* \param copyParams a struct containing parameters specifying buffer offset, stride, and height
1708+
* \param source the source transfer buffer
1709+
* \param destination the destination texture region
1710+
* \param copyParams buffer offset, stride, and height
17111711
* \param cycle if SDL_TRUE, cycles the texture if the texture slice is bound, otherwise overwrites the data.
17121712
*
17131713
* \since This function is available since SDL 3.x.x
17141714
*/
17151715
extern SDL_DECLSPEC void SDLCALL SDL_GpuUploadToTexture(
17161716
SDL_GpuCopyPass *copyPass,
1717-
SDL_GpuTransferBuffer *transferBuffer,
1718-
SDL_GpuTextureRegion *textureRegion,
1717+
SDL_GpuTransferBuffer *source,
1718+
SDL_GpuTextureRegion *destination,
17191719
SDL_GpuBufferImageCopy *copyParams,
17201720
SDL_bool cycle);
17211721

@@ -1727,17 +1727,17 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuUploadToTexture(
17271727
* You may assume that the upload has finished in subsequent commands.
17281728
*
17291729
* \param copyPass a copy pass handle
1730-
* \param transferBuffer a transfer buffer
1731-
* \param buffer a buffer
1732-
* \param copyParams a struct containing offsets and length
1730+
* \param source the source transfer buffer
1731+
* \param destination the destination buffer
1732+
* \param copyParams buffer offsets and length
17331733
* \param cycle if SDL_TRUE, cycles the buffer if it is bound, otherwise overwrites the data.
17341734
*
17351735
* \since This function is available since SDL 3.x.x
17361736
*/
17371737
extern SDL_DECLSPEC void SDLCALL SDL_GpuUploadToBuffer(
17381738
SDL_GpuCopyPass *copyPass,
1739-
SDL_GpuTransferBuffer *transferBuffer,
1740-
SDL_GpuBuffer *buffer,
1739+
SDL_GpuTransferBuffer *source,
1740+
SDL_GpuBuffer *destination,
17411741
SDL_GpuBufferCopy *copyParams,
17421742
SDL_bool cycle);
17431743

@@ -1798,33 +1798,33 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuGenerateMipmaps(
17981798
* This data is not guaranteed to be copied until the command buffer fence is signaled.
17991799
*
18001800
* \param copyPass a copy pass handle
1801-
* \param textureRegion the texture region to download
1802-
* \param transferBuffer the transfer buffer to download into
1801+
* \param source the source texture region
1802+
* \param destination the destination transfer buffer
18031803
* \param copyParams a struct containing parameters specifying buffer offset, stride, and height
18041804
*
18051805
* \since This function is available since SDL 3.x.x
18061806
*/
18071807
extern SDL_DECLSPEC void SDLCALL SDL_GpuDownloadFromTexture(
18081808
SDL_GpuCopyPass *copyPass,
1809-
SDL_GpuTextureRegion *textureRegion,
1810-
SDL_GpuTransferBuffer *transferBuffer,
1809+
SDL_GpuTextureRegion *source,
1810+
SDL_GpuTransferBuffer *destination,
18111811
SDL_GpuBufferImageCopy *copyParams);
18121812

18131813
/**
18141814
* Copies data from a buffer to a transfer buffer on the GPU timeline.
18151815
* This data is not guaranteed to be copied until the command buffer fence is signaled.
18161816
*
18171817
* \param copyPass a copy pass handle
1818-
* \param buffer the buffer to download
1819-
* \param transferBuffer the transfer buffer to download into
1818+
* \param source the source buffer
1819+
* \param destination the destination transfer buffer
18201820
* \param copyParams a struct containing offsets and length
18211821
*
18221822
* \since This function is available since SDL 3.x.x
18231823
*/
18241824
extern SDL_DECLSPEC void SDLCALL SDL_GpuDownloadFromBuffer(
18251825
SDL_GpuCopyPass *copyPass,
1826-
SDL_GpuBuffer *buffer,
1827-
SDL_GpuTransferBuffer *transferBuffer,
1826+
SDL_GpuBuffer *source,
1827+
SDL_GpuTransferBuffer *destination,
18281828
SDL_GpuBufferCopy *copyParams);
18291829

18301830
/**

src/gpu/SDL_gpu.c

+16-16
Original file line numberDiff line numberDiff line change
@@ -1082,33 +1082,33 @@ SDL_GpuCopyPass *SDL_GpuBeginCopyPass(
10821082

10831083
void SDL_GpuUploadToTexture(
10841084
SDL_GpuCopyPass *copyPass,
1085-
SDL_GpuTransferBuffer *transferBuffer,
1086-
SDL_GpuTextureRegion *textureRegion,
1085+
SDL_GpuTransferBuffer *source,
1086+
SDL_GpuTextureRegion *destination,
10871087
SDL_GpuBufferImageCopy *copyParams,
10881088
SDL_bool cycle)
10891089
{
10901090
NULL_ASSERT(copyPass)
10911091
CHECK_COPYPASS
10921092
COPYPASS_DEVICE->UploadToTexture(
10931093
COPYPASS_COMMAND_BUFFER,
1094-
transferBuffer,
1095-
textureRegion,
1094+
source,
1095+
destination,
10961096
copyParams,
10971097
cycle);
10981098
}
10991099

11001100
void SDL_GpuUploadToBuffer(
11011101
SDL_GpuCopyPass *copyPass,
1102-
SDL_GpuTransferBuffer *transferBuffer,
1103-
SDL_GpuBuffer *buffer,
1102+
SDL_GpuTransferBuffer *source,
1103+
SDL_GpuBuffer *destination,
11041104
SDL_GpuBufferCopy *copyParams,
11051105
SDL_bool cycle)
11061106
{
11071107
NULL_ASSERT(copyPass)
11081108
COPYPASS_DEVICE->UploadToBuffer(
11091109
COPYPASS_COMMAND_BUFFER,
1110-
transferBuffer,
1111-
buffer,
1110+
source,
1111+
destination,
11121112
copyParams,
11131113
cycle);
11141114
}
@@ -1155,29 +1155,29 @@ void SDL_GpuGenerateMipmaps(
11551155

11561156
void SDL_GpuDownloadFromTexture(
11571157
SDL_GpuCopyPass *copyPass,
1158-
SDL_GpuTextureRegion *textureRegion,
1159-
SDL_GpuTransferBuffer *transferBuffer,
1158+
SDL_GpuTextureRegion *source,
1159+
SDL_GpuTransferBuffer *destination,
11601160
SDL_GpuBufferImageCopy *copyParams)
11611161
{
11621162
NULL_ASSERT(copyPass);
11631163
COPYPASS_DEVICE->DownloadFromTexture(
11641164
COPYPASS_COMMAND_BUFFER,
1165-
textureRegion,
1166-
transferBuffer,
1165+
source,
1166+
destination,
11671167
copyParams);
11681168
}
11691169

11701170
void SDL_GpuDownloadFromBuffer(
11711171
SDL_GpuCopyPass *copyPass,
1172-
SDL_GpuBuffer *buffer,
1173-
SDL_GpuTransferBuffer *transferBuffer,
1172+
SDL_GpuBuffer *source,
1173+
SDL_GpuTransferBuffer *destination,
11741174
SDL_GpuBufferCopy *copyParams)
11751175
{
11761176
NULL_ASSERT(copyPass);
11771177
COPYPASS_DEVICE->DownloadFromBuffer(
11781178
COPYPASS_COMMAND_BUFFER,
1179-
buffer,
1180-
transferBuffer,
1179+
source,
1180+
destination,
11811181
copyParams);
11821182
}
11831183

src/gpu/SDL_gpu_driver.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -467,15 +467,15 @@ struct SDL_GpuDevice
467467

468468
void (*UploadToTexture)(
469469
SDL_GpuCommandBuffer *commandBuffer,
470-
SDL_GpuTransferBuffer *transferBuffer,
471-
SDL_GpuTextureRegion *textureSlice,
470+
SDL_GpuTransferBuffer *source,
471+
SDL_GpuTextureRegion *destination,
472472
SDL_GpuBufferImageCopy *copyParams,
473473
SDL_bool cycle);
474474

475475
void (*UploadToBuffer)(
476476
SDL_GpuCommandBuffer *commandBuffer,
477-
SDL_GpuTransferBuffer *transferBuffer,
478-
SDL_GpuBuffer *buffer,
477+
SDL_GpuTransferBuffer *source,
478+
SDL_GpuBuffer *destination,
479479
SDL_GpuBufferCopy *copyParams,
480480
SDL_bool cycle);
481481

@@ -498,14 +498,14 @@ struct SDL_GpuDevice
498498

499499
void (*DownloadFromTexture)(
500500
SDL_GpuCommandBuffer *commandBuffer,
501-
SDL_GpuTextureRegion *textureSlice,
502-
SDL_GpuTransferBuffer *transferBuffer,
501+
SDL_GpuTextureRegion *source,
502+
SDL_GpuTransferBuffer *destination,
503503
SDL_GpuBufferImageCopy *copyParams);
504504

505505
void (*DownloadFromBuffer)(
506506
SDL_GpuCommandBuffer *commandBuffer,
507-
SDL_GpuBuffer *buffer,
508-
SDL_GpuTransferBuffer *transferBuffer,
507+
SDL_GpuBuffer *source,
508+
SDL_GpuTransferBuffer *destination,
509509
SDL_GpuBufferCopy *copyParams);
510510

511511
void (*EndCopyPass)(

src/gpu/d3d11/SDL_gpu_d3d11.c

+39-39
Original file line numberDiff line numberDiff line change
@@ -2801,29 +2801,29 @@ static void D3D11_BeginCopyPass(
28012801

28022802
static void D3D11_UploadToTexture(
28032803
SDL_GpuCommandBuffer *commandBuffer,
2804-
SDL_GpuTransferBuffer *transferBuffer,
2805-
SDL_GpuTextureRegion *textureRegion,
2804+
SDL_GpuTransferBuffer *source,
2805+
SDL_GpuTextureRegion *destination,
28062806
SDL_GpuBufferImageCopy *copyParams,
28072807
SDL_bool cycle)
28082808
{
28092809
D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer;
28102810
D3D11Renderer *renderer = (D3D11Renderer *)d3d11CommandBuffer->renderer;
2811-
D3D11TransferBufferContainer *transferContainer = (D3D11TransferBufferContainer *)transferBuffer;
2811+
D3D11TransferBufferContainer *transferContainer = (D3D11TransferBufferContainer *)source;
28122812
D3D11TransferBuffer *d3d11TransferBuffer = transferContainer->activeBuffer;
2813-
D3D11TextureContainer *d3d11TextureContainer = (D3D11TextureContainer *)textureRegion->textureSlice.texture;
2813+
D3D11TextureContainer *d3d11TextureContainer = (D3D11TextureContainer *)destination->textureSlice.texture;
28142814
Uint32 bufferStride = copyParams->bufferStride;
28152815
Uint32 bufferImageHeight = copyParams->bufferImageHeight;
2816-
Sint32 w = textureRegion->w;
2817-
Sint32 h = textureRegion->h;
2816+
Sint32 w = destination->w;
2817+
Sint32 h = destination->h;
28182818
D3D11Texture *stagingTexture;
28192819
SDL_GpuTextureCreateInfo stagingTextureCreateInfo;
28202820
D3D11_SUBRESOURCE_DATA initialData;
28212821

28222822
D3D11TextureSubresource *textureSubresource = D3D11_INTERNAL_PrepareTextureSubresourceForWrite(
28232823
renderer,
28242824
d3d11TextureContainer,
2825-
textureRegion->textureSlice.layer,
2826-
textureRegion->textureSlice.mipLevel,
2825+
destination->textureSlice.layer,
2826+
destination->textureSlice.mipLevel,
28272827
cycle);
28282828

28292829
Sint32 blockSize = Texture_GetBlockSize(textureSubresource->parent->format);
@@ -2844,13 +2844,13 @@ static void D3D11_UploadToTexture(
28442844

28452845
stagingTextureCreateInfo.width = w;
28462846
stagingTextureCreateInfo.height = h;
2847-
stagingTextureCreateInfo.depth = textureRegion->d;
2847+
stagingTextureCreateInfo.depth = destination->d;
28482848
stagingTextureCreateInfo.layerCount = 1;
28492849
stagingTextureCreateInfo.levelCount = 1;
28502850
stagingTextureCreateInfo.isCube = 0;
28512851
stagingTextureCreateInfo.usageFlags = 0;
28522852
stagingTextureCreateInfo.sampleCount = SDL_GPU_SAMPLECOUNT_1;
2853-
stagingTextureCreateInfo.format = ((D3D11TextureContainer *)textureRegion->textureSlice.texture)->createInfo.format;
2853+
stagingTextureCreateInfo.format = ((D3D11TextureContainer *)destination->textureSlice.texture)->createInfo.format;
28542854

28552855
initialData.pSysMem = d3d11TransferBuffer->data + copyParams->bufferOffset;
28562856
initialData.SysMemPitch = bufferStride;
@@ -2871,9 +2871,9 @@ static void D3D11_UploadToTexture(
28712871
d3d11CommandBuffer->context,
28722872
textureSubresource->parent->handle,
28732873
textureSubresource->index,
2874-
textureRegion->x,
2875-
textureRegion->y,
2876-
textureRegion->z,
2874+
destination->x,
2875+
destination->y,
2876+
destination->z,
28772877
stagingTexture->handle,
28782878
0,
28792879
NULL,
@@ -2888,16 +2888,16 @@ static void D3D11_UploadToTexture(
28882888

28892889
static void D3D11_UploadToBuffer(
28902890
SDL_GpuCommandBuffer *commandBuffer,
2891-
SDL_GpuTransferBuffer *transferBuffer,
2892-
SDL_GpuBuffer *buffer,
2891+
SDL_GpuTransferBuffer *source,
2892+
SDL_GpuBuffer *destination,
28932893
SDL_GpuBufferCopy *copyParams,
28942894
SDL_bool cycle)
28952895
{
28962896
D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer;
28972897
D3D11Renderer *renderer = (D3D11Renderer *)d3d11CommandBuffer->renderer;
2898-
D3D11TransferBufferContainer *transferContainer = (D3D11TransferBufferContainer *)transferBuffer;
2898+
D3D11TransferBufferContainer *transferContainer = (D3D11TransferBufferContainer *)source;
28992899
D3D11TransferBuffer *d3d11TransferBuffer = transferContainer->activeBuffer;
2900-
D3D11BufferContainer *bufferContainer = (D3D11BufferContainer *)buffer;
2900+
D3D11BufferContainer *bufferContainer = (D3D11BufferContainer *)destination;
29012901
D3D11Buffer *d3d11Buffer = D3D11_INTERNAL_PrepareBufferForWrite(
29022902
renderer,
29032903
bufferContainer,
@@ -2949,26 +2949,26 @@ static void D3D11_UploadToBuffer(
29492949

29502950
static void D3D11_DownloadFromTexture(
29512951
SDL_GpuCommandBuffer *commandBuffer,
2952-
SDL_GpuTextureRegion *textureRegion,
2953-
SDL_GpuTransferBuffer *transferBuffer,
2952+
SDL_GpuTextureRegion *source,
2953+
SDL_GpuTransferBuffer *destination,
29542954
SDL_GpuBufferImageCopy *copyParams)
29552955
{
29562956
D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer;
29572957
D3D11Renderer *renderer = d3d11CommandBuffer->renderer;
2958-
D3D11TransferBufferContainer *container = (D3D11TransferBufferContainer *)transferBuffer;
2958+
D3D11TransferBufferContainer *container = (D3D11TransferBufferContainer *)destination;
29592959
D3D11TransferBuffer *d3d11TransferBuffer = container->activeBuffer;
2960-
D3D11TextureContainer *d3d11TextureContainer = (D3D11TextureContainer *)textureRegion->textureSlice.texture;
2960+
D3D11TextureContainer *d3d11TextureContainer = (D3D11TextureContainer *)source->textureSlice.texture;
29612961
D3D11_TEXTURE2D_DESC stagingDesc2D;
29622962
D3D11_TEXTURE3D_DESC stagingDesc3D;
29632963
D3D11TextureSubresource *textureSubresource = D3D11_INTERNAL_FetchTextureSubresource(
29642964
d3d11TextureContainer->activeTexture,
2965-
textureRegion->textureSlice.layer,
2966-
textureRegion->textureSlice.mipLevel);
2965+
source->textureSlice.layer,
2966+
source->textureSlice.mipLevel);
29672967
D3D11TextureDownload *textureDownload;
29682968
Uint32 bufferStride = copyParams->bufferStride;
29692969
Uint32 bufferImageHeight = copyParams->bufferImageHeight;
29702970
Uint32 bytesPerRow, bytesPerDepthSlice;
2971-
D3D11_BOX srcBox = { textureRegion->x, textureRegion->y, textureRegion->z, textureRegion->x + textureRegion->w, textureRegion->y + textureRegion->h, 1 };
2971+
D3D11_BOX srcBox = { source->x, source->y, source->z, source->x + source->w, source->y + source->h, 1 };
29722972
HRESULT res;
29732973

29742974
if (d3d11TransferBuffer->textureDownloadCount >= d3d11TransferBuffer->textureDownloadCapacity)
@@ -2983,16 +2983,16 @@ static void D3D11_DownloadFromTexture(
29832983
d3d11TransferBuffer->textureDownloadCount += 1;
29842984

29852985
if (bufferStride == 0 || bufferImageHeight == 0) {
2986-
bufferStride = textureRegion->w;
2987-
bufferImageHeight = textureRegion->h;
2986+
bufferStride = source->w;
2987+
bufferImageHeight = source->h;
29882988
}
29892989

29902990
bytesPerRow = BytesPerRow(bufferStride, textureSubresource->parent->format);
29912991
bytesPerDepthSlice = bytesPerRow * bufferImageHeight;
29922992

2993-
if (textureRegion->d == 1) {
2994-
stagingDesc2D.Width = textureRegion->w;
2995-
stagingDesc2D.Height = textureRegion->h;
2993+
if (source->d == 1) {
2994+
stagingDesc2D.Width = source->w;
2995+
stagingDesc2D.Height = source->h;
29962996
stagingDesc2D.MipLevels = 1;
29972997
stagingDesc2D.ArraySize = 1;
29982998
stagingDesc2D.Format = SDLToD3D11_TextureFormat[textureSubresource->parent->format];
@@ -3010,9 +3010,9 @@ static void D3D11_DownloadFromTexture(
30103010
(ID3D11Texture2D **)&textureDownload->stagingTexture);
30113011
ERROR_CHECK_RETURN("Staging texture creation failed", )
30123012
} else {
3013-
stagingDesc3D.Width = textureRegion->w;
3014-
stagingDesc3D.Height = textureRegion->h;
3015-
stagingDesc3D.Depth = textureRegion->d;
3013+
stagingDesc3D.Width = source->w;
3014+
stagingDesc3D.Height = source->h;
3015+
stagingDesc3D.Depth = source->d;
30163016
stagingDesc3D.MipLevels = 1;
30173017
stagingDesc3D.Format = SDLToD3D11_TextureFormat[textureSubresource->parent->format];
30183018
stagingDesc3D.Usage = D3D11_USAGE_STAGING;
@@ -3027,9 +3027,9 @@ static void D3D11_DownloadFromTexture(
30273027
(ID3D11Texture3D **)&textureDownload->stagingTexture);
30283028
}
30293029

3030-
textureDownload->width = textureRegion->w;
3031-
textureDownload->height = textureRegion->h;
3032-
textureDownload->depth = textureRegion->d;
3030+
textureDownload->width = source->w;
3031+
textureDownload->height = source->h;
3032+
textureDownload->depth = source->d;
30333033
textureDownload->bufferOffset = copyParams->bufferOffset;
30343034
textureDownload->bytesPerRow = bytesPerRow;
30353035
textureDownload->bytesPerDepthSlice = bytesPerDepthSlice;
@@ -3052,15 +3052,15 @@ static void D3D11_DownloadFromTexture(
30523052

30533053
static void D3D11_DownloadFromBuffer(
30543054
SDL_GpuCommandBuffer *commandBuffer,
3055-
SDL_GpuBuffer *buffer,
3056-
SDL_GpuTransferBuffer *transferBuffer,
3055+
SDL_GpuBuffer *source,
3056+
SDL_GpuTransferBuffer *destination,
30573057
SDL_GpuBufferCopy *copyParams)
30583058
{
30593059
D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer;
30603060
D3D11Renderer *renderer = d3d11CommandBuffer->renderer;
3061-
D3D11TransferBufferContainer *container = (D3D11TransferBufferContainer *)transferBuffer;
3061+
D3D11TransferBufferContainer *container = (D3D11TransferBufferContainer *)destination;
30623062
D3D11TransferBuffer *d3d11TransferBuffer = container->activeBuffer;
3063-
D3D11BufferContainer *d3d11BufferContainer = (D3D11BufferContainer *)buffer;
3063+
D3D11BufferContainer *d3d11BufferContainer = (D3D11BufferContainer *)source;
30643064
D3D11BufferDownload *bufferDownload;
30653065
D3D11_BOX srcBox = { copyParams->srcOffset, 0, 0, copyParams->size, 1, 1 };
30663066
D3D11_BUFFER_DESC stagingBufferDesc;

0 commit comments

Comments
 (0)