Fixed incorrect sampler when changing Metal draw state

(cherry picked from commit 0f9292a367)
This commit is contained in:
Sam Lantinga
2026-03-21 14:08:40 -07:00
parent c9271b2f18
commit b7e46361f5

View File

@@ -1369,6 +1369,7 @@ typedef struct
size_t constants_offset;
SDL_Texture *texture;
bool texture_palette;
SDL_PixelFormat texture_format;
SDL_ScaleMode texture_scale_mode;
SDL_TextureAddressMode texture_address_mode_u;
SDL_TextureAddressMode texture_address_mode_v;
@@ -1645,7 +1646,8 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, c
statecache->texture = texture;
}
if (cmd->data.draw.texture_scale_mode != statecache->texture_scale_mode ||
if (texture->format != statecache->texture_format ||
cmd->data.draw.texture_scale_mode != statecache->texture_scale_mode ||
cmd->data.draw.texture_address_mode_u != statecache->texture_address_mode_u ||
cmd->data.draw.texture_address_mode_v != statecache->texture_address_mode_v) {
id<MTLSamplerState> mtlsampler = GetSampler(data, texture->format, cmd->data.draw.texture_scale_mode, cmd->data.draw.texture_address_mode_u, cmd->data.draw.texture_address_mode_v);
@@ -1654,6 +1656,7 @@ static bool SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, c
}
[data.mtlcmdencoder setFragmentSamplerState:mtlsampler atIndex:0];
statecache->texture_format = texture->format;
statecache->texture_scale_mode = cmd->data.draw.texture_scale_mode;
statecache->texture_address_mode_u = cmd->data.draw.texture_address_mode_u;
statecache->texture_address_mode_v = cmd->data.draw.texture_address_mode_v;