From e6097bdc29bee1854ac9f4b8f0dd1b25619425ad Mon Sep 17 00:00:00 2001 From: Caleb Cornett Date: Fri, 21 Jun 2024 13:35:19 -0500 Subject: [PATCH] Remove support for border colors (#50) --- include/SDL3/SDL_gpu.h | 15 +----------- src/gpu/d3d11/SDL_gpu_d3d11.c | 41 ++------------------------------- src/gpu/metal/SDL_gpu_metal.m | 15 ++---------- src/gpu/vulkan/SDL_gpu_vulkan.c | 14 ++--------- 4 files changed, 7 insertions(+), 78 deletions(-) diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h index 2b47bb4972f1a..43d20b6bc4009 100644 --- a/include/SDL3/SDL_gpu.h +++ b/include/SDL3/SDL_gpu.h @@ -319,21 +319,9 @@ typedef enum SDL_GpuSamplerAddressMode { SDL_GPU_SAMPLERADDRESSMODE_REPEAT, SDL_GPU_SAMPLERADDRESSMODE_MIRRORED_REPEAT, - SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE, - SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_BORDER + SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE } SDL_GpuSamplerAddressMode; -/* FIXME: we should probably make a library-level decision about color types */ -typedef enum SDL_GpuBorderColor -{ - SDL_GPU_BORDERCOLOR_FLOAT_TRANSPARENT_BLACK, - SDL_GPU_BORDERCOLOR_INT_TRANSPARENT_BLACK, - SDL_GPU_BORDERCOLOR_FLOAT_OPAQUE_BLACK, - SDL_GPU_BORDERCOLOR_INT_OPAQUE_BLACK, - SDL_GPU_BORDERCOLOR_FLOAT_OPAQUE_WHITE, - SDL_GPU_BORDERCOLOR_INT_OPAQUE_WHITE -} SDL_GpuBorderColor; - /* * VSYNC: * Waits for vblank before presenting. @@ -486,7 +474,6 @@ typedef struct SDL_GpuSamplerCreateInfo SDL_GpuCompareOp compareOp; float minLod; float maxLod; - SDL_GpuBorderColor borderColor; } SDL_GpuSamplerCreateInfo; typedef struct SDL_GpuVertexBinding diff --git a/src/gpu/d3d11/SDL_gpu_d3d11.c b/src/gpu/d3d11/SDL_gpu_d3d11.c index 643e67c2faedd..2fef227c56e85 100644 --- a/src/gpu/d3d11/SDL_gpu_d3d11.c +++ b/src/gpu/d3d11/SDL_gpu_d3d11.c @@ -374,41 +374,9 @@ static D3D11_INPUT_CLASSIFICATION SDLToD3D11_VertexInputRate[] = { static D3D11_TEXTURE_ADDRESS_MODE SDLToD3D11_SamplerAddressMode[] = { D3D11_TEXTURE_ADDRESS_WRAP, /* REPEAT */ D3D11_TEXTURE_ADDRESS_MIRROR, /* MIRRORED_REPEAT */ - D3D11_TEXTURE_ADDRESS_CLAMP, /* CLAMP_TO_EDGE */ - D3D11_TEXTURE_ADDRESS_BORDER /* CLAMP_TO_BORDER */ + D3D11_TEXTURE_ADDRESS_CLAMP /* CLAMP_TO_EDGE */ }; -static void SDLToD3D11_BorderColor( - SDL_GpuSamplerCreateInfo *createInfo, - D3D11_SAMPLER_DESC *desc) -{ - switch (createInfo->borderColor) { - case SDL_GPU_BORDERCOLOR_FLOAT_OPAQUE_BLACK: - case SDL_GPU_BORDERCOLOR_INT_OPAQUE_BLACK: - desc->BorderColor[0] = 0.0f; - desc->BorderColor[1] = 0.0f; - desc->BorderColor[2] = 0.0f; - desc->BorderColor[3] = 1.0f; - break; - - case SDL_GPU_BORDERCOLOR_FLOAT_OPAQUE_WHITE: - case SDL_GPU_BORDERCOLOR_INT_OPAQUE_WHITE: - desc->BorderColor[0] = 1.0f; - desc->BorderColor[1] = 1.0f; - desc->BorderColor[2] = 1.0f; - desc->BorderColor[3] = 1.0f; - break; - - case SDL_GPU_BORDERCOLOR_FLOAT_TRANSPARENT_BLACK: - case SDL_GPU_BORDERCOLOR_INT_TRANSPARENT_BLACK: - desc->BorderColor[0] = 0.0f; - desc->BorderColor[1] = 0.0f; - desc->BorderColor[2] = 0.0f; - desc->BorderColor[3] = 0.0f; - break; - } -} - static D3D11_FILTER SDLToD3D11_Filter(SDL_GpuSamplerCreateInfo *createInfo) { if (createInfo->minFilter == SDL_GPU_FILTER_LINEAR) { @@ -1875,17 +1843,13 @@ static SDL_GpuSampler *D3D11_CreateSampler( samplerDesc.AddressU = SDLToD3D11_SamplerAddressMode[samplerCreateInfo->addressModeU]; samplerDesc.AddressV = SDLToD3D11_SamplerAddressMode[samplerCreateInfo->addressModeV]; samplerDesc.AddressW = SDLToD3D11_SamplerAddressMode[samplerCreateInfo->addressModeW]; - - SDLToD3D11_BorderColor( - samplerCreateInfo, - &samplerDesc); - samplerDesc.ComparisonFunc = (samplerCreateInfo->compareEnable ? SDLToD3D11_CompareOp[samplerCreateInfo->compareOp] : SDLToD3D11_CompareOp[SDL_GPU_COMPAREOP_ALWAYS]); samplerDesc.MaxAnisotropy = (samplerCreateInfo->anisotropyEnable ? (UINT)samplerCreateInfo->maxAnisotropy : 0); samplerDesc.Filter = SDLToD3D11_Filter(samplerCreateInfo); samplerDesc.MaxLOD = samplerCreateInfo->maxLod; samplerDesc.MinLOD = samplerCreateInfo->minLod; samplerDesc.MipLODBias = samplerCreateInfo->mipLodBias; + SDL_zeroa(samplerDesc.BorderColor); /* arbitrary, unused */ res = ID3D11Device_CreateSamplerState( renderer->device, @@ -6059,7 +6023,6 @@ static void D3D11_INTERNAL_InitBlitPipelines( samplerCreateInfo.mipLodBias = 0.0f; samplerCreateInfo.minLod = 0; samplerCreateInfo.maxLod = 1000; - samplerCreateInfo.borderColor = SDL_GPU_BORDERCOLOR_FLOAT_TRANSPARENT_BLACK; renderer->blitNearestSampler = D3D11_CreateSampler( (SDL_GpuRenderer *)renderer, diff --git a/src/gpu/metal/SDL_gpu_metal.m b/src/gpu/metal/SDL_gpu_metal.m index bbaddf861f15c..db1b8bf724043 100644 --- a/src/gpu/metal/SDL_gpu_metal.m +++ b/src/gpu/metal/SDL_gpu_metal.m @@ -250,17 +250,7 @@ static void METAL_UnclaimWindow( static MTLSamplerAddressMode SDLToMetal_SamplerAddressMode[] = { MTLSamplerAddressModeRepeat, /* REPEAT */ MTLSamplerAddressModeMirrorRepeat, /* MIRRORED_REPEAT */ - MTLSamplerAddressModeClampToEdge, /* CLAMP_TO_EDGE */ - MTLSamplerAddressModeClampToBorderColor, /* CLAMP_TO_BORDER */ -}; - -static MTLSamplerBorderColor SDLToMetal_BorderColor[] = { - MTLSamplerBorderColorTransparentBlack, /* FLOAT_TRANSPARENT_BLACK */ - MTLSamplerBorderColorTransparentBlack, /* INT_TRANSPARENT_BLACK */ - MTLSamplerBorderColorOpaqueBlack, /* FLOAT_OPAQUE_BLACK */ - MTLSamplerBorderColorOpaqueBlack, /* INT_OPAQUE_BLACK */ - MTLSamplerBorderColorOpaqueWhite, /* FLOAT_OPAQUE_WHITE */ - MTLSamplerBorderColorOpaqueWhite, /* INT_OPAQUE_WHITE */ + MTLSamplerAddressModeClampToEdge /* CLAMP_TO_EDGE */ }; static MTLSamplerMinMagFilter SDLToMetal_MinMagFilter[] = { @@ -1163,7 +1153,6 @@ static void METAL_PopDebugGroup( samplerDesc.rAddressMode = SDLToMetal_SamplerAddressMode[samplerCreateInfo->addressModeU]; samplerDesc.sAddressMode = SDLToMetal_SamplerAddressMode[samplerCreateInfo->addressModeV]; samplerDesc.tAddressMode = SDLToMetal_SamplerAddressMode[samplerCreateInfo->addressModeW]; - samplerDesc.borderColor = SDLToMetal_BorderColor[samplerCreateInfo->borderColor]; samplerDesc.minFilter = SDLToMetal_MinMagFilter[samplerCreateInfo->minFilter]; samplerDesc.magFilter = SDLToMetal_MinMagFilter[samplerCreateInfo->magFilter]; samplerDesc.mipFilter = SDLToMetal_MipFilter[samplerCreateInfo->mipmapMode]; /* FIXME: Is this right with non-mipmapped samplers? */ @@ -1171,6 +1160,7 @@ static void METAL_PopDebugGroup( samplerDesc.lodMaxClamp = samplerCreateInfo->maxLod; samplerDesc.maxAnisotropy = (NSUInteger)((samplerCreateInfo->anisotropyEnable) ? samplerCreateInfo->maxAnisotropy : 1); samplerDesc.compareFunction = (samplerCreateInfo->compareEnable) ? SDLToMetal_CompareOp[samplerCreateInfo->compareOp] : MTLCompareFunctionAlways; + samplerDesc.borderColor = MTLSamplerBorderColorTransparentBlack; /* arbitrary, unused */ sampler = [renderer->device newSamplerStateWithDescriptor:samplerDesc]; if (sampler == NULL) { @@ -3619,7 +3609,6 @@ static void METAL_INTERNAL_InitBlitResources( samplerCreateInfo.mipLodBias = 0.0f; samplerCreateInfo.minLod = 0; samplerCreateInfo.maxLod = 1000; - samplerCreateInfo.borderColor = SDL_GPU_BORDERCOLOR_FLOAT_TRANSPARENT_BLACK; renderer->blitNearestSampler = METAL_CreateSampler( (SDL_GpuRenderer *)renderer, diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c index 05958b6d772af..2d68e582ba6d2 100644 --- a/src/gpu/vulkan/SDL_gpu_vulkan.c +++ b/src/gpu/vulkan/SDL_gpu_vulkan.c @@ -324,17 +324,7 @@ static VkSamplerMipmapMode SDLToVK_SamplerMipmapMode[] = { static VkSamplerAddressMode SDLToVK_SamplerAddressMode[] = { VK_SAMPLER_ADDRESS_MODE_REPEAT, VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT, - VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, - VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER -}; - -static VkBorderColor SDLToVK_BorderColor[] = { - VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, - VK_BORDER_COLOR_INT_TRANSPARENT_BLACK, - VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK, - VK_BORDER_COLOR_INT_OPAQUE_BLACK, - VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE, - VK_BORDER_COLOR_INT_OPAQUE_WHITE + VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE }; /* Structures */ @@ -6599,7 +6589,7 @@ static SDL_GpuSampler *VULKAN_CreateSampler( vkSamplerCreateInfo.compareOp = SDLToVK_CompareOp[samplerCreateInfo->compareOp]; vkSamplerCreateInfo.minLod = samplerCreateInfo->minLod; vkSamplerCreateInfo.maxLod = samplerCreateInfo->maxLod; - vkSamplerCreateInfo.borderColor = SDLToVK_BorderColor[samplerCreateInfo->borderColor]; + vkSamplerCreateInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; /* arbitrary, unused */ vkSamplerCreateInfo.unnormalizedCoordinates = VK_FALSE; vulkanResult = renderer->vkCreateSampler(