Added some pixel format checks

In my limited testing, the texture is always in the R8G8B8A8 format, but, just incase, added a check for it and if it isn't then bail out.
This commit is contained in:
ScoochAside 2024-07-05 19:01:47 -04:00 committed by LibretroAdmin
parent d6773ced37
commit 22057bbb05
1 changed files with 17 additions and 9 deletions

View File

@ -3641,6 +3641,7 @@ static bool d3d11_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle)
uint8_t* bufferRow;
uint32_t y;
uint32_t x;
bool ret;
if(!d3d11)
return false;
@ -3678,6 +3679,8 @@ static bool d3d11_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle)
BackBufferData = (const uint8_t*)Map.pData;
/* Assuming format is DXGI_FORMAT_R8G8B8A8_UNORM */
if(StagingDesc.Format == DXGI_FORMAT_R8G8B8A8_UNORM)
{
for (y = 0; y < d3d11->vp.height; y++, BackBufferData += Map.RowPitch)
{
bufferRow = buffer + 3 * (d3d11->vp.height - y - 1) * d3d11->vp.width;
@ -3689,13 +3692,18 @@ static bool d3d11_gfx_read_viewport(void* data, uint8_t* buffer, bool is_idle)
bufferRow[3 * x + 0] = BackBufferData[4 * x + 2];
}
}
ret = true;
}
else
ret = false;
d3d11->context->lpVtbl->Unmap(d3d11->context, BackBufferStaging, 0);
/* Release the backbuffer staging. */
BackBufferStaging->lpVtbl->Release(BackBufferStaging);
BackBufferStagingTexture->lpVtbl->Release(BackBufferStagingTexture);
return true;
return ret;
}
static void d3d11_set_menu_texture_frame(