sync D3D_RenderReadPixels with D3D11_RenderReadPixels - use the result of SDL_ConvertPixels to propagate error - get rid of the verbose error message of D3D11_RenderReadPixels in case SDL_ConvertPixels failed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index ec986b3..f43e3ff 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -1271,6 +1271,7 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
RECT d3drect;
D3DLOCKED_RECT locked;
HRESULT result;
+ int status;
if (data->currentRenderTarget) {
backBuffer = data->currentRenderTarget;
@@ -1305,7 +1306,7 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
return D3D_SetError("LockRect()", result);
}
- SDL_ConvertPixels(rect->w, rect->h,
+ status = SDL_ConvertPixels(rect->w, rect->h,
D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch,
format, pixels, pitch);
@@ -1313,7 +1314,7 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
IDirect3DSurface9_Release(surface);
- return 0;
+ return status;
}
static void
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index dcab009..2f359cf 100644
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -2235,30 +2235,20 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
/* Copy the data into the desired buffer, converting pixels to the
* desired format at the same time:
*/
- if (SDL_ConvertPixels(
+ status = SDL_ConvertPixels(
rect->w, rect->h,
D3D11_DXGIFormatToSDLPixelFormat(stagingTextureDesc.Format),
textureMemory.pData,
textureMemory.RowPitch,
format,
pixels,
- pitch) != 0) {
- /* When SDL_ConvertPixels fails, it'll have already set the format.
- * Get the error message, and attach some extra data to it.
- */
- char errorMessage[1024];
- SDL_snprintf(errorMessage, sizeof(errorMessage), "%s, Convert Pixels failed: %s", __FUNCTION__, SDL_GetError());
- SDL_SetError("%s", errorMessage);
- goto done;
- }
+ pitch);
/* Unmap the texture: */
ID3D11DeviceContext_Unmap(data->d3dContext,
(ID3D11Resource *)stagingTexture,
0);
- status = 0;
-
done:
SAFE_RELEASE(backBuffer);
SAFE_RELEASE(stagingTexture);