From e1f33342506496a14e24ae0834d3e7f3c128b798 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 10 Apr 2023 18:36:54 +0300 Subject: [PATCH] Return HDR screenshot depth --- od-win32/avioutput.cpp | 6 +++--- od-win32/direct3d.h | 2 +- od-win32/direct3d11.cpp | 3 ++- od-win32/screenshot.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/od-win32/avioutput.cpp b/od-win32/avioutput.cpp index 2f71e14c..add6a748 100644 --- a/od-win32/avioutput.cpp +++ b/od-win32/avioutput.cpp @@ -962,10 +962,10 @@ static void AVIOuput_WAVWriteAudio(uae_u8 *sndbuffer, int sndbufsize) static int getFromRenderTarget11(struct avientry *avie, bool renderTarget) { int ok = 0; - int w, h, pitch, bits = 32; + int w, h, pitch, bits = 32, d; void *data; - bool got = D3D11_capture(aviout_monid, &data, &w, &h, &pitch, renderTarget); + bool got = D3D11_capture(aviout_monid, &data, &w, &h, &d, &pitch, renderTarget); if (got) { int dpitch = ((aviout_width_out * avioutput_bits + 31) & ~31) / 8; for (int y = 0; y < h && y < aviout_height_out; y++) { @@ -984,7 +984,7 @@ static int getFromRenderTarget11(struct avientry *avie, bool renderTarget) } } } - D3D11_capture(aviout_monid, NULL, NULL, NULL, NULL, renderTarget); + D3D11_capture(aviout_monid, NULL, NULL, NULL, NULL, NULL, renderTarget); ok = 1; } return ok; diff --git a/od-win32/direct3d.h b/od-win32/direct3d.h index 05bbfcce..7f310713 100644 --- a/od-win32/direct3d.h +++ b/od-win32/direct3d.h @@ -38,7 +38,7 @@ extern bool(*D3D_extoverlay)(struct extoverlay*, int); extern void(*D3D_paint)(void); extern LPDIRECT3DSURFACE9 D3D_capture(int, int*,int*,int*,bool); -extern bool D3D11_capture(int, void**,int*, int*,int*,bool); +extern bool D3D11_capture(int, void**,int*, int*, int*,int*,bool); void D3D_getpixelformat(int depth, int *rb, int *gb, int *bb, int *rs, int *gs, int *bs, int *ab, int *as, int *a); diff --git a/od-win32/direct3d11.cpp b/od-win32/direct3d11.cpp index a5f7e917..2a0404eb 100644 --- a/od-win32/direct3d11.cpp +++ b/od-win32/direct3d11.cpp @@ -5198,7 +5198,7 @@ static HDC xD3D_getDC(int monid, HDC hdc) } } -bool D3D11_capture(int monid, void **data, int *w, int *h, int *pitch, bool rendertarget) +bool D3D11_capture(int monid, void **data, int *w, int *h, int *d, int *pitch, bool rendertarget) { struct d3d11struct *d3d = &d3d11data[monid]; HRESULT hr; @@ -5236,6 +5236,7 @@ bool D3D11_capture(int monid, void **data, int *w, int *h, int *pitch, bool rend *pitch = map.RowPitch; *w = desc.Width; *h = desc.Height; + *d = d3d->hdr ? 36 : 24; return true; } else { write_log(_T("Screenshot RenderTargetView->GetResource() failed\n")); diff --git a/od-win32/screenshot.cpp b/od-win32/screenshot.cpp index c05fb7d9..c7571ae4 100644 --- a/od-win32/screenshot.cpp +++ b/od-win32/screenshot.cpp @@ -427,9 +427,9 @@ donormal: height = state->Height; } if (D3D_isenabled(0) == 2) { - int w, h, pitch, bits = 32; + int w, h, pitch, bits = 32, d; void *data; - bool got = D3D11_capture(monid, &data, &w, &h, &pitch, renderTarget); + bool got = D3D11_capture(monid, &data, &w, &h, &d, &pitch, renderTarget); int dpitch = (((width * depth + 31) & ~31) / 8); lpvBits = xmalloc(uae_u8, dpitch * height); @@ -447,7 +447,7 @@ donormal: bi->bmiHeader.biClrUsed = 0; bi->bmiHeader.biClrImportant = 0; - if (got && lpvBits) { + if (got && lpvBits && d <= 32) { for (int y = 0; y < h && y < height; y++) { uae_u8 *d = (uae_u8*)lpvBits + (height - y - 1) * dpitch; uae_u32 *s = (uae_u32*)((uae_u8*)data + y * pitch); @@ -466,7 +466,7 @@ donormal: } } if (got) - D3D11_capture(monid, NULL, NULL, NULL, NULL, renderTarget); + D3D11_capture(monid, NULL, NULL, NULL, NULL, NULL, renderTarget); d3dcaptured = true; } else if (D3D_isenabled(0) == 1) { -- 2.47.3