Skip to content

Commit

Permalink
Transfer usage restructuring and D3D11 async readback (thatcosmonaut#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
thatcosmonaut authored and flibitijibibo committed Jul 13, 2024
1 parent 808cd7f commit 89ed3e8
Show file tree
Hide file tree
Showing 8 changed files with 354 additions and 346 deletions.
22 changes: 6 additions & 16 deletions include/SDL3/SDL_gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,11 @@ typedef enum SDL_GpuBufferUsageFlagBits

typedef Uint32 SDL_GpuBufferUsageFlags;

typedef enum SDL_GpuTransferBufferMapFlagBits
typedef enum SDL_GpuTransferBufferUsage
{
SDL_GPU_TRANSFER_MAP_READ = 0x00000001,
SDL_GPU_TRANSFER_MAP_WRITE = 0x00000002
} SDL_GpuTransferBufferMapFlagBits;

typedef Uint32 SDL_GpuTransferBufferMapFlags;
SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD
} SDL_GpuTransferBufferUsage;

typedef enum SDL_GpuShaderStage
{
Expand Down Expand Up @@ -336,12 +334,6 @@ typedef enum SDL_GpuBorderColor
SDL_GPU_BORDERCOLOR_INT_OPAQUE_WHITE
} SDL_GpuBorderColor;

typedef enum SDL_GpuTransferUsage
{
SDL_GPU_TRANSFERUSAGE_BUFFER,
SDL_GPU_TRANSFERUSAGE_TEXTURE
} SDL_GpuTransferUsage;

/*
* VSYNC:
* Waits for vblank before presenting.
Expand Down Expand Up @@ -950,8 +942,7 @@ extern SDL_DECLSPEC SDL_GpuBuffer *SDLCALL SDL_GpuCreateBuffer(
* Creates a transfer buffer to be used when uploading to or downloading from graphics resources.
*
* \param device a GPU Context
* \param usage specifies whether the transfer buffer will transfer buffers or textures
* \param mapFlags specify read-write options for the transfer buffer
* \param usage whether the transfer buffer will be used for uploads or downloads
* \param sizeInBytes the size of the transfer buffer
* \returns a transfer buffer on success, or NULL on failure
*
Expand All @@ -965,8 +956,7 @@ extern SDL_DECLSPEC SDL_GpuBuffer *SDLCALL SDL_GpuCreateBuffer(
*/
extern SDL_DECLSPEC SDL_GpuTransferBuffer *SDLCALL SDL_GpuCreateTransferBuffer(
SDL_GpuDevice *device,
SDL_GpuTransferUsage usage,
SDL_GpuTransferBufferMapFlags mapFlags,
SDL_GpuTransferBufferUsage usage,
Uint32 sizeInBytes);

/* Debug Naming */
Expand Down
2 changes: 1 addition & 1 deletion src/dynapi/SDL_dynapi_procs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ SDL_DYNAPI_PROC(SDL_GpuSampler*,SDL_GpuCreateSampler,(SDL_GpuDevice *a, SDL_GpuS
SDL_DYNAPI_PROC(SDL_GpuShader*,SDL_GpuCreateShader,(SDL_GpuDevice *a, SDL_GpuShaderCreateInfo *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GpuTexture*,SDL_GpuCreateTexture,(SDL_GpuDevice *a, SDL_GpuTextureCreateInfo *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GpuBuffer*,SDL_GpuCreateBuffer,(SDL_GpuDevice *a, SDL_GpuBufferUsageFlags b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_GpuTransferBuffer*,SDL_GpuCreateTransferBuffer,(SDL_GpuDevice *a, SDL_GpuTransferUsage b, SDL_GpuTransferBufferMapFlags c, Uint32 d),(a,b,c,d),return)
SDL_DYNAPI_PROC(SDL_GpuTransferBuffer*,SDL_GpuCreateTransferBuffer,(SDL_GpuDevice *a, SDL_GpuTransferBufferUsage b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_GpuSetBufferName,(SDL_GpuDevice *a, SDL_GpuBuffer *b, const char *c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_GpuSetTextureName,(SDL_GpuDevice *a, SDL_GpuTexture *b, const char *c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_GpuSetStringMarker,(SDL_GpuCommandBuffer *a, const char *b),(a,b),)
Expand Down
4 changes: 1 addition & 3 deletions src/gpu/SDL_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,13 @@ SDL_GpuBuffer *SDL_GpuCreateBuffer(

SDL_GpuTransferBuffer *SDL_GpuCreateTransferBuffer(
SDL_GpuDevice *device,
SDL_GpuTransferUsage usage,
SDL_GpuTransferBufferMapFlags mapFlags,
SDL_GpuTransferBufferUsage usage,
Uint32 sizeInBytes)
{
NULL_ASSERT(device)
return device->CreateTransferBuffer(
device->driverData,
usage,
mapFlags,
sizeInBytes);
}

Expand Down
3 changes: 1 addition & 2 deletions src/gpu/SDL_gpu_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ struct SDL_GpuDevice

SDL_GpuTransferBuffer *(*CreateTransferBuffer)(
SDL_GpuRenderer *driverData,
SDL_GpuTransferUsage usage,
SDL_GpuTransferBufferMapFlags mapFlags,
SDL_GpuTransferBufferUsage usage,
Uint32 sizeInBytes);

/* Debug Naming */
Expand Down
Loading

0 comments on commit 89ed3e8

Please sign in to comment.