diff --git a/gfx/common/d3d11_defines.h b/gfx/common/d3d11_defines.h index 49bf2472c9..27218cc538 100644 --- a/gfx/common/d3d11_defines.h +++ b/gfx/common/d3d11_defines.h @@ -29,7 +29,6 @@ #include #include #include -#include #include "../drivers_shader/slang_process.h" @@ -127,42 +126,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; - -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 +134,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_common.c b/gfx/common/d3d12_common.c index 1d50ac5b32..8c4940d2ce 100644 --- a/gfx/common/d3d12_common.c +++ b/gfx/common/d3d12_common.c @@ -19,10 +19,12 @@ #include -#include "d3d_common.h" +#include +#include + #include "d3d12_defines.h" -#include "dxgi_common.h" #include "d3dcompiler_common.h" +#include "dxgi_common.h" #if defined(HAVE_DYLIB) && !defined(__WINRT__) #include diff --git a/gfx/common/d3d12_defines.h b/gfx/common/d3d12_defines.h index fbc2f53c50..eb077ef554 100644 --- a/gfx/common/d3d12_defines.h +++ b/gfx/common/d3d12_defines.h @@ -24,9 +24,6 @@ #include #include "dxgi_common.h" -#include - -#include #include "../common/d3dcompiler_common.h" #include "../drivers_shader/slang_process.h" @@ -116,61 +113,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 */ - D3D12_DESCRIPTOR_HEAP_DESC desc; - D3D12_CPU_DESCRIPTOR_HANDLE cpu; /* descriptor */ - D3D12_GPU_DESCRIPTOR_HANDLE gpu; /* descriptor */ - UINT stride; - bool* map; - 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 +121,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/d3d9_common.h b/gfx/common/d3d9_common.h index 1340fee856..0ccbdd6959 100644 --- a/gfx/common/d3d9_common.h +++ b/gfx/common/d3d9_common.h @@ -21,6 +21,9 @@ #include #include +#ifndef _XBOX +#define WIN32_LEAN_AND_MEAN +#endif #include #include "d3d_common.h" diff --git a/gfx/common/gl1_defines.h b/gfx/common/gl1_defines.h index 918e46ddd2..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 @@ -69,51 +67,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..671fd93639 100644 --- a/gfx/common/gl3_defines.h +++ b/gfx/common/gl3_defines.h @@ -27,13 +27,6 @@ #endif #include -#include -#include -#include -#include - -#include "../video_driver.h" -#include "../drivers_shader/shader_gl3.h" RETRO_BEGIN_DECLS @@ -60,86 +53,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/vulkan_common.h b/gfx/common/vulkan_common.h index a83dff025c..1368dd025a 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -328,28 +327,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; @@ -446,28 +423,6 @@ struct vk_image 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 */ @@ -516,174 +471,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/common/win32_common.h b/gfx/common/win32_common.h index f044d2c381..cdc665ecf8 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -40,7 +40,11 @@ #include "../../ui/drivers/ui_win32_resource.h" #include "../../ui/drivers/ui_win32.h" -#if (defined(_MSC_VER) && (_MSC_VER >= 1400)) || defined(__MINGW32__) +#if (defined(_MSC_VER) && (_MSC_VER < 1400)) +#ifdef HAVE_CLIP_WINDOW +#undef HAVE_CLIP_WINDOW +#endif +#else #ifndef HAVE_CLIP_WINDOW #define HAVE_CLIP_WINDOW #endif diff --git a/gfx/drivers/d3d11.c b/gfx/drivers/d3d11.c index f24ccbf278..cde98d8152 100644 --- a/gfx/drivers/d3d11.c +++ b/gfx/drivers/d3d11.c @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include @@ -66,6 +68,179 @@ #include "../drivers_shader/slang_process.h" #endif +typedef struct d3d11_vertex_t +{ + float position[2]; + float texcoord[2]; + 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; + +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; + #ifdef __WINRT__ #include "../../uwp/uwp_func.h" #else diff --git a/gfx/drivers/d3d12.c b/gfx/drivers/d3d12.c index 72f062b4df..fc0849a361 100644 --- a/gfx/drivers/d3d12.c +++ b/gfx/drivers/d3d12.c @@ -22,21 +22,18 @@ */ #define CINTERFACE -#define WIN32_LEAN_AND_MEAN +#define COBJMACROS #include #include #include -#include - #include #include #include +#include #include -#include - #ifdef HAVE_MENU #include "../../menu/menu_driver.h" #endif @@ -57,10 +54,6 @@ #include "../../state_manager.h" #endif -#include "../common/d3d_common.h" -#include "../common/dxgi_common.h" -#include "../common/d3d12_defines.h" -#include "../common/d3dcompiler_common.h" #ifdef HAVE_SLANG #include "../drivers_shader/slang_process.h" #endif @@ -69,6 +62,253 @@ #include "../../uwp/uwp_func.h" #endif +#include +#include + +#include + +#include "../common/d3d_common.h" +#include "../common/d3d12_defines.h" +#include "../common/dxgi_common.h" +#include "../common/d3dcompiler_common.h" + +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 */ + D3D12_DESCRIPTOR_HEAP_DESC desc; + D3D12_CPU_DESCRIPTOR_HANDLE cpu; /* descriptor */ + D3D12_GPU_DESCRIPTOR_HANDLE gpu; /* descriptor */ + UINT stride; + bool* map; + 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; + + +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_GFX_SYNC() \ { \ D3D12Fence fence = d3d12->queue.fence; \ 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/d3d9hlsl.c b/gfx/drivers/d3d9hlsl.c index cb5865fbc4..9dff66079f 100644 --- a/gfx/drivers/d3d9hlsl.c +++ b/gfx/drivers/d3d9hlsl.c @@ -41,6 +41,9 @@ #include #include +#ifndef _XBOX +#define WIN32_LEAN_AND_MEAN +#endif #include #include diff --git a/gfx/drivers/gl1.c b/gfx/drivers/gl1.c index 2e56333150..47e764e3b4 100644 --- a/gfx/drivers/gl1.c +++ b/gfx/drivers/gl1.c @@ -34,6 +34,8 @@ #include #include #include +#include +#include #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -66,6 +68,54 @@ #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..3b82307365 100644 --- a/gfx/drivers/gl3.c +++ b/gfx/drivers/gl3.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include "../../configuration.h" @@ -42,6 +43,9 @@ #include "../../state_manager.h" #endif +#include "../video_driver.h" +#include "../drivers_shader/shader_gl3.h" + #include "../../retroarch.h" #include "../../verbosity.h" @@ -59,6 +63,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/vulkan.c b/gfx/drivers/vulkan.c index f52be7f58a..7fe3e9bf1a 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -57,6 +58,219 @@ #define VK_REMAP_TO_TEXFMT(fmt) ((fmt == VK_FORMAT_R5G6B5_UNORM_PACK16) ? VK_FORMAT_R8G8B8A8_UNORM : fmt) +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 */ + 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; +}; + +#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 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; diff --git a/gfx/drivers_shader/shader_vulkan.cpp b/gfx/drivers_shader/shader_vulkan.cpp index b33fc0ec66..752b25970c 100644 --- a/gfx/drivers_shader/shader_vulkan.cpp +++ b/gfx/drivers_shader/shader_vulkan.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/gfx/include/dxsdk/d3d12.h b/gfx/include/dxsdk/d3d12.h index 6fcbcd7f7f..237a82c87d 100644 --- a/gfx/include/dxsdk/d3d12.h +++ b/gfx/include/dxsdk/d3d12.h @@ -9848,9 +9848,9 @@ HRESULT WINAPI D3D12GetDebugInterface( _In_ REFIID riid, _COM_Outptr_opt_ void** // -------------------------------------------------------------------------------------------------------------------------------- HRESULT WINAPI D3D12EnableExperimentalFeatures( UINT NumFeatures, - __in_ecount(NumFeatures) const IID* pIIDs, - __in_ecount_opt(NumFeatures) void* pConfigurationStructs, - __in_ecount_opt(NumFeatures) UINT* pConfigurationStructSizes); + SAL__in_ecount(NumFeatures) const IID* pIIDs, + SAL__in_ecount_opt(NumFeatures) void* pConfigurationStructs, + SAL__in_ecount_opt(NumFeatures) UINT* pConfigurationStructSizes); // -------------------------------------------------------------------------------------------------------------------------------- // Experimental Feature: D3D12ExperimentalShaderModels diff --git a/input/input_keymaps.h b/input/input_keymaps.h index fecbe00abd..6e7347e5e5 100644 --- a/input/input_keymaps.h +++ b/input/input_keymaps.h @@ -26,168 +26,162 @@ RETRO_BEGIN_DECLS -#if defined(_WIN32) && _WIN32_WINNT >= 0x0501 && !defined(__WINRT__) -enum winraw_scancodes -{ - SC_ESCAPE = 0x01, - SC_1 = 0x02, - SC_2 = 0x03, - SC_3 = 0x04, - SC_4 = 0x05, - SC_5 = 0x06, - SC_6 = 0x07, - SC_7 = 0x08, - SC_8 = 0x09, - SC_9 = 0x0A, - SC_0 = 0x0B, - SC_MINUS = 0x0C, - SC_EQUALS = 0x0D, - SC_BACKSPACE = 0x0E, - SC_TAB = 0x0F, - SC_q = 0x10, - SC_w = 0x11, - SC_e = 0x12, - SC_r = 0x13, - SC_t = 0x14, - SC_y = 0x15, - SC_u = 0x16, - SC_i = 0x17, - SC_o = 0x18, - SC_p = 0x19, - SC_LEFTBRACKET = 0x1A, - SC_RIGHTBRACKET = 0x1B, - SC_RETURN = 0x1C, - SC_LCTRL = 0x1D, - SC_a = 0x1E, - SC_s = 0x1F, - SC_d = 0x20, - SC_f = 0x21, - SC_g = 0x22, - SC_h = 0x23, - SC_j = 0x24, - SC_k = 0x25, - SC_l = 0x26, - SC_SEMICOLON = 0x27, - SC_APOSTROPHE = 0x28, - SC_BACKQUOTE = 0x29, - SC_LSHIFT = 0x2A, - SC_BACKSLASH = 0x2B, - SC_z = 0x2C, - SC_x = 0x2D, - SC_c = 0x2E, - SC_v = 0x2F, - SC_b = 0x30, - SC_n = 0x31, - SC_m = 0x32, - SC_COMMA = 0x33, - SC_PERIOD = 0x34, - SC_SLASH = 0x35, - SC_RSHIFT = 0x36, - SC_KP_MULTIPLY = 0x37, - SC_LALT = 0x38, - SC_SPACE = 0x39, - SC_CAPSLOCK = 0x3A, - SC_F1 = 0x3B, - SC_F2 = 0x3C, - SC_F3 = 0x3D, - SC_F4 = 0x3E, - SC_F5 = 0x3F, - SC_F6 = 0x40, - SC_F7 = 0x41, - SC_F8 = 0x42, - SC_F9 = 0x43, - SC_F10 = 0x44, - SC_NUMLOCK = 0x45, - SC_SCROLLLOCK = 0x46, - SC_KP7 = 0x47, - SC_KP8 = 0x48, - SC_KP9 = 0x49, - SC_KP_MINUS = 0x4A, - SC_KP4 = 0x4B, - SC_KP5 = 0x4C, - SC_KP6 = 0x4D, - SC_KP_PLUS = 0x4E, - SC_KP1 = 0x4F, - SC_KP2 = 0x50, - SC_KP3 = 0x51, - SC_KP0 = 0x52, - SC_KP_PERIOD = 0x53, - SC_ALT_PRINT = 0x54, - SC_ANGLEBRACKET = 0x56, - SC_F11 = 0x57, - SC_F12 = 0x58, - SC_OEM_1 = 0x5a, - SC_OEM_2 = 0x5b, - SC_OEM_3 = 0x5c, - SC_ERASE_EOF = 0x5d, - SC_CLEAR = 0x5d, - SC_OEM_4 = 0x5e, - SC_OEM_5 = 0x5f, - SC_HELP = 0x63, - SC_F13 = 0x64, - SC_F14 = 0x65, - SC_F15 = 0x66, - SC_F16 = 0x67, - SC_F17 = 0x68, - SC_F18 = 0x69, - SC_F19 = 0x6a, - SC_F20 = 0x6b, - SC_F21 = 0x6c, - SC_F22 = 0x6d, - SC_F23 = 0x6e, - SC_OEM_6 = 0x6f, - SC_KATAKANA = 0x70, - SC_OEM_7 = 0x71, - SC_F24 = 0x76, - SC_SBCSCHAR = 0x77, - SC_CONVERT = 0x79, - SC_NONCONVERT = 0x7B, - - SC_MEDIA_PREV = 0xE010, - SC_MEDIA_NEXT = 0xE019, - SC_KP_ENTER = 0xE01C, - SC_RCTRL = 0xE01D, - SC_VOLUME_MUTE = 0xE020, - SC_LAUNCH_APP2 = 0xE021, - SC_MEDIA_PLAY = 0xE022, - SC_MEDIA_STOP = 0xE024, - SC_VOLUME_DOWN = 0xE02E, - SC_VOLUME_UP = 0xE030, - SC_BROWSER_HOME = 0xE032, - SC_KP_DIVIDE = 0xE035, - SC_PRINT = 0xE037, - SC_RALT = 0xE038, - SC_BREAK = 0xE046, - SC_HOME = 0xE047, - SC_UP = 0xE048, - SC_PAGEUP = 0xE049, - SC_LEFT = 0xE04B, - SC_RIGHT = 0xE04D, - SC_END = 0xE04F, - SC_DOWN = 0xE050, - SC_PAGEDOWN = 0xE051, - SC_INSERT = 0xE052, - SC_DELETE = 0xE053, - SC_LSUPER = 0xE05B, - SC_RSUPER = 0xE05C, - SC_MENU = 0xE05D, - SC_POWER = 0xE05E, - SC_SLEEP = 0xE05F, - SC_WAKE = 0xE063, - SC_BROWSER_SEARCH = 0xE065, - SC_BROWSER_FAVORITES = 0xE066, - SC_BROWSER_REFRESH = 0xE067, - SC_BROWSER_STOP = 0xE068, - SC_BROWSER_FORWARD = 0xE069, - SC_BROWSER_BACK = 0xE06A, - SC_LAUNCH_APP1 = 0xE06B, - SC_LAUNCH_EMAIL = 0xE06C, - SC_LAUNCH_MEDIA = 0xE06D, - - SC_PAUSE = 0xFFFE/*0xE11D45*/, - SC_LAST = 0xFFFF -}; -#endif +/* Windows raw scancodes */ +#define SC_ESCAPE 0x01 +#define SC_1 0x02 +#define SC_2 0x03 +#define SC_3 0x04 +#define SC_4 0x05 +#define SC_5 0x06 +#define SC_6 0x07 +#define SC_7 0x08 +#define SC_8 0x09 +#define SC_9 0x0A +#define SC_0 0x0B +#define SC_MINUS 0x0C +#define SC_EQUALS 0x0D +#define SC_BACKSPACE 0x0E +#define SC_TAB 0x0F +#define SC_q 0x10 +#define SC_w 0x11 +#define SC_e 0x12 +#define SC_r 0x13 +#define SC_t 0x14 +#define SC_y 0x15 +#define SC_u 0x16 +#define SC_i 0x17 +#define SC_o 0x18 +#define SC_p 0x19 +#define SC_LEFTBRACKET 0x1A +#define SC_RIGHTBRACKET 0x1B +#define SC_RETURN 0x1C +#define SC_LCTRL 0x1D +#define SC_a 0x1E +#define SC_s 0x1F +#define SC_d 0x20 +#define SC_f 0x21 +#define SC_g 0x22 +#define SC_h 0x23 +#define SC_j 0x24 +#define SC_k 0x25 +#define SC_l 0x26 +#define SC_SEMICOLON 0x27 +#define SC_APOSTROPHE 0x28 +#define SC_BACKQUOTE 0x29 +#define SC_LSHIFT 0x2A +#define SC_BACKSLASH 0x2B +#define SC_z 0x2C +#define SC_x 0x2D +#define SC_c 0x2E +#define SC_v 0x2F +#define SC_b 0x30 +#define SC_n 0x31 +#define SC_m 0x32 +#define SC_COMMA 0x33 +#define SC_PERIOD 0x34 +#define SC_SLASH 0x35 +#define SC_RSHIFT 0x36 +#define SC_KP_MULTIPLY 0x37 +#define SC_LALT 0x38 +#define SC_SPACE 0x39 +#define SC_CAPSLOCK 0x3A +#define SC_F1 0x3B +#define SC_F2 0x3C +#define SC_F3 0x3D +#define SC_F4 0x3E +#define SC_F5 0x3F +#define SC_F6 0x40 +#define SC_F7 0x41 +#define SC_F8 0x42 +#define SC_F9 0x43 +#define SC_F10 0x44 +#define SC_NUMLOCK 0x45 +#define SC_SCROLLLOCK 0x46 +#define SC_KP7 0x47 +#define SC_KP8 0x48 +#define SC_KP9 0x49 +#define SC_KP_MINUS 0x4A +#define SC_KP4 0x4B +#define SC_KP5 0x4C +#define SC_KP6 0x4D +#define SC_KP_PLUS 0x4E +#define SC_KP1 0x4F +#define SC_KP2 0x50 +#define SC_KP3 0x51 +#define SC_KP0 0x52 +#define SC_KP_PERIOD 0x53 +#define SC_ALT_PRINT 0x54 +#define SC_ANGLEBRACKET 0x56 +#define SC_F11 0x57 +#define SC_F12 0x58 +#define SC_OEM_1 0x5a +#define SC_OEM_2 0x5b +#define SC_OEM_3 0x5c +#define SC_ERASE_EOF 0x5d +#define SC_CLEAR 0x5d +#define SC_OEM_4 0x5e +#define SC_OEM_5 0x5f +#define SC_HELP 0x63 +#define SC_F13 0x64 +#define SC_F14 0x65 +#define SC_F15 0x66 +#define SC_F16 0x67 +#define SC_F17 0x68 +#define SC_F18 0x69 +#define SC_F19 0x6a +#define SC_F20 0x6b +#define SC_F21 0x6c +#define SC_F22 0x6d +#define SC_F23 0x6e +#define SC_OEM_6 0x6f +#define SC_KATAKANA 0x70 +#define SC_OEM_7 0x71 +#define SC_F24 0x76 +#define SC_SBCSCHAR 0x77 +#define SC_CONVERT 0x79 +#define SC_NONCONVERT 0x7B +#define SC_MEDIA_PREV 0xE010 +#define SC_MEDIA_NEXT 0xE019 +#define SC_KP_ENTER 0xE01C +#define SC_RCTRL 0xE01D +#define SC_VOLUME_MUTE 0xE020 +#define SC_LAUNCH_APP2 0xE021 +#define SC_MEDIA_PLAY 0xE022 +#define SC_MEDIA_STOP 0xE024 +#define SC_VOLUME_DOWN 0xE02E +#define SC_VOLUME_UP 0xE030 +#define SC_BROWSER_HOME 0xE032 +#define SC_KP_DIVIDE 0xE035 +#define SC_PRINT 0xE037 +#define SC_RALT 0xE038 +#define SC_BREAK 0xE046 +#define SC_HOME 0xE047 +#define SC_UP 0xE048 +#define SC_PAGEUP 0xE049 +#define SC_LEFT 0xE04B +#define SC_RIGHT 0xE04D +#define SC_END 0xE04F +#define SC_DOWN 0xE050 +#define SC_PAGEDOWN 0xE051 +#define SC_INSERT 0xE052 +#define SC_DELETE 0xE053 +#define SC_LSUPER 0xE05B +#define SC_RSUPER 0xE05C +#define SC_MENU 0xE05D +#define SC_POWER 0xE05E +#define SC_SLEEP 0xE05F +#define SC_WAKE 0xE063 +#define SC_BROWSER_SEARCH 0xE065 +#define SC_BROWSER_FAVORITES 0xE066 +#define SC_BROWSER_REFRESH 0xE067 +#define SC_BROWSER_STOP 0xE068 +#define SC_BROWSER_FORWARD 0xE069 +#define SC_BROWSER_BACK 0xE06A +#define SC_LAUNCH_APP1 0xE06B +#define SC_LAUNCH_EMAIL 0xE06C +#define SC_LAUNCH_MEDIA 0xE06D +#define SC_PAUSE 0xFFFE /*0xE11D45*/ +#define SC_LAST 0xFFF struct rarch_key_map { diff --git a/libretro-common/include/libretro_d3d.h b/libretro-common/include/libretro_d3d.h index 8e1824323b..c449103a2e 100644 --- a/libretro-common/include/libretro_d3d.h +++ b/libretro-common/include/libretro_d3d.h @@ -30,58 +30,11 @@ #include "libretro.h" #ifdef HAVE_D3D11 - -#include -#include - -#define RETRO_HW_RENDER_INTERFACE_D3D11_VERSION 1 - -struct retro_hw_render_interface_d3d11 -{ - /* Must be set to RETRO_HW_RENDER_INTERFACE_D3D11. */ - enum retro_hw_render_interface_type interface_type; - /* Must be set to RETRO_HW_RENDER_INTERFACE_D3D11_VERSION. */ - unsigned interface_version; - - /* Opaque handle to the d3d11 backend in the frontend - * which must be passed along to all function pointers - * in this interface. - */ - void* handle; - ID3D11Device *device; - ID3D11DeviceContext *context; - D3D_FEATURE_LEVEL featureLevel; - pD3DCompile D3DCompile; -}; - +#include "libretro_d3d11.h" #endif #ifdef HAVE_D3D12 - -#include -#include - -#define RETRO_HW_RENDER_INTERFACE_D3D12_VERSION 1 - -struct retro_hw_render_interface_d3d12 -{ - /* Must be set to RETRO_HW_RENDER_INTERFACE_D3D12. */ - enum retro_hw_render_interface_type interface_type; - /* Must be set to RETRO_HW_RENDER_INTERFACE_D3D12_VERSION. */ - unsigned interface_version; - - /* Opaque handle to the d3d12 backend in the frontend - * which must be passed along to all function pointers - * in this interface. - */ - void* handle; - ID3D12Device *device; - ID3D12CommandQueue *queue; - pD3DCompile D3DCompile; - D3D12_RESOURCE_STATES required_state; - void (*set_texture)(void* handle, ID3D12Resource* texture, DXGI_FORMAT format); -}; - +#include "libretro_d3d12.h" #endif #endif /* LIBRETRO_DIRECT3D_H__ */ diff --git a/libretro-common/include/libretro_d3d11.h b/libretro-common/include/libretro_d3d11.h new file mode 100644 index 0000000000..1bb787a71f --- /dev/null +++ b/libretro-common/include/libretro_d3d11.h @@ -0,0 +1,53 @@ +/* Copyright (C) 2010-2020 The RetroArch team + * + * --------------------------------------------------------------------------------------------- + * The following license statement only applies to this libretro API header (libretro_d3d.h) + * --------------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the + * "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LIBRETRO_DIRECT3D11_H__ +#define LIBRETRO_DIRECT3D11_H__ + +#include +#include + +#define RETRO_HW_RENDER_INTERFACE_D3D11_VERSION 1 + +struct retro_hw_render_interface_d3d11 +{ + /* Must be set to RETRO_HW_RENDER_INTERFACE_D3D11. */ + enum retro_hw_render_interface_type interface_type; + /* Must be set to RETRO_HW_RENDER_INTERFACE_D3D11_VERSION. */ + unsigned interface_version; + + /* Opaque handle to the d3d11 backend in the frontend + * which must be passed along to all function pointers + * in this interface. + */ + void* handle; + ID3D11Device *device; + ID3D11DeviceContext *context; + D3D_FEATURE_LEVEL featureLevel; + pD3DCompile D3DCompile; +}; + +#endif /* LIBRETRO_DIRECT3D11_H__ */ diff --git a/libretro-common/include/libretro_d3d12.h b/libretro-common/include/libretro_d3d12.h new file mode 100644 index 0000000000..e9d1dd3ed3 --- /dev/null +++ b/libretro-common/include/libretro_d3d12.h @@ -0,0 +1,54 @@ +/* Copyright (C) 2010-2020 The RetroArch team + * + * --------------------------------------------------------------------------------------------- + * The following license statement only applies to this libretro API header (libretro_d3d.h) + * --------------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the + * "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LIBRETRO_DIRECT3D12_H__ +#define LIBRETRO_DIRECT3D12_H__ + +#include +#include + +#define RETRO_HW_RENDER_INTERFACE_D3D12_VERSION 1 + +struct retro_hw_render_interface_d3d12 +{ + /* Must be set to RETRO_HW_RENDER_INTERFACE_D3D12. */ + enum retro_hw_render_interface_type interface_type; + /* Must be set to RETRO_HW_RENDER_INTERFACE_D3D12_VERSION. */ + unsigned interface_version; + + /* Opaque handle to the d3d12 backend in the frontend + * which must be passed along to all function pointers + * in this interface. + */ + void* handle; + ID3D12Device *device; + ID3D12CommandQueue *queue; + pD3DCompile D3DCompile; + D3D12_RESOURCE_STATES required_state; + void (*set_texture)(void* handle, ID3D12Resource* texture, DXGI_FORMAT format); +}; + +#endif /* LIBRETRO_DIRECT3D12_H__ */