Skip to content

Commit d3e9ff6

Browse files
thatcosmonautflibitijibibo
authored andcommitted
Transfer usage restructuring and D3D11 async readback (#42)
1 parent cb230db commit d3e9ff6

File tree

8 files changed

+354
-346
lines changed

8 files changed

+354
-346
lines changed

include/SDL3/SDL_gpu.h

+6-16
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,11 @@ typedef enum SDL_GpuBufferUsageFlagBits
177177

178178
typedef Uint32 SDL_GpuBufferUsageFlags;
179179

180-
typedef enum SDL_GpuTransferBufferMapFlagBits
180+
typedef enum SDL_GpuTransferBufferUsage
181181
{
182-
SDL_GPU_TRANSFER_MAP_READ = 0x00000001,
183-
SDL_GPU_TRANSFER_MAP_WRITE = 0x00000002
184-
} SDL_GpuTransferBufferMapFlagBits;
185-
186-
typedef Uint32 SDL_GpuTransferBufferMapFlags;
182+
SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
183+
SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD
184+
} SDL_GpuTransferBufferUsage;
187185

188186
typedef enum SDL_GpuShaderStage
189187
{
@@ -336,12 +334,6 @@ typedef enum SDL_GpuBorderColor
336334
SDL_GPU_BORDERCOLOR_INT_OPAQUE_WHITE
337335
} SDL_GpuBorderColor;
338336

339-
typedef enum SDL_GpuTransferUsage
340-
{
341-
SDL_GPU_TRANSFERUSAGE_BUFFER,
342-
SDL_GPU_TRANSFERUSAGE_TEXTURE
343-
} SDL_GpuTransferUsage;
344-
345337
/*
346338
* VSYNC:
347339
* Waits for vblank before presenting.
@@ -950,8 +942,7 @@ extern SDL_DECLSPEC SDL_GpuBuffer *SDLCALL SDL_GpuCreateBuffer(
950942
* Creates a transfer buffer to be used when uploading to or downloading from graphics resources.
951943
*
952944
* \param device a GPU Context
953-
* \param usage specifies whether the transfer buffer will transfer buffers or textures
954-
* \param mapFlags specify read-write options for the transfer buffer
945+
* \param usage whether the transfer buffer will be used for uploads or downloads
955946
* \param sizeInBytes the size of the transfer buffer
956947
* \returns a transfer buffer on success, or NULL on failure
957948
*
@@ -965,8 +956,7 @@ extern SDL_DECLSPEC SDL_GpuBuffer *SDLCALL SDL_GpuCreateBuffer(
965956
*/
966957
extern SDL_DECLSPEC SDL_GpuTransferBuffer *SDLCALL SDL_GpuCreateTransferBuffer(
967958
SDL_GpuDevice *device,
968-
SDL_GpuTransferUsage usage,
969-
SDL_GpuTransferBufferMapFlags mapFlags,
959+
SDL_GpuTransferBufferUsage usage,
970960
Uint32 sizeInBytes);
971961

972962
/* Debug Naming */

src/dynapi/SDL_dynapi_procs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ SDL_DYNAPI_PROC(SDL_GpuSampler*,SDL_GpuCreateSampler,(SDL_GpuDevice *a, SDL_GpuS
11001100
SDL_DYNAPI_PROC(SDL_GpuShader*,SDL_GpuCreateShader,(SDL_GpuDevice *a, SDL_GpuShaderCreateInfo *b),(a,b),return)
11011101
SDL_DYNAPI_PROC(SDL_GpuTexture*,SDL_GpuCreateTexture,(SDL_GpuDevice *a, SDL_GpuTextureCreateInfo *b),(a,b),return)
11021102
SDL_DYNAPI_PROC(SDL_GpuBuffer*,SDL_GpuCreateBuffer,(SDL_GpuDevice *a, SDL_GpuBufferUsageFlags b, Uint32 c),(a,b,c),return)
1103-
SDL_DYNAPI_PROC(SDL_GpuTransferBuffer*,SDL_GpuCreateTransferBuffer,(SDL_GpuDevice *a, SDL_GpuTransferUsage b, SDL_GpuTransferBufferMapFlags c, Uint32 d),(a,b,c,d),return)
1103+
SDL_DYNAPI_PROC(SDL_GpuTransferBuffer*,SDL_GpuCreateTransferBuffer,(SDL_GpuDevice *a, SDL_GpuTransferBufferUsage b, Uint32 c),(a,b,c),return)
11041104
SDL_DYNAPI_PROC(void,SDL_GpuSetBufferName,(SDL_GpuDevice *a, SDL_GpuBuffer *b, const char *c),(a,b,c),)
11051105
SDL_DYNAPI_PROC(void,SDL_GpuSetTextureName,(SDL_GpuDevice *a, SDL_GpuTexture *b, const char *c),(a,b,c),)
11061106
SDL_DYNAPI_PROC(void,SDL_GpuSetStringMarker,(SDL_GpuCommandBuffer *a, const char *b),(a,b),)

src/gpu/SDL_gpu.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -444,15 +444,13 @@ SDL_GpuBuffer *SDL_GpuCreateBuffer(
444444

445445
SDL_GpuTransferBuffer *SDL_GpuCreateTransferBuffer(
446446
SDL_GpuDevice *device,
447-
SDL_GpuTransferUsage usage,
448-
SDL_GpuTransferBufferMapFlags mapFlags,
447+
SDL_GpuTransferBufferUsage usage,
449448
Uint32 sizeInBytes)
450449
{
451450
NULL_ASSERT(device)
452451
return device->CreateTransferBuffer(
453452
device->driverData,
454453
usage,
455-
mapFlags,
456454
sizeInBytes);
457455
}
458456

src/gpu/SDL_gpu_driver.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ struct SDL_GpuDevice
231231

232232
SDL_GpuTransferBuffer *(*CreateTransferBuffer)(
233233
SDL_GpuRenderer *driverData,
234-
SDL_GpuTransferUsage usage,
235-
SDL_GpuTransferBufferMapFlags mapFlags,
234+
SDL_GpuTransferBufferUsage usage,
236235
Uint32 sizeInBytes);
237236

238237
/* Debug Naming */

0 commit comments

Comments
 (0)