Fixed pitch alignment when updating SDL_PIXELFORMAT_P010 textures
This commit is contained in:
parent
f2cd361e25
commit
2bedd7f02e
3 changed files with 22 additions and 6 deletions
|
@ -1549,8 +1549,13 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex
|
|||
stagingTextureDesc.Format == DXGI_FORMAT_P010) {
|
||||
/* Copy the UV plane as well */
|
||||
h = (h + 1) / 2;
|
||||
if (stagingTextureDesc.Format == DXGI_FORMAT_P010) {
|
||||
length = (length + 3) & ~3;
|
||||
pitch = (pitch + 3) & ~3;
|
||||
} else {
|
||||
length = (length + 1) & ~1;
|
||||
pitch = (pitch + 1) & ~1;
|
||||
}
|
||||
dst = (Uint8 *)textureMemory.pData + stagingTextureDesc.Height * textureMemory.RowPitch;
|
||||
for (row = 0; row < h; ++row) {
|
||||
SDL_memcpy(dst, src, length);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2779,7 +2779,13 @@ static int VULKAN_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture,
|
|||
// NV12/NV21 data
|
||||
else if (numPlanes == 2)
|
||||
{
|
||||
if (VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 1, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) & ~1, &textureData->mainImage.imageLayout) < 0) {
|
||||
if (texture->format == SDL_PIXELFORMAT_P010) {
|
||||
srcPitch = (srcPitch + 3) & ~3;
|
||||
} else {
|
||||
srcPitch = (srcPitch + 1) & ~1;
|
||||
}
|
||||
|
||||
if (VULKAN_UpdateTextureInternal(rendererData, textureData->mainImage.image, textureData->mainImage.format, 1, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, srcPitch, &textureData->mainImage.imageLayout) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue