diff --git a/gfx/common/ctr_defines.h b/gfx/common/ctr_defines.h index facbeb57ba..2eee236552 100644 --- a/gfx/common/ctr_defines.h +++ b/gfx/common/ctr_defines.h @@ -27,156 +27,6 @@ #define CTR_BOTTOM_FRAMEBUFFER_HEIGHT 240 #define CTR_STATE_DATE_SIZE 11 -#define CTR_SET_SCALE_VECTOR(vec, vp_width, vp_height, tex_width, tex_height) \ - (vec)->x = -2.0f / (vp_width); \ - (vec)->y = -2.0f / (vp_height); \ - (vec)->u = 1.0f / (tex_width); \ - (vec)->v = -1.0f / (tex_height) - -typedef enum -{ - CTR_VIDEO_MODE_3D = 0, - CTR_VIDEO_MODE_2D, - CTR_VIDEO_MODE_2D_400X240, - CTR_VIDEO_MODE_2D_800X240, - CTR_VIDEO_MODE_LAST -} ctr_video_mode_enum; - -typedef enum -{ - CTR_BOTTOM_MENU_NOT_AVAILABLE = 0, - CTR_BOTTOM_MENU_DEFAULT, - CTR_BOTTOM_MENU_SELECT -} ctr_bottom_menu; - -typedef struct -{ - float v; - float u; - float y; - float x; -} ctr_scale_vector_t; - -typedef struct -{ - s16 x0, y0, x1, y1; - s16 u0, v0, u1, v1; -} ctr_vertex_t; - -typedef struct ctr_video -{ - struct - { - struct - { - void* left; - void* right; - }top; - void* bottom; - }drawbuffers; - void* depthbuffer; - - struct - { - uint32_t* display_list; - void* texture_linear; - void* texture_swizzled; - ctr_vertex_t* frame_coords; - int display_list_size; - int texture_width; - int texture_height; - ctr_scale_vector_t scale_vector; - }menu; - - uint32_t *display_list; - void *texture_linear; - void *texture_swizzled; - int display_list_size; - unsigned int texture_width; - unsigned int texture_height; - - ctr_scale_vector_t scale_vector; - ctr_vertex_t* frame_coords; - - DVLB_s* dvlb; - shaderProgram_s shader; - - video_viewport_t vp; - - unsigned rotation; - -#ifdef HAVE_OVERLAY - struct ctr_overlay_data *overlay; - unsigned overlays; -#endif - - aptHookCookie lcd_aptHook; - ctr_video_mode_enum video_mode; - int current_buffer_top; - int current_buffer_bottom; - - struct - { - ctr_vertex_t* buffer; - ctr_vertex_t* current; - size_t size; - }vertex_cache; - - int state_slot; - u64 idle_timestamp; - ctr_bottom_menu bottom_menu; - ctr_bottom_menu prev_bottom_menu; - struct ctr_bottom_texture_data *bottom_textures; - - volatile bool vsync_event_pending; -#ifdef HAVE_OVERLAY - bool overlay_enabled; - bool overlay_full_screen; -#endif - bool rgb32; - bool vsync; - bool smooth; - bool menu_texture_enable; - bool menu_texture_frame_enable; - bool keep_aspect; - bool should_resize; - bool msg_rendering_enabled; - bool supports_parallax_disable; - bool enable_3d; - bool p3d_event_pending; - bool ppf_event_pending; - bool init_bottom_menu; - bool refresh_bottom_menu; - bool render_font_bottom; - bool render_state_from_png_file; - bool state_data_exist; - bool bottom_check_idle; - bool bottom_is_idle; - bool bottom_is_fading; - char state_date[CTR_STATE_DATE_SIZE]; -} ctr_video_t; - -typedef struct ctr_texture -{ - unsigned int width; - unsigned int height; - unsigned int active_width; - unsigned int active_height; - - enum texture_filter_type type; - void* data; -} ctr_texture_t; - -#ifdef HAVE_OVERLAY -struct ctr_overlay_data -{ - ctr_texture_t texture; - ctr_vertex_t* frame_coords; - ctr_scale_vector_t scale_vector; - float alpha_mod; -}; -#endif - #ifdef USE_CTRULIB_2 extern u8* gfxTopLeftFramebuffers[2]; extern u8* gfxTopRightFramebuffers[2]; diff --git a/gfx/common/d3d10_defines.h b/gfx/common/d3d10_defines.h index 3774344767..958d82fddb 100644 --- a/gfx/common/d3d10_defines.h +++ b/gfx/common/d3d10_defines.h @@ -81,42 +81,6 @@ typedef ID3D10Debug* D3D10Debug; typedef ID3D10SwitchToRef* D3D10SwitchToRef; typedef ID3D10InfoQueue* D3D10InfoQueue; -typedef struct d3d10_vertex_t -{ - float position[2]; - float texcoord[2]; - float color[4]; -} d3d10_vertex_t; - -typedef struct -{ - D3D10Texture2D handle; - D3D10Texture2D staging; - D3D10_TEXTURE2D_DESC desc; - D3D10RenderTargetView rt_view; - D3D10ShaderResourceView view; - D3D10SamplerStateRef sampler; - float4_t size_data; -} d3d10_texture_t; - -typedef struct -{ - struct - { - float x, y, w, h; - } pos; - struct - { - float u, v, w, h; - } coords; - UINT32 colors[4]; - struct - { - float scaling; - float rotation; - } params; -} d3d10_sprite_t; - #ifndef ALIGN #ifdef _MSC_VER #define ALIGN(x) __declspec(align(x)) @@ -125,112 +89,4 @@ typedef struct #endif #endif -typedef struct ALIGN(16) -{ - math_matrix_4x4 mvp; - struct - { - float width; - float height; - } OutputSize; - float time; -} d3d10_uniform_t; - -typedef struct d3d10_shader_t -{ - D3D10VertexShader vs; - D3D10PixelShader ps; - D3D10GeometryShader gs; - D3D10InputLayout layout; -} d3d10_shader_t; - -typedef struct -{ - unsigned cur_mon_id; - DXGISwapChain swapChain; - D3D10Device device; - D3D10RasterizerState state; - D3D10RenderTargetView renderTargetView; - D3D10Buffer ubo; - d3d10_uniform_t ubo_values; - D3D10SamplerState samplers[RARCH_FILTER_MAX][RARCH_WRAP_MAX]; - D3D10BlendState blend_enable; - D3D10BlendState blend_disable; - D3D10BlendState blend_pipeline; - D3D10Buffer menu_pipeline_vbo; - math_matrix_4x4 mvp, mvp_no_rot; - struct video_viewport vp; - D3D10_VIEWPORT viewport; - DXGI_FORMAT format; - float clearcolor[4]; - unsigned swap_interval; - d3d10_shader_t shaders[GFX_MAX_SHADERS]; -#ifdef __WINRT__ - DXGIFactory2 factory; -#else - DXGIFactory1 factory; -#endif - DXGIAdapter adapter; - - struct - { - d3d10_shader_t shader; - d3d10_shader_t shader_font; - D3D10Buffer vbo; - int offset; - int capacity; - } sprites; - -#ifdef HAVE_OVERLAY - struct - { - D3D10Buffer vbo; - d3d10_texture_t* textures; - int count; - } overlays; -#endif - - struct - { - d3d10_texture_t texture; - D3D10Buffer vbo; - } menu; - struct - { - d3d10_texture_t texture[GFX_MAX_FRAME_HISTORY + 1]; - D3D10Buffer vbo; - D3D10Buffer ubo; - D3D10_VIEWPORT viewport; - float4_t output_size; - int rotation; - } frame; - - struct - { - d3d10_shader_t shader; - D3D10Buffer buffers[SLANG_CBUFFER_MAX]; - d3d10_texture_t rt; - d3d10_texture_t feedback; - D3D10_VIEWPORT viewport; - pass_semantics_t semantics; - uint32_t frame_count; - int32_t frame_direction; - uint32_t frame_time_delta; - float original_fps; - uint32_t rotation; - uint32_t total_subframes; - uint32_t current_subframe; - float core_aspect; - float core_aspect_rot; - - } pass[GFX_MAX_SHADERS]; - - struct video_shader* shader_preset; - d3d10_texture_t luts[GFX_MAX_TEXTURES]; - struct string_list *gpu_list; - IDXGIAdapter1 *adapters[D3D10_MAX_GPU_COUNT]; - IDXGIAdapter1 *current_adapter; - uint16_t flags; -} d3d10_video_t; - #endif diff --git a/gfx/common/d3d11_defines.h b/gfx/common/d3d11_defines.h index 49bf2472c9..4e429805e8 100644 --- a/gfx/common/d3d11_defines.h +++ b/gfx/common/d3d11_defines.h @@ -134,35 +134,6 @@ typedef struct d3d11_vertex_t float color[4]; } d3d11_vertex_t; -typedef struct -{ - D3D11Texture2D handle; - D3D11Texture2D staging; - D3D11_TEXTURE2D_DESC desc; - D3D11RenderTargetView rt_view; - D3D11ShaderResourceView view; - D3D11SamplerStateRef sampler; - float4_t size_data; -} d3d11_texture_t; - -typedef struct -{ - UINT32 colors[4]; - struct - { - float x, y, w, h; - } pos; - struct - { - float u, v, w, h; - } coords; - struct - { - float scaling; - float rotation; - } params; -} d3d11_sprite_t; - #ifndef ALIGN #ifdef _MSC_VER #define ALIGN(x) __declspec(align(x)) @@ -171,140 +142,4 @@ typedef struct #endif #endif -typedef struct ALIGN(16) -{ - math_matrix_4x4 mvp; - struct - { - float width; - float height; - } OutputSize; - float time; -} d3d11_uniform_t; - -typedef struct d3d11_shader_t -{ - D3D11VertexShader vs; - D3D11PixelShader ps; - D3D11GeometryShader gs; - D3D11InputLayout layout; -} d3d11_shader_t; - -typedef struct -{ - unsigned cur_mon_id; - HANDLE frameLatencyWaitableObject; - DXGISwapChain swapChain; - D3D11Device device; - D3D_FEATURE_LEVEL supportedFeatureLevel; - D3D11DeviceContext context; - D3D11RasterizerState scissor_enabled; - D3D11RasterizerState scissor_disabled; - D3D11Buffer ubo; - d3d11_uniform_t ubo_values; -#ifdef HAVE_DXGI_HDR - d3d11_texture_t back_buffer; -#endif - D3D11SamplerState samplers[RARCH_FILTER_MAX][RARCH_WRAP_MAX]; - D3D11BlendState blend_enable; - D3D11BlendState blend_disable; - D3D11BlendState blend_pipeline; - D3D11Buffer menu_pipeline_vbo; - math_matrix_4x4 mvp, mvp_no_rot, identity; - struct video_viewport vp; - D3D11_VIEWPORT viewport; - D3D11_RECT scissor; - DXGI_FORMAT format; - float clearcolor[4]; - unsigned swap_interval; - int8_t wait_for_vblank; - uint32_t flags; - d3d11_shader_t shaders[GFX_MAX_SHADERS]; -#ifdef HAVE_DXGI_HDR - enum dxgi_swapchain_bit_depth - chain_bit_depth; - DXGI_COLOR_SPACE_TYPE chain_color_space; - DXGI_FORMAT chain_formats[DXGI_SWAPCHAIN_BIT_DEPTH_COUNT]; -#endif -#ifdef __WINRT__ - DXGIFactory2 factory; -#else - DXGIFactory1 factory; -#endif - DXGIAdapter adapter; - - struct retro_hw_render_interface_d3d11 hw_iface; - -#ifdef HAVE_DXGI_HDR - struct - { - dxgi_hdr_uniform_t ubo_values; - D3D11Buffer ubo; - float max_output_nits; - float min_output_nits; - float max_cll; - float max_fall; - } hdr; -#endif - - struct - { - d3d11_shader_t shader; - d3d11_shader_t shader_font; - D3D11Buffer vbo; - int offset; - int capacity; - } sprites; - -#ifdef HAVE_OVERLAY - struct - { - D3D11Buffer vbo; - d3d11_texture_t* textures; - int count; - } overlays; -#endif - - struct - { - d3d11_texture_t texture; - D3D11Buffer vbo; - } menu; - - struct - { - d3d11_texture_t texture[GFX_MAX_FRAME_HISTORY + 1]; - D3D11Buffer vbo; - D3D11Buffer ubo; - D3D11_VIEWPORT viewport; - float4_t output_size; - int rotation; - } frame; - - struct - { - d3d11_shader_t shader; - D3D11Buffer buffers[SLANG_CBUFFER_MAX]; - d3d11_texture_t rt; - d3d11_texture_t feedback; - D3D11_VIEWPORT viewport; - pass_semantics_t semantics; - uint32_t frame_count; - int32_t frame_direction; - uint32_t frame_time_delta; - float original_fps; - uint32_t rotation; - uint32_t total_subframes; - uint32_t current_subframe; - float core_aspect; - float core_aspect_rot; - } pass[GFX_MAX_SHADERS]; - - struct video_shader* shader_preset; - struct string_list *gpu_list; - IDXGIAdapter1 *current_adapter; - IDXGIAdapter1 *adapters[D3D11_MAX_GPU_COUNT]; - d3d11_texture_t luts[GFX_MAX_TEXTURES]; -} d3d11_video_t; - #endif diff --git a/gfx/common/d3d12_defines.h b/gfx/common/d3d12_defines.h index fbc2f53c50..eae0bd728a 100644 --- a/gfx/common/d3d12_defines.h +++ b/gfx/common/d3d12_defines.h @@ -116,31 +116,6 @@ typedef ID3D12DeviceRemovedExtendedDataSettings* D3D12DeviceRemovedExtendedData #endif typedef ID3D12InfoQueue* D3D12InfoQueue; -typedef struct d3d12_vertex_t -{ - float position[2]; - float texcoord[2]; - float color[4]; -} d3d12_vertex_t; - -typedef struct -{ - struct - { - float x, y, w, h; - } pos; - struct - { - float u, v, w, h; - } coords; - struct - { - float scaling; - float rotation; - } params; - UINT32 colors[4]; -} d3d12_sprite_t; - typedef struct { D3D12DescriptorHeap handle; /* descriptor pool */ @@ -152,25 +127,6 @@ typedef struct int start; } d3d12_descriptor_heap_t; -typedef struct -{ - D3D12Resource handle; - D3D12Resource upload_buffer; - D3D12_RESOURCE_DESC desc; - /* the first view is srv, the rest are mip levels uavs */ - D3D12_CPU_DESCRIPTOR_HANDLE cpu_descriptor[D3D12_MAX_TEXTURE_DIMENSION_2_TO_EXP - 5]; - D3D12_GPU_DESCRIPTOR_HANDLE gpu_descriptor[D3D12_MAX_TEXTURE_DIMENSION_2_TO_EXP - 5]; - D3D12_GPU_DESCRIPTOR_HANDLE sampler; - D3D12_CPU_DESCRIPTOR_HANDLE rt_view; - D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout; - UINT num_rows; - UINT64 row_size_in_bytes; - UINT64 total_bytes; - d3d12_descriptor_heap_t* srv_heap; - float4_t size_data; - bool dirty; -} d3d12_texture_t; - #ifndef ALIGN #ifdef _MSC_VER #define ALIGN(x) __declspec(align(x)) @@ -179,187 +135,6 @@ typedef struct #endif #endif -typedef struct ALIGN(16) -{ - math_matrix_4x4 mvp; - struct - { - float width; - float height; - } OutputSize; - float time; -} d3d12_uniform_t; - -typedef struct -{ - unsigned cur_mon_id; -#ifdef __WINRT__ - DXGIFactory2 factory; -#else - DXGIFactory1 factory; -#endif - DXGIAdapter adapter; - D3D12Device device; - -#ifdef DEVICE_DEBUG -#ifdef DEBUG - D3D12DebugDevice debug_device; - D3D12InfoQueue info_queue; - D3D12DeviceRemovedExtendedDataSettings device_removed_info; -#endif /* DEBUG */ -#endif /* DEVICE_DEBUG */ - - struct retro_hw_render_interface_d3d12 hw_iface; - D3D12Resource hw_render_texture; - DXGI_FORMAT hw_render_texture_format; - - IDXGIAdapter1 *adapters[D3D12_MAX_GPU_COUNT]; - struct string_list *gpu_list; - - struct - { - D3D12CommandQueue handle; - D3D12CommandAllocator allocator; - D3D12GraphicsCommandList cmd; - D3D12Fence fence; - HANDLE fenceEvent; - UINT64 fenceValue; - } queue; - - struct - { - D3D12RootSignature cs_rootSignature; /* descriptor layout */ - D3D12RootSignature sl_rootSignature; /* descriptor layout */ - D3D12RootSignature rootSignature; /* descriptor layout */ - d3d12_descriptor_heap_t srv_heap; /* ShaderResourceView descriptor heap */ - d3d12_descriptor_heap_t rtv_heap; /* RenderTargetView descriptor heap */ - d3d12_descriptor_heap_t sampler_heap; - } desc; - - struct - { - HANDLE frameLatencyWaitableObject; - DXGISwapChain handle; - D3D12Resource renderTargets[2]; -#ifdef HAVE_DXGI_HDR - d3d12_texture_t back_buffer; -#endif - D3D12_CPU_DESCRIPTOR_HANDLE desc_handles[2]; - D3D12_VIEWPORT viewport; - D3D12_RECT scissorRect; - float clearcolor[4]; - int frame_index; - unsigned swap_interval; -#ifdef HAVE_DXGI_HDR - enum dxgi_swapchain_bit_depth bit_depth; - DXGI_COLOR_SPACE_TYPE color_space; - DXGI_FORMAT formats[DXGI_SWAPCHAIN_BIT_DEPTH_COUNT]; -#endif - } chain; - - struct - { - d3d12_texture_t texture[GFX_MAX_FRAME_HISTORY + 1]; - D3D12Resource ubo; - D3D12_CONSTANT_BUFFER_VIEW_DESC ubo_view; - D3D12Resource vbo; - D3D12_VERTEX_BUFFER_VIEW vbo_view; - D3D12_VIEWPORT viewport; - D3D12_RECT scissorRect; - float4_t output_size; - int rotation; - } frame; - -#ifdef HAVE_DXGI_HDR - struct - { - dxgi_hdr_uniform_t ubo_values; - D3D12Resource ubo; - D3D12_CONSTANT_BUFFER_VIEW_DESC ubo_view; - float max_output_nits; - float min_output_nits; - float max_cll; - float max_fall; - } hdr; -#endif - - struct - { - D3D12Resource vbo; - D3D12_VERTEX_BUFFER_VIEW vbo_view; - d3d12_texture_t texture; - - float alpha; - } menu; - - struct - { - D3D12PipelineStateRef pipe; - D3D12PipelineState pipe_blend; - D3D12PipelineState pipe_noblend; - D3D12PipelineState pipe_font; - D3D12Resource vbo; - D3D12_VERTEX_BUFFER_VIEW vbo_view; - int offset; - int capacity; - } sprites; - -#ifdef HAVE_OVERLAY - struct - { - D3D12Resource vbo; - D3D12_VERTEX_BUFFER_VIEW vbo_view; - d3d12_texture_t* textures; - int count; - } overlays; -#endif - - struct - { - D3D12PipelineState pipe; - D3D12_GPU_DESCRIPTOR_HANDLE sampler; - D3D12Resource buffers[SLANG_CBUFFER_MAX]; - D3D12_CONSTANT_BUFFER_VIEW_DESC buffer_view[SLANG_CBUFFER_MAX]; - d3d12_texture_t rt; - d3d12_texture_t feedback; - D3D12_VIEWPORT viewport; - D3D12_RECT scissorRect; - pass_semantics_t semantics; - uint32_t frame_count; - int32_t frame_direction; - uint32_t frame_time_delta; - float original_fps; - uint32_t rotation; - uint32_t total_subframes; - uint32_t current_subframe; - float core_aspect; - float core_aspect_rot; - D3D12_GPU_DESCRIPTOR_HANDLE textures; - D3D12_GPU_DESCRIPTOR_HANDLE samplers; - } pass[GFX_MAX_SHADERS]; - - struct video_shader* shader_preset; - d3d12_texture_t luts[GFX_MAX_TEXTURES]; - - D3D12PipelineState pipes[GFX_MAX_SHADERS]; - D3D12PipelineState mipmapgen_pipe; - d3d12_uniform_t ubo_values; - D3D12Resource ubo; - D3D12_CONSTANT_BUFFER_VIEW_DESC ubo_view; - DXGI_FORMAT format; - D3D12_GPU_DESCRIPTOR_HANDLE samplers[RARCH_FILTER_MAX][RARCH_WRAP_MAX]; - math_matrix_4x4 mvp, mvp_no_rot, identity; - struct video_viewport vp; - D3D12Resource menu_pipeline_vbo; - D3D12_VERTEX_BUFFER_VIEW menu_pipeline_vbo_view; - -#ifdef DEBUG - D3D12Debug debugController; -#endif - uint32_t flags; - int8_t wait_for_vblank; -} d3d12_video_t; - /* end of auto-generated */ #endif diff --git a/gfx/common/d3d8_defines.h b/gfx/common/d3d8_defines.h index f377590ca5..798fe89add 100644 --- a/gfx/common/d3d8_defines.h +++ b/gfx/common/d3d8_defines.h @@ -25,53 +25,4 @@ #include "../../retroarch.h" #include "../../verbosity.h" -RETRO_BEGIN_DECLS - -typedef struct d3d8_video -{ - overlay_t *menu; - void *renderchain_data; - - struct video_viewport vp; - struct video_shader shader; - video_info_t video_info; -#ifdef HAVE_WINDOW - WNDCLASSEX windowClass; -#endif - LPDIRECT3DDEVICE8 dev; - D3DVIEWPORT8 out_vp; - - char *shader_path; - - struct - { - void *buffer; - void *decl; - int size; - int offset; - }menu_display; - - overlay_t *overlays; - size_t overlays_size; - unsigned cur_mon_id; - unsigned dev_rotation; - math_matrix_4x4 mvp; /* float alignment */ - math_matrix_4x4 mvp_rotate; /* float alignment */ - math_matrix_4x4 mvp_transposed; /* float alignment */ - - bool keep_aspect; - bool should_resize; - bool quitting; - bool needs_restore; - bool overlays_enabled; - /* TODO - refactor this away properly. */ - bool resolution_hd_enable; - - /* Only used for Xbox */ - bool widescreen_mode; - -} d3d8_video_t; - -RETRO_END_DECLS - #endif diff --git a/gfx/common/gl1_defines.h b/gfx/common/gl1_defines.h index 918e46ddd2..d94743820d 100644 --- a/gfx/common/gl1_defines.h +++ b/gfx/common/gl1_defines.h @@ -69,51 +69,4 @@ enum gl1_flags GL1_FLAG_FRAME_DUPE_LOCK = (1 << 12) }; -typedef struct gl1 -{ - struct video_viewport vp; - struct video_coords coords; - math_matrix_4x4 mvp, mvp_no_rot; - - void *ctx_data; - const gfx_ctx_driver_t *ctx_driver; - struct string_list *extensions; - struct video_tex_info tex_info; - void *readback_buffer_screenshot; - GLuint *overlay_tex; - float *overlay_vertex_coord; - float *overlay_tex_coord; - float *overlay_color_coord; - const float *vertex_ptr; - const float *white_color_ptr; - unsigned char *menu_frame; - unsigned char *video_buf; - unsigned char *menu_video_buf; - - int version_major; - int version_minor; - unsigned video_width; - unsigned video_height; - unsigned video_pitch; - unsigned screen_width; - unsigned screen_height; - unsigned menu_width; - unsigned menu_height; - unsigned menu_pitch; - unsigned video_bits; - unsigned menu_bits; - unsigned out_vp_width; - unsigned out_vp_height; - unsigned tex_index; /* For use with PREV. */ - unsigned textures; - unsigned rotation; - unsigned overlays; - - GLuint tex; - GLuint menu_tex; - GLuint texture[GFX_MAX_TEXTURES]; - - uint16_t flags; -} gl1_t; - #endif diff --git a/gfx/common/gl3_defines.h b/gfx/common/gl3_defines.h index c3ed727490..73977da7ea 100644 --- a/gfx/common/gl3_defines.h +++ b/gfx/common/gl3_defines.h @@ -60,86 +60,6 @@ enum gl3_flags GL3_FLAG_FRAME_DUPE_LOCK = (1 << 13) }; -struct gl3_streamed_texture -{ - GLuint tex; - unsigned width; - unsigned height; -}; - - -typedef struct gl3 -{ - const gfx_ctx_driver_t *ctx_driver; - void *ctx_data; - gl3_filter_chain_t *filter_chain; - gl3_filter_chain_t *filter_chain_default; - GLuint *overlay_tex; - float *overlay_vertex_coord; - float *overlay_tex_coord; - float *overlay_color_coord; - GLsync fences[GL_CORE_NUM_FENCES]; - void *readback_buffer_screenshot; - struct scaler_ctx pbo_readback_scaler; - - video_info_t video_info; - video_viewport_t vp; - struct gl3_viewport filter_chain_vp; - struct gl3_streamed_texture textures[GL_CORE_NUM_TEXTURES]; - - GLuint vao; - GLuint menu_texture; - GLuint pbo_readback[GL_CORE_NUM_PBOS]; - - struct - { - GLuint alpha_blend; - GLuint font; - GLuint ribbon; - GLuint ribbon_simple; - GLuint snow_simple; - GLuint snow; - GLuint bokeh; - struct gl3_buffer_locations alpha_blend_loc; - struct gl3_buffer_locations font_loc; - struct gl3_buffer_locations ribbon_loc; - struct gl3_buffer_locations ribbon_simple_loc; - struct gl3_buffer_locations snow_simple_loc; - struct gl3_buffer_locations snow_loc; - struct gl3_buffer_locations bokeh_loc; - } pipelines; - - - unsigned video_width; - unsigned video_height; - unsigned overlays; - unsigned version_major; - unsigned version_minor; - unsigned out_vp_width; - unsigned out_vp_height; - unsigned rotation; - unsigned textures_index; - unsigned scratch_vbo_index; - unsigned fence_count; - unsigned pbo_readback_index; - unsigned hw_render_max_width; - unsigned hw_render_max_height; - GLuint scratch_vbos[GL_CORE_NUM_VBOS]; - GLuint hw_render_texture; - GLuint hw_render_fbo; - GLuint hw_render_rb_ds; - - float menu_texture_alpha; - math_matrix_4x4 mvp; /* float alignment */ - math_matrix_4x4 mvp_yflip; - math_matrix_4x4 mvp_no_rot; - math_matrix_4x4 mvp_no_rot_yflip; - - uint16_t flags; - - bool pbo_readback_valid[GL_CORE_NUM_PBOS]; -} gl3_t; - RETRO_END_DECLS #endif diff --git a/gfx/common/vga_defines.h b/gfx/common/vga_defines.h index 745322cb9b..cd75a2edee 100644 --- a/gfx/common/vga_defines.h +++ b/gfx/common/vga_defines.h @@ -21,22 +21,4 @@ #define VGA_WIDTH 320 #define VGA_HEIGHT 200 -typedef struct vga -{ - unsigned char *vga_menu_frame; - unsigned char *vga_frame; - - unsigned vga_menu_width; - unsigned vga_menu_height; - unsigned vga_menu_pitch; - unsigned vga_menu_bits; - unsigned vga_video_width; - unsigned vga_video_height; - unsigned vga_video_pitch; - unsigned vga_video_bits; - - bool color; - bool vga_rgb32; -} vga_t; - #endif diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index a83dff025c..93684bad0c 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -516,174 +516,6 @@ struct vk_descriptor_manager unsigned num_sizes; }; -struct vk_per_frame -{ - struct vk_texture texture; /* uint64_t alignment */ - struct vk_texture texture_optimal; - struct vk_buffer_chain vbo; /* uint64_t alignment */ - struct vk_buffer_chain ubo; - struct vk_descriptor_manager descriptor_manager; - - VkCommandPool cmd_pool; /* ptr alignment */ - VkCommandBuffer cmd; /* ptr alignment */ -}; - -struct vk_draw_quad -{ - struct vk_texture *texture; - const math_matrix_4x4 *mvp; - VkPipeline pipeline; /* ptr alignment */ - VkSampler sampler; /* ptr alignment */ - struct vk_color color; /* float alignment */ -}; - -struct vk_draw_triangles -{ - const void *uniform; - const struct vk_buffer_range *vbo; - struct vk_texture *texture; - VkPipeline pipeline; /* ptr alignment */ - VkSampler sampler; /* ptr alignment */ - size_t uniform_size; - unsigned vertices; -}; - -typedef struct vk -{ - vulkan_filter_chain_t *filter_chain; - vulkan_filter_chain_t *filter_chain_default; - vulkan_context_t *context; - void *ctx_data; - const gfx_ctx_driver_t *ctx_driver; - struct vk_per_frame *chain; - struct vk_image *backbuffer; -#ifdef VULKAN_HDR_SWAPCHAIN - VkRenderPass readback_render_pass; - struct vk_image main_buffer; - struct vk_image readback_image; -#endif /* VULKAN_HDR_SWAPCHAIN */ - - unsigned video_width; - unsigned video_height; - - unsigned tex_w, tex_h; - unsigned out_vp_width; - unsigned out_vp_height; - unsigned rotation; - unsigned num_swapchain_images; - unsigned last_valid_index; - - video_info_t video; - - VkFormat tex_fmt; - math_matrix_4x4 mvp, mvp_no_rot, mvp_menu; /* float alignment */ - VkViewport vk_vp; - VkRenderPass render_pass; - struct video_viewport vp; - float translate_x; - float translate_y; - struct vk_per_frame swapchain[VULKAN_MAX_SWAPCHAIN_IMAGES]; - struct vk_image backbuffers[VULKAN_MAX_SWAPCHAIN_IMAGES]; - struct vk_texture default_texture; - - /* Currently active command buffer. */ - VkCommandBuffer cmd; - /* Staging pool for doing buffer transfers on GPU. */ - VkCommandPool staging_pool; - - struct - { - struct scaler_ctx scaler_bgr; - struct scaler_ctx scaler_rgb; - struct vk_texture staging[VULKAN_MAX_SWAPCHAIN_IMAGES]; - } readback; - - struct - { - struct vk_texture *images; - struct vk_vertex *vertex; - unsigned count; - } overlay; - - struct - { - VkPipeline alpha_blend; - VkPipeline font; - VkPipeline rgb565_to_rgba8888; -#ifdef VULKAN_HDR_SWAPCHAIN - VkPipeline hdr; - VkPipeline hdr_to_sdr; /* for readback */ -#endif /* VULKAN_HDR_SWAPCHAIN */ - VkDescriptorSetLayout set_layout; - VkPipelineLayout layout; - VkPipelineCache cache; - } pipelines; - - struct - { - VkPipeline pipelines[8 * 2]; - struct vk_texture blank_texture; - } display; - -#ifdef VULKAN_HDR_SWAPCHAIN - struct - { - struct vk_buffer ubo; - float max_output_nits; - float min_output_nits; - float max_cll; - float max_fall; - } hdr; -#endif /* VULKAN_HDR_SWAPCHAIN */ - - struct - { - struct vk_texture textures[VULKAN_MAX_SWAPCHAIN_IMAGES]; - struct vk_texture textures_optimal[VULKAN_MAX_SWAPCHAIN_IMAGES]; - unsigned last_index; - float alpha; - bool dirty[VULKAN_MAX_SWAPCHAIN_IMAGES]; - } menu; - - struct - { - VkSampler linear; - VkSampler nearest; - VkSampler mipmap_nearest; - VkSampler mipmap_linear; - } samplers; - - struct - { - const struct retro_vulkan_image *image; - VkPipelineStageFlags *wait_dst_stages; - VkCommandBuffer *cmd; - VkSemaphore *semaphores; - VkSemaphore signal_semaphore; /* ptr alignment */ - - struct retro_hw_render_interface_vulkan iface; - - unsigned capacity_cmd; - unsigned last_width; - unsigned last_height; - uint32_t num_semaphores; - uint32_t num_cmd; - uint32_t src_queue_family; - - } hw; - - struct - { - uint64_t dirty; - VkPipeline pipeline; /* ptr alignment */ - VkImageView view; /* ptr alignment */ - VkSampler sampler; /* ptr alignment */ - math_matrix_4x4 mvp; - VkRect2D scissor; /* int32_t alignment */ - } tracker; - uint32_t flags; -} vk_t; - bool vulkan_buffer_chain_alloc(const struct vulkan_context *context, struct vk_buffer_chain *chain, size_t len, struct vk_buffer_range *range); diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index 4f9400010f..0151e03a6d 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -58,6 +58,12 @@ #include "../../tasks/tasks_internal.h" #endif +#define CTR_SET_SCALE_VECTOR(vec, vp_width, vp_height, tex_width, tex_height) \ + (vec)->x = -2.0f / (vp_width); \ + (vec)->y = -2.0f / (vp_height); \ + (vec)->u = 1.0f / (tex_width); \ + (vec)->v = -1.0f / (tex_height) + enum { CTR_TEXTURE_BOTTOM_MENU = 0, @@ -65,6 +71,150 @@ enum CTR_TEXTURE_LAST }; +typedef enum +{ + CTR_VIDEO_MODE_3D = 0, + CTR_VIDEO_MODE_2D, + CTR_VIDEO_MODE_2D_400X240, + CTR_VIDEO_MODE_2D_800X240, + CTR_VIDEO_MODE_LAST +} ctr_video_mode_enum; + +typedef enum +{ + CTR_BOTTOM_MENU_NOT_AVAILABLE = 0, + CTR_BOTTOM_MENU_DEFAULT, + CTR_BOTTOM_MENU_SELECT +} ctr_bottom_menu; + +typedef struct +{ + float v; + float u; + float y; + float x; +} ctr_scale_vector_t; + +typedef struct +{ + s16 x0, y0, x1, y1; + s16 u0, v0, u1, v1; +} ctr_vertex_t; + +typedef struct ctr_video +{ + struct + { + struct + { + void* left; + void* right; + }top; + void* bottom; + }drawbuffers; + void* depthbuffer; + + struct + { + uint32_t* display_list; + void* texture_linear; + void* texture_swizzled; + ctr_vertex_t* frame_coords; + int display_list_size; + int texture_width; + int texture_height; + ctr_scale_vector_t scale_vector; + }menu; + + uint32_t *display_list; + void *texture_linear; + void *texture_swizzled; + int display_list_size; + unsigned int texture_width; + unsigned int texture_height; + + ctr_scale_vector_t scale_vector; + ctr_vertex_t* frame_coords; + + DVLB_s* dvlb; + shaderProgram_s shader; + + video_viewport_t vp; + + unsigned rotation; + +#ifdef HAVE_OVERLAY + struct ctr_overlay_data *overlay; + unsigned overlays; +#endif + + aptHookCookie lcd_aptHook; + ctr_video_mode_enum video_mode; + int current_buffer_top; + int current_buffer_bottom; + + struct + { + ctr_vertex_t* buffer; + ctr_vertex_t* current; + size_t size; + }vertex_cache; + + int state_slot; + u64 idle_timestamp; + ctr_bottom_menu bottom_menu; + ctr_bottom_menu prev_bottom_menu; + struct ctr_bottom_texture_data *bottom_textures; + + volatile bool vsync_event_pending; +#ifdef HAVE_OVERLAY + bool overlay_enabled; + bool overlay_full_screen; +#endif + bool rgb32; + bool vsync; + bool smooth; + bool menu_texture_enable; + bool menu_texture_frame_enable; + bool keep_aspect; + bool should_resize; + bool msg_rendering_enabled; + bool supports_parallax_disable; + bool enable_3d; + bool p3d_event_pending; + bool ppf_event_pending; + bool init_bottom_menu; + bool refresh_bottom_menu; + bool render_font_bottom; + bool render_state_from_png_file; + bool state_data_exist; + bool bottom_check_idle; + bool bottom_is_idle; + bool bottom_is_fading; + char state_date[CTR_STATE_DATE_SIZE]; +} ctr_video_t; + +typedef struct ctr_texture +{ + unsigned int width; + unsigned int height; + unsigned int active_width; + unsigned int active_height; + + enum texture_filter_type type; + void* data; +} ctr_texture_t; + +#ifdef HAVE_OVERLAY +struct ctr_overlay_data +{ + ctr_texture_t texture; + ctr_vertex_t* frame_coords; + ctr_scale_vector_t scale_vector; + float alpha_mod; +}; +#endif + struct ctr_bottom_texture_data { uintptr_t texture; @@ -980,7 +1130,8 @@ static void save_state_to_file(void *data) command_event(CMD_EVENT_RAM_STATE_TO_FILE, state_path); } -static void ctr_bottom_menu_control(void* data, bool lcd_bottom, uint32_t flags) +static void ctr_bottom_menu_control(void* data, + bool lcd_bottom, uint32_t flags) { touchPosition state_tmp_touch; uint32_t state_tmp = 0; diff --git a/gfx/drivers/d3d10.c b/gfx/drivers/d3d10.c index dca9a59acf..f0738648eb 100644 --- a/gfx/drivers/d3d10.c +++ b/gfx/drivers/d3d10.c @@ -63,6 +63,17 @@ #define D3D10_ROLLING_SCANLINE_SIMULATION +typedef struct +{ + D3D10Texture2D handle; + D3D10Texture2D staging; + D3D10_TEXTURE2D_DESC desc; + D3D10RenderTargetView rt_view; + D3D10ShaderResourceView view; + D3D10SamplerStateRef sampler; + float4_t size_data; +} d3d10_texture_t; + typedef struct { d3d10_texture_t texture; @@ -71,6 +82,140 @@ typedef struct struct font_atlas* atlas; } d3d10_font_t; +typedef struct d3d10_vertex_t +{ + float position[2]; + float texcoord[2]; + float color[4]; +} d3d10_vertex_t; + +typedef struct +{ + struct + { + float x, y, w, h; + } pos; + struct + { + float u, v, w, h; + } coords; + UINT32 colors[4]; + struct + { + float scaling; + float rotation; + } params; +} d3d10_sprite_t; + +typedef struct ALIGN(16) +{ + math_matrix_4x4 mvp; + struct + { + float width; + float height; + } OutputSize; + float time; +} d3d10_uniform_t; + +typedef struct d3d10_shader_t +{ + D3D10VertexShader vs; + D3D10PixelShader ps; + D3D10GeometryShader gs; + D3D10InputLayout layout; +} d3d10_shader_t; + +typedef struct +{ + unsigned cur_mon_id; + DXGISwapChain swapChain; + D3D10Device device; + D3D10RasterizerState state; + D3D10RenderTargetView renderTargetView; + D3D10Buffer ubo; + d3d10_uniform_t ubo_values; + D3D10SamplerState samplers[RARCH_FILTER_MAX][RARCH_WRAP_MAX]; + D3D10BlendState blend_enable; + D3D10BlendState blend_disable; + D3D10BlendState blend_pipeline; + D3D10Buffer menu_pipeline_vbo; + math_matrix_4x4 mvp, mvp_no_rot; + struct video_viewport vp; + D3D10_VIEWPORT viewport; + DXGI_FORMAT format; + float clearcolor[4]; + unsigned swap_interval; + d3d10_shader_t shaders[GFX_MAX_SHADERS]; +#ifdef __WINRT__ + DXGIFactory2 factory; +#else + DXGIFactory1 factory; +#endif + DXGIAdapter adapter; + + struct + { + d3d10_shader_t shader; + d3d10_shader_t shader_font; + D3D10Buffer vbo; + int offset; + int capacity; + } sprites; + +#ifdef HAVE_OVERLAY + struct + { + D3D10Buffer vbo; + d3d10_texture_t* textures; + int count; + } overlays; +#endif + + struct + { + d3d10_texture_t texture; + D3D10Buffer vbo; + } menu; + struct + { + d3d10_texture_t texture[GFX_MAX_FRAME_HISTORY + 1]; + D3D10Buffer vbo; + D3D10Buffer ubo; + D3D10_VIEWPORT viewport; + float4_t output_size; + int rotation; + } frame; + + struct + { + d3d10_shader_t shader; + D3D10Buffer buffers[SLANG_CBUFFER_MAX]; + d3d10_texture_t rt; + d3d10_texture_t feedback; + D3D10_VIEWPORT viewport; + pass_semantics_t semantics; + uint32_t frame_count; + int32_t frame_direction; + uint32_t frame_time_delta; + float original_fps; + uint32_t rotation; + uint32_t total_subframes; + uint32_t current_subframe; + float core_aspect; + float core_aspect_rot; + + } pass[GFX_MAX_SHADERS]; + + struct video_shader* shader_preset; + d3d10_texture_t luts[GFX_MAX_TEXTURES]; + struct string_list *gpu_list; + IDXGIAdapter1 *adapters[D3D10_MAX_GPU_COUNT]; + IDXGIAdapter1 *current_adapter; + uint16_t flags; +} d3d10_video_t; + + /* Temporary workaround for d3d10 not being able to poll flags during init */ static gfx_ctx_driver_t d3d10_fake_context; static uint32_t d3d10_get_flags(void *data); diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index f24ccbf278..6574983ff5 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -76,6 +76,172 @@ const GUID DECLSPEC_SELECTANY libretro_IID_IDXGIFactory5 = { 0x7632e1f5,0xee65,0 #endif #endif +typedef struct +{ + D3D11Texture2D handle; + D3D11Texture2D staging; + D3D11_TEXTURE2D_DESC desc; + D3D11RenderTargetView rt_view; + D3D11ShaderResourceView view; + D3D11SamplerStateRef sampler; + float4_t size_data; +} d3d11_texture_t; + +typedef struct +{ + UINT32 colors[4]; + struct + { + float x, y, w, h; + } pos; + struct + { + float u, v, w, h; + } coords; + struct + { + float scaling; + float rotation; + } params; +} d3d11_sprite_t; + +typedef struct ALIGN(16) +{ + math_matrix_4x4 mvp; + struct + { + float width; + float height; + } OutputSize; + float time; +} d3d11_uniform_t; + +typedef struct d3d11_shader_t +{ + D3D11VertexShader vs; + D3D11PixelShader ps; + D3D11GeometryShader gs; + D3D11InputLayout layout; +} d3d11_shader_t; + +typedef struct +{ + unsigned cur_mon_id; + HANDLE frameLatencyWaitableObject; + DXGISwapChain swapChain; + D3D11Device device; + D3D_FEATURE_LEVEL supportedFeatureLevel; + D3D11DeviceContext context; + D3D11RasterizerState scissor_enabled; + D3D11RasterizerState scissor_disabled; + D3D11Buffer ubo; + d3d11_uniform_t ubo_values; +#ifdef HAVE_DXGI_HDR + d3d11_texture_t back_buffer; +#endif + D3D11SamplerState samplers[RARCH_FILTER_MAX][RARCH_WRAP_MAX]; + D3D11BlendState blend_enable; + D3D11BlendState blend_disable; + D3D11BlendState blend_pipeline; + D3D11Buffer menu_pipeline_vbo; + math_matrix_4x4 mvp, mvp_no_rot, identity; + struct video_viewport vp; + D3D11_VIEWPORT viewport; + D3D11_RECT scissor; + DXGI_FORMAT format; + float clearcolor[4]; + unsigned swap_interval; + int8_t wait_for_vblank; + uint32_t flags; + d3d11_shader_t shaders[GFX_MAX_SHADERS]; +#ifdef HAVE_DXGI_HDR + enum dxgi_swapchain_bit_depth + chain_bit_depth; + DXGI_COLOR_SPACE_TYPE chain_color_space; + DXGI_FORMAT chain_formats[DXGI_SWAPCHAIN_BIT_DEPTH_COUNT]; +#endif +#ifdef __WINRT__ + DXGIFactory2 factory; +#else + DXGIFactory1 factory; +#endif + DXGIAdapter adapter; + + struct retro_hw_render_interface_d3d11 hw_iface; + +#ifdef HAVE_DXGI_HDR + struct + { + dxgi_hdr_uniform_t ubo_values; + D3D11Buffer ubo; + float max_output_nits; + float min_output_nits; + float max_cll; + float max_fall; + } hdr; +#endif + + struct + { + d3d11_shader_t shader; + d3d11_shader_t shader_font; + D3D11Buffer vbo; + int offset; + int capacity; + } sprites; + +#ifdef HAVE_OVERLAY + struct + { + D3D11Buffer vbo; + d3d11_texture_t* textures; + int count; + } overlays; +#endif + + struct + { + d3d11_texture_t texture; + D3D11Buffer vbo; + } menu; + + struct + { + d3d11_texture_t texture[GFX_MAX_FRAME_HISTORY + 1]; + D3D11Buffer vbo; + D3D11Buffer ubo; + D3D11_VIEWPORT viewport; + float4_t output_size; + int rotation; + } frame; + + struct + { + d3d11_shader_t shader; + D3D11Buffer buffers[SLANG_CBUFFER_MAX]; + d3d11_texture_t rt; + d3d11_texture_t feedback; + D3D11_VIEWPORT viewport; + pass_semantics_t semantics; + uint32_t frame_count; + int32_t frame_direction; + uint32_t frame_time_delta; + float original_fps; + uint32_t rotation; + uint32_t total_subframes; + uint32_t current_subframe; + float core_aspect; + float core_aspect_rot; + } pass[GFX_MAX_SHADERS]; + + struct video_shader* shader_preset; + struct string_list *gpu_list; + IDXGIAdapter1 *current_adapter; + IDXGIAdapter1 *adapters[D3D11_MAX_GPU_COUNT]; + d3d11_texture_t luts[GFX_MAX_TEXTURES]; +} d3d11_video_t; + + #define D3D11_ROLLING_SCANLINE_SIMULATION /* Temporary workaround for d3d11 not being able to poll flags during init */ diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index 72f062b4df..f332c28c26 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -80,6 +80,232 @@ } \ } +typedef struct d3d12_vertex_t +{ + float position[2]; + float texcoord[2]; + float color[4]; +} d3d12_vertex_t; + +typedef struct +{ + struct + { + float x, y, w, h; + } pos; + struct + { + float u, v, w, h; + } coords; + struct + { + float scaling; + float rotation; + } params; + UINT32 colors[4]; +} d3d12_sprite_t; + + +typedef struct +{ + D3D12Resource handle; + D3D12Resource upload_buffer; + D3D12_RESOURCE_DESC desc; + /* the first view is srv, the rest are mip levels uavs */ + D3D12_CPU_DESCRIPTOR_HANDLE cpu_descriptor[D3D12_MAX_TEXTURE_DIMENSION_2_TO_EXP - 5]; + D3D12_GPU_DESCRIPTOR_HANDLE gpu_descriptor[D3D12_MAX_TEXTURE_DIMENSION_2_TO_EXP - 5]; + D3D12_GPU_DESCRIPTOR_HANDLE sampler; + D3D12_CPU_DESCRIPTOR_HANDLE rt_view; + D3D12_PLACED_SUBRESOURCE_FOOTPRINT layout; + UINT num_rows; + UINT64 row_size_in_bytes; + UINT64 total_bytes; + d3d12_descriptor_heap_t* srv_heap; + float4_t size_data; + bool dirty; +} d3d12_texture_t; + +typedef struct ALIGN(16) +{ + math_matrix_4x4 mvp; + struct + { + float width; + float height; + } OutputSize; + float time; +} d3d12_uniform_t; + +typedef struct +{ + unsigned cur_mon_id; +#ifdef __WINRT__ + DXGIFactory2 factory; +#else + DXGIFactory1 factory; +#endif + DXGIAdapter adapter; + D3D12Device device; + +#ifdef DEVICE_DEBUG +#ifdef DEBUG + D3D12DebugDevice debug_device; + D3D12InfoQueue info_queue; + D3D12DeviceRemovedExtendedDataSettings device_removed_info; +#endif /* DEBUG */ +#endif /* DEVICE_DEBUG */ + + struct retro_hw_render_interface_d3d12 hw_iface; + D3D12Resource hw_render_texture; + DXGI_FORMAT hw_render_texture_format; + + IDXGIAdapter1 *adapters[D3D12_MAX_GPU_COUNT]; + struct string_list *gpu_list; + + struct + { + D3D12CommandQueue handle; + D3D12CommandAllocator allocator; + D3D12GraphicsCommandList cmd; + D3D12Fence fence; + HANDLE fenceEvent; + UINT64 fenceValue; + } queue; + + struct + { + D3D12RootSignature cs_rootSignature; /* descriptor layout */ + D3D12RootSignature sl_rootSignature; /* descriptor layout */ + D3D12RootSignature rootSignature; /* descriptor layout */ + d3d12_descriptor_heap_t srv_heap; /* ShaderResourceView descriptor heap */ + d3d12_descriptor_heap_t rtv_heap; /* RenderTargetView descriptor heap */ + d3d12_descriptor_heap_t sampler_heap; + } desc; + + struct + { + HANDLE frameLatencyWaitableObject; + DXGISwapChain handle; + D3D12Resource renderTargets[2]; +#ifdef HAVE_DXGI_HDR + d3d12_texture_t back_buffer; +#endif + D3D12_CPU_DESCRIPTOR_HANDLE desc_handles[2]; + D3D12_VIEWPORT viewport; + D3D12_RECT scissorRect; + float clearcolor[4]; + int frame_index; + unsigned swap_interval; +#ifdef HAVE_DXGI_HDR + enum dxgi_swapchain_bit_depth bit_depth; + DXGI_COLOR_SPACE_TYPE color_space; + DXGI_FORMAT formats[DXGI_SWAPCHAIN_BIT_DEPTH_COUNT]; +#endif + } chain; + + struct + { + d3d12_texture_t texture[GFX_MAX_FRAME_HISTORY + 1]; + D3D12Resource ubo; + D3D12_CONSTANT_BUFFER_VIEW_DESC ubo_view; + D3D12Resource vbo; + D3D12_VERTEX_BUFFER_VIEW vbo_view; + D3D12_VIEWPORT viewport; + D3D12_RECT scissorRect; + float4_t output_size; + int rotation; + } frame; + +#ifdef HAVE_DXGI_HDR + struct + { + dxgi_hdr_uniform_t ubo_values; + D3D12Resource ubo; + D3D12_CONSTANT_BUFFER_VIEW_DESC ubo_view; + float max_output_nits; + float min_output_nits; + float max_cll; + float max_fall; + } hdr; +#endif + + struct + { + D3D12Resource vbo; + D3D12_VERTEX_BUFFER_VIEW vbo_view; + d3d12_texture_t texture; + + float alpha; + } menu; + + struct + { + D3D12PipelineStateRef pipe; + D3D12PipelineState pipe_blend; + D3D12PipelineState pipe_noblend; + D3D12PipelineState pipe_font; + D3D12Resource vbo; + D3D12_VERTEX_BUFFER_VIEW vbo_view; + int offset; + int capacity; + } sprites; + +#ifdef HAVE_OVERLAY + struct + { + D3D12Resource vbo; + D3D12_VERTEX_BUFFER_VIEW vbo_view; + d3d12_texture_t* textures; + int count; + } overlays; +#endif + + struct + { + D3D12PipelineState pipe; + D3D12_GPU_DESCRIPTOR_HANDLE sampler; + D3D12Resource buffers[SLANG_CBUFFER_MAX]; + D3D12_CONSTANT_BUFFER_VIEW_DESC buffer_view[SLANG_CBUFFER_MAX]; + d3d12_texture_t rt; + d3d12_texture_t feedback; + D3D12_VIEWPORT viewport; + D3D12_RECT scissorRect; + pass_semantics_t semantics; + uint32_t frame_count; + int32_t frame_direction; + uint32_t frame_time_delta; + float original_fps; + uint32_t rotation; + uint32_t total_subframes; + uint32_t current_subframe; + float core_aspect; + float core_aspect_rot; + D3D12_GPU_DESCRIPTOR_HANDLE textures; + D3D12_GPU_DESCRIPTOR_HANDLE samplers; + } pass[GFX_MAX_SHADERS]; + + struct video_shader* shader_preset; + d3d12_texture_t luts[GFX_MAX_TEXTURES]; + + D3D12PipelineState pipes[GFX_MAX_SHADERS]; + D3D12PipelineState mipmapgen_pipe; + d3d12_uniform_t ubo_values; + D3D12Resource ubo; + D3D12_CONSTANT_BUFFER_VIEW_DESC ubo_view; + DXGI_FORMAT format; + D3D12_GPU_DESCRIPTOR_HANDLE samplers[RARCH_FILTER_MAX][RARCH_WRAP_MAX]; + math_matrix_4x4 mvp, mvp_no_rot, identity; + struct video_viewport vp; + D3D12Resource menu_pipeline_vbo; + D3D12_VERTEX_BUFFER_VIEW menu_pipeline_vbo_view; + +#ifdef DEBUG + D3D12Debug debugController; +#endif + uint32_t flags; + int8_t wait_for_vblank; +} d3d12_video_t; + #define D3D12_ROLLING_SCANLINE_SIMULATION typedef struct diff --git a/gfx/drivers/d3d8.c b/gfx/drivers/d3d8.c index 344c9cdf04..864cf38ae2 100644 --- a/gfx/drivers/d3d8.c +++ b/gfx/drivers/d3d8.c @@ -79,6 +79,50 @@ #define D3D8_ARGB8888_FORMAT D3DFMT_A8R8G8B8 #endif +typedef struct d3d8_video +{ + overlay_t *menu; + void *renderchain_data; + + struct video_viewport vp; + struct video_shader shader; + video_info_t video_info; +#ifdef HAVE_WINDOW + WNDCLASSEX windowClass; +#endif + LPDIRECT3DDEVICE8 dev; + D3DVIEWPORT8 out_vp; + + char *shader_path; + + struct + { + void *buffer; + void *decl; + int size; + int offset; + }menu_display; + + overlay_t *overlays; + size_t overlays_size; + unsigned cur_mon_id; + unsigned dev_rotation; + math_matrix_4x4 mvp; /* float alignment */ + math_matrix_4x4 mvp_rotate; /* float alignment */ + math_matrix_4x4 mvp_transposed; /* float alignment */ + + bool keep_aspect; + bool should_resize; + bool quitting; + bool needs_restore; + bool overlays_enabled; + /* TODO - refactor this away properly. */ + bool resolution_hd_enable; + + /* Only used for Xbox */ + bool widescreen_mode; +} d3d8_video_t; + typedef struct d3d8_renderchain { unsigned pixel_size; diff --git a/gfx/drivers/gl1.c b/gfx/drivers/gl1.c index 2e56333150..ba02c7572f 100644 --- a/gfx/drivers/gl1.c +++ b/gfx/drivers/gl1.c @@ -66,6 +66,53 @@ #include #endif +typedef struct gl1 +{ + struct video_viewport vp; + struct video_coords coords; + math_matrix_4x4 mvp, mvp_no_rot; + + void *ctx_data; + const gfx_ctx_driver_t *ctx_driver; + struct string_list *extensions; + struct video_tex_info tex_info; + void *readback_buffer_screenshot; + GLuint *overlay_tex; + float *overlay_vertex_coord; + float *overlay_tex_coord; + float *overlay_color_coord; + const float *vertex_ptr; + const float *white_color_ptr; + unsigned char *menu_frame; + unsigned char *video_buf; + unsigned char *menu_video_buf; + + int version_major; + int version_minor; + unsigned video_width; + unsigned video_height; + unsigned video_pitch; + unsigned screen_width; + unsigned screen_height; + unsigned menu_width; + unsigned menu_height; + unsigned menu_pitch; + unsigned video_bits; + unsigned menu_bits; + unsigned out_vp_width; + unsigned out_vp_height; + unsigned tex_index; /* For use with PREV. */ + unsigned textures; + unsigned rotation; + unsigned overlays; + + GLuint tex; + GLuint menu_tex; + GLuint texture[GFX_MAX_TEXTURES]; + + uint16_t flags; +} gl1_t; + /* TODO: Move viewport side effects to the caller: it's a source of bugs. */ #define GL1_RASTER_FONT_EMIT(c, vx, vy) \ diff --git a/gfx/drivers/gl3.c b/gfx/drivers/gl3.c index 1df73980bb..17b526ef1b 100644 --- a/gfx/drivers/gl3.c +++ b/gfx/drivers/gl3.c @@ -59,6 +59,85 @@ #include "../gfx_widgets.h" #endif +struct gl3_streamed_texture +{ + GLuint tex; + unsigned width; + unsigned height; +}; + +typedef struct gl3 +{ + const gfx_ctx_driver_t *ctx_driver; + void *ctx_data; + gl3_filter_chain_t *filter_chain; + gl3_filter_chain_t *filter_chain_default; + GLuint *overlay_tex; + float *overlay_vertex_coord; + float *overlay_tex_coord; + float *overlay_color_coord; + GLsync fences[GL_CORE_NUM_FENCES]; + void *readback_buffer_screenshot; + struct scaler_ctx pbo_readback_scaler; + + video_info_t video_info; + video_viewport_t vp; + struct gl3_viewport filter_chain_vp; + struct gl3_streamed_texture textures[GL_CORE_NUM_TEXTURES]; + + GLuint vao; + GLuint menu_texture; + GLuint pbo_readback[GL_CORE_NUM_PBOS]; + + struct + { + GLuint alpha_blend; + GLuint font; + GLuint ribbon; + GLuint ribbon_simple; + GLuint snow_simple; + GLuint snow; + GLuint bokeh; + struct gl3_buffer_locations alpha_blend_loc; + struct gl3_buffer_locations font_loc; + struct gl3_buffer_locations ribbon_loc; + struct gl3_buffer_locations ribbon_simple_loc; + struct gl3_buffer_locations snow_simple_loc; + struct gl3_buffer_locations snow_loc; + struct gl3_buffer_locations bokeh_loc; + } pipelines; + + + unsigned video_width; + unsigned video_height; + unsigned overlays; + unsigned version_major; + unsigned version_minor; + unsigned out_vp_width; + unsigned out_vp_height; + unsigned rotation; + unsigned textures_index; + unsigned scratch_vbo_index; + unsigned fence_count; + unsigned pbo_readback_index; + unsigned hw_render_max_width; + unsigned hw_render_max_height; + GLuint scratch_vbos[GL_CORE_NUM_VBOS]; + GLuint hw_render_texture; + GLuint hw_render_fbo; + GLuint hw_render_rb_ds; + + float menu_texture_alpha; + math_matrix_4x4 mvp; /* float alignment */ + math_matrix_4x4 mvp_yflip; + math_matrix_4x4 mvp_no_rot; + math_matrix_4x4 mvp_no_rot_yflip; + + uint16_t flags; + + bool pbo_readback_valid[GL_CORE_NUM_PBOS]; +} gl3_t; + static const struct video_ortho gl3_default_ortho = {0, 1, 0, 1, -1, 1}; static const float gl3_vertexes[8] = { diff --git a/gfx/drivers/vga_gfx.c b/gfx/drivers/vga_gfx.c index 068bd05071..c7db258e79 100644 --- a/gfx/drivers/vga_gfx.c +++ b/gfx/drivers/vga_gfx.c @@ -37,10 +37,6 @@ #include "../../driver.h" #include "../../verbosity.h" -/* - * FONT DRIVER - */ - typedef struct { const font_renderer_driver_t *font_driver; @@ -48,6 +44,25 @@ typedef struct vga_t *vga; } vga_raster_t; +typedef struct vga +{ + unsigned char *vga_menu_frame; + unsigned char *vga_frame; + + unsigned vga_menu_width; + unsigned vga_menu_height; + unsigned vga_menu_pitch; + unsigned vga_menu_bits; + unsigned vga_video_width; + unsigned vga_video_height; + unsigned vga_video_pitch; + unsigned vga_video_bits; + + bool color; + bool vga_rgb32; +} vga_t; + + static void *vga_font_init(void *data, const char *font_path, float font_size, bool is_threaded) diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index f52be7f58a..2db7a00e2f 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -57,6 +57,174 @@ #define VK_REMAP_TO_TEXFMT(fmt) ((fmt == VK_FORMAT_R5G6B5_UNORM_PACK16) ? VK_FORMAT_R8G8B8A8_UNORM : fmt) +struct vk_per_frame +{ + struct vk_texture texture; /* uint64_t alignment */ + struct vk_texture texture_optimal; + struct vk_buffer_chain vbo; /* uint64_t alignment */ + struct vk_buffer_chain ubo; + struct vk_descriptor_manager descriptor_manager; + + VkCommandPool cmd_pool; /* ptr alignment */ + VkCommandBuffer cmd; /* ptr alignment */ +}; + +struct vk_draw_quad +{ + struct vk_texture *texture; + const math_matrix_4x4 *mvp; + VkPipeline pipeline; /* ptr alignment */ + VkSampler sampler; /* ptr alignment */ + struct vk_color color; /* float alignment */ +}; + +struct vk_draw_triangles +{ + const void *uniform; + const struct vk_buffer_range *vbo; + struct vk_texture *texture; + VkPipeline pipeline; /* ptr alignment */ + VkSampler sampler; /* ptr alignment */ + size_t uniform_size; + unsigned vertices; +}; + +typedef struct vk +{ + vulkan_filter_chain_t *filter_chain; + vulkan_filter_chain_t *filter_chain_default; + vulkan_context_t *context; + void *ctx_data; + const gfx_ctx_driver_t *ctx_driver; + struct vk_per_frame *chain; + struct vk_image *backbuffer; +#ifdef VULKAN_HDR_SWAPCHAIN + VkRenderPass readback_render_pass; + struct vk_image main_buffer; + struct vk_image readback_image; +#endif /* VULKAN_HDR_SWAPCHAIN */ + + unsigned video_width; + unsigned video_height; + + unsigned tex_w, tex_h; + unsigned out_vp_width; + unsigned out_vp_height; + unsigned rotation; + unsigned num_swapchain_images; + unsigned last_valid_index; + + video_info_t video; + + VkFormat tex_fmt; + math_matrix_4x4 mvp, mvp_no_rot, mvp_menu; /* float alignment */ + VkViewport vk_vp; + VkRenderPass render_pass; + struct video_viewport vp; + float translate_x; + float translate_y; + struct vk_per_frame swapchain[VULKAN_MAX_SWAPCHAIN_IMAGES]; + struct vk_image backbuffers[VULKAN_MAX_SWAPCHAIN_IMAGES]; + struct vk_texture default_texture; + + /* Currently active command buffer. */ + VkCommandBuffer cmd; + /* Staging pool for doing buffer transfers on GPU. */ + VkCommandPool staging_pool; + + struct + { + struct scaler_ctx scaler_bgr; + struct scaler_ctx scaler_rgb; + struct vk_texture staging[VULKAN_MAX_SWAPCHAIN_IMAGES]; + } readback; + + struct + { + struct vk_texture *images; + struct vk_vertex *vertex; + unsigned count; + } overlay; + + struct + { + VkPipeline alpha_blend; + VkPipeline font; + VkPipeline rgb565_to_rgba8888; +#ifdef VULKAN_HDR_SWAPCHAIN + VkPipeline hdr; + VkPipeline hdr_to_sdr; /* for readback */ +#endif /* VULKAN_HDR_SWAPCHAIN */ + VkDescriptorSetLayout set_layout; + VkPipelineLayout layout; + VkPipelineCache cache; + } pipelines; + + struct + { + VkPipeline pipelines[8 * 2]; + struct vk_texture blank_texture; + } display; + +#ifdef VULKAN_HDR_SWAPCHAIN + struct + { + struct vk_buffer ubo; + float max_output_nits; + float min_output_nits; + float max_cll; + float max_fall; + } hdr; +#endif /* VULKAN_HDR_SWAPCHAIN */ + + struct + { + struct vk_texture textures[VULKAN_MAX_SWAPCHAIN_IMAGES]; + struct vk_texture textures_optimal[VULKAN_MAX_SWAPCHAIN_IMAGES]; + unsigned last_index; + float alpha; + bool dirty[VULKAN_MAX_SWAPCHAIN_IMAGES]; + } menu; + + struct + { + VkSampler linear; + VkSampler nearest; + VkSampler mipmap_nearest; + VkSampler mipmap_linear; + } samplers; + + struct + { + const struct retro_vulkan_image *image; + VkPipelineStageFlags *wait_dst_stages; + VkCommandBuffer *cmd; + VkSemaphore *semaphores; + VkSemaphore signal_semaphore; /* ptr alignment */ + + struct retro_hw_render_interface_vulkan iface; + + unsigned capacity_cmd; + unsigned last_width; + unsigned last_height; + uint32_t num_semaphores; + uint32_t num_cmd; + uint32_t src_queue_family; + + } hw; + + struct + { + uint64_t dirty; + VkPipeline pipeline; /* ptr alignment */ + VkImageView view; /* ptr alignment */ + VkSampler sampler; /* ptr alignment */ + math_matrix_4x4 mvp; + VkRect2D scissor; /* int32_t alignment */ + } tracker; + uint32_t flags; +} vk_t; + typedef struct { vk_t *vk;