mirror of
https://github.com/libretro/RetroArch
synced 2025-02-07 03:40:24 +00:00
Merge pull request #6163 from aliaspider/master
(d3d10/11/12) resize swapchain correctly when the window's size changes.
This commit is contained in:
commit
cb63f20c8c
@ -1123,6 +1123,7 @@ typedef struct
|
||||
DXGI_FORMAT format;
|
||||
|
||||
bool vsync;
|
||||
bool need_resize;
|
||||
} d3d10_video_t;
|
||||
|
||||
void d3d10_init_texture(D3D10Device device, d3d10_texture_t* texture);
|
||||
|
@ -2501,6 +2501,7 @@ typedef struct
|
||||
DXGI_FORMAT format;
|
||||
|
||||
bool vsync;
|
||||
bool need_resize;
|
||||
} d3d11_video_t;
|
||||
|
||||
void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture);
|
||||
|
@ -1172,6 +1172,7 @@ typedef struct
|
||||
DXGI_FORMAT format;
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE sampler_linear;
|
||||
D3D12_GPU_DESCRIPTOR_HANDLE sampler_nearest;
|
||||
bool need_resize;
|
||||
|
||||
#ifdef DEBUG
|
||||
D3D12Debug debugController;
|
||||
|
@ -217,6 +217,26 @@ static bool d3d10_gfx_frame(
|
||||
(void)msg;
|
||||
|
||||
d3d10_video_t* d3d10 = (d3d10_video_t*)data;
|
||||
|
||||
if (d3d10->need_resize)
|
||||
{
|
||||
D3D10Texture2D backBuffer;
|
||||
D3D10_VIEWPORT vp = { 0, 0, video_info->width, video_info->height, 0.0f, 1.0f };
|
||||
|
||||
Release(d3d10->renderTargetView);
|
||||
DXGIResizeBuffers(d3d10->swapChain, 0, 0, 0, 0, 0);
|
||||
|
||||
DXGIGetSwapChainBufferD3D10(d3d10->swapChain, 0, &backBuffer);
|
||||
D3D10CreateTexture2DRenderTargetView(d3d10->device, backBuffer, NULL, &d3d10->renderTargetView);
|
||||
Release(backBuffer);
|
||||
|
||||
D3D10SetRenderTargets(d3d10->device, 1, &d3d10->renderTargetView, NULL);
|
||||
D3D10SetViewports(d3d10->device, 1, &vp);
|
||||
|
||||
d3d10->need_resize = false;
|
||||
}
|
||||
|
||||
|
||||
PERF_START();
|
||||
D3D10ClearRenderTargetView(d3d10->device, d3d10->renderTargetView, d3d10->clearcolor);
|
||||
|
||||
@ -286,7 +306,9 @@ static bool d3d10_gfx_alive(void* data)
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
|
||||
win32_check_window(&quit, &resize, &width, &height);
|
||||
d3d10_video_t* d3d10 = (d3d10_video_t*)data;
|
||||
|
||||
win32_check_window(&quit, &d3d10->need_resize, &width, &height);
|
||||
|
||||
if (width != 0 && height != 0)
|
||||
video_driver_set_size(&width, &height);
|
||||
|
@ -230,6 +230,24 @@ static bool d3d11_gfx_frame(
|
||||
{
|
||||
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
|
||||
|
||||
if (d3d11->need_resize)
|
||||
{
|
||||
D3D11Texture2D backBuffer;
|
||||
D3D11_VIEWPORT vp = { 0, 0, video_info->width, video_info->height, 0.0f, 1.0f };
|
||||
|
||||
Release(d3d11->renderTargetView);
|
||||
DXGIResizeBuffers(d3d11->swapChain, 0, 0, 0, 0, 0);
|
||||
|
||||
DXGIGetSwapChainBufferD3D11(d3d11->swapChain, 0, &backBuffer);
|
||||
D3D11CreateTexture2DRenderTargetView(d3d11->device, backBuffer, NULL, &d3d11->renderTargetView);
|
||||
Release(backBuffer);
|
||||
|
||||
D3D11SetRenderTargets(d3d11->ctx, 1, &d3d11->renderTargetView, NULL);
|
||||
D3D11SetViewports(d3d11->ctx, 1, &vp);
|
||||
|
||||
d3d11->need_resize = false;
|
||||
}
|
||||
|
||||
PERF_START();
|
||||
D3D11ClearRenderTargetView(d3d11->ctx, d3d11->renderTargetView, d3d11->clearcolor);
|
||||
|
||||
@ -303,9 +321,9 @@ static bool d3d11_gfx_alive(void* data)
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
|
||||
(void)data;
|
||||
d3d11_video_t* d3d11 = (d3d11_video_t*)data;
|
||||
|
||||
win32_check_window(&quit, &resize, &width, &height);
|
||||
win32_check_window(&quit, &d3d11->need_resize, &width, &height);
|
||||
|
||||
if (width != 0 && height != 0)
|
||||
video_driver_set_size(&width, &height);
|
||||
|
@ -103,7 +103,32 @@ static bool d3d12_gfx_frame(
|
||||
{
|
||||
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
|
||||
|
||||
(void)msg;
|
||||
if (d3d12->need_resize)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (int i = 0; i < countof(d3d12->chain.renderTargets); i++)
|
||||
Release(d3d12->chain.renderTargets[i]);
|
||||
|
||||
DXGIResizeBuffers(d3d12->chain.handle, 0, 0, 0, 0, 0);
|
||||
|
||||
for (int i = 0; i < countof(d3d12->chain.renderTargets); i++)
|
||||
{
|
||||
DXGIGetSwapChainBuffer(d3d12->chain.handle, i, &d3d12->chain.renderTargets[i]);
|
||||
D3D12CreateRenderTargetView(
|
||||
d3d12->device, d3d12->chain.renderTargets[i], NULL, d3d12->chain.desc_handles[i]);
|
||||
}
|
||||
|
||||
d3d12->chain.viewport.Width = video_info->width;
|
||||
d3d12->chain.viewport.Height = video_info->height;
|
||||
d3d12->chain.scissorRect.right = video_info->width;
|
||||
d3d12->chain.scissorRect.bottom = video_info->height;
|
||||
d3d12->chain.frame_index = DXGIGetCurrentBackBufferIndex(d3d12->chain.handle);
|
||||
|
||||
d3d12->need_resize = false;
|
||||
}
|
||||
|
||||
|
||||
PERF_START();
|
||||
D3D12ResetCommandAllocator(d3d12->queue.allocator);
|
||||
|
||||
@ -209,7 +234,9 @@ static bool d3d12_gfx_alive(void* data)
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
|
||||
win32_check_window(&quit, &resize, &width, &height);
|
||||
d3d12_video_t* d3d12 = (d3d12_video_t*)data;
|
||||
|
||||
win32_check_window(&quit, &d3d12->need_resize, &width, &height);
|
||||
|
||||
if (width != 0 && height != 0)
|
||||
video_driver_set_size(&width, &height);
|
||||
|
Loading…
x
Reference in New Issue
Block a user