mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-03-23 22:15:05 +00:00
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
This commit is contained in:
parent
3bef4a5da6
commit
2cfc83eab7
|
@ -1271,6 +1271,7 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||||
RECT d3drect;
|
RECT d3drect;
|
||||||
D3DLOCKED_RECT locked;
|
D3DLOCKED_RECT locked;
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
|
int status;
|
||||||
|
|
||||||
if (data->currentRenderTarget) {
|
if (data->currentRenderTarget) {
|
||||||
backBuffer = data->currentRenderTarget;
|
backBuffer = data->currentRenderTarget;
|
||||||
|
@ -1305,7 +1306,7 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||||
return D3D_SetError("LockRect()", result);
|
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,
|
D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch,
|
||||||
format, pixels, pitch);
|
format, pixels, pitch);
|
||||||
|
|
||||||
|
@ -1313,7 +1314,7 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||||
|
|
||||||
IDirect3DSurface9_Release(surface);
|
IDirect3DSurface9_Release(surface);
|
||||||
|
|
||||||
return 0;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -2235,30 +2235,20 @@ D3D11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
|
||||||
/* Copy the data into the desired buffer, converting pixels to the
|
/* Copy the data into the desired buffer, converting pixels to the
|
||||||
* desired format at the same time:
|
* desired format at the same time:
|
||||||
*/
|
*/
|
||||||
if (SDL_ConvertPixels(
|
status = SDL_ConvertPixels(
|
||||||
rect->w, rect->h,
|
rect->w, rect->h,
|
||||||
D3D11_DXGIFormatToSDLPixelFormat(stagingTextureDesc.Format),
|
D3D11_DXGIFormatToSDLPixelFormat(stagingTextureDesc.Format),
|
||||||
textureMemory.pData,
|
textureMemory.pData,
|
||||||
textureMemory.RowPitch,
|
textureMemory.RowPitch,
|
||||||
format,
|
format,
|
||||||
pixels,
|
pixels,
|
||||||
pitch) != 0) {
|
pitch);
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Unmap the texture: */
|
/* Unmap the texture: */
|
||||||
ID3D11DeviceContext_Unmap(data->d3dContext,
|
ID3D11DeviceContext_Unmap(data->d3dContext,
|
||||||
(ID3D11Resource *)stagingTexture,
|
(ID3D11Resource *)stagingTexture,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
status = 0;
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
SAFE_RELEASE(backBuffer);
|
SAFE_RELEASE(backBuffer);
|
||||||
SAFE_RELEASE(stagingTexture);
|
SAFE_RELEASE(stagingTexture);
|
||||||
|
|
Loading…
Reference in a new issue