Fixed pitch alignment when updating SDL_PIXELFORMAT_P010 textures
parent
f2cd361e25
commit
2bedd7f02e
|
@ -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;
|
||||
length = (length + 1) & ~1;
|
||||
pitch = (pitch + 1) & ~1;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ typedef struct
|
|||
float scRGB_output;
|
||||
float input_type;
|
||||
float color_scale;
|
||||
float unused_pad0;
|
||||
float unused_pad0;
|
||||
|
||||
float tonemap_method;
|
||||
float tonemap_factor1;
|
||||
|
@ -2779,8 +2779,14 @@ 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) {
|
||||
return -1;
|
||||
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;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue