From 595c15a0870a786f9ba006b78d0d8fb2b08c072b Mon Sep 17 00:00:00 2001 From: Caleb Cornett Date: Thu, 12 Oct 2023 22:11:55 -0500 Subject: [PATCH] Add a border color conversion function --- src/Refresh_Driver_D3D11.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/Refresh_Driver_D3D11.c b/src/Refresh_Driver_D3D11.c index 8325942..9d3ec06 100644 --- a/src/Refresh_Driver_D3D11.c +++ b/src/Refresh_Driver_D3D11.c @@ -245,6 +245,38 @@ static D3D11_TEXTURE_ADDRESS_MODE RefreshToD3D11_SamplerAddressMode[] = D3D11_TEXTURE_ADDRESS_BORDER /* CLAMP_TO_BORDER */ }; +static void RefreshToD3D11_BorderColor( + Refresh_SamplerStateCreateInfo *createInfo, + D3D11_SAMPLER_DESC *desc +) { + switch (createInfo->borderColor) + { + case REFRESH_BORDERCOLOR_FLOAT_OPAQUE_BLACK: + case REFRESH_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 REFRESH_BORDERCOLOR_FLOAT_OPAQUE_WHITE: + case REFRESH_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 REFRESH_BORDERCOLOR_FLOAT_TRANSPARENT_BLACK: + case REFRESH_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 RefreshToD3D11_Filter(Refresh_SamplerStateCreateInfo *createInfo) { if (createInfo->minFilter == REFRESH_FILTER_LINEAR) @@ -1018,7 +1050,10 @@ static Refresh_Sampler* D3D11_CreateSampler( samplerDesc.AddressV = RefreshToD3D11_SamplerAddressMode[samplerStateCreateInfo->addressModeV]; samplerDesc.AddressW = RefreshToD3D11_SamplerAddressMode[samplerStateCreateInfo->addressModeW]; - /* FIXME: border color! */ + RefreshToD3D11_BorderColor( + samplerStateCreateInfo, + &samplerDesc + ); samplerDesc.ComparisonFunc = ( samplerStateCreateInfo->compareEnable ?