From 490fb759054c2a289b2f103db94b30007524f7ab Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sun, 8 Jan 2023 18:31:04 +0100 Subject: [PATCH] (drivers_display) Cleanups --- gfx/drivers_display/gfx_display_ctr.c | 1 - gfx/drivers_display/gfx_display_d3d10.c | 1 - gfx/drivers_display/gfx_display_d3d11.c | 17 +++--- gfx/drivers_display/gfx_display_d3d12.c | 44 ++++++++------- gfx/drivers_display/gfx_display_d3d8.c | 7 ++- gfx/drivers_display/gfx_display_d3d9cg.c | 7 ++- gfx/drivers_display/gfx_display_d3d9hlsl.c | 13 ++--- gfx/drivers_display/gfx_display_gdi.c | 9 +--- gfx/drivers_display/gfx_display_gl1.c | 15 +++--- gfx/drivers_display/gfx_display_gl2.c | 13 +++-- gfx/drivers_display/gfx_display_gl3.c | 12 ++--- gfx/drivers_display/gfx_display_metal.m | 63 ++++++++++------------ gfx/drivers_display/gfx_display_rsx.c | 28 +++++----- gfx/drivers_display/gfx_display_switch.c | 3 -- gfx/drivers_display/gfx_display_vita2d.c | 7 ++- gfx/drivers_display/gfx_display_vulkan.c | 7 ++- gfx/drivers_display/gfx_display_wiiu.c | 55 ++++++++++++------- 17 files changed, 151 insertions(+), 151 deletions(-) diff --git a/gfx/drivers_display/gfx_display_ctr.c b/gfx/drivers_display/gfx_display_ctr.c index 75088c489b..12a22d4073 100644 --- a/gfx/drivers_display/gfx_display_ctr.c +++ b/gfx/drivers_display/gfx_display_ctr.c @@ -21,7 +21,6 @@ #include "../gfx_display.h" -#include "../../retroarch.h" #include "../common/ctr_common.h" #include "../drivers/ctr_gu.h" #include "../../ctr/gpu_old.h" diff --git a/gfx/drivers_display/gfx_display_d3d10.c b/gfx/drivers_display/gfx_display_d3d10.c index 6c64896d9d..f92797ffb0 100644 --- a/gfx/drivers_display/gfx_display_d3d10.c +++ b/gfx/drivers_display/gfx_display_d3d10.c @@ -24,7 +24,6 @@ #include "../gfx_display.h" -#include "../../retroarch.h" #include "../common/d3d10_common.h" static void gfx_display_d3d10_blend_begin(void *data) diff --git a/gfx/drivers_display/gfx_display_d3d11.c b/gfx/drivers_display/gfx_display_d3d11.c index a04caeb073..229dfef8b0 100644 --- a/gfx/drivers_display/gfx_display_d3d11.c +++ b/gfx/drivers_display/gfx_display_d3d11.c @@ -23,7 +23,6 @@ #include "../gfx_display.h" -#include "../../retroarch.h" #include "../common/d3d11_common.h" static void gfx_display_d3d11_blend_begin(void *data) @@ -225,7 +224,8 @@ static void gfx_display_d3d11_draw_pipeline(gfx_display_ctx_draw_t *draw, vertex_data.pSysMem = ca->coords.vertex; vertex_data.SysMemPitch = 0; vertex_data.SysMemSlicePitch = 0; - d3d11->device->lpVtbl->CreateBuffer(d3d11->device, &desc, &vertex_data, + d3d11->device->lpVtbl->CreateBuffer( + d3d11->device, &desc, &vertex_data, &d3d11->menu_pipeline_vbo); } } @@ -237,7 +237,9 @@ static void gfx_display_d3d11_draw_pipeline(gfx_display_ctx_draw_t *draw, &d3d11->menu_pipeline_vbo, &stride, &offset); } draw->coords->vertices = ca->coords.vertices; - d3d11->context->lpVtbl->OMSetBlendState(d3d11->context, d3d11->blend_pipeline, NULL, D3D11_DEFAULT_SAMPLE_MASK); + d3d11->context->lpVtbl->OMSetBlendState( + d3d11->context, d3d11->blend_pipeline, + NULL, D3D11_DEFAULT_SAMPLE_MASK); break; } @@ -258,16 +260,19 @@ static void gfx_display_d3d11_draw_pipeline(gfx_display_ctx_draw_t *draw, return; } - d3d11->context->lpVtbl->IASetPrimitiveTopology(d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + d3d11->context->lpVtbl->IASetPrimitiveTopology( + d3d11->context, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); d3d11->ubo_values.time += 0.01f; { D3D11_MAPPED_SUBRESOURCE mapped_ubo; d3d11->context->lpVtbl->Map( - d3d11->context, (D3D11Resource)d3d11->ubo, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_ubo); + d3d11->context, (D3D11Resource)d3d11->ubo, + 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped_ubo); *(d3d11_uniform_t*)mapped_ubo.pData = d3d11->ubo_values; - d3d11->context->lpVtbl->Unmap(d3d11->context, (D3D11Resource)d3d11->ubo, 0); + d3d11->context->lpVtbl->Unmap(d3d11->context, + (D3D11Resource)d3d11->ubo, 0); } } diff --git a/gfx/drivers_display/gfx_display_d3d12.c b/gfx/drivers_display/gfx_display_d3d12.c index eecdd89b34..9f23ae2b80 100644 --- a/gfx/drivers_display/gfx_display_d3d12.c +++ b/gfx/drivers_display/gfx_display_d3d12.c @@ -23,7 +23,6 @@ #include "../gfx_display.h" -#include "../../retroarch.h" #include "../common/d3d12_common.h" static void gfx_display_d3d12_blend_begin(void *data) @@ -88,11 +87,12 @@ static void gfx_display_d3d12_draw(gfx_display_ctx_draw_t *draw, if (vertex_count == 1) { - sprite->pos.x = draw->x / (float)d3d12->chain.viewport.Width; - sprite->pos.y = (d3d12->chain.viewport.Height - draw->y - draw->height) / - (float)d3d12->chain.viewport.Height; - sprite->pos.w = draw->width / (float)d3d12->chain.viewport.Width; - sprite->pos.h = draw->height / (float)d3d12->chain.viewport.Height; + sprite->pos.x = draw->x / (float)d3d12->chain.viewport.Width; + sprite->pos.y = + (d3d12->chain.viewport.Height - draw->y - draw->height) / + (float)d3d12->chain.viewport.Height; + sprite->pos.w = draw->width / (float)d3d12->chain.viewport.Width; + sprite->pos.h = draw->height / (float)d3d12->chain.viewport.Height; sprite->coords.u = 0.0f; sprite->coords.v = 0.0f; @@ -104,18 +104,18 @@ static void gfx_display_d3d12_draw(gfx_display_ctx_draw_t *draw, else sprite->params.scaling = 1.0f; - sprite->params.rotation = draw->rotation; + sprite->params.rotation = draw->rotation; - sprite->colors[3] = DXGI_COLOR_RGBA( + sprite->colors[3] = DXGI_COLOR_RGBA( 0xFF * draw->coords->color[0], 0xFF * draw->coords->color[1], 0xFF * draw->coords->color[2], 0xFF * draw->coords->color[3]); - sprite->colors[2] = DXGI_COLOR_RGBA( + sprite->colors[2] = DXGI_COLOR_RGBA( 0xFF * draw->coords->color[4], 0xFF * draw->coords->color[5], 0xFF * draw->coords->color[6], 0xFF * draw->coords->color[7]); - sprite->colors[1] = DXGI_COLOR_RGBA( + sprite->colors[1] = DXGI_COLOR_RGBA( 0xFF * draw->coords->color[8], 0xFF * draw->coords->color[9], 0xFF * draw->coords->color[10], 0xFF * draw->coords->color[11]); - sprite->colors[0] = DXGI_COLOR_RGBA( + sprite->colors[0] = DXGI_COLOR_RGBA( 0xFF * draw->coords->color[12], 0xFF * draw->coords->color[13], 0xFF * draw->coords->color[14], 0xFF * draw->coords->color[15]); } @@ -201,8 +201,8 @@ static void gfx_display_d3d12_draw_pipeline(gfx_display_ctx_draw_t *draw, D3D12_RANGE read_range; void* vertex_data_begin; - d3d12->menu_pipeline_vbo_view.StrideInBytes = 2 * sizeof(float); - d3d12->menu_pipeline_vbo_view.SizeInBytes = + d3d12->menu_pipeline_vbo_view.StrideInBytes = 2 * sizeof(float); + d3d12->menu_pipeline_vbo_view.SizeInBytes = ca->coords.vertices * d3d12->menu_pipeline_vbo_view.StrideInBytes; d3d12->menu_pipeline_vbo_view.BufferLocation = d3d12_create_buffer( d3d12->device, d3d12->menu_pipeline_vbo_view.SizeInBytes, @@ -210,11 +210,14 @@ static void gfx_display_d3d12_draw_pipeline(gfx_display_ctx_draw_t *draw, read_range.Begin = 0; read_range.End = 0; - D3D12Map(d3d12->menu_pipeline_vbo, 0, &read_range, &vertex_data_begin); - memcpy(vertex_data_begin, ca->coords.vertex, d3d12->menu_pipeline_vbo_view.SizeInBytes); + D3D12Map(d3d12->menu_pipeline_vbo, 0, + &read_range, &vertex_data_begin); + memcpy(vertex_data_begin, ca->coords.vertex, + d3d12->menu_pipeline_vbo_view.SizeInBytes); D3D12Unmap(d3d12->menu_pipeline_vbo, 0, NULL); } - D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->menu_pipeline_vbo_view); + D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, + &d3d12->menu_pipeline_vbo_view); draw->coords->vertices = ca->coords.vertices; break; } @@ -223,13 +226,15 @@ static void gfx_display_d3d12_draw_pipeline(gfx_display_ctx_draw_t *draw, case VIDEO_SHADER_MENU_4: case VIDEO_SHADER_MENU_5: case VIDEO_SHADER_MENU_6: - D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, &d3d12->frame.vbo_view); + D3D12IASetVertexBuffers(d3d12->queue.cmd, 0, 1, + &d3d12->frame.vbo_view); draw->coords->vertices = 4; break; default: return; } - D3D12IASetPrimitiveTopology(d3d12->queue.cmd, D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); + D3D12IASetPrimitiveTopology(d3d12->queue.cmd, + D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP); d3d12->ubo_values.time += 0.01f; @@ -244,7 +249,8 @@ static void gfx_display_d3d12_draw_pipeline(gfx_display_ctx_draw_t *draw, D3D12Unmap(d3d12->ubo, 0, NULL); } D3D12SetGraphicsRootConstantBufferView( - d3d12->queue.cmd, ROOT_ID_UBO, d3d12->ubo_view.BufferLocation); + d3d12->queue.cmd, ROOT_ID_UBO, + d3d12->ubo_view.BufferLocation); } void gfx_display_d3d12_scissor_begin(void *data, diff --git a/gfx/drivers_display/gfx_display_d3d8.c b/gfx/drivers_display/gfx_display_d3d8.c index 30c72899fa..40722cd308 100644 --- a/gfx/drivers_display/gfx_display_d3d8.c +++ b/gfx/drivers_display/gfx_display_d3d8.c @@ -25,18 +25,17 @@ #include "../gfx_display.h" -#include "../../retroarch.h" #include "../common/d3d_common.h" #include "../common/d3d8_common.h" -static const float d3d8_vertexes[] = { +static const float d3d8_vertexes[8] = { 0, 0, 1, 0, 0, 1, 1, 1 }; -static const float d3d8_tex_coords[] = { +static const float d3d8_tex_coords[8] = { 0, 1, 1, 1, 0, 0, @@ -55,7 +54,7 @@ static const float *gfx_display_d3d8_get_default_tex_coords(void) static void *gfx_display_d3d8_get_default_mvp(void *data) { - static float id[] = { 1.0f, 0.0f, 0.0f, 0.0f, + static float id[16] = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f diff --git a/gfx/drivers_display/gfx_display_d3d9cg.c b/gfx/drivers_display/gfx_display_d3d9cg.c index 3ed178cf9f..e9c42e5634 100644 --- a/gfx/drivers_display/gfx_display_d3d9cg.c +++ b/gfx/drivers_display/gfx_display_d3d9cg.c @@ -25,18 +25,17 @@ #include "../gfx_display.h" -#include "../../retroarch.h" #include "../common/d3d_common.h" #include "../common/d3d9_common.h" -static const float d3d9_cg_vertexes[] = { +static const float d3d9_cg_vertexes[8] = { 0, 0, 1, 0, 0, 1, 1, 1 }; -static const float d3d9_cg_tex_coords[] = { +static const float d3d9_cg_tex_coords[8] = { 0, 1, 1, 1, 0, 0, @@ -55,7 +54,7 @@ static const float *gfx_display_d3d9_cg_get_default_tex_coords(void) static void *gfx_display_d3d9_cg_get_default_mvp(void *data) { - static float id[] = { 1.0f, 0.0f, 0.0f, 0.0f, + static float id[16] = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f diff --git a/gfx/drivers_display/gfx_display_d3d9hlsl.c b/gfx/drivers_display/gfx_display_d3d9hlsl.c index ebbb86c517..fc01daac85 100644 --- a/gfx/drivers_display/gfx_display_d3d9hlsl.c +++ b/gfx/drivers_display/gfx_display_d3d9hlsl.c @@ -25,18 +25,17 @@ #include "../gfx_display.h" -#include "../../retroarch.h" #include "../common/d3d_common.h" #include "../common/d3d9_common.h" -static const float d3d9_hlsl_vertexes[] = { +static const float d3d9_hlsl_vertexes[8] = { 0, 0, 1, 0, 0, 1, 1, 1 }; -static const float d3d9_hlsl_tex_coords[] = { +static const float d3d9_hlsl_tex_coords[8] = { 0, 1, 1, 1, 0, 0, @@ -55,7 +54,7 @@ static const float *gfx_display_d3d9_hlsl_get_default_tex_coords(void) static void *gfx_display_d3d9_hlsl_get_default_mvp(void *data) { - static float id[] = { 1.0f, 0.0f, 0.0f, 0.0f, + static float id[16] = { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f @@ -96,10 +95,8 @@ static void gfx_display_d3d9_hlsl_blend_end(void *data) { d3d9_video_t *d3d = (d3d9_video_t*)data; - if (!d3d) - return; - - IDirect3DDevice9_SetRenderState(d3d->dev, D3DRS_ALPHABLENDENABLE, false); + if (d3d) + IDirect3DDevice9_SetRenderState(d3d->dev, D3DRS_ALPHABLENDENABLE, false); } static void gfx_display_d3d9_bind_texture(gfx_display_ctx_draw_t *draw, diff --git a/gfx/drivers_display/gfx_display_gdi.c b/gfx/drivers_display/gfx_display_gdi.c index 3903821727..fd2abd21a5 100644 --- a/gfx/drivers_display/gfx_display_gdi.c +++ b/gfx/drivers_display/gfx_display_gdi.c @@ -14,16 +14,11 @@ * If not, see . */ -#include - +#if 0 #include -#include +#endif #include -#include "../../config.def.h" -#include "../../retroarch.h" -#include "../../verbosity.h" - #include "../gfx_display.h" #if defined(_WIN32) && !defined(_XBOX) diff --git a/gfx/drivers_display/gfx_display_gl1.c b/gfx/drivers_display/gfx_display_gl1.c index 22be7fdfcd..de83971da9 100644 --- a/gfx/drivers_display/gfx_display_gl1.c +++ b/gfx/drivers_display/gfx_display_gl1.c @@ -20,19 +20,18 @@ #include "../../config.h" #endif -#include "../../retroarch.h" -#include "../common/gl1_common.h" - #include "../gfx_display.h" -static const GLfloat gl1_menu_vertexes[] = { +#include "../common/gl1_common.h" + +static const GLfloat gl1_menu_vertexes[8] = { 0, 0, 1, 0, 0, 1, 1, 1 }; -static const GLfloat gl1_menu_tex_coords[] = { +static const GLfloat gl1_menu_tex_coords[8] = { 0, 1, 1, 1, 0, 0, @@ -139,8 +138,10 @@ static void gfx_display_gl1_draw(gfx_display_ctx_draw_t *draw, vertices3 = (float*)malloc(sizeof(float) * 3 * draw->coords->vertices); for (i = 0; i < draw->coords->vertices; i++) { - memcpy(&vertices3[i*3], &draw->coords->vertex[i*2], sizeof(float) * 2); - vertices3[i*3+2] = 0.0f; + memcpy(&vertices3[i * 3], + &draw->coords->vertex[i * 2], + sizeof(float) * 2); + vertices3[i * 3 + 2] = 0.0f; } glVertexPointer(3, GL_FLOAT, 0, vertices3); } diff --git a/gfx/drivers_display/gfx_display_gl2.c b/gfx/drivers_display/gfx_display_gl2.c index 6d0493bbd6..1564683ad3 100644 --- a/gfx/drivers_display/gfx_display_gl2.c +++ b/gfx/drivers_display/gfx_display_gl2.c @@ -19,11 +19,10 @@ #include "../../config.h" #endif -#include "../../retroarch.h" -#include "../common/gl2_common.h" - #include "../gfx_display.h" +#include "../common/gl2_common.h" + #if defined(__arm__) || defined(__aarch64__) static int scx0, scx1, scy0, scy1; @@ -67,14 +66,14 @@ static bool scissor_is_outside_rectangle( #define MALI_BUG #endif -static const GLfloat gl2_vertexes[] = { +static const GLfloat gl2_vertexes[8] = { 0, 0, 1, 0, 0, 1, 1, 1 }; -static const GLfloat gl2_tex_coords[] = { +static const GLfloat gl2_tex_coords[8] = { 0, 1, 1, 1, 0, 0, @@ -186,8 +185,8 @@ gfx_display_gl2_discard_draw_rectangle(gfx_display_ctx_draw_t *draw, /* Have to update scissor_set_rectangle() if the * video dimensions change */ - if ((width != last_video_width) || - (height != last_video_height)) + if ( (width != last_video_width) + || (height != last_video_height)) { scissor_set_rectangle(0, width - 1, diff --git a/gfx/drivers_display/gfx_display_gl3.c b/gfx/drivers_display/gfx_display_gl3.c index 9cb98f9bbb..92c9cc62f8 100644 --- a/gfx/drivers_display/gfx_display_gl3.c +++ b/gfx/drivers_display/gfx_display_gl3.c @@ -20,27 +20,25 @@ #include "../../config.h" #endif -#include "../common/gl3_common.h" - #include "../gfx_display.h" -#include "../../retroarch.h" +#include "../common/gl3_common.h" -static const float gl3_vertexes[] = { +static const float gl3_vertexes[8] = { 0, 0, 1, 0, 0, 1, 1, 1 }; -static const float gl3_tex_coords[] = { +static const float gl3_tex_coords[8] = { 0, 1, 1, 1, 0, 0, 1, 0 }; -static const float gl3_colors[] = { +static const float gl3_colors[16] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, @@ -148,7 +146,7 @@ static void gfx_display_gl3_draw(gfx_display_ctx_draw_t *draw, const float *tex_coord = NULL; const float *color = NULL; GLuint texture = 0; - gl3_t *gl = (gl3_t*)data; + gl3_t *gl = (gl3_t*)data; const struct gl3_buffer_locations *loc = NULL; diff --git a/gfx/drivers_display/gfx_display_metal.m b/gfx/drivers_display/gfx_display_metal.m index 9a790d4e7c..de73ab6415 100644 --- a/gfx/drivers_display/gfx_display_metal.m +++ b/gfx/drivers_display/gfx_display_metal.m @@ -21,7 +21,6 @@ #include "../gfx_display.h" -#include "../../retroarch.h" #import "../common/metal_common.h" static const float *gfx_display_metal_get_default_vertices(void) @@ -46,19 +45,15 @@ static void *gfx_display_metal_get_default_mvp(void *data) static void gfx_display_metal_blend_begin(void *data) { MetalDriver *md = (__bridge MetalDriver *)data; - if (!md) - return; - - md.display.blend = YES; + if (md) + md.display.blend = YES; } static void gfx_display_metal_blend_end(void *data) { MetalDriver *md = (__bridge MetalDriver *)data; - if (!md) - return; - - md.display.blend = NO; + if (md) + md.display.blend = NO; } static void gfx_display_metal_draw(gfx_display_ctx_draw_t *draw, @@ -67,10 +62,8 @@ static void gfx_display_metal_draw(gfx_display_ctx_draw_t *draw, unsigned video_height) { MetalDriver *md = (__bridge MetalDriver *)data; - if (!md || !draw) - return; - - [md.display draw:draw]; + if (md && draw) + [md.display draw:draw]; } static void gfx_display_metal_draw_pipeline( @@ -81,10 +74,8 @@ static void gfx_display_metal_draw_pipeline( unsigned video_height) { MetalDriver *md = (__bridge MetalDriver *)data; - if (!md || !draw) - return; - - [md.display drawPipeline:draw]; + if (md && draw) + [md.display drawPipeline:draw]; } static void gfx_display_metal_scissor_begin( @@ -93,11 +84,15 @@ static void gfx_display_metal_scissor_begin( unsigned video_height, int x, int y, unsigned width, unsigned height) { + MTLScissorRect r; MetalDriver *md = (__bridge MetalDriver *)data; if (!md) return; - MTLScissorRect r = {.x = (NSUInteger)x, .y = (NSUInteger)y, .width = width, .height = height}; + r.x = (NSUInteger)x; + r.y = (NSUInteger)y; + r.width = width; + r.height = height; [md.display setScissorRect:r]; } @@ -106,24 +101,22 @@ static void gfx_display_metal_scissor_end(void *data, unsigned video_height) { MetalDriver *md = (__bridge MetalDriver *)data; - if (!md) - return; - - [md.display clearScissorRect]; + if (md) + [md.display clearScissorRect]; } gfx_display_ctx_driver_t gfx_display_ctx_metal = { - .draw = gfx_display_metal_draw, - .draw_pipeline = gfx_display_metal_draw_pipeline, - .blend_begin = gfx_display_metal_blend_begin, - .blend_end = gfx_display_metal_blend_end, - .get_default_mvp = gfx_display_metal_get_default_mvp, - .get_default_vertices = gfx_display_metal_get_default_vertices, - .get_default_tex_coords = gfx_display_metal_get_default_tex_coords, - .font_type = FONT_DRIVER_RENDER_METAL_API, - .type = GFX_VIDEO_DRIVER_METAL, - .ident = "metal", - .handles_transform = NO, - .scissor_begin = gfx_display_metal_scissor_begin, - .scissor_end = gfx_display_metal_scissor_end + gfx_display_metal_draw, + gfx_display_metal_draw_pipeline, + gfx_display_metal_blend_begin, + gfx_display_metal_blend_end, + gfx_display_metal_get_default_mvp, + gfx_display_metal_get_default_vertices, + gfx_display_metal_get_default_tex_coords, + FONT_DRIVER_RENDER_METAL_API, + GFX_VIDEO_DRIVER_METAL, + "metal", + false, + gfx_display_metal_scissor_begin, + gfx_display_metal_scissor_end }; diff --git a/gfx/drivers_display/gfx_display_rsx.c b/gfx/drivers_display/gfx_display_rsx.c index e114f9d045..4499b22b07 100644 --- a/gfx/drivers_display/gfx_display_rsx.c +++ b/gfx/drivers_display/gfx_display_rsx.c @@ -21,17 +21,16 @@ #include "../gfx_display.h" -#include "../../retroarch.h" #include "../common/rsx_common.h" -static const float rsx_vertexes[] = { +static const float rsx_vertexes[8] = { 0, 0, 1, 0, 0, 1, 1, 1 }; -static const float rsx_tex_coords[] = { +static const float rsx_tex_coords[8] = { 0, 1, 1, 1, 0, 0, @@ -86,16 +85,16 @@ static void gfx_display_rsx_draw(gfx_display_ctx_draw_t *draw, if (!draw->texture) return; - vp.x = fabs(draw->x); - vp.y = fabs(rsx->height - draw->y - draw->height); - vp.w = draw->width <= rsx->width ? draw->width : rsx->width; - vp.h = draw->height <= rsx->height ? draw->height : rsx->height; - vp.min = 0.0f; - vp.max = 1.0f; - vp.scale[0] = vp.w*0.5f; - vp.scale[1] = vp.h*-0.5f; - vp.scale[2] = (vp.max - vp.min)*0.5f; - vp.scale[3] = 0.0f; + vp.x = fabs(draw->x); + vp.y = fabs(rsx->height - draw->y - draw->height); + vp.w = (draw->width <= rsx->width) ? draw->width : rsx->width; + vp.h = (draw->height <= rsx->height) ? draw->height : rsx->height; + vp.min = 0.0f; + vp.max = 1.0f; + vp.scale[0] = vp.w*0.5f; + vp.scale[1] = vp.h*-0.5f; + vp.scale[2] = (vp.max - vp.min)*0.5f; + vp.scale[3] = 0.0f; vp.offset[0] = vp.x + vp.w*0.5f; vp.offset[1] = vp.y + vp.h*0.5f; vp.offset[2] = (vp.max + vp.min)*0.5f; @@ -125,7 +124,8 @@ static void gfx_display_rsx_draw(gfx_display_ctx_draw_t *draw, rsxBindVertexArrayAttrib(rsx->context, rsx->uv_index->index, 0, rsx->uv_offset, sizeof(rsx_vertex_t), 2, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX); rsxBindVertexArrayAttrib(rsx->context, rsx->col_index->index, 0, rsx->col_offset, sizeof(rsx_vertex_t), 4, GCM_VERTEX_DATA_TYPE_F32, GCM_LOCATION_RSX); - rsxSetVertexProgramParameter(rsx->context, rsx->vpo, rsx->proj_matrix, (float *)&rsx->mvp_no_rot); + rsxSetVertexProgramParameter(rsx->context, + rsx->vpo, rsx->proj_matrix, (float *)&rsx->mvp_no_rot); rsxClearSurface(rsx->context, GCM_CLEAR_Z); rsxDrawVertexArray(rsx->context, GCM_TYPE_TRIANGLE_STRIP, 0, draw->coords->vertices); } diff --git a/gfx/drivers_display/gfx_display_switch.c b/gfx/drivers_display/gfx_display_switch.c index fbc01f193e..f48c33386b 100644 --- a/gfx/drivers_display/gfx_display_switch.c +++ b/gfx/drivers_display/gfx_display_switch.c @@ -14,11 +14,8 @@ */ #include -#include #include -#include "../../retroarch.h" - #include "../gfx_display.h" static void gfx_display_switch_draw(gfx_display_ctx_draw_t *draw, diff --git a/gfx/drivers_display/gfx_display_vita2d.c b/gfx/drivers_display/gfx_display_vita2d.c index 00b4194240..398331262f 100644 --- a/gfx/drivers_display/gfx_display_vita2d.c +++ b/gfx/drivers_display/gfx_display_vita2d.c @@ -23,25 +23,24 @@ #include "../gfx_display.h" -#include "../../retroarch.h" #include "../common/vita2d_common.h" #include -static const float vita2d_vertexes[] = { +static const float vita2d_vertexes[8] = { 0, 0, 1, 0, 0, 1, 1, 1 }; -static const float vita2d_tex_coords[] = { +static const float vita2d_tex_coords[8] = { 0, 1, 1, 1, 0, 0, 1, 0 }; -static const float vita2d_colors[] = { +static const float vita2d_colors[16] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, diff --git a/gfx/drivers_display/gfx_display_vulkan.c b/gfx/drivers_display/gfx_display_vulkan.c index b98eb0dcbb..06d8cae8e3 100644 --- a/gfx/drivers_display/gfx_display_vulkan.c +++ b/gfx/drivers_display/gfx_display_vulkan.c @@ -22,25 +22,24 @@ #include "../gfx_display.h" -#include "../../retroarch.h" #include "../common/vulkan_common.h" /* Will do Y-flip later, but try to make it similar to GL. */ -static const float vk_vertexes[] = { +static const float vk_vertexes[8] = { 0, 0, 1, 0, 0, 1, 1, 1 }; -static const float vk_tex_coords[] = { +static const float vk_tex_coords[8] = { 0, 1, 1, 1, 0, 0, 1, 0 }; -static const float vk_colors[] = { +static const float vk_colors[16] = { 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, diff --git a/gfx/drivers_display/gfx_display_wiiu.c b/gfx/drivers_display/gfx_display_wiiu.c index 23c9831d03..5806a57954 100644 --- a/gfx/drivers_display/gfx_display_wiiu.c +++ b/gfx/drivers_display/gfx_display_wiiu.c @@ -22,7 +22,6 @@ #include "../gfx_display.h" -#include "../../retroarch.h" #include "../common/gx2_common.h" #include "../../wiiu/system/memory.h" #include "../../wiiu/wiiu_dbg.h" @@ -166,20 +165,23 @@ static void gfx_display_wiiu_draw(gfx_display_ctx_draw_t *draw, } else { + sprite_vertex_t* v; if (wiiu->vertex_cache.current + 1 > wiiu->vertex_cache.size) return; - sprite_vertex_t* v = wiiu->vertex_cache.v + wiiu->vertex_cache.current; - v->pos.x = draw->x; - v->pos.y = wiiu->color_buffer.surface.height - draw->y - draw->height; - v->pos.width = draw->width; - v->pos.height = draw->height; - v->coord.u = 0.0f; - v->coord.v = 0.0f; - v->coord.width = 1.0f; - v->coord.height = 1.0f; + v = wiiu->vertex_cache.v + wiiu->vertex_cache.current; + v->pos.x = draw->x; + v->pos.y = wiiu->color_buffer.surface.height - + draw->y - draw->height; + v->pos.width = draw->width; + v->pos.height = draw->height; + v->coord.u = 0.0f; + v->coord.v = 0.0f; + v->coord.width = 1.0f; + v->coord.height = 1.0f; - v->color = COLOR_RGBA(0xFF * draw->coords->color[0], 0xFF * draw->coords->color[1], + v->color = COLOR_RGBA( + 0xFF * draw->coords->color[0], 0xFF * draw->coords->color[1], 0xFF * draw->coords->color[2], 0xFF * draw->coords->color[3]); if (draw->texture) @@ -193,8 +195,10 @@ static void gfx_display_wiiu_draw(gfx_display_ctx_draw_t *draw, GX2SetShaderMode(GX2_SHADER_MODE_GEOMETRY_SHADER); GX2SetShader(&sprite_shader); #if 0 - GX2SetGeometryShaderInputRingBuffer(wiiu->input_ring_buffer, wiiu->input_ring_buffer_size); - GX2SetGeometryShaderOutputRingBuffer(wiiu->output_ring_buffer, wiiu->output_ring_buffer_size); + GX2SetGeometryShaderInputRingBuffer(wiiu->input_ring_buffer, + wiiu->input_ring_buffer_size); + GX2SetGeometryShaderOutputRingBuffer(wiiu->output_ring_buffer, + wiiu->output_ring_buffer_size); #endif GX2SetVertexUniformBlock(sprite_shader.vs.uniformBlocks[0].offset, sprite_shader.vs.uniformBlocks[0].size, @@ -202,8 +206,10 @@ static void gfx_display_wiiu_draw(gfx_display_ctx_draw_t *draw, GX2SetVertexUniformBlock(sprite_shader.vs.uniformBlocks[1].offset, sprite_shader.vs.uniformBlocks[1].size, wiiu->ubo_tex); - GX2SetAttribBuffer(0, wiiu->vertex_cache.size * sizeof(*wiiu->vertex_cache.v), - sizeof(*wiiu->vertex_cache.v), wiiu->vertex_cache.v); + GX2SetAttribBuffer(0, wiiu->vertex_cache.size + * sizeof(*wiiu->vertex_cache.v), + sizeof(*wiiu->vertex_cache.v), + wiiu->vertex_cache.v); } static void gfx_display_wiiu_draw_pipeline( @@ -231,16 +237,23 @@ static void gfx_display_wiiu_draw_pipeline( draw->coords->vertex = wiiu->menu_shader_vbo; draw->coords->vertices = ca->coords.vertices; - GX2SetAttribBuffer(0, draw->coords->vertices * 2 * sizeof(float), 2 * sizeof(float), wiiu->menu_shader_vbo); - GX2SetBlendControl(GX2_RENDER_TARGET_0, GX2_BLEND_MODE_SRC_ALPHA, GX2_BLEND_MODE_ONE, - GX2_BLEND_COMBINE_MODE_ADD, GX2_DISABLE, 0, 0, 0); + GX2SetAttribBuffer(0, + draw->coords->vertices * 2 * sizeof(float), + 2 * sizeof(float), wiiu->menu_shader_vbo); + GX2SetBlendControl(GX2_RENDER_TARGET_0, + GX2_BLEND_MODE_SRC_ALPHA, + GX2_BLEND_MODE_ONE, + GX2_BLEND_COMBINE_MODE_ADD, + GX2_DISABLE, 0, 0, 0); break; case VIDEO_SHADER_MENU_3: case VIDEO_SHADER_MENU_4: case VIDEO_SHADER_MENU_5: case VIDEO_SHADER_MENU_6: - GX2SetAttribBuffer(0, 4 * sizeof(*wiiu->v), sizeof(*wiiu->v), wiiu->v); + GX2SetAttribBuffer(0, + 4 * sizeof(*wiiu->v), + sizeof(*wiiu->v), wiiu->v); break; default: return; @@ -248,7 +261,9 @@ static void gfx_display_wiiu_draw_pipeline( if (!wiiu->menu_shader_ubo) { - wiiu->menu_shader_ubo = MEM2_alloc(sizeof(*wiiu->menu_shader_ubo), GX2_UNIFORM_BLOCK_ALIGNMENT); + wiiu->menu_shader_ubo = MEM2_alloc( + sizeof(*wiiu->menu_shader_ubo), + GX2_UNIFORM_BLOCK_ALIGNMENT); matrix_4x4_ortho(wiiu->menu_shader_ubo->mvp, 0, 1, 1, 0, -1, 1); wiiu->menu_shader_ubo->OutputSize.width = wiiu->color_buffer.surface.width; wiiu->menu_shader_ubo->OutputSize.height = wiiu->color_buffer.surface.height;