├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ ├── artifacts.yml │ └── test-build-windows.yml ├── .gitmodules ├── LICENSE ├── README.md ├── RELEASE ├── VP_DXVK_requirements.json ├── build-win32.txt ├── build-win64.txt ├── dxvk.conf ├── include ├── native │ ├── meson.build │ ├── windows │ │ ├── oaidl.h │ │ ├── objbase.h │ │ ├── ocidl.h │ │ ├── ole2.h │ │ ├── poppack.h │ │ ├── pshpack4.h │ │ ├── rpc.h │ │ ├── rpcndr.h │ │ ├── unknwn.h │ │ ├── windows.h │ │ └── windows_base.h │ └── wsi │ │ ├── native_glfw.h │ │ ├── native_sdl2.h │ │ └── native_wsi.h └── openvr │ ├── LICENSE │ └── openvr.hpp ├── meson.build ├── meson_options.txt ├── package-native.sh ├── package-release.sh ├── src ├── d3d10 │ ├── d3d10_blend.cpp │ ├── d3d10_blend.h │ ├── d3d10_buffer.cpp │ ├── d3d10_buffer.h │ ├── d3d10_core.cpp │ ├── d3d10_depth_stencil.cpp │ ├── d3d10_depth_stencil.h │ ├── d3d10_device.cpp │ ├── d3d10_device.h │ ├── d3d10_include.h │ ├── d3d10_input_layout.cpp │ ├── d3d10_input_layout.h │ ├── d3d10_multithread.cpp │ ├── d3d10_multithread.h │ ├── d3d10_query.cpp │ ├── d3d10_query.h │ ├── d3d10_rasterizer.cpp │ ├── d3d10_rasterizer.h │ ├── d3d10_sampler.cpp │ ├── d3d10_sampler.h │ ├── d3d10_shader.h │ ├── d3d10_texture.cpp │ ├── d3d10_texture.h │ ├── d3d10_util.cpp │ ├── d3d10_util.h │ ├── d3d10_view_dsv.cpp │ ├── d3d10_view_dsv.h │ ├── d3d10_view_rtv.cpp │ ├── d3d10_view_rtv.h │ ├── d3d10_view_srv.cpp │ ├── d3d10_view_srv.h │ ├── d3d10core.def │ ├── d3d10core.sym │ ├── meson.build │ └── version10_core.rc ├── d3d11 │ ├── d3d11.def │ ├── d3d11.sym │ ├── d3d11_annotation.cpp │ ├── d3d11_annotation.h │ ├── d3d11_blend.cpp │ ├── d3d11_blend.h │ ├── d3d11_buffer.cpp │ ├── d3d11_buffer.h │ ├── d3d11_class_linkage.cpp │ ├── d3d11_class_linkage.h │ ├── d3d11_cmd.h │ ├── d3d11_cmdlist.cpp │ ├── d3d11_cmdlist.h │ ├── d3d11_context.cpp │ ├── d3d11_context.h │ ├── d3d11_context_def.cpp │ ├── d3d11_context_def.h │ ├── d3d11_context_ext.cpp │ ├── d3d11_context_ext.h │ ├── d3d11_context_imm.cpp │ ├── d3d11_context_imm.h │ ├── d3d11_context_state.h │ ├── d3d11_cuda.cpp │ ├── d3d11_cuda.h │ ├── d3d11_depth_stencil.cpp │ ├── d3d11_depth_stencil.h │ ├── d3d11_device.cpp │ ├── d3d11_device.h │ ├── d3d11_device_child.h │ ├── d3d11_enums.cpp │ ├── d3d11_enums.h │ ├── d3d11_features.cpp │ ├── d3d11_features.h │ ├── d3d11_fence.cpp │ ├── d3d11_fence.h │ ├── d3d11_gdi.cpp │ ├── d3d11_gdi.h │ ├── d3d11_include.h │ ├── d3d11_initializer.cpp │ ├── d3d11_initializer.h │ ├── d3d11_input_layout.cpp │ ├── d3d11_input_layout.h │ ├── d3d11_interfaces.h │ ├── d3d11_interop.cpp │ ├── d3d11_interop.h │ ├── d3d11_main.cpp │ ├── d3d11_on_12.cpp │ ├── d3d11_on_12.h │ ├── d3d11_on_12_interfaces.h │ ├── d3d11_options.cpp │ ├── d3d11_options.h │ ├── d3d11_query.cpp │ ├── d3d11_query.h │ ├── d3d11_rasterizer.cpp │ ├── d3d11_rasterizer.h │ ├── d3d11_resource.cpp │ ├── d3d11_resource.h │ ├── d3d11_sampler.cpp │ ├── d3d11_sampler.h │ ├── d3d11_shader.cpp │ ├── d3d11_shader.h │ ├── d3d11_state.cpp │ ├── d3d11_state.h │ ├── d3d11_state_object.cpp │ ├── d3d11_state_object.h │ ├── d3d11_swapchain.cpp │ ├── d3d11_swapchain.h │ ├── d3d11_texture.cpp │ ├── d3d11_texture.h │ ├── d3d11_util.cpp │ ├── d3d11_util.h │ ├── d3d11_video.cpp │ ├── d3d11_video.h │ ├── d3d11_view.h │ ├── d3d11_view_dsv.cpp │ ├── d3d11_view_dsv.h │ ├── d3d11_view_rtv.cpp │ ├── d3d11_view_rtv.h │ ├── d3d11_view_srv.cpp │ ├── d3d11_view_srv.h │ ├── d3d11_view_uav.cpp │ ├── d3d11_view_uav.h │ ├── meson.build │ ├── shaders │ │ ├── d3d11_video_blit_frag.frag │ │ └── d3d11_video_blit_vert.vert │ └── version.rc ├── d3d8 │ ├── d3d8.def │ ├── d3d8.sym │ ├── d3d8_batch.h │ ├── d3d8_buffer.h │ ├── d3d8_caps.h │ ├── d3d8_d3d9_util.h │ ├── d3d8_device.cpp │ ├── d3d8_device.h │ ├── d3d8_device_child.h │ ├── d3d8_format.h │ ├── d3d8_include.h │ ├── d3d8_interface.cpp │ ├── d3d8_interface.h │ ├── d3d8_main.cpp │ ├── d3d8_options.cpp │ ├── d3d8_options.h │ ├── d3d8_resource.h │ ├── d3d8_shader.cpp │ ├── d3d8_shader.h │ ├── d3d8_state_block.cpp │ ├── d3d8_state_block.h │ ├── d3d8_subresource.h │ ├── d3d8_surface.cpp │ ├── d3d8_surface.h │ ├── d3d8_swapchain.h │ ├── d3d8_texture.h │ ├── d3d8_volume.h │ ├── d3d8_wrapped_object.h │ ├── meson.build │ └── version.rc ├── d3d9 │ ├── d3d9.def │ ├── d3d9.sym │ ├── d3d9_adapter.cpp │ ├── d3d9_adapter.h │ ├── d3d9_annotation.cpp │ ├── d3d9_annotation.h │ ├── d3d9_bridge.cpp │ ├── d3d9_bridge.h │ ├── d3d9_buffer.cpp │ ├── d3d9_buffer.h │ ├── d3d9_caps.h │ ├── d3d9_common_buffer.cpp │ ├── d3d9_common_buffer.h │ ├── d3d9_common_texture.cpp │ ├── d3d9_common_texture.h │ ├── d3d9_constant_buffer.cpp │ ├── d3d9_constant_buffer.h │ ├── d3d9_constant_layout.h │ ├── d3d9_constant_set.h │ ├── d3d9_cursor.cpp │ ├── d3d9_cursor.h │ ├── d3d9_device.cpp │ ├── d3d9_device.h │ ├── d3d9_device_child.h │ ├── d3d9_fixed_function.cpp │ ├── d3d9_fixed_function.h │ ├── d3d9_format.cpp │ ├── d3d9_format.h │ ├── d3d9_format_helpers.cpp │ ├── d3d9_format_helpers.h │ ├── d3d9_hud.cpp │ ├── d3d9_hud.h │ ├── d3d9_include.h │ ├── d3d9_initializer.cpp │ ├── d3d9_initializer.h │ ├── d3d9_interface.cpp │ ├── d3d9_interface.h │ ├── d3d9_interfaces.h │ ├── d3d9_interop.cpp │ ├── d3d9_interop.h │ ├── d3d9_main.cpp │ ├── d3d9_mem.cpp │ ├── d3d9_mem.h │ ├── d3d9_monitor.cpp │ ├── d3d9_monitor.h │ ├── d3d9_multithread.cpp │ ├── d3d9_multithread.h │ ├── d3d9_names.cpp │ ├── d3d9_names.h │ ├── d3d9_on_12.cpp │ ├── d3d9_on_12.h │ ├── d3d9_options.cpp │ ├── d3d9_options.h │ ├── d3d9_query.cpp │ ├── d3d9_query.h │ ├── d3d9_resource.h │ ├── d3d9_sampler.cpp │ ├── d3d9_sampler.h │ ├── d3d9_shader.cpp │ ├── d3d9_shader.h │ ├── d3d9_shader_validator.h │ ├── d3d9_spec_constants.h │ ├── d3d9_state.cpp │ ├── d3d9_state.h │ ├── d3d9_stateblock.cpp │ ├── d3d9_stateblock.h │ ├── d3d9_subresource.h │ ├── d3d9_surface.cpp │ ├── d3d9_surface.h │ ├── d3d9_swapchain.cpp │ ├── d3d9_swapchain.h │ ├── d3d9_swvp_emu.cpp │ ├── d3d9_swvp_emu.h │ ├── d3d9_texture.cpp │ ├── d3d9_texture.h │ ├── d3d9_util.cpp │ ├── d3d9_util.h │ ├── d3d9_vertex_declaration.cpp │ ├── d3d9_vertex_declaration.h │ ├── d3d9_volume.cpp │ ├── d3d9_volume.h │ ├── d3d9_window.cpp │ ├── d3d9_window.h │ ├── meson.build │ ├── shaders │ │ ├── d3d9_convert_a2w10v10u10.comp │ │ ├── d3d9_convert_common.h │ │ ├── d3d9_convert_l6v5u5.comp │ │ ├── d3d9_convert_nv12.comp │ │ ├── d3d9_convert_w11v11u10.comp │ │ ├── d3d9_convert_x8l8v8u8.comp │ │ ├── d3d9_convert_yuy2_uyvy.comp │ │ └── d3d9_convert_yv12.comp │ └── version.rc ├── dxbc │ ├── dxbc_analysis.cpp │ ├── dxbc_analysis.h │ ├── dxbc_chunk_isgn.cpp │ ├── dxbc_chunk_isgn.h │ ├── dxbc_chunk_shex.cpp │ ├── dxbc_chunk_shex.h │ ├── dxbc_common.cpp │ ├── dxbc_common.h │ ├── dxbc_compiler.cpp │ ├── dxbc_compiler.h │ ├── dxbc_decoder.cpp │ ├── dxbc_decoder.h │ ├── dxbc_defs.cpp │ ├── dxbc_defs.h │ ├── dxbc_enums.h │ ├── dxbc_header.cpp │ ├── dxbc_header.h │ ├── dxbc_include.h │ ├── dxbc_modinfo.h │ ├── dxbc_module.cpp │ ├── dxbc_module.h │ ├── dxbc_names.cpp │ ├── dxbc_names.h │ ├── dxbc_options.cpp │ ├── dxbc_options.h │ ├── dxbc_reader.cpp │ ├── dxbc_reader.h │ ├── dxbc_tag.h │ ├── dxbc_util.cpp │ ├── dxbc_util.h │ └── meson.build ├── dxgi │ ├── dxgi.def │ ├── dxgi.sym │ ├── dxgi_adapter.cpp │ ├── dxgi_adapter.h │ ├── dxgi_enums.cpp │ ├── dxgi_enums.h │ ├── dxgi_factory.cpp │ ├── dxgi_factory.h │ ├── dxgi_format.cpp │ ├── dxgi_format.h │ ├── dxgi_include.h │ ├── dxgi_interfaces.h │ ├── dxgi_main.cpp │ ├── dxgi_monitor.cpp │ ├── dxgi_monitor.h │ ├── dxgi_object.h │ ├── dxgi_options.cpp │ ├── dxgi_options.h │ ├── dxgi_output.cpp │ ├── dxgi_output.h │ ├── dxgi_surface.cpp │ ├── dxgi_surface.h │ ├── dxgi_swapchain.cpp │ ├── dxgi_swapchain.h │ ├── dxgi_swapchain_dispatcher.h │ ├── meson.build │ └── version.rc ├── dxso │ ├── dxso_analysis.cpp │ ├── dxso_analysis.h │ ├── dxso_code.cpp │ ├── dxso_code.h │ ├── dxso_common.cpp │ ├── dxso_common.h │ ├── dxso_compiler.cpp │ ├── dxso_compiler.h │ ├── dxso_ctab.cpp │ ├── dxso_ctab.h │ ├── dxso_decoder.cpp │ ├── dxso_decoder.h │ ├── dxso_enums.cpp │ ├── dxso_enums.h │ ├── dxso_header.cpp │ ├── dxso_header.h │ ├── dxso_include.h │ ├── dxso_isgn.h │ ├── dxso_modinfo.h │ ├── dxso_module.cpp │ ├── dxso_module.h │ ├── dxso_options.cpp │ ├── dxso_options.h │ ├── dxso_reader.cpp │ ├── dxso_reader.h │ ├── dxso_tables.cpp │ ├── dxso_tables.h │ ├── dxso_util.cpp │ ├── dxso_util.h │ └── meson.build ├── dxvk │ ├── dxvk_adapter.cpp │ ├── dxvk_adapter.h │ ├── dxvk_annotation.h │ ├── dxvk_barrier.cpp │ ├── dxvk_barrier.h │ ├── dxvk_bind_mask.h │ ├── dxvk_buffer.cpp │ ├── dxvk_buffer.h │ ├── dxvk_cmdlist.cpp │ ├── dxvk_cmdlist.h │ ├── dxvk_compute.cpp │ ├── dxvk_compute.h │ ├── dxvk_constant_state.h │ ├── dxvk_context.cpp │ ├── dxvk_context.h │ ├── dxvk_context_state.h │ ├── dxvk_cs.cpp │ ├── dxvk_cs.h │ ├── dxvk_data.cpp │ ├── dxvk_data.h │ ├── dxvk_descriptor.cpp │ ├── dxvk_descriptor.h │ ├── dxvk_device.cpp │ ├── dxvk_device.h │ ├── dxvk_device_filter.cpp │ ├── dxvk_device_filter.h │ ├── dxvk_device_info.h │ ├── dxvk_extension_provider.h │ ├── dxvk_extensions.cpp │ ├── dxvk_extensions.h │ ├── dxvk_fence.cpp │ ├── dxvk_fence.h │ ├── dxvk_format.cpp │ ├── dxvk_format.h │ ├── dxvk_framebuffer.cpp │ ├── dxvk_framebuffer.h │ ├── dxvk_gpu_event.cpp │ ├── dxvk_gpu_event.h │ ├── dxvk_gpu_query.cpp │ ├── dxvk_gpu_query.h │ ├── dxvk_graphics.cpp │ ├── dxvk_graphics.h │ ├── dxvk_graphics_state.h │ ├── dxvk_hash.h │ ├── dxvk_image.cpp │ ├── dxvk_image.h │ ├── dxvk_include.h │ ├── dxvk_instance.cpp │ ├── dxvk_instance.h │ ├── dxvk_lifetime.cpp │ ├── dxvk_lifetime.h │ ├── dxvk_limits.h │ ├── dxvk_marker.h │ ├── dxvk_memory.cpp │ ├── dxvk_memory.h │ ├── dxvk_meta_blit.cpp │ ├── dxvk_meta_blit.h │ ├── dxvk_meta_clear.cpp │ ├── dxvk_meta_clear.h │ ├── dxvk_meta_copy.cpp │ ├── dxvk_meta_copy.h │ ├── dxvk_meta_mipgen.cpp │ ├── dxvk_meta_mipgen.h │ ├── dxvk_meta_pack.cpp │ ├── dxvk_meta_pack.h │ ├── dxvk_meta_resolve.cpp │ ├── dxvk_meta_resolve.h │ ├── dxvk_objects.h │ ├── dxvk_openvr.cpp │ ├── dxvk_openvr.h │ ├── dxvk_openxr.cpp │ ├── dxvk_openxr.h │ ├── dxvk_options.cpp │ ├── dxvk_options.h │ ├── dxvk_pipelayout.cpp │ ├── dxvk_pipelayout.h │ ├── dxvk_pipemanager.cpp │ ├── dxvk_pipemanager.h │ ├── dxvk_platform_exts.cpp │ ├── dxvk_platform_exts.h │ ├── dxvk_presenter.cpp │ ├── dxvk_presenter.h │ ├── dxvk_queue.cpp │ ├── dxvk_queue.h │ ├── dxvk_recycler.h │ ├── dxvk_renderpass.h │ ├── dxvk_resource.cpp │ ├── dxvk_resource.h │ ├── dxvk_sampler.cpp │ ├── dxvk_sampler.h │ ├── dxvk_shader.cpp │ ├── dxvk_shader.h │ ├── dxvk_shader_key.cpp │ ├── dxvk_shader_key.h │ ├── dxvk_signal.cpp │ ├── dxvk_signal.h │ ├── dxvk_sparse.cpp │ ├── dxvk_sparse.h │ ├── dxvk_staging.cpp │ ├── dxvk_staging.h │ ├── dxvk_state_cache.cpp │ ├── dxvk_state_cache.h │ ├── dxvk_state_cache_types.h │ ├── dxvk_stats.cpp │ ├── dxvk_stats.h │ ├── dxvk_swapchain_blitter.cpp │ ├── dxvk_swapchain_blitter.h │ ├── dxvk_unbound.cpp │ ├── dxvk_unbound.h │ ├── dxvk_util.cpp │ ├── dxvk_util.h │ ├── hud │ │ ├── dxvk_hud.cpp │ │ ├── dxvk_hud.h │ │ ├── dxvk_hud_font.cpp │ │ ├── dxvk_hud_font.h │ │ ├── dxvk_hud_item.cpp │ │ ├── dxvk_hud_item.h │ │ ├── dxvk_hud_renderer.cpp │ │ ├── dxvk_hud_renderer.h │ │ └── shaders │ │ │ ├── hud_frag_common.glsl │ │ │ ├── hud_graph_frag.frag │ │ │ ├── hud_graph_vert.vert │ │ │ ├── hud_text_frag.frag │ │ │ └── hud_text_vert.vert │ ├── meson.build │ └── shaders │ │ ├── dxvk_blit_frag_1d.frag │ │ ├── dxvk_blit_frag_2d.frag │ │ ├── dxvk_blit_frag_3d.frag │ │ ├── dxvk_clear_buffer_f.comp │ │ ├── dxvk_clear_buffer_u.comp │ │ ├── dxvk_clear_image1d_f.comp │ │ ├── dxvk_clear_image1d_u.comp │ │ ├── dxvk_clear_image1darr_f.comp │ │ ├── dxvk_clear_image1darr_u.comp │ │ ├── dxvk_clear_image2d_f.comp │ │ ├── dxvk_clear_image2d_u.comp │ │ ├── dxvk_clear_image2darr_f.comp │ │ ├── dxvk_clear_image2darr_u.comp │ │ ├── dxvk_clear_image3d_f.comp │ │ ├── dxvk_clear_image3d_u.comp │ │ ├── dxvk_copy_buffer_image.comp │ │ ├── dxvk_copy_color_1d.frag │ │ ├── dxvk_copy_color_2d.frag │ │ ├── dxvk_copy_color_ms.frag │ │ ├── dxvk_copy_depth_stencil_1d.frag │ │ ├── dxvk_copy_depth_stencil_2d.frag │ │ ├── dxvk_copy_depth_stencil_ms.frag │ │ ├── dxvk_dummy_frag.frag │ │ ├── dxvk_fullscreen_geom.geom │ │ ├── dxvk_fullscreen_layer_vert.vert │ │ ├── dxvk_fullscreen_vert.vert │ │ ├── dxvk_pack_d24s8.comp │ │ ├── dxvk_pack_d32s8.comp │ │ ├── dxvk_present_frag.frag │ │ ├── dxvk_present_frag_blit.frag │ │ ├── dxvk_present_frag_ms.frag │ │ ├── dxvk_present_frag_ms_amd.frag │ │ ├── dxvk_present_vert.vert │ │ ├── dxvk_resolve_frag_d.frag │ │ ├── dxvk_resolve_frag_ds.frag │ │ ├── dxvk_resolve_frag_f.frag │ │ ├── dxvk_resolve_frag_f_amd.frag │ │ ├── dxvk_resolve_frag_i.frag │ │ ├── dxvk_resolve_frag_u.frag │ │ ├── dxvk_unpack_d24s8.comp │ │ ├── dxvk_unpack_d24s8_as_d32s8.comp │ │ └── dxvk_unpack_d32s8.comp ├── meson.build ├── spirv │ ├── meson.build │ ├── spirv_code_buffer.cpp │ ├── spirv_code_buffer.h │ ├── spirv_compression.cpp │ ├── spirv_compression.h │ ├── spirv_include.h │ ├── spirv_instruction.h │ ├── spirv_module.cpp │ └── spirv_module.h ├── util │ ├── com │ │ ├── com_guid.cpp │ │ ├── com_guid.h │ │ ├── com_include.h │ │ ├── com_object.h │ │ ├── com_pointer.h │ │ ├── com_private_data.cpp │ │ └── com_private_data.h │ ├── config │ │ ├── config.cpp │ │ └── config.h │ ├── log │ │ ├── log.cpp │ │ ├── log.h │ │ ├── log_debug.cpp │ │ └── log_debug.h │ ├── meson.build │ ├── rc │ │ ├── util_rc.h │ │ └── util_rc_ptr.h │ ├── sha1 │ │ ├── sha1.c │ │ ├── sha1.h │ │ ├── sha1_util.cpp │ │ └── sha1_util.h │ ├── sync │ │ ├── sync_list.h │ │ ├── sync_recursive.cpp │ │ ├── sync_recursive.h │ │ ├── sync_signal.h │ │ ├── sync_spinlock.h │ │ └── sync_ticketlock.h │ ├── thread.cpp │ ├── thread.h │ ├── util_bit.h │ ├── util_enum.h │ ├── util_env.cpp │ ├── util_env.h │ ├── util_error.h │ ├── util_flags.h │ ├── util_flush.cpp │ ├── util_flush.h │ ├── util_fps_limiter.cpp │ ├── util_fps_limiter.h │ ├── util_gdi.cpp │ ├── util_gdi.h │ ├── util_lazy.h │ ├── util_likely.h │ ├── util_lru.h │ ├── util_luid.cpp │ ├── util_luid.h │ ├── util_math.h │ ├── util_matrix.cpp │ ├── util_matrix.h │ ├── util_misc.h │ ├── util_ratio.h │ ├── util_shared_res.cpp │ ├── util_shared_res.h │ ├── util_singleton.h │ ├── util_sleep.cpp │ ├── util_sleep.h │ ├── util_small_vector.h │ ├── util_string.cpp │ ├── util_string.h │ ├── util_time.h │ ├── util_vector.h │ ├── util_version.h │ └── util_win32_compat.h ├── vulkan │ ├── meson.build │ ├── vulkan_loader.cpp │ ├── vulkan_loader.h │ ├── vulkan_names.cpp │ ├── vulkan_names.h │ └── vulkan_util.h └── wsi │ ├── glfw │ ├── wsi_monitor_glfw.cpp │ ├── wsi_platform_glfw.cpp │ ├── wsi_platform_glfw.h │ ├── wsi_platform_glfw_funcs.h │ └── wsi_window_glfw.cpp │ ├── meson.build │ ├── sdl2 │ ├── wsi_monitor_sdl2.cpp │ ├── wsi_platform_sdl2.cpp │ ├── wsi_platform_sdl2.h │ ├── wsi_platform_sdl2_funcs.h │ └── wsi_window_sdl2.cpp │ ├── win32 │ ├── wsi_monitor_win32.cpp │ ├── wsi_platform_win32.cpp │ ├── wsi_platform_win32.h │ └── wsi_window_win32.cpp │ ├── wsi_edid.cpp │ ├── wsi_edid.h │ ├── wsi_monitor.h │ ├── wsi_platform.cpp │ ├── wsi_platform.h │ └── wsi_window.h └── version.h.in /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Please report new bugs to https://github.com/doitsujin/dxvk 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | This repo is no longer open to issues. Please report new issues at https://github.com/doitsujin/dxvk/issues/new/choose 11 | 12 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "include/native/directx"] 2 | path = include/native/directx 3 | url = https://github.com/Joshua-Ashton/mingw-directx-headers 4 | [submodule "include/vulkan"] 5 | path = include/vulkan 6 | url = https://github.com/KhronosGroup/Vulkan-Headers 7 | [submodule "include/spirv"] 8 | path = include/spirv 9 | url = https://github.com/KhronosGroup/SPIRV-Headers.git 10 | [submodule "subprojects/libdisplay-info"] 11 | path = subprojects/libdisplay-info 12 | url = https://gitlab.freedesktop.org/JoshuaAshton/libdisplay-info.git 13 | branch = windows 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Philip Rebohle 2 | Copyright (c) 2019 Joshua Ashton 3 | Copyright (c) 2023 Jeffrey Ellison 4 | 5 | zlib/libpng license 6 | 7 | This software is provided 'as-is', without any express or implied 8 | warranty. In no event will the authors be held liable for any damages 9 | arising from the use of this software. 10 | 11 | Permission is granted to anyone to use this software for any purpose, 12 | including commercial applications, and to alter it and redistribute it 13 | freely, subject to the following restrictions: 14 | 15 | – The origin of this software must not be misrepresented; you must not 16 | claim that you wrote the original software. If you use this software 17 | in a product, an acknowledgment in the product documentation would be 18 | appreciated but is not required. 19 | 20 | – Altered source versions must be plainly marked as such, and must not 21 | be misrepresented as being the original software. 22 | 23 | – This notice may not be removed or altered from any source distribution. 24 | -------------------------------------------------------------------------------- /RELEASE: -------------------------------------------------------------------------------- 1 | 2.3.1 2 | -------------------------------------------------------------------------------- /build-win32.txt: -------------------------------------------------------------------------------- 1 | [binaries] 2 | c = 'i686-w64-mingw32-gcc' 3 | cpp = 'i686-w64-mingw32-g++' 4 | ar = 'i686-w64-mingw32-ar' 5 | strip = 'i686-w64-mingw32-strip' 6 | windres = 'i686-w64-mingw32-windres' 7 | 8 | [properties] 9 | needs_exe_wrapper = true 10 | 11 | [host_machine] 12 | system = 'windows' 13 | cpu_family = 'x86' 14 | cpu = 'x86' 15 | endian = 'little' 16 | -------------------------------------------------------------------------------- /build-win64.txt: -------------------------------------------------------------------------------- 1 | [binaries] 2 | c = 'x86_64-w64-mingw32-gcc' 3 | cpp = 'x86_64-w64-mingw32-g++' 4 | ar = 'x86_64-w64-mingw32-ar' 5 | strip = 'x86_64-w64-mingw32-strip' 6 | windres = 'x86_64-w64-mingw32-windres' 7 | 8 | [properties] 9 | needs_exe_wrapper = true 10 | 11 | [host_machine] 12 | system = 'windows' 13 | cpu_family = 'x86_64' 14 | cpu = 'x86_64' 15 | endian = 'little' 16 | -------------------------------------------------------------------------------- /include/native/meson.build: -------------------------------------------------------------------------------- 1 | install_subdir( 2 | 'directx', 3 | install_dir: get_option('includedir') / 'dxvk', 4 | strip_directory: true, 5 | exclude_files: '.git' 6 | ) 7 | 8 | install_subdir( 9 | 'windows', 10 | install_dir: get_option('includedir') / 'dxvk', 11 | strip_directory: true, 12 | ) 13 | 14 | install_headers( 15 | 'wsi/native_wsi.h', 16 | 'wsi/native_sdl2.h', 17 | 'wsi/native_glfw.h', 18 | subdir: 'dxvk/wsi', 19 | ) 20 | -------------------------------------------------------------------------------- /include/native/windows/oaidl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Don't care. -------------------------------------------------------------------------------- /include/native/windows/objbase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Don't care. -------------------------------------------------------------------------------- /include/native/windows/ocidl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Don't care. -------------------------------------------------------------------------------- /include/native/windows/ole2.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Don't care. -------------------------------------------------------------------------------- /include/native/windows/poppack.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the mingw-w64 runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 | */ 6 | #if !(defined(lint) || defined(RC_INVOKED)) 7 | #pragma pack(pop) 8 | #endif 9 | -------------------------------------------------------------------------------- /include/native/windows/pshpack4.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the mingw-w64 runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 | */ 6 | #if !(defined(lint) || defined(RC_INVOKED)) 7 | #pragma pack(push,4) 8 | #endif 9 | -------------------------------------------------------------------------------- /include/native/windows/rpc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Don't care. -------------------------------------------------------------------------------- /include/native/windows/rpcndr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Don't care. -------------------------------------------------------------------------------- /include/native/windows/unknwn.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "windows_base.h" 4 | 5 | typedef interface IUnknown IUnknown; 6 | 7 | DEFINE_GUID(IID_IUnknown, 0x00000000,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46) 8 | 9 | #ifdef __cplusplus 10 | struct IUnknown { 11 | 12 | public: 13 | 14 | virtual HRESULT QueryInterface(REFIID riid, void** ppvObject) = 0; 15 | template 16 | HRESULT STDMETHODCALLTYPE QueryInterface(Q **pp) { 17 | return QueryInterface(__uuidof(Q), (void **)pp); 18 | } 19 | 20 | virtual ULONG AddRef() = 0; 21 | virtual ULONG Release() = 0; 22 | 23 | }; 24 | #else 25 | typedef struct IUnknownVtbl 26 | { 27 | BEGIN_INTERFACE 28 | 29 | HRESULT (STDMETHODCALLTYPE *QueryInterface)( 30 | IUnknown *This, 31 | REFIID riid, 32 | void **ppvObject 33 | ); 34 | ULONG (STDMETHODCALLTYPE *AddRef)(IUnknown *This); 35 | ULONG (STDMETHODCALLTYPE *Release)(IUnknown *This); 36 | 37 | END_INTERFACE 38 | } IUnknownVtbl; 39 | 40 | interface IUnknown 41 | { 42 | CONST_VTBL struct IUnknownVtbl *lpVtbl; 43 | }; 44 | 45 | #define IUnknown_AddRef(This) ((This)->lpVtbl->AddRef(This)) 46 | #define IUnknown_Release(This) ((This)->lpVtbl->Release(This)) 47 | 48 | #endif // __cplusplus 49 | 50 | DECLARE_UUIDOF_HELPER(IUnknown, 0x00000000,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46) 51 | 52 | #define IID_PPV_ARGS(ppType) __uuidof(decltype(**(ppType))), [](auto** pp) { (void)static_cast(*pp); return reinterpret_cast(pp); }(ppType) 53 | -------------------------------------------------------------------------------- /include/native/windows/windows.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "windows_base.h" 4 | #include "unknwn.h" -------------------------------------------------------------------------------- /include/native/wsi/native_glfw.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace dxvk::wsi { 6 | 7 | inline GLFWwindow* fromHwnd(HWND hWindow) { 8 | return reinterpret_cast(hWindow); 9 | } 10 | 11 | inline HWND toHwnd(GLFWwindow* pWindow) { 12 | return reinterpret_cast(pWindow); 13 | } 14 | 15 | // Offset so null HMONITORs go to -1 16 | inline int32_t fromHmonitor(HMONITOR hMonitor) { 17 | return static_cast(reinterpret_cast(hMonitor)) - 1; 18 | } 19 | 20 | // Offset so -1 display id goes to 0 == NULL 21 | inline HMONITOR toHmonitor(int32_t displayId) { 22 | return reinterpret_cast(static_cast(displayId + 1)); 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /include/native/wsi/native_sdl2.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | namespace dxvk::wsi { 6 | 7 | inline SDL_Window* fromHwnd(HWND hWindow) { 8 | return reinterpret_cast(hWindow); 9 | } 10 | 11 | inline HWND toHwnd(SDL_Window* pWindow) { 12 | return reinterpret_cast(pWindow); 13 | } 14 | 15 | // Offset so null HMONITORs go to -1 16 | inline int32_t fromHmonitor(HMONITOR hMonitor) { 17 | return static_cast(reinterpret_cast(hMonitor)) - 1; 18 | } 19 | 20 | // Offset so -1 display id goes to 0 == NULL 21 | inline HMONITOR toHmonitor(int32_t displayId) { 22 | return reinterpret_cast(static_cast(displayId + 1)); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /include/native/wsi/native_wsi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef DXVK_WSI_WIN32 4 | #error You shouldnt be using this code path. 5 | #elif DXVK_WSI_SDL2 6 | #include "wsi/native_sdl2.h" 7 | #elif DXVK_WSI_GLFW 8 | #include "wsi/native_glfw.h" 9 | #else 10 | #error Unknown wsi! 11 | #endif -------------------------------------------------------------------------------- /include/openvr/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Valve Corporation 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation and/or 12 | other materials provided with the distribution. 13 | 14 | 3. Neither the name of the copyright holder nor the names of its contributors 15 | may be used to endorse or promote products derived from this software without 16 | specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 22 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 25 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('enable_dxgi', type : 'boolean', value : true, description: 'Build DXGI') 2 | option('enable_d3d8', type : 'boolean', value : true, description: 'Build D3D8') 3 | option('enable_d3d9', type : 'boolean', value : true, description: 'Build D3D9') 4 | option('enable_d3d10', type : 'boolean', value : true, description: 'Build D3D10') 5 | option('enable_d3d11', type : 'boolean', value : true, description: 'Build D3D11') 6 | option('build_id', type : 'boolean', value : false) 7 | 8 | option('dxvk_native_wsi', type : 'string', value : 'sdl2', description: 'WSI system to use if building natively.') -------------------------------------------------------------------------------- /src/d3d10/d3d10_blend.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d10_util.h" 4 | 5 | namespace dxvk { 6 | 7 | class D3D11BlendState; 8 | class D3D11Device; 9 | 10 | class D3D10BlendState : public ID3D10BlendState1 { 11 | 12 | public: 13 | 14 | D3D10BlendState(D3D11BlendState* pParent) 15 | : m_d3d11(pParent) { } 16 | 17 | HRESULT STDMETHODCALLTYPE QueryInterface( 18 | REFIID riid, 19 | void** ppvObject); 20 | 21 | ULONG STDMETHODCALLTYPE AddRef(); 22 | 23 | ULONG STDMETHODCALLTYPE Release(); 24 | 25 | void STDMETHODCALLTYPE GetDevice( 26 | ID3D10Device** ppDevice); 27 | 28 | HRESULT STDMETHODCALLTYPE GetPrivateData( 29 | REFGUID guid, 30 | UINT* pDataSize, 31 | void* pData); 32 | 33 | HRESULT STDMETHODCALLTYPE SetPrivateData( 34 | REFGUID guid, 35 | UINT DataSize, 36 | const void* pData); 37 | 38 | HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( 39 | REFGUID guid, 40 | const IUnknown* pData); 41 | 42 | void STDMETHODCALLTYPE GetDesc( 43 | D3D10_BLEND_DESC* pDesc); 44 | 45 | void STDMETHODCALLTYPE GetDesc1( 46 | D3D10_BLEND_DESC1* pDesc); 47 | 48 | D3D11BlendState* GetD3D11Iface() { 49 | return m_d3d11; 50 | } 51 | 52 | private: 53 | 54 | D3D11BlendState* m_d3d11; 55 | 56 | }; 57 | 58 | } -------------------------------------------------------------------------------- /src/d3d10/d3d10_depth_stencil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d10_util.h" 4 | 5 | namespace dxvk { 6 | 7 | class D3D11DepthStencilState; 8 | class D3D11Device; 9 | 10 | class D3D10DepthStencilState : public ID3D10DepthStencilState { 11 | 12 | public: 13 | 14 | D3D10DepthStencilState(D3D11DepthStencilState* pParent) 15 | : m_d3d11(pParent) { } 16 | 17 | HRESULT STDMETHODCALLTYPE QueryInterface( 18 | REFIID riid, 19 | void** ppvObject); 20 | 21 | ULONG STDMETHODCALLTYPE AddRef(); 22 | 23 | ULONG STDMETHODCALLTYPE Release(); 24 | 25 | void STDMETHODCALLTYPE GetDevice( 26 | ID3D10Device** ppDevice); 27 | 28 | HRESULT STDMETHODCALLTYPE GetPrivateData( 29 | REFGUID guid, 30 | UINT* pDataSize, 31 | void* pData); 32 | 33 | HRESULT STDMETHODCALLTYPE SetPrivateData( 34 | REFGUID guid, 35 | UINT DataSize, 36 | const void* pData); 37 | 38 | HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( 39 | REFGUID guid, 40 | const IUnknown* pData); 41 | 42 | void STDMETHODCALLTYPE GetDesc( 43 | D3D10_DEPTH_STENCIL_DESC* pDesc); 44 | 45 | D3D11DepthStencilState* GetD3D11Iface() { 46 | return m_d3d11; 47 | } 48 | 49 | private: 50 | 51 | D3D11DepthStencilState* m_d3d11; 52 | 53 | }; 54 | 55 | } -------------------------------------------------------------------------------- /src/d3d10/d3d10_include.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../dxgi/dxgi_include.h" 4 | 5 | #include "../util/sync/sync_spinlock.h" 6 | #include "../util/sync/sync_recursive.h" 7 | 8 | #include 9 | #include 10 | -------------------------------------------------------------------------------- /src/d3d10/d3d10_input_layout.cpp: -------------------------------------------------------------------------------- 1 | #include "d3d10_input_layout.h" 2 | 3 | #include "../d3d11/d3d11_device.h" 4 | #include "../d3d11/d3d11_input_layout.h" 5 | 6 | namespace dxvk { 7 | 8 | HRESULT STDMETHODCALLTYPE D3D10InputLayout::QueryInterface( 9 | REFIID riid, 10 | void** ppvObject) { 11 | return m_d3d11->QueryInterface(riid, ppvObject); 12 | } 13 | 14 | 15 | ULONG STDMETHODCALLTYPE D3D10InputLayout::AddRef() { 16 | return m_d3d11->AddRef(); 17 | } 18 | 19 | 20 | ULONG STDMETHODCALLTYPE D3D10InputLayout::Release() { 21 | return m_d3d11->Release(); 22 | } 23 | 24 | 25 | void STDMETHODCALLTYPE D3D10InputLayout::GetDevice( 26 | ID3D10Device** ppDevice) { 27 | GetD3D10Device(m_d3d11, ppDevice); 28 | } 29 | 30 | 31 | HRESULT STDMETHODCALLTYPE D3D10InputLayout::GetPrivateData( 32 | REFGUID guid, 33 | UINT* pDataSize, 34 | void* pData) { 35 | return m_d3d11->GetPrivateData(guid, pDataSize, pData); 36 | } 37 | 38 | 39 | HRESULT STDMETHODCALLTYPE D3D10InputLayout::SetPrivateData( 40 | REFGUID guid, 41 | UINT DataSize, 42 | const void* pData) { 43 | return m_d3d11->SetPrivateData(guid, DataSize, pData); 44 | } 45 | 46 | 47 | HRESULT STDMETHODCALLTYPE D3D10InputLayout::SetPrivateDataInterface( 48 | REFGUID guid, 49 | const IUnknown* pData) { 50 | return m_d3d11->SetPrivateDataInterface(guid, pData); 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /src/d3d10/d3d10_input_layout.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d10_util.h" 4 | 5 | namespace dxvk { 6 | 7 | class D3D11Device; 8 | class D3D11InputLayout; 9 | 10 | class D3D10InputLayout : public ID3D10InputLayout { 11 | 12 | public: 13 | 14 | D3D10InputLayout(D3D11InputLayout* pParent) 15 | : m_d3d11(pParent) { } 16 | 17 | HRESULT STDMETHODCALLTYPE QueryInterface( 18 | REFIID riid, 19 | void** ppvObject); 20 | 21 | ULONG STDMETHODCALLTYPE AddRef(); 22 | 23 | ULONG STDMETHODCALLTYPE Release(); 24 | 25 | void STDMETHODCALLTYPE GetDevice( 26 | ID3D10Device** ppDevice); 27 | 28 | HRESULT STDMETHODCALLTYPE GetPrivateData( 29 | REFGUID guid, 30 | UINT* pDataSize, 31 | void* pData); 32 | 33 | HRESULT STDMETHODCALLTYPE SetPrivateData( 34 | REFGUID guid, 35 | UINT DataSize, 36 | const void* pData); 37 | 38 | HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( 39 | REFGUID guid, 40 | const IUnknown* pData); 41 | 42 | D3D11InputLayout* GetD3D11Iface() { 43 | return m_d3d11; 44 | } 45 | 46 | private: 47 | 48 | D3D11InputLayout* m_d3d11; 49 | 50 | }; 51 | 52 | } -------------------------------------------------------------------------------- /src/d3d10/d3d10_multithread.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "d3d10_device.h" 4 | 5 | namespace dxvk { 6 | 7 | D3D10Multithread::D3D10Multithread( 8 | IUnknown* pParent, 9 | BOOL Protected, 10 | BOOL Force) 11 | : m_parent (pParent), 12 | m_protected (Protected || Force), 13 | m_enabled (Protected), 14 | m_forced (Force) { 15 | 16 | } 17 | 18 | 19 | D3D10Multithread::~D3D10Multithread() { 20 | 21 | } 22 | 23 | 24 | ULONG STDMETHODCALLTYPE D3D10Multithread::AddRef() { 25 | return m_parent->AddRef(); 26 | } 27 | 28 | 29 | ULONG STDMETHODCALLTYPE D3D10Multithread::Release() { 30 | return m_parent->Release(); 31 | } 32 | 33 | 34 | HRESULT STDMETHODCALLTYPE D3D10Multithread::QueryInterface( 35 | REFIID riid, 36 | void** ppvObject) { 37 | return m_parent->QueryInterface(riid, ppvObject); 38 | } 39 | 40 | 41 | void STDMETHODCALLTYPE D3D10Multithread::Enter() { 42 | if (m_protected) 43 | m_mutex.lock(); 44 | } 45 | 46 | 47 | void STDMETHODCALLTYPE D3D10Multithread::Leave() { 48 | if (m_protected) 49 | m_mutex.unlock(); 50 | } 51 | 52 | 53 | BOOL STDMETHODCALLTYPE D3D10Multithread::SetMultithreadProtected( 54 | BOOL bMTProtect) { 55 | BOOL result = m_enabled; 56 | m_enabled = bMTProtect; 57 | 58 | if (!m_forced) 59 | m_protected = m_enabled; 60 | 61 | return result; 62 | } 63 | 64 | 65 | BOOL STDMETHODCALLTYPE D3D10Multithread::GetMultithreadProtected() { 66 | return m_enabled; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/d3d10/d3d10_rasterizer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d10_util.h" 4 | 5 | namespace dxvk { 6 | 7 | class D3D11RasterizerState; 8 | class D3D11Device; 9 | 10 | class D3D10RasterizerState : public ID3D10RasterizerState { 11 | 12 | public: 13 | 14 | D3D10RasterizerState(D3D11RasterizerState* pParent) 15 | : m_d3d11(pParent) { } 16 | 17 | HRESULT STDMETHODCALLTYPE QueryInterface( 18 | REFIID riid, 19 | void** ppvObject); 20 | 21 | ULONG STDMETHODCALLTYPE AddRef(); 22 | 23 | ULONG STDMETHODCALLTYPE Release(); 24 | 25 | void STDMETHODCALLTYPE GetDevice( 26 | ID3D10Device** ppDevice); 27 | 28 | HRESULT STDMETHODCALLTYPE GetPrivateData( 29 | REFGUID guid, 30 | UINT* pDataSize, 31 | void* pData); 32 | 33 | HRESULT STDMETHODCALLTYPE SetPrivateData( 34 | REFGUID guid, 35 | UINT DataSize, 36 | const void* pData); 37 | 38 | HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( 39 | REFGUID guid, 40 | const IUnknown* pData); 41 | 42 | void STDMETHODCALLTYPE GetDesc( 43 | D3D10_RASTERIZER_DESC* pDesc); 44 | 45 | D3D11RasterizerState* GetD3D11Iface() { 46 | return m_d3d11; 47 | } 48 | 49 | private: 50 | 51 | D3D11RasterizerState* m_d3d11; 52 | 53 | }; 54 | 55 | } -------------------------------------------------------------------------------- /src/d3d10/d3d10_sampler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d10_util.h" 4 | 5 | namespace dxvk { 6 | 7 | class D3D11Device; 8 | class D3D11SamplerState; 9 | 10 | class D3D10SamplerState : public ID3D10SamplerState { 11 | 12 | public: 13 | 14 | D3D10SamplerState(D3D11SamplerState* pParent) 15 | : m_d3d11(pParent) { } 16 | 17 | HRESULT STDMETHODCALLTYPE QueryInterface( 18 | REFIID riid, 19 | void** ppvObject); 20 | 21 | ULONG STDMETHODCALLTYPE AddRef(); 22 | 23 | ULONG STDMETHODCALLTYPE Release(); 24 | 25 | void STDMETHODCALLTYPE GetDevice( 26 | ID3D10Device** ppDevice); 27 | 28 | HRESULT STDMETHODCALLTYPE GetPrivateData( 29 | REFGUID guid, 30 | UINT* pDataSize, 31 | void* pData); 32 | 33 | HRESULT STDMETHODCALLTYPE SetPrivateData( 34 | REFGUID guid, 35 | UINT DataSize, 36 | const void* pData); 37 | 38 | HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( 39 | REFGUID guid, 40 | const IUnknown* pData); 41 | 42 | void STDMETHODCALLTYPE GetDesc( 43 | D3D10_SAMPLER_DESC* pDesc); 44 | 45 | D3D11SamplerState* GetD3D11Iface() { 46 | return m_d3d11; 47 | } 48 | 49 | private: 50 | 51 | D3D11SamplerState* m_d3d11; 52 | 53 | }; 54 | 55 | } -------------------------------------------------------------------------------- /src/d3d10/d3d10_view_dsv.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d10_util.h" 4 | 5 | namespace dxvk { 6 | 7 | class D3D11Device; 8 | class D3D11DepthStencilView; 9 | 10 | class D3D10DepthStencilView : public ID3D10DepthStencilView { 11 | 12 | public: 13 | 14 | D3D10DepthStencilView(D3D11DepthStencilView* pParent) 15 | : m_d3d11(pParent) { } 16 | 17 | HRESULT STDMETHODCALLTYPE QueryInterface( 18 | REFIID riid, 19 | void** ppvObject); 20 | 21 | ULONG STDMETHODCALLTYPE AddRef(); 22 | 23 | ULONG STDMETHODCALLTYPE Release(); 24 | 25 | void STDMETHODCALLTYPE GetDevice( 26 | ID3D10Device** ppDevice); 27 | 28 | HRESULT STDMETHODCALLTYPE GetPrivateData( 29 | REFGUID guid, 30 | UINT* pDataSize, 31 | void* pData); 32 | 33 | HRESULT STDMETHODCALLTYPE SetPrivateData( 34 | REFGUID guid, 35 | UINT DataSize, 36 | const void* pData); 37 | 38 | HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( 39 | REFGUID guid, 40 | const IUnknown* pData); 41 | 42 | void STDMETHODCALLTYPE GetResource( 43 | ID3D10Resource** ppResource); 44 | 45 | void STDMETHODCALLTYPE GetDesc( 46 | D3D10_DEPTH_STENCIL_VIEW_DESC* pDesc); 47 | 48 | D3D11DepthStencilView* GetD3D11Iface() { 49 | return m_d3d11; 50 | } 51 | 52 | private: 53 | 54 | D3D11DepthStencilView* m_d3d11; 55 | 56 | }; 57 | 58 | } -------------------------------------------------------------------------------- /src/d3d10/d3d10_view_rtv.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d10_util.h" 4 | 5 | namespace dxvk { 6 | 7 | class D3D11Device; 8 | class D3D11RenderTargetView; 9 | 10 | class D3D10RenderTargetView : public ID3D10RenderTargetView { 11 | 12 | public: 13 | 14 | D3D10RenderTargetView(D3D11RenderTargetView* pParent) 15 | : m_d3d11(pParent) { } 16 | 17 | HRESULT STDMETHODCALLTYPE QueryInterface( 18 | REFIID riid, 19 | void** ppvObject); 20 | 21 | ULONG STDMETHODCALLTYPE AddRef(); 22 | 23 | ULONG STDMETHODCALLTYPE Release(); 24 | 25 | void STDMETHODCALLTYPE GetDevice( 26 | ID3D10Device** ppDevice); 27 | 28 | HRESULT STDMETHODCALLTYPE GetPrivateData( 29 | REFGUID guid, 30 | UINT* pDataSize, 31 | void* pData); 32 | 33 | HRESULT STDMETHODCALLTYPE SetPrivateData( 34 | REFGUID guid, 35 | UINT DataSize, 36 | const void* pData); 37 | 38 | HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( 39 | REFGUID guid, 40 | const IUnknown* pData); 41 | 42 | void STDMETHODCALLTYPE GetResource( 43 | ID3D10Resource** ppResource); 44 | 45 | void STDMETHODCALLTYPE GetDesc( 46 | D3D10_RENDER_TARGET_VIEW_DESC* pDesc); 47 | 48 | D3D11RenderTargetView* GetD3D11Iface() { 49 | return m_d3d11; 50 | } 51 | 52 | private: 53 | 54 | D3D11RenderTargetView* m_d3d11; 55 | 56 | }; 57 | 58 | } -------------------------------------------------------------------------------- /src/d3d10/d3d10core.def: -------------------------------------------------------------------------------- 1 | LIBRARY D3D10CORE.DLL 2 | EXPORTS 3 | D3D10CoreCreateDevice 4 | D3D10CoreGetVersion 5 | D3D10CoreRegisterLayers 6 | -------------------------------------------------------------------------------- /src/d3d10/d3d10core.sym: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | D3D10CoreCreateDevice; 4 | D3D10CoreGetVersion; 5 | D3D10CoreRegisterLayers; 6 | 7 | local: 8 | *; 9 | }; 10 | -------------------------------------------------------------------------------- /src/d3d10/meson.build: -------------------------------------------------------------------------------- 1 | d3d10_core_res = wrc_generator.process('version10_core.rc') 2 | 3 | d3d10_core_src = [ 4 | 'd3d10_core.cpp', 5 | ] 6 | 7 | d3d10_core_ld_args = [] 8 | d3d10_core_link_depends = [] 9 | 10 | if platform == 'windows' 11 | d3d10_d3d11_dep = lib_d3d11 12 | else 13 | d3d10_core_ld_args += [ '-Wl,--version-script', join_paths(meson.current_source_dir(), 'd3d10core.sym') ] 14 | d3d10_core_link_depends += files('d3d10core.sym') 15 | d3d10_d3d11_dep = d3d11_dep 16 | endif 17 | 18 | d3d10_core_dll = shared_library(dxvk_name_prefix+'d3d10core', d3d10_core_src, d3d10_core_res, 19 | dependencies : [ d3d10_d3d11_dep ], 20 | include_directories : dxvk_include_path, 21 | install : true, 22 | vs_module_defs : 'd3d10core'+def_spec_ext, 23 | link_args : d3d10_core_ld_args, 24 | link_depends : [ d3d10_core_link_depends ], 25 | kwargs : dxvk_so_version, 26 | ) 27 | 28 | d3d10_core_dep = declare_dependency( 29 | link_with : [ d3d10_core_dll ], 30 | ) 31 | 32 | if platform != 'windows' 33 | pkg.generate(d3d10_core_dll, 34 | filebase: dxvk_pkg_prefix + 'd3d10core', 35 | subdirs: 'dxvk', 36 | ) 37 | endif 38 | -------------------------------------------------------------------------------- /src/d3d10/version10_core.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // DLL version information. 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION 10,0,17763,1 6 | PRODUCTVERSION 10,0,17763,1 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_NT_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE VFT2_UNKNOWN 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "080904b0" 16 | BEGIN 17 | VALUE "CompanyName", "DXVK" 18 | VALUE "FileDescription", "Direct3D 10 Runtime" 19 | VALUE "FileVersion", "10.0.17763.1 (WinBuild.160101.0800)" 20 | VALUE "InternalName", "D3D10Core.dll" 21 | VALUE "LegalCopyright", "zlib/libpng license" 22 | VALUE "OriginalFilename", "D3D10Core.dll" 23 | VALUE "ProductName", "DXVK" 24 | VALUE "ProductVersion", "10.0.17763.1" 25 | END 26 | END 27 | BLOCK "VarFileInfo" 28 | BEGIN 29 | VALUE "Translation", 0x0809, 1200 30 | END 31 | END 32 | 33 | -------------------------------------------------------------------------------- /src/d3d11/d3d11.def: -------------------------------------------------------------------------------- 1 | LIBRARY D3D11.DLL 2 | EXPORTS 3 | D3D11CoreCreateDevice @18 4 | D3D11CreateDevice @22 5 | D3D11CreateDeviceAndSwapChain @23 6 | D3D11On12CreateDevice @24 7 | -------------------------------------------------------------------------------- /src/d3d11/d3d11.sym: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | D3D11CoreCreateDevice; 4 | D3D11CreateDevice; 5 | D3D11CreateDeviceAndSwapChain; 6 | D3D11On12CreateDevice; 7 | 8 | local: 9 | *; 10 | }; 11 | -------------------------------------------------------------------------------- /src/d3d11/d3d11_annotation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "d3d11_include.h" 6 | 7 | #include "../dxvk/dxvk_annotation.h" 8 | #include "../dxvk/dxvk_device.h" 9 | 10 | namespace dxvk { 11 | 12 | class D3D11DeferredContext; 13 | class D3D11ImmediateContext; 14 | 15 | template 16 | class D3D11UserDefinedAnnotation final : public IDXVKUserDefinedAnnotation { 17 | constexpr static bool IsDeferred = std::is_same_v; 18 | public: 19 | 20 | D3D11UserDefinedAnnotation( 21 | ContextType* container, 22 | const Rc& dxvkDevice); 23 | 24 | ~D3D11UserDefinedAnnotation(); 25 | 26 | D3D11UserDefinedAnnotation (const D3D11UserDefinedAnnotation&) = delete; 27 | D3D11UserDefinedAnnotation& operator = (const D3D11UserDefinedAnnotation&) = delete; 28 | 29 | ULONG STDMETHODCALLTYPE AddRef(); 30 | 31 | ULONG STDMETHODCALLTYPE Release(); 32 | 33 | HRESULT STDMETHODCALLTYPE QueryInterface( 34 | REFIID riid, 35 | void** ppvObject); 36 | 37 | INT STDMETHODCALLTYPE BeginEvent( 38 | D3DCOLOR Color, 39 | LPCWSTR Name); 40 | 41 | INT STDMETHODCALLTYPE EndEvent(); 42 | 43 | void STDMETHODCALLTYPE SetMarker( 44 | D3DCOLOR Color, 45 | LPCWSTR Name); 46 | 47 | BOOL STDMETHODCALLTYPE GetStatus(); 48 | 49 | private: 50 | 51 | ContextType* m_container; 52 | int32_t m_eventDepth; 53 | bool m_annotationsEnabled; 54 | }; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/d3d11/d3d11_class_linkage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d11_device_child.h" 4 | 5 | namespace dxvk { 6 | 7 | class D3D11Device; 8 | 9 | // TODO implement properly 10 | class D3D11ClassLinkage : public D3D11DeviceChild { 11 | 12 | public: 13 | 14 | D3D11ClassLinkage( 15 | D3D11Device* pDevice); 16 | 17 | ~D3D11ClassLinkage(); 18 | 19 | HRESULT STDMETHODCALLTYPE QueryInterface( 20 | REFIID riid, 21 | void** ppvObject) final; 22 | 23 | HRESULT STDMETHODCALLTYPE CreateClassInstance( 24 | LPCSTR pClassTypeName, 25 | UINT ConstantBufferOffset, 26 | UINT ConstantVectorOffset, 27 | UINT TextureOffset, 28 | UINT SamplerOffset, 29 | ID3D11ClassInstance **ppInstance); 30 | 31 | HRESULT STDMETHODCALLTYPE GetClassInstance( 32 | LPCSTR pClassInstanceName, 33 | UINT InstanceIndex, 34 | ID3D11ClassInstance **ppInstance); 35 | 36 | }; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/d3d11/d3d11_cmd.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d11_include.h" 4 | 5 | namespace dxvk { 6 | 7 | /** 8 | * \brief D3D11 command type 9 | * 10 | * Used to identify the type of command 11 | * data most recently added to a CS chunk. 12 | */ 13 | enum class D3D11CmdType { 14 | DrawIndirect, 15 | DrawIndirectIndexed, 16 | }; 17 | 18 | 19 | /** 20 | * \brief Command data header 21 | * 22 | * Stores the command type. All command 23 | * data structs must inherit this struct. 24 | */ 25 | struct D3D11CmdData { 26 | D3D11CmdType type; 27 | }; 28 | 29 | 30 | /** 31 | * \brief Indirect draw command data 32 | * 33 | * Stores the offset into the draw buffer for 34 | * the first draw, as well as the number of 35 | * draws to execute. 36 | */ 37 | struct D3D11CmdDrawIndirectData : public D3D11CmdData { 38 | uint32_t offset; 39 | uint32_t count; 40 | uint32_t stride; 41 | }; 42 | 43 | } -------------------------------------------------------------------------------- /src/d3d11/d3d11_enums.cpp: -------------------------------------------------------------------------------- 1 | #include "d3d11_enums.h" 2 | 3 | std::ostream& operator << (std::ostream& os, D3D_FEATURE_LEVEL e) { 4 | switch (e) { 5 | ENUM_NAME(D3D_FEATURE_LEVEL_9_1); 6 | ENUM_NAME(D3D_FEATURE_LEVEL_9_2); 7 | ENUM_NAME(D3D_FEATURE_LEVEL_9_3); 8 | ENUM_NAME(D3D_FEATURE_LEVEL_10_0); 9 | ENUM_NAME(D3D_FEATURE_LEVEL_10_1); 10 | ENUM_NAME(D3D_FEATURE_LEVEL_11_0); 11 | ENUM_NAME(D3D_FEATURE_LEVEL_11_1); 12 | ENUM_NAME(D3D_FEATURE_LEVEL_12_0); 13 | ENUM_NAME(D3D_FEATURE_LEVEL_12_1); 14 | ENUM_DEFAULT(e); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/d3d11/d3d11_enums.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "d3d11_include.h" 6 | 7 | std::ostream& operator << (std::ostream& os, D3D_FEATURE_LEVEL e); -------------------------------------------------------------------------------- /src/d3d11/d3d11_fence.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../dxvk/dxvk_fence.h" 4 | #include "../dxvk/dxvk_gpu_query.h" 5 | 6 | #include "d3d11_device_child.h" 7 | 8 | namespace dxvk { 9 | 10 | class D3D11Fence : public D3D11DeviceChild { 11 | 12 | public: 13 | 14 | D3D11Fence( 15 | D3D11Device* pDevice, 16 | UINT64 InitialValue, 17 | D3D11_FENCE_FLAG Flags, 18 | HANDLE hFence); 19 | 20 | ~D3D11Fence(); 21 | 22 | HRESULT STDMETHODCALLTYPE QueryInterface( 23 | REFIID riid, 24 | void** ppvObject); 25 | 26 | HRESULT STDMETHODCALLTYPE CreateSharedHandle( 27 | const SECURITY_ATTRIBUTES* pAttributes, 28 | DWORD dwAccess, 29 | LPCWSTR lpName, 30 | HANDLE* pHandle); 31 | 32 | HRESULT STDMETHODCALLTYPE SetEventOnCompletion( 33 | UINT64 Value, 34 | HANDLE hEvent); 35 | 36 | UINT64 STDMETHODCALLTYPE GetCompletedValue(); 37 | 38 | Rc GetFence() const { 39 | return m_fence; 40 | } 41 | 42 | private: 43 | 44 | Rc m_fence; 45 | D3D11_FENCE_FLAG m_flags; 46 | 47 | }; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/d3d11/d3d11_gdi.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "d3d11_include.h" 6 | 7 | namespace dxvk { 8 | 9 | class D3D11GDISurface { 10 | 11 | public: 12 | 13 | D3D11GDISurface( 14 | ID3D11Resource* pResource, 15 | UINT Subresource); 16 | 17 | ~D3D11GDISurface(); 18 | 19 | HRESULT Acquire( 20 | BOOL Discard, 21 | HDC* phdc); 22 | 23 | HRESULT Release( 24 | const RECT* pDirtyRect); 25 | 26 | private: 27 | 28 | ID3D11Resource* m_resource; 29 | uint32_t m_subresource; 30 | ID3D11Resource* m_readback; 31 | HDC m_hdc; 32 | HANDLE m_hbitmap; 33 | bool m_acquired; 34 | 35 | std::vector m_data; 36 | 37 | HRESULT CreateReadbackResource(); 38 | 39 | }; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/d3d11/d3d11_include.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../dxgi/dxgi_include.h" 4 | 5 | #include 6 | -------------------------------------------------------------------------------- /src/d3d11/d3d11_input_layout.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d11_device_child.h" 4 | 5 | #include "../d3d10/d3d10_input_layout.h" 6 | 7 | namespace dxvk { 8 | 9 | class D3D11Device; 10 | 11 | class D3D11InputLayout : public D3D11DeviceChild { 12 | 13 | public: 14 | 15 | D3D11InputLayout( 16 | D3D11Device* pDevice, 17 | uint32_t numAttributes, 18 | const DxvkVertexAttribute* pAttributes, 19 | uint32_t numBindings, 20 | const DxvkVertexBinding* pBindings); 21 | 22 | ~D3D11InputLayout(); 23 | 24 | HRESULT STDMETHODCALLTYPE QueryInterface( 25 | REFIID riid, 26 | void** ppvObject) final; 27 | 28 | void BindToContext(DxvkContext* ctx); 29 | 30 | bool Compare( 31 | const D3D11InputLayout* pOther) const; 32 | 33 | D3D10InputLayout* GetD3D10Iface() { 34 | return &m_d3d10; 35 | } 36 | 37 | private: 38 | 39 | std::vector m_attributes; 40 | std::vector m_bindings; 41 | 42 | D3D10InputLayout m_d3d10; 43 | 44 | }; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/d3d11/d3d11_sampler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../dxvk/dxvk_device.h" 4 | 5 | #include "../d3d10/d3d10_sampler.h" 6 | 7 | #include "d3d11_device_child.h" 8 | 9 | namespace dxvk { 10 | 11 | class D3D11Device; 12 | 13 | class D3D11SamplerState : public D3D11StateObject { 14 | 15 | public: 16 | 17 | using DescType = D3D11_SAMPLER_DESC; 18 | 19 | D3D11SamplerState( 20 | D3D11Device* device, 21 | const D3D11_SAMPLER_DESC& desc); 22 | ~D3D11SamplerState(); 23 | 24 | HRESULT STDMETHODCALLTYPE QueryInterface( 25 | REFIID riid, 26 | void** ppvObject) final; 27 | 28 | void STDMETHODCALLTYPE GetDesc( 29 | D3D11_SAMPLER_DESC* pDesc) final; 30 | 31 | Rc GetDXVKSampler() const { 32 | return m_sampler; 33 | } 34 | 35 | D3D10SamplerState* GetD3D10Iface() { 36 | return &m_d3d10; 37 | } 38 | 39 | static HRESULT NormalizeDesc( 40 | D3D11_SAMPLER_DESC* pDesc); 41 | 42 | private: 43 | 44 | D3D11_SAMPLER_DESC m_desc; 45 | Rc m_sampler; 46 | D3D10SamplerState m_d3d10; 47 | 48 | std::atomic m_refCount = { 0u }; 49 | 50 | static bool ValidateAddressMode( 51 | D3D11_TEXTURE_ADDRESS_MODE Mode); 52 | 53 | static bool ValidateComparisonFunc( 54 | D3D11_COMPARISON_FUNC Comparison); 55 | 56 | }; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/d3d11/d3d11_state_object.cpp: -------------------------------------------------------------------------------- 1 | #include "d3d11_state_object.h" 2 | 3 | namespace dxvk { 4 | 5 | D3D11DeviceContextState::D3D11DeviceContextState( 6 | D3D11Device* pDevice) 7 | : D3D11DeviceChild(pDevice) { 8 | 9 | } 10 | 11 | 12 | D3D11DeviceContextState::~D3D11DeviceContextState() { 13 | 14 | } 15 | 16 | 17 | HRESULT STDMETHODCALLTYPE D3D11DeviceContextState::QueryInterface( 18 | REFIID riid, 19 | void** ppvObject) { 20 | if (ppvObject == nullptr) 21 | return E_POINTER; 22 | 23 | *ppvObject = nullptr; 24 | 25 | if (riid == __uuidof(IUnknown) 26 | || riid == __uuidof(ID3D11DeviceChild) 27 | || riid == __uuidof(ID3DDeviceContextState)) { 28 | *ppvObject = ref(this); 29 | return S_OK; 30 | } 31 | 32 | if (logQueryInterfaceError(__uuidof(ID3DDeviceContextState), riid)) { 33 | Logger::warn("D3D11DeviceContextState::QueryInterface: Unknown interface query"); 34 | Logger::warn(str::format(riid)); 35 | } 36 | 37 | return E_NOINTERFACE; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/d3d11/d3d11_state_object.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d11_device.h" 4 | #include "d3d11_context_state.h" 5 | #include "d3d11_device_child.h" 6 | 7 | namespace dxvk { 8 | 9 | /** 10 | * \brief Device context state implementation 11 | * 12 | * This is an opaque interface in D3D11, and we only 13 | * implement the state block-like functionality, not 14 | * the methods to disable certain context and device 15 | * interfaces based on the emulated device IID. 16 | */ 17 | class D3D11DeviceContextState : public D3D11DeviceChild { 18 | 19 | public: 20 | 21 | D3D11DeviceContextState( 22 | D3D11Device* pDevice); 23 | 24 | ~D3D11DeviceContextState(); 25 | 26 | HRESULT STDMETHODCALLTYPE QueryInterface( 27 | REFIID riid, 28 | void** ppvObject); 29 | 30 | void SetState(const D3D11ContextState& State) { 31 | m_state = State; 32 | } 33 | 34 | void GetState(D3D11ContextState& State) const { 35 | State = m_state; 36 | } 37 | 38 | private: 39 | 40 | D3D11ContextState m_state; 41 | 42 | }; 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/d3d11/shaders/d3d11_video_blit_vert.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) out vec2 o_texcoord; 4 | 5 | void main() { 6 | vec2 coord = vec2( 7 | float(gl_VertexIndex & 1) * 2.0f, 8 | float(gl_VertexIndex & 2)); 9 | 10 | o_texcoord = coord; 11 | gl_Position = vec4(-1.0f + 2.0f * coord, 0.0f, 1.0f); 12 | } 13 | -------------------------------------------------------------------------------- /src/d3d11/version.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // DLL version information. 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION 10,0,17763,1 6 | PRODUCTVERSION 10,0,17763,1 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_NT_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE VFT2_UNKNOWN 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "080904b0" 16 | BEGIN 17 | VALUE "CompanyName", "DXVK" 18 | VALUE "FileDescription", "Direct3D 11 Runtime" 19 | VALUE "FileVersion", "10.0.17763.1 (WinBuild.160101.0800)" 20 | VALUE "InternalName", "D3D11.dll" 21 | VALUE "LegalCopyright", "zlib/libpng license" 22 | VALUE "OriginalFilename", "D3D11.dll" 23 | VALUE "ProductName", "DXVK" 24 | VALUE "ProductVersion", "10.0.17763.1" 25 | END 26 | END 27 | BLOCK "VarFileInfo" 28 | BEGIN 29 | VALUE "Translation", 0x0809, 1200 30 | END 31 | END 32 | 33 | -------------------------------------------------------------------------------- /src/d3d8/d3d8.def: -------------------------------------------------------------------------------- 1 | LIBRARY D3D8.DLL 2 | EXPORTS 3 | Direct3DCreate8 @ 5 4 | -------------------------------------------------------------------------------- /src/d3d8/d3d8.sym: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | Direct3DCreate8; 4 | 5 | local: 6 | *; 7 | }; 8 | -------------------------------------------------------------------------------- /src/d3d8/d3d8_caps.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace dxvk::d8caps { 4 | 5 | inline constexpr uint32_t MAX_TEXTURE_STAGES = 8; 6 | inline constexpr uint32_t MAX_STREAMS = 16; 7 | 8 | } -------------------------------------------------------------------------------- /src/d3d8/d3d8_main.cpp: -------------------------------------------------------------------------------- 1 | #include "d3d8_interface.h" 2 | 3 | namespace dxvk { 4 | Logger Logger::s_instance("d3d8.log"); 5 | 6 | HRESULT CreateD3D8(IDirect3D8** ppDirect3D8) { 7 | if (!ppDirect3D8) 8 | return D3DERR_INVALIDCALL; 9 | 10 | *ppDirect3D8 = ref(new D3D8Interface()); 11 | return D3D_OK; 12 | } 13 | } 14 | 15 | extern "C" { 16 | DLLEXPORT IDirect3D8* __stdcall Direct3DCreate8(UINT nSDKVersion) { 17 | dxvk::Logger::trace("Direct3DCreate8 called"); 18 | 19 | IDirect3D8* pDirect3D = nullptr; 20 | dxvk::CreateD3D8(&pDirect3D); 21 | 22 | return pDirect3D; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/d3d8/d3d8_shader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d8_include.h" 4 | #include "d3d8_options.h" 5 | 6 | namespace dxvk { 7 | 8 | struct D3D9VertexShaderCode { 9 | d3d9::D3DVERTEXELEMENT9 declaration[MAXD3DDECLLENGTH + 1]; 10 | std::vector function; 11 | }; 12 | 13 | D3D9VertexShaderCode TranslateVertexShader8( 14 | const DWORD* pDeclaration, 15 | const DWORD* pFunction, 16 | const D3D8Options& overrides); 17 | 18 | } -------------------------------------------------------------------------------- /src/d3d8/d3d8_state_block.cpp: -------------------------------------------------------------------------------- 1 | #include "d3d8_device.h" 2 | #include "d3d8_state_block.h" 3 | 4 | HRESULT dxvk::D3D8StateBlock::Capture() { 5 | if (unlikely(m_stateBlock == nullptr)) 6 | return D3DERR_INVALIDCALL; 7 | 8 | if (m_capture.vs) m_device->GetVertexShader(&m_vertexShader); 9 | if (m_capture.ps) m_device->GetPixelShader(&m_pixelShader); 10 | 11 | for (DWORD stage = 0; stage < m_textures.size(); stage++) { 12 | if (m_capture.textures.get(stage)) 13 | m_textures[stage] = m_device->m_textures[stage].ptr(); 14 | } 15 | 16 | if (m_capture.indices) { 17 | m_baseVertexIndex = m_device->m_baseVertexIndex; 18 | m_indices = m_device->m_indices.ptr(); 19 | } 20 | 21 | if (m_capture.swvp) 22 | m_device->GetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, (DWORD*)&m_isSWVP); 23 | 24 | return m_stateBlock->Capture(); 25 | } 26 | 27 | HRESULT dxvk::D3D8StateBlock::Apply() { 28 | if (unlikely(m_stateBlock == nullptr)) 29 | return D3DERR_INVALIDCALL; 30 | 31 | HRESULT res = m_stateBlock->Apply(); 32 | 33 | if (m_capture.vs) m_device->SetVertexShader(m_vertexShader); 34 | if (m_capture.ps) m_device->SetPixelShader(m_pixelShader); 35 | 36 | for (DWORD stage = 0; stage < m_textures.size(); stage++) { 37 | if (m_capture.textures.get(stage)) 38 | m_device->SetTexture(stage, m_textures[stage]); 39 | } 40 | 41 | if (m_capture.indices) 42 | m_device->SetIndices(m_indices, m_baseVertexIndex); 43 | 44 | // This was a very easy footgun for D3D8 applications. 45 | if (m_capture.swvp) 46 | m_device->SetRenderState(D3DRS_SOFTWAREVERTEXPROCESSING, m_isSWVP); 47 | 48 | return res; 49 | } 50 | -------------------------------------------------------------------------------- /src/d3d8/d3d8_surface.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "d3d8_surface.h" 3 | #include "d3d8_device.h" 4 | 5 | namespace dxvk { 6 | 7 | Com D3D8Surface::CreateBlitImage() { 8 | d3d9::D3DSURFACE_DESC desc; 9 | GetD3D9()->GetDesc(&desc); 10 | 11 | // NOTE: This adds a D3DPOOL_DEFAULT resource to the 12 | // device, which counts as losable during device reset 13 | Com image = nullptr; 14 | HRESULT res = GetParent()->GetD3D9()->CreateRenderTarget( 15 | desc.Width, desc.Height, desc.Format, 16 | d3d9::D3DMULTISAMPLE_NONE, 0, 17 | FALSE, 18 | &image, 19 | NULL); 20 | 21 | if (FAILED(res)) 22 | throw new DxvkError("D3D8: Failed to create blit image"); 23 | 24 | return image; 25 | } 26 | } -------------------------------------------------------------------------------- /src/d3d8/d3d8_swapchain.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d8_device_child.h" 4 | #include "d3d8_surface.h" 5 | #include "d3d8_d3d9_util.h" 6 | 7 | namespace dxvk { 8 | 9 | using D3D8SwapChainBase = D3D8DeviceChild; 10 | class D3D8SwapChain final : public D3D8SwapChainBase { 11 | 12 | public: 13 | 14 | D3D8SwapChain( 15 | D3D8Device* pDevice, 16 | Com&& pSwapChain) 17 | : D3D8SwapChainBase(pDevice, std::move(pSwapChain)) {} 18 | 19 | HRESULT STDMETHODCALLTYPE Present(const RECT *src, const RECT *dst, HWND hWnd, const RGNDATA *dirtyRegion) final { 20 | return GetD3D9()->Present(src, dst, hWnd, dirtyRegion, 0); 21 | } 22 | 23 | HRESULT STDMETHODCALLTYPE GetBackBuffer(UINT BackBuffer, D3DBACKBUFFER_TYPE Type, IDirect3DSurface8** ppBackBuffer) final { 24 | // Same logic as in D3D8Device::GetBackBuffer 25 | if (unlikely(m_backBuffer == nullptr)) { 26 | Com pSurface9; 27 | HRESULT res = GetD3D9()->GetBackBuffer(BackBuffer, (d3d9::D3DBACKBUFFER_TYPE)Type, &pSurface9); 28 | 29 | m_backBuffer = new D3D8Surface(GetParent(), std::move(pSurface9)); 30 | *ppBackBuffer = m_backBuffer.ref(); 31 | return res; 32 | } 33 | 34 | *ppBackBuffer = m_backBuffer.ref(); 35 | return D3D_OK; 36 | } 37 | private: 38 | Com m_backBuffer = nullptr; 39 | 40 | }; 41 | 42 | } -------------------------------------------------------------------------------- /src/d3d8/d3d8_volume.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d8_subresource.h" 4 | #include "d3d8_d3d9_util.h" 5 | 6 | namespace dxvk { 7 | 8 | using D3D8VolumeBase = D3D8Subresource; 9 | class D3D8Volume final : public D3D8VolumeBase { 10 | 11 | public: 12 | 13 | D3D8Volume( 14 | D3D8Device* pDevice, 15 | IDirect3DVolumeTexture8* pTexture, 16 | Com&& pVolume) 17 | : D3D8VolumeBase(pDevice, std::move(pVolume), pTexture) {} 18 | 19 | HRESULT STDMETHODCALLTYPE GetDesc(D3DVOLUME_DESC* pDesc) { 20 | d3d9::D3DVOLUME_DESC desc; 21 | HRESULT res = GetD3D9()->GetDesc(&desc); 22 | ConvertVolumeDesc8(&desc, pDesc); 23 | return res; 24 | } 25 | 26 | HRESULT STDMETHODCALLTYPE LockBox(D3DLOCKED_BOX* pLockedBox, CONST D3DBOX* pBox, DWORD Flags) final { 27 | return GetD3D9()->LockBox( 28 | reinterpret_cast(pLockedBox), 29 | reinterpret_cast(pBox), 30 | Flags 31 | ); 32 | } 33 | 34 | HRESULT STDMETHODCALLTYPE UnlockBox() final { 35 | return GetD3D9()->UnlockBox(); 36 | } 37 | 38 | }; 39 | 40 | } -------------------------------------------------------------------------------- /src/d3d8/d3d8_wrapped_object.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d8_include.h" 4 | 5 | namespace dxvk { 6 | 7 | template 8 | class D3D8WrappedObject : public ComObjectClamp { 9 | 10 | public: 11 | 12 | using D3D9 = D3D9Type; 13 | using D3D8 = D3D8Type; 14 | 15 | D3D8WrappedObject(Com&& object) 16 | : m_d3d9(std::move(object)) { 17 | } 18 | 19 | D3D9* GetD3D9() { 20 | return m_d3d9.ptr(); 21 | } 22 | 23 | // For cases where the object may be null. 24 | static D3D9* GetD3D9Nullable(D3D8WrappedObject* self) { 25 | if (unlikely(self == NULL)) { 26 | return NULL; 27 | } 28 | return self->m_d3d9.ptr(); 29 | } 30 | 31 | template 32 | static D3D9* GetD3D9Nullable(Com& self) { 33 | return GetD3D9Nullable(self.ptr()); 34 | } 35 | 36 | virtual IUnknown* GetInterface(REFIID riid) { 37 | if (riid == __uuidof(IUnknown)) 38 | return this; 39 | if (riid == __uuidof(D3D8)) 40 | return this; 41 | 42 | throw E_NOINTERFACE; 43 | } 44 | 45 | HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) final { 46 | if (ppvObject == nullptr) 47 | return E_POINTER; 48 | 49 | *ppvObject = nullptr; 50 | 51 | try { 52 | *ppvObject = ref(this->GetInterface(riid)); 53 | return S_OK; 54 | } catch (HRESULT err) { 55 | Logger::warn("D3D8WrappedObject::QueryInterface: Unknown interface query"); 56 | Logger::warn(str::format(riid)); 57 | return err; 58 | } 59 | } 60 | 61 | 62 | private: 63 | 64 | Com m_d3d9; 65 | 66 | }; 67 | 68 | } -------------------------------------------------------------------------------- /src/d3d8/meson.build: -------------------------------------------------------------------------------- 1 | d3d8_res = wrc_generator.process('version.rc') 2 | 3 | d3d8_src = [ 4 | 'd3d8_main.cpp', 5 | 'd3d8_interface.cpp', 6 | 'd3d8_device.cpp', 7 | 'd3d8_options.cpp', 8 | 'd3d8_surface.cpp', 9 | 'd3d8_state_block.cpp', 10 | 'd3d8_shader.cpp' 11 | ] 12 | 13 | d3d8_ld_args = [] 14 | d3d8_link_depends = [] 15 | 16 | if platform != 'windows' 17 | lib_d3d9 = d3d9_dep 18 | d3d8_ld_args += [ '-Wl,--version-script', join_paths(meson.current_source_dir(), 'd3d8.sym') ] 19 | d3d8_link_depends += files('d3d8.sym') 20 | endif 21 | 22 | d3d8_dll = shared_library(dxvk_name_prefix+'d3d8', d3d8_src, d3d8_res, 23 | dependencies : [ lib_d3d9, util_dep, dxso_dep, dxvk_dep ], 24 | include_directories : dxvk_include_path, 25 | install : true, 26 | vs_module_defs : 'd3d8'+def_spec_ext, 27 | link_args : d3d8_ld_args, 28 | link_depends : [ d3d8_link_depends ], 29 | kwargs : dxvk_so_version, 30 | ) 31 | 32 | d3d8_dep = declare_dependency( 33 | link_with : [ d3d8_dll ], 34 | include_directories : [ dxvk_include_path ], 35 | ) 36 | 37 | if platform != 'windows' 38 | pkg.generate(d3d8_dll, 39 | filebase: dxvk_pkg_prefix + 'd3d8', 40 | subdirs: 'dxvk', 41 | ) 42 | endif 43 | -------------------------------------------------------------------------------- /src/d3d8/version.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | // DLL version information. 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION 10,0,17763,1 6 | PRODUCTVERSION 10,0,17763,1 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | FILEFLAGS 0 9 | FILEOS VOS_NT_WINDOWS32 10 | FILETYPE VFT_DLL 11 | FILESUBTYPE VFT2_UNKNOWN 12 | BEGIN 13 | BLOCK "StringFileInfo" 14 | BEGIN 15 | BLOCK "080904b0" 16 | BEGIN 17 | VALUE "CompanyName", "DXVK" 18 | VALUE "FileDescription", "Direct3D 8 Runtime" 19 | VALUE "FileVersion", "10.0.17763.1 (WinBuild.160101.0800)" 20 | VALUE "InternalName", "D3D8.dll" 21 | VALUE "LegalCopyright", "zlib/libpng license" 22 | VALUE "OriginalFilename", "D3D8.dll" 23 | VALUE "ProductName", "DXVK" 24 | VALUE "ProductVersion", "10.0.17763.1" 25 | END 26 | END 27 | BLOCK "VarFileInfo" 28 | BEGIN 29 | VALUE "Translation", 0x0809, 1200 30 | END 31 | END 32 | -------------------------------------------------------------------------------- /src/d3d9/d3d9.def: -------------------------------------------------------------------------------- 1 | LIBRARY D3D9.DLL 2 | EXPORTS 3 | Direct3DShaderValidatorCreate9 @24 4 | 5 | PSGPError @25 6 | PSGPSampleTexture @26 7 | 8 | D3DPERF_BeginEvent @27 9 | D3DPERF_EndEvent @28 10 | D3DPERF_GetStatus @29 11 | D3DPERF_QueryRepeatFrame @30 12 | D3DPERF_SetMarker @31 13 | D3DPERF_SetOptions @32 14 | D3DPERF_SetRegion @33 15 | 16 | DebugSetLevel @34 17 | DebugSetMute @35 18 | 19 | Direct3D9EnableMaximizedWindowedModeShim @36 20 | 21 | Direct3DCreate9 @37 22 | Direct3DCreate9Ex @38 23 | 24 | DXVK_RegisterAnnotation @28257 NONAME 25 | DXVK_UnRegisterAnnotation @28258 NONAME 26 | 27 | Direct3D9ForceHybridEnumeration @16 NONAME PRIVATE 28 | 29 | Direct3DCreate9On12 @20 30 | Direct3DCreate9On12Ex @21 31 | -------------------------------------------------------------------------------- /src/d3d9/d3d9.sym: -------------------------------------------------------------------------------- 1 | { 2 | global: 3 | Direct3DCreate9; 4 | Direct3DCreate9Ex; 5 | D3DPERF_BeginEvent; 6 | D3DPERF_EndEvent; 7 | D3DPERF_SetMarker; 8 | D3DPERF_SetRegion; 9 | D3DPERF_QueryRepeatFrame; 10 | D3DPERF_SetOptions; 11 | D3DPERF_GetStatus; 12 | DebugSetMute; 13 | DebugSetLevel; 14 | PSGPError; 15 | PSGPSampleTexture; 16 | Direct3DShaderValidatorCreate9; 17 | Direct3D9EnableMaximizedWindowedModeShim; 18 | DXVK_RegisterAnnotation; 19 | DXVK_UnRegisterAnnotation; 20 | Direct3D9ForceHybridEnumeration; 21 | Direct3DCreate9On12; 22 | Direct3DCreate9On12Ex; 23 | 24 | local: 25 | *; 26 | }; 27 | -------------------------------------------------------------------------------- /src/d3d9/d3d9_caps.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d9_include.h" 4 | 5 | namespace dxvk::caps { 6 | 7 | constexpr uint32_t MaxClipPlanes = 6; 8 | constexpr uint32_t MaxSamplers = 16; 9 | constexpr uint32_t MaxStreams = 16; 10 | constexpr uint32_t MaxSimultaneousTextures = 8; 11 | constexpr uint32_t MaxTextureBlendStages = MaxSimultaneousTextures; 12 | constexpr uint32_t MaxSimultaneousRenderTargets = D3D_MAX_SIMULTANEOUS_RENDERTARGETS; 13 | 14 | constexpr uint32_t MaxFloatConstantsVS = 256; 15 | constexpr uint32_t MaxFloatConstantsPS = 224; 16 | constexpr uint32_t MaxOtherConstants = 16; 17 | constexpr uint32_t MaxFloatConstantsSoftware = 8192; 18 | constexpr uint32_t MaxOtherConstantsSoftware = 2048; 19 | 20 | constexpr uint32_t InputRegisterCount = 16; 21 | 22 | constexpr uint32_t MaxTextureDimension = 16384; 23 | constexpr uint32_t MaxMipLevels = 15; 24 | constexpr uint32_t MaxSubresources = 15 * 6; 25 | 26 | constexpr uint32_t MaxTransforms = 10 + 256; 27 | 28 | constexpr uint32_t TextureStageCount = MaxSimultaneousTextures; 29 | 30 | constexpr uint32_t MaxEnabledLights = 8; 31 | 32 | constexpr uint32_t MaxTexturesVS = 4; 33 | constexpr uint32_t MaxTexturesPS = 16; 34 | 35 | } -------------------------------------------------------------------------------- /src/d3d9/d3d9_constant_layout.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "d3d9_caps.h" 6 | 7 | namespace dxvk { 8 | 9 | struct D3D9ConstantLayout { 10 | uint32_t floatCount; 11 | uint32_t intCount; 12 | uint32_t boolCount; 13 | uint32_t bitmaskCount; 14 | 15 | uint32_t floatSize() const { return floatCount * 4 * sizeof(float); } 16 | uint32_t intSize() const { return intCount * 4 * sizeof(int); } 17 | uint32_t bitmaskSize() const { 18 | // Account for SWVP (non SWVP uses a spec constant) 19 | return bitmaskCount != 1 20 | ? bitmaskCount * 1 * sizeof(uint32_t) 21 | : 0; 22 | } 23 | 24 | uint32_t intOffset() const { return 0; } 25 | uint32_t floatOffset() const { return intOffset() + intSize(); } 26 | uint32_t bitmaskOffset() const { return floatOffset() + floatSize(); } 27 | 28 | uint32_t totalSize() const { return floatSize() + intSize() + bitmaskSize(); } 29 | }; 30 | 31 | } -------------------------------------------------------------------------------- /src/d3d9/d3d9_constant_set.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d9_caps.h" 4 | #include "d3d9_constant_buffer.h" 5 | 6 | #include "../dxvk/dxvk_buffer.h" 7 | 8 | #include "../dxso/dxso_isgn.h" 9 | 10 | #include "../util/util_math.h" 11 | #include "../util/util_vector.h" 12 | 13 | #include 14 | 15 | namespace dxvk { 16 | 17 | enum class D3D9ConstantType { 18 | Float, 19 | Int, 20 | Bool 21 | }; 22 | 23 | // We make an assumption later based on the packing of this struct for copying. 24 | struct D3D9ShaderConstantsVSSoftware { 25 | Vector4i iConsts[caps::MaxOtherConstantsSoftware]; 26 | Vector4 fConsts[caps::MaxFloatConstantsSoftware]; 27 | uint32_t bConsts[caps::MaxOtherConstantsSoftware / 32]; 28 | }; 29 | 30 | struct D3D9ShaderConstantsVSHardware { 31 | Vector4i iConsts[caps::MaxOtherConstants]; 32 | Vector4 fConsts[caps::MaxFloatConstantsVS]; 33 | uint32_t bConsts[1]; 34 | }; 35 | 36 | struct D3D9ShaderConstantsPS { 37 | Vector4i iConsts[caps::MaxOtherConstants]; 38 | Vector4 fConsts[caps::MaxFloatConstantsPS]; 39 | uint32_t bConsts[1]; 40 | }; 41 | 42 | struct D3D9SwvpConstantBuffers { 43 | D3D9ConstantBuffer intBuffer; 44 | D3D9ConstantBuffer boolBuffer; 45 | }; 46 | 47 | struct D3D9ConstantSets { 48 | D3D9SwvpConstantBuffers swvp; 49 | D3D9ConstantBuffer buffer; 50 | DxsoShaderMetaInfo meta = {}; 51 | bool dirty = true; 52 | }; 53 | 54 | } -------------------------------------------------------------------------------- /src/d3d9/d3d9_cursor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d9_include.h" 4 | 5 | namespace dxvk { 6 | 7 | constexpr uint32_t HardwareCursorWidth = 32u; 8 | constexpr uint32_t HardwareCursorHeight = 32u; 9 | constexpr uint32_t HardwareCursorFormatSize = 4u; 10 | constexpr uint32_t HardwareCursorPitch = HardwareCursorWidth * HardwareCursorFormatSize; 11 | 12 | // Format Size of 4 bytes (ARGB) 13 | using CursorBitmap = uint8_t[HardwareCursorHeight * HardwareCursorPitch]; 14 | // Monochrome mask (1 bit) 15 | using CursorMask = uint8_t[HardwareCursorHeight * HardwareCursorWidth / 8]; 16 | 17 | class D3D9Cursor { 18 | 19 | public: 20 | 21 | #ifdef _WIN32 22 | ~D3D9Cursor() { 23 | if (m_hCursor != nullptr) 24 | ::DestroyCursor(m_hCursor); 25 | } 26 | #endif 27 | 28 | void UpdateCursor(int X, int Y); 29 | 30 | BOOL ShowCursor(BOOL bShow); 31 | 32 | HRESULT SetHardwareCursor(UINT XHotSpot, UINT YHotSpot, const CursorBitmap& bitmap); 33 | 34 | private: 35 | 36 | BOOL m_visible = FALSE; 37 | 38 | #ifdef _WIN32 39 | HCURSOR m_hCursor = nullptr; 40 | #endif 41 | 42 | }; 43 | 44 | } -------------------------------------------------------------------------------- /src/d3d9/d3d9_device_child.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d9_include.h" 4 | 5 | namespace dxvk { 6 | 7 | class D3D9DeviceEx; 8 | 9 | template 10 | class D3D9DeviceChild : public ComObjectClamp { 11 | 12 | public: 13 | 14 | D3D9DeviceChild(D3D9DeviceEx* pDevice) 15 | : m_parent( pDevice ) { } 16 | 17 | ULONG STDMETHODCALLTYPE AddRef() { 18 | uint32_t refCount = this->m_refCount++; 19 | if (unlikely(!refCount)) { 20 | this->AddRefPrivate(); 21 | GetDevice()->AddRef(); 22 | } 23 | 24 | return refCount + 1; 25 | } 26 | 27 | ULONG STDMETHODCALLTYPE Release() { 28 | uint32_t refCount = --this->m_refCount; 29 | if (unlikely(!refCount)) { 30 | auto* pDevice = GetDevice(); 31 | this->ReleasePrivate(); 32 | pDevice->Release(); 33 | } 34 | return refCount; 35 | } 36 | 37 | HRESULT STDMETHODCALLTYPE GetDevice(IDirect3DDevice9** ppDevice) { 38 | InitReturnPtr(ppDevice); 39 | 40 | if (ppDevice == nullptr) 41 | return D3DERR_INVALIDCALL; 42 | 43 | *ppDevice = ref(GetDevice()); 44 | return D3D_OK; 45 | } 46 | 47 | IDirect3DDevice9Ex* GetDevice() { 48 | return reinterpret_cast(m_parent); 49 | } 50 | 51 | D3D9DeviceEx* GetParent() { 52 | return m_parent; 53 | } 54 | 55 | protected: 56 | 57 | D3D9DeviceEx* m_parent; 58 | 59 | }; 60 | 61 | } -------------------------------------------------------------------------------- /src/d3d9/d3d9_format_helpers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d9_include.h" 4 | #include "d3d9_format.h" 5 | #include "../dxvk/dxvk_device.h" 6 | #include "../dxvk/dxvk_context.h" 7 | 8 | namespace dxvk { 9 | 10 | class D3D9FormatHelper { 11 | 12 | public: 13 | 14 | D3D9FormatHelper(const Rc& device); 15 | 16 | void Flush(); 17 | 18 | void ConvertFormat( 19 | D3D9_CONVERSION_FORMAT_INFO conversionFormat, 20 | const Rc& dstImage, 21 | VkImageSubresourceLayers dstSubresource, 22 | const DxvkBufferSlice& srcSlice); 23 | 24 | private: 25 | 26 | void ConvertGenericFormat( 27 | D3D9_CONVERSION_FORMAT_INFO videoFormat, 28 | const Rc& dstImage, 29 | VkImageSubresourceLayers dstSubresource, 30 | const DxvkBufferSlice& srcSlice, 31 | VkFormat bufferFormat, 32 | uint32_t specConstantValue, 33 | VkExtent2D macroPixelRun); 34 | 35 | enum BindingIds : uint32_t { 36 | Image = 0, 37 | Buffer = 1, 38 | }; 39 | 40 | void InitShaders(); 41 | 42 | Rc InitShader(SpirvCodeBuffer code); 43 | 44 | void FlushInternal(); 45 | 46 | Rc m_device; 47 | Rc m_context; 48 | 49 | size_t m_transferCommands = 0; 50 | 51 | std::array, D3D9ConversionFormat_Count> m_shaders; 52 | 53 | }; 54 | 55 | } -------------------------------------------------------------------------------- /src/d3d9/d3d9_hud.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d9_device.h" 4 | #include "../dxvk/hud/dxvk_hud_item.h" 5 | 6 | namespace dxvk::hud { 7 | 8 | /** 9 | * \brief HUD item to display sampler count 10 | */ 11 | class HudSamplerCount : public HudItem { 12 | 13 | public: 14 | 15 | HudSamplerCount(D3D9DeviceEx* device); 16 | 17 | void update(dxvk::high_resolution_clock::time_point time); 18 | 19 | HudPos render( 20 | HudRenderer& renderer, 21 | HudPos position); 22 | 23 | private: 24 | 25 | D3D9DeviceEx* m_device; 26 | 27 | std::string m_samplerCount; 28 | 29 | }; 30 | 31 | /** 32 | * \brief HUD item to display unmappable memory 33 | */ 34 | class HudTextureMemory : public HudItem { 35 | constexpr static int64_t UpdateInterval = 500'000; 36 | 37 | public: 38 | 39 | HudTextureMemory(D3D9DeviceEx* device); 40 | 41 | void update(dxvk::high_resolution_clock::time_point time); 42 | 43 | HudPos render( 44 | HudRenderer& renderer, 45 | HudPos position); 46 | 47 | private: 48 | 49 | D3D9DeviceEx* m_device; 50 | 51 | uint32_t m_maxAllocated = 0; 52 | uint32_t m_maxUsed = 0; 53 | uint32_t m_maxMapped = 0; 54 | 55 | dxvk::high_resolution_clock::time_point m_lastUpdate 56 | = dxvk::high_resolution_clock::now(); 57 | 58 | std::string m_allocatedString; 59 | std::string m_mappedString; 60 | 61 | }; 62 | 63 | } -------------------------------------------------------------------------------- /src/d3d9/d3d9_initializer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d9_common_buffer.h" 4 | #include "d3d9_common_texture.h" 5 | 6 | namespace dxvk { 7 | 8 | /** 9 | * \brief Resource initialization context 10 | * 11 | * Manages a context which is used for resource 12 | * initialization. This includes 13 | * zero-initialization for buffers and images. 14 | */ 15 | class D3D9Initializer { 16 | constexpr static size_t MaxTransferMemory = 32 * 1024 * 1024; 17 | constexpr static size_t MaxTransferCommands = 512; 18 | public: 19 | 20 | D3D9Initializer( 21 | const Rc& Device); 22 | 23 | ~D3D9Initializer(); 24 | 25 | void Flush(); 26 | 27 | void InitBuffer( 28 | D3D9CommonBuffer* pBuffer); 29 | 30 | void InitTexture( 31 | D3D9CommonTexture* pTexture, 32 | void* pInitialData = nullptr); 33 | 34 | private: 35 | 36 | dxvk::mutex m_mutex; 37 | 38 | Rc m_device; 39 | Rc m_context; 40 | 41 | size_t m_transferCommands = 0; 42 | size_t m_transferMemory = 0; 43 | 44 | void InitDeviceLocalBuffer( 45 | DxvkBufferSlice Slice); 46 | 47 | void InitHostVisibleBuffer( 48 | DxvkBufferSlice Slice); 49 | 50 | void InitDeviceLocalTexture( 51 | D3D9CommonTexture* pTexture); 52 | 53 | void InitHostVisibleTexture( 54 | D3D9CommonTexture* pTexture, 55 | void* pInitialData); 56 | 57 | void FlushImplicit(); 58 | void FlushInternal(); 59 | 60 | }; 61 | 62 | } -------------------------------------------------------------------------------- /src/d3d9/d3d9_multithread.cpp: -------------------------------------------------------------------------------- 1 | #include "d3d9_device.h" 2 | 3 | namespace dxvk { 4 | 5 | D3D9Multithread::D3D9Multithread( 6 | BOOL Protected) 7 | : m_protected( Protected ) { } 8 | 9 | } -------------------------------------------------------------------------------- /src/d3d9/d3d9_multithread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d9_include.h" 4 | 5 | namespace dxvk { 6 | 7 | /** 8 | * \brief Device lock 9 | * 10 | * Lightweight RAII wrapper that implements 11 | * a subset of the functionality provided by 12 | * \c std::unique_lock, with the goal of being 13 | * cheaper to construct and destroy. 14 | */ 15 | class D3D9DeviceLock { 16 | 17 | public: 18 | 19 | D3D9DeviceLock() 20 | : m_mutex(nullptr) { } 21 | 22 | D3D9DeviceLock(sync::RecursiveSpinlock& mutex) 23 | : m_mutex(&mutex) { 24 | mutex.lock(); 25 | } 26 | 27 | D3D9DeviceLock(D3D9DeviceLock&& other) 28 | : m_mutex(other.m_mutex) { 29 | other.m_mutex = nullptr; 30 | } 31 | 32 | D3D9DeviceLock& operator = (D3D9DeviceLock&& other) { 33 | if (m_mutex) 34 | m_mutex->unlock(); 35 | 36 | m_mutex = other.m_mutex; 37 | other.m_mutex = nullptr; 38 | return *this; 39 | } 40 | 41 | ~D3D9DeviceLock() { 42 | if (m_mutex != nullptr) 43 | m_mutex->unlock(); 44 | } 45 | 46 | private: 47 | 48 | sync::RecursiveSpinlock* m_mutex; 49 | 50 | }; 51 | 52 | 53 | /** 54 | * \brief D3D9 context lock 55 | */ 56 | class D3D9Multithread { 57 | 58 | public: 59 | 60 | D3D9Multithread( 61 | BOOL Protected); 62 | 63 | D3D9DeviceLock AcquireLock() { 64 | return m_protected 65 | ? D3D9DeviceLock(m_mutex) 66 | : D3D9DeviceLock(); 67 | } 68 | 69 | private: 70 | 71 | BOOL m_protected; 72 | 73 | sync::RecursiveSpinlock m_mutex; 74 | 75 | }; 76 | 77 | } -------------------------------------------------------------------------------- /src/d3d9/d3d9_names.h: -------------------------------------------------------------------------------- 1 | #include "d3d9_include.h" 2 | 3 | namespace dxvk { 4 | 5 | std::ostream& operator << (std::ostream& os, D3DRENDERSTATETYPE e); 6 | 7 | } -------------------------------------------------------------------------------- /src/d3d9/d3d9_on_12.cpp: -------------------------------------------------------------------------------- 1 | #include "d3d9_on_12.h" 2 | 3 | #include "d3d9_device.h" 4 | 5 | namespace dxvk { 6 | 7 | D3D9On12::D3D9On12(D3D9DeviceEx* device) 8 | : m_device(device) { 9 | 10 | } 11 | 12 | HRESULT STDMETHODCALLTYPE D3D9On12::QueryInterface(REFIID riid, void** object) { 13 | return m_device->QueryInterface(riid, object); 14 | } 15 | ULONG STDMETHODCALLTYPE D3D9On12::AddRef() { 16 | return m_device->AddRef(); 17 | } 18 | ULONG STDMETHODCALLTYPE D3D9On12::Release() { 19 | return m_device->Release(); 20 | } 21 | 22 | HRESULT STDMETHODCALLTYPE D3D9On12::GetD3D12Device(REFIID riid, void** object) { 23 | InitReturnPtr(object); 24 | 25 | Logger::err("D3D9On12::GetD3D12Device: Stub"); 26 | return E_NOINTERFACE; 27 | } 28 | HRESULT STDMETHODCALLTYPE D3D9On12::UnwrapUnderlyingResource(IDirect3DResource9* resource, ID3D12CommandQueue* command_queue, REFIID riid, void** object) { 29 | Logger::err("D3D9On12::GetD3D12Device: UnwrapUnderlyingResource: Stub"); 30 | return E_NOINTERFACE; 31 | } 32 | HRESULT STDMETHODCALLTYPE D3D9On12::ReturnUnderlyingResource(IDirect3DResource9* resource, UINT num_sync, UINT64* signal_values, ID3D12Fence** fences) { 33 | if (num_sync) 34 | Logger::err("D3D9On12::GetD3D12Device: ReturnUnderlyingResource: Stub"); 35 | 36 | m_device->FlushAndSync9On12(); 37 | return S_OK; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/d3d9/d3d9_on_12.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "d3d9_include.h" 4 | 5 | namespace dxvk { 6 | 7 | class D3D9DeviceEx; 8 | 9 | class D3D9On12 final : public IDirect3DDevice9On12 { 10 | 11 | public: 12 | 13 | D3D9On12(D3D9DeviceEx* device); 14 | 15 | HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** object); 16 | ULONG STDMETHODCALLTYPE AddRef(); 17 | ULONG STDMETHODCALLTYPE Release(); 18 | 19 | HRESULT STDMETHODCALLTYPE GetD3D12Device(REFIID riid, void** object); 20 | HRESULT STDMETHODCALLTYPE UnwrapUnderlyingResource(IDirect3DResource9* resource, ID3D12CommandQueue* command_queue, REFIID riid, void** object); 21 | HRESULT STDMETHODCALLTYPE ReturnUnderlyingResource(IDirect3DResource9* resource, UINT num_sync, UINT64* signal_values, ID3D12Fence** fences); 22 | 23 | private: 24 | 25 | D3D9DeviceEx* m_device; 26 | 27 | }; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/d3d9/d3d9_sampler.cpp: -------------------------------------------------------------------------------- 1 | #include "d3d9_sampler.h" 2 | 3 | namespace dxvk { 4 | 5 | size_t D3D9SamplerKeyHash::operator () (const D3D9SamplerKey& key) const { 6 | DxvkHashState state; 7 | 8 | std::hash dhash; 9 | std::hash tahash; 10 | std::hash tfhash; 11 | std::hash fhash; 12 | std::hash bhash; 13 | 14 | state.add(tahash(key.AddressU)); 15 | state.add(tahash(key.AddressV)); 16 | state.add(tahash(key.AddressW)); 17 | state.add(tfhash(key.MagFilter)); 18 | state.add(tfhash(key.MinFilter)); 19 | state.add(tfhash(key.MipFilter)); 20 | state.add(dhash (key.MaxAnisotropy)); 21 | state.add(fhash (key.MipmapLodBias)); 22 | state.add(dhash (key.MaxMipLevel)); 23 | state.add(dhash (key.BorderColor)); 24 | state.add(bhash (key.Depth)); 25 | 26 | return state; 27 | } 28 | 29 | 30 | bool D3D9SamplerKeyEq::operator () (const D3D9SamplerKey& a, const D3D9SamplerKey& b) const { 31 | return a.AddressU == b.AddressU 32 | && a.AddressV == b.AddressV 33 | && a.AddressW == b.AddressW 34 | && a.MagFilter == b.MagFilter 35 | && a.MinFilter == b.MinFilter 36 | && a.MipFilter == b.MipFilter 37 | && a.MaxAnisotropy == b.MaxAnisotropy 38 | && a.MipmapLodBias == b.MipmapLodBias 39 | && a.MaxMipLevel == b.MaxMipLevel 40 | && a.BorderColor == b.BorderColor 41 | && a.Depth == b.Depth; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /src/d3d9/d3d9_state.cpp: -------------------------------------------------------------------------------- 1 | #include "d3d9_state.h" 2 | 3 | #include "d3d9_texture.h" 4 | 5 | namespace dxvk { 6 | 7 | template