From c32cb5175588ae3b549a8defab350c65eac8ec44 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 Mar 2020 01:45:29 +0100 Subject: [PATCH] Cleanups --- gfx/drivers/d3d10.c | 16 +++++++++------- gfx/drivers/d3d11.c | 19 +++++++++++-------- gfx/drivers/d3d12.c | 44 +++++++++++++++++++++++--------------------- gfx/drivers/d3d8.c | 6 +++--- gfx/drivers/gl1.c | 6 ++++-- 5 files changed, 50 insertions(+), 41 deletions(-) diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index 85669318f4..1b8551e929 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -60,14 +60,14 @@ static struct string_list *d3d10_gpu_list = NULL; static IDXGIAdapter1 *d3d10_adapters[D3D10_MAX_GPU_COUNT] = {NULL}; static IDXGIAdapter1 *d3d10_current_adapter = NULL; -static void d3d10_clear_scissor(d3d10_video_t *d3d10, video_frame_info_t *video_info) +static void d3d10_clear_scissor(d3d10_video_t *d3d10, unsigned width, unsigned height) { D3D10_RECT scissor_rect; scissor_rect.left = 0; scissor_rect.top = 0; - scissor_rect.right = video_info->width; - scissor_rect.bottom = video_info->height; + scissor_rect.right = width; + scissor_rect.bottom = height; D3D10SetScissorRects(d3d10->device, 1, &scissor_rect); } @@ -1204,6 +1204,8 @@ static bool d3d10_gfx_frame( d3d10_texture_t* texture = NULL; d3d10_video_t * d3d10 = (d3d10_video_t*)data; D3D10Device context = d3d10->device; + unsigned video_width = video_info->width; + unsigned video_height = video_info->height; if (d3d10->resize_chain) { @@ -1218,8 +1220,8 @@ static bool d3d10_gfx_frame( Release(backBuffer); D3D10SetRenderTargets(d3d10->device, 1, &d3d10->renderTargetView, NULL); - d3d10->viewport.Width = video_info->width; - d3d10->viewport.Height = video_info->height; + d3d10->viewport.Width = video_width; + d3d10->viewport.Height = video_height; d3d10->ubo_values.OutputSize.width = d3d10->viewport.Width; d3d10->ubo_values.OutputSize.height = d3d10->viewport.Height; @@ -1227,7 +1229,7 @@ static bool d3d10_gfx_frame( d3d10->resize_chain = false; d3d10->resize_viewport = true; - video_driver_set_size(video_info->width, video_info->height); + video_driver_set_size(video_width, video_height); } #if 0 /* custom viewport doesn't call apply_state_changes, so we can't rely on this for now */ @@ -1427,7 +1429,7 @@ static bool d3d10_gfx_frame( D3D10ClearRenderTargetView(context, d3d10->renderTargetView, d3d10->clearcolor); D3D10SetViewports(context, 1, &d3d10->frame.viewport); - d3d10_clear_scissor(d3d10, video_info); + d3d10_clear_scissor(d3d10, video_width, video_height); D3D10Draw(context, 4, 0); diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 83ae566eba..f61767a0ee 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -73,14 +73,14 @@ static struct string_list *d3d11_gpu_list = NULL; static IDXGIAdapter1 *d3d11_adapters[D3D11_MAX_GPU_COUNT] = {NULL}; static IDXGIAdapter1 *d3d11_current_adapter = NULL; -static void d3d11_clear_scissor(d3d11_video_t *d3d11, video_frame_info_t *video_info) +static void d3d11_clear_scissor(d3d11_video_t *d3d11, unsigned video_width, unsigned video_height) { D3D11_RECT scissor_rect; scissor_rect.left = 0; scissor_rect.top = 0; - scissor_rect.right = video_info->width; - scissor_rect.bottom = video_info->height; + scissor_rect.right = video_width; + scissor_rect.bottom = video_height; D3D11SetScissorRects(d3d11->context, 1, &scissor_rect); } @@ -1285,6 +1285,8 @@ static bool d3d11_gfx_frame( d3d11_texture_t* texture = NULL; d3d11_video_t* d3d11 = (d3d11_video_t*)data; D3D11DeviceContext context = d3d11->context; + unsigned video_width = video_info->width; + unsigned video_height = video_info->height; if (d3d11->resize_chain) { @@ -1300,15 +1302,15 @@ static bool d3d11_gfx_frame( D3D11SetRenderTargets(context, 1, &d3d11->renderTargetView, NULL); - d3d11->viewport.Width = video_info->width; - d3d11->viewport.Height = video_info->height; + d3d11->viewport.Width = video_width; + d3d11->viewport.Height = video_height; d3d11->ubo_values.OutputSize.width = d3d11->viewport.Width; d3d11->ubo_values.OutputSize.height = d3d11->viewport.Height; d3d11->resize_chain = false; d3d11->resize_viewport = true; - video_driver_set_size(video_info->width, video_info->height); + video_driver_set_size(video_width, video_height); } #ifdef __WINRT__ @@ -1316,7 +1318,8 @@ static bool d3d11_gfx_frame( D3D11SetRenderTargets(context, 1, &d3d11->renderTargetView, NULL); #endif -#if 0 /* custom viewport doesn't call apply_state_changes, so we can't rely on this for now */ + /* custom viewport doesn't call apply_state_changes, so we can't rely on this for now */ +#if 0 if (d3d11->resize_viewport) #endif d3d11_update_viewport(d3d11, false); @@ -1500,7 +1503,7 @@ static bool d3d11_gfx_frame( D3D11ClearRenderTargetView(context, d3d11->renderTargetView, d3d11->clearcolor); D3D11SetViewports(context, 1, &d3d11->frame.viewport); - d3d11_clear_scissor(d3d11, video_info); + d3d11_clear_scissor(d3d11, video_width, video_height); D3D11Draw(context, 4, 0); diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index a2cb8a1e43..75e01ec5fa 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -1168,6 +1168,8 @@ static bool d3d12_gfx_frame( unsigned i; d3d12_texture_t* texture = NULL; d3d12_video_t* d3d12 = (d3d12_video_t*)data; + unsigned video_width = video_info->width; + unsigned video_height = video_info->height; d3d12_gfx_sync(d3d12); @@ -1187,17 +1189,17 @@ static bool d3d12_gfx_frame( 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.viewport.Width = video_width; + d3d12->chain.viewport.Height = video_height; + d3d12->chain.scissorRect.right = video_width; + d3d12->chain.scissorRect.bottom = video_height; d3d12->resize_chain = false; d3d12->resize_viewport = true; d3d12->ubo_values.OutputSize.width = d3d12->chain.viewport.Width; d3d12->ubo_values.OutputSize.height = d3d12->chain.viewport.Height; - video_driver_set_size(video_info->width, video_info->height); + video_driver_set_size(video_width, video_height); } D3D12ResetCommandAllocator(d3d12->queue.allocator); @@ -1225,7 +1227,7 @@ static bool d3d12_gfx_frame( if (d3d12->shader_preset->luts && d3d12->luts[0].dirty) for (i = 0; i < d3d12->shader_preset->luts; i++) d3d12_upload_texture(d3d12->queue.cmd, &d3d12->luts[i], - video_info->userdata); + d3d12); if (d3d12->frame.texture[0].desc.Width != width || d3d12->frame.texture[0].desc.Height != height) @@ -1276,7 +1278,7 @@ static bool d3d12_gfx_frame( d3d12_update_texture(width, height, pitch, d3d12->format, frame, &d3d12->frame.texture[0]); d3d12_upload_texture(d3d12->queue.cmd, &d3d12->frame.texture[0], - video_info->userdata); + d3d12); } D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->frame.vbo_view); @@ -1471,7 +1473,7 @@ static bool d3d12_gfx_frame( { if (d3d12->menu.texture.dirty) d3d12_upload_texture(d3d12->queue.cmd, &d3d12->menu.texture, - video_info->userdata); + d3d12); D3D12SetGraphicsRootConstantBufferView( d3d12->queue.cmd, ROOT_ID_UBO, d3d12->ubo_view.BufferLocation); @@ -1510,20 +1512,20 @@ static bool d3d12_gfx_frame( else #endif if (video_info->statistics_show) - { - struct font_params *osd_params = (struct font_params*) - &video_info->osd_stat_params; - - if (osd_params) { - D3D12SetPipelineState(d3d12->queue.cmd, d3d12->sprites.pipe_blend); - D3D12RSSetViewports(d3d12->queue.cmd, 1, &d3d12->chain.viewport); - D3D12RSSetScissorRects(d3d12->queue.cmd, 1, &d3d12->chain.scissorRect); - D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->sprites.vbo_view); - font_driver_render_msg(d3d12, video_info, video_info->stat_text, - (const struct font_params*)&video_info->osd_stat_params, NULL); + struct font_params *osd_params = (struct font_params*) + &video_info->osd_stat_params; + + if (osd_params) + { + D3D12SetPipelineState(d3d12->queue.cmd, d3d12->sprites.pipe_blend); + D3D12RSSetViewports(d3d12->queue.cmd, 1, &d3d12->chain.viewport); + D3D12RSSetScissorRects(d3d12->queue.cmd, 1, &d3d12->chain.scissorRect); + D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->sprites.vbo_view); + font_driver_render_msg(d3d12, video_info, video_info->stat_text, + (const struct font_params*)&video_info->osd_stat_params, NULL); + } } - } #ifdef HAVE_OVERLAY if (d3d12->overlays.enabled) { @@ -1551,7 +1553,7 @@ static bool d3d12_gfx_frame( if (d3d12->overlays.textures[i].dirty) d3d12_upload_texture(d3d12->queue.cmd, &d3d12->overlays.textures[i], - video_info->userdata); + d3d12); D3D12SetGraphicsRootDescriptorTable( d3d12->queue.cmd, ROOT_ID_TEXTURE_T, d3d12->overlays.textures[i].gpu_descriptor[0]); diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index 670480ea3e..dd7379bbfe 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -1705,10 +1705,10 @@ static void d3d8_video_texture_load_d3d( uintptr_t *id) { D3DLOCKED_RECT d3dlr; - unsigned usage = 0; + unsigned usage = 0; d3d8_video_t *d3d = (d3d8_video_t*)info->userdata; - struct texture_image *ti = (struct texture_image*)info->data; - LPDIRECT3DTEXTURE8 tex = (LPDIRECT3DTEXTURE8)d3d8_texture_new(d3d->dev, NULL, + struct texture_image *ti = (struct texture_image*)info->data; + LPDIRECT3DTEXTURE8 tex = (LPDIRECT3DTEXTURE8)d3d8_texture_new(d3d->dev, NULL, ti->width, ti->height, 0, usage, d3d8_get_argb8888_format(), D3DPOOL_MANAGED, 0, 0, 0, diff --git a/gfx/drivers/gl1.c b/gfx/drivers/gl1.c index 1ec99a16e7..a81baad15c 100644 --- a/gfx/drivers/gl1.c +++ b/gfx/drivers/gl1.c @@ -694,6 +694,8 @@ static bool gl1_gfx_frame(void *data, const void *frame, unsigned bits = gl1->video_bits; unsigned pot_width = 0; unsigned pot_height = 0; + unsigned video_width = video_info->width; + unsigned video_height = video_info->height; gl1_context_bind_hw_render(gl1, false); @@ -717,7 +719,7 @@ static bool gl1_gfx_frame(void *data, const void *frame, mode.width, mode.height); gl1_gfx_set_viewport(gl1, - video_info->width, video_info->height, false, true); + video_width, video_height, false, true); } glClearColor(0.0f, 0.0f, 0.0f, 1.0f); @@ -824,7 +826,7 @@ static bool gl1_gfx_frame(void *data, const void *frame, if (gl1->menu_texture_full_screen) { - glViewport(0, 0, video_info->width, video_info->height); + glViewport(0, 0, video_width, video_height); draw_tex(gl1, pot_width, pot_height, width, height, gl1->menu_tex, frame_to_copy); glViewport(gl1->vp.x, gl1->vp.y, gl1->vp.width, gl1->vp.height); }