mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-27 08:18:41 +00:00
Fix GetSampler() bug for INDEX8 pixel format (#15099)
(cherry picked from commit 4a4ae4a79d)
This commit is contained in:
parent
27439467ce
commit
01d8bb5b7c
5 changed files with 34 additions and 38 deletions
|
|
@ -774,6 +774,11 @@ static void SetViewportAndScissor(GPU_RenderData *data)
|
|||
|
||||
static SDL_GPUSampler *GetSampler(GPU_RenderData *data, SDL_PixelFormat format, SDL_ScaleMode scale_mode, SDL_TextureAddressMode address_u, SDL_TextureAddressMode address_v)
|
||||
{
|
||||
if (format == SDL_PIXELFORMAT_INDEX8) {
|
||||
// We'll do linear sampling in the shader if needed
|
||||
scale_mode = SDL_SCALEMODE_NEAREST;
|
||||
}
|
||||
|
||||
Uint32 key = RENDER_SAMPLER_HASHKEY(scale_mode, address_u, address_v);
|
||||
SDL_assert(key < SDL_arraysize(data->samplers));
|
||||
if (!data->samplers[key]) {
|
||||
|
|
@ -787,16 +792,9 @@ static SDL_GPUSampler *GetSampler(GPU_RenderData *data, SDL_PixelFormat format,
|
|||
break;
|
||||
case SDL_SCALEMODE_PIXELART: // Uses linear sampling
|
||||
case SDL_SCALEMODE_LINEAR:
|
||||
if (format == SDL_PIXELFORMAT_INDEX8) {
|
||||
// We'll do linear sampling in the shader
|
||||
sci.min_filter = SDL_GPU_FILTER_NEAREST;
|
||||
sci.mag_filter = SDL_GPU_FILTER_NEAREST;
|
||||
sci.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST;
|
||||
} else {
|
||||
sci.min_filter = SDL_GPU_FILTER_LINEAR;
|
||||
sci.mag_filter = SDL_GPU_FILTER_LINEAR;
|
||||
sci.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR;
|
||||
}
|
||||
sci.min_filter = SDL_GPU_FILTER_LINEAR;
|
||||
sci.mag_filter = SDL_GPU_FILTER_LINEAR;
|
||||
sci.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_LINEAR;
|
||||
break;
|
||||
default:
|
||||
SDL_SetError("Unknown scale mode: %d", scale_mode);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue