mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-13 19:42:29 +00:00
chore(build): use SDL3
This commit is contained in:
parent
9d04a35d87
commit
b3c0734a9e
3286 changed files with 866354 additions and 554996 deletions
2968
vendor/sdl-3.2.10/src/gpu/SDL_gpu.c
vendored
Normal file
2968
vendor/sdl-3.2.10/src/gpu/SDL_gpu.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
998
vendor/sdl-3.2.10/src/gpu/SDL_sysgpu.h
vendored
Normal file
998
vendor/sdl-3.2.10/src/gpu/SDL_sysgpu.h
vendored
Normal file
|
|
@ -0,0 +1,998 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
#include "../video/SDL_sysvideo.h"
|
||||
#include "SDL_internal.h"
|
||||
|
||||
#ifndef SDL_GPU_DRIVER_H
|
||||
#define SDL_GPU_DRIVER_H
|
||||
|
||||
// Common Structs
|
||||
|
||||
typedef struct Pass
|
||||
{
|
||||
SDL_GPUCommandBuffer *command_buffer;
|
||||
bool in_progress;
|
||||
} Pass;
|
||||
|
||||
typedef struct CommandBufferCommonHeader
|
||||
{
|
||||
SDL_GPUDevice *device;
|
||||
Pass render_pass;
|
||||
bool graphics_pipeline_bound;
|
||||
Pass compute_pass;
|
||||
bool compute_pipeline_bound;
|
||||
Pass copy_pass;
|
||||
bool swapchain_texture_acquired;
|
||||
bool submitted;
|
||||
} CommandBufferCommonHeader;
|
||||
|
||||
typedef struct TextureCommonHeader
|
||||
{
|
||||
SDL_GPUTextureCreateInfo info;
|
||||
} TextureCommonHeader;
|
||||
|
||||
typedef struct BlitFragmentUniforms
|
||||
{
|
||||
// texcoord space
|
||||
float left;
|
||||
float top;
|
||||
float width;
|
||||
float height;
|
||||
|
||||
Uint32 mip_level;
|
||||
float layer_or_depth;
|
||||
} BlitFragmentUniforms;
|
||||
|
||||
typedef struct BlitPipelineCacheEntry
|
||||
{
|
||||
SDL_GPUTextureType type;
|
||||
SDL_GPUTextureFormat format;
|
||||
SDL_GPUGraphicsPipeline *pipeline;
|
||||
} BlitPipelineCacheEntry;
|
||||
|
||||
// Internal Helper Utilities
|
||||
|
||||
#define SDL_GPU_TEXTUREFORMAT_MAX_ENUM_VALUE (SDL_GPU_TEXTUREFORMAT_ASTC_12x12_FLOAT + 1)
|
||||
#define SDL_GPU_VERTEXELEMENTFORMAT_MAX_ENUM_VALUE (SDL_GPU_VERTEXELEMENTFORMAT_HALF4 + 1)
|
||||
#define SDL_GPU_COMPAREOP_MAX_ENUM_VALUE (SDL_GPU_COMPAREOP_ALWAYS + 1)
|
||||
#define SDL_GPU_STENCILOP_MAX_ENUM_VALUE (SDL_GPU_STENCILOP_DECREMENT_AND_WRAP + 1)
|
||||
#define SDL_GPU_BLENDOP_MAX_ENUM_VALUE (SDL_GPU_BLENDOP_MAX + 1)
|
||||
#define SDL_GPU_BLENDFACTOR_MAX_ENUM_VALUE (SDL_GPU_BLENDFACTOR_SRC_ALPHA_SATURATE + 1)
|
||||
#define SDL_GPU_SWAPCHAINCOMPOSITION_MAX_ENUM_VALUE (SDL_GPU_SWAPCHAINCOMPOSITION_HDR10_ST2084 + 1)
|
||||
#define SDL_GPU_PRESENTMODE_MAX_ENUM_VALUE (SDL_GPU_PRESENTMODE_MAILBOX + 1)
|
||||
|
||||
static inline Sint32 Texture_GetBlockWidth(
|
||||
SDL_GPUTextureFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_12x10_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_12x12_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_12x10_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_12x12_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_12x10_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_12x12_FLOAT:
|
||||
return 12;
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x5_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x6_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x10_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x5_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x6_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x8_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x10_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x5_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x6_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x8_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x10_FLOAT:
|
||||
return 10;
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x5_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x6_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x5_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x6_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x8_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x5_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x6_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x8_FLOAT:
|
||||
return 8;
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_6x5_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_6x6_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_6x5_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_6x6_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_6x5_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_6x6_FLOAT:
|
||||
return 6;
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_5x4_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_5x5_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_5x4_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_5x5_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_5x4_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_5x5_FLOAT:
|
||||
return 5;
|
||||
case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC5_RG_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC6H_RGB_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC6H_RGB_UFLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_4x4_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_4x4_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_4x4_FLOAT:
|
||||
return 4;
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_A8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8_SNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8_SNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16_SNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16_SNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R11G11B10_UFLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32G32_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32G32B32A32_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32G32_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32G32B32A32_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_D16_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_D24_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_D32_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT:
|
||||
return 1;
|
||||
default:
|
||||
SDL_assert_release(!"Unrecognized TextureFormat!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline Sint32 Texture_GetBlockHeight(
|
||||
SDL_GPUTextureFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_12x12_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_12x12_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_12x12_FLOAT:
|
||||
return 12;
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_12x10_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_12x10_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_12x10_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x10_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x10_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x10_FLOAT:
|
||||
return 10;
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x8_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x8_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x8_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x8_FLOAT:
|
||||
return 8;
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x6_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x6_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x6_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x6_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x6_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x6_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_6x6_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_6x6_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_6x6_FLOAT:
|
||||
return 6;
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x5_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x5_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_10x5_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x5_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x5_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_8x5_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_6x5_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_6x5_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_6x5_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_5x5_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_5x5_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_5x5_FLOAT:
|
||||
return 5;
|
||||
case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC2_RGBA_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC4_R_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC5_RG_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC6H_RGB_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC6H_RGB_UFLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC1_RGBA_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_5x4_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_5x4_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_5x4_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_4x4_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_4x4_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_ASTC_4x4_FLOAT:
|
||||
return 4;
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_B5G6R5_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_B5G5R5A1_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_B4G4R4A4_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R10G10B10A2_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_A8_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8_SNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8_SNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_SNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16_SNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16_SNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_SNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32G32_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32G32B32A32_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R11G11B10_UFLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32G32_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32G32B32A32_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32G32_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R32G32B32A32_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_B8G8R8A8_UNORM_SRGB:
|
||||
case SDL_GPU_TEXTUREFORMAT_D16_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_D24_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_D32_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT:
|
||||
return 1;
|
||||
default:
|
||||
SDL_assert_release(!"Unrecognized TextureFormat!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool IsDepthFormat(
|
||||
SDL_GPUTextureFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case SDL_GPU_TEXTUREFORMAT_D16_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_D24_UNORM:
|
||||
case SDL_GPU_TEXTUREFORMAT_D32_FLOAT:
|
||||
case SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool IsStencilFormat(
|
||||
SDL_GPUTextureFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case SDL_GPU_TEXTUREFORMAT_D24_UNORM_S8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_D32_FLOAT_S8_UINT:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool IsIntegerFormat(
|
||||
SDL_GPUTextureFormat format)
|
||||
{
|
||||
switch (format) {
|
||||
case SDL_GPU_TEXTUREFORMAT_R8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_UINT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R8G8B8A8_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16_INT:
|
||||
case SDL_GPU_TEXTUREFORMAT_R16G16B16A16_INT:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static inline Uint32 IndexSize(SDL_GPUIndexElementSize size)
|
||||
{
|
||||
return (size == SDL_GPU_INDEXELEMENTSIZE_16BIT) ? 2 : 4;
|
||||
}
|
||||
|
||||
static inline Uint32 BytesPerRow(
|
||||
Sint32 width,
|
||||
SDL_GPUTextureFormat format)
|
||||
{
|
||||
Uint32 blockWidth = Texture_GetBlockWidth(format);
|
||||
Uint32 blocksPerRow = (width + blockWidth - 1) / blockWidth;
|
||||
return blocksPerRow * SDL_GPUTextureFormatTexelBlockSize(format);
|
||||
}
|
||||
|
||||
// GraphicsDevice Limits
|
||||
|
||||
#define MAX_TEXTURE_SAMPLERS_PER_STAGE 16
|
||||
#define MAX_STORAGE_TEXTURES_PER_STAGE 8
|
||||
#define MAX_STORAGE_BUFFERS_PER_STAGE 8
|
||||
#define MAX_UNIFORM_BUFFERS_PER_STAGE 4
|
||||
#define MAX_COMPUTE_WRITE_TEXTURES 8
|
||||
#define MAX_COMPUTE_WRITE_BUFFERS 8
|
||||
#define UNIFORM_BUFFER_SIZE 32768
|
||||
#define MAX_VERTEX_BUFFERS 16
|
||||
#define MAX_VERTEX_ATTRIBUTES 16
|
||||
#define MAX_COLOR_TARGET_BINDINGS 4
|
||||
#define MAX_PRESENT_COUNT 16
|
||||
#define MAX_FRAMES_IN_FLIGHT 3
|
||||
|
||||
// Internal Macros
|
||||
|
||||
#define EXPAND_ARRAY_IF_NEEDED(arr, elementType, newCount, capacity, newCapacity) \
|
||||
do { \
|
||||
if ((newCount) >= (capacity)) { \
|
||||
(capacity) = (newCapacity); \
|
||||
(arr) = (elementType *)SDL_realloc( \
|
||||
(arr), \
|
||||
sizeof(elementType) * (capacity)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
// Internal Declarations
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // __cplusplus
|
||||
|
||||
SDL_GPUGraphicsPipeline *SDL_GPU_FetchBlitPipeline(
|
||||
SDL_GPUDevice *device,
|
||||
SDL_GPUTextureType sourceTextureType,
|
||||
SDL_GPUTextureFormat destinationFormat,
|
||||
SDL_GPUShader *blitVertexShader,
|
||||
SDL_GPUShader *blitFrom2DShader,
|
||||
SDL_GPUShader *blitFrom2DArrayShader,
|
||||
SDL_GPUShader *blitFrom3DShader,
|
||||
SDL_GPUShader *blitFromCubeShader,
|
||||
SDL_GPUShader *blitFromCubeArrayShader,
|
||||
BlitPipelineCacheEntry **blitPipelines,
|
||||
Uint32 *blitPipelineCount,
|
||||
Uint32 *blitPipelineCapacity);
|
||||
|
||||
void SDL_GPU_BlitCommon(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUBlitInfo *info,
|
||||
SDL_GPUSampler *blitLinearSampler,
|
||||
SDL_GPUSampler *blitNearestSampler,
|
||||
SDL_GPUShader *blitVertexShader,
|
||||
SDL_GPUShader *blitFrom2DShader,
|
||||
SDL_GPUShader *blitFrom2DArrayShader,
|
||||
SDL_GPUShader *blitFrom3DShader,
|
||||
SDL_GPUShader *blitFromCubeShader,
|
||||
SDL_GPUShader *blitFromCubeArrayShader,
|
||||
BlitPipelineCacheEntry **blitPipelines,
|
||||
Uint32 *blitPipelineCount,
|
||||
Uint32 *blitPipelineCapacity);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
||||
// SDL_GPUDevice Definition
|
||||
|
||||
typedef struct SDL_GPURenderer SDL_GPURenderer;
|
||||
|
||||
struct SDL_GPUDevice
|
||||
{
|
||||
// Quit
|
||||
|
||||
void (*DestroyDevice)(SDL_GPUDevice *device);
|
||||
|
||||
// State Creation
|
||||
|
||||
SDL_GPUComputePipeline *(*CreateComputePipeline)(
|
||||
SDL_GPURenderer *driverData,
|
||||
const SDL_GPUComputePipelineCreateInfo *createinfo);
|
||||
|
||||
SDL_GPUGraphicsPipeline *(*CreateGraphicsPipeline)(
|
||||
SDL_GPURenderer *driverData,
|
||||
const SDL_GPUGraphicsPipelineCreateInfo *createinfo);
|
||||
|
||||
SDL_GPUSampler *(*CreateSampler)(
|
||||
SDL_GPURenderer *driverData,
|
||||
const SDL_GPUSamplerCreateInfo *createinfo);
|
||||
|
||||
SDL_GPUShader *(*CreateShader)(
|
||||
SDL_GPURenderer *driverData,
|
||||
const SDL_GPUShaderCreateInfo *createinfo);
|
||||
|
||||
SDL_GPUTexture *(*CreateTexture)(
|
||||
SDL_GPURenderer *driverData,
|
||||
const SDL_GPUTextureCreateInfo *createinfo);
|
||||
|
||||
SDL_GPUBuffer *(*CreateBuffer)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUBufferUsageFlags usageFlags,
|
||||
Uint32 size,
|
||||
const char *debugName);
|
||||
|
||||
SDL_GPUTransferBuffer *(*CreateTransferBuffer)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUTransferBufferUsage usage,
|
||||
Uint32 size,
|
||||
const char *debugName);
|
||||
|
||||
// Debug Naming
|
||||
|
||||
void (*SetBufferName)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUBuffer *buffer,
|
||||
const char *text);
|
||||
|
||||
void (*SetTextureName)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUTexture *texture,
|
||||
const char *text);
|
||||
|
||||
void (*InsertDebugLabel)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const char *text);
|
||||
|
||||
void (*PushDebugGroup)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const char *name);
|
||||
|
||||
void (*PopDebugGroup)(
|
||||
SDL_GPUCommandBuffer *commandBuffer);
|
||||
|
||||
// Disposal
|
||||
|
||||
void (*ReleaseTexture)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUTexture *texture);
|
||||
|
||||
void (*ReleaseSampler)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUSampler *sampler);
|
||||
|
||||
void (*ReleaseBuffer)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUBuffer *buffer);
|
||||
|
||||
void (*ReleaseTransferBuffer)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUTransferBuffer *transferBuffer);
|
||||
|
||||
void (*ReleaseShader)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUShader *shader);
|
||||
|
||||
void (*ReleaseComputePipeline)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUComputePipeline *computePipeline);
|
||||
|
||||
void (*ReleaseGraphicsPipeline)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUGraphicsPipeline *graphicsPipeline);
|
||||
|
||||
// Render Pass
|
||||
|
||||
void (*BeginRenderPass)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUColorTargetInfo *colorTargetInfos,
|
||||
Uint32 numColorTargets,
|
||||
const SDL_GPUDepthStencilTargetInfo *depthStencilTargetInfo);
|
||||
|
||||
void (*BindGraphicsPipeline)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_GPUGraphicsPipeline *graphicsPipeline);
|
||||
|
||||
void (*SetViewport)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUViewport *viewport);
|
||||
|
||||
void (*SetScissor)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_Rect *scissor);
|
||||
|
||||
void (*SetBlendConstants)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_FColor blendConstants);
|
||||
|
||||
void (*SetStencilReference)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint8 reference);
|
||||
|
||||
void (*BindVertexBuffers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
const SDL_GPUBufferBinding *bindings,
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindIndexBuffer)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUBufferBinding *binding,
|
||||
SDL_GPUIndexElementSize indexElementSize);
|
||||
|
||||
void (*BindVertexSamplers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
const SDL_GPUTextureSamplerBinding *textureSamplerBindings,
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindVertexStorageTextures)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
SDL_GPUTexture *const *storageTextures,
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindVertexStorageBuffers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
SDL_GPUBuffer *const *storageBuffers,
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindFragmentSamplers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
const SDL_GPUTextureSamplerBinding *textureSamplerBindings,
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindFragmentStorageTextures)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
SDL_GPUTexture *const *storageTextures,
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindFragmentStorageBuffers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
SDL_GPUBuffer *const *storageBuffers,
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*PushVertexUniformData)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 slotIndex,
|
||||
const void *data,
|
||||
Uint32 length);
|
||||
|
||||
void (*PushFragmentUniformData)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 slotIndex,
|
||||
const void *data,
|
||||
Uint32 length);
|
||||
|
||||
void (*DrawIndexedPrimitives)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 numIndices,
|
||||
Uint32 numInstances,
|
||||
Uint32 firstIndex,
|
||||
Sint32 vertexOffset,
|
||||
Uint32 firstInstance);
|
||||
|
||||
void (*DrawPrimitives)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 numVertices,
|
||||
Uint32 numInstances,
|
||||
Uint32 firstVertex,
|
||||
Uint32 firstInstance);
|
||||
|
||||
void (*DrawPrimitivesIndirect)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_GPUBuffer *buffer,
|
||||
Uint32 offset,
|
||||
Uint32 drawCount);
|
||||
|
||||
void (*DrawIndexedPrimitivesIndirect)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_GPUBuffer *buffer,
|
||||
Uint32 offset,
|
||||
Uint32 drawCount);
|
||||
|
||||
void (*EndRenderPass)(
|
||||
SDL_GPUCommandBuffer *commandBuffer);
|
||||
|
||||
// Compute Pass
|
||||
|
||||
void (*BeginComputePass)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUStorageTextureReadWriteBinding *storageTextureBindings,
|
||||
Uint32 numStorageTextureBindings,
|
||||
const SDL_GPUStorageBufferReadWriteBinding *storageBufferBindings,
|
||||
Uint32 numStorageBufferBindings);
|
||||
|
||||
void (*BindComputePipeline)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_GPUComputePipeline *computePipeline);
|
||||
|
||||
void (*BindComputeSamplers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
const SDL_GPUTextureSamplerBinding *textureSamplerBindings,
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindComputeStorageTextures)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
SDL_GPUTexture *const *storageTextures,
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*BindComputeStorageBuffers)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 firstSlot,
|
||||
SDL_GPUBuffer *const *storageBuffers,
|
||||
Uint32 numBindings);
|
||||
|
||||
void (*PushComputeUniformData)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 slotIndex,
|
||||
const void *data,
|
||||
Uint32 length);
|
||||
|
||||
void (*DispatchCompute)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
Uint32 groupcountX,
|
||||
Uint32 groupcountY,
|
||||
Uint32 groupcountZ);
|
||||
|
||||
void (*DispatchComputeIndirect)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_GPUBuffer *buffer,
|
||||
Uint32 offset);
|
||||
|
||||
void (*EndComputePass)(
|
||||
SDL_GPUCommandBuffer *commandBuffer);
|
||||
|
||||
// TransferBuffer Data
|
||||
|
||||
void *(*MapTransferBuffer)(
|
||||
SDL_GPURenderer *device,
|
||||
SDL_GPUTransferBuffer *transferBuffer,
|
||||
bool cycle);
|
||||
|
||||
void (*UnmapTransferBuffer)(
|
||||
SDL_GPURenderer *device,
|
||||
SDL_GPUTransferBuffer *transferBuffer);
|
||||
|
||||
// Copy Pass
|
||||
|
||||
void (*BeginCopyPass)(
|
||||
SDL_GPUCommandBuffer *commandBuffer);
|
||||
|
||||
void (*UploadToTexture)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUTextureTransferInfo *source,
|
||||
const SDL_GPUTextureRegion *destination,
|
||||
bool cycle);
|
||||
|
||||
void (*UploadToBuffer)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUTransferBufferLocation *source,
|
||||
const SDL_GPUBufferRegion *destination,
|
||||
bool cycle);
|
||||
|
||||
void (*CopyTextureToTexture)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUTextureLocation *source,
|
||||
const SDL_GPUTextureLocation *destination,
|
||||
Uint32 w,
|
||||
Uint32 h,
|
||||
Uint32 d,
|
||||
bool cycle);
|
||||
|
||||
void (*CopyBufferToBuffer)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUBufferLocation *source,
|
||||
const SDL_GPUBufferLocation *destination,
|
||||
Uint32 size,
|
||||
bool cycle);
|
||||
|
||||
void (*GenerateMipmaps)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_GPUTexture *texture);
|
||||
|
||||
void (*DownloadFromTexture)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUTextureRegion *source,
|
||||
const SDL_GPUTextureTransferInfo *destination);
|
||||
|
||||
void (*DownloadFromBuffer)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUBufferRegion *source,
|
||||
const SDL_GPUTransferBufferLocation *destination);
|
||||
|
||||
void (*EndCopyPass)(
|
||||
SDL_GPUCommandBuffer *commandBuffer);
|
||||
|
||||
void (*Blit)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
const SDL_GPUBlitInfo *info);
|
||||
|
||||
// Submission/Presentation
|
||||
|
||||
bool (*SupportsSwapchainComposition)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_Window *window,
|
||||
SDL_GPUSwapchainComposition swapchainComposition);
|
||||
|
||||
bool (*SupportsPresentMode)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_Window *window,
|
||||
SDL_GPUPresentMode presentMode);
|
||||
|
||||
bool (*ClaimWindow)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_Window *window);
|
||||
|
||||
void (*ReleaseWindow)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_Window *window);
|
||||
|
||||
bool (*SetSwapchainParameters)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_Window *window,
|
||||
SDL_GPUSwapchainComposition swapchainComposition,
|
||||
SDL_GPUPresentMode presentMode);
|
||||
|
||||
bool (*SetAllowedFramesInFlight)(
|
||||
SDL_GPURenderer *driverData,
|
||||
Uint32 allowedFramesInFlight);
|
||||
|
||||
SDL_GPUTextureFormat (*GetSwapchainTextureFormat)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_Window *window);
|
||||
|
||||
SDL_GPUCommandBuffer *(*AcquireCommandBuffer)(
|
||||
SDL_GPURenderer *driverData);
|
||||
|
||||
bool (*AcquireSwapchainTexture)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_Window *window,
|
||||
SDL_GPUTexture **swapchainTexture,
|
||||
Uint32 *swapchainTextureWidth,
|
||||
Uint32 *swapchainTextureHeight);
|
||||
|
||||
bool (*WaitForSwapchain)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_Window *window);
|
||||
|
||||
bool (*WaitAndAcquireSwapchainTexture)(
|
||||
SDL_GPUCommandBuffer *commandBuffer,
|
||||
SDL_Window *window,
|
||||
SDL_GPUTexture **swapchainTexture,
|
||||
Uint32 *swapchainTextureWidth,
|
||||
Uint32 *swapchainTextureHeight);
|
||||
|
||||
bool (*Submit)(
|
||||
SDL_GPUCommandBuffer *commandBuffer);
|
||||
|
||||
SDL_GPUFence *(*SubmitAndAcquireFence)(
|
||||
SDL_GPUCommandBuffer *commandBuffer);
|
||||
|
||||
bool (*Cancel)(
|
||||
SDL_GPUCommandBuffer *commandBuffer);
|
||||
|
||||
bool (*Wait)(
|
||||
SDL_GPURenderer *driverData);
|
||||
|
||||
bool (*WaitForFences)(
|
||||
SDL_GPURenderer *driverData,
|
||||
bool waitAll,
|
||||
SDL_GPUFence *const *fences,
|
||||
Uint32 numFences);
|
||||
|
||||
bool (*QueryFence)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUFence *fence);
|
||||
|
||||
void (*ReleaseFence)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUFence *fence);
|
||||
|
||||
// Feature Queries
|
||||
|
||||
bool (*SupportsTextureFormat)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUTextureFormat format,
|
||||
SDL_GPUTextureType type,
|
||||
SDL_GPUTextureUsageFlags usage);
|
||||
|
||||
bool (*SupportsSampleCount)(
|
||||
SDL_GPURenderer *driverData,
|
||||
SDL_GPUTextureFormat format,
|
||||
SDL_GPUSampleCount desiredSampleCount);
|
||||
|
||||
// Opaque pointer for the Driver
|
||||
SDL_GPURenderer *driverData;
|
||||
|
||||
// Store this for SDL_GetGPUDeviceDriver()
|
||||
const char *backend;
|
||||
|
||||
// Store this for SDL_GetGPUShaderFormats()
|
||||
SDL_GPUShaderFormat shader_formats;
|
||||
|
||||
// Store this for SDL_gpu.c's debug layer
|
||||
bool debug_mode;
|
||||
};
|
||||
|
||||
#define ASSIGN_DRIVER_FUNC(func, name) \
|
||||
result->func = name##_##func;
|
||||
#define ASSIGN_DRIVER(name) \
|
||||
ASSIGN_DRIVER_FUNC(DestroyDevice, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateComputePipeline, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateGraphicsPipeline, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateSampler, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateShader, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateTexture, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateBuffer, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateTransferBuffer, name) \
|
||||
ASSIGN_DRIVER_FUNC(SetBufferName, name) \
|
||||
ASSIGN_DRIVER_FUNC(SetTextureName, name) \
|
||||
ASSIGN_DRIVER_FUNC(InsertDebugLabel, name) \
|
||||
ASSIGN_DRIVER_FUNC(PushDebugGroup, name) \
|
||||
ASSIGN_DRIVER_FUNC(PopDebugGroup, name) \
|
||||
ASSIGN_DRIVER_FUNC(ReleaseTexture, name) \
|
||||
ASSIGN_DRIVER_FUNC(ReleaseSampler, name) \
|
||||
ASSIGN_DRIVER_FUNC(ReleaseBuffer, name) \
|
||||
ASSIGN_DRIVER_FUNC(ReleaseTransferBuffer, name) \
|
||||
ASSIGN_DRIVER_FUNC(ReleaseShader, name) \
|
||||
ASSIGN_DRIVER_FUNC(ReleaseComputePipeline, name) \
|
||||
ASSIGN_DRIVER_FUNC(ReleaseGraphicsPipeline, name) \
|
||||
ASSIGN_DRIVER_FUNC(BeginRenderPass, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindGraphicsPipeline, name) \
|
||||
ASSIGN_DRIVER_FUNC(SetViewport, name) \
|
||||
ASSIGN_DRIVER_FUNC(SetScissor, name) \
|
||||
ASSIGN_DRIVER_FUNC(SetBlendConstants, name) \
|
||||
ASSIGN_DRIVER_FUNC(SetStencilReference, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindVertexBuffers, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindIndexBuffer, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindVertexSamplers, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindVertexStorageTextures, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindVertexStorageBuffers, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindFragmentSamplers, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindFragmentStorageTextures, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindFragmentStorageBuffers, name) \
|
||||
ASSIGN_DRIVER_FUNC(PushVertexUniformData, name) \
|
||||
ASSIGN_DRIVER_FUNC(PushFragmentUniformData, name) \
|
||||
ASSIGN_DRIVER_FUNC(DrawIndexedPrimitives, name) \
|
||||
ASSIGN_DRIVER_FUNC(DrawPrimitives, name) \
|
||||
ASSIGN_DRIVER_FUNC(DrawPrimitivesIndirect, name) \
|
||||
ASSIGN_DRIVER_FUNC(DrawIndexedPrimitivesIndirect, name) \
|
||||
ASSIGN_DRIVER_FUNC(EndRenderPass, name) \
|
||||
ASSIGN_DRIVER_FUNC(BeginComputePass, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindComputePipeline, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindComputeSamplers, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindComputeStorageTextures, name) \
|
||||
ASSIGN_DRIVER_FUNC(BindComputeStorageBuffers, name) \
|
||||
ASSIGN_DRIVER_FUNC(PushComputeUniformData, name) \
|
||||
ASSIGN_DRIVER_FUNC(DispatchCompute, name) \
|
||||
ASSIGN_DRIVER_FUNC(DispatchComputeIndirect, name) \
|
||||
ASSIGN_DRIVER_FUNC(EndComputePass, name) \
|
||||
ASSIGN_DRIVER_FUNC(MapTransferBuffer, name) \
|
||||
ASSIGN_DRIVER_FUNC(UnmapTransferBuffer, name) \
|
||||
ASSIGN_DRIVER_FUNC(BeginCopyPass, name) \
|
||||
ASSIGN_DRIVER_FUNC(UploadToTexture, name) \
|
||||
ASSIGN_DRIVER_FUNC(UploadToBuffer, name) \
|
||||
ASSIGN_DRIVER_FUNC(DownloadFromTexture, name) \
|
||||
ASSIGN_DRIVER_FUNC(DownloadFromBuffer, name) \
|
||||
ASSIGN_DRIVER_FUNC(CopyTextureToTexture, name) \
|
||||
ASSIGN_DRIVER_FUNC(CopyBufferToBuffer, name) \
|
||||
ASSIGN_DRIVER_FUNC(GenerateMipmaps, name) \
|
||||
ASSIGN_DRIVER_FUNC(EndCopyPass, name) \
|
||||
ASSIGN_DRIVER_FUNC(Blit, name) \
|
||||
ASSIGN_DRIVER_FUNC(SupportsSwapchainComposition, name) \
|
||||
ASSIGN_DRIVER_FUNC(SupportsPresentMode, name) \
|
||||
ASSIGN_DRIVER_FUNC(ClaimWindow, name) \
|
||||
ASSIGN_DRIVER_FUNC(ReleaseWindow, name) \
|
||||
ASSIGN_DRIVER_FUNC(SetSwapchainParameters, name) \
|
||||
ASSIGN_DRIVER_FUNC(SetAllowedFramesInFlight, name) \
|
||||
ASSIGN_DRIVER_FUNC(GetSwapchainTextureFormat, name) \
|
||||
ASSIGN_DRIVER_FUNC(AcquireCommandBuffer, name) \
|
||||
ASSIGN_DRIVER_FUNC(AcquireSwapchainTexture, name) \
|
||||
ASSIGN_DRIVER_FUNC(WaitForSwapchain, name) \
|
||||
ASSIGN_DRIVER_FUNC(WaitAndAcquireSwapchainTexture, name)\
|
||||
ASSIGN_DRIVER_FUNC(Submit, name) \
|
||||
ASSIGN_DRIVER_FUNC(SubmitAndAcquireFence, name) \
|
||||
ASSIGN_DRIVER_FUNC(Cancel, name) \
|
||||
ASSIGN_DRIVER_FUNC(Wait, name) \
|
||||
ASSIGN_DRIVER_FUNC(WaitForFences, name) \
|
||||
ASSIGN_DRIVER_FUNC(QueryFence, name) \
|
||||
ASSIGN_DRIVER_FUNC(ReleaseFence, name) \
|
||||
ASSIGN_DRIVER_FUNC(SupportsTextureFormat, name) \
|
||||
ASSIGN_DRIVER_FUNC(SupportsSampleCount, name)
|
||||
|
||||
typedef struct SDL_GPUBootstrap
|
||||
{
|
||||
const char *name;
|
||||
const SDL_GPUShaderFormat shader_formats;
|
||||
bool (*PrepareDriver)(SDL_VideoDevice *_this);
|
||||
SDL_GPUDevice *(*CreateDevice)(bool debug_mode, bool prefer_low_power, SDL_PropertiesID props);
|
||||
} SDL_GPUBootstrap;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern SDL_GPUBootstrap VulkanDriver;
|
||||
extern SDL_GPUBootstrap D3D12Driver;
|
||||
extern SDL_GPUBootstrap MetalDriver;
|
||||
extern SDL_GPUBootstrap PrivateGPUDriver;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SDL_GPU_DRIVER_H
|
||||
3349
vendor/sdl-3.2.10/src/gpu/d3d12/D3D12_Blit.h
vendored
Normal file
3349
vendor/sdl-3.2.10/src/gpu/d3d12/D3D12_Blit.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
97
vendor/sdl-3.2.10/src/gpu/d3d12/D3D_Blit.hlsl
vendored
Normal file
97
vendor/sdl-3.2.10/src/gpu/d3d12/D3D_Blit.hlsl
vendored
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
#define BlitRS \
|
||||
"DescriptorTable ( Sampler(s0, space=2), visibility = SHADER_VISIBILITY_PIXEL ),"\
|
||||
"DescriptorTable ( SRV(t0, space=2), visibility = SHADER_VISIBILITY_PIXEL ),"\
|
||||
"CBV(b0, space=3, visibility = SHADER_VISIBILITY_PIXEL),"\
|
||||
|
||||
struct VertexToPixel
|
||||
{
|
||||
float2 tex : TEXCOORD0;
|
||||
float4 pos : SV_POSITION;
|
||||
};
|
||||
|
||||
cbuffer SourceRegionBuffer : register(b0, space3)
|
||||
{
|
||||
float2 UVLeftTop;
|
||||
float2 UVDimensions;
|
||||
uint MipLevel;
|
||||
float LayerOrDepth;
|
||||
};
|
||||
|
||||
Texture2D SourceTexture2D : register(t0, space2);
|
||||
Texture2DArray SourceTexture2DArray : register(t0, space2);
|
||||
Texture3D SourceTexture3D : register(t0, space2);
|
||||
TextureCube SourceTextureCube : register(t0, space2);
|
||||
TextureCubeArray SourceTextureCubeArray : register(t0, space2);
|
||||
sampler SourceSampler : register(s0, space2);
|
||||
|
||||
[RootSignature(BlitRS)]
|
||||
VertexToPixel FullscreenVert(uint vI : SV_VERTEXID)
|
||||
{
|
||||
float2 inTex = float2((vI << 1) & 2, vI & 2);
|
||||
VertexToPixel Out = (VertexToPixel)0;
|
||||
Out.tex = inTex;
|
||||
Out.pos = float4(inTex * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);
|
||||
return Out;
|
||||
}
|
||||
|
||||
[RootSignature(BlitRS)]
|
||||
float4 BlitFrom2D(VertexToPixel input) : SV_Target0
|
||||
{
|
||||
float2 newCoord = UVLeftTop + UVDimensions * input.tex;
|
||||
return SourceTexture2D.SampleLevel(SourceSampler, newCoord, MipLevel);
|
||||
}
|
||||
|
||||
[RootSignature(BlitRS)]
|
||||
float4 BlitFrom2DArray(VertexToPixel input) : SV_Target0
|
||||
{
|
||||
float3 newCoord = float3(UVLeftTop + UVDimensions * input.tex, (uint)LayerOrDepth);
|
||||
return SourceTexture2DArray.SampleLevel(SourceSampler, newCoord, MipLevel);
|
||||
}
|
||||
|
||||
[RootSignature(BlitRS)]
|
||||
float4 BlitFrom3D(VertexToPixel input) : SV_Target0
|
||||
{
|
||||
float3 newCoord = float3(UVLeftTop + UVDimensions * input.tex, LayerOrDepth);
|
||||
return SourceTexture3D.SampleLevel(SourceSampler, newCoord, MipLevel);
|
||||
}
|
||||
|
||||
[RootSignature(BlitRS)]
|
||||
float4 BlitFromCube(VertexToPixel input) : SV_Target0
|
||||
{
|
||||
// Thanks, Wikipedia! https://en.wikipedia.org/wiki/Cube_mapping
|
||||
float3 newCoord;
|
||||
float2 scaledUV = UVLeftTop + UVDimensions * input.tex;
|
||||
float u = 2.0 * scaledUV.x - 1.0;
|
||||
float v = 2.0 * scaledUV.y - 1.0;
|
||||
switch ((uint)LayerOrDepth) {
|
||||
case 0: newCoord = float3(1.0, -v, -u); break; // POSITIVE X
|
||||
case 1: newCoord = float3(-1.0, -v, u); break; // NEGATIVE X
|
||||
case 2: newCoord = float3(u, 1.0, -v); break; // POSITIVE Y
|
||||
case 3: newCoord = float3(u, -1.0, v); break; // NEGATIVE Y
|
||||
case 4: newCoord = float3(u, -v, 1.0); break; // POSITIVE Z
|
||||
case 5: newCoord = float3(-u, -v, -1.0); break; // NEGATIVE Z
|
||||
default: newCoord = float3(0, 0, 0); break; // silences warning
|
||||
}
|
||||
return SourceTextureCube.SampleLevel(SourceSampler, newCoord, MipLevel);
|
||||
}
|
||||
|
||||
[RootSignature(BlitRS)]
|
||||
float4 BlitFromCubeArray(VertexToPixel input) : SV_Target0
|
||||
{
|
||||
// Thanks, Wikipedia! https://en.wikipedia.org/wiki/Cube_mapping
|
||||
float3 newCoord;
|
||||
float2 scaledUV = UVLeftTop + UVDimensions * input.tex;
|
||||
float u = 2.0 * scaledUV.x - 1.0;
|
||||
float v = 2.0 * scaledUV.y - 1.0;
|
||||
uint ArrayIndex = (uint)LayerOrDepth / 6;
|
||||
switch ((uint)LayerOrDepth % 6) {
|
||||
case 0: newCoord = float3(1.0, -v, -u); break; // POSITIVE X
|
||||
case 1: newCoord = float3(-1.0, -v, u); break; // NEGATIVE X
|
||||
case 2: newCoord = float3(u, 1.0, -v); break; // POSITIVE Y
|
||||
case 3: newCoord = float3(u, -1.0, v); break; // NEGATIVE Y
|
||||
case 4: newCoord = float3(u, -v, 1.0); break; // POSITIVE Z
|
||||
case 5: newCoord = float3(-u, -v, -1.0); break; // NEGATIVE Z
|
||||
default: newCoord = float3(0, 0, 0); break; // silences warning
|
||||
}
|
||||
return SourceTextureCubeArray.SampleLevel(SourceSampler, float4(newCoord, float(ArrayIndex)), MipLevel);
|
||||
}
|
||||
9113
vendor/sdl-3.2.10/src/gpu/d3d12/SDL_gpu_d3d12.c
vendored
Normal file
9113
vendor/sdl-3.2.10/src/gpu/d3d12/SDL_gpu_d3d12.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
18
vendor/sdl-3.2.10/src/gpu/d3d12/compile_shaders.bat
vendored
Normal file
18
vendor/sdl-3.2.10/src/gpu/d3d12/compile_shaders.bat
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
rem This script runs for the Windows build, but also via the _xbox variant with these vars set.
|
||||
rem Make sure to default to building for Windows if they're not set.
|
||||
if %DXC%.==. set DXC=dxc
|
||||
if %SUFFIX%.==. set SUFFIX=.h
|
||||
|
||||
echo Building with %DXC%
|
||||
echo Suffix %SUFFIX%
|
||||
|
||||
cd "%~dp0"
|
||||
|
||||
%DXC% -E FullscreenVert -T vs_6_0 -Fh D3D12_FullscreenVert.h D3D_Blit.hlsl
|
||||
%DXC% -E BlitFrom2D -T ps_6_0 -Fh D3D12_BlitFrom2D.h D3D_Blit.hlsl
|
||||
%DXC% -E BlitFrom2DArray -T ps_6_0 -Fh D3D12_BlitFrom2DArray.h D3D_Blit.hlsl
|
||||
%DXC% -E BlitFrom3D -T ps_6_0 -Fh D3D12_BlitFrom3D.h D3D_Blit.hlsl
|
||||
%DXC% -E BlitFromCube -T ps_6_0 -Fh D3D12_BlitFromCube.h D3D_Blit.hlsl
|
||||
%DXC% -E BlitFromCubeArray -T ps_6_0 -Fh D3D12_BlitFromCubeArray.h D3D_Blit.hlsl
|
||||
copy /b D3D12_FullscreenVert.h+D3D12_BlitFrom2D.h+D3D12_BlitFrom2DArray.h+D3D12_BlitFrom3D.h+D3D12_BlitFromCube.h+D3D12_BlitFromCubeArray.h D3D12_Blit%SUFFIX%
|
||||
del D3D12_FullscreenVert.h D3D12_BlitFrom2D.h D3D12_BlitFrom2DArray.h D3D12_BlitFrom3D.h D3D12_BlitFromCube.h D3D12_BlitFromCubeArray.h
|
||||
13
vendor/sdl-3.2.10/src/gpu/d3d12/compile_shaders_xbox.bat
vendored
Normal file
13
vendor/sdl-3.2.10/src/gpu/d3d12/compile_shaders_xbox.bat
vendored
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
if %2.==one. goto setxboxone
|
||||
rem Xbox Series compile
|
||||
set DXC="%GameDKLatest%\GXDK\bin\Scarlett\DXC.exe"
|
||||
set SUFFIX=_Series.h
|
||||
goto startbuild
|
||||
|
||||
:setxboxone
|
||||
set DXC="%GameDKLatest%\GXDK\bin\XboxOne\DXC.exe"
|
||||
set SUFFIX=_One.h
|
||||
|
||||
:startbuild
|
||||
|
||||
call "%~dp0\compile_shaders.bat"
|
||||
10088
vendor/sdl-3.2.10/src/gpu/metal/Metal_Blit.h
vendored
Normal file
10088
vendor/sdl-3.2.10/src/gpu/metal/Metal_Blit.h
vendored
Normal file
File diff suppressed because it is too large
Load diff
110
vendor/sdl-3.2.10/src/gpu/metal/Metal_Blit.metal
vendored
Normal file
110
vendor/sdl-3.2.10/src/gpu/metal/Metal_Blit.metal
vendored
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
#include <metal_stdlib>
|
||||
using namespace metal;
|
||||
|
||||
struct VertexToFragment {
|
||||
float2 tex;
|
||||
float4 pos [[position]];
|
||||
};
|
||||
|
||||
struct SourceRegion {
|
||||
float2 UVLeftTop;
|
||||
float2 UVDimensions;
|
||||
uint MipLevel;
|
||||
float LayerOrDepth;
|
||||
};
|
||||
|
||||
#if COMPILE_FullscreenVert
|
||||
vertex VertexToFragment FullscreenVert(uint vI [[vertex_id]]) {
|
||||
float2 inTex = float2((vI << 1) & 2, vI & 2);
|
||||
VertexToFragment out;
|
||||
out.tex = inTex;
|
||||
out.pos = float4(inTex * float2(2.0f, -2.0f) + float2(-1.0f, 1.0f), 0.0f, 1.0f);
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if COMPILE_BlitFrom2D
|
||||
fragment float4 BlitFrom2D(
|
||||
VertexToFragment input [[stage_in]],
|
||||
constant SourceRegion &sourceRegion [[buffer(0)]],
|
||||
texture2d<float> sourceTexture [[texture(0)]],
|
||||
sampler sourceSampler [[sampler(0)]])
|
||||
{
|
||||
float2 newCoord = sourceRegion.UVLeftTop + sourceRegion.UVDimensions * input.tex;
|
||||
return sourceTexture.sample(sourceSampler, newCoord, level(sourceRegion.MipLevel));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if COMPILE_BlitFrom2DArray
|
||||
fragment float4 BlitFrom2DArray(
|
||||
VertexToFragment input [[stage_in]],
|
||||
constant SourceRegion &sourceRegion [[buffer(0)]],
|
||||
texture2d_array<float> sourceTexture [[texture(0)]],
|
||||
sampler sourceSampler [[sampler(0)]])
|
||||
{
|
||||
float2 newCoord = sourceRegion.UVLeftTop + sourceRegion.UVDimensions * input.tex;
|
||||
return sourceTexture.sample(sourceSampler, newCoord, (uint)sourceRegion.LayerOrDepth, level(sourceRegion.MipLevel));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if COMPILE_BlitFrom3D
|
||||
fragment float4 BlitFrom3D(
|
||||
VertexToFragment input [[stage_in]],
|
||||
constant SourceRegion &sourceRegion [[buffer(0)]],
|
||||
texture3d<float> sourceTexture [[texture(0)]],
|
||||
sampler sourceSampler [[sampler(0)]])
|
||||
{
|
||||
float2 newCoord = sourceRegion.UVLeftTop + sourceRegion.UVDimensions * input.tex;
|
||||
return sourceTexture.sample(sourceSampler, float3(newCoord, sourceRegion.LayerOrDepth), level(sourceRegion.MipLevel));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if COMPILE_BlitFromCube
|
||||
fragment float4 BlitFromCube(
|
||||
VertexToFragment input [[stage_in]],
|
||||
constant SourceRegion &sourceRegion [[buffer(0)]],
|
||||
texturecube<float> sourceTexture [[texture(0)]],
|
||||
sampler sourceSampler [[sampler(0)]])
|
||||
{
|
||||
// Thanks, Wikipedia! https://en.wikipedia.org/wiki/Cube_mapping
|
||||
float2 scaledUV = sourceRegion.UVLeftTop + sourceRegion.UVDimensions * input.tex;
|
||||
float u = 2.0 * scaledUV.x - 1.0;
|
||||
float v = 2.0 * scaledUV.y - 1.0;
|
||||
float3 newCoord;
|
||||
switch ((uint)sourceRegion.LayerOrDepth) {
|
||||
case 0: newCoord = float3(1.0, -v, -u); break; // POSITIVE X
|
||||
case 1: newCoord = float3(-1.0, -v, u); break; // NEGATIVE X
|
||||
case 2: newCoord = float3(u, 1.0, -v); break; // POSITIVE Y
|
||||
case 3: newCoord = float3(u, -1.0, v); break; // NEGATIVE Y
|
||||
case 4: newCoord = float3(u, -v, 1.0); break; // POSITIVE Z
|
||||
case 5: newCoord = float3(-u, -v, -1.0); break; // NEGATIVE Z
|
||||
default: newCoord = float3(0, 0, 0); break; // silences warning
|
||||
}
|
||||
return sourceTexture.sample(sourceSampler, newCoord, level(sourceRegion.MipLevel));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if COMPILE_BlitFromCubeArray
|
||||
fragment float4 BlitFromCubeArray(
|
||||
VertexToFragment input [[stage_in]],
|
||||
constant SourceRegion &sourceRegion [[buffer(0)]],
|
||||
texturecube_array<float> sourceTexture [[texture(0)]],
|
||||
sampler sourceSampler [[sampler(0)]])
|
||||
{
|
||||
// Thanks, Wikipedia! https://en.wikipedia.org/wiki/Cube_mapping
|
||||
float2 scaledUV = sourceRegion.UVLeftTop + sourceRegion.UVDimensions * input.tex;
|
||||
float u = 2.0 * scaledUV.x - 1.0;
|
||||
float v = 2.0 * scaledUV.y - 1.0;
|
||||
float3 newCoord;
|
||||
switch (((uint)sourceRegion.LayerOrDepth) % 6) {
|
||||
case 0: newCoord = float3(1.0, -v, -u); break; // POSITIVE X
|
||||
case 1: newCoord = float3(-1.0, -v, u); break; // NEGATIVE X
|
||||
case 2: newCoord = float3(u, 1.0, -v); break; // POSITIVE Y
|
||||
case 3: newCoord = float3(u, -1.0, v); break; // NEGATIVE Y
|
||||
case 4: newCoord = float3(u, -v, 1.0); break; // POSITIVE Z
|
||||
case 5: newCoord = float3(-u, -v, -1.0); break; // NEGATIVE Z
|
||||
default: newCoord = float3(0, 0, 0); break; // silences warning
|
||||
}
|
||||
return sourceTexture.sample(sourceSampler, newCoord, (uint)sourceRegion.LayerOrDepth / 6, level(sourceRegion.MipLevel));
|
||||
}
|
||||
#endif
|
||||
4580
vendor/sdl-3.2.10/src/gpu/metal/SDL_gpu_metal.m
vendored
Normal file
4580
vendor/sdl-3.2.10/src/gpu/metal/SDL_gpu_metal.m
vendored
Normal file
File diff suppressed because it is too large
Load diff
68
vendor/sdl-3.2.10/src/gpu/metal/compile_shaders.sh
vendored
Executable file
68
vendor/sdl-3.2.10/src/gpu/metal/compile_shaders.sh
vendored
Executable file
|
|
@ -0,0 +1,68 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
set -e
|
||||
cd `dirname "$0"`
|
||||
|
||||
shadernames=(FullscreenVert BlitFrom2D BlitFrom2DArray BlitFrom3D BlitFromCube BlitFromCubeArray)
|
||||
|
||||
generate_shaders()
|
||||
{
|
||||
fileplatform=$1
|
||||
compileplatform=$2
|
||||
sdkplatform=$3
|
||||
minversion=$4
|
||||
|
||||
for shadername in "${shadernames[@]}"; do
|
||||
xcrun -sdk $sdkplatform metal -c -std=$compileplatform-metal2.0 -m$sdkplatform-version-min=$minversion -Wall -O3 -D COMPILE_$shadername -o ./$shadername.air ./Metal_Blit.metal || exit $?
|
||||
xcrun -sdk $sdkplatform metallib -o $shadername.metallib $shadername.air || exit $?
|
||||
xxd -i $shadername.metallib | perl -w -p -e 's/\Aunsigned /const unsigned /;' >./${shadername}_$fileplatform.h
|
||||
rm -f $shadername.air $shadername.metallib
|
||||
done
|
||||
}
|
||||
|
||||
generate_shaders macos macos macosx 10.11
|
||||
generate_shaders ios ios iphoneos 11.0
|
||||
generate_shaders iphonesimulator ios iphonesimulator 11.0
|
||||
generate_shaders tvos ios appletvos 11.0
|
||||
generate_shaders tvsimulator ios appletvsimulator 11.0
|
||||
|
||||
# Bundle together one mega-header
|
||||
catShaders()
|
||||
{
|
||||
target=$1
|
||||
for shadername in "${shadernames[@]}"; do
|
||||
cat ${shadername}_$target.h >> Metal_Blit.h
|
||||
done
|
||||
}
|
||||
|
||||
rm -f Metal_Blit.h
|
||||
echo "#if defined(SDL_PLATFORM_IOS)" >> Metal_Blit.h
|
||||
echo "#if TARGET_OS_SIMULATOR" >> Metal_Blit.h
|
||||
catShaders iphonesimulator
|
||||
echo "#else" >> Metal_Blit.h
|
||||
catShaders ios
|
||||
echo "#endif" >> Metal_Blit.h
|
||||
echo "#elif defined(SDL_PLATFORM_TVOS)" >> Metal_Blit.h
|
||||
echo "#if TARGET_OS_SIMULATOR" >> Metal_Blit.h
|
||||
catShaders tvsimulator
|
||||
echo "#else" >> Metal_Blit.h
|
||||
catShaders tvos
|
||||
echo "#endif" >> Metal_Blit.h
|
||||
echo "#else" >> Metal_Blit.h
|
||||
catShaders macos
|
||||
echo "#endif" >> Metal_Blit.h
|
||||
|
||||
# Clean up
|
||||
cleanupShaders()
|
||||
{
|
||||
target=$1
|
||||
for shadername in "${shadernames[@]}"; do
|
||||
rm -f ${shadername}_$target.h
|
||||
done
|
||||
}
|
||||
cleanupShaders iphonesimulator
|
||||
cleanupShaders ios
|
||||
cleanupShaders tvsimulator
|
||||
cleanupShaders tvos
|
||||
cleanupShaders macos
|
||||
11852
vendor/sdl-3.2.10/src/gpu/vulkan/SDL_gpu_vulkan.c
vendored
Normal file
11852
vendor/sdl-3.2.10/src/gpu/vulkan/SDL_gpu_vulkan.c
vendored
Normal file
File diff suppressed because it is too large
Load diff
176
vendor/sdl-3.2.10/src/gpu/vulkan/SDL_gpu_vulkan_vkfuncs.h
vendored
Normal file
176
vendor/sdl-3.2.10/src/gpu/vulkan/SDL_gpu_vulkan_vkfuncs.h
vendored
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Global functions from the Vulkan Loader
|
||||
*/
|
||||
|
||||
#ifndef VULKAN_GLOBAL_FUNCTION
|
||||
#define VULKAN_GLOBAL_FUNCTION(name)
|
||||
#endif
|
||||
VULKAN_GLOBAL_FUNCTION(vkCreateInstance)
|
||||
VULKAN_GLOBAL_FUNCTION(vkEnumerateInstanceExtensionProperties)
|
||||
VULKAN_GLOBAL_FUNCTION(vkEnumerateInstanceLayerProperties)
|
||||
|
||||
/*
|
||||
* vkInstance, created by global vkCreateInstance function
|
||||
*/
|
||||
|
||||
#ifndef VULKAN_INSTANCE_FUNCTION
|
||||
#define VULKAN_INSTANCE_FUNCTION(name)
|
||||
#endif
|
||||
|
||||
// Vulkan 1.0
|
||||
VULKAN_INSTANCE_FUNCTION(vkGetDeviceProcAddr)
|
||||
VULKAN_INSTANCE_FUNCTION(vkCreateDevice)
|
||||
VULKAN_INSTANCE_FUNCTION(vkDestroyInstance)
|
||||
VULKAN_INSTANCE_FUNCTION(vkEnumerateDeviceExtensionProperties)
|
||||
VULKAN_INSTANCE_FUNCTION(vkEnumeratePhysicalDevices)
|
||||
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceFeatures)
|
||||
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceQueueFamilyProperties)
|
||||
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceFormatProperties)
|
||||
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceImageFormatProperties)
|
||||
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceMemoryProperties)
|
||||
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceProperties)
|
||||
|
||||
// VK_KHR_get_physical_device_properties2, needed for KHR_driver_properties
|
||||
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceProperties2KHR)
|
||||
|
||||
// VK_KHR_surface
|
||||
VULKAN_INSTANCE_FUNCTION(vkDestroySurfaceKHR)
|
||||
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceCapabilitiesKHR)
|
||||
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceFormatsKHR)
|
||||
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfacePresentModesKHR)
|
||||
VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceSurfaceSupportKHR)
|
||||
|
||||
// VK_EXT_debug_utils
|
||||
VULKAN_INSTANCE_FUNCTION(vkCmdBeginDebugUtilsLabelEXT)
|
||||
VULKAN_INSTANCE_FUNCTION(vkSetDebugUtilsObjectNameEXT)
|
||||
VULKAN_INSTANCE_FUNCTION(vkCmdEndDebugUtilsLabelEXT)
|
||||
VULKAN_INSTANCE_FUNCTION(vkCmdInsertDebugUtilsLabelEXT)
|
||||
|
||||
/*
|
||||
* vkDevice, created by a vkInstance
|
||||
*/
|
||||
|
||||
#ifndef VULKAN_DEVICE_FUNCTION
|
||||
#define VULKAN_DEVICE_FUNCTION(name)
|
||||
#endif
|
||||
|
||||
// Vulkan 1.0
|
||||
VULKAN_DEVICE_FUNCTION(vkAllocateCommandBuffers)
|
||||
VULKAN_DEVICE_FUNCTION(vkAllocateDescriptorSets)
|
||||
VULKAN_DEVICE_FUNCTION(vkAllocateMemory)
|
||||
VULKAN_DEVICE_FUNCTION(vkBeginCommandBuffer)
|
||||
VULKAN_DEVICE_FUNCTION(vkBindBufferMemory)
|
||||
VULKAN_DEVICE_FUNCTION(vkBindImageMemory)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdBeginRenderPass)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdBindDescriptorSets)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdBindIndexBuffer)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdBindPipeline)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdBindVertexBuffers)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdBlitImage)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdClearAttachments)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdClearColorImage)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdClearDepthStencilImage)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdCopyBuffer)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdCopyImage)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdCopyBufferToImage)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdCopyImageToBuffer)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdDispatch)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdDispatchIndirect)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdDraw)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdDrawIndexed)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdDrawIndexedIndirect)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdDrawIndirect)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdEndRenderPass)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdPipelineBarrier)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdResolveImage)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdSetBlendConstants)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdSetDepthBias)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdSetScissor)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdSetStencilReference)
|
||||
VULKAN_DEVICE_FUNCTION(vkCmdSetViewport)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateBuffer)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateCommandPool)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateDescriptorPool)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateDescriptorSetLayout)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateFence)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateFramebuffer)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateComputePipelines)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateGraphicsPipelines)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateImage)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateImageView)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreatePipelineCache)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreatePipelineLayout)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateRenderPass)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateSampler)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateSemaphore)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateShaderModule)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyBuffer)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyCommandPool)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyDescriptorPool)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyDescriptorSetLayout)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyDevice)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyFence)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyFramebuffer)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyImage)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyImageView)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyPipeline)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyPipelineCache)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyPipelineLayout)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyRenderPass)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroySampler)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroySemaphore)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroyShaderModule)
|
||||
VULKAN_DEVICE_FUNCTION(vkDeviceWaitIdle)
|
||||
VULKAN_DEVICE_FUNCTION(vkEndCommandBuffer)
|
||||
VULKAN_DEVICE_FUNCTION(vkFreeCommandBuffers)
|
||||
VULKAN_DEVICE_FUNCTION(vkFreeMemory)
|
||||
VULKAN_DEVICE_FUNCTION(vkGetDeviceQueue)
|
||||
VULKAN_DEVICE_FUNCTION(vkGetPipelineCacheData)
|
||||
VULKAN_DEVICE_FUNCTION(vkGetFenceStatus)
|
||||
VULKAN_DEVICE_FUNCTION(vkGetBufferMemoryRequirements)
|
||||
VULKAN_DEVICE_FUNCTION(vkGetImageMemoryRequirements)
|
||||
VULKAN_DEVICE_FUNCTION(vkMapMemory)
|
||||
VULKAN_DEVICE_FUNCTION(vkQueueSubmit)
|
||||
VULKAN_DEVICE_FUNCTION(vkQueueWaitIdle)
|
||||
VULKAN_DEVICE_FUNCTION(vkResetCommandBuffer)
|
||||
VULKAN_DEVICE_FUNCTION(vkResetCommandPool)
|
||||
VULKAN_DEVICE_FUNCTION(vkResetDescriptorPool)
|
||||
VULKAN_DEVICE_FUNCTION(vkResetFences)
|
||||
VULKAN_DEVICE_FUNCTION(vkUnmapMemory)
|
||||
VULKAN_DEVICE_FUNCTION(vkUpdateDescriptorSets)
|
||||
VULKAN_DEVICE_FUNCTION(vkWaitForFences)
|
||||
|
||||
// VK_KHR_swapchain
|
||||
VULKAN_DEVICE_FUNCTION(vkAcquireNextImageKHR)
|
||||
VULKAN_DEVICE_FUNCTION(vkCreateSwapchainKHR)
|
||||
VULKAN_DEVICE_FUNCTION(vkDestroySwapchainKHR)
|
||||
VULKAN_DEVICE_FUNCTION(vkQueuePresentKHR)
|
||||
VULKAN_DEVICE_FUNCTION(vkGetSwapchainImagesKHR)
|
||||
|
||||
/*
|
||||
* Redefine these every time you include this header!
|
||||
*/
|
||||
#undef VULKAN_GLOBAL_FUNCTION
|
||||
#undef VULKAN_INSTANCE_FUNCTION
|
||||
#undef VULKAN_DEVICE_FUNCTION
|
||||
Loading…
Add table
Add a link
Reference in a new issue