diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index 3c88aff3eb..6e56ec51c5 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -287,14 +287,26 @@ static void d3d10_set_filtering(void* data, unsigned index, bool smooth, bool ct static void d3d10_gfx_set_rotation(void* data, unsigned rotation) { - math_matrix_4x4 rot; + static math_matrix_4x4 rot = { + { 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 1.0f } + }; + float radians, cosine, sine; void* mapped_ubo = NULL; d3d10_video_t* d3d10 = (d3d10_video_t*)data; if (!d3d10) return; - matrix_4x4_rotate_z(rot, rotation * (M_PI / 2.0f)); + radians = rotation * (M_PI / 2.0f); + cosine = cosf(radians); + sine = sinf(radians); + MAT_ELEM_4X4(rot, 0, 0) = cosine; + MAT_ELEM_4X4(rot, 0, 1) = -sine; + MAT_ELEM_4X4(rot, 1, 0) = sine; + MAT_ELEM_4X4(rot, 1, 1) = cosine; matrix_4x4_multiply(d3d10->mvp, rot, d3d10->ubo_values.mvp); d3d10->frame.ubo->lpVtbl->Map(d3d10->frame.ubo, diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index e9d5789f27..9666754884 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -433,14 +433,26 @@ static void d3d11_set_filtering(void* data, unsigned index, static void d3d11_gfx_set_rotation(void* data, unsigned rotation) { - math_matrix_4x4 rot; + float radians, cosine, sine; D3D11_MAPPED_SUBRESOURCE mapped_ubo; - d3d11_video_t* d3d11 = (d3d11_video_t*)data; + static math_matrix_4x4 rot = { + { 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 1.0f } + }; + d3d11_video_t* d3d11 = (d3d11_video_t*)data; if (!d3d11) return; - matrix_4x4_rotate_z(rot, rotation * (M_PI / 2.0f)); + radians = rotation * (M_PI / 2.0f); + cosine = cosf(radians); + sine = sinf(radians); + MAT_ELEM_4X4(rot, 0, 0) = cosine; + MAT_ELEM_4X4(rot, 0, 1) = -sine; + MAT_ELEM_4X4(rot, 1, 0) = sine; + MAT_ELEM_4X4(rot, 1, 1) = cosine; matrix_4x4_multiply(d3d11->mvp, rot, d3d11->ubo_values.mvp); d3d11->context->lpVtbl->Map( diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index 043239fa84..6639892296 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -441,8 +441,14 @@ static void d3d12_set_filtering(void* data, unsigned index, bool smooth, bool ct static void d3d12_gfx_set_rotation(void* data, unsigned rotation) { - math_matrix_4x4 rot; math_matrix_4x4* mvp; + static math_matrix_4x4 rot = { + { 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 1.0f } + }; + float radians, cosine, sine; D3D12_RANGE read_range; d3d12_video_t* d3d12 = (d3d12_video_t*)data; @@ -452,13 +458,19 @@ static void d3d12_gfx_set_rotation(void* data, unsigned rotation) d3d12_gfx_sync(d3d12); d3d12->frame.rotation = rotation; - matrix_4x4_rotate_z(rot, d3d12->frame.rotation * (M_PI / 2.0f)); + radians = d3d12->frame.rotation * (M_PI / 2.0f); + cosine = cosf(radians); + sine = sinf(radians); + MAT_ELEM_4X4(rot, 0, 0) = cosine; + MAT_ELEM_4X4(rot, 0, 1) = -sine; + MAT_ELEM_4X4(rot, 1, 0) = sine; + MAT_ELEM_4X4(rot, 1, 1) = cosine; matrix_4x4_multiply(d3d12->mvp, rot, d3d12->mvp_no_rot); read_range.Begin = 0; read_range.End = 0; D3D12Map(d3d12->frame.ubo, 0, &read_range, (void**)&mvp); - *mvp = d3d12->mvp; + *mvp = d3d12->mvp; D3D12Unmap(d3d12->frame.ubo, 0, NULL); } diff --git a/gfx/drivers/gl1.c b/gfx/drivers/gl1.c index afb1d69f73..b427463b17 100644 --- a/gfx/drivers/gl1.c +++ b/gfx/drivers/gl1.c @@ -451,7 +451,13 @@ error: static void gl1_set_projection(gl1_t *gl1, struct video_ortho *ortho, bool allow_rotate) { - math_matrix_4x4 rot; + static math_matrix_4x4 rot = { + { 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 1.0f } + }; + float radians, cosine, sine; /* Calculate projection. */ matrix_4x4_ortho(gl1->mvp_no_rot, ortho->left, ortho->right, @@ -463,7 +469,13 @@ static void gl1_set_projection(gl1_t *gl1, return; } - matrix_4x4_rotate_z(rot, M_PI * gl1->rotation / 180.0f); + radians = M_PI * gl1->rotation / 180.0f; + cosine = cosf(radians); + sine = sinf(radians); + MAT_ELEM_4X4(rot, 0, 0) = cosine; + MAT_ELEM_4X4(rot, 0, 1) = -sine; + MAT_ELEM_4X4(rot, 1, 0) = sine; + MAT_ELEM_4X4(rot, 1, 1) = cosine; matrix_4x4_multiply(gl1->mvp, rot, gl1->mvp_no_rot); } diff --git a/gfx/drivers/gl2.c b/gfx/drivers/gl2.c index 571ee0ec75..11e9c9b4f6 100644 --- a/gfx/drivers/gl2.c +++ b/gfx/drivers/gl2.c @@ -371,7 +371,13 @@ static bool gl2_recreate_fbo( static void gl2_set_projection(gl2_t *gl, struct video_ortho *ortho, bool allow_rotate) { - math_matrix_4x4 rot; + static math_matrix_4x4 rot = { + { 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 1.0f } + }; + float radians, cosine, sine; /* Calculate projection. */ matrix_4x4_ortho(gl->mvp_no_rot, ortho->left, ortho->right, @@ -383,7 +389,13 @@ static void gl2_set_projection(gl2_t *gl, return; } - matrix_4x4_rotate_z(rot, M_PI * gl->rotation / 180.0f); + radians = M_PI * gl->rotation / 180.0f; + cosine = cosf(radians); + sine = sinf(radians); + MAT_ELEM_4X4(rot, 0, 0) = cosine; + MAT_ELEM_4X4(rot, 0, 1) = -sine; + MAT_ELEM_4X4(rot, 1, 0) = sine; + MAT_ELEM_4X4(rot, 1, 1) = cosine; matrix_4x4_multiply(gl->mvp, rot, gl->mvp_no_rot); } diff --git a/gfx/drivers/gl3.c b/gfx/drivers/gl3.c index f2cfe024b6..7dc6f0378e 100644 --- a/gfx/drivers/gl3.c +++ b/gfx/drivers/gl3.c @@ -723,7 +723,13 @@ static const gfx_ctx_driver_t *gl3_get_context(gl3_t *gl) static void gl3_set_projection(gl3_t *gl, const struct video_ortho *ortho, bool allow_rotate) { - math_matrix_4x4 rot; + static math_matrix_4x4 rot = { + { 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 1.0f } + }; + float radians, cosine, sine; /* Calculate projection. */ matrix_4x4_ortho(gl->mvp_no_rot, ortho->left, ortho->right, @@ -735,7 +741,13 @@ static void gl3_set_projection(gl3_t *gl, return; } - matrix_4x4_rotate_z(rot, M_PI * gl->rotation / 180.0f); + radians = M_PI * gl->rotation / 180.0f; + cosine = cosf(radians); + sine = sinf(radians); + MAT_ELEM_4X4(rot, 0, 0) = cosine; + MAT_ELEM_4X4(rot, 0, 1) = -sine; + MAT_ELEM_4X4(rot, 1, 0) = sine; + MAT_ELEM_4X4(rot, 1, 1) = cosine; matrix_4x4_multiply(gl->mvp, rot, gl->mvp_no_rot); memcpy(gl->mvp_no_rot_yflip.data, gl->mvp_no_rot.data, sizeof(gl->mvp_no_rot.data)); diff --git a/gfx/drivers/gx2_gfx.c b/gfx/drivers/gx2_gfx.c index 34faba2ed2..5b09566115 100644 --- a/gfx/drivers/gx2_gfx.c +++ b/gfx/drivers/gx2_gfx.c @@ -86,9 +86,23 @@ static void wiiu_set_tex_coords(frame_vertex_t *v, static void wiiu_set_projection(wiiu_video_t *wiiu) { - math_matrix_4x4 proj, rot; + static math_matrix_4x4 rot = { + { 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 1.0f } + }; + float radians, cosine, sine; + math_matrix_4x4 proj; + matrix_4x4_ortho(proj, 0, 1, 1, 0, -1, 1); - matrix_4x4_rotate_z(rot, wiiu->rotation * M_PI_2); + radians = wiiu->rotation * M_PI_2; + cosine = cosf(radians); + sine = sinf(radians); + MAT_ELEM_4X4(rot, 0, 0) = cosine; + MAT_ELEM_4X4(rot, 0, 1) = -sine; + MAT_ELEM_4X4(rot, 1, 0) = sine; + MAT_ELEM_4X4(rot, 1, 1) = cosine; matrix_4x4_multiply((*wiiu->ubo_mvp), rot, proj); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_UNIFORM_BLOCK, wiiu->ubo_mvp, sizeof(*wiiu->ubo_mvp)); } diff --git a/gfx/drivers/rsx_gfx.c b/gfx/drivers/rsx_gfx.c index cb38b42e60..13c947ac76 100644 --- a/gfx/drivers/rsx_gfx.c +++ b/gfx/drivers/rsx_gfx.c @@ -445,7 +445,8 @@ static void* rsx_init(const video_info_t* video, rsx_context_bind_hw_render(rsx, true); - if (video->font_enable) { + if (video->font_enable) + { font_driver_init_osd(rsx, video, false, @@ -460,7 +461,13 @@ static void* rsx_init(const video_info_t* video, static void rsx_set_projection(rsx_t *rsx, struct video_ortho *ortho, bool allow_rotate) { - math_matrix_4x4 rot; + static math_matrix_4x4 rot = { + { 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 1.0f } + }; + float radians, cosine, sine; /* Calculate projection. */ matrix_4x4_ortho(rsx->mvp_no_rot, ortho->left, ortho->right, @@ -472,7 +479,13 @@ static void rsx_set_projection(rsx_t *rsx, return; } - matrix_4x4_rotate_z(rot, M_PI * rsx->rotation / 180.0f); + radians = M_PI * rsx->rotation / 180.0f; + cosine = cosf(radians); + sine = sinf(radians); + MAT_ELEM_4X4(rot, 0, 0) = cosine; + MAT_ELEM_4X4(rot, 0, 1) = -sine; + MAT_ELEM_4X4(rot, 1, 0) = sine; + MAT_ELEM_4X4(rot, 1, 1) = cosine; matrix_4x4_multiply(rsx->mvp, rot, rsx->mvp_no_rot); } diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 91c9d95f54..683caff97b 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -370,7 +370,13 @@ static bool vita2d_gfx_set_shader(void *data, static void vita2d_set_projection(vita_video_t *vita, struct video_ortho *ortho, bool allow_rotate) { - math_matrix_4x4 rot; + static math_matrix_4x4 rot = { + { 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 1.0f } + }; + float radians, cosine, sine; /* Calculate projection. */ matrix_4x4_ortho(vita->mvp_no_rot, ortho->left, ortho->right, @@ -382,7 +388,13 @@ static void vita2d_set_projection(vita_video_t *vita, return; } - matrix_4x4_rotate_z(rot, M_PI * vita->rotation / 180.0f); + radians = M_PI * vita->rotation / 180.0f; + cosine = cosf(radians); + sine = sinf(radians); + MAT_ELEM_4X4(rot, 0, 0) = cosine; + MAT_ELEM_4X4(rot, 0, 1) = -sine; + MAT_ELEM_4X4(rot, 1, 0) = sine; + MAT_ELEM_4X4(rot, 1, 1) = cosine; matrix_4x4_multiply(vita->mvp, rot, vita->mvp_no_rot); } diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index bec41dcbe6..08a4f387db 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1757,7 +1757,13 @@ static bool vulkan_set_shader(void *data, static void vulkan_set_projection(vk_t *vk, struct video_ortho *ortho, bool allow_rotate) { - math_matrix_4x4 rot; + float radians, cosine, sine; + static math_matrix_4x4 rot = { + { 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 0.0f , + 0.0f, 0.0f, 0.0f, 1.0f } + }; /* Calculate projection. */ matrix_4x4_ortho(vk->mvp_no_rot, ortho->left, ortho->right, @@ -1769,7 +1775,13 @@ static void vulkan_set_projection(vk_t *vk, return; } - matrix_4x4_rotate_z(rot, M_PI * vk->rotation / 180.0f); + radians = M_PI * vk->rotation / 180.0f; + cosine = cosf(radians); + sine = sinf(radians); + MAT_ELEM_4X4(rot, 0, 0) = cosine; + MAT_ELEM_4X4(rot, 0, 1) = -sine; + MAT_ELEM_4X4(rot, 1, 0) = sine; + MAT_ELEM_4X4(rot, 1, 1) = cosine; matrix_4x4_multiply(vk->mvp, rot, vk->mvp_no_rot); } diff --git a/gfx/gfx_display.c b/gfx/gfx_display.c index 0b90895c19..c3b5703955 100644 --- a/gfx/gfx_display.c +++ b/gfx/gfx_display.c @@ -960,7 +960,7 @@ void gfx_display_rotate_z(gfx_display_t *p_disp, gfx_display_ctx_rotate_draw_t *draw, void *data) { float cosine, sine, radians; - math_matrix_4x4 matrix_rotated = { + static math_matrix_4x4 matrix_rotated = { { 0.0f, 0.0f, 0.0f, 0.0f , 0.0f, 0.0f, 0.0f, 0.0f , 0.0f, 0.0f, 1.0f, 0.0f , @@ -988,15 +988,15 @@ void gfx_display_rotate_z(gfx_display_t *p_disp, if (draw->scale_enable) { - math_matrix_4x4 matrix_scaled = { + static math_matrix_4x4 matrix_scaled = { { 0.0f, 0.0f, 0.0f, 0.0f , 0.0f, 0.0f, 0.0f, 0.0f , 0.0f, 0.0f, 0.0f, 0.0f , 0.0f, 0.0f, 0.0f, 1.0f } }; - MAT_ELEM_4X4(matrix_scaled, 0, 0) = draw->scale_x; - MAT_ELEM_4X4(matrix_scaled, 1, 1) = draw->scale_y; - MAT_ELEM_4X4(matrix_scaled, 2, 2) = draw->scale_z; + MAT_ELEM_4X4(matrix_scaled, 0, 0) = draw->scale_x; + MAT_ELEM_4X4(matrix_scaled, 1, 1) = draw->scale_y; + MAT_ELEM_4X4(matrix_scaled, 2, 2) = draw->scale_z; matrix_4x4_multiply(*draw->matrix, matrix_scaled, *draw->matrix); } }