Fixed pitch alignment when updating SDL_PIXELFORMAT_P010 textures

This commit is contained in:
Sam Lantinga
2024-03-01 16:22:10 -08:00
parent f2cd361e25
commit 2bedd7f02e
3 changed files with 22 additions and 6 deletions

View File

@@ -1975,7 +1975,12 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
/* Skip to the correct offset into the next texture */
srcPixels = (const void *)((const Uint8 *)srcPixels + rect->h * srcPitch);
if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 1, rect->x, rect->y, (rect->w + 1) & ~1, (rect->h + 1) & ~1, srcPixels, (srcPitch + 1) & ~1, &textureData->mainResourceState) < 0) {
if (texture->format == SDL_PIXELFORMAT_P010) {
srcPitch = (srcPitch + 3) & ~3;
} else {
srcPitch = (srcPitch + 1) & ~1;
}
if (D3D12_UpdateTextureInternal(rendererData, textureData->mainTexture, 1, rect->x, rect->y, (rect->w + 1) & ~1, (rect->h + 1) & ~1, srcPixels, srcPitch, &textureData->mainResourceState) < 0) {
return -1;
}
}