diff --git a/gfx/common/d3d10_defines.h b/gfx/common/d3d10_defines.h index 958d82fddb..c812a63769 100644 --- a/gfx/common/d3d10_defines.h +++ b/gfx/common/d3d10_defines.h @@ -23,9 +23,6 @@ #include -#include -#include - #include "../drivers_shader/slang_process.h" #define D3D10_MAX_GPU_COUNT 16 @@ -46,7 +43,6 @@ enum d3d10_video_flags D3D10_ST_FLAG_FRAME_DUPE_LOCK = (1 << 11) }; - typedef const ID3D10SamplerState* D3D10SamplerStateRef; typedef ID3D10InputLayout* D3D10InputLayout; diff --git a/gfx/common/d3d11_defines.h b/gfx/common/d3d11_defines.h index 4e429805e8..4c0ac2d3fd 100644 --- a/gfx/common/d3d11_defines.h +++ b/gfx/common/d3d11_defines.h @@ -18,8 +18,6 @@ #include -#include - #include "dxgi_common.h" #ifdef CINTERFACE #define D3D11_NO_HELPERS @@ -27,8 +25,6 @@ #include #include -#include -#include #include #include "../drivers_shader/slang_process.h" @@ -127,13 +123,6 @@ typedef ID3D11SwitchToRef* D3D11SwitchToRef; typedef ID3D11TracingDevice* D3D11TracingDevice; typedef ID3D11InfoQueue* D3D11InfoQueue; -typedef struct d3d11_vertex_t -{ - float position[2]; - float texcoord[2]; - float color[4]; -} d3d11_vertex_t; - #ifndef ALIGN #ifdef _MSC_VER #define ALIGN(x) __declspec(align(x)) diff --git a/gfx/common/d3d12_defines.h b/gfx/common/d3d12_defines.h index eae0bd728a..1eac7f4da1 100644 --- a/gfx/common/d3d12_defines.h +++ b/gfx/common/d3d12_defines.h @@ -18,11 +18,8 @@ #define _D3D12_DEFINES_H_ #include -#include #include -#include - #include "dxgi_common.h" #include diff --git a/gfx/common/gl1_defines.h b/gfx/common/gl1_defines.h index d94743820d..1e9085bd3c 100644 --- a/gfx/common/gl1_defines.h +++ b/gfx/common/gl1_defines.h @@ -20,8 +20,6 @@ #include #include -#include -#include #if defined(__APPLE__) #include diff --git a/gfx/common/gl3_defines.h b/gfx/common/gl3_defines.h index 73977da7ea..f861809dd9 100644 --- a/gfx/common/gl3_defines.h +++ b/gfx/common/gl3_defines.h @@ -27,10 +27,7 @@ #endif #include -#include -#include #include -#include #include "../video_driver.h" #include "../drivers_shader/shader_gl3.h" diff --git a/gfx/common/ps2_defines.h b/gfx/common/ps2_defines.h deleted file mode 100644 index d2a926693c..0000000000 --- a/gfx/common/ps2_defines.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef PS2_DEFINES_H__ -#define PS2_DEFINES_H__ - -#include -#include - -#include -#include - -#include "../video_defines.h" -#include "../../libretro-common/include/libretro_gskit_ps2.h" - -typedef struct ps2_video -{ - /* I need to create this additional field - * to be used in the font driver*/ - bool clearVRAM_font; - bool menuVisible; - bool vsync; - int vsync_callback_id; - bool force_aspect; - - int8_t vmode; - int video_window_offset_x; - int video_window_offset_y; - - int PSM; - int tex_filter; - int menu_filter; - - video_viewport_t vp; - - /* Palette in the cores */ - struct retro_hw_render_interface_gskit_ps2 iface; - - GSGLOBAL *gsGlobal; - GSTEXTURE *menuTexture; - GSTEXTURE *coreTexture; - - /* Last scaling state, for detecting changes */ - int iTextureWidth; - int iTextureHeight; - float fDAR; - bool bScaleInteger; - struct retro_hw_ps2_insets padding; - - /* Current scaling calculation result */ - int iDisplayWidth; - int iDisplayHeight; -} ps2_video_t; - -#endif diff --git a/gfx/common/rsx_defines.h b/gfx/common/rsx_defines.h index a615314f2a..be81325682 100644 --- a/gfx/common/rsx_defines.h +++ b/gfx/common/rsx_defines.h @@ -103,14 +103,14 @@ typedef struct uint32_t *ptr; /* Internal stuff */ uint32_t offset; -} rsxBuffer; +} rsx_buffer; typedef struct { video_viewport_t vp; - rsxBuffer buffers[RSX_MAX_BUFFERS]; + rsx_buffer buffers[RSX_MAX_BUFFERS]; #if defined(HAVE_MENU_BUFFER) - rsxBuffer menuBuffers[RSX_MAX_MENU_BUFFERS]; + rsx_buffer menuBuffers[RSX_MAX_MENU_BUFFERS]; int menuBuffer; #endif int currentBuffer, nextBuffer; diff --git a/gfx/common/vga_defines.h b/gfx/common/vga_defines.h deleted file mode 100644 index cd75a2edee..0000000000 --- a/gfx/common/vga_defines.h +++ /dev/null @@ -1,24 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * copyright (c) 2011-2015 - Daniel De Matteis - * copyright (c) 2016-2019 - Brad Parker - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#ifndef __VGA_DEFINES_H -#define __VGA_DEFINES_H - -#define VGA_WIDTH 320 -#define VGA_HEIGHT 200 - -#endif diff --git a/gfx/common/vita2d_defines.h b/gfx/common/vita2d_defines.h deleted file mode 100644 index a15c991ccb..0000000000 --- a/gfx/common/vita2d_defines.h +++ /dev/null @@ -1,91 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2017 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -#ifndef VITA2D_DEFINES_H__ -#define VITA2D_DEFINES_H__ - -#include - -#include -#include -#include - -#include - -#include "../../driver.h" -#include "../../retroarch.h" - -typedef struct vita_menu_frame -{ - vita2d_texture *texture; - int width; - int height; - bool active; -} vita_menu_t; - -#ifdef HAVE_OVERLAY -struct vita_overlay_data -{ - vita2d_texture *tex; - float x; - float y; - float w; - float h; - float tex_x; - float tex_y; - float tex_w; - float tex_h; - float alpha_mod; - float width; - float height; -}; -#endif - -typedef struct vita_video -{ - vita2d_texture *texture; - SceGxmTextureFormat format; - int width; - int height; - SceGxmTextureFilter tex_filter; - - video_viewport_t vp; - - math_matrix_4x4 mvp, mvp_no_rot; - - vita_menu_t menu; - -#ifdef HAVE_OVERLAY - struct vita_overlay_data *overlay; - unsigned overlays; -#endif - unsigned video_width; - unsigned video_height; - unsigned rotation; - -#ifdef HAVE_OVERLAY - bool overlay_enable; - bool overlay_full_screen; -#endif - bool fullscreen; - bool vsync; - bool rgb32; - bool vblank_not_reached; - bool keep_aspect; - bool should_resize; -} vita_video_t; - -#endif diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index 93684bad0c..29329fb27e 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -39,10 +39,6 @@ #include #include #include -#include -#include -#include -#include #include #include @@ -328,28 +324,6 @@ enum vk_texture_flags VK_TEX_FLAG_MIPMAP = (1 << 2) }; -#ifdef VULKAN_HDR_SWAPCHAIN - -#ifndef VKALIGN -#ifdef _MSC_VER -#define VKALIGN(x) __declspec(align(x)) -#else -#define VKALIGN(x) __attribute__((aligned(x))) -#endif -#endif - -typedef struct VKALIGN(16) -{ - math_matrix_4x4 mvp; - float contrast; /* 2.0f */ - float paper_white_nits; /* 200.0f */ - float max_nits; /* 1000.0f */ - float expand_gamut; /* 1.0f */ - float inverse_tonemap; /* 1.0f */ - float hdr10; /* 1.0f */ -} vulkan_hdr_uniform_t; -#endif /* VULKAN_HDR_SWAPCHAIN */ - typedef struct vulkan_context { slock_t *queue_lock; @@ -426,48 +400,6 @@ struct vulkan_display_surface_info unsigned refresh_rate_x1000; }; -struct vk_color -{ - float r, g, b, a; -}; - -struct vk_vertex -{ - float x, y; - float tex_x, tex_y; - struct vk_color color; /* float alignment */ -}; - -struct vk_image -{ - VkImage image; /* ptr alignment */ - VkImageView view; /* ptr alignment */ - VkFramebuffer framebuffer; /* ptr alignment */ - VkDeviceMemory memory; /* ptr alignment */ -}; - -struct vk_texture -{ - VkDeviceSize memory_size; /* uint64_t alignment */ - - void *mapped; - VkImage image; /* ptr alignment */ - VkImageView view; /* ptr alignment */ - VkBuffer buffer; /* ptr alignment */ - VkDeviceMemory memory; /* ptr alignment */ - - size_t offset; - size_t stride; - size_t size; - uint32_t memory_type; - unsigned width, height; - - VkImageLayout layout; /* enum alignment */ - VkFormat format; /* enum alignment */ - enum vk_texture_type type; - uint8_t flags; -}; - struct vk_buffer { VkDeviceSize size; /* uint64_t alignment */ diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index 6574983ff5..3725d89598 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -76,6 +76,13 @@ const GUID DECLSPEC_SELECTANY libretro_IID_IDXGIFactory5 = { 0x7632e1f5,0xee65,0 #endif #endif +typedef struct d3d11_vertex_t +{ + float position[2]; + float texcoord[2]; + float color[4]; +} d3d11_vertex_t; + typedef struct { D3D11Texture2D handle; diff --git a/gfx/drivers/ps2_gfx.c b/gfx/drivers/ps2_gfx.c index d476f058e1..22fee348da 100644 --- a/gfx/drivers/ps2_gfx.c +++ b/gfx/drivers/ps2_gfx.c @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -27,12 +28,12 @@ #include #include +#include "../video_defines.h" #include "../../driver.h" #include "../../retroarch.h" #include "../../verbosity.h" #include "../gfx_display.h" -#include "../common/ps2_defines.h" /* Generic tint color */ #define GS_TEXT GS_SETREG_RGBA(0x80, 0x80, 0x80, 0x80) @@ -71,6 +72,45 @@ typedef struct void* font_data; } ps2_font_t; +typedef struct ps2_video +{ + /* I need to create this additional field + * to be used in the font driver*/ + bool clearVRAM_font; + bool menuVisible; + bool vsync; + int vsync_callback_id; + bool force_aspect; + + int8_t vmode; + int video_window_offset_x; + int video_window_offset_y; + + int PSM; + int tex_filter; + int menu_filter; + + video_viewport_t vp; + + /* Palette in the cores */ + struct retro_hw_render_interface_gskit_ps2 iface; + + GSGLOBAL *gsGlobal; + GSTEXTURE *menuTexture; + GSTEXTURE *coreTexture; + + /* Last scaling state, for detecting changes */ + int iTextureWidth; + int iTextureHeight; + float fDAR; + bool bScaleInteger; + struct retro_hw_ps2_insets padding; + + /* Current scaling calculation result */ + int iDisplayWidth; + int iDisplayHeight; +} ps2_video_t; + static struct rm_mode rm_mode_table[NUM_RM_VMODES] = { /* SDTV modes */ {-1, 704, -1, 4, GS_INTERLACED, GS_FIELD, -1, 11, "AUTO"}, @@ -252,7 +292,7 @@ static void ps2_font_render_line( width = glyph->width; height = glyph->height; - /* The -0.5 is needed to achieve pixel perfect. + /* The -0.5 is needed to achieve pixel perfect. * More info here (PS2 GSKit uses same logic as Direct3D9) * https://docs.microsoft.com/en-us/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-coordinates */ diff --git a/gfx/drivers/rsx_gfx.c b/gfx/drivers/rsx_gfx.c index ad46f92853..23543f007f 100644 --- a/gfx/drivers/rsx_gfx.c +++ b/gfx/drivers/rsx_gfx.c @@ -1070,7 +1070,7 @@ static bool rsx_tasks_finder(retro_task_t *task,void *userdata) { return task; } task_finder_data_t rsx_tasks_finder_data = {rsx_tasks_finder, NULL}; #endif -static int rsx_make_buffer(rsxBuffer * buffer, u16 width, u16 height, int id) +static int rsx_make_buffer(rsx_buffer *buffer, u16 width, u16 height, int id) { int depth = sizeof(u32); int pitch = depth * width; @@ -1229,7 +1229,7 @@ error: return NULL; } -static void rsx_init_render_target(rsx_t *rsx, rsxBuffer * buffer, int id) +static void rsx_init_render_target(rsx_t *rsx, rsx_buffer *buffer, int id) { u32 i; memset(&rsx->surface[id], 0, sizeof(gcmSurface)); @@ -1572,7 +1572,7 @@ static void rsx_fill_black(uint32_t *dst, uint32_t *dst_end, size_t sz) } static void rsx_blit_buffer( - rsxBuffer *buffer, const void *frame, unsigned width, + rsx_buffer *buffer, const void *frame, unsigned width, unsigned height, unsigned pitch, int rgb32, bool do_scaling) { int i; @@ -2086,7 +2086,7 @@ static void rsx_get_overlay_interface(void *data, static void rsx_update_screen(rsx_t* gcm) { - rsxBuffer *buffer = NULL; + rsx_buffer *buffer = NULL; #if defined(HAVE_MENU_BUFFER) if (gcm->menu_frame_enable) { diff --git a/gfx/drivers/vga_gfx.c b/gfx/drivers/vga_gfx.c index c7db258e79..c9179b77f7 100644 --- a/gfx/drivers/vga_gfx.c +++ b/gfx/drivers/vga_gfx.c @@ -30,13 +30,14 @@ #include "../../menu/menu_driver.h" #endif -#include "../common/vga_defines.h" - #include "../font_driver.h" #include "../../driver.h" #include "../../verbosity.h" +#define VGA_WIDTH 320 +#define VGA_HEIGHT 200 + typedef struct { const font_renderer_driver_t *font_driver; diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index a98e80d275..17eb866f32 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -35,14 +36,75 @@ #include "../font_driver.h" #include "../video_driver.h" -#include "../common/vita2d_defines.h" +#include + #include "../../driver.h" +#include "../../retroarch.h" #include "../../verbosity.h" #include "../../configuration.h" -#include #include +typedef struct vita_menu_frame +{ + vita2d_texture *texture; + int width; + int height; + bool active; +} vita_menu_t; + +#ifdef HAVE_OVERLAY +struct vita_overlay_data +{ + vita2d_texture *tex; + float x; + float y; + float w; + float h; + float tex_x; + float tex_y; + float tex_w; + float tex_h; + float alpha_mod; + float width; + float height; +}; +#endif + +typedef struct vita_video +{ + vita2d_texture *texture; + SceGxmTextureFormat format; + int width; + int height; + SceGxmTextureFilter tex_filter; + + video_viewport_t vp; + + math_matrix_4x4 mvp, mvp_no_rot; + + vita_menu_t menu; + +#ifdef HAVE_OVERLAY + struct vita_overlay_data *overlay; + unsigned overlays; +#endif + unsigned video_width; + unsigned video_height; + unsigned rotation; + +#ifdef HAVE_OVERLAY + bool overlay_enable; + bool overlay_full_screen; +#endif + bool fullscreen; + bool vsync; + bool rgb32; + bool vblank_not_reached; + bool keep_aspect; + bool should_resize; +} vita_video_t; + typedef struct { vita_video_t *vita; diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 2db7a00e2f..ec44414a01 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -57,6 +57,69 @@ #define VK_REMAP_TO_TEXFMT(fmt) ((fmt == VK_FORMAT_R5G6B5_UNORM_PACK16) ? VK_FORMAT_R8G8B8A8_UNORM : fmt) +#ifdef VULKAN_HDR_SWAPCHAIN +#ifndef VKALIGN +#ifdef _MSC_VER +#define VKALIGN(x) __declspec(align(x)) +#else +#define VKALIGN(x) __attribute__((aligned(x))) +#endif +#endif + +typedef struct VKALIGN(16) +{ + math_matrix_4x4 mvp; + float contrast; /* 2.0f */ + float paper_white_nits; /* 200.0f */ + float max_nits; /* 1000.0f */ + float expand_gamut; /* 1.0f */ + float inverse_tonemap; /* 1.0f */ + float hdr10; /* 1.0f */ +} vulkan_hdr_uniform_t; +#endif + +struct vk_color +{ + float r, g, b, a; +}; + +struct vk_vertex +{ + float x, y; + float tex_x, tex_y; + struct vk_color color; /* float alignment */ +}; + +struct vk_image +{ + VkImage image; /* ptr alignment */ + VkImageView view; /* ptr alignment */ + VkFramebuffer framebuffer; /* ptr alignment */ + VkDeviceMemory memory; /* ptr alignment */ +}; + +struct vk_texture +{ + VkDeviceSize memory_size; /* uint64_t alignment */ + + void *mapped; + VkImage image; /* ptr alignment */ + VkImageView view; /* ptr alignment */ + VkBuffer buffer; /* ptr alignment */ + VkDeviceMemory memory; /* ptr alignment */ + + size_t offset; + size_t stride; + size_t size; + uint32_t memory_type; + unsigned width, height; + + VkImageLayout layout; /* enum alignment */ + VkFormat format; /* enum alignment */ + enum vk_texture_type type; + uint8_t flags; +}; + struct vk_per_frame { struct vk_texture texture; /* uint64_t alignment */ diff --git a/gfx/drivers_shader/shader_vulkan.cpp b/gfx/drivers_shader/shader_vulkan.cpp index b33fc0ec66..af622268f1 100644 --- a/gfx/drivers_shader/shader_vulkan.cpp +++ b/gfx/drivers_shader/shader_vulkan.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "slang_reflection.h"