Compare commits

...

1545 Commits

Author SHA1 Message Date
Blisto91 c1f665f92b [util] Disable supportDFFormats for Prototype
Incorrect shadows on AMD & Intel
2024-05-18 19:31:07 +02:00
WinterSnowfall 20185a5309 [d3d9] Do not enable support for DF formats on Nvidia 2024-05-18 16:16:34 +00:00
Blisto91 0c2efda804 [meta] Add DXVK Native section to the readme 2024-05-16 10:57:35 +00:00
Blisto91 c7d61b2fc0 [native] Change DXVK_WSIDRIVER to DXVK_WSI_DRIVER 2024-05-16 10:57:35 +00:00
Ethan Lee 6259e86392 [meson] Use dependency() instead of find_library() for SDL2/GLFW detection.
Since we're not linking to the libraries anymore, it doesn't make much sense to
use find_library, and in fact we need to use dependency() in order to get the
right CFLAGS for includes, defines, etc, so use that instead.

As a result, we can remove the 'SDL2/' folders from the includes, making the SDL
includes more correct.
2024-05-13 13:18:03 +00:00
Ethan Lee d5d236a1e2 [wsi] Refactor platform system to support multiple WSI implementations 2024-05-13 13:18:03 +00:00
Ethan Lee 10b83d184b [native] Dynamically load SDL2/GLFW at runtime.
Removing these link-time dependencies is important for making a single binary that is compatible with either backend, regardless of whether or not each one is currently available to the program.
2024-05-13 13:18:03 +00:00
Ethan Lee 0f7c1f753a [wsi] Refactor the WSI backends to be implementations of a WsiDriver interface.
Rather than directly calling functions, the API now calls shared functions that call into a WsiDriver instance, which is allocated and implemented by the backend. Functionally this should be the same, it just has the extra allocation for the function table.

This prepares the WSI library for supporting multiple implementations in a single binary.
2024-05-13 13:18:03 +00:00
Ethan Lee 529129c332 [dxvk] Move getInstanceExtensions platform logic to wsi.
This ensures that all of the WSI backend logic is in one place rather than two.
2024-05-13 13:18:03 +00:00
Ethan Lee 4055a92856 [wsi] Add init/quit functions, integrate them into DxvkInstance.
This is preparation for loading/unloading WSI backends at runtime, which will be in an upcoming commit.
2024-05-13 13:18:03 +00:00
Blisto91 7bad17c1d1 [util] Set deviceLossOnFocusLoss for The Sims 3
Prevents the game black screening on alt-tab
2024-05-11 14:38:43 +02:00
Blisto91 6b76d70d9d [util] Enable d3d11.longMad for Guild Wars 2
Fixes invisibility effect flicker when invariantPosition is enabled
2024-05-09 00:47:13 +02:00
Philip Rebohle 611dc60018 [d3d9] Do not support cube textures with depth formats 2024-05-08 17:05:48 +00:00
WinterSnowfall b2789ab894 [d3d9] Validate DS format support during CheckDepthStencilMatch 2024-05-06 20:26:09 +00:00
Philip Rebohle ab715a8876 [d3d11] Implement better filtering when blitting video content
Unlike linear filtering this guarantees that we never read outside the source
region, and this also lets us perform color space conversion prior to filtering.
2024-05-03 16:23:17 +02:00
talkingerbil 1fb35b6d19
[dxgi] Initialize UMD version quad to a max signed int64 (#3985) 2024-05-03 16:22:58 +02:00
Rémi Bernon 4333ee872d [d3d11] Use nearest filter for ID3D11VideoContext scaling 2024-05-02 18:17:54 +02:00
Rémi Bernon b99d42c688 [d3d11] Implement VideoProcessorSetStreamSourceRect scaling 2024-05-02 18:17:54 +02:00
Blisto91 dacb8b434b [util] Add configs for Delta Force Xtreme 1 & 2
Prevents the games from black screening on Alt-Tab and helps big performance dips.
2024-05-01 14:08:03 +02:00
Philip Rebohle ea4cb84d8a [dxvk] Remove workaround for non-dynamic depth clip
Kind of pointless and everyone supports the required EDS3 subset anyway.
2024-04-29 17:43:40 +02:00
Philip Rebohle 65373792d2 [dxvk] Forward link flags when using shader identifiers
Fixes a long-standing bug that now causes validation errors.
2024-04-29 17:43:40 +02:00
Lierrmm 29253da356 feat: add H2M-Mod to config 2024-04-29 16:19:42 +02:00
Robin Kertels 79398b468d [util] Enable longMad for Red Faction Guerrila Remastered 2024-04-29 13:17:21 +02:00
Robin Kertels e7d14e97de [dxbc] Implement option to split up fma 2024-04-29 13:17:21 +02:00
Philip Rebohle c613078ba8 [dxvk] Bump internal version number
Potentially useful for drivers and tools to deal with the new pipeline
layout changes.
2024-04-26 19:54:52 +02:00
Philip Rebohle 2970645f33 [dxvk] Fix push constant compatibility for pipeline libraries
When linking pipelines, all pipeline libraries are required to declare
the exact same set of push constants, even for stages not part of the
respective libraries.

This invalidates all fossilize databases.
2024-04-26 19:54:52 +02:00
Philip Rebohle 462165da19 [util] Add Deck profile for Fallout 4
Should fix the FPS problem on Deck OLED.
2024-04-26 14:34:08 +02:00
Philip Rebohle 3f27a0ee58 [util] Add a way to define app profiles exclusive to Steam Deck 2024-04-26 14:34:08 +02:00
Katharine Chui aac3396671 [dxgi] unchain DxgiFactory::CreateSwapChain and CreateSwapChainForHwnd
similar to https://github.com/doitsujin/dxvk/pull/3966, avoid
chaining so that dxgi tools attempting to wrap swapchains don't
end up double wrapping

ref: https://github.com/SpecialKO/SpecialK/issues/168
2024-04-25 12:07:50 +02:00
Katharine Chui 92a43ebf65 [dxgi] unchain DxgiSwapChain::Present1 and Present
dxgi hooking tools might hook both, eg. https://github.com/SpecialKO/SpecialK/issues/167
2024-04-22 14:04:43 +02:00
Blisto91 8ba5256dc7 [util] Set deferSurfaceCreation for 9th Dawn II
OpenGL game that also spins up d3d9. Will black screen without deferSurfaceCreation when using dxvk
2024-04-22 04:48:56 +02:00
Philip Rebohle 2b70ba8f77 [dxbc] Do not emit OpImageQueryLevels for multisampled images 2024-04-19 13:55:31 +02:00
Philip Rebohle 9c66c4bf1d [build] Target SPIR-V 1.6 for built-in GLSL shaders
Silences a Mesa warning when the HUD is enabled.
2024-04-19 13:36:32 +02:00
Philip Rebohle 00872e9e4f [dxvk] Fix render target clears with format reinterpretation
With LOAD_OP_CLEAR, we cannot rely on the clear actually being performed
with the view format in mind. Use a vkCmdClearAttachment path instead.
2024-04-19 13:08:36 +02:00
Philip Rebohle 35157357dd [dxvk] Fix stencil discard being broken 2024-04-19 01:43:23 +02:00
Philip Rebohle 617ebf4e05 [dxbc] Take used components into account for PS inputs 2024-04-19 01:01:52 +02:00
Philip Rebohle c2489d5a45 [dxbc] Fix array register anaylsis with multiple dst operands 2024-04-19 01:01:52 +02:00
Philip Rebohle 6ef98c613f [dxvk] Re-enable maintenance4 feature
Sileces some validation errors.
2024-04-19 01:01:52 +02:00
Philip Rebohle 7441137a33 [dxbc] Ignore system value components when declaring inputs 2024-04-19 01:01:52 +02:00
WinterSnowfall 571948cfc0 [d3d9] Remove support for VERTEXSTATS queries 2024-04-13 19:11:00 +01:00
Martino Fontana 133f0794bc [util] Remove framerate limiter for Nier Replicant
Without mods, Nier Replicant runs faster when going above 60 FPS.
The game had an official patch that implemented a framerate limiter to prevent this. This limiter is terrible, because it's not a stable 60 FPS, but a weird 57-58 FPS. There's no way to disable this in-game, it has to be done by editing a config file or through a mod.

So, why remove the default frame limiter from DXVK?
- In the default case (a user plays the game as it is), it does nothing, since 57-58 is lower than 60.
- If a user is going out of their way to edit the config file, why would they assume that DXVK already provides a frame limiter? They are going to follow [a guide](https://www.pcgamingwiki.com/wiki/NieR_Replicant#Framerate_limited_to_57.7E58_FPS) that says to set up a frame limiter, it doesn't say "set up a frame limiter, unless you are using DXVK, in that case it's already there".
- They are using [Special K in order to use a mod to play at high refresh rates at normal speed](https://wiki.special-k.info/SpecialK/Custom/Replicant). In this case, DXVK's default limiter is harmful, since it is not documented that it's there by default.

Since this default limiter is useless in the first two cases and harmful in the third, I think it should be removed.
The alternative would be to document this (e.g. in PCGamingWiki), but the instructions wouldn't look pretty... "After following the instructions to use Special K in order to play at higher framerates at normal speed, if are using DXVK/Proton, also do these things to disable its default 60 FPS cap: [...]"

Especially because that the game isn't broken in the default case, I don't think DXVK should tamper with these things in a way that requires documentation to revert.

Tested Special K's mod to play at higher refresh rates on Linux.
2024-04-08 21:48:47 +02:00
Philip Rebohle 44695f9311 [dxvk] Adjust desciptor pool reset heuristic
Drastically limits the amount of descriptor memory we allocate in situations
where an application renders without presenting anything to a swap chain.

The new limit is a bit tight for some real-world use cases (e.g. Ashes of the Singularity),
but at worst we will start calling vkAllocateDescriptorSets once per set and draw.
2024-04-08 15:40:25 +02:00
Casey Bowman 49e9ea5f5a [dxgi] Force vendor ID change when XeSS is detected on an Intel GPU
Games using libxess.dll or wrapper modules will crash.
To work around this, we hide the Intel GPU's vendor ID to avoid using the
XeSS module.
2024-04-03 20:32:04 +02:00
Blisto91 198bd3a4b8 [d3d11] Remove missed Shared Keyedmutex warning
D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX is implemented.
2024-04-03 20:31:52 +02:00
Philip Rebohle f06c646315 [dxbc] Remove broken atomic counter subgroup optimization
This is not a legal optimization inside non-uniform control flow due
to Vulkan's extremely permissive convergence rules, and apparently
breaks on Nvidia as a result.

Mesa drivers already do the same thing internally anyway.
2024-04-03 14:55:43 +02:00
Philip Rebohle 855b2746b6 [util] Remove TRAHA Global config
This game apparently no longer exists.
2024-03-26 13:42:55 +01:00
Blisto91 28c7c09bf5 [dxgi] Remove useMonitorFallback option
QueryDisplayConfig optimization is now in Proton 9 Wine
2024-03-21 17:23:38 +01:00
Philip Rebohle 2742486540 [dxvk] Don't query color space support for null surfaces
Fixes a crash in games with the dxgi.deferSurfaceCreation workaround set.
Note that this potentially breaks HDR.
2024-03-21 15:32:48 +01:00
Philip Rebohle 037d0fa1ad [meta] Release 2.3.1 2024-03-20 13:48:30 +01:00
Philip Rebohle cbf51a7a25 [d3d11] Enable copy usage for typeless images as necessary 2024-03-20 13:30:31 +01:00
Philip Rebohle 70e34dc31c [dxvk] Support arbitrary source formats for color<->depth copies
Fixes rendering bugs in War Thunder.
2024-03-20 13:29:59 +01:00
Philip Rebohle c5aeb0f87a [dxvk] Get rid of separate depth shaders for shader-based copies
We can export both depth and color in a single shader instead.
2024-03-19 19:32:12 +01:00
Philip Rebohle a163082770 [dxvk] Align index buffer size to index size
Fixes validation errors in FFXIV.
2024-03-19 19:32:12 +01:00
Blisto91 2e1a19c7fd [util] Cap Dark Void to 60fps
Game crashes in certain places like specific cutscenes unless capped at 60fps.
2024-03-18 12:56:27 +01:00
Joshua Ashton 0beb18ef73 [d3d9] Wait for submission when calling ReturnUnderlyingResource 2024-03-16 19:11:11 +00:00
Joshua Ashton ef4428ab8c [d3d9] Improve ReturnUnderlyingResource stub for 9on12 2024-03-16 18:59:03 +00:00
Philip Rebohle 1085ba713e [dxgi] Implicitly set HDR color space for RGBA16_FLOAT swap chains 2024-03-16 18:56:41 +00:00
Philip Rebohle e857b09432 [dxgi] Change default behaviour of hideNvkGpu option 2024-03-15 22:48:57 +01:00
Kaitlyn 538f1d13d4 Fix UAV as well 2024-03-15 15:22:13 +01:00
Kaitlyn 783c9d4591 Fix MiscFlags check in GetDescFromResource 2024-03-15 15:22:13 +01:00
Kaitlyn 1a685b1c67 Implement D3D11DXGIDevice::EnqueueSetEvent 2024-03-15 13:47:28 +01:00
Robin Kertels 8b8be7c2bf [d3d9] Fix stream count in Reset 2024-03-10 17:12:22 +01:00
Billy Laws 0776d764a4
build: Support building for ARM64EC
When targeting ARM64EC, both __x86_64__ and _M_X86_64 are defined but
not all x86 intrinsics are present, treat EC as regular ARM64 so the
native intrinsics are used instead.
2024-03-09 05:43:46 +00:00
Robin Kertels 15ddadc4de [d3d9] Fix number of streams 2024-03-08 18:42:15 +01:00
Philip Rebohle 69a52b3da0 [dxbc] Do not emit depth compare for unsupported image types
Fixes invalid SPIR-V.
2024-03-07 16:11:23 +01:00
Philip Rebohle 707ad6f328 [spirv] Add OpConstantNull 2024-03-07 16:11:23 +01:00
Philip Rebohle 3a6992ea97 [dxbc] Enable depth compare types for 1D images
Used by Renderdoc internal shaders.
2024-03-07 16:11:23 +01:00
Robin Kertels 72c86b8229 [d3d9] Only unbind in EndScene if the game cleared the binding 2024-03-06 22:58:48 +01:00
Robin Kertels 85215b10d6 [d3d9] Respect vertex buffer offset when dynamically uploading geometry 2024-03-06 18:13:26 +01:00
Philip Rebohle fd3fbf6607 [dxvk] Remove old memory budget code
Obsolete since we removed the Nvidia HVV workaround for old drivers.

Closes #3877.
2024-03-06 15:48:34 +01:00
Minelelol 0a699fddb6 Update config.cpp
Insane Performance increase
2024-03-06 15:25:16 +01:00
Blisto91 afec5cce88 [util] Remove some unneeded built in configs
Dirt 5 does not crash without working ags anymore and Ethan Carter Redux also starts fine without a spoof.
This allows the built in AMD ags in Proton 9 to be used for these games.

The Hitman 3 config is redundant as it doesn't allow RT to be enabled without Nvapi anyway.
2024-03-06 15:24:54 +01:00
Ethan Lee 4b0e3111d1 meson: Check for bundled Vulkan/SPIR-V headers before adding them to the include list.
This feature requires Meson 0.58 or newer.
2024-03-06 15:21:15 +01:00
Philip Rebohle 0414bbe2d5 [dxgi] Add separate option to override vendor IDs for NVK 2024-03-06 14:46:21 +01:00
Robin Kertels 20490b678f [d3d9] Fix missing else brackets in ResetSwapchain 2024-03-06 12:08:45 +01:00
Blisto91 428c98bc63 [util] Disable countLosableResources for all d3d9 Supreme Ruler games
All the d3d9 Supreme ruler games have this issue.
2024-03-05 15:28:11 +01:00
Robin Kertels a0e39e94fa [d3d9] Use most recently used swapchain for GetFrontBufferData 2024-03-05 13:54:15 +00:00
Robin Kertels eaa732d0b3 [d3d9] Place GetFrontBufferData screenshot at window position 2024-03-05 13:54:15 +00:00
Robin Kertels 49b18f03fe [d3d9] Unbind buffers in EndScene & Reset 2024-03-05 13:52:51 +00:00
Philip Rebohle c9cea93b7b [dxbc] Use raw access chains for buffer loads and stores
Maps more or less perfectly to D3D raw and structured buffers.
2024-03-05 14:41:18 +01:00
Philip Rebohle 69d74a46a0 [dxbc] Remove emitRawBuffer{Load,Store}
And factor these into the callers. We need to preserve the raw
index and offset parameters to use raw access chains.
2024-03-05 14:41:18 +01:00
Philip Rebohle 94098aa97d [dxbc] Enable SPV_NV_raw_access_chains 2024-03-05 14:41:18 +01:00
Philip Rebohle c677ba9b3e [dxvk] Enable VK_NV_raw_access_chains if available 2024-03-05 14:41:18 +01:00
Philip Rebohle 77c7396ee1 [spirv] Add support for OpRawAccessChainNV 2024-03-05 14:41:18 +01:00
Philip Rebohle f07e5f9eaa [include] Update SPIR-V headers 2024-03-05 14:41:18 +01:00
Philip Rebohle d5c3011f54 [include] Update Vulkan headers 2024-03-05 14:41:18 +01:00
Blisto91 6b3b934471 [util] Clarify maxDeviceMemory and maxSharedMemory
This config often leads to confusion as people expect applications to honor the limit.
2024-03-02 20:41:19 +01:00
Philip Rebohle 9004c132ed [dxbc] Declare dynamically indexed UBOs with the maximum possible size
Fixes #3861.
2024-02-23 13:39:29 +01:00
Philip Rebohle 24d4c9c938 [util] Disable command lists for Granblue Fantasy Relink
The uses deferred contexts for rendering if driver command lists are enabled,
but when AMDAGS is loaded, it will also unconditionally use MultiDrawIndirect
functions. Since the AGS version in use does not support deferred contexts,
this breaks rendering, so we will have to force it into the immediate context
path.

Testing also shows slightly higher performance (~3-5%) with this path in
CPU-bound scenarios.
2024-02-22 16:07:24 +01:00
Philip Rebohle 5ded7d67f0 [d3d11] Implement UpdateSubresource bug if native command lists are disabled 2024-02-22 16:07:24 +01:00
Philip Rebohle 234f3ea071 [d3d11] Add option to hide native command list support 2024-02-22 16:07:24 +01:00
Robin Kertels c5a37d443a [d3d9] Handle null IBO when uploading data for draw 2024-02-20 13:04:01 -08:00
Robin Kertels f254afb4fb [util] Enable strict float emulation for Red River 2024-02-20 12:58:03 -08:00
Robin Kertels 39c19e9299 [d3d9] End scene on reset 2024-02-20 12:58:03 -08:00
Robin Kertels 738fd4f895 [d3d9] Don't actually unbind buffers 2024-02-20 12:58:03 -08:00
Philip Rebohle 9491b56beb util: Enable d3d11.ignoreGraphicsBarriers for Granblue Relink
Improves GPU-bound performance due to the game using PS UAVs.
2024-02-15 20:33:55 +01:00
Robin Kertels ab3593185f [d3d9] Fail GetRTData if src and dst have mismatching sizes
MySims tries to do this and needs this to fail,
otherwise mouse picking is off.
2024-02-06 11:02:43 +01:00
Robin Kertels e9a0fec5b3 [dxso] Clamp Exp when fast float emulation is enabled 2024-02-06 11:02:20 +01:00
Echo J fae78407a2 d3d9: Remove an unused variable
This fixes a gcc warning (originally reported by Saancreed)
2024-02-06 10:19:28 +01:00
Robin Kertels 5312ef1cf9 [d3d9] Upload DYNAMIC+SYSMEM vertex and index data for each draw 2024-02-05 13:13:18 +00:00
Robin Kertels 62d64bd63a [d3d9] Don't upload buffers before Up draws 2024-02-05 13:13:18 +00:00
Robin Kertels f83ba898af [dxvk] Use signed int for vertexOffset
BaseVertexIndex is signed in Vulkan, D3D11 & D3D9.
2024-02-05 13:13:18 +00:00
Ethan Lee 30f2b2df31 package-native.sh should force libdisplay-info subproject
This ensures that the script produces a build similar to the default steamrt build, even if libdisplay-info is available on the build system root.
2024-02-05 13:08:30 +01:00
Philip Rebohle 05cb963e22 [util] Set sync interval override for P3R 2024-02-02 17:30:13 +01:00
Philip Rebohle eb339bc7e4 [dxgi,d3d11] Move syncInterval override to DXGI swap chain
This way it also applies to D3D12 games.
2024-02-02 17:30:13 +01:00
Ethan Lee c423819e90 [meson] Only use the libdisplay-info subproject as a fallback 2024-01-30 20:48:40 +01:00
Tatsuyuki Ishi e2a46a347d [meta] Declare bool conversion operators as explicit
Non-explicit conversion operators in general can participate in very
surprising conversion chains. Explicit bool operator is a good place to
start with, because even with explicit they do get automatic contextual
conversion in a lot of places, e.g., if conditions.
2024-01-27 11:44:51 +01:00
Tatsuyuki Ishi afc6aa70fb [d3d11] Explicitly convert DxvkExt to bool in D3D11DeviceFeatures
When assigning to a BOOL (which is an uint in disguise) and using explicit
bool conversion operators (introduced in a latter commit) an explicit cast
is required.
2024-01-27 11:44:51 +01:00
Tatsuyuki Ishi 799aeff560 [dxvk] Fix incorrect comparison in DxvkSparsePageTable::updateMapping
m_mappings[page] was getting implicitly converted to bool.
2024-01-27 11:44:51 +01:00
Robin Kertels 2ca8fdf890 [util] Disable counting losable resources for Supreme Ruler Ultimate
The game is broken and leaks a state block.
2024-01-26 18:11:25 +00:00
Robin Kertels 0841f5faf4 [d3d9] Implement config option to disable rejecting reset 2024-01-26 18:11:25 +00:00
Ethan Lee 2334bbccb0 [native] Add a DECLARE_INTERFACE define for !CONST_VTABLE.
This helps avoid some compiler warnings on GCC in particular.
2024-01-26 17:48:44 +00:00
Robin Kertels 7d9864c077 [d3d9] Only enable ATOC when rendering to MS RT 2024-01-26 17:48:21 +00:00
Dean Beeler d4c5fc74e7
d3d11: Fix crash when srv is submitted to ClearUnorderedAccessViewUint
* The Settlers submits (possibly incorrectly) an SRV to ClearUnorderedAccessViewUint. The static_cast in the function does not translate correctly and crashes.

Native D3D11 behavior is to ignore the bad parameter entirely. It does not clear the SRV nor does it fault or even error with the DEBUG validator.
2024-01-23 16:01:12 +01:00
Tatsuyuki Ishi 6199776869 [build] Set filealign for MSVC builds
Useful if you want to run a MSVC build on Wine.
2024-01-23 15:45:42 +01:00
Tatsuyuki Ishi 6faf3c1acd [build] Don't pass unix compiler and link args to MSVC
clang-cl accepts both style of options but these will be generally meaningless:
- Static CRT is unnecessary.
- File alignment will be introduced in another commit.
- Wine has partial support for PDB backtrace so there is probably no need to
  insist on DWARF (which is unsupported by real MSVC anyway).
- MSVC doesn't have the weird stdcall ordinal naming convention that
  necessiates fixup and kill-at.
2024-01-23 15:45:42 +01:00
Tatsuyuki Ishi ab6bd8b17f [build] Recognize more MSVC-like compilers as MSVC
clang-cl has its own compiler id but supports MSVC argument conventions.
Use get_argument_syntax to recognize MSVC-like compilers generally.
2024-01-23 15:45:42 +01:00
Tatsuyuki Ishi 89267b62ad [build] Remove declspec UUID annotations
MIDL_INTERFACE already implies struct DECLSPEC_UUID.
2024-01-23 15:44:47 +01:00
Blisto91 34d8e65fd7 [util] cachedDynamicBuffers for Codename Panzers Phase One/Two
Helps CPU bound performance
2024-01-23 15:44:28 +01:00
Joshua Ashton 1568c263fb [d3d9] Only add unique modes to mode list 2024-01-19 16:28:22 +00:00
Joshua Ashton 0cd4165658 [d3d9] Add D3DDISPLAYMODEEX operator 2024-01-19 16:28:22 +00:00
Joshua Ashton 4b8e8bed6e [d3d9] Move operators out of dxvk namespace 2024-01-19 16:28:22 +00:00
r-a-sattarov ac78048c23 [util] Fix e2k build 2024-01-16 22:03:31 +01:00
Richard Yao 14560600a9 Micro-optimize locking in fences
When a fence has been missed, we can avoid locking *most* of the time
via the double-checked locking pattern. We still lock before a second
check in case the scheduler caused us to miss the fence. If the
scheduler did cause us to miss the fence, we can drop the lock prior to
executing the callback function, as a second micro-optimization.

Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
2024-01-15 12:42:19 +01:00
Blisto91 854e06d3f0 [util] Enable deviceLossOnFocusLoss for BF2 and BF2142
The ingame spawn and gear selection GUI can disappear from view unless this is set.
2024-01-14 22:25:43 +01:00
Blisto91 eb806952d8
[util] Set deviceLossOnFocusLoss for Assassin's Creed 2 (#3763)
Makes it not crash on alt tab using at least Proton. 
Windows will still have issues with alt tab.
2024-01-09 10:43:48 +01:00
Blisto91 a44dfabe26 [util] Set float emulation to Strict for UK Truck Simulator 1
Fixes black foliage
2024-01-09 10:42:52 +01:00
spiffeeroo 5e06cf9573 [util] Limit Sonic CD to 60 fps
Game engine physics/speed for Sonic CD is tied to frame rate so limit max frame rate to 60 fps. Otherwise, the game runs too quickly for high refresh rate monitors.
2024-01-02 19:05:44 +01:00
Blisto91 2cf590f636 [util] Enable cached vertex buffers for Kenshi
Improves the games performance when CPU bound.
2023-12-30 22:47:24 +01:00
Robin Kertels a7a63b37c3 [util] Fix incorrect config option name 2023-12-27 03:06:49 +01:00
Robin Kertels 9cde0b5798 [d3d9] Fix off-by-one when copying shader defined constants 2023-12-25 14:51:02 +00:00
Blisto91 adb33d3af1 [util] Hide Intel in Far Cry 3, 4 and Primal
Also unhides Nvidia in Primal as it has the same clear value rounding assumptions as Far Cry 3 and 4
2023-12-23 09:23:27 +01:00
Philip Rebohle 1b31aa5dbc [util] Enable hideIntegratedGraphics for Metro Exodus EE 2023-12-01 14:14:36 +01:00
Philip Rebohle 03c09ce15f [dxvk] Add option to skip integrated GPU adapters 2023-12-01 14:14:13 +01:00
Blisto91 91f7f43c35 [util] Don't spoof Nvidia on AMD GPUs in Hitman 3
Spoofing to Nvidia prevents ray tracing enablement on AMD and the game does not crash without ags anymore
2023-11-18 12:18:08 +01:00
Robin Kertels d998dee46e [d3d11] Lock context in KeyedMutex::ReleaseSync
Co-authored-by: Yuxuan Shui <yshuiv7@gmail.com>
2023-11-16 15:43:07 +01:00
Philip Rebohle ea3149801f [d3d9] Return empty buffer slice for out-of-bounds offsets
Fixes #3715.
2023-11-14 10:54:54 -08:00
xpander69 1cb58b0732 [Util] two more executables to workaround Warhammer Online
Test server executables need the same VendorID to work around the rendering issues.
2023-11-14 12:23:50 +01:00
Philip Rebohle 2ed1778df9 [d3d11] Handle potential integer overflow when validating draw offsets
Apparently some games use -1 as an argument offset, which is nonsensical
and leads to issues.
2023-11-02 17:49:38 +01:00
Philip Rebohle a427d22cde [dxvk] Add Vulkan instance flag for D3D9 apps 2023-10-31 16:05:58 +01:00
Joshua Ashton 22c2abb9b7 [dxgi] Treat R16G16B16A16_FLOAT as 32bpp for display
HDR in Control (a patch released by a developer post-launch, not
actually in the game sadly) tries to set a video mode with
DXGI_FORMAT_R16G16B16A16_FLOAT.

This seemingly works on Windows, and based on FindClosestMode etc
documentaton, this seems required to work for any format that scanout
it supported for.

It's really not like the bpp is meaningful on Windows with the
distinction of 8bit and 10bit not working in GDI modes at all.
Nor does it end up actually setting anything on Linux/Deck where
modesets are emulated.

So, treat DXGI_FORMAT_R16G16B16A16_FLOAT as 32bpp so the
FindClosestMatchingMode and EnterFullscreenMode calls succeed.
2023-10-29 10:09:34 +01:00
Blisto91 f45911a28f [util] Disable allowDirectBufferMapping for SkyDrift
Works around a alt tab OOM crash
2023-10-23 14:52:44 +02:00
Blisto91 e00db24557 [util] Enable useMonitorFallback for Holocure
Temporary performance drop workaround until QueryDisplayConfig optimization is in Proton Wine.
2023-10-10 19:32:23 +02:00
Paul Gofman 552d2f0a6d [dxgi] Add useMonitorFallback option
And enable it for CP2077.
It is supposed to be dropped once QueryDisplayConfig optimization
is in Proton Wine.
2023-10-10 12:01:51 +02:00
WinterSnowfall 4d974685c9 [d3d9] Mark presenter for recreation on device reset with deferSurfaceCreation 2023-10-06 14:05:39 +02:00
Blisto91 f0ff0007dc [util] Enable cachedDynamicBuffers for Battlestations Midway
Helps performance dips that can happen in some areas
2023-10-06 14:05:04 +02:00
Robin Kertels 494f7fd38d [d3d9] Only set initial NeedsUpload for D3DPOOL_MANAGED textures 2023-09-19 13:25:12 -07:00
WinterSnowfall 0632da1935 [d3d9] Add a device compatibility mode for d3d8 2023-09-19 09:19:55 -07:00
Philip Rebohle 83dc4678df [util] Set maximum frame latency to 1 for Age of Empires 2 (2013)
Game seems to be doing something horrible on its own, literally impossible
to make it run smoothly. This at least seems to limit excursions to ±10ms
and fix the camera flinging back and forth when running the game through
Gamescope.
2023-09-14 16:50:30 +02:00
Paul Gofman f93cfbc26a [d3d11] Pass device directly to D3D11DXGIKeyedMutex 2023-09-13 14:29:25 -07:00
Philip Rebohle c113b791a1 [util] Enable 60 FPS lock for Aviary Attorney
This game (or nw.js) comes with a hard-coded frame rate limit that
behaves more like a random number generator which happens to average
out at around 16ms on a good day.

Fix this complete mess by enabling ours on top of that.
2023-09-08 03:04:02 +02:00
Ellie Hermaszewska 41191af3b1 A few more WinDef types in windows_base.h
These specific ones are used in MS's d3dx12 headers
2023-09-07 16:31:32 +02:00
Philip Rebohle 5828f0e2b9 Revert "[dxgi] Use VK_FORMAT_A8_UNORM if available"
This reverts commit 6a5ed02db3.

Native A8 breaks Crysis 2/3 Remastered for unknown reasons.
2023-09-07 03:58:39 +02:00
Philip Rebohle 80e075406b [meta] Release 2.3 2023-09-04 17:59:12 +02:00
Margen67 a53f0e8168 [util] Remove whitespace 2023-09-04 03:10:49 +02:00
Margen67 4705de5725 [util] Escape . 2023-09-04 03:10:49 +02:00
Robin Kertels 9e26964a96 [d3d9] Divide projected textures by w if ProjectedCount is 0 2023-09-03 18:08:47 -07:00
Blisto91 ce2f9f35ce [util] Hide AMD in Riders Republic
Works around crashing because of statically linked amd ags
2023-09-01 00:21:16 +02:00
Philip Rebohle a3fa9c26dc Revert "[d3d11] Implement DXGI_SWAP_EFFECT_SEQUENTIAL and FLIP_SEQUENTIAL"
This reverts commit 79f6239df3.

Some engines use SEQUENTIAL presentation despite not making use of it, and
sparse binding is much slower than expected on Nvidia drivers, which leads
to massive performance regressions across the board.
2023-09-01 00:15:09 +02:00
Joshua Ashton ff5507769a [wsi] Add proper values for SDR metadata fallbacks 2023-08-31 22:54:02 +01:00
WinterSnowfall 5c56fa0df4 [util] Enable deferSurfaceCreation for Drakensang 2023-08-30 18:02:02 +02:00
Tatsuyuki Ishi 7e10021eac Remove unused DxvkResource::waitIdle
Spinning-based wait idle is no longer used.
2023-08-29 11:05:42 +02:00
Joshua Ashton bbd1d84cd0 [dxgi] Set BitsPerColor to 10
For two reasons:
1) Some apps will only enable or attempt to enable HDR if BitsPerColor is >= 10.

2) Encouraging apps to create 10-bit swapchains for use in hardware dithering on Gamescope/Steam Deck and to have more precision thru scanout color transforms
2023-08-26 01:43:42 -07:00
Jens Peters 02db89ac30 [dxgi] Allow HDR on UE4/D3D11 when NVAPI is enabled 2023-08-24 21:21:29 -07:00
Philip Rebohle 92dc61f161 [d3d11] Fix up UAV clears for A8_UNORM 2023-08-24 13:12:07 +02:00
Philip Rebohle 6a5ed02db3 [dxgi] Use VK_FORMAT_A8_UNORM if available 2023-08-24 13:12:07 +02:00
Philip Rebohle 64828e2c6c [dxvk] Use vkCmdBindIndexBuffer2 if supported 2023-08-24 13:12:07 +02:00
Philip Rebohle a4f2a49a02 [dxvk] Add description for new image formats 2023-08-24 13:12:07 +02:00
Philip Rebohle aa41a7a351 [dxvk] Enable VK_KHR_maintenance5 if available. 2023-08-24 13:12:07 +02:00
Philip Rebohle fb71c08d8c [include] Update Vulkan headers. 2023-08-24 13:12:07 +02:00
Philip Rebohle 79f6239df3 [d3d11] Implement DXGI_SWAP_EFFECT_SEQUENTIAL and FLIP_SEQUENTIAL
Requires sparse since we have no other means to swap the backing image.
2023-08-24 13:00:35 +02:00
Philip Rebohle 53a68635b2 [dxvk] Optimize page table updates for images
Dramatically reduces overhead when binding full subresources.
2023-08-24 13:00:35 +02:00
Philip Rebohle 179c5ec998 [dxvk] Sort allocated memory pages for sparse allocator
This way, memory regions bound to consecutive pages are more likely
to end up in consecutive memory regions, which allows batching page
table updates more efficiently.
2023-08-24 13:00:35 +02:00
Philip Rebohle d6e0107e23 [dxvk] Ensure to submit sparse binding commands 2023-08-24 13:00:35 +02:00
Joshua Ashton 428ca9416d [d3d11] Implement synchronization on keyed mutexes
Co-authored-by: Paul Gofman <pgofman@codeweavers.com>
2023-08-23 16:50:52 +02:00
Joshua Ashton c26f40229a [vulkan] Query wine_vk{Acquire,Release}KeyedMutex
Non-standard functions, but exposed by winevulkan to support keyed mutexes.

Co-authored-by: Paul Gofman <pgofman@codeweavers.com>
2023-08-23 16:50:52 +02:00
Joshua Ashton 8226690298 [dxvk] Enable VK_KHR_win32_keyed_mutex
Co-authored-by: Paul Gofman <pgofman@codeweavers.com>
2023-08-23 16:50:52 +02:00
Joshua Ashton 138f727fbb [native] Add WAIT_* defines 2023-08-23 16:50:52 +02:00
Philip Rebohle c2cd129b89 [dxvk] Fix xfb counter buffer draw tracking 2023-08-23 13:44:35 +02:00
Philip Rebohle 915244c00c [d3d11] Fix various D3D10 interface queries 2023-08-23 01:06:04 +02:00
Blisto91 6fce094942 [util] Limit fps in Project: Snowblind
Player movement and animation can bug out at high fps like issues moving around objects and the players head detaching slightly when moving backwards.
Seems like it also helps some crash issues.
2023-08-21 01:43:24 +02:00
Robin Kertels 740ebec7ee [d3d9+dxso] Consider DMAP sampler in bit masks 2023-08-20 10:21:16 -07:00
Robin Kertels bcaaac4ad7 [d3d9] Handle sampling from DS_READONLY properly 2023-08-18 18:59:53 -07:00
Joshua Ashton 1130512db5 [dxgi] Add global HDR interop interface for NVAPI/AGS 2023-08-18 22:57:06 +01:00
Blisto91 143eb8c710 [meta] Document DXVK_CONFIG in readme 2023-08-16 12:57:42 +02:00
Philip Rebohle 4ae542e875 [util] Do not hide Nvidia GPUs from Ratchet & Clank
NVAPI is disabled now due to crashing issues in a wine-specific code
path within the game, but we still want it to detect the correct GPU
so that it doesn't complain about drivers and also allows users to
enable Raytracing.
2023-08-15 00:23:19 +02:00
Philip Rebohle 952c66fe2a [dxgi] Add options to hide Intel or AMD GPUs. 2023-08-14 20:12:02 +02:00
Philip Rebohle b6a7714e67 [dxgi,util] Rename dxgi.nvapiHack option to dxgi.hideNvidiaGpu 2023-08-14 19:21:16 +02:00
Etaash Mathamsetty 037669f715 [dxso] Don't assume 32 registers. 2023-08-13 20:34:38 +01:00
Robin Kertels 295a58afdf [d3d9] Check depth bounds test when deciding to bind DSV 2023-08-13 20:32:20 +01:00
Robin Kertels 0746a3b91a [d3d9] Don't resolve an image with 1 sample 2023-08-10 13:45:40 +02:00
Etaash Mathamsetty 429555a540 [dxgi] Fix behavior of GetWindowAssociation 2023-08-09 12:18:24 +02:00
Blisto91 dfcd7aedd8
[util] Limit Conflict Vietnam to 60fps (#3606)
Physics can bug out at higher fps making the character fly or get stuck when running up or down slopes.
2023-08-09 12:18:10 +02:00
gofman cbda22a040
[d3d11] Add stub IDXGIKeyedMutex interface. (#3601)
Partially based on a patch by Derek Lesho.

Co-authored-by: Paul Gofman <pgofman@codeweavers.com>
2023-08-07 17:23:32 +02:00
Georg Lehmann 549bd86f03 [d3d9] use strict float emulation for nvk
nvk supports nir_op_fmulz/ffmaz
2023-08-06 11:01:03 +01:00
WinterSnowfall b0b46fd075 [d3d9] Don't show/hide a software cursor 2023-08-02 01:51:19 +01:00
Joshua Ashton a62117cd13 build: Disable stdcall alias-ing and use kill-at
Disable stdcall aliasing and enable kill-at to ensure our exported
functions don't have the @8, @40, etc suffixes.

This still keeps `--enable-stdcall-fixup` as otherwise the linker can
get confused trying to find exports from the .def. This does not result
in aliases being added, just for them to be found to add to the export
table.

This also switches d3d11 to use the MinGW provided dxgi.lib for linking
and d3d10 to use the MinGW provided d3d11.lib for linking.
Unfortunately the .a's we output seem to still have the @blah that we
killed so we cannot use them for internal linkage since using kill-at.

Tested that what we get out of MinGW now is what we want with dllexp.

Supercedes: #3590

Exports

```
➜  build git:(master) ✗ winedump -j export src/dxgi/dxgi.dll
Contents of src/dxgi/dxgi.dll: 129505860 bytes

  Name:            DXGI.DLL
  Characteristics: 00000000
  TimeDateStamp:   64C97A2D Tue Aug  1 22:33:33 2023
  Version:         0.00
  Ordinal base:    9
  # of functions:  9
  # of Names:      5
Addresses of functions: 00423028
Addresses of name ordinals: 00423060
Addresses of names: 0042304C

  Entry Pt  Ordn  Name
  00007C17     9 CreateDXGIFactory
  00007BF3    10 CreateDXGIFactory1
  00007B62    11 CreateDXGIFactory2
  00007C3B    16 DXGIDeclareAdapterRemovalSupport
  00007CD8    17 DXGIGetDebugInterface1

Done dumping src/dxgi/dxgi.dll
```

```
➜  build git:(fix-stdcall-32-bit) winedump -j export src/d3d11/d3d11.dll
Contents of src/d3d11/d3d11.dll: 263021637 bytes

  Name:            D3D11.DLL
  Characteristics: 00000000
  TimeDateStamp:   64C97A2E Tue Aug  1 22:33:34 2023
  Version:         0.00
  Ordinal base:    18
  # of functions:  7
  # of Names:      4
Addresses of functions: 005E3028
Addresses of name ordinals: 005E3054
Addresses of names: 005E3044

  Entry Pt  Ordn  Name
  00020045    18 D3D11CoreCreateDevice
  000200AA    22 D3D11CreateDevice
  0002010E    23 D3D11CreateDeviceAndSwapChain
  0002025F    24 D3D11On12CreateDevice

Done dumping src/d3d11/d3d11.dll
```

Import of DXGI in D3D11

```
  offset 005e1014 dxgi.dll
  Hint/Name Table: 005E408C
  TimeDateStamp:   00000000 (Thu Jan  1 01:00:00 1970)
  ForwarderChain:  00000000
  First thunk RVA: 005E4300
   Thunk    Ordn  Name
  005e4300     4  CreateDXGIFactory1
```
2023-08-01 23:35:09 +01:00
pchome e598dcd77e
[util] Add DXVK_CONFIG to define additional options 2023-08-01 22:09:29 +02:00
Philip Rebohle 09857dcaa9 [dxvk] Dirty multisample state if sample mask export changes.
This affects Alpha-to-Coverage.
2023-08-01 18:07:47 +02:00
Philip Rebohle d66f8385c3 [dxvk] Disable alpha to coverage if sample mask is written
Matches D3D11 behaviour and fixes tree rendering in A Total War Saga: TROY.
2023-08-01 16:58:46 +02:00
Philip Rebohle 007e9f4c89 [dxvk] Check whether fragment shader exports sample mask 2023-08-01 16:27:23 +02:00
Philip Rebohle 9b019d26ac [dxgi] Forward IDXGIOutput::GetFrameStatistics to full-screen swap chain
Testing on Windows reveals that this function does not work with windowed
mode swap chains even in flip model.
2023-07-31 21:47:44 +02:00
Philip Rebohle 228615b639 [d3d11] Rework D3D11CoreCreateDevice
FiveM calls this directly and apparently our signature wasn't quite
what they expect it to be.
2023-07-31 13:13:48 +02:00
Ellie Hermaszewska dfbebba6b5
[native] Add CHAR and PCSTR to windows_base.h 2023-07-29 18:01:01 +01:00
Blisto91 4ed04268fd [build] Use new glslang name with fallback 2023-07-29 14:54:32 +02:00
Blisto91 4ed1474030 [meta] Move up Vulkan driver section in readme 2023-07-23 19:59:31 +02:00
Blisto91 13440a5d89 [dxvk] Clarify Vulkan 1.3 driver requirement in log 2023-07-23 19:59:31 +02:00
Blisto91 1daae75048 [util] Set Cached Dynamic Resources for d3d11 Vindictus
Co-authored-by: NorbertHarangozo <maszek.solutions@gmail.com>
2023-07-23 19:12:12 +02:00
Philip Rebohle b4d87eaac0 [dxbc] Fix constant texture offsets with 1D textures
Fixes #3572.
2023-07-22 17:37:37 +02:00
Philip Rebohle 1e11db98d0 [dxvk] Use separate mutex for completed chunk counter
Fixes a possible deadlock.
2023-07-21 21:45:50 +02:00
Philip Rebohle f689ddd838 [dxvk] Use dual queues for CS thread
Reduces lock contention since we can just swap out the entire queue
any time the worker thread runs out of stuff to do.
2023-07-21 21:21:34 +02:00
Philip Rebohle eed43c8524 [dxgi] Fix QPC time in frame statistics 2023-07-21 10:22:56 +02:00
Philip Rebohle d066fbbaed [d3d11] Set up line rasterization mode appropriately 2023-07-20 23:43:03 +02:00
Philip Rebohle a67c99943a [dxbc] Set output topology for GS and TES correctly 2023-07-20 23:43:03 +02:00
Philip Rebohle 5ece97f769 [dxvk] Add line rasterization mode to rasterization state 2023-07-20 23:43:03 +02:00
Philip Rebohle 228cd4c331 [dxvk] Enable VK_EXT_line_rasterization if supported. 2023-07-20 23:43:03 +02:00
Blisto91 98f3887680 [util] Cleanup a couple of example config options 2023-07-17 15:38:13 +02:00
Blisto91 3a9a70b5f0 [meta] Add Graphics Pipeline Library section to readme 2023-07-17 15:38:13 +02:00
Philip Rebohle 878da4984b [util] Disable single-use command lists for Ghost Recon Wildlands 2023-07-17 15:00:55 +02:00
Philip Rebohle c599f95e5d [d3d11] Do not cache GetCurrentProcess result
This is just a constant.
2023-07-16 21:16:16 +02:00
Paul Gofman 4893788d9b [d3d11] Fixup incorrect MiscFlags in D3D11Device::OpenSharedResourceGeneric()
So texture sharing works with vkd3d-proton before correcting flags
there.
2023-07-16 15:34:39 +02:00
Paul Gofman fc952a3ca3 [d3d11] Validate texture sharing parameters at texture creation 2023-07-16 15:34:39 +02:00
Paul Gofman 01ad79278b [d3d11] Support just one handle type in D3D11DXGIResource::{Get|Create}SharedHandle 2023-07-16 15:34:39 +02:00
Paul Gofman 48557886de [d3d11] Determine shared texture handle type through D3D11_RESOURCE_MISC_SHARED_NTHANDLE 2023-07-16 15:34:39 +02:00
Paul Gofman 8319793a98 [d3d11] Always close handle in D3D11CommonTexture::ExportImageInfo()
For KMT handle openKmtHandle() creates new handle, for NT handle
m_image->sharedHandle() gets duplicated handle from
vkGetMemoryWin32HandleKHR().
2023-07-16 15:34:39 +02:00
Blisto91 886268fcf9 [util] Remove Secret World Legends config 2023-07-16 15:26:46 +02:00
Hans-Kristian Arntzen 84e59fc9e5 [ci] Download glslangValidator.exe directly rather than using choco.
The choco package is extremely outdated and breaks now.
2023-07-16 15:25:21 +02:00
Blisto91 6be1f6d7bd [util] Limit fps in The Incredibles 2023-07-05 20:48:19 +02:00
Joshua Ashton 2f72115f91 [d3d9] Keep 1 presenter per swapchain window
Some apps such as level editors such as Hammer World Editor, some GUI apps/launchers etc use window overrides in presentation.

Previously we'd remake a new surface every time, which was incredibly slow making these apps basically unusable.

Now we keep one surface + swapchain + image views around per window/window override we have, along with the frame latency objs + frame counter.
(Obviously an app may present to multiple windows in a frame, so for frame latency purposes we track that per-window.
2023-07-04 16:44:31 +02:00
Alpyne 026aa49ef8 [util] replaceNaN: Align result
Otherwise _mm_store_ps can fail
2023-07-03 15:36:21 +02:00
Trevonn 3a368f4780 Bladestorm Nightmare - Game speed increases when above 60 FPS outside of missions
The game has 3 v-sync options but doesn't explain what they do.
0 = 60 FPS
1 = Monitor Refresh Rate
2 = 30 FPS

Framerate is capped at 60 in missions and then up to monitor refresh in the main menu and tavern area

This PR would provide a better default experience for people using option 1 with high refresh displays
2023-07-01 17:12:36 +02:00
Tatsuyuki Ishi 2ef41bdbf6 build: Switch symbols to DWARF 4
Since [1], Wine's supports and uses DWARF 4 as default. Make use of it, which
should fix inlined stacks and some other small details.

[1]: https://www.winehq.org/pipermail/wine-devel/2021-November/201333.html
2023-07-01 17:12:18 +02:00
Philip Rebohle 0f4458e173 [dxvk] Remove pending submission counter 2023-06-26 01:37:46 +01:00
Philip Rebohle ccb87d5ea9 [d3d9] Port flush heuristic from D3D11 2023-06-26 01:37:46 +01:00
Alpyne 022bf1d134 [d3d9] Allow changing API name for d3d8 2023-06-24 18:18:38 +01:00
Alpyne d6e7e3e780 [d3d9] Add DxvkD3D8Bridge for d3d8 interop 2023-06-24 17:58:49 +01:00
Blisto91 b77928b6fe [util] Fix Modern Warfare 2 Campaign Remastered config 2023-06-24 13:28:49 +02:00
Philip Rebohle 987df8a487 [util] Filter out internal private ref on object destruction
Closes #3531 for real this time.
2023-06-24 12:45:38 +02:00
Philip Rebohle a7278cdab1 [dxgi] Do not interact with other DXGI objects during swapchain destruction
This trips up Stalker Anomaly for some reason, but initializing an output
is not meaningful anyway in this situation since we either know the output
in question already, or we don't and it cannot be in a non-default state.

Closes #3531.
2023-06-24 12:38:10 +02:00
Joshua Ashton 3b3ebc9350 [d3d9] Rename some members to be clearer 2023-06-24 04:09:04 +01:00
Joshua Ashton 00ae118655 [d3d9] Don't use m_activeRTs in SetPixelShader
These are just textures, not surfaces.
2023-06-24 04:07:19 +01:00
Joshua Ashton 55be12daa5 Revert "[d3d9] Use m_activeRTs in BindFramebuffer"
This is only textures. Oops.

This reverts commit ff65599dba.
2023-06-24 04:06:24 +01:00
Joshua Ashton 0e36a07a93 [d3d9] Don't mark DS as hazardous if depth write is disabled 2023-06-24 03:55:16 +01:00
Joshua Ashton ff65599dba [d3d9] Use m_activeRTs in BindFramebuffer
Can roll in the anyColorWrites this way.
2023-06-24 03:42:54 +01:00
Joshua Ashton 6b60de2d31 [d3d9] Fix unbinding RTs
Fixes a regression with 8560efa3c7 in ND1.

Also more optimized.
2023-06-24 03:41:31 +01:00
Joshua Ashton 362743c1d6 [d3d9] Update DS hazards when PS shader masks change 2023-06-24 02:55:38 +01:00
Joshua Ashton 7f302fc350 [d3d9] Don't mark DS hazards if not used by shader 2023-06-24 02:53:14 +01:00
Philip Rebohle 8704ed7af6 [dxvk] Ignore some pipeline flags when ending render pass 2023-06-22 23:41:24 +02:00
Philip Rebohle 0895858901 [dxvk] Only decrement pending submission count for command submissions
Otherwise we'll underflow the integer and break the D3D9 flush heuristic.
2023-06-22 20:15:42 +02:00
Joshua Ashton 80b27f95bc [d3d9] Fix active hazards RT only being 4 bits 2023-06-22 16:37:09 +01:00
Joshua Ashton a791493d14 [d3d9] Don't rebind AlphaTest when changing RT if not necessary 2023-06-22 16:37:09 +01:00
Joshua Ashton c768196251 [d3d9] Compress hazard state going into CS
This can potentially happen per-draw so make it as small as possible.
2023-06-22 16:37:09 +01:00
Joshua Ashton 3625c5d481 [d3d9] Optimize DS active hazard check
There can only be one DS, so no need to loop over.
2023-06-22 16:37:09 +01:00
Philip Rebohle b3cbe36c08 [dxvk] Apply frame rate limit on presentation timeline
This may reduce latency as we no longer end up stalling subsequent
GPU submissions.
2023-06-22 16:17:03 +02:00
Philip Rebohle 166d90b04c [d3d11] Fix frame latency based on buffer count
We need to ignore the front buffer here since we synchronize after
presentation.
2023-06-22 16:16:30 +02:00
Robin Kertels 60b6e98529 [d3d9] Transition DS too if there's a feedback loop 2023-06-21 15:16:43 +01:00
Robin Kertels a20869fb93 [d3d9] Track textures in m_activeHazardsRT instead of RT
There's 21 textures and only 4 RTs.
Tracking the textures allows us to mask off the active texture bitfield
instead of the active render target one, potentially resulting in fewer iterations.
2023-06-21 15:16:43 +01:00
Philip Rebohle a287566c65 [dxgi] Implement frame statistics based on IDXGIVkSwapChain1 2023-06-21 15:16:37 +02:00
Philip Rebohle 28f48f9fdc [dxgi] Initialize output refresh counts with non-zero values
Matches Windows behaviour.
2023-06-21 15:16:37 +02:00
Philip Rebohle e02a800c33 [d3d11] Implement IDXGIVkSwapChain1 interface for D3D11 swap chain 2023-06-21 15:16:37 +02:00
Philip Rebohle d7fa39c4eb [util] Be more robust against timing weirdness when computing vblank count 2023-06-21 15:16:37 +02:00
Philip Rebohle d1e39be7e7 [dxgi] Add IDXGIVkSwapChain1 interface definition 2023-06-21 15:16:37 +02:00
Philip Rebohle 438c535fe7 [d3d11] Always release frame latency semaphore in Present 2023-06-21 15:16:37 +02:00
Philip Rebohle 7dbe4abb48 [d3d9] Use new presenter signal mechanism for frame pacing 2023-06-21 15:16:37 +02:00
Philip Rebohle e99bc591df [d3d11] Use new presenter signal mechanism for frame latency event 2023-06-21 15:16:37 +02:00
Philip Rebohle 08363edb05 [dxvk] Only synchronize with presents with FIFO present modes 2023-06-21 15:16:37 +02:00
Philip Rebohle 5d1196733b [dxvk] Implement waiting for specific present requests 2023-06-21 15:16:37 +02:00
Philip Rebohle ca3492570c [dxvk] Add functionality to wait for a given present operation 2023-06-21 15:16:37 +02:00
Philip Rebohle 215c4f8f6f [dxvk] Enable VK_KHR_present_id and VK_KHR_present_wait if supported 2023-06-21 15:16:37 +02:00
Robin Kertels 5a1ebfa4ee Revert "[d3d9] Only use direct buffer mapping for DYNAMIC buffers"
This reverts commit 1850819483.
2023-06-20 23:08:52 +01:00
Joshua Ashton 6f87ccdafc [d3d11] Use FORCE_UNORM depth bias representation for UNORM formats 2023-06-20 13:31:48 +01:00
Joshua Ashton b30a4f0cc7 [d3d9] Use FLOAT or FORCE_UNORM depth bias representation 2023-06-20 13:31:48 +01:00
Joshua Ashton 4e9853f608 [dxvk] Expose depth bias representation/exact controls 2023-06-20 13:31:48 +01:00
Joshua Ashton 5fbb0dd4ba [dxvk] Enable EXT_depth_bias_control 2023-06-20 13:31:48 +01:00
Joshua Ashton 77f6f2a84b [include] Bump Vulkan headers to v1.3.254 2023-06-20 13:31:48 +01:00
Alpyne 0b9acf3a25 [util] Add str::split
Used by d3d8
2023-06-20 13:31:17 +01:00
Timo Gurr 211d095ee4 [util] Limit STEINS;GATE ELITE to 60 fps
Intros, menu and ui animations are playing way too fast, also causing
input issues.
2023-06-20 13:27:52 +02:00
Trevonn 77e7e8bfba [util] Report NVIDIA for Star Wars Battlefront as it errors out on AMD 2023-06-20 13:23:52 +02:00
Alpyne 42a0264e69 [build] Fix libdisplay-info
See https://gitlab.freedesktop.org/JoshuaAshton/libdisplay-info/-/merge_requests/4
2023-06-19 21:14:03 +01:00
Alpyne 5d29140f74 [util] replaceNaN: Use unaligned SIMD _mm_loadu_ps
There is no good reason to expect games will have aligned the data they're passing in.
2023-06-19 21:13:37 +01:00
Alpyne 0236e780a7 [d3d9] Fix std::hex in D3D9CommonTexture 2023-06-19 21:02:10 +01:00
Alpyne 24dbcf8fd8 [dxso] Shared code for texbem and bem 2023-06-19 20:59:18 +01:00
Alpyne 404c984f9c [dxso] Implement bem instruction 2023-06-19 20:59:18 +01:00
Alpyne a79772322b [d3d9] Initialize m_mapFlags to 0
Can sometimes get weird default values in there.
2023-06-19 19:52:03 +01:00
Trevonn 36e6a7c2e5 [util] Set maxChunkSize to 1 for GOG and fix EA App exe name
Similar to the other launchers the VRAM goes 600MB+ to 100MB+
2023-06-16 16:28:31 +01:00
Trevonn c5ab5be48d [util] Set maxChunkSize to 1 for EA App
Reduces GPU VRAM usage of EADesktop.exe from 162MB to 6MB
2023-06-15 19:39:28 +01:00
Paul Gofman af9bd16b8d [dxvk] Always reference library in VR extension providers 2023-06-15 19:07:26 +02:00
Winter Snowfall 2c014fdb34 [util] Match on the GOG version of KoF XIII as well 2023-06-15 19:06:45 +02:00
Timo Gurr 6478c10a18 [util] Set maxChunkSize to 1 for Battle.net
Currently when Diablo 4 is running the Battle.net launcher it uses around
600MB of VRAM. Reducing the max chunk size to 1MB reduces the memory usage
to around 150MB.
2023-06-15 19:06:26 +02:00
Philip Rebohle 7388c243d2 [dxvk] Fix incorrect fullScreenExclusive feature check 2023-06-15 17:32:05 +02:00
Lilium bd575a4a46 [d3d11] implement 'clampNegativeLodBias' as a conf option 2023-06-14 20:22:27 +01:00
Lilium 3fce9886f5 [d3d9] implement 'clampNegativeLodBias' as a conf option 2023-06-14 20:22:27 +01:00
Lilium 5d134b877a [d3d9] implement 'samplerLodBias' as a conf option 2023-06-14 20:22:27 +01:00
Robin Kertels c75ed86909 [d3d9] Reset vertex & index buffer in Reset 2023-06-13 22:47:55 +01:00
Robin Kertels d1707026f9 [d3d9] Remove uninitialized device present params 2023-06-13 22:47:55 +01:00
Robin Kertels b8d36eeacc [d3d9] Fix losing auto depth stencil surface 2023-06-13 22:47:55 +01:00
Robin Kertels 8f740c53b4 [d3d9] Remove IsLosable
Redundant.
2023-06-13 22:47:55 +01:00
Robin Kertels 52ac271acb [d3d9] Reject Reset if there's any remaining DEFAULT resources 2023-06-13 14:15:18 +01:00
Robin Kertels a1a91dd766 [d3d9] Fix potential race when discarding systemmem textures 2023-06-11 16:57:17 +01:00
Robin Kertels 22f6246fd6 [util] Fix app profile grouping 2023-06-11 16:57:17 +01:00
Robin Kertels 9d6804e40a [util] Disable direct buffer mapping for Injustice 2023-06-11 16:57:17 +01:00
Robin Kertels 5fd025c513 [d3d9] Rename apitraceMode
It's not just used for apitrace and the new name
is more consistent with the D3D11 equivalent option.
2023-06-11 16:57:17 +01:00
Robin Kertels d9d6316609 [d3d9] Remove allowDiscard hack 2023-06-11 16:57:17 +01:00
Robin Kertels 9b877cf623 [util] Remove D&D - The Temple of Evil workaround
The game uses SWVP, so we don't need an app hack here.
2023-06-11 16:57:17 +01:00
Robin Kertels 2c3f2b9ad1 [d3d9] Ignore DISCARD after device loss 2023-06-11 16:57:17 +01:00
Robin Kertels 1850819483 [d3d9] Only use direct buffer mapping for DYNAMIC buffers
Tests show that buffers with just D3DUSAGE_WRITEONLY are uploaded on Unlock.
2023-06-11 16:57:17 +01:00
Robin Kertels 1db2e3a6ec [util] Re-enable direct buffer mapping for Dark Romance
The game uses SWVP, so we don't need the hack anymore.
2023-06-11 16:57:17 +01:00
Robin Kertels 2efd3f3698 [util] Re-enable direct buffer mapping for RE games
I cannot reproduce the stalls anymore.
2023-06-11 16:57:17 +01:00
Robin Kertels bbaf01d9e6 [d3d9] Force staging buffer mapping for pure SWVP devices 2023-06-11 16:57:17 +01:00
Robin Kertels 4a55047dde [d3d9] Forbid disabling SWVP on a pure SWVP device 2023-06-11 16:57:17 +01:00
Joshua Ashton 3fddc364ee [util] Fix UTF8 encodeTypedChar for 4 byte chars
Some flipped logic here...
2023-06-10 13:58:33 +02:00
Blisto91 f3fb5ba320 [util] Example config wording changes 2023-06-06 13:47:00 -07:00
Philip Rebohle 4d254b13be [dxgi] Unlock presenter lock early during presentation
If SetGammaControl and Present are called at the same time, we'll
otherwise have a deadlock due to reversed lock order.

Fixes #3458.
2023-06-05 17:02:15 +02:00
Joshua Ashton d241daa0b1 [util] Add app profile for Fallout 76 2023-06-05 03:00:53 +02:00
Eric Sullivan 2e70a2b07d [util] Set maxChunkSize to 1 for the Rockstar launcher and social club
Currently when Red Dead Redemption 2 is running the Rockstar launcher,
and social club each use over 600MB of VRAM. The root cause of this is
DXVK creating two memory pools of 256MB for read, and read/write resources.
Reducing the max chunk size to 1MB reduces the memory usage of each to
around 40MB.
2023-06-05 02:17:26 +02:00
Robin Kertels 52f04ca3d4 [d3d9] FF: Fix using wrong texCoord mask 2023-06-04 17:52:18 +01:00
Joshua Ashton c585ea251e [dxso] Respect all PS input elements for registers
Fixes shadows in Test Drive Unlimited 2.

Closes: #3469
2023-06-02 23:12:22 +02:00
Philip Rebohle ab00591297 [dxvk] Introduce dxvk.tearFree option
And replace the old frontend-specific options.
2023-06-01 17:48:51 +02:00
Philip Rebohle 85d52ccb88 [dxvk] Implement dynamic present mode switching
This way, we don't need to recreate the swap chain when the app switches
between vsync enabled and disabled. Currently only works when running
bleeding-edge Gamescope with ENABLE_GAMESCOPE_WSI=1.
2023-06-01 17:48:51 +02:00
Philip Rebohle e6be0cf996 [dxvk] Rework present mode selection for swap chains 2023-06-01 17:48:51 +02:00
Philip Rebohle 1728d9e89d [dxvk] Rework presenter creation to take a DxvkDevice
This way we can easily query available Vulkan features.
2023-06-01 17:48:51 +02:00
Philip Rebohle b1b0abdbbf [dxvk] Move presenter implementation to DXVK module 2023-06-01 17:48:51 +02:00
Philip Rebohle be875cd7e6 [dxvk] Enable VK_EXT_swapchain_maintenance1 and surface_maintenance1 2023-06-01 17:48:51 +02:00
Philip Rebohle 0543956ea0 [meta] Update Vulkan headers 2023-06-01 17:48:51 +02:00
Blisto91 e9e0949717 [meta] Clarify readme setup instructions 2023-05-31 12:58:28 +02:00
WinterSnowfall 8b6cbda6de [d3d9] Properly expose the MaxVertexBlendMatrixIndex capability 2023-05-30 23:56:26 +01:00
Robin Kertels 4b10846008 [dxso] Fix RT mask for SM1 2023-05-26 04:28:49 +01:00
Joshua Ashton e0654977c9 [d3d9] Stub out D3D9On12 interfaces
Closes: #3445
2023-05-24 14:36:45 +01:00
Joshua Ashton b5c18a02ae [d3d9] Optimize UpdateAnyColorWrites for 0th case
This is the most common
2023-05-24 14:21:30 +01:00
Joshua Ashton cafd104783 [d3d9] Pack RT bitmasks tightly
No need to waste a whole 32-bits for each entry here when we only have 4 possible RTs at a time.
2023-05-24 14:10:41 +01:00
Joshua Ashton 269bab2c34 [d3d9] Track if any color writes are enabled for an RT
Use this for determining whether to rebind FB and in checks, otherwise we can miss stuff for pure surface RTs
2023-05-24 14:05:13 +01:00
Joshua Ashton 075c0bf203 [d3d9] Use m_boundRTs for COLORWRITEENABLE checks
Also allows us to check for NULL RTs with this too and avoid extra work!
2023-05-24 13:42:42 +01:00
Joshua Ashton 8560efa3c7 [d3d9] Unbind RTs which are unwritten by a PS
Otherwise we can end up with feedback loops on RTs with a 0 color mask.

Closes: #3447
2023-05-24 13:40:17 +01:00
Blisto91 b9b2db510e [util] Limit fps for some Tomb Raider games 2023-05-24 14:31:38 +02:00
Lilium d5c6ae2e4d [dxvk] dxvk_adapter: implement macro to check for feature need in checkFeatureSupport 2023-05-24 11:53:34 +01:00
Lilium 633f6663a4 [dxvk] fix copy mistake in dxvk_adapter 2023-05-24 11:53:34 +01:00
Robin Kertels d2759c20ba [d3d9+d3d11] Remove DEVICE_LOCAL flag when forcing cached memory
Otherwise DXVK removes both flags at once
and we may end up with uncached memory.
2023-05-22 23:53:01 +02:00
Robin Kertels 1a2e724c16 [util] Enable apitrace mode for Tomb Raider Anniversary
... and Underworld.
2023-05-22 12:24:49 +02:00
Blisto91 6449f583f8 [util] Set dcSingleUseMode to false for SnowRunner 2023-05-21 16:05:41 +02:00
Joshua Ashton f2bb1d4b69 [d3d9] Add extended swapchain interfaces
Allows for controling colorspace, etc.
2023-05-19 19:26:27 +01:00
Joshua Ashton 495dc75ab2 [wsi] Pull out NormalizeDisplayMetadata 2023-05-19 19:26:27 +01:00
Paul Gofman 550e04c579 [dxgi] Preserve system monitor sort order in enumMonitors() 2023-05-19 18:17:40 +02:00
WinterSnowfall d4a7346198 [dxvk] Add configurable HUD opacity 2023-05-19 18:11:25 +02:00
Blisto91 99b367cdd6 [util] Set floatEmulation to Strict for Halo Online 2023-05-18 17:40:01 +01:00
Blisto91 65520fa18e [util] Fix BlazBlue Centralfiction config 2023-05-16 18:56:23 +02:00
Joshua Ashton f30376a1e4 [d3d11] Fix min luminance of HDR Metadata
This should be a multiply instead of a divide. Values are 1/10000th of a nit (0.0001 nit).
2023-05-13 21:16:29 +00:00
Philip Rebohle cae0a1cef3 [meta] Release 2.2 2023-05-12 11:26:07 +02:00
Philip Rebohle 14eb469005 [dxgi] Be more robust against monitor enumeration issues.
If there are monitors on the system that are not associated with
any adapter, enumerate all monitors for all adatpers. May solve
some issues if device filter options are used on multi-GPU systems.
2023-05-11 16:38:45 +02:00
Oleksii Bozhenko 80f7d2abd8 [d3d9] fix opCompositeExtract out of bound
Closes: https://github.com/doitsujin/dxvk/issues/3293

Signed-by: Oleksii Bozhenko <oleksii.bozhenko@globallogic.com>
2023-05-09 20:39:55 +00:00
Alpyne 2b09932d51 [d3d9] Fix crash if device is freed with bound textures 2023-05-09 00:12:35 +00:00
Robin Kertels bef2ef69ab [d3d9] Fix stupid variable name 2023-05-07 14:05:39 +02:00
Robin Kertels b08665c808 [d3d9] Fix compiler warning in Clear size check 2023-05-06 14:16:54 +01:00
Robin Kertels 96e22e7c67 [d3d9+util] Remove a bunch of redundant config options 2023-05-06 14:16:54 +01:00
Robin Kertels 5443a2f9f5 [d3d9] Don't swap buffers for SWAPEFFECT_COPY & DISCARD with 1 backbuffer 2023-05-06 14:16:54 +01:00
Paul Gofman 83a294285e [dxgi] Only enumerate outputs which belong to the adapter or associated iGPU 2023-05-05 16:44:51 +02:00
Robin Kertels 242ac20752 [d3d9] Release DC in fallback present path 2023-05-04 18:42:04 +02:00
Robin Kertels b357d16940 [util] Enable deviceLost for DC Universe Online and GTA IV 2023-05-03 13:04:00 +01:00
Robin Kertels b4366db398 [d3d9] Implement rudimentary device loss 2023-05-03 13:04:00 +01:00
Blisto91 b5f43063b1 [util] Spoof Nvidia for Modern Warfare 2 Campaign Remastered 2023-05-03 13:02:08 +01:00
Joshua Ashton f140d2de0d [d3d9] Handle swapchain OOM and other errors more gracefully
Supercedes: #2964
2023-05-03 12:59:02 +01:00
Aleksey Komarov 20356148af
include: Add few defines and types in windows.h for DXVK Native (#3307)
* windows: add define for ZeroMemory

* windows: add few *LP types, DUMMYUNIONNAME*, __C89_NAMELESSSTRUCTNAME

---------

Co-authored-by: Joshie <joshua@froggi.es>
2023-05-03 12:58:33 +01:00
Ellie Hermaszewska b81536458f
include: Implement some small utilities in native headers (#3361)
* Add QueryInterface template to IUnknown

As described here https://learn.microsoft.com/en-us/windows/win32/api/unknwn/nf-unknwn-iunknown-queryinterface\(q\)\?source\=recommendations

* Implement DEFINE_ENUM_FLAG_OPERATORS

* Add REFCLSID to windows_base.h

This is used by the latest d3d12 headers for D3D12GetInterface
2023-05-03 12:39:51 +01:00
Robin Kertels 9ce1c4df0d [dxvk] Update tracked rtLayouts when changing image layout 2023-05-03 13:23:47 +02:00
Robin Kertels 860237e775 [d3d9] Skip 0x0 clears 2023-05-03 13:23:47 +02:00
Robin Kertels ceb3a7f8c6 [dxvk] Do direct FB resolve if resolve format is UNDEFINED
If the format is undefined, we use the format of each image
which is obviously also view compatible with the imge.
2023-05-03 13:23:47 +02:00
Robin Kertels a42643b235 [d3d9] Fall back to GDI blit for partial presents 2023-05-03 12:18:11 +01:00
Philip Rebohle 5c8ed491ab [dxvk] Rewrite thread wrapper
Addresses some issues raised in #3378.
2023-04-26 10:48:47 +02:00
Joshua Ashton b44c5bbd18 [dxgi] Fallback to P3 color primaries for HDR displays without chroma info in edid 2023-04-21 04:21:16 +01:00
mbriar 16d2a6045c [util] Switch Nioh deferSurfaceCreation from dxgi to d3d9
This game seems to behave similar to all the Tecmo Koei Atelier games
and not deferring surface creation for d3d9 prevents VRR from working on
X11.
2023-04-19 16:42:42 +02:00
mbriar 1971a5d187 [util] Also add d3d9.deferSurfaceCreation for Atelier Ryza 3
Reported to help with VRR, see https://github.com/ValveSoftware/Proton/issues/6648#issuecomment-1514394149
2023-04-19 16:42:42 +02:00
Philip Rebohle e074d83d0b [dxvk] Introduce GetContext method to retrieve immediate context.
Bypasses vtable hooks when retrieving the immediate context internally.
Remaining uses of GetImmediateContext are fine since those only interact
with public methods.
2023-04-18 12:42:24 +02:00
Robin Kertels 990a720525 [d3d9] Handle a bunch of texture converter edge cases 2023-04-16 09:18:30 +01:00
Rémi Bernon 0cf563d5df [dxgi] Leave current fullscreen mode when SetFullscreenState changes monitors
This fixes RiME not moving its window when output display is
changed in the game settings.
2023-04-14 00:41:18 +02:00
Florian Will 01dc9ddc7d [util] Add new "Zusi 3" exe filename
In addition to the legacy "ZusiSim.exe" executable, the recent 3.5
release added a 64-bit "ZusiSim.64.exe" executable. This is now the
default executable when launching the game in Steam. The game is
unplayable without this option, so update the regex for Zusi 3.

Fixes #3250.
2023-04-13 13:37:07 +02:00
oltolm 6b779206d9 remove unneeded definitions 2023-04-11 18:30:46 +02:00
Blisto91 8508633ba3 [util] Disable allowDirectBufferMapping for Dark Romance: Vampire in Love 2023-04-11 08:37:50 +01:00
Robin Kertels af0009c5de [d3d9] Use DxvkFormatInfo for video formats
And fix UYUY and YUY2 in the process.
2023-04-08 03:15:44 +01:00
Robin Kertels 31af522cbc [dxvk] Add VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM 2023-04-08 03:15:44 +01:00
Philip Rebohle d9a6b40ae3 [dxvk] Create and copy temporary image for resolves as necessary
Fixes #3337.
2023-04-06 21:04:56 +02:00
Tatsuyuki Ishi 6d14fffdbd [spirv] Declare defaulted copy and move constructor for SpirvCodeBuffer.
If a type has a destructor it will not get an implicit move constructor.

But if we declare a defaulted move constructor then we will get the copy
constructor deleted. So declare both to be defaulted.

Cuts 8.8% off shader translation time during loading in Overwatch 2.
2023-04-06 10:23:11 +02:00
Blisto91 3ce3209e3e [util] Set syncInterval to 1 for Crash Bandicoot N sane trilogy 2023-04-05 16:25:05 +01:00
Philip Rebohle f212cc8f7d [dxvk] Only enable dynamic MSAA state if sample shading is enabled
Otherwise, create a more specialized fragment output library on demand.
May help RADV since dynamic alpha-to-coverage triggers a less efficient
code path.
2023-04-04 17:34:07 +02:00
Philip Rebohle 306919047b [dxvk] Log driver name in addition to version
Fixes #3313.
2023-03-27 15:44:19 +02:00
Philip Rebohle 977669c613 [util] Enable cached dynamic vertex/index buffers in GTA V
Fixes #3311.
2023-03-25 22:40:43 +01:00
Zhiyi Zhang 631171cf45 [util] Disable nvapiHack for Tom Clancy's Ghost Recon Breakpoint.
Otherwise, it shows a DirectX error dialog and exits when using an NVIDIA GPU.
2023-03-25 22:38:07 +01:00
František Zatloukal 1a5afc77b1 [util] Include cstdint to fix compilation with GCC 13 2023-03-23 23:37:10 +01:00
Robin Kertels d11878e793 [d3d9] Only apply viewport zBias if minZ is below 0.5
Fixes Space Marine shadows.
Tests show that Windows D3D9 (Nvidia) works like that.
2023-03-23 03:52:08 +00:00
Philip Rebohle 4b74d1a97b [meta] Clarify file paths for install instructions
We got half a dozen issues about this in the past couple of weeks, and
it's quite frankly getting annoying, so just explain it in such a way
that everyone should understand it.
2023-03-23 02:05:42 +01:00
Blisto91 b0ed97e070 [util] Disable nvapiHack for Diablo 4 2023-03-22 17:10:18 +01:00
Philip Rebohle 3d5becaf6a [d3d11] Implement Acquire/ReleaseWrappedResource 2023-03-18 00:50:42 +01:00
Philip Rebohle 5595844f75 [dxvk] Add explicit buffer/image memory barrier methods
Useful for interop.
2023-03-18 00:50:42 +01:00
Philip Rebohle 9bdad71dc6 [d3d11] Implement CreateWrappedResource for D3D12 textures 2023-03-18 00:50:42 +01:00
Philip Rebohle 3c99314332 [d3d11] Implement CreateWrappedResource for D3D12 buffers 2023-03-18 00:50:42 +01:00
Philip Rebohle fa8cf50263 [dxvk] Implement functionality to import foreign buffers 2023-03-18 00:50:42 +01:00
Philip Rebohle 3f9d2269f6 [d3d11] Synchronize queue submissions for 11on12 devices as necessary
When the app explicitly calls Flush, Signal or Wait, we need to wait
for the submission to actually take place so that subsequent D3D12
submissions execute in the correct order.
2023-03-18 00:50:42 +01:00
Philip Rebohle 6432787ac3 [d3d11] Implement D3D11on12 device creation 2023-03-18 00:50:42 +01:00
Philip Rebohle da32453b42 [dxvk] Add submission feedback to command submissions 2023-03-16 20:59:43 +01:00
Philip Rebohle 27f3648a44 [dxvk] Check instance extensions for feature enablement as necessary 2023-03-16 20:59:43 +01:00
Philip Rebohle 35895ba05b [dxvk] Add callback to lock submission queue
Can be used to perform additional synchronization as necessary.
2023-03-16 20:59:43 +01:00
Philip Rebohle 56a8fa2e6f [dxvk] Implement functionality to import existing Vulkan device 2023-03-16 20:59:43 +01:00
Philip Rebohle d8f3a1c83d [dxvk] Rework device queue initialization 2023-03-16 20:59:43 +01:00
Philip Rebohle ef9d5048f3 [dxvk] Rework instance creation
Allows importing foreign Vulkan instances.
2023-03-16 20:59:43 +01:00
Philip Rebohle f50f5bc9bc [vulkan] Allow importing existing Vulkan dispatch tables 2023-03-16 20:59:43 +01:00
Philip Rebohle b06e82591e [include] Add definitions for D3D12 header 2023-03-16 20:59:43 +01:00
Philip Rebohle 687d32cac5 [dxvk] Fix memory reporting derp 2023-03-15 02:14:54 +01:00
WinterSnowfall 243c2f3cf5 [d3d9] remove support for the A1/X1R5G5B5 formats 2023-03-14 13:17:13 +00:00
Philip Rebohle af811656bb [meta] Update issue template 2023-03-13 17:54:34 +01:00
Philip Rebohle 05fb634f91 [util] Use __wine_dbg_output if available 2023-03-13 16:32:32 +01:00
Blisto91 3a123222e5 [util] Enable cached vertex buffers for SpellForce 3 2023-03-13 13:22:39 +01:00
Philip Rebohle 4faa598e09 [dxvk] Report memory used rather than allocated for heap properties
We can do this at least for DXVK's own memory allocations.
2023-03-12 13:59:47 +01:00
Philip Rebohle 6783123654 [dxgi] Use heap size to determine reservable memory
Budgets can change dynamically, so this should be more robust.
2023-03-12 13:59:17 +01:00
Robin Kertels d14dcf5d47 [d3d9] Fix redundant copy of SWVP VS consts
Fixes performance regression caused by state block changes.
2023-03-10 03:24:32 +00:00
Joshua Ashton 996acbe3f2 [d3d9] Refactor state blocks to allocate dynamically. 2023-03-07 23:24:01 +00:00
Blisto91 8ecd1b3b6b [util] enableDialogMode for Codename Panzers Phase One/Two 2023-03-07 22:51:23 +00:00
Philip Rebohle 7f21a6c491 [dxvk] Accumulate query data into query object
And do so when adding additional query handles, in order
to avoid allocating queries indefinitely if End is never
called, which Halo:MCC supposedly does.

Co-authored-by: Sam Edwards <CFSworks@gmail.com>
2023-03-06 12:35:22 +01:00
Philip Rebohle e430ff5cfd [dxvk] Use small_vector to store query handles. 2023-03-06 12:35:22 +01:00
Joshua Ashton 1acf885109 [dxvk] Call SDL_Vulkan_LoadLibrary in getInstanceExtensions for SDL WSI
Closes: #3275
2023-03-03 00:14:22 +00:00
Robin Kertels 1c6fc7b5b8 [d3d9] Clamp stage and type in [G,S]etTextureStageState
This is what happens on the Nvidia D3D9 driver.
Dawn of Magic 2 calls SetTextureStageState with a
stage > 7 and expects that to succeed.
2023-03-02 13:41:32 +00:00
Guy1524 5609c5e076
[util] Reduce maximum chunk size for WILD HEARTS.
Co-authored-by: Blisto91 <47954800+Blisto91@users.noreply.github.com>
2023-03-01 15:38:14 +01:00
Philip Rebohle 55e7cb1d54 [dxgi] Only log QueryInterface errors once 2023-03-01 13:25:56 +01:00
Philip Rebohle 4c78964679 [d3d9] Only log QueryInterface errors once 2023-03-01 13:25:56 +01:00
Philip Rebohle cc78276897 [d3d11] Only log QueryInterface errors once 2023-03-01 13:25:56 +01:00
Philip Rebohle aa92cf48f5 [util] Add function to cache QueryInterface errors 2023-03-01 13:25:56 +01:00
Philip Rebohle 81440340ac [d3d9,dxvk,util] Actually use dxvk::mutex 2023-03-01 13:03:43 +01:00
Philip Rebohle 2356d34f2e [d3d11] Create video context resources on demand
Saves another memory allocation that we will often not need.
2023-03-01 12:37:06 +01:00
Philip Rebohle f4b91817fe [dxvk] Create dummy sampler and buffer on demand
We only need the dummy buffer for transform feedback, all other cases
are handled by null descriptors. May save a memory allocation.
2023-03-01 12:10:48 +01:00
Philip Rebohle 2be0d6842e [dxvk] Add option to limit memory chunk size 2023-03-01 11:53:18 +01:00
Robin Kertels 0d28be4ab8 [d3d9] Fix capturing lights in state block 2023-02-23 13:15:17 +00:00
Blisto91 081181313e
[util] Limit Battle Fantasia Revisited Edition to 60fps (#3256) 2023-02-18 10:54:14 +01:00
TacoDeBoss caf31033d7
[util] Far Cry 2: Set VendorId to Nvidia, enable apitraceMode (#3241) 2023-02-07 12:14:48 +01:00
Paul Gofman 2263dcad95 [d3d11] Improve video processor caps query stubs 2023-01-31 13:39:09 +01:00
Jens Peters 41b1efd7ce [dxgi] Fix potential division by zero in log statement
Apparently 0/0 is legal and should be interpreted as 0/1.
2023-01-28 00:51:01 +01:00
Philip Rebohle c6111eaf61 [dxvk] Fix small_vector size
Kind of harmless since we're not using this much.
2023-01-27 05:27:49 +01:00
Philip Rebohle 2abc102d2c [meta] Release 2.1 2023-01-24 14:54:09 +01:00
Philip Rebohle 61d72eebc1 [dxgi,d3d9] Use global singleton for DXVK instances
No reason to have multiple of these around, and instance creation
is fairly expensive.
2023-01-23 17:17:56 +01:00
Philip Rebohle d4143429c4 [util] Add Singleton helper 2023-01-23 17:17:43 +01:00
Philip Rebohle 255ab1a63c [hud] Display more useful driver info in HUD
Vulkan versions are irrelevant anyway, not sure why we
ever displayed that in the first place.
2023-01-23 00:10:39 +01:00
Philip Rebohle 3128f4ea8e [dxgi] Implement IDXGIVkInteropFactory for DXGI factory 2023-01-22 20:04:39 +01:00
Philip Rebohle 0ee69fef00 [dxgi] Define IDXGIVkInteropFactory interface 2023-01-22 19:57:17 +01:00
Philip Rebohle 41ee092b97 [dxvk] Get rid of global timeline semaphore
Timeline semaphores are broken on 32-bit Proton, so just use the existing
command list binary semaphore to synchronize sparse binding operation.

This will introduce some additional graphics queue submissions around
sparse binding, but since that is basically unused it's not a concern.
2023-01-21 13:15:09 +01:00
Philip Rebohle d020f4451a [dxvk] Invalidate all v16 cache files
We were randomly writing bogus data in an irrecoverable way,
so in order to not cause any problems for users, invalidate
all caches created with this version.
2023-01-21 01:24:02 +01:00
Philip Rebohle 3d24560af7 [dxvk] Fix reading out-of-bounds memory in state cache
Fixes #3196, not to mention that this was god-awful code anyway.
2023-01-21 01:14:45 +01:00
Philip Rebohle 0af5ececa6 [dxvk] Also reset descriptor pool when only one pool is in use
This way we can often avoid allocating additional descriptor pools.
2023-01-20 15:23:25 +01:00
Philip Rebohle eacb8da9f7 [dxvk] Tweak descriptor pool numbers
Increases the descriptor pool size on 64-bit, but also makes
significantly better use of descriptor pool memory in situations
with very high draw counts and many UBO descriptor set updates.
2023-01-20 14:34:46 +01:00
Philip Rebohle 4d0d455895 [vulkan] Try loading winevulkan.dll before vulkan-1.dll
Should bypass issues with third-party overlays trying to hook Vulkan.
2023-01-18 18:10:57 +01:00
Philip Rebohle c6668ffbaa [dxvk] Drop shader module workaround for compute pipelines.
This was a bug in early Nvidia development drivers, but has been fixed since.
2023-01-18 15:56:00 +01:00
Blisto91 906b931e61 [util] Disable unmapping for BlazBlue Centralfiction 2023-01-17 20:49:26 +01:00
Philip Rebohle d7a4ddb5d0 [d3d11] Implement more accurate resource tracking on deferred contexts
Allows us to track chunks that access any given tracked resource more
accurately and flush as needed, e.g. if a staging buffer is written at
the start of a long command list.
2023-01-17 15:01:06 +01:00
Philip Rebohle cf5adb8b12 [d3d11] Improve flushing around deferred context submissions 2023-01-17 15:01:06 +01:00
Philip Rebohle 591e2df701 [d3d11] Consider flushing after each CS chunk
This way we will never end up with overly long command lists.
2023-01-17 15:01:06 +01:00
Philip Rebohle 2a3d7ee7dc [d3d11] Use new flush heuristic 2023-01-17 15:01:06 +01:00
Philip Rebohle f952418958 [d3d11] Determine pending commands based on sequence number
We get this for free and this allows us to query how many CS chunks
have been emitted since the last flush.
2023-01-17 15:01:06 +01:00
Philip Rebohle 0ac247c89c [util] Add helper class for common flush heuristic 2023-01-17 15:01:06 +01:00
Philip Rebohle 741cc493c6 [dxvk] Increase maximum number of command buffers in flight 2023-01-17 15:01:06 +01:00
Philip Rebohle f7aa310fdd [dxvk] Disable pipeline lifetime tracking for RADV
Seems like this is not needed on this driver, so let's just use
the fast path by default. Makes the current implementation work
with 32-bit games as well since caching does not work yet.
2023-01-17 14:02:38 +01:00
Philip Rebohle 421d7d9077 Revert "[vulkan] Use fence for acquiring a swap chain image"
Breaks things and we don't really need this right now anyway.
2023-01-16 23:16:38 +01:00
Philip Rebohle 599357721a [hud] Support HDR color spaces
Blending is broken if we need to do encoding in the shader, but we
cannot do much about that without changing the rendering process,
so this will have to do for now.
2023-01-16 18:04:18 +00:00
Philip Rebohle 0e503ce795 [vulkan] Log swap chain color space 2023-01-16 18:04:18 +00:00
Philip Rebohle 1482715fd1 [vulkan] Use fence for acquiring a swap chain image
In practice, drivers will block here anyway.
2023-01-16 16:20:56 +01:00
Joshua Ashton 132bc529c3 [dxgi] Only allow colorspace punting if we started in sRGB 2023-01-16 13:45:03 +01:00
Joshua Ashton 28ee6867be [dxgi] Expose only sRGB when enableHDR is disabled
Death Stranding: Director's Cut crashes if HDR was last enabled in-game and CheckColorSpaceSupport reports support for HDR but it is not globally enabled in DXGIOutput::GetDesc1's ColorSpace.

It seems safer to just lock HDR behind an option to avoid any teething issues like this. It sucks, but it also makes sense in a way.
2023-01-16 13:45:03 +01:00
Joshua Ashton bb75e214d6 [dxgi] Store top-level DxgiFactory in DxgiSwapChain
Can do this now that we tossed the old stuff that depended on the swapchain factory being resident in D3D11.
2023-01-16 13:45:03 +01:00
Joshua Ashton 9010f11adf [dxgi, d3d11] Remove support for legacy IWineDXGISwapChainFactory interface
vkd3d-proton 2.8 released last year with support for the new swapchain
interface.

No need to keep support for this legacy interface hanging around when
it complicates adding DxgiOptions support to the swapchain.
2023-01-16 13:45:03 +01:00
Philip Rebohle af05265cb6 [dxvk] Set thread priority for background workers
We accidentally lost this somehow.
2023-01-15 15:54:03 +01:00
Philip Rebohle 459758c6ff [d3d9] Don't set storage buffer usage unless necessary
This actually matters now to some degree.
2023-01-15 15:36:05 +01:00
Philip Rebohle d35bf455d9 [dxvk] Rename bindResourceBuffer to bindUniformBuffer 2023-01-15 15:36:05 +01:00
Philip Rebohle a8f9fdb21d [dxvk] Rearrange descriptor sets
This allows us not to unnecessarily dirty the FS UBO set when
changing tetxure bindings, leading to a cleaner separation.
2023-01-15 15:36:05 +01:00
Philip Rebohle 4a30933359 [dxvk] Add UBO set property to descriptor info
Used to explicitly propagate storage buffer bindings
to the respective UBO set.
2023-01-15 15:36:05 +01:00
Philip Rebohle 6f194b0e7b [d3d11] Bind UAV counter buffers as views 2023-01-15 15:36:05 +01:00
Philip Rebohle 82f500250f [hud] Bind data buffers as views 2023-01-15 15:36:05 +01:00
Philip Rebohle c347bd4d8b [dxvk] Allow creating buffer views with undefined format 2023-01-15 15:36:05 +01:00
Philip Rebohle 92de3f3f5f [d3d11] Add missing context locks 2023-01-14 18:40:41 +01:00
Philip Rebohle 1c2df54bdf [dxvk] Improve logging in case of memory errors 2023-01-14 03:39:55 +01:00
Philip Rebohle 2922b780c1 [dxvk] Properly handle bufferImageGranularity for images
Fixes validation errors about dedicated allocations being
bigger than the image's memory requirement on Nvidia.
2023-01-14 03:39:55 +01:00
Robin Kertels 97a91c816f [d3d9] Disable instancing for non-indexed draws 2023-01-13 21:58:41 +00:00
Philip Rebohle 3a84838ac4 [hud] Display approximate progress when compiling shaders 2023-01-13 16:43:27 +01:00
Philip Rebohle c978e62ec8 [dxvk] Implement better priority system for background shader compiles
Reduces the number of workers that perform background optimization,
which may reduce the performance impact when encountering a large
number of new pipelines at once.
2023-01-13 16:43:27 +01:00
Blisto91 cc9266edaa [util] Add config for Alien Rage
Reporting a GTX 295 puts us into the highest behind the scenes graphics settings preset bucket and prevents the shadow issue with `FloatingPointRenderTargets` set to false in the lower preset bucket.
NvapiHack needs to be disabled on Linux since the game pings it in the Windows system folder and want's the VendorId to match your GPU. Else the issue will still happen on Nvidia Linux
2023-01-13 14:15:54 +01:00
Philip Rebohle 070a340115 [dxvk] Remove path to look up optimized pipeline in cache
For some reason this sometimes takes several milliseconds, which
leads to noticeable stutter. Linking a pipeline is more consistent.
2023-01-13 11:40:01 +01:00
Philip Rebohle a22d70e184 [dxvk] Remove unused compileComputePipeline function 2023-01-12 17:35:05 +01:00
Philip Rebohle e5157a5360 [dxvk] Add pre-rasterization pipeline libraries to the state cache
This allows compiling tessellation or geometry shader pipelines
early while still using the pipeline library path.

Also removes compute shaders. Since API-provided compute shaders
are always compiled early, supporting them is no longer needed.
2023-01-11 11:48:16 +01:00
Philip Rebohle 28ae85b7ab [dxvk] Enable creating full pre-rasterization pipeline libraries 2023-01-11 11:48:16 +01:00
Philip Rebohle 17529101d5 [dxvk] Allow creating pipeline libraries with more than one shader 2023-01-11 11:48:16 +01:00
Philip Rebohle f9ff96d727 [dxvk] Implement checks for pre-raster pipeline library compatibility 2023-01-11 11:48:16 +01:00
Philip Rebohle b916dc04e5 [dxbc] Fill in patch vertex count info 2023-01-11 11:48:16 +01:00
Philip Rebohle 5e42230b95 [dxvk] Add patch vertex count to shader info struct 2023-01-11 11:48:16 +01:00
Philip Rebohle f76a7c285c [dxvk] Rework DxvkShaderPipelineLibrary to work with multiple shaders 2023-01-11 11:48:16 +01:00
Philip Rebohle 8011a40843 Revert "[dxbc] Handle dead code in shader binaries"
Apparently this regressed something, but the reporter who asked
for this fix in the first place did not specify what, so let's
just revert this and break the whole thing again until we get
something to actually work with.

This reverts commit 5115d80d51.
2023-01-10 20:37:22 +01:00
Philip Rebohle 8052347a22 [dxvk] Keep more empty system memory chunks alive 2023-01-10 03:42:37 +01:00
Philip Rebohle 0342a25e61 [d3d9,dxso] Add d3d9.forceSampleRateShading option 2023-01-09 18:35:02 +01:00
Philip Rebohle e426ec09a1 [d3d11,dxbc] Add d3d11.forceSampleRateShading option 2023-01-09 18:35:02 +01:00
Philip Rebohle 06fb93daf0 [dxvk] Only create state cache file on demand
If no pipelines are ever written to it, we should not create
the cache file in the first place.
2023-01-09 18:31:18 +01:00
Philip Rebohle 6a4fe06ac6 [dxvk] Fix incorrect flags for null fs pipeline layout 2023-01-09 18:31:18 +01:00
Joshua Ashton 5206d97710 [dxgi] Workaround UE4 DX11 + HDR crashes
Unreal Engine 4 titles use AGS/NVAPI to try and enable
HDR globally.
They can key this off IDXGIOutput::GetDesc1's ColorSpace
being HDR10.
Many of these UE4 games statically link against AGS.

This is a problem as when UE4 tries to enable HDR via AGS,
it does not check if AGSContext, and the display info etc
are nullptr unlike the rest of the code using AGS.
So we need to special-case UE4 titles to disable reporting a HDR
when they are in DX11 mode.

The simplest way to do this is to key off the fact that all
UE4 titles have an executable ending with "-Win64-Shipping".

We check if d3d12.dll is present, to determine what path in
UE4 we are on, as there are some games that ship both and support HDR.
(eg. The Dark Pictures: House of Ashes, 1281590)
Luckily for us, they only load d3d12.dll on the D3D12 render path
so we can key off that to force disable HDR only in D3D11.
2023-01-09 12:54:28 +00:00
Blisto91 3ed0a4fd43 [util] Set Secret World Legends launcher to SM 2 2023-01-08 10:47:04 +01:00
Beyley Thomas c11a63f5e5 [wsi] Add GLFW backend 2023-01-08 10:36:25 +01:00
Hunter Kvalevog 3491895960 [dxvk] Remove SDL dummy window
SDL >= 2.0.9 permits passing a nullptr window to
SDL_Vulkan_GetInstanceExtensions, so there's no
point in going though the work of creating a
window just to call this function.
2023-01-07 22:43:32 +00:00
Philip Rebohle 196fefec4c [dxvk] Enable dynamic multisample state if supported by the device
Eliminates stutter in situations where sample rate shading is used with MSAA.
2023-01-06 23:48:31 +01:00
Philip Rebohle f269cde749 [dxvk] Enable device features for dynamic multisample state 2023-01-06 23:48:31 +01:00
Philip Rebohle 4612113227 [meta] Update hopelessly outdated README entry 2023-01-06 23:48:14 +01:00
Philip Rebohle 389634f9b9 [d3d11] Fix D3D11Texture2D reference counting 2023-01-06 22:52:29 +01:00
Philip Rebohle 5115d80d51 [dxbc] Handle dead code in shader binaries
We should not emit any code when not inside a function.

Fixes #3154.
2023-01-06 20:49:13 +01:00
Joshua Ashton c10b53ed3e [dxgi] Add dxgi.enableHDR option 2023-01-06 17:27:38 +01:00
Joshua Ashton 3375cdf1fa [dxgi] Initialize DxgiOptions before DxgiMonitorInfo
Needed to we can access DxgiOptions inside of DxgiMonitorInfo for the dxgi.enableHDR property coming up in a future commit.
2023-01-06 17:27:38 +01:00
Joshua Ashton f25475d05e [dxgi] Normalize display metadata to something rational
Sometimes we can't get an EDID if things aren't plumbed fully, or some displays just have broken EDIDs.

This accounts for both of those cases by using some dummy data if we are missing information.

Fixes value reporting to match Windows on common displays such as LG OLEDs.
2023-01-06 17:27:38 +01:00
Joshua Ashton f453d6ee2a [dxgi] Implement DXGIOutput::GetDesc1's ColorSpace
Adds the ability to punt the global colorspace into HDR from SetColorSpace1.

We have no way of checking the actual Windows colorspace as the
only public method for this *is* DXGI which we are re-implementing.
So we just pick our color space based on the DXVK_HDR env var
and the punting from SetColorSpace1.

We might expand on this in future, but this is good enough for an
initial implementation.
2023-01-06 17:27:38 +01:00
Blisto91 dd660585c0 [meta] Remove current year from copyright notice 2023-01-06 16:48:04 +01:00
Joshua Ashton 4d2e90ceba [build] Bump libdisplay-info fork again 🐸
Bruh moment with MAX_PATH define between MinGW and Windows headers going on. Should have just PRed it from the start to avoid the churn :(
2023-01-06 11:29:50 +00:00
Joshua Ashton 421ac48007 [build] Bump libdisplay-info fork subproject to fix MSVC builds 2023-01-06 10:38:17 +00:00
Joshua Ashton fd34dba070 [build] Bump libdisplay-info fork
Should fix issues running under Windows with MinGW builds.
2023-01-06 10:08:52 +00:00
Robin Kertels f94b42f23f [d3d9] Dont use GenerateDrawInfo in DrawPrimitiveUp
This is confusing because it looks like a race condition
at first glance.
2022-12-30 19:29:34 +00:00
Philip Rebohle 12901b52f1 [dxvk] Split barriers with very large VkDependencyInfo structures
Works around an AMD driver bug. Fixes #3138.
2022-12-20 03:10:44 +01:00
Philip Rebohle f4f4f3647f [d3d11] Do not create storage image views with swizzle
This happens when a game uses A8_UNORM UAVs. Vulkan doesn't allow this,
and it's not meaningful for stores anyway, we'd need shader emulation.
2022-12-20 02:20:11 +01:00
Joshua Ashton c7be18cb26 [d3d11] Implement SetHDRMetadata 2022-12-19 22:15:18 +01:00
Joshua Ashton e5418a956a [vulkan] Add setHdrMetadata method to Presenter 2022-12-19 22:15:18 +01:00
Joshua Ashton 731bf84edd [dxvk] Enable VK_EXT_hdr_metadata 2022-12-19 22:15:18 +01:00
Joshua Ashton 4335eccae9 [dxvk] Enable VK_EXT_swapchain_colorspace 2022-12-19 22:15:18 +01:00
Joshua Ashton 33acf58ac7 [d3d11] Implement CheckColorSpaceSupport and SetColorSpace 2022-12-19 22:15:18 +01:00
Joshua Ashton 50054d4675 [vulkan] Add supportsColorSpace method to Presenter 2022-12-19 22:15:18 +01:00
Joshua Ashton fd661d587e [vulkan] Simplify args to Presenter GetSupported* methods 2022-12-19 22:15:18 +01:00
Robin Kertels 18b0ef697c [dxvk] Rework SetEventOnCompletion
* Create the waiter thread on demand
* Don't wake up the waiter thread every 10ms
  when no events are queued
* Wait on caller thread when hEvent = null
2022-12-16 17:37:19 +01:00
Philip Rebohle 6d4161cd6e [meta] Fix issues with build scripts if there are spaces in the path 2022-12-16 17:15:50 +01:00
Philip Rebohle c55c09368b [d3d11] Only store low 8 bits of stencil reference
Seems to match behaviour of the D3D11 runtime, in that OMGetDepthStencilState
will not retain the high bits.

Found by CME. Should fix #1784.
2022-12-11 19:51:57 +01:00
Blisto91 7b2024888e [util] disable unmapping for Final Fantasy XIV d3d9 2022-12-11 14:01:27 +01:00
Joshua Ashton c0d843c578 [wsi] Fix overwriting colorimetry info to NULL 2022-12-08 06:48:30 +00:00
bno1 858452a0bd [build] Fix submodule url for libdisplay-info 2022-12-06 22:53:49 +01:00
Philip Rebohle b838b65516 [d3d9] Correctly mask alpha reference push constant
We accidentally lost this during the rework, since the initial
implementation scaled the alpha ref value on the CPU.

Fixes #3123.
2022-12-06 21:25:55 +00:00
Blisto91 4a4d880130 [util] Set TRAHA Global to Intel vendor id 2022-12-04 23:06:59 +01:00
Robin Kertels 522909b165 [d3d9] Don't set NeedsReadback when dirtying mip maps
It's impossible to lock non 0 mips anyway.
2022-12-03 15:18:40 +00:00
Philip Rebohle 573be24269 [wsi] Fix crash when parsing EDID fails
If info is null then we shouldn't pass it around.

Also improve formatting a bit.
2022-12-02 00:23:38 +00:00
Philip Rebohle 9f70666777 [build] Allow standalone DXGI builds 2022-11-28 13:48:05 +01:00
Hans-Kristian Arntzen 42332f7fb8 [dxgi] Fix IDXGISwapchain::CheckColorSpaceSuport 2022-11-28 12:45:34 +01:00
wael 7644776f7a README: fix wine dll path 2022-11-26 13:05:15 +01:00
Philip Rebohle 57176e77ea [meta] Don't try to package setup script in a release tarball 2022-11-25 14:51:52 +01:00
Philip Rebohle 64cb1ad208 [meta] Remove setup script 2022-11-25 14:50:31 +01:00
Philip Rebohle 4f90d7bf5f [dxbc,d3d11] Don't access shex chunk if it is not defined 2022-11-25 12:45:32 +01:00
Joshua Ashton d01c9cb6d4 [wsi] Free edid info after parsing 2022-11-25 08:44:39 +00:00
Philip Rebohle ebd29007d4 [dxgi] Actually unlock monitor info
Fixes some deadlocks.
2022-11-21 20:24:15 +01:00
Philip Rebohle c6611dffa7 Revert "[dxbc] Move shex check to constructor"
Breaks stuff for unknown reasons.
2022-11-21 19:35:21 +01:00
Joshua Ashton f0a0e1b964 [dxgi] Report display metadata in IDXGIOutput6::GetDesc1 2022-11-21 17:26:53 +01:00
Joshua Ashton aa71e7e323 [dxgi] Cache display metadata + colorimetry in DXGI_VK_MONITOR_DATA 2022-11-21 17:26:53 +01:00
Joshua Ashton fabe4a85e3 [wsi] Add parseColorimetryInfo helper 2022-11-21 17:26:53 +01:00
Joshua Ashton ac10c75ca0 [build] Add Josh's libdisplay-info fork for parsing EDIDs
This will be used to parse static HDR metadata and chromaticity of the display.

Upstream currently has no Windows or MSVC support so use my fork for now.
2022-11-21 17:26:53 +01:00
Philip Rebohle 3b9235fe23 [util] Set max frame latency to 1 for Sonic Frontiers
Seems like the only reason this game passes QA is because there *was* no
QA. Seriously broken when GPU-bound even on Windows.
2022-11-21 17:18:01 +01:00
Robin Kertels 4796eb0b0d [d3d9] Implement capturing lights in state blocks 2022-11-21 16:06:49 +00:00
Robin Kertels 1a3b576d35 [util] Implement bit vector 2022-11-21 16:06:49 +00:00
Robin Kertels d0a10cc9f8 [d3d9] Handle DS texture uploads 2022-11-21 15:59:25 +00:00
Blisto91 2c53459f4c [util] disable floatControls for Bad Company 2 2022-11-21 13:13:57 +01:00
Robin Kertels dd7ec24269 [dxbc] Move shex check to constructor
Otherwise we dereference a null pointer when
accessing the DxbcProgramInfo.
2022-11-21 01:49:35 +01:00
Robin Kertels 3393c5f4ff [d3d9] Only upload mip 0 of managed automipgen textures 2022-11-19 17:34:02 +00:00
Philip Rebohle a130146f15 [dxvk] Remove dead enableRtOutputNanFixup option
Dead code since 2.0, not sure why this was still in here.
2022-11-18 22:31:54 +01:00
Joshua Ashton e037d24017 [util] Default initialize BitMask to 0
Found via an MSVC warning, may not fix anything, but good to do anyway.
2022-11-17 17:38:46 +01:00
Joshua Ashton 287412f746 [util] Cast _tzcnt_u64 to uint32_t
MSVC has _tzcnt_u64 return a uint64_t, which obviously, it can never return a number that big.
2022-11-17 17:38:46 +01:00
Joshua Ashton 69b1aa251d [wsi] Add getMonitorEdid function
What an unbelievable pain this is to do on Windows...

No-op on SDL2 right now, as there is nothing for that.
2022-11-17 17:38:16 +01:00
Blisto91 ad3c316d0c [util] Set Black Mesa customVendorId to Nvidia 2022-11-16 11:30:40 +01:00
Robin Kertels 785bc9738f [util] Disable DC Single Use Mode for Cardfight!! Vanguard Dear Days 2022-11-15 16:55:38 +01:00
Philip Rebohle 8f8a93696d [meta] Release 2.0 2022-11-10 13:55:39 +01:00
Robin Kertels 8a2e4ef481 [d3d9] Allow locking DEFAULT pool based on texture type 2022-11-10 13:37:52 +01:00
Philip Rebohle 82685ca4fc [meta] Explicitly use meson setup command
Fixes some deprecation warnings with Meson 0.64.
2022-11-10 13:26:31 +01:00
Blisto91 bc08cac220 [util] Enable apitraceMode for Sonic & All-Stars Racing Transformed 2022-11-09 19:22:14 +01:00
Christopher Egert e30b783505 d3d9: Use a different rvalue for depth bias on NV 2022-11-09 01:15:00 +00:00
Robin Kertels ecc2302389 [d3d9] Fix query reset counter underflow 2022-11-07 23:34:32 +00:00
Philip Rebohle 76e6b2764b [dxgi] Change CreateSwapChain to take a surface factory 2022-11-07 14:14:05 +01:00
Philip Rebohle 03dca539cb [vulkan,d3d9,d3d11] Move surface creation to swap chain implementation 2022-11-07 14:14:05 +01:00
Philip Rebohle 49cf0ecf54 [vulkan] Don't handle SURFACE_LOST in Vulkan presenter 2022-11-07 14:14:05 +01:00
Philip Rebohle 3a9e975a71 [dxgi] Implement DxgiSurfaceFactory 2022-11-07 14:14:05 +01:00
Philip Rebohle 1754b73ade [wsi] Change interface for surface creation
This temporarily breaks Win32 swap chains, but we're fine with that
since this will take some refactoring.
2022-11-07 14:14:05 +01:00
Philip Rebohle bd87e19de1 [dxgi] Introduce IDXGIVkSurfaceFactory 2022-11-07 14:14:05 +01:00
Robin Kertels d8933ca175 [d3d9] Only do one allocation for all texture subresources 2022-11-06 19:35:03 +00:00
Blisto91 145c1ce127 [util] Limit fps to 60 for some WayForward games 2022-11-06 15:32:28 +01:00
Robin Kertels 4fb7acc64e [d3d9] Implement converter for W11V11U10 2022-11-06 02:55:29 +00:00
Vlad 40a4908a2a Support for MW:R H1-Mod 2022-11-05 16:07:16 +01:00
Blisto91 e1eec9b359 [util] Set Fallout 3 to Nvidia vendor id 2022-11-05 16:07:04 +01:00
Robin Kertels 892f676605 [util] Disable direct buffer mapping for Dragon Age Origins 2022-11-02 16:12:28 +01:00
Philip Rebohle 0b9f785bc5 [dxvk] Remove broken memory budget logic for UMA systems
All heaps on an UMA systems are by definition device-local, so this
just leads to unnecessary issues.
2022-11-01 12:48:03 +01:00
Adam Jereczek 0462454d2b
Fix for saving vertex shader constants with a StateBlock
Co-authored-by: aroztkow <aneta.roztkowska@intel.com>
2022-10-31 18:16:15 +00:00
Robin Kertels 0fc5c84e7b [d3d9] Don't advertise support for MS INTZ format 2022-10-30 21:50:44 +00:00
Georg Lehmann bc31ebe151 [d3d9] Fix OptimizeLayout with feedback loop usage.
We kind of need dcc on GFX8/9.
2022-10-29 11:21:55 +02:00
Konstantin Kharlamov cd21cd7fa3 setup_dxvk.sh: install with reflinks if supported
Some filesystems, such as XFS and BTRFS, may perform a lightweight copy
with CoW. This is most useful for rarely changing content, and the
usecase of installing DXVK is one of such usecases, as library files are
usually not modified (might be removed, but it's not modification).

So make use of it whenever supported.
2022-10-25 03:46:31 +02:00
Winter Snowfall f84f992d44 [util] Also enable workaround for the "mod load exe" of ToEE 2022-10-25 03:45:53 +02:00
iczero 6335f065c3 Ensure setup_dxvk.sh works with spaces in basedir 2022-10-25 03:45:23 +02:00
Robin Kertels 9c22a58543 [d3d9] Disable locking non-dynamic default textures 2022-10-24 20:55:00 +01:00
Robin Kertels d771f7cf8f [d3d9] Remove dead fields 2022-10-24 20:55:00 +01:00
Philip Rebohle 494e01b353 [d3d9] Avoid querying environment variables on shader creation 2022-10-24 18:01:48 +02:00
Philip Rebohle b055c2daea [d3d11] Avoid querying environment variables on shader creation 2022-10-24 17:58:57 +02:00
Philip Rebohle fea86ef116 [dxvk] Use dynamic depth clip enable for linked pipelines if supported
This way we won't have to compile any vertex shader pipelines twice.
2022-10-24 16:39:24 +02:00
Philip Rebohle 8e7ea899d2 [dxvk] Enable VK_EXT_extended_dynamic_state_3 if available 2022-10-24 16:39:24 +02:00
Philip Rebohle 859de7e828 [dxvk] Always enable depth clip feature if supported 2022-10-24 16:39:24 +02:00
Philip Rebohle a6ede3e0c2 [meta] Update Vulkan headers to 1.3.231 2022-10-24 16:39:24 +02:00
Georg Lehmann ae764333f4 [build] Use glslang with --depfile to rebuild on header changes 2022-10-21 17:04:47 +02:00
Georg Lehmann 2653628041 [build] Always use glslang with --quiet
We depend on a new enough glslang anyway.
2022-10-21 17:04:47 +02:00
Paul Gofman e311f25287 [dxgi] Store device pointer in DxgiSwapChainDispatcher 2022-10-20 19:05:19 +02:00
Philip Rebohle 53a0c3726c [dxvk] Don't crash immediately on pipeline library compile error
Things will blow up down the line but there's no good reason to crash
immediately. Also ignore returned pipeline on error so we'll always
return null.
2022-10-18 00:07:41 +02:00
Philip Rebohle 69d7af42a4 [dxgi] Change swap chain interface to better map to D3D12 needs 2022-10-16 16:38:29 +02:00
Philip Rebohle d7ac21b6c7 [dxgi] Use new DXVK swap chain factory if available 2022-10-16 16:38:29 +02:00
Philip Rebohle aca67f64da [d3d11] Implement IDXGIVkSwapChainFactory for D3D11 2022-10-16 16:38:29 +02:00
Philip Rebohle 580dd5cf4a [dxgi] Add swap chain factory interface definition 2022-10-16 16:38:29 +02:00
Joshua Ashton fc3d04c1c9 [meta] Fix opt_strip in package-native.sh 2022-10-15 18:25:19 +01:00
Joshua Ashton be9687f396 [meta] Fix --dev-build on package-native.sh
Re-add the suffix to the build dir.
2022-10-15 18:18:52 +01:00
Joshua Ashton d83e184afd [d3d10] Enable native builds
This started working at some point... may as well!
2022-10-15 18:17:29 +01:00
Joshua Ashton eea77b845f [meta] Add CI for native builds in Steam Runtime Sniper 2022-10-15 18:11:34 +01:00
Joshua Ashton 2484dac34a [meta] Add package-native.sh 2022-10-15 18:11:34 +01:00
Joshua Ashton 1157b235cc [build] Specify static libgcc/stdc++ on native
We don't have any interfaces that rely on the c++ abi. Makes our builds more portable.

Means that our builds in Sniper can be used on games that are still forcing the old C++03 string abi.
2022-10-15 19:10:57 +02:00
Joshua Ashton 1d3decf100 [build] Add version scripts for native builds
FEX would like clean symbols for experimenting with making thunks down the line.

We also just shouldn't be exporting a bunch of random crap -- sadly -fvisibility=hidden doesn't help with a bunch of stuff :(

For reference, RADV also does this.
2022-10-15 19:10:57 +02:00
Joshua Ashton 25798f6fe1 [build] Set name_prefix to `libdxvk_` for native builds
Less rude and nicer than just d3d9.so.
Matches old DXVK native behaviour too.
2022-10-15 19:10:57 +02:00
Christophe f1578b8ed3
[meta] Factorize history and contributors sections using schema 0.8.1 2022-10-15 17:24:44 +01:00
Joshua Ashton 3b90f5a77f [util] Enable apitrace mode for Hammer World Editor 2022-10-15 17:21:29 +01:00
Jens Peters c54eac7d61 [build] Update github actions
Use github-checkout v3, github-upload-artifact-action v3 and joshua-ashton-gcc-problem-matcher v2.
Fixes Node.js 12 deprecation warning.
2022-10-14 09:32:51 +01:00
Robin Kertels 4bcabe8d46 [d3d9] Return 0 if any vertex decl element can't be represented as fvf 2022-10-12 23:07:23 +01:00
Robin Kertels 7090105573 [d3d9] Remove declaration fvf mapping log spam 2022-10-12 23:07:23 +01:00
Robin Kertels 2b964f0c67 [d3d9] Make MapD3DDeclToFvf more readable
All branches return, so we might as well
give it a bit more room to breath.
2022-10-12 23:07:23 +01:00
Philip Rebohle bd7d2aac71 [dxgi] Get rid of NotifyModeChange method
Was only used for the FPS limiter.
2022-10-07 13:25:56 +02:00
Vinjul1704 038ed23a5d [util] Force SM1 for the Escape from Tarkov launcher 2022-10-06 21:32:19 +02:00
Joshua Ashton fa45e5838e [util] Fix tzcnt on ARM64 + Clang
This needed brackets around this conditional.
2022-10-05 19:01:05 +01:00
Philip Rebohle ab622760a0 [dxbc] Emit new block only after emitting switch instruction
Otherwise emitting the OpSwitch will reset the block ID, which
is not desireable. Fixes #2975.
2022-10-04 21:00:50 +02:00
Blisto91 f8bd19f210 [util] Cap Sonic Adventure 2 to 60 fps 2022-09-30 19:14:59 -02:30
Adam Jereczek b2ad25755a
[d3d9] Fix for missing restriction check in ProcessVertices
Co-authored-by: aroztkow <aneta.roztkowska@intel.com>
2022-09-28 12:10:41 -02:30
Joshua Ashton 49854dbfba [d3d9] Saturate viewport depth range
Viewport depth range in D3D9 is clamped at 0-1, same as OpenGL.

Drivers like RADV, etc support VK_EXT_depth_range_unrestricted,
which makes the regular UB of this actually work -- which isn't what
we want.

We also don't enable VK_EXT_depth_range_unrestricted, so we shouldn't
be setting depth ranges outside of the 0-1 bounds anyway.

Closes: #2960
2022-09-27 18:58:40 -02:30
Georg Lehmann 50857537d6 [d3d9] Use D32 not D32_S8 when upgrading formats without stencil aspect. 2022-09-27 18:58:32 +01:00
Georg Lehmann a9bdea72e9 [d3d9] Clamp Dref to [0.0, 1.0] if the texture is emulated UNORM 2022-09-26 21:39:51 +01:00
Georg Lehmann 6fe96d7d82 [dxso] Support clamping Dref. 2022-09-26 21:39:51 +01:00
Georg Lehmann 5684e29718 [d3d9] Track if a texture is upgraded to D32f 2022-09-26 21:39:51 +01:00
Georg Lehmann 6188ffa23a [d3d9] Add a config option for D24 -> D32 2022-09-26 21:39:51 +01:00
Georg Lehmann 7552cfe62a [dxso] Always lower projection 2022-09-26 21:39:51 +01:00
Philip Rebohle f1f8d45fcd [dxvk] Rework allocation logic for large resources
This may reduce internal fragmentation with very large resources.

We previously changed behaviour to not do this in order to reduce memory
pressure in the average case, however by trying to suballocate from existing
chunks and falling back to a dedicated allocation on failure, rather than
allocating a new chunk, we can mostly avoid that situation.
2022-09-24 17:06:00 +02:00
Philip Rebohle 15588004b4 [dxvk] Bump memory chunk size to 256 MiB. 2022-09-24 17:06:00 +02:00
Joshua Ashton f2950953e0 [d3d9] Avoid depth degenerate viewports 2022-09-23 13:26:50 +01:00
Joshua Ashton d221bb7a9c [d3d9] Add ID3D9VkInteropDevice
Provides access to the device and instance handles
as well as the queue that is used for rendering.
2022-09-22 17:58:54 +01:00
Joshua Ashton e976218e17 [d3d9] Make GetDXVKDevice return a const Rc reference
Avoids some useless reffing.
2022-09-22 17:58:54 +01:00
Joshua Ashton ac13112619 [d3d9] Add ID3D9VkInteropTexture
Provides access to the backing resource of a D3D9 texture.
2022-09-22 17:58:54 +01:00
Joshua Ashton ae2465079e [d3d9] Add ID3D9VkInteropInterface
Allows getting the VkInstance handle from a IDirect3D9 interface,
as well as VkPhysicalDevices from adapter ordinals.
2022-09-22 17:58:54 +01:00
Joshua Ashton 1451032b83
[d3d9] Minor cleanups in vertex declaration code (#2950) 2022-09-22 09:46:51 +00:00
Krzysztof Dobrowolski 1e1ef8f1bd
[d3d9] Fix for missing mapping of VertexElements declarations to FVF bits
When Vertex declaration is created by CreateVertexDeclaration
and SetFVF is not called then GetFVF returns 0.
This code change implements mapping of D3D declarations to FVF mask
and sets it if FVF was not set previously.
2022-09-22 08:41:40 +00:00
Michał Pyrzowski 82ebc29e18
[dxso] Fix for illegal OpCompositeConstruct while translating Crs opcode
During the translation of the Crs opcode to SPIR-V there is an assumption that the result type is a composite type. This is not always true. If the result is a scalar type the translation adds an OpCompositeConstruct with a scalar result type. This is a spec violation.

This change checks if the result type is a composite type and does not add the OpCompositeConstruct in case of scalar types.
2022-09-21 10:47:16 +00:00
Robin Kertels 5c22e2fbda [util] Enable GTA IV config for Episodes from Liberty City 2022-09-19 15:11:01 +01:00
Robin Kertels c759fb45aa [util] Disable DF support for pretty mirrors in GTA IV 2022-09-19 15:11:01 +01:00
Robin Kertels 5962be44c6 [dxso] Define color inputs as centroids on SM3 too 2022-09-19 15:10:43 +01:00
Philip Rebohle c4c1d413db [meta] Update default config file 2022-09-19 16:09:48 +02:00
Philip Rebohle a14ce8d1b0 [d3d11] Enable ROV support if corresponding Vulkan features are supported 2022-09-19 15:44:23 +02:00
Philip Rebohle 35a84053b5 [dxbc] Implement rasterizer ordered views 2022-09-19 15:44:23 +02:00
Philip Rebohle 8ca5edeacd [dxbc] Decode rasterizer ordered flag for UAVs 2022-09-19 15:44:23 +02:00
Philip Rebohle 9532126f7c [dxvk] Enable VK_EXT_fragment_shader_interlock 2022-09-19 15:44:23 +02:00
Philip Rebohle 0bb0c1e646 [util] Enable ignoreGraphicsBarriers for FFXV
Massively improves performance when VXAO is enabled.
2022-09-19 15:43:45 +02:00
Philip Rebohle 2a7706ba53 [dxbc] Do not enable SPV_KHR_shader_float_controls
This is core in Vulkan 1.2 and SPIR-V 1.5.
2022-09-18 02:27:03 +02:00
Philip Rebohle 9fa587e13c [dxgi] Always use swap chain-local present count for frame statistics
Doesn't appear to match Windows behaviour, but there may be scenarios
when we can't query the current monitor. Statistics still need to be
consistent in this case.

See #2933.
2022-09-17 05:01:36 +02:00
Philip Rebohle 5b6b9923ab [dxbc] Write point size in vertex shaders
Silences some validation errors when point rendering is enabled.
2022-09-17 01:52:19 +02:00
Philip Rebohle d93568f1a9 [dxbc] Don't emit built-in position as a block variable
This is no longer needed for interface matching.
2022-09-17 01:52:19 +02:00
xpander69 07094ac4f9 [util] Remove fps cap from Warhammer Online
This is a bit embarrassing. Added this config few days ago to counter the animation breakages, but now Return of Reckoning devs patched the executable on their side to cap the framerate by default. So the workaround is not needed anymore.
2022-09-16 21:32:49 +01:00
Philip Rebohle 4fb6c200d7 [d3d9] Use precise matrix-vector operations to compute vertex position 2022-09-16 20:04:01 +01:00
Philip Rebohle b56ec10deb [d3d9] Add helpers for precise matrix-vector products 2022-09-16 20:04:01 +01:00
Philip Rebohle 3a63c7cb31 [dxvk] Hide some more format compatibility validation errors 2022-09-16 17:24:33 +02:00
Philip Rebohle 67bd2b5e76 [dxgi] Report swap chain frame statistics 2022-09-16 12:49:42 +02:00
Philip Rebohle fe3fc82d8e [dxgi] Handle mode changes for frame statistics 2022-09-16 12:49:42 +02:00
Philip Rebohle faaa6bf1df [dxgi] Promote output stored in swap chain to IDXGIOutput1 2022-09-16 12:49:42 +02:00
Philip Rebohle 57af9e8760 [dxgi] Estimate vblank count for frame statistics 2022-09-16 12:49:42 +02:00
Philip Rebohle c56a9b5a3f [dxgi] Implement WaitForVBlank using new sleep helper
Not very accurate, but probably good enough if the display
refresh rate is known.
2022-09-16 12:49:42 +02:00
Philip Rebohle 3543673c5c [util] Add helper to compute display refresh related stuff 2022-09-16 12:49:42 +02:00
Philip Rebohle e019edc8c3 [util] Add helper to get time point from raw counter value 2022-09-16 12:49:42 +02:00
Philip Rebohle c1ab09a048 [util] Move platform-specific sleep code to dedicated helper class 2022-09-16 12:49:42 +02:00
Joshua Ashton 000a647c56 [d3d11] Store D3D11DeviceContextState as private ref
Avoids a circular dependency
2022-09-16 12:49:10 +02:00
Joshua Ashton a69c65265a [d3d11] Store context predication query as private ref 2022-09-16 12:49:10 +02:00
Joshua Ashton 9e4877be81 [d3d11] Store SoTarget buffer as a private ref 2022-09-16 12:49:10 +02:00
Joshua Ashton b40935a48d [d3d11] Store context state ID buffers as private refs 2022-09-16 12:49:10 +02:00
Joshua Ashton ca38cebe0b [d3d11] Store private refs for IA layout 2022-09-16 12:49:10 +02:00
Joshua Ashton 9545281542 [d3d11] Store private refs for VB + IB bindings 2022-09-16 12:49:10 +02:00
Joshua Ashton 9bfe46ac50 [d3d11] Store private refs for srv and rtv bindings 2022-09-16 12:49:10 +02:00
Joshua Ashton 2419226456 [d3d11] Store private refs for constant buffer bindings 2022-09-16 12:49:10 +02:00
Joshua Ashton 8758bcedae [d3d11] Store private refs to context shaders 2022-09-16 12:49:10 +02:00
Joshua Ashton 699d56e35d [d3d11] Handle nullptr RasterizerState in ApplyRasterizerSampleCount
This broke as of a637134c56 is causing a crash in the BGFX d3d11 samples.
2022-09-16 11:40:36 +02:00
Joshua Ashton 3a6f8fa413 [d3d11] Assign ForcedSampleCount to correct value in ApplyRasterizerSampleCount
ForcedSampleCount was never being respected as it would always be replaced with 1 as it was being assigned to the wrong variable.

This was also probably causing a bunch of redundant CS work as it was changing state that was dirty checked.
2022-09-16 11:40:36 +02:00
Philip Rebohle 1c33d8be1f [dxgi] Fix return value of ChangeDisplayMode 2022-09-15 15:35:54 +02:00
Paul Gofman 10d6e15646 [d3d9] Do not set window size and position when restoring from fullscreen state
Closes #2920.
2022-09-15 09:33:24 +01:00
Krzysztof Dobrowolski 19b76825d0 [d3d9] Fix for missing restriction check in UpdateSurface.
The spec of IDirect3DDevice9::UpdateSurface contains the following restriction:
- Neither surface can be created with multisampling.
  The only valid flag for both surfaces is D3DMULTISAMPLE_NONE.

This commit adds this check and returns D3DERR_INVALIDCALL
when source or destination surfaces are multisampled.
2022-09-15 09:32:31 +01:00
Blisto91 2890f690f6 [meta] remove --with-d3d10 from readme 2022-09-14 18:04:36 +02:00
Georg Lehmann 18a801de84 [dxso] Use a * (y - x) + x for lerp.
Fixes Alice: Madness Returns.
2022-09-13 23:10:11 +01:00
Rhys Perry 63ca34bb29 [dxbc] Fix forceVolatileTgsmAccess for stores
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
2022-09-13 21:41:59 +02:00
Joshua Ashton 68c528d345 [util] Implement bitmask iterator on non-x86 platforms 2022-09-13 20:11:17 +01:00
Joshua Ashton 2218462ff2 [util] Implement spin on ARM64 2022-09-13 20:11:17 +01:00
Joshua Ashton 57cee691b3 [util] Implement replaceNaN for non-x86 platforms 2022-09-13 20:11:17 +01:00
Joshua Ashton 2d8e14fcf4 [util] Implement bcmpeq for non-x86 platforms 2022-09-13 20:11:17 +01:00
Joshua Ashton c3093b546e [util] Implement tzcnt for non-x86 platforms 2022-09-13 20:11:17 +01:00
Joshua Ashton 466026632d [util] Only include x86 intrinsics headers on x86 2022-09-13 20:11:17 +01:00
Joshua Ashton 736f91fad1 [util] Add macro to determine CPU arch 2022-09-13 20:11:17 +01:00
Philip Rebohle 21a521361e [spirv] Remove OpKill helper
This is deprecated, so make sure we never accidentally
use it in the future.
2022-09-13 15:30:13 +02:00
Philip Rebohle af208ceb9e [dxbc] Optimize write pattern for TGSM initialization
Reduces bank conflicts.
2022-09-12 22:33:40 +02:00
Philip Rebohle 05f36fd97b [dxbc] Only use workgroup scope in compute shaders
Turns out that global barriers can be used in graphics shaders.
2022-09-12 22:05:39 +02:00
Philip Rebohle 0502a0464f [dxbc] Fix broken barrier around TGSM init code 2022-09-12 22:05:39 +02:00
Philip Rebohle 944a945822 [dxvk] Fix validation error on FS resolve path 2022-09-12 18:59:58 +02:00
Philip Rebohle d9466eb2b9 [dxvk] Get rid of immutable sampler for resolve operations 2022-09-12 18:59:58 +02:00
Riesi 26c8f46b6b [util] Limit King Of Fighters XIII to 60 FPS
Game speed is tied to FPS
fixes #2647
2022-09-12 18:53:42 +02:00
Blisto91 e05e063df0 [util] Enable memoryTrackTest for SiN Episodes Emergence 2022-09-12 18:37:30 +02:00
Philip Rebohle eda366662c [dxbc] Handle workgroup-coherent UAVs more efficiently
Some drivers don't handle the workgroup scope on stores and loads properly,
so let's just do the availability and visibility operation on barriers.
2022-09-12 18:19:02 +02:00
Philip Rebohle 8842af2ad6 [dxvk] Get rid of sampler for pack operations 2022-09-12 14:20:30 +02:00
Philip Rebohle 8dc9400045 [d3d11] Report D3D11_FORMAT_SUPPORT2_SHAREABLE appropriately 2022-09-11 16:40:02 +02:00
Philip Rebohle 299fc4c4cf [d3d11] Determine shared resources tier more accurately 2022-09-11 16:40:02 +02:00
Philip Rebohle 443cb658f7 [dxvk] Clean up DxvkImage::canShareImage 2022-09-11 16:40:02 +02:00
Philip Rebohle 0123e844b2 [dxvk] Move getFormatLimits back to DxvkAdapter 2022-09-11 16:40:02 +02:00
Philip Rebohle c0fdf1449c [dxvk] Allow querying external memory features for image formats 2022-09-11 16:40:02 +02:00
Philip Rebohle 3a636f6094 [dxvk] Introduce DxvkFormatQuery 2022-09-11 16:40:02 +02:00
Joshua Ashton ce47bf4264 [build] Disable some dumb clang warnings 2022-09-10 21:46:07 +00:00
Joshua Ashton 10bb285f2e [d3d9] Remove unused dstExtent + friends in GetRenderTargetData 2022-09-10 21:46:07 +00:00
Joshua Ashton 935541bcb0 [util] Make math types have implicit copy assignments
We define implicit copy constructors, should also define implicit copy assignments.
2022-09-10 21:46:07 +00:00
Joshua Ashton 99e01d64f7 [dxso] Make fallthrough for extra params explicit 2022-09-10 21:46:07 +00:00
Joshua Ashton 9adc6f2d3e [d3d11] Remove unused this capture in UnbindResources 2022-09-10 21:46:07 +00:00
Joshua Ashton a3727ebd42 [d3d11] Fix UNKNOWN enum in video view dimension switch cases 2022-09-10 21:46:07 +00:00
Joshua Ashton f9bd1a5d79 [build] Enable warning_level 2
Compiles cleanly with GCC 12
2022-09-10 21:27:04 +00:00
Joshua Ashton 64d88c684d [dxbc] Explicitly cast down to VkAccessFlags when assinging binding.access
Otherwise both halves of the terniary are differing types causing a warning.
2022-09-10 21:27:04 +00:00
Joshua Ashton aa06e71dee [d3d11] Remove useless const qualifiers on IsYCbCr and NeedsCopy return values 2022-09-10 21:27:04 +00:00
Joshua Ashton ce5e7ad427 [d3d11] Remove MaxAnisotropy < 0 check
This type is unsigned, this is impossible.
2022-09-10 21:27:04 +00:00
Joshua Ashton b0ac267fd5 [d3d9] Explicitly cast to D3DRENDERSTATETYPE in ColorWriteIndex
Need this to silence warnings after doing some arithmetic on an enum.
2022-09-10 21:27:04 +00:00
Joshua Ashton f42df87937 [dxvk] Remove useless const qualifier on getColorAttachmentIndex return type
This does nothing.
2022-09-10 21:27:04 +00:00
Joshua Ashton ec6ad90f22 [dxvk] Fix value type in QueueItem
This was being truncated from uint64_t -> uint32_t then stored in a uint64_t which seems unintentional...
2022-09-10 22:55:58 +02:00
Philip Rebohle cbbc4a595e [meta] Update issue template 2022-09-10 21:21:54 +02:00
Philip Rebohle ccfb986e72 [dxbc] Rework TGSM workaround 2022-09-10 14:27:13 +02:00
Philip Rebohle 8176101228 [dxbc] Enable Vulkan memory model 2022-09-10 14:27:13 +02:00
Philip Rebohle 68cfc84329 [dxvk] Enable vulkanMemoryModel feature 2022-09-10 14:27:13 +02:00
Philip Rebohle 0b891a93b2 [spirv] Add support for memory operands on load/store operations 2022-09-10 14:27:13 +02:00
Philip Rebohle d564be68d6 [spirv] Handle availability and visibility image operands 2022-09-10 14:27:13 +02:00
Philip Rebohle 0f9a042952 [d3d11] Report Tiled Resources Tier 3 again
Partially reverts df5756c9a5.

Turns out that WARP does this, so we might as well expose it too.
2022-09-10 14:26:50 +02:00
xpander69 2ec25f588f Cap Warhammer Online to 100 FPS
Animations break with 100+ FPS. Engine Limitation. WAR-64.exe is affected by this. WAR.exe is capped to 100 by default.
2022-09-10 13:02:47 +02:00
Georg Lehmann bd5d9d90c9 [d3d9] Use xor to swap bit in depth mask. 2022-09-10 04:16:30 +00:00
Georg Lehmann 1bc6f9660a [d3d9] Force D3DTADDRESS_CLAMP for cubes. 2022-09-10 04:16:30 +00:00
Philip Rebohle 5babb29922 [d3d11] Set host stage and access bits for staging resources
We don't need this for resources that we'll never read back from.
2022-09-08 19:26:55 +02:00
Philip Rebohle 4b8387c9b1 [d3d9] Set host stage and access bits for image staging buffers
This is already being done for buffers.
2022-09-08 19:26:55 +02:00
Philip Rebohle 044e2e9dff [dxvk] Defer host barriers until the end of the current command buffer 2022-09-08 19:26:55 +02:00
Philip Rebohle 72de8a1dc1 [dxvk] Destroy command list fences
Fixes a validation error.
2022-09-08 19:26:33 +02:00
Philip Rebohle 912b06f37c [meta] Bump MinGW version requirement to 10.0 in README 2022-09-08 12:09:11 +02:00
Robin Kertels 2b16134b64 [util] Enable d3d9.memoryTrackTest for The Ship 2022-09-07 21:05:48 +02:00
Joshua Ashton 1ea48558e5 [wsi] Fix return value of setMonitorDisplayMode 2022-09-07 21:05:20 +02:00
Joshua Ashton 846db795f8 [dxvk] Link against dl for native builds
Fixes build under Steam Runtime Sniper
2022-09-07 17:02:54 +01:00
Philip Rebohle 9964e4a632 [d3d11] Clean up resource validation around tiled resources 2022-09-05 07:51:08 +02:00
Philip Rebohle df5756c9a5 [d3d11] Do not report Tiled Resources Tier 3
Neither Nvidia nor AMD drivers report Tier 3 support on Windows,
so this is likely a D3D11 runtime limitation, even though the
API could technically support it.
2022-09-05 07:51:08 +02:00
Philip Rebohle b12e4fc59f [dxvk] Check whether SparseResidency capability is used in a shader 2022-09-05 07:51:08 +02:00
Philip Rebohle 02600706fe [d3d11] Enable Conservative Rasterization Tier 3
Mostly to bring this in line with vkd3d-proton.
2022-09-05 07:27:00 +02:00
Philip Rebohle d14d70af05 [dxvk] Check whether FragmentFullyCoveredEXT capability is used in a shader 2022-09-05 07:26:23 +02:00
Philip Rebohle 3401964ee2 [dxbc] Implement support for SV_InnerCoverage 2022-09-05 07:21:47 +02:00
Philip Rebohle bd912212b5 [d3d11] Adjust preferred mapping modes for default images 2022-09-05 05:52:55 +02:00
Philip Rebohle fdcbdeb28f [d3d11] Implement dirty trackig for default-mapped images
Avoids GPU synchronization when using WriteToSubresource,
and also reduces bandwidth.
2022-09-05 05:52:55 +02:00
Philip Rebohle 40ffac72d9 [d3d11] Introduce methods for dirty region tracking for mapped images 2022-09-05 05:52:55 +02:00
Philip Rebohle 1bed39f266 [d3d11] Rework ReadFromSubresource and WriteToSubresource
Mainly changes the code to use existing helpers where possible, and
adds support for planar images, which was previously completely broken
for these functions.
2022-09-05 04:32:01 +02:00
Philip Rebohle ca833082b5 [d3d11] Fix broken image readback for mapped default images 2022-09-05 04:31:13 +02:00
Philip Rebohle e9851bee86 [dxvk] Introduce per-aspect version of computeImageDataSize 2022-09-05 04:31:13 +02:00
Philip Rebohle 957d99ed8d [dxvk] Fix broken layer handling in packImageData 2022-09-05 03:39:23 +02:00
Philip Rebohle d42df37257 [meta] Clean up obsolete feature levels in Vulkan profile 2022-09-04 18:28:27 +02:00
Philip Rebohle e8c1a8e734 [dxbc] Clean up support check for R32 reads without format 2022-09-04 18:28:27 +02:00
Philip Rebohle 6d9353f4e9 [d3d11] Don't depend on variableMultisampleRate feature 2022-09-04 18:28:27 +02:00
Philip Rebohle 882072e134 [d3d11] Move maximum feature level check to D3D11DeviceFeatures 2022-09-04 18:28:27 +02:00
Philip Rebohle c082e7f0a9 [d3d11] Add convenience query for Conservative Rasterization tier 2022-09-04 18:28:27 +02:00
Philip Rebohle 59dd2d54cd [d3d11] Add convenience query for Tiled Resources tier 2022-09-04 18:28:27 +02:00
Philip Rebohle 0e70398d4e [d3d11] Use D3D11DeviceFeatures in CheckFeatureSupport 2022-09-04 18:28:27 +02:00
Philip Rebohle 71d6e8f849 [d3d11] Introduce D3D11DeviceFeatures 2022-09-04 18:28:27 +02:00
Philip Rebohle 5490aa936b [d3d11] Rework D3D11 feature enablement
Rather than enabling based on requested feature levels, always enable
all supported features that we might use, and report the maximum
feature level based on that.

This fixes an issue in CreateDeviceContextState which may raise the
device feature level, and another issue wherein the feature level
override is ignored if tiled resources are not supported.
2022-09-04 18:28:27 +02:00
Philip Rebohle c4516c5b04 [dxvk] Improve behaviour when variableMultisampleRate is not supported 2022-09-04 18:28:27 +02:00
Philip Rebohle 8d9d9912ff [dxvk] Remove extension info from DXVK device 2022-09-04 18:28:27 +02:00
Philip Rebohle ff6a6e2d37 [d3d11] Use new pseudo-features where applicable 2022-09-04 18:28:27 +02:00
Philip Rebohle 51e0a56243 [dxvk] Use new pseudo-features where applicable 2022-09-04 18:28:27 +02:00
Philip Rebohle 019ebeeaf7 [dxvk] Introduce pseudo-features for extensions with no feature struct
Makes it easier to keep track of supported extensions.
2022-09-04 18:28:27 +02:00
Philip Rebohle 1b66b8c9f3 [dxvk] Go back to fence-based command list synchronization
Timeline semaphores are too unreliable on 32-bit Proton builds.
2022-09-04 18:23:11 +02:00
Philip Rebohle 439043ddb4 [d3d11] Do not implicitly stall waitable swap chains 2022-09-02 14:33:11 +02:00
Philip Rebohle 17320776f0 [dxgi] Duplicate frame latency handle
Apps can call CloseHandle on this.
2022-09-02 14:25:12 +02:00
Philip Rebohle 11ef172c79 [util] Add stubs for DuplicateHandle and GetCurrentProcess 2022-09-02 14:25:12 +02:00
Philip Rebohle 2659cfc674 [native] Add defines for DuplicateHandle flags 2022-09-02 14:25:12 +02:00
Philip Rebohle fa743f162b [dxvk] Don't create queues with QUEUE_FAMILY_IGNORED
We accidentally broke drivers which don't support sparse.

Closes #2891.
Closes #2890.

Reported-by: mykhailo.skorokhodov@globallogic.com
2022-09-02 11:07:09 +02:00
Joshua Ashton 36f523bbf5 [vulkan] Fix loading libvulkan natively 2022-09-01 04:37:43 +02:00
Joshua Ashton b05ae33273 [util] Return null if HMODULE is nullptr in GetProcAddress compat
dlsym with NULL will try to find the symbol from anything currently
loaded.
2022-09-01 04:37:43 +02:00
Jens Peters 4fc5ba66ed [util] Add missing feature level in example config 2022-09-01 04:36:02 +02:00
Philip Rebohle 735349bf1b [dxvk] Fix barrier typo 2022-09-01 03:35:58 +02:00
Philip Rebohle 097d3edd05 [dxvk] Create debug messenger if DXVK_DEBUG=validation is set 2022-09-01 00:25:10 +02:00
Philip Rebohle 2f39ae792a [dxvk] Change DXVK_PERF_EVENTS environment variable to DXVK_DEBUG 2022-09-01 00:25:10 +02:00
Philip Rebohle f8781e1c4c [vulkan] Add missing VK_EXT_debug_utils entry points 2022-09-01 00:25:10 +02:00
Philip Rebohle 321338af00 [dxvk] Remove unused m_device member from DxvkBuffer 2022-09-01 00:07:23 +02:00
Philip Rebohle 7b4925dc45 [dxvk] Fix potential sparse allocator lifetime issues 2022-08-31 23:48:46 +02:00
Philip Rebohle c3c6dbf669 [dxvk] Fix potential buffer lifetime issues 2022-08-31 23:48:34 +02:00
Philip Rebohle a11fb568b9 [tests] Remove D3D9 tests 2022-08-31 17:01:22 +02:00
Philip Rebohle 632e26f687 [tests] Remove D3D11 and DXGI tests 2022-08-31 16:43:55 +02:00
Philip Rebohle 2b6a903ad9 [tests] Remove DXBC tests 2022-08-31 16:26:37 +02:00
Philip Rebohle e882a7f8ba [d3d11] Implement extended shader interface 2022-08-31 16:25:44 +02:00
Philip Rebohle 610472e658 [d3d11] Introduce ID3D11VkExtShader 2022-08-31 16:25:44 +02:00
Philip Rebohle 354b88d178 [dxvk] Add shader method to retrieve raw code 2022-08-31 16:25:44 +02:00
WinterSnowfall 3e0031cefe [util] Add a maxAvailableMemory limit for Heroes of Annihilated Empires 2022-08-30 13:21:29 +02:00
Philip Rebohle 5e33374fd2 [meta] Remove shaderStorageImage*WithoutFormat capabilities from profile
We no longer use these.
2022-08-30 13:20:50 +02:00
Philip Rebohle 399ba71387 [meta] Add profile for D3D11 FL12_0 2022-08-30 13:18:15 +02:00
Philip Rebohle 788d80cfe7 [meta] Fix some trailing comma warnings in Vulkan profile 2022-08-30 13:17:52 +02:00
Christophe 575367461c Add VKDK profiles file to express Vulkan requirements 2022-08-30 12:54:45 +02:00
Georg Lehmann b96947107a [build] Remove dead lib_d3dcompiler_43.
Fixes MSVC build.
2022-08-30 10:16:18 +01:00
Philip Rebohle c72c6ec6ed [d3d10] Remove d3d10.dll and d3d10_1.dll
These are incomplete and are already not being used anyway,
so just drop them.
2022-08-30 02:42:03 +02:00
Philip Rebohle 8395033f4a [meta] Remove d3d10 options from setup script 2022-08-30 02:42:03 +02:00
Joshua Ashton c49b1ee390 [d3d9] Use SetStateTexture in Reset
Fixes m_activeTextures not getting updated
2022-08-29 10:16:21 +00:00
Blisto91 7ebd359941 [util] correct maxFeatureLevel to 12_0 in example config 2022-08-27 22:02:35 +02:00
Krzysztof Bogacki 2fa628fce6 [build] Remove vulkan-1.lib 2022-08-27 20:18:06 +01:00
Joshua Ashton 86efa46fcf [dxvk] Throw DxvkError if we failed to load vulkan library 2022-08-27 19:32:03 +02:00
Joshua Ashton 286ab017da [vulkan] Add valid method to LibraryLoader 2022-08-27 19:32:03 +02:00
Joshua Ashton 482a7e433b [vulkan] Make LibraryLoader dynamically load vulkan-1
This makes LibraryLoader actually load the library and moves ownership
of GetInstanceProcAddr into it, which means we pass through the
loaders into their parents to grab stuff.
2022-08-27 19:32:03 +02:00
Joshua Ashton f6fcbb7127 [util] Rename CloseLibrary to FreeLibrary in win32 compat headers
Typo...
2022-08-27 19:32:03 +02:00
Robin Kertels bfd47ec876 [d3d9] Try to match either top or bottom mips in UpdateTexture 2022-08-26 20:56:42 +01:00
Joshua Ashton a29896642c [native] Bump DirectX headers
For _mingw_unicode for D3DCompiler
2022-08-26 19:52:26 +02:00
Joshua Ashton 2f3b3e64b4 [native] Add extra definitions needed for D3DCompiler 2022-08-26 19:52:26 +02:00
Philip Rebohle 91bdc8d06c [d3d11] Expose feature level 12_0 2022-08-26 05:53:03 +02:00
Philip Rebohle 91ff6d68e1 [d3d11] Expose support for tiled resources 2022-08-26 05:53:03 +02:00
Philip Rebohle 790da79512 [d3d11] Implement min/max filters 2022-08-26 05:53:03 +02:00
Philip Rebohle 0a222aaaf0 [d3d11] Implement CopyTiles and UpdateTiles 2022-08-26 05:53:03 +02:00
Philip Rebohle ca41bb4ea4 [d3d11] Implement CopyTileMappings 2022-08-26 05:53:03 +02:00
Philip Rebohle ff2ff37696 [d3d11] Implement UpdateTileMappings 2022-08-26 05:53:03 +02:00
Philip Rebohle 5130638ebe [d3d11] Implement ResizeTilePool 2022-08-26 05:53:03 +02:00
Philip Rebohle e8f59bfd7c [d3d11] Implement tile pool creation 2022-08-26 05:53:03 +02:00
Philip Rebohle 0cd67cb98a [d3d11] Implement tiled image creation 2022-08-26 05:53:03 +02:00
Philip Rebohle 0637fdf82e [d3d11] Implement tiled buffer creation 2022-08-26 05:53:03 +02:00
Philip Rebohle 7f856b545a [d3d11] Implement format feature check for tiled resources 2022-08-26 05:53:03 +02:00
Philip Rebohle ca0dedd213 [d3d11] Implement multisampling support check for tiled resources 2022-08-26 05:53:03 +02:00
Philip Rebohle 3f7093325b [d3d11] Implement GetResourceTiling 2022-08-26 05:53:03 +02:00
Philip Rebohle f97660e210 [d3d11] Implement TiledResourceBarrier 2022-08-26 05:53:03 +02:00
Philip Rebohle 626ccef43b [d3d11] Enable sparse features if supported by the device 2022-08-26 05:53:03 +02:00
Philip Rebohle eaa5d16616 [dxbc] Use texel buffers for raw/structured buffers with sparse feedback 2022-08-26 05:53:03 +02:00
Philip Rebohle 336aafcdf7 [dxbc] Explicitly store whether a resource is a raw SSBO 2022-08-26 05:53:03 +02:00
Philip Rebohle d6613f50c5 [dxbc] Implement ld for buffers with sparse feedback 2022-08-26 05:53:03 +02:00
Philip Rebohle e58f9a5e99 [dxbc] Implement ld for images with sparse feedback 2022-08-26 05:53:03 +02:00
Philip Rebohle db3b2e23fb [dxbc] Implement ld_uav_typed with sparse feedback 2022-08-26 05:53:03 +02:00
Philip Rebohle 0faba649da [dxbc] Implement sample operations with sparse feedback 2022-08-26 05:53:03 +02:00
Philip Rebohle d5b68b3642 [dxbc] Implement gather operations with sparse feedback 2022-08-26 05:53:03 +02:00
Philip Rebohle 614024873d [dxbc] Implement CheckAccessFullyMapped instruction 2022-08-26 05:53:03 +02:00
Philip Rebohle eb8a238d6f [dxbc] Add definitions for sparse feedback instructions 2022-08-26 05:53:03 +02:00
Philip Rebohle 70158fa9cf [spirv] Add support for sparse image opcodes 2022-08-26 05:53:03 +02:00
Philip Rebohle 2329c71b6f [dxvk] Implement sampler reduction mode 2022-08-26 05:53:03 +02:00
Philip Rebohle 43b19f773c [dxvk] Introduce initSparseImage 2022-08-26 05:53:03 +02:00
Philip Rebohle fc0d952edb [dxvk] Introduce copySparsePages{To,From}Buffer 2022-08-26 05:53:03 +02:00
Philip Rebohle d5348a0cf0 [dxvk] Introduce updatePageTable 2022-08-26 05:53:03 +02:00
Philip Rebohle 12d2f8a9d4 [dxvk] Expose sparse binding operations as part of the command list 2022-08-26 05:53:03 +02:00
Philip Rebohle 2615af7664 [dxvk] Submit sparse binding operations alongside command buffers 2022-08-26 05:53:03 +02:00
Philip Rebohle d3b6502a17 [dxvk] Introduce DxvkSparseBindSubmission 2022-08-26 05:53:03 +02:00
Philip Rebohle 3057f6a51b [dxvk] Add structures for sparse binding operations 2022-08-26 05:53:03 +02:00
Philip Rebohle f9db4921e0 [dxvk] Implement sparse memory allocator 2022-08-26 05:53:03 +02:00
Philip Rebohle 6f216f9df4 [dxvk] Do not discard sparse buffers
This would only blow up.
2022-08-26 05:53:03 +02:00
Philip Rebohle dd54de4d97 [dxvk] Introduce DxvkPagedResource 2022-08-26 05:53:03 +02:00
Philip Rebohle 2d124b811b [dxvk] Implement sparse image creation 2022-08-26 05:53:03 +02:00
Philip Rebohle f7c255de2a [dxvk] Implement sparse buffer creation 2022-08-26 05:53:03 +02:00
Philip Rebohle bc3affc264 [dxvk] Add functionality to query sparse metadata 2022-08-26 05:53:03 +02:00
Philip Rebohle e923cc5b69 [dxvk] Change emitGraphicsBarrier to specify a dependency 2022-08-26 05:53:03 +02:00
Philip Rebohle 388288114a [dxvk] Find a sparse binding queue 2022-08-26 05:53:03 +02:00
Philip Rebohle 71c9c4a5cc [dxvk] Log sparse features 2022-08-26 05:53:03 +02:00
Philip Rebohle 6e6d64b83e [dxvk] Remove redundant error message 2022-08-26 05:53:03 +02:00
Philip Rebohle 3ee808afd6 [dxvk] Make memory object of an image publicly accessible 2022-08-26 05:53:03 +02:00
Philip Rebohle edc74f4c8b [d3d11] Handle D3D11_FEATURE_D3D11_OPTIONS5 2022-08-26 05:15:28 +02:00
Philip Rebohle 9b4e53cee2 [d3d11] Handle D3D11_FEATURE_SHADER_CACHE 2022-08-26 05:15:28 +02:00
Philip Rebohle 9420391dce [d3d11] Adjust reported resource sharing caps 2022-08-26 05:15:28 +02:00
Philip Rebohle f521a342d0 [d3d11] Report marker support appropriately 2022-08-26 05:15:28 +02:00
Blisto91 8f24093864 [util] cap MGS V Ground Zeroes vram at 4095 2022-08-26 03:52:02 +02:00
Philip Rebohle a2a21cb4d3 [dxvk] Clean up internal memory allocation API 2022-08-25 18:23:02 +02:00
Philip Rebohle 5117210c93 [dxvk] Fix fb resolve barriers
No idea how that ended up broken *this* badly.
2022-08-25 02:25:23 +02:00
Philip Rebohle 559fa50f54 [d3d11] Introduce d3d11.enableContextLock option 2022-08-24 12:27:02 +02:00
Philip Rebohle 86bdda70b4 [d3d11] Move D3D10Multithread instance to immediate context
Deferred contexts do not support this.
2022-08-24 12:15:35 +02:00
Georg Lehmann 87b1f9fa2d [dxso] Fix write mask for nrm 2022-08-23 00:38:04 +02:00
Blisto91 372a27fad2 [util] remove allowDoNotWait from example config 2022-08-22 22:09:44 +02:00
Philip Rebohle 17959640c3 [dxvk] Work around vkWaitSemaphore incorrectly returning with VK_TIMEOUT 2022-08-22 20:30:16 +02:00
Philip Rebohle 07a1045ffb [dxvk] Add context methods for submission splitting 2022-08-22 15:44:00 +02:00
Philip Rebohle 6f2ff2562d [dxvk] Support splitting command lists into multipe submissions 2022-08-22 15:43:23 +02:00
Philip Rebohle e378be826e [dxvk] Use DxvkCommandPool 2022-08-22 14:40:41 +02:00
Philip Rebohle c3a721f562 [dxvk] Introduce DxvkCommandPool 2022-08-22 14:14:25 +02:00
Philip Rebohle def93fd18b [dxvk] Introduce DxvkCommandSubmissionInfo 2022-08-22 14:14:25 +02:00
Philip Rebohle d367fac64e [dxvk] Rework queue submission helper
We want this to be less verbose and smarter about when to perform
submissions for when we introduce the ability to split a command
list into multiple submissions.
2022-08-22 14:14:25 +02:00
Philip Rebohle f88239719c [dxvk] Explicitly mark execution command buffer as used
We can omit the execution command buffer in some circumstances,
and for the sparse resource changes we need to track this in
order to be able to merge consecutive sparse binding calls.

We only need to do this on action commands with observable side effects
as long as the backend still properly resets those command buffers.
All draw commands are implcitly covered by cmdBeginRendering.
2022-08-22 12:36:59 +02:00
Philip Rebohle dd0d611d4d [dxvk] Reintroduce binary semaphore for transfer <-> graphics sync
The global timeline semaphore does not work here since we could be
signaling it from two different queues at the same time, or out of
order.
2022-08-22 05:52:28 +02:00
Philip Rebohle 3d6b687e41 [dxbc] Remove useless lambda 2022-08-22 05:21:49 +02:00
Robin Kertels a8b578b2a2 [d3d9] Fix crash when auto generating mip maps for unmappable textures 2022-08-22 01:48:35 +01:00
Philip Rebohle 3c38bdbd0e [dxvk] Initialize DxvkSubmitInfo properly
We don't use the semaphore value here, but it shouldn't
contain undefined data.
2022-08-22 02:00:10 +02:00
Philip Rebohle f385b4bb47 [dxvk] Use global timeline semaphore for command list synchronization
Replaces the old fence mechanism and also makes it easier to
synchronize across queues.
2022-08-22 00:40:07 +02:00
Philip Rebohle cff9056915 [dxvk] Always enable timeline semaphore feature 2022-08-22 00:40:07 +02:00
Philip Rebohle 11ef1084d0 [dxvk] Rename semaphore stuff in command list code 2022-08-22 00:08:42 +02:00
Philip Rebohle 23c3960f65 [dxvk] Store WSI semaphore pair directly with the command list 2022-08-22 00:07:15 +02:00
Philip Rebohle 85aa0a0ecb [dxvk] Fix meson issue for native builds 2022-08-21 23:22:43 +02:00
Philip Rebohle 9feed43abf [meta] Add README entry about submodules 2022-08-21 22:54:21 +02:00
Philip Rebohle c1448d31fa [meta] Use SPIRV-Headers repository as a submodule 2022-08-21 22:54:21 +02:00
Philip Rebohle aa554f1166 [meta] Use Vulkan-Headers repository as a submodule 2022-08-21 22:54:21 +02:00
Joshua Ashton c258eb05d2 [build] Enable building natively for non-Windows
Yipee 🥳🎉

RIP DXVK Native
2022-08-21 22:37:13 +02:00
Joshua Ashton 9dad1aadbe [build] Set SDL2 WSI env vars and defines on native builds 2022-08-21 22:37:13 +02:00
Joshua Ashton 801d97806d [d3d11] Stub out OpenSharedResourceGeneric on non-Windows 2022-08-21 22:37:13 +02:00
Joshua Ashton be33ccbce9 [dxgi] Revert 538b132490
This breaks things for 32-bit, but it really shouldn't. My hypothesis currently is that the .lib generated is bogus, but the exports in the actual DLL are correct.
2022-08-21 20:28:40 +00:00
Joshua Ashton a4261ddd14 [dxgi] Use high_resolution_clock get_counter instead of QPC for SyncQPCTime
Abstracts this across platforms
2022-08-21 22:24:06 +02:00
Joshua Ashton 9610e29a65 [util] Implement get_frequency + get_counter on non-Windows platforms 2022-08-21 22:24:06 +02:00
Joshua Ashton 8921f62539 [util] Rename getFrequency, getCounter -> get_frequency, get_counter
To be consistent with STL naming conventions
2022-08-21 22:24:06 +02:00
Joshua Ashton 1c1dba4624
[util] Implement thread set_priority on non-Windows platforms 2022-08-21 22:17:33 +02:00
Joshua Ashton 97350d6c35 [dxvk] Support for SDL2 WSI 2022-08-21 22:07:18 +02:00
Joshua Ashton 5787d9ee04 [dxvk] Check platform before building openvr + openxr cpps 2022-08-21 22:07:18 +02:00
Joshua Ashton e6fb3e1509 [wsi] Add SDL2 implementation 2022-08-21 22:07:18 +02:00
Joshua Ashton 191d54e210 [build] Don't build D3D10 on non-Windows platforms
Not supported due to d3dcompiler schenanigans
2022-08-21 22:03:45 +02:00
Joshua Ashton baba2e3c09 [d3d11] Use dxgi_dep instead of lib_dxgi
Fixes building on native.
2022-08-21 22:03:45 +02:00
Joshua Ashton baa88d8cf1 [d3d11] Don't check for apitrace on non-Windows platforms 2022-08-21 22:03:45 +02:00
Joshua Ashton a5db9d22f1 [dxvk] Disable VrInstance and DxvkXrProvider on native builds
If/when we want to support VR on native builds, we can deal with that then.
2022-08-21 22:03:45 +02:00
Joshua Ashton 8b7e0bc2fd [dxgi] Include win32 compat headers where applicable 2022-08-21 21:40:55 +02:00
Joshua Ashton 968bdccbef [d3d9] Include win32 compat headers where applicable 2022-08-21 21:40:55 +02:00
Joshua Ashton a554a6d60d [d3d11] Include win32 compat headers where applicable 2022-08-21 21:40:55 +02:00
Joshua Ashton ba8868be24 [util] Add win32 compat header
Header of misc. stubs and re-implementations.
2022-08-21 21:40:55 +02:00
Joshua Ashton ad386305ff [d3d9] Correct DLLEXPORT for native builds 2022-08-21 21:36:50 +02:00
Joshua Ashton f0f4258be3 [dxgi] Correct DLLEXPORT for native builds 2022-08-21 21:36:50 +02:00
Joshua Ashton 538b132490 [dxgi] Don't declspec dllexport on MinGW builds
Fixes ordinal exporting on MinGW on 32-bit builds.
Mirrors this D3D9 commit here: 904d3e6c90
2022-08-21 21:36:50 +02:00
Joshua Ashton 4a113c39d3 [d3d11] Remove compat definitions for older MinGW
These conflict with native builds, and have existed for a long time now.
2022-08-21 21:35:24 +02:00
Joshua Ashton fad6f764ea [dxgi] Remove unused DEVMODE variable 2022-08-21 21:35:09 +02:00
Joshua Ashton e51c196ee9 [dxgi] Remove MonitorEnumProc and MonitorEnumInfo
Not used anymore, replaced by WSI abstraction.
2022-08-21 21:35:09 +02:00
Joshua Ashton 915ec4acc2 [dxvk] Remove WIN32 check for handle type in DxvkSharedHandleInfo
The initial implementation if-deffed this, but it doesn't need to be.
2022-08-21 21:34:39 +02:00
Joshua Ashton 38cd2f7290 [dxvk] Remove WIN32 check for handle type in DxvkFenceCreateInfo
On other platforms we always have a HANDLE and will return through a HANDLE anyway.

When we implement this on Linux, we can just add an `int fd` to the union and it can use that, and return it out as a HANDLE.
2022-08-21 21:34:39 +02:00
Joshua Ashton 0e4e9355cb [d3d9] Ifdef out code for enumerating adapters by attached displays 2022-08-21 19:29:05 +00:00
Joshua Ashton bf99127ee3 [d3d9] Stub out cursor code on non-Windows platforms 2022-08-21 19:29:05 +00:00
Joshua Ashton c6c8acb000 [d3d9] Use wsi's isWindow in LeaveFullscreenMode 2022-08-21 19:29:05 +00:00
Joshua Ashton 5f9df1f6e3 [d3d9] Remove leftover GetWindowRect
This is already done for us.
2022-08-21 19:29:05 +00:00
Joshua Ashton 1c679edbfb [d3d9] Use topath helpers in shader code 2022-08-21 21:28:04 +02:00
Joshua Ashton 0a203095d6 [d3d11] Use topath helper in shader code 2022-08-21 21:28:04 +02:00
Joshua Ashton 9d64982b23 [dxvk] Use path_string for getCacheFileName 2022-08-21 21:28:04 +02:00
Joshua Ashton 9509ec1144 [util] Define platform path_string type 2022-08-21 21:28:04 +02:00
Joshua Ashton eda3ba6372 [vulkan] Toss obsolete fullscreen exclusive hack
Wine never had support for VK_EXT_exclusive_fullscreen and Proton since dropped support for it now that Doom External does not require it.
2022-08-21 21:26:28 +02:00
Joshua Ashton 5c2a748d96 [util] Rename always_inline to force_inline
This conflicts with other libraries using the always_inline attribute in GCC as it defines it with the same name.
2022-08-21 21:25:54 +02:00
Joshua Ashton 0dc3200951 [vulkan] Re-enable VK_USE_PLATFORM_WIN32_KHR everywhere
My initial idea was to if-def out the other extensions, but that's messy, so we just provide the needed types in the native headers now.
2022-08-21 19:31:33 +01:00
Joshua Ashton 91a5123ad0 [native] Add SDL2 native headers
Not included by DXVK at all, but used by external applications.
2022-08-21 19:31:33 +01:00
Joshua Ashton e969f49cee [native] Add DirectX headers submodule
Adds DirectX headers for use when building DXVK
natively for Linux.

These use the substitute Windows headers I made.

These are a minimal set of DirectX specific headers that are compatible with the substitute Windows headers I made.

For any license concerns please see the README in the submodule.
2022-08-21 19:31:33 +01:00
Joshua Ashton 92698be09a [native] Add substitute Windows headers
Adds substutite Windows headers for use when building DXVK
natively for Linux.

The main one being windows_base.h which has all of the definitions.

It supports stuff like __uuidof using some template nonsense too.
2022-08-21 19:31:33 +01:00
Philip Rebohle 1c35fbb33c [util] Fix strlcpy compiler warning 2022-08-21 01:48:29 +01:00
Kassin Dornelles f80347d9a9 [util] Remove RE:REV2 and RE5 workarounds
There's no real impact, it doesn't fix stuttering (for non-GPL drivers) and since GPL got merged this is not needed anymore
2022-08-21 01:52:39 +02:00
Joshua Ashton 16ff9b48cd [dxgi] Enumerate interlaced modes if requested 2022-08-20 20:27:07 +02:00
Joshua Ashton af802fbff8 [util] Delete util_monitor
No longer used, replaced by new wsi interface
2022-08-20 20:27:07 +02:00
Joshua Ashton f3992658a4 [d3d9] Remove unused util_monitor include 2022-08-20 20:27:07 +02:00
Joshua Ashton 69eba93764 [d3d9] Make window proc code use new wsi interface 2022-08-20 20:27:07 +02:00
Joshua Ashton 9690b2a9e4 [d3d9] Make adapter code use new wsi abstraction 2022-08-20 20:27:07 +02:00
Joshua Ashton dac7e38f4b [d3d9] Make swapchain use new wsi abstraction 2022-08-20 20:27:07 +02:00
Joshua Ashton 654b517057 [d3d9] Add helpers for new WSI interface 2022-08-20 20:27:07 +02:00
Joshua Ashton bc8e75fdfa [dxgi] Make adapter code use new wsi interface 2022-08-20 20:27:07 +02:00
Joshua Ashton 59b943cf12 [dxgi] Remove unused util_monitor include 2022-08-20 20:27:07 +02:00
Joshua Ashton 21744198e0 [dxgi] Make swapchain use new wsi interface 2022-08-20 20:27:07 +02:00
Joshua Ashton e13a9f9cf6 [dxgi] Make output code use new wsi interface 2022-08-20 20:27:07 +02:00
Joshua Ashton 71a630801e [dxgi] Add helpers for new wsi interface 2022-08-20 20:27:07 +02:00
Joshua Ashton 9f9c93dcbd [d3d11] Use new wsi interface 2022-08-20 20:27:07 +02:00
Joshua Ashton 4f80ffd830 [vulkan] Use surface creation from wsi interface 2022-08-20 20:27:07 +02:00
Joshua Ashton 86b603b8f9 [dxvk] Link against new wsi lib 2022-08-20 20:27:07 +02:00
Joshua Ashton 4b0f13d351 [build] Set dxvk_wsi and defines for Windows 2022-08-20 20:27:07 +02:00
Joshua Ashton b875d49c85 [wsi] Move DxvkWindowState to wsi platform header 2022-08-20 20:27:07 +02:00
Joshua Ashton efa6523e3e [wsi] Implement wsi interface for Windows 2022-08-20 20:27:07 +02:00
Joshua Ashton 050e5b327c [wsi] Define wsi interface 2022-08-20 20:27:07 +02:00
Philip Rebohle 76ee76d6da [d3d9,dxso] Use DemoteToHelperInvocation for alpha test
May enable additional compiler optimizations.
2022-08-19 14:49:18 +00:00
Philip Rebohle 2d92679cd1 [dxso] Remove fallback path for discards 2022-08-19 13:36:54 +00:00
Philip Rebohle 165648017e [dxbc] Remove fallback path for discards 2022-08-19 13:36:54 +00:00
Philip Rebohle ea4e0bc470 [d3d9,d3d11] Require shaderDemoteToHelperInvocation feature 2022-08-19 13:36:54 +00:00
Georg Lehmann 155944c2b4 [dxso] normalize 0 to 0 with strict float emulation 2022-08-19 13:36:14 +00:00
Philip Rebohle 85cc87e42a
[d3d9] Fix invalid shader in fixed-function alpha test 2022-08-18 17:08:59 +02:00
Philip Rebohle 658d824ddd
[d3d11] Silence log spam for invalid image operations 2022-08-18 14:48:29 +02:00
Philip Rebohle 4869b0defa
[dxvk] Fix race condition requestCompileShader 2022-08-18 02:57:45 +02:00
Philip Rebohle a695644fea [d3d9] Remove alphaTestWiggleRoom option 2022-08-18 00:10:39 +02:00
Philip Rebohle 5a3cb5ad3e [d3d9] Adjust alpha test precision based on render target format
More or less matches what Nvidia's D3D9 driver does on Turing.
2022-08-18 00:10:39 +02:00
Philip Rebohle 47fa3824dc [d3d9] Re-implement alpha test to support configurable accuracy
The current implementation always uses 12 bits of accuracy.
2022-08-18 00:10:39 +02:00
Philip Rebohle 2c713a34c9 [d3d9,dxso] Factor out common alpha test code 2022-08-18 00:10:39 +02:00
Philip Rebohle 3806bd44d8
[dxvk] Change descriptor info to take only one shader stage
And fix the binding index -> descriptor mapping.
This affects D3D9 since the spec constant change.
2022-08-17 22:40:58 +02:00
Philip Rebohle 3c2fc41e4c [d3d9] Re-bind framebuffer if RT hazards change
Otherwise we never set the feedback loop bits in the backend.
2022-08-17 18:36:30 +00:00
Philip Rebohle 7ddfcfeb20
[tests] Also log D3D11_FEATURE_FORMAT_SUPPORT2 in format tester 2022-08-17 15:56:02 +02:00
Philip Rebohle 52314ba4fd
[dxvk] Do not log storage image features that we no longer enable 2022-08-17 15:39:03 +02:00
Philip Rebohle 5e394b5554
[dxvk] Remove old format support queries 2022-08-17 15:39:03 +02:00
Philip Rebohle 80fc1d8b25
[d3d9] Use new format support queries 2022-08-17 15:39:03 +02:00
Philip Rebohle 13152088d4
[dxgi] Use new format support queries to initialize format table 2022-08-17 15:39:03 +02:00
Philip Rebohle 4aeb397ba3
[d3d11] Use new format support queries to check D3D11 format support 2022-08-17 15:39:03 +02:00
Philip Rebohle 099c70c2bd
[d3d11] Use new format support queries in resource creation 2022-08-17 15:26:03 +02:00
Philip Rebohle 3717922381
[d3d11,dxbc] Rework check for TypedUAVLoadAdditionalFormats 2022-08-17 15:26:03 +02:00
Philip Rebohle 653a98f01b
[dxvk] Use new format support queries 2022-08-17 15:26:03 +02:00
Philip Rebohle cc8010fb7c
[dxvk] Add format feature queries to DxvkDevice 2022-08-17 15:20:13 +02:00
Philip Rebohle 61025c0079
[dxvk] Don't disable frame rate limiter if vsync is enabled
This only works if we know the actual refresh rate of the display.
However, in a wine virtual desktop or with proton's fshack, this
is often not the case, so we'd see a 60 Hz mode on a high-refresh
rate display and never actually enable the limiter.
2022-08-17 01:53:24 +02:00
Riesi 04bc1bac73 [util] Limit Beyond Good and Evil FPS to 60
UI breaks on higher FPS
2022-08-16 19:11:41 +02:00
Philip Rebohle e0af668f6c
[dxvk] Use DxvkBindingLayoutObjects for set lookup directly
Avoids pointer dereferencing on a really hot code path. This is also
safe since there's a 1:1 mapping between the VkPipelineLayout and the
given ovbject type.
2022-08-16 15:35:57 +02:00
Philip Rebohle 9f9324c421
[dxvk] Use existing bit mask iterator for descriptor set allocation 2022-08-16 15:24:39 +02:00
Joshua Ashton 084969135b [d3d9] Only set feedback loop usage on textures, not plain surfaces 2022-08-16 12:33:17 +00:00
Joshua Ashton cf9e217e7b [util] Support for fps limiter on non-Windows platforms
Defaults to a sleep granularity of 0.5ms, which is slightly on the cautious side.

Calls through to std::this_thread::sleep_for directly, which calls through to nanosleep.
2022-08-16 14:32:07 +02:00
Joshua Ashton d1e2b89282 [util] Use chrono literal for ms in fps limiter 2022-08-16 14:32:07 +02:00
Joshua Ashton 5fcc9a1bd1 [util] Move platform specific sleep to own function in fps limiter 2022-08-16 14:32:07 +02:00
Joshua Ashton 05a5b82f59 [util] Move sleep granularity getting to own function 2022-08-16 14:32:07 +02:00
Joshua Ashton b885883e06 [util] Rename NtTimerDuration to TimerDuration 2022-08-16 14:32:07 +02:00
Joshua Ashton a78aab147e [d3d9] Add feedback loop usage for DS 2022-08-16 10:39:06 +00:00
Joshua Ashton 870dd18f92 [d3d9] Set VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT for render targets
Closes: #2825
2022-08-16 08:43:52 +00:00
Joshua Ashton 6baaa3a5f2 [d3d9] New window proc code on multiple platforms 2022-08-14 17:22:58 +00:00
Joshua Ashton 7506f65801 [d3d9] Move window proc handling code to own file 2022-08-14 17:18:10 +00:00
Robin Kertels de8d2b37bb [d3d9] FF: Don't change flatShadingMask for outputs 2022-08-13 14:38:57 +01:00
Robin Kertels 46cb05ce45 [d3d9+util] Always ignore D3DLOCK_DONOTWAIT
We only ever stall when locking a texture that was
previously used with GetRenderTargetData or
GetFrontBufferData. Games are known to break
if locking those textures doesn't succeed.
2022-08-12 14:18:13 +01:00
Philip Rebohle 67614917c3
[meta] Update README on shader compiler threads 2022-08-11 20:20:59 +02:00
Philip Rebohle 0d33d063ca
[dxvk] Remove device LUID workaround
winevulkan properly supports this now.
2022-08-11 16:01:53 +02:00
Philip Rebohle 673797c36a
[dxvk] Fix hang on exit with high priority queue
No idea why I'm not seeing hangs on my end, but this is definitely a bug.
2022-08-11 14:00:57 +02:00
Philip Rebohle 715b5119e6
[dxvk] Fix check in DxvkShaderPipelineLibrary::compilePipeline
Since we destroy pipelines on 32-bit we should just make sure this
doesn't get executed unnecessarily.
2022-08-11 13:43:38 +02:00
Philip Rebohle a4848201f8
[dxvk] Update buffer views in commitGraphicsBarriers
Otherwise we might end up accessing stale buffer slices, since this
happens before descriptor updates. This is not needed for compute.

Also fix weird indentation while we're at it.
2022-08-11 13:13:02 +02:00
Philip Rebohle 9bd0040a90
[d3d9] Request high-priority shader compiles as necessary 2022-08-11 12:39:28 +02:00
Philip Rebohle d3ab905621
[d3d11] Request high-priority shader compiles as necessary
This can reduce stutter in case shaders are needed immediately while
background threads are still busy compiling a different set of shaders.
2022-08-11 12:39:28 +02:00
Philip Rebohle c3a53127d7
[dxvk] Add high-priority queue for shader compiles
As well as an API to queue shaders as high priority.
2022-08-11 12:39:28 +02:00
Philip Rebohle f09f11aad0
[dxvk] Track pipeline library compile for each shader 2022-08-11 12:39:25 +02:00
Robin Kertels b5b74116fa [d3d9] Fix rare hang when waiting for staging buffer markers 2022-08-11 12:37:28 +02:00
Robin Kertels 5cdee45387 [util] Disable direct buffer mapping for GHWT
The game ends up discarding a 11MB buffer which causes it
to run out of address space and crash. Disabling direct buffer
mapping makes it use staging buffers and the staging buffer
limit saves the day.
2022-08-11 04:36:01 +01:00
Philip Rebohle 85c278f515
[dxvk] Don't try to merge buffer ranges in barrier list
Too slow, doesn't work most of the time anyway.
2022-08-11 00:38:49 +02:00
Philip Rebohle 4c7da80c14
[dxvk] Simplify barrier image and buffer slice implementations
Pre-process the given ranges so that compare and merge
operations become both simpler and faster.
2022-08-11 00:29:31 +02:00
Philip Rebohle 8aae9c85bb
[dxvk] Optimize barrier hash table lookup
Using a prime as the table size is technically better, but that
integer division kind of hurts when we're spamming look-ups.
2022-08-10 23:08:28 +02:00
Philip Rebohle ad020c23f9
[dxvk] Optimize barrier logic
The is*Dirty methods can exit early if the resource to check
is only used for reading. Only call get*Access to check for
write-after-write scenarios.
2022-08-10 20:47:52 +02:00
Philip Rebohle 11fbcd3131
[dxvk] Rework compute barrier handling to use common functions
Cleans up code a bit and should technically even make things a bit
more efficient.
2022-08-10 19:28:35 +02:00
Philip Rebohle 01014c1a2b
[dxvk] Rework checkGfx*Barrier methods 2022-08-10 19:28:35 +02:00
Philip Rebohle 9a6c378f3d
[dxvk] Only use one descriptor set for compute shaders
Simplifies things a bit and avoids redundant sets in the pipeline layout.
2022-08-10 19:28:32 +02:00
Philip Rebohle 02f653fdd2 [d3d9] Limit amount of staging memory in flight 2022-08-10 17:31:55 +02:00
Robin Kertels 9d981ec1a8 [dxvk] Introduce DxvkMarker
Co-authored-by: Philip Rebohle <philip.rebohle@tu-dortmund.de>
2022-08-10 17:31:55 +02:00
Robin Kertels 8feabc653e [d3d9] Do implicit flush after uploading textures or buffers 2022-08-10 17:31:55 +02:00
Robin Kertels f031ce44cf [util] Set lower memory limits for Guitar Hero WT 2022-08-10 17:31:55 +02:00
Philip Rebohle 67f937111d
[dxvk] Remove shrinkNvidiaHVVHeap workaround
No longer needed.
2022-08-10 16:39:58 +02:00
Philip Rebohle 3edb0ef114
[d3d11] Ensure that all required inputs are defined by input layout 2022-08-10 14:12:39 +02:00
Philip Rebohle 5540df955c
[dxbc] Rework semantic name matching 2022-08-10 14:11:47 +02:00
Philip Rebohle ec0c377cf8
[dxvk] Disable maintenance4 feature
We don't *really* need it (although some of the guarantees are nice to
have). For some reason, this completely destroys GPU-bound performance
on AMDVLK and AMD's Windows driver.
2022-08-10 01:04:38 +02:00
Paul Gofman 59441b1ff5 [dxgi] Also support use after free in IDXGISwapChain::SetFullscreenState() 2022-08-09 23:10:50 +02:00
Joshua Ashton 8580bb32ca [vulkan] Only define VK_USE_PLATFORM_WIN32_KHR on Windows 2022-08-09 14:16:50 +01:00
Joshua Ashton 50018de483 [util] Use topath helper for fstreams 2022-08-09 14:16:50 +01:00
Joshua Ashton 5de058e14a [util] Introduce topath helper
Manages converting strings to the right type for paths per-platform
2022-08-09 14:16:50 +01:00
Joshua Ashton d9000485ea [util] Add stubs for shared resources on other platforms 2022-08-09 14:16:50 +01:00
Joshua Ashton 8c3a44cac4 [util] Add stubs for GDI functions on other platforms 2022-08-09 14:16:50 +01:00
Philip Rebohle ab1d629961 [dxvk] Implement lifetime tracking for graphics pipelines 2022-08-09 13:40:58 +02:00
Philip Rebohle 764de6ff82 [dxvk] Add use counter to pipeline libraries
And destroy Vulkan pipeline objects once the counter reaches zero.
2022-08-09 13:40:58 +02:00
Philip Rebohle 1f9db49727 [dxvk] Change member order in pipeline manager
Ensures that pipelines are destroyed before pipeline libraries.
2022-08-09 13:40:58 +02:00
Philip Rebohle b97dba3712 [dxvk] Use shader module identifier for subsequent pipeline libary compiles
Should further reduce the hit we take from destroying pipeline libraries.
2022-08-09 13:40:58 +02:00
Philip Rebohle 4bc2d713fb [dxvk] Destroy shader pipeline libraries after initial compile on 32-bit
This alone saves ~700 MiB of address space in the Resident Evil 6 main
menu on Nvidia.
2022-08-09 13:40:58 +02:00
Philip Rebohle 915b03ba7b [dxvk] Add option to control pipeline lifetime tracking 2022-08-09 13:40:58 +02:00
Philip Rebohle eddbe73ba4
[dxbc] Fix off-by-one error for primitive vertex counts
Not sure if it's even possible to use this, but this was clearly a bug.
2022-08-09 03:19:59 +02:00
Philip Rebohle d6253aeae6
[dxvk] Order descriptors by type and binding
Reduces the number of unique descriptor set layouts further,
which may help with descriptor pool usage, and also makes
branching more predictable for the CPU.
2022-08-09 03:19:59 +02:00
Robin Kertels 1fcd5dc0af [d3d9] Unmap stored shader bytecode 2022-08-08 23:15:21 +01:00
Robin Kertels 49e9ba2ca7 [d3d9] Move d3d9 bytecode into D3D9Shader
This reduces the amount of times we copy the bytecode
and actually frees it when the game frees the associated shader.
2022-08-08 23:15:21 +01:00
Robin Kertels 1628b9e63a [d3d9] Add 64bit implementation for D3D9MemoryAllocator
This just uses malloc & free but allows us to use
the same code for D3D9 shader bytecode on 64 bit builds.
2022-08-08 23:15:21 +01:00
Robin Kertels 01fb40423d [d3d9] Remove some dead debug code
Oops.
2022-08-08 23:15:21 +01:00
Robin Kertels 36d8bb77a5 [d3d9] Fix synchronization in UpdateTextureFromBuffer 2022-08-08 23:14:30 +01:00
Robin Kertels ac1e44f120 [d3d9] Fix typo 2022-08-08 23:14:30 +01:00
Derek Lesho 57dcf73a54 d3d11: Fix shared textures that export both NT and KMT handles.
We should always create the DxvkImage with the KMT handle type, so that the call later to openKmtHandle succeeds.  Also, don't free sharedHandle when exporting an NT handle.
2022-08-08 23:31:01 +02:00
Philip Rebohle 0ad7a08c49
[dxvk] Get rid of some old debug code for compute pipelines 2022-08-08 18:58:22 +02:00
Philip Rebohle c392308e6f
[dxvk] Fix spec constant selector test for compute shaders
This isn't supported on compute.
2022-08-08 18:54:11 +02:00
Philip Rebohle 7789fd53ff [d3d9] Use new flat shading state for fixed-function pipelines 2022-08-08 13:34:59 +02:00
Philip Rebohle 8f1024c094 [d3d9] Use new flat shading state for DXSO shaders 2022-08-08 13:34:59 +02:00
Philip Rebohle dfdb729476 [dxvk] Add SPIR-V pass to decorate variables as flat on demand 2022-08-08 13:34:59 +02:00
Philip Rebohle a84beae112 [dxvk] Add flat shading field to pipeline state 2022-08-08 13:34:59 +02:00
Philip Rebohle 0adf64f085 [dxvk] Add flat shading parameter to rasterizer state 2022-08-08 13:34:59 +02:00
Joshua Ashton 4f0c217633 [d3d9] Fix recording MultiplyTransform 2022-08-08 03:53:25 +01:00
Philip Rebohle 43df6cfa45
[dxvk] Fix indentation
Thanks, VSCode.
2022-08-08 04:50:50 +02:00
Philip Rebohle 2b2c44aa99
[dxvk] Move image view cookie to DxvkResource 2022-08-07 21:24:57 +02:00
Philip Rebohle 4831909656
[d3d9] Enable apitrace mode for The Witcher 2022-08-07 20:04:37 +02:00
Philip Rebohle a74f8da7b7
[d3d11] Use bindVertexBufferRange whenever possible 2022-08-07 19:03:51 +02:00
Philip Rebohle 97f0d1dfb8
[d3d11] Use bindIndexBufferRange whenever possible 2022-08-07 19:03:51 +02:00
Philip Rebohle 35dde3e1b9
[d3d11] Change how resourece binding treats null resources 2022-08-07 19:03:51 +02:00
Philip Rebohle 897e7816f0
[d3d11] Don't return undefined slices from GetBufferSlice
Instead, return a slice with length zero.
2022-08-07 19:03:51 +02:00
Philip Rebohle 08b9b0eb44
[dxvk] Introduce bindVertexBufferRange and bindIndexBufferRange 2022-08-07 19:03:51 +02:00
Philip Rebohle 26d46e7f80
[dxvk] Handle bound buffers with zero size in the backend 2022-08-07 18:45:17 +02:00
Philip Rebohle d314bee86d
[d3d11] Fix bad signature of various BindToContext methods 2022-08-07 18:44:47 +02:00
Philip Rebohle 45a1587b88
[d3d11] Fix some possible constant buffer binding bugs 2022-08-07 18:44:47 +02:00
Philip Rebohle 2e6a2f1be3
[dxvk] Make shader stage parameter in bindShader a template parameter 2022-08-07 18:44:44 +02:00
Philip Rebohle 29a2cb9a5e
[d3d9,d3d11] Make GetShaderStage functions constexpr 2022-08-07 18:44:44 +02:00
Philip Rebohle 12c2d24d5c
[dxvk] Remove bindResourceView method 2022-08-07 17:59:20 +02:00
Philip Rebohle 69b15b7fe6
[dxvk] Use new resource view binding methods in swapchain blitter 2022-08-07 17:59:20 +02:00
Philip Rebohle eebcfcf973
[hud] Use new resource view binding methods 2022-08-07 17:59:20 +02:00
Philip Rebohle 1c1958be44
[d3d9] Use new resource view binding methods 2022-08-07 17:59:20 +02:00
Philip Rebohle 28ecf8268d
[d3d11] Use new resource view binding methods 2022-08-07 17:59:20 +02:00
Philip Rebohle 317850e16f
[dxvk] Introduce bindResourceImageView and bindResourceBufferView methods 2022-08-07 17:59:20 +02:00
Philip Rebohle 88bdf2b592
[dxvk] Use vertex extent from vertex binding info
Computing this at runtime is fairly expensive, so try to avoid.
2022-08-07 17:58:19 +02:00
Philip Rebohle 6bcb0a0d61
[d3d11] Compute vertex extent in CreateInputLayout 2022-08-07 17:58:19 +02:00
Philip Rebohle 64169316e6
[d3d9] Compute vertex extent in BindInputLayout 2022-08-07 17:58:19 +02:00
Philip Rebohle bb8a87196f
[dxvk] Add vertex extent to vertex binding info 2022-08-07 17:58:19 +02:00
Robin Kertels ddb528cc8e [d3d9] Change texture before updating fetch4 2022-08-07 00:56:38 +01:00
Blisto91 7b28bbae11 [util] Disable unmapping for Saints Row 2 2022-08-06 21:13:32 +01:00
Georg Lehmann 135b8a0e53 [dxso] Setup spec ubo for pixel shaders 2022-08-06 12:35:23 +02:00
Georg Lehmann 6589966fce [d3d9] Fix FF VS fog with GPL 2022-08-06 12:35:23 +02:00
Joshua Ashton 65da0da954 [d3d9] Support for graphics pipeline libraries 2022-08-06 01:20:22 +00:00
Joshua Ashton 9108f8c76c [d3d9] Clean up fetch4 handling 2022-08-06 01:35:43 +01:00
Joshua Ashton 8c9601b4cd [d3d9] Remove generalHazards option
Move everything into MarkRenderHazard.

We are doing a big bump for driver support anyway, no reason to keep this around. Old drivers can take the perf penalty.
2022-08-06 01:33:30 +01:00
Joshua Ashton 63d582a6e7 [d3d9] Use VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_EXT for hazards if available 2022-08-06 01:33:30 +01:00
Joshua Ashton 90abd993d4 [d3d9] Pass feedback loop aspect mask to backend 2022-08-06 01:33:30 +01:00
Joshua Ashton 8d070e54a1 [d3d9] Enable extAttachmentFeedbackLoopLayout feature if available 2022-08-06 01:33:30 +01:00
Joshua Ashton 31d17efb48 [dxvk] Add feedback loop aspect flags to bindRenderTargets 2022-08-06 01:33:30 +01:00
Joshua Ashton dff514c924 [dxvk] Add hazard tracking to fragment output state
We need this to set the right pipeline bits for supporting attachment feedback loops on some vendors.
2022-08-06 01:33:30 +01:00
Joshua Ashton 43f53f3c0e [dxvk] Enable VK_EXT_attachment_feedback_loop_layout if available 2022-08-06 01:33:30 +01:00
Joshua Ashton 49b76fdd07 [dxvk] Support feedback loop layout in pickLayout 2022-08-06 01:33:30 +01:00
Joshua Ashton 9cf5c648d3 [vulkan] Add feedback loop layout to getWritableAspectsForLayout 2022-08-06 01:33:30 +01:00
Joshua Ashton 3c4e85d630 [meta] Update Vulkan headers to 1.3.224 2022-08-06 01:33:30 +01:00
Philip Rebohle e7b7299ec1
[dxvk] Also consider built-ins declared via OpMemberDecorate
Otherwise we'll miss D3D11 shaders. Oops...
2022-08-06 02:28:39 +02:00
Philip Rebohle 4d9c09b5e7
[dxvk] Don't use pipeline libraries for VS that doesn't export position 2022-08-06 02:09:55 +02:00
Philip Rebohle 3aa786fb6f
[dxvk] Get rid of MaxNumActiveBindings
This only existed due to the binding mask, which we removed with
the null descriptor rework. We can basically support an unlimited
number of descriptors now.
2022-08-06 01:53:08 +02:00
Philip Rebohle b950102233
[dxvk] Don't use MaxNumActiveBindings for descriptor updates 2022-08-06 01:44:56 +02:00
Philip Rebohle 6fba4c47fe
[dxvk] Don't use MaxNumActiveBindings when creating descriptor set layouts 2022-08-06 01:37:17 +02:00
Philip Rebohle 2fe61675bf
[dxvk] Use existing bit mask iterator when updating descriptor sets
And clean up the code a little.
2022-08-05 21:43:11 +02:00
Robin Kertels 9e1ecec79f [d3d9] Disable fetch4 when binding an incompatible texture
Fixes lighting in Spider-Man: Shattered Dimensions.
2022-08-05 19:33:32 +01:00
Philip Rebohle d498551a23 [dxso] Add bit selectors to D3D9ShaderSpecConstantManager
Avoids doing double bitfield extractions which isn't
optimized right now.
2022-08-05 19:31:02 +01:00
Joshua Ashton 9619377723 [dxso] Convert opIEqual 1 -> opINotEqual 0
Better chance of getting optimized
2022-08-05 19:31:02 +01:00
Joshua Ashton b2cbf198e4 [d3d9, dxso] Refactor spec constants to use a bitfield layout
This allows us to use the same information to dump into a push constant for unoptimized pipelines.
2022-08-05 19:31:02 +01:00
Joshua Ashton 438ae5cdfc [dxso] Fix getting sampler type of vertex textures
Fixes: c7afe0dd23
2022-08-05 19:31:02 +01:00
Philip Rebohle 7e237b33b7
[d3d11] Track highest bound unordered access view 2022-08-05 14:13:25 +02:00
Philip Rebohle 934caa3fd7
[d3d11] Track highest bound vertex buffer 2022-08-05 14:13:25 +02:00
Philip Rebohle 3dbd9d8659
[d3d11] Track highest bound sampler 2022-08-05 14:13:25 +02:00
Philip Rebohle 6c372e40f6
[d3d11] Track highest bound shader resource 2022-08-05 14:13:24 +02:00
Philip Rebohle 5dd2b20940
[d3d11] Track highest bound constant buffer 2022-08-05 14:13:24 +02:00
Philip Rebohle 18c4ca8e92
[d3d11] Introduce D3D11MaxUsedBindings
And use it in ResetCommandListState, in order to avoid redundant state changes.
2022-08-05 14:13:24 +02:00
Philip Rebohle ebbb77518a
[d3d11] Clean up after performing video blit
Otherwise, with the upcoming clear/restore optimizations,
we'd possibly leave some resources bound.
2022-08-05 14:13:24 +02:00
Philip Rebohle 9f07bc6532
[d3d11] Refactor shader state 2022-08-05 14:13:24 +02:00
Philip Rebohle 95ab1465ab
[d3d11] Add reset method to more context state 2022-08-05 14:13:24 +02:00
Philip Rebohle 4e1f6e5efd
[d3d11] Refactor unordered access view and output merger state 2022-08-05 14:13:24 +02:00
Philip Rebohle 8383423fbe
[d3d11] Refactor sampler state 2022-08-05 14:13:24 +02:00
Philip Rebohle 1b4cb66dc3
[d3d11] Refactor shader resource state 2022-08-05 14:13:24 +02:00
Philip Rebohle 33e169e85f
[d3d11] Refactor constant buffer state 2022-08-05 14:13:24 +02:00
Philip Rebohle 7685a86494
[d3d11] Change state restoring behaviour in SwapDeviceContextState 2022-08-05 14:13:24 +02:00
Philip Rebohle c7d9201303
[d3d11] Change state clearing behaviour around deferred contexts
Resetting command list state at the end of each D3D11 command list,
as well as before ExecuteCommandList, will allow us to track which
state needs to be reset, which may save us a significant amount of
CPU work.
2022-08-05 14:13:24 +02:00
Philip Rebohle 91fc0a8688
[d3d11] Rename and factor out some state clearing methods 2022-08-05 14:13:21 +02:00
Philip Rebohle 211ad0efcc
[dxvk] Always use init barrier set for initial transition in initImage
This allows us to batch image initialization barriers better.
2022-08-05 12:46:41 +02:00
Philip Rebohle 0f94971193
[d3d11,d3d9] Lock context/device in EndFrame
Fixes #2787.
2022-08-05 12:10:03 +02:00
Philip Rebohle 37a2b02558
[d3d11] Fix compiler error on GCC 10.3 2022-08-04 18:42:13 +02:00
Philip Rebohle 67c11e63e6
[dxvk] Remove old resource binding methods 2022-08-04 13:43:36 +02:00
Philip Rebohle 37337dd4a6
[dxvk] Use new binding methods for swapchain blitter 2022-08-04 13:43:36 +02:00
Philip Rebohle 77e7c7c6b8
[hud] Use new binding methods for HUD rendering 2022-08-04 13:43:36 +02:00
Philip Rebohle 9d967f2fed
[d3d11] Use new binding methods in video context 2022-08-04 13:43:36 +02:00
Philip Rebohle e49524fcb0
[d3d11] Move GetType and GetContextFlags to D3D11CommonContext 2022-08-04 13:43:36 +02:00
Philip Rebohle 1d2d712dfb
[d3d11] Move d3d11_context_common.* -> d3d11_context.* 2022-08-04 13:43:36 +02:00
Philip Rebohle 30b1cac0ae
[d3d11] Remove old D3D11DeviceContext class 2022-08-04 13:43:36 +02:00
Philip Rebohle 20df9fc899
[d3d11] Move all remaining context code to D3D11CommonContext 2022-08-04 13:43:36 +02:00
Philip Rebohle a3ed84c0c1
[d3d11] Move remaining D3D11DeviceContext members to D3D11CommonContext 2022-08-04 13:43:36 +02:00
Philip Rebohle b20bfe763e
[d3d11] Move D3D10Multithread instance to D3D11CommonContext 2022-08-04 13:43:36 +02:00
Philip Rebohle 9a2d8878ef
[d3d11] Move Track*SequenceNumber methods to D3D11CommonContext 2022-08-04 13:43:36 +02:00
Philip Rebohle 532b3a6add
[d3d11] Move EmitCs and related methods to D3D11CommonContext 2022-08-04 13:43:36 +02:00
Philip Rebohle e0ea272c0d
[d3d11] Move misc methods to D3D11CommonContext 2022-08-04 13:43:36 +02:00
Philip Rebohle 9e916edef9
[d3d11] Move Draw* and Dispatch* methods to D3D11CommonContext 2022-08-04 13:43:36 +02:00
Philip Rebohle 1d87af062c
[d3d11] Move ResolveSubresource to D3D11CommonContext 2022-08-04 13:43:36 +02:00
Philip Rebohle 17c318864e
[d3d11] Move Apply* methods to D3D11CommonContext 2022-08-04 13:43:36 +02:00
Philip Rebohle 7c82ed35b2
[d3d11] Move internal resource update methods to D3D11CommonContext 2022-08-04 13:43:36 +02:00
Philip Rebohle 956bad5e84
[d3d11] Move GenerateMips to D3D11CommonContext 2022-08-04 13:43:36 +02:00
Philip Rebohle 751d7467df
[d3d11] Move Clear* methods to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle 50942cd2d9
[d3d11] Move Copy* methods to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle 163af1309d
[d3d11] Move SetPredication to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle b8b5662461
[d3d11] Move Discard* methods to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle efea51c254
[d3d11] Move SO* methods to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle 4d498851a8
[d3d11] Move RS* methods to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle 1ef9d5389b
[d3d11] Move ClearState and RestoreState to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle f664e87749
[d3d11] Move CSSetUnorderedAccessViews to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle 159eed825f
[d3d11] Move *SetSamplers methods to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle 3af5b3ba7b
[d3d11] Move *SetShaderResources methods to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle bfaa21dccc
[d3d11] Move *SetConstantBuffers methods to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle 26ac57f688
[d3d11] Move *SetShader methods to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle e0ee06a279
[d3d11] Move IA* functions to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle 77c032da5c
[d3d11] Move OM* functions to D3D11CommonContext
We can get rid of the immediate context overload as well
since we can just directly call FlushImplicit here.
2022-08-04 13:43:35 +02:00
Philip Rebohle 5a45677a39
[d3d11] Add hazard tracking methods to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle 43661abbfc
[d3d11] Add binding methods to D3D11CommonContext
Uses mutable lambdas to avoid redundant ref counting on immediate contexts.
2022-08-04 13:43:35 +02:00
Philip Rebohle a7c25a01f2
[d3d11] Move D3D11DeviceContextExt to D3D11CommonContext
Will be needed for both EmitCs and TrackSequenceNumber functions.
2022-08-04 13:43:35 +02:00
Philip Rebohle 3f5f731c42
[d3d11] Move D3D11UserDefinedAnnotation member to D3D11CommonContext
This needs to be temlpated because we'll be moving EmitCs to the
common implementation as well, and make EmitCsChunk non-virtual.
2022-08-04 13:43:35 +02:00
Philip Rebohle 10345d0063
[d3d11] Move QueryInterface to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle 4af974768a
[d3d11] Refactor D3D11UserDefinedAnnotation 2022-08-04 13:43:35 +02:00
Philip Rebohle 3ead348b82
[d3d11] Move UpdateSubresource code to D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle e4204f76e6
[d3d11] Introduce D3D11CommonContext 2022-08-04 13:43:35 +02:00
Philip Rebohle 0315997fcd
[d3d9] Use mutable lambdas to avoid some redundant ref counting 2022-08-04 13:43:35 +02:00
Philip Rebohle f10be7bc85
[dxvk] Add binding methods that take rvalue references
The goal here is to replace the old methods entirely.
2022-08-04 13:43:32 +02:00
Georg Lehmann 8e37949a71 [util] Use raw tzcnt for BitMask iterator
Dereferencing an end iterator is UB, so we don't have to care about the 0
case.
2022-08-03 22:34:21 +02:00
Philip Rebohle fc7e934854
[util] Always inline Rc::decRef and Rc::incRef
GCC feels the need to generate functions with two instructions for some
reason. Doesn't meaningfully change performance, but makes profiling a
lot easier in some instances.
2022-08-03 15:15:11 +02:00
Joshua Ashton ac2d3e952d [util] Set m_size in small_vector::resize
Turns out this has been broken since it was added, meaning
isViewCompatible has always returned false putting us down slow paths
for UAV clears + copies for the past two years.
2022-08-02 23:54:23 +02:00
Philip Rebohle c1cb4d9d18
[dxvk] Add feature check for external semaphores 2022-08-02 14:37:31 +02:00
Rosen Penev 08424ccb2e
[d3d9] Add missing vector header
Fixes compilation under MSYS2's clang backend.
2022-08-02 13:10:12 +02:00
Joshua Ashton 715493cd75 [d3d10] Mark D3D10ShaderReflection classes as final
Fixes warnings about calling delete on non-final inherited objects.
2022-08-02 13:09:34 +02:00
Philip Rebohle 5256d5e2f6
[dxvk] Fix minor edge cases when parsing floats in config file 2022-08-01 20:24:31 +02:00
Philip Rebohle 727fd7ac33
[d3d11] Add option to control sampler LOD bias 2022-08-01 13:15:09 +02:00
Philip Rebohle 9671055538
[util] Support parsing floating point arguments 2022-08-01 12:05:43 +02:00
pchome 8db2eb51fa [d3d9] fix ordinal values in the DEF file 2022-07-31 14:57:58 +01:00
Philip Rebohle 54f989b2e6 [dxso] Introduce getSpecConstantBufferSlot 2022-07-31 02:10:37 +01:00
Philip Rebohle a2ef99b95c [d3d9] Generalize D3D9ConstantBuffer constructor 2022-07-31 02:10:37 +01:00
Philip Rebohle 00eaec1619
[dxvk] Use normalized state to look up optimized graphics pipelines
We can't normalize all state at the time it is bound, e.g. disabling
unused blend state before render targets are known. By looking up
pipelines using normalized state we ensure that our VkPipelines are
actually unique.

Based on my testing this only affects a small number of pipelines in
most games (anywhere from 0 to a couple dozen), with some outliers
like The Witcher 1, where a third of the pipelines are redundant due
to stale render state.
2022-07-31 02:53:20 +02:00
Philip Rebohle db786cda6c
[dxvk] Remove old code to process specialization constants
We barely use spec constants anymore, so a much simpler solution will do.
2022-07-31 02:53:20 +02:00
Philip Rebohle b2969f628f
[dxvk] Introduce DxvkGraphicsPipelineDynamicState 2022-07-31 02:53:20 +02:00
Philip Rebohle 63420c0cd7
[dxvk] Introduce DxvkGraphicsPipelineShaderState
And factor out a bunch of related code.
2022-07-31 02:53:20 +02:00
Philip Rebohle 30fa9df868
[dxvk] Introduce DxvkGraphicsPipelineSpecConstantState 2022-07-31 02:53:20 +02:00
Philip Rebohle 32c2d91961
[dxvk] Make DxvkShaderModuleCreateInfo usable with lookup tables 2022-07-31 02:53:20 +02:00
Philip Rebohle 9cb0d6d610
[dxvk] Make fragment shader state usable with lookup tables 2022-07-31 02:53:20 +02:00
Philip Rebohle 97ab6a313b
[dxvk] Make pre-rasterization state usable with lookup tables 2022-07-31 02:53:20 +02:00
Philip Rebohle 0a15146746
[dxvk] Use unordered map to look up base pipelines
No reason to use a linear list here. The object is always locked
when we access this list, so we don't need the lock-free one here.
2022-07-31 02:53:20 +02:00
Philip Rebohle 0eaad2eb5b [dxso] Don't create shader object for redundant PS permutations 2022-07-30 22:15:41 +01:00
Joshua Ashton 76ddd2a35a [build] Use current_source_dir instead of source_root
source_root is deprecated and doesn't work if we are used in a subproject
2022-07-30 21:28:09 +02:00
Joshua Ashton 297759be4e [build] Initial reworkings for non-Windows platform support in Meson 2022-07-30 21:28:09 +02:00
Philip Rebohle 8d72b8e820
[dxvk] Reject pipelines that set unused spec constants 2022-07-30 21:24:15 +02:00
Philip Rebohle 54f9eaf13c
[dxvk] Don't spam log messages when pipeline state validation fails 2022-07-30 21:17:21 +02:00
Philip Rebohle 4d8b75c8fb
[d3d9] Fix spec constant derp 2022-07-30 20:38:58 +02:00
Philip Rebohle 10e6d0ef8a
[dxvk] Don't redundantly reset spec constant values
No longer needed.
2022-07-30 20:38:04 +02:00
Philip Rebohle ec7de66419 [util] Use transcodeString in tows and fromws helpers 2022-07-30 20:30:32 +02:00
Philip Rebohle 1c08725acd [util] Use transcodeString in createDirectory function 2022-07-30 20:30:32 +02:00
Philip Rebohle 65070bd765 [util] Use transcodeString in setThreadName function 2022-07-30 20:30:32 +02:00
Philip Rebohle bb3c0b9707 [dxgi] Use transcodeString to convert adapter name 2022-07-30 20:30:32 +02:00
Philip Rebohle 200df73ba7 [util] Implement utility functions for string conversion 2022-07-30 20:30:32 +02:00
Robin Kertels bad7d4690b [d3d9] Handle very large Up draws 2022-07-30 20:29:31 +02:00
Philip Rebohle 2782afaf8a
[dxvk] Inline pushConstants method
No reason not to.
2022-07-30 17:52:55 +02:00
Philip Rebohle 94ca65d587
[dxvk] Ignore spec constants that are not used by the current pipeline
May reduce the number of pipeline permutations.
2022-07-30 17:42:46 +02:00
Philip Rebohle 47794b661e
[dxvk] Only pass requried spec constants when compiling compute pipelines 2022-07-30 16:00:28 +02:00
Philip Rebohle b90f8819c6
[dxvk] Only pass required spec constants when compiling graphics pipelines 2022-07-30 15:54:38 +02:00
Philip Rebohle 80a58f000a
[dxvk] Generate bit mask of used spec constants in DxvkShader
This way we can more accurately track which constants are used, and not
pass any unnecessary data at compile time. We can extend this in the
future to also skip unused constants for pipeline lookups.

Also, any spec constant with the ID of MaxNumSpecConstants will be treated
as a spec constant selector. If the shader uses this constant, it is assumed
that it does not access any other spec constants if the value of this constant
is 0. This will allow shaders with spec constants to be used with pipeline
libraries.
2022-07-30 15:46:47 +02:00
Joshua Ashton 753aede1fc [d3d9] Correct comment about ProjectionType 2022-07-30 12:34:18 +00:00
Joshua Ashton 1d1f0c7e7e [d3d9] Document D3D9SpecConstantId 2022-07-30 12:30:33 +00:00
Robin Kertels ea76bfd019 [d3d9] Unmap unused resources 2022-07-29 13:14:33 +01:00
Robin Kertels b4f432f1de [util] Implement LRU list 2022-07-29 13:14:33 +01:00
Robin Kertels 6ca6554452 [d3d9] Use memory mapped files for textures 2022-07-29 13:14:33 +01:00
Robin Kertels d598fd3156 [d3d9] Add HUD item for unmappable memory 2022-07-29 13:14:33 +01:00
Robin Kertels c3dbb6429f [d3d9] Implement memory allocator for memory mapped files 2022-07-29 13:14:33 +01:00
Robin Kertels 08ad6583ea [d3d9] Only set upload bit for managed textures
Otherwise D3DPOOL_DEFAULT can hit the draw time late
upload path.
2022-07-29 13:14:33 +01:00
Robin Kertels ba4d95c5fc [d3d9] Remove direct upload path
And remove some tracking that will no longer be necessary.
2022-07-29 13:14:33 +01:00
Robin Kertels 45c1d7911e [d3d9] Remove evictManagedOnUnlock
This is annoying to maintain and hopefully won't be necessary anymore.
2022-07-29 13:14:33 +01:00
Robin Kertels 116feca6af [d3d9] Handle unbound textures in fixed function shaders 2022-07-28 14:56:28 +00:00
Philip Rebohle 6c5f73ac26
[dxvk] Reintroduce VkPhysicalDeviceIDProperties
We need this to get the device LUID. Wine does not fill in the
LUID properties in VkPhysicalDeviceVulkan11Properties right now.

Fixes DLSS not working, as well as other potential issues.
2022-07-26 22:38:33 +02:00
Joshua Ashton 6425d2368b [build] Use arch-mingw-github-action v8
Fixes generated version info.
2022-07-26 18:49:22 +01:00
Philip Rebohle 5fe04eb6ac
[dxvk] Fix weird indentation
how did this happen
2022-07-26 02:40:30 +02:00
Blisto91 b06140af47 [util] set maxFrameLatency to 1 for YS Origin 2022-07-25 16:20:28 +02:00
Philip Rebohle 08da6d8ca4
[dxbc] Bound-check mip level for resinfo instruction 2022-07-25 15:58:55 +02:00
Krzysztof Dobrowolski abf5ed154f [dxvk] Add Direct3D9ForceHybridEnumeration empty export function. 2022-07-25 12:04:27 +00:00
Philip Rebohle b67d5c8c1d
[util] Correctly mark flag register as clobbered 2022-07-24 17:30:54 +02:00
Philip Rebohle 41ec5d2c52
[dxvk] Avoid bsf instruction
It's very slow compared to tzcnt on some CPUs, and we have a working fallback.
2022-07-24 15:24:00 +02:00
Philip Rebohle 9cd0473544
[util] Set ignoreGraphicsBarriers option for Stray 2022-07-23 21:21:22 +02:00
Philip Rebohle 9d8484f2e9
[dxvk] Use synchronization2 functions for timestamp queries
Again not really making use of the new stage flags, but might as well
call the function. Oversight from earlier changes.
2022-07-23 15:32:59 +02:00
Blisto91 cb291f29a1 [util] enable alphaTestWiggleRoom for Ninja Blade 2022-07-23 13:02:53 +00:00
Blisto91 f2d4455cdf [util] enable dialog mode for NFS 3 modern patch 2022-07-22 19:47:44 +02:00
Derek Lesho 8fefb099d7 [d3d11] Add support for shared ID3D11Fence resources 2022-07-21 23:39:31 +02:00
Derek Lesho a3548f8043 [dxvk] Add shared handle access to DxvkFence 2022-07-21 23:39:31 +02:00
Derek Lesho a8e573b9b8 [dxvk] Enable VK_KHR_external_semaphore_win32 if available 2022-07-21 23:39:31 +02:00
Philip Rebohle dcd2c4847b
[d3d11] Implement ID3D11Fence
No interop support just yet.

Co-authored-by: Derek Lesho <dlesho@codeweavers.com>
2022-07-21 02:15:16 +02:00
Philip Rebohle 05a827703b
[dxvk] Add fence support to command list
Co-authored-by: Derek Lesho <dlesho@codeweavers.com>
2022-07-21 02:14:59 +02:00
Philip Rebohle 4167e1b887
[dxvk] Refactor queue submission info
Co-authored-by: Derek Lesho <dlesho@codeweavers.com>
2022-07-21 02:14:59 +02:00
Philip Rebohle 446ec07f3b
[dxvk] Add DxvkFence
Co-authored-by: Derek Lesho <dlesho@codeweavers.com>
2022-07-21 02:14:59 +02:00
Philip Rebohle a40724aaf8
[dxvk] Add timeline semaphore entry points
Co-authored-by: Derek Lesho <dlesho@codeweavers.com>
2022-07-21 02:14:53 +02:00
Philip Rebohle ec813e036c
[dxbc] Fix UAV write test
We broke this during the null descriptor refactor. Also make it so that
we don't generate conditionals when there's nothing to test.
2022-07-20 22:56:32 +02:00
Philip Rebohle 779f8b39cd
[spirv] Track currently active block ID 2022-07-20 22:38:03 +02:00
Philip Rebohle a178c57aea
[dxvk] Remove barrier argument from render target transition functions
We're always using the same barrier set anyway.
2022-07-20 16:57:27 +02:00
Philip Rebohle 16eae7adde
[dxvk] Allow resetting the state cache using the DXVK_STATE_CACHE env var 2022-07-20 13:58:50 +02:00
Kassin Dornelles 75d0b1af96 [util] Remove Resident Evil 6 workaround
It's actually making things worse, so better use the default path
2022-07-20 12:00:13 +02:00
Philip Rebohle 2d93760002
[dxvk] Clarify feature enablement
And fall back to robustImageAccess if robustImageAccess2 is not supported.
Not what we want, but better than nothing.
2022-07-19 19:08:58 +02:00
Philip Rebohle fc796abede
[dxvk] Bump engine version reported to the Vulkan driver
Might help with Fossilize stuff.
2022-07-19 15:27:18 +02:00
Philip Rebohle 0ba741b7d2
[dxvk] Use copy_commands2 functions for buffer <-> image copies 2022-07-19 15:16:54 +02:00
Philip Rebohle 23846ad577
[dxvk] Use copy_commands2 functions for image copies 2022-07-19 15:16:54 +02:00
Philip Rebohle dc1d82deff
[dxvk] Use copy_commands2 functions for buffer copies 2022-07-19 15:16:54 +02:00
Philip Rebohle f39d49772d
[dxvk] Use copy_commands2 functions for image resolves
Same idea as with blits, don't expose VkImageResolve2.
2022-07-19 14:10:47 +02:00
Philip Rebohle ff81323228
[dxvk] Use copy_commands2 functions for image blits
Don't expose VkImageBlit2 to client APIs since we can't easily
support pNext chains, so just convert the struct internally.
2022-07-19 13:53:28 +02:00
Philip Rebohle 563b1d7801
[dxvk] Add entry points for copy_commands2 2022-07-19 13:49:01 +02:00
Philip Rebohle 330ff8fa48
[dxvk] Use synchronization2 functions for queue submissions 2022-07-19 02:27:31 +02:00
Philip Rebohle 0c79882e84
[dxvk] Use synchronization2 functions for events 2022-07-19 02:27:31 +02:00
Philip Rebohle adb906b18c
[dxvk] Use synchronization2 functions for barriers
We don't really use the new stage/access flags yet, and I'm not sure
whether we will move to them since the benefits seem rather limited.
However, using the functions means we can bypass a lot of internal
translation inside some Vulkan drivers.
2022-07-19 02:27:31 +02:00
Philip Rebohle 0d65142136
[dxvk] Add entry points for new synchronization API 2022-07-18 22:49:49 +02:00
Philip Rebohle 17205f5353
[dxvk] Fix formatting in barrier function 2022-07-18 22:49:47 +02:00
Blisto91 e28b268351 [util] Enable disableMsaa option for Mary Skelter 2 2022-07-18 22:17:13 +02:00
Philip Rebohle e6df48fa3e
[dxvk] Fix a derp 2022-07-18 14:53:29 +02:00
Philip Rebohle a76b5693f3
[dxvk] Clean up remaining object creation code 2022-07-18 14:52:12 +02:00
Philip Rebohle 9ebeb8e502
[dxvk] Clean up instance creation code a bit 2022-07-18 14:51:40 +02:00
Philip Rebohle a1ace8ef21
[dxvk] Clean up misc. code 2022-07-18 14:51:26 +02:00
Philip Rebohle 37f31ae1e7
[dxvk] Clean up more code around object creation in meta passes 2022-07-18 14:50:29 +02:00
Philip Rebohle fc461d0e27
[dxvk] Clean up some swapchain creation code 2022-07-18 14:49:28 +02:00
Philip Rebohle 04f43f0d2c
[dxvk] Clean up sampler creation code 2022-07-18 14:36:08 +02:00
Philip Rebohle 6276d5503c
[ðxvk] Clean up some device creation code 2022-07-18 14:31:09 +02:00
Philip Rebohle d29d403c67
[dxvk] Clean up buffer and buffer view creation code 2022-07-18 14:21:23 +02:00
Philip Rebohle 0b11995dea
[dxvk] Clean up image and image view creation code
Someone was dunk while setting pNext to VK_NULL_HANDLE instead of nullptr.
2022-07-18 14:19:06 +02:00
Philip Rebohle 8d1b9eca5d
[dxvk] Fix blending with A8 render targets 2022-07-17 17:06:42 +02:00
Philip Rebohle f15466a2c5
[dxvk] Remove remaining built-in specialization constants 2022-07-17 17:06:42 +02:00
Philip Rebohle 0f16a8f70d
[dxbc] Remove output mapping code 2022-07-17 17:06:42 +02:00
Philip Rebohle 568aae8667
[dxvk] Use SPIR-V pass to swizzle FS outputs instead of spec constants 2022-07-17 17:06:42 +02:00
Philip Rebohle c401167161
[dxvk] Introduce SPIR-V pass to inject render target swizzles 2022-07-17 17:06:40 +02:00
Leopard1907 48ac9b27e4 eveonline-dx12_workaround
Launcher probes feature level 12_1, if it fails to probe it DX12 option in launcher stays greyed out, doesn't let user enable DX12.
2022-07-17 13:51:40 +02:00
Philip Rebohle d898eff3be
[dxvk] Don't remove private inpurs from interface list in SPIR-V 1.4+
And if we have to, exit after one iteration since otherwise our iterator
gets invalidated.
2022-07-17 03:57:05 +02:00
Philip Rebohle ff39819086
[dxvk] Merge methods to bind a compute pipeline
There is no workload in practice where the same shader will be used
multiple times with different spec constants, so there is no good
reason to have two dirty flags or to split lookup and binding.
2022-07-17 00:09:30 +02:00
Philip Rebohle a1c3df7750
[dxvk] Always pre-compile compute shaders
We didn't initially do this because the pipeline library code
unconditionally used pNext chains to pass shader code. However,
shader module creation has since been refactored, and now there
is no good reason not to compile compute shaders immediately.

Also fix the stat counter while we're at it.
2022-07-16 23:42:46 +02:00
Philip Rebohle 8747c0f105
[dxvk] Remove unused method from graphics pipeline code 2022-07-16 23:17:06 +02:00
Philip Rebohle 6e8598846d
[dxvk] Allow mutable commands to be recorded into CS chunks 2022-07-16 20:19:46 +02:00
Philip Rebohle 39dd25e972
[dxvk] Unconditionally call updateDynamicState
And optimize that instead. The previous check would always succeed anyway
since we'd set unused dynamic states to dirty, which is necessary for us
to update that state once it's actually used by a pipeline.
2022-07-16 14:47:54 +02:00
Philip Rebohle dadc1bc8ff
[dxvk] Add dirty tracking for dynamic depth-stencil state
Significantly reduces the number of API calls and potentially
context rolls when switching between different base pipelines.
2022-07-16 13:27:55 +02:00
Philip Rebohle 2fabc90f46
[dxvk] Add fast path for rasterizer state comparison 2022-07-16 13:21:58 +02:00
Philip Rebohle e2340d7224
[dxvk] Fix dual-source blending with multiple bound render targets
We can't write to more than one render target, so zero out the write
mask. Also, normalize blend state for disabled render targets for
good measure.
2022-07-15 23:51:04 +02:00
Philip Rebohle 9e7b93b55b
[dxvk] Fix infinite recursion caused by rebase derp 2022-07-15 19:32:03 +02:00
Philip Rebohle 661a8cd258
[dxvk] Be consistent about enabling dynamic blend constants 2022-07-15 17:25:39 +02:00
Philip Rebohle 46a596dd84
[dxvk] Normalize vertex input state using vertex shader input mask
Filters out unused bindings and attributes when creating Vulkan pipelines.
2022-07-15 17:25:39 +02:00
Philip Rebohle 2fee959515
[dxvk] Bump state cache format to v15 2022-07-15 17:25:39 +02:00
Philip Rebohle 35fad0aa6c
[dxvk] Use dynamic vertex strides whenever possible
May reduce the number of pipeline permutations, as well as the overhead
of the bindVertexBuffer call.
2022-07-15 17:25:39 +02:00
Philip Rebohle fc525d5b70
[dxvk] Optimize format lookup for simple formats 2022-07-15 17:25:34 +02:00
Philip Rebohle cdf22a4086
[dxvk] Rename imageFormatInfo -> lookupFormatInfo 2022-07-15 17:25:13 +02:00
Philip Rebohle 5c4b44c97c
[dxvk] Correctly detect viewport index or layer exports in DxvkShader 2022-07-15 16:12:03 +02:00
Philip Rebohle c3af42356f
[dxbc] Enable SPIR-V 1.6 2022-07-15 16:10:16 +02:00
Philip Rebohle e5c45d4ce0
[dxbc] Use StorageBuffer storage class instead of BufferBlock 2022-07-15 16:10:16 +02:00
Philip Rebohle 320534cb34
[spirv] Automatically track interface variables 2022-07-15 16:10:16 +02:00
Philip Rebohle 10c5c17bc1
[meta] Build meta shaders against Vulkan 1.2
Silences some validation errors regarding layer export.
2022-07-15 16:10:16 +02:00
Philip Rebohle 5ecd11fbd0
[meta] Update SPIR-V headers 2022-07-15 16:10:16 +02:00
Philip Rebohle 686df3ec1b
[dxvk] Don't set scissor and viewport count for meta pipelines
Oversight from when we changed these to be unconditionally dynamic.
Fixes a bunch of validation errors.
2022-07-15 16:07:31 +02:00
Philip Rebohle b59571ab22
[dxvk] Explicitly initialize null descriptor structs
There's a weird rule that requires null buffer descriptors to specify
VK_WHOLE_SIZE. Silences a bunch of validation errors in God of War.
2022-07-15 15:59:54 +02:00
Philip Rebohle 0f6ba59f16
[dxvk] Normalize dynamic depth-stencil state based on bound attachment
We already do the same for monolothic pipelines. SpellForce 3 tries
to write depth with a read-only layout, which is a bad idea.
2022-07-14 22:25:59 +02:00
Philip Rebohle b00d7f35f5
[dxvk] Mark more pipeline state as dynamic for base pipelines
Otherwise we might never set depth bias and friends.
2022-07-14 21:51:57 +02:00
Philip Rebohle 70a71237cf
[dxvk] Always initialize dynamic depth/stencil state
Spec says we must set any dynamic state before making a draw call, there
doesn't seem to be an exception if we don't enable depth or stencil tests.
2022-07-14 21:45:22 +02:00
Philip Rebohle 0b59af996a
[dxvk] Use dynamic depth bias enable for base pipelines
This is always supported in Vulkan 1.3.
2022-07-14 21:35:28 +02:00
Philip Rebohle d6d7d5137b
[dxvk] Drop VK_EXT_4444_formats
These formats are core in Vulkan 1.3 and all relevant drivers support them.
2022-07-14 21:21:34 +02:00
Philip Rebohle f60bdcbcbf
[dxvk] Replace VK_EXT_shader_demote_to_helper_invocation with core feature 2022-07-14 21:21:34 +02:00
Philip Rebohle 13425eb39b
[dxvk] Replace VK_EXT_pipeline_creation_cache_control with core feature 2022-07-14 21:21:34 +02:00
Philip Rebohle 7677db3371
[dxvk] Replace VK_EXT_extended_dynamic_state with core feature 2022-07-14 21:21:34 +02:00
Philip Rebohle 3cfc3e7714
[dxvk] Replace VK_KHR_dynamic_rendering with core feature 2022-07-14 21:21:34 +02:00
Philip Rebohle e79a2e8dfa
[dxvk] Enable Vulkan 1.3 feature structs 2022-07-14 21:21:34 +02:00
Philip Rebohle 1dd3f24b43
[dxbc] Drop workarounds for unsupported drivers 2022-07-14 21:21:34 +02:00
Philip Rebohle 223a4fd186
[d3d9] Always assume RADV has fast mulz support
All supported Mesa version support this.
2022-07-14 21:21:34 +02:00
Philip Rebohle 81b89cf31d
[dxvk] Simplify Nvidia HVV workaround
We no longer support 465 series drivers, so the check was obsolete.
2022-07-14 21:21:34 +02:00
Philip Rebohle 131af0d677
[dxvk] Replace VK_KHR_driver_properties with core feature 2022-07-14 21:21:34 +02:00
Philip Rebohle 78c5ef88bc
[dxvk] Replace VK_KHR_shader_float_controls with core feature 2022-07-14 21:21:34 +02:00
Philip Rebohle 000e3cb960
[dxvk] Replace VK_KHR_image_format_list with core feature 2022-07-14 21:21:34 +02:00
Philip Rebohle 956f293a69
[dxvk] Replace VK_KHR_depth_stencil_resolve with core feature 2022-07-14 21:21:34 +02:00
Philip Rebohle b701dd497f
[dxvk] Drop VK_KHR_create_renderpass2 2022-07-14 21:21:34 +02:00
Philip Rebohle d657a526ae
[dxvk] Replace VK_EXT_shader_viewport_index_layer with core features
And enable them optionally in the backend, since we use this for meta
operations.
2022-07-14 21:21:34 +02:00
Philip Rebohle afdaba6caf
[dxvk] Replace VK_KHR_buffer_device_address with core feature 2022-07-14 21:21:34 +02:00
Philip Rebohle 0b47297b7d
[dxvk] Replace VK_EXT_host_query_reset with core feature
And make it a hard requirement in the backend. We no longer support
the old fallback path for queries anyway.
2022-07-14 21:21:34 +02:00
Philip Rebohle f07ba07ad8
[dxvk] Replace VK_KHR_draw_indirect_count with core feature
And enable it optionally in the backend, since we provide the functionality.
2022-07-14 21:21:34 +02:00
Philip Rebohle eee4ac1e91
[dxvk] Replace VK_KHR_sampler_mirror_clamp_to_edge with core features
And make it a hard requirement. We're not checking for feature support
anyway and all relevant drivers support this feature anyway.
2022-07-14 21:21:34 +02:00
Philip Rebohle 73f313f904
[dxvk] Enable Vulkan 1.2 feature structs 2022-07-14 21:21:34 +02:00
Philip Rebohle 2774a04195
[dxvk] Use VkPhysicalDeviceVulkan11{Features,Properties} where appropriate 2022-07-14 21:21:34 +02:00
Philip Rebohle fd15795a0b
[dxvk] Require Vulkan 1.3 adapter 2022-07-14 21:21:34 +02:00
Philip Rebohle 6ac5ca3bff [d3d9] Use existing staging buffer implementation for managed uploads 2022-07-14 18:22:23 +02:00
Philip Rebohle f07a6e160c [d3d9] Rework UP buffer allocation 2022-07-14 18:22:23 +02:00
Joshua Ashton e884413c49 [dxvk] Don't synchronize device if going for DLL shutdown
All our other threads have been destroyed and we can no longer synchronize with them properly.

Co-authored-by: Paul Gofman <pgofman@codeweavers.com>
2022-07-14 17:04:52 +02:00
Georg Lehmann 5ae5476d71 [d3d9] Make reported sample counts consistent with DecodeMultiSampleType behavior. 2022-07-14 15:32:42 +01:00
Philip Rebohle 9e110cd3e5 [d3d9] Fix up unsupported sample counts 2022-07-14 14:58:58 +01:00
Philip Rebohle 74a8bfb774 [d3d9] Remove CreateConstantBuffer method 2022-07-14 15:55:08 +02:00
Philip Rebohle 4635c72e95 [d3d9] Use generic constant buffers for SWVP 2022-07-14 15:55:08 +02:00
Philip Rebohle 08c3c45853 [d3d9] Use generic constant buffer implementation 2022-07-14 15:55:08 +02:00
Philip Rebohle e8d5ce94ea [d3d9] Introduce D3D9ConstantBuffer 2022-07-14 15:55:08 +02:00
Philip Rebohle bcd2be0698
[d3d11] Fix subtle bug in constant buffer rebinding
Previously, if the app called SetConstantBuffers1 with a non-zero
offset and a full UBO range, and then SetConstantBuffers with the
same buffer, we would not rebind that buffer at offset zero.
2022-07-14 15:14:25 +02:00
Philip Rebohle aef2eb14df
[dxvk] Use BindConstantBufferRange for SetConstantBuffers1 if possible
Reduces ref counting overhead in the few games that use this.
2022-07-14 15:14:21 +02:00
Philip Rebohle ce3eae59a9
[dxvk] Introduce bindResourceBufferRange 2022-07-14 14:56:13 +02:00
Philip Rebohle 57445227ac
[d3d11] Fix render target validation (again)
This behaviour is rather obscure and undocumented, but testing shows
that DSV <-> RTV mismatches are allowed under some circumstances.

Fixes #2555.
2022-07-14 12:39:14 +02:00
Robin Kertels ce48b57f94
[d3d9] Allow POOL_SCRATCH targets in GetFrontBufferData 2022-07-13 14:01:12 +02:00
Blisto91 64d2260656
[d3d9] add D3DFMT_UNKNOWN to windowed BackBufferFormat 2022-07-13 13:03:05 +02:00
Philip Rebohle 95995041b0
[d3d9] Explicitly check for Unknown in CheckDeviceFormatConversion 2022-07-13 12:35:33 +02:00
Robin Kertels 10b174b52c [d3d9] Fix barriers with staging buffers 2022-07-12 21:16:32 +01:00
Philip Rebohle bd68f05c9b
[dxvk] Make emitRenderTargetReadbackBarrier more generic
And also remove the redundant pipeline barrier.
2022-07-12 17:29:11 +02:00
Philip Rebohle 5ff6f3a2ca
[dxvk] Fix graphics UAV barriers
We broke this when replacing gfxBarriers with execBarriers,
since starting a render pass instance clears queued up barriers.
2022-07-12 14:26:52 +02:00
Philip Rebohle 59475fb053
[dxvk] Remove cull mode and front face from pipeline state
And bump state cache version to v14.
2022-07-12 12:07:25 +02:00
Philip Rebohle d3c8d21047
[dxvk] Make cull mode and front face dynamic state 2022-07-12 12:03:05 +02:00
Philip Rebohle 18d4a87333
[dxvk] Add pipeline flag for rasterizer discard 2022-07-12 11:42:24 +02:00
Philip Rebohle 77891d71db
[d3d11] Fix unused variable warning 2022-07-12 11:39:56 +02:00
Philip Rebohle f99a833f51
[d3d11] Remove d3d11.constantBufferRangeCheck option 2022-07-12 02:11:39 +02:00
Philip Rebohle e8f48c71ab
[dxvk] Always enable robustBufferAccess2 feature
And respect the required alignments when creating buffers.
2022-07-12 02:11:32 +02:00
Philip Rebohle 6f5ae58ccc
[dxvk] Remove dummy resources that are no longer needed 2022-07-12 01:54:22 +02:00
Philip Rebohle 6482898167
[dxvk] Mark VK_KHR_create_renderpass_2 as required
Dependency of VK_KHR_dynamic_rendering.
2022-07-12 00:54:24 +02:00
Philip Rebohle 379c2e545e
[util] Work around silly compiler warnings on GCC 12.1
No, we're not actually reading 64 bytes from a 1-byte area.
2022-07-11 19:24:09 +02:00
Philip Rebohle 52038b2f83
[dxvk] Ignore state cache for pipelines that can be fast linked 2022-07-11 16:23:14 +02:00
Philip Rebohle ca52c5a67f
[dxvk] Don't read or create state cache file if state cache is disabled 2022-07-11 01:19:09 +02:00
Philip Rebohle 00cfee9d17
[d3d11] Ignore OMSetRenderTargets calls with incompatible view sizes
Fixes #2701.
2022-07-10 15:17:00 +02:00
Matej Dian 1b89394aa0
[util] Enable cached dynamic resources for DayZ (#2709) 2022-07-09 15:51:04 +02:00
Philip Rebohle 2832083fe5
[dxvk] Properly log pipeline state on error 2022-07-09 13:53:20 +02:00
Philip Rebohle c6168179bd
[dxvk] Re-add render target format validation
This was lost during the state cache and render target state rework.
2022-07-09 13:44:52 +02:00
Philip Rebohle 021aff1fc0
[dxvk] Support fomatting more Vulkan enum names 2022-07-09 13:41:07 +02:00
Philip Rebohle 02aa1736f5
[dxvk] Try to create cached optimized pipeline whenever possible 2022-07-09 13:41:07 +02:00
Philip Rebohle df1908f7bf
[dxvk] Support creating shader stage infos with module identifiers 2022-07-09 13:41:07 +02:00
Philip Rebohle 52cc0a366e
[dxvk] Query shader module identifiers from shader pipeline libraries 2022-07-09 13:41:07 +02:00
Philip Rebohle 331c790592
[dxvk] Enable VK_EXT_shader_module_identifier if supported 2022-07-09 13:41:07 +02:00
Philip Rebohle 04545ab00a
[dxvk] Enable VK_EXT_pipeline_creation_cache_control if supported 2022-07-09 13:41:07 +02:00
Philip Rebohle f4fd8c6c65
[dxvk] Remove in-memory pipeline cache
Doesn't really do much and only prevents Nvidia's disk cache
from working on 515.49.06 drivers.
2022-07-09 13:41:07 +02:00
Philip Rebohle 645886db8d
[hud] Display pipeline library count in HUD 2022-07-09 13:41:07 +02:00
Philip Rebohle 3552983084
[dxvk] Add stat counter for pipeline libraries 2022-07-09 13:41:07 +02:00
Philip Rebohle 4535fdc336
[dxvk] Pass pipeline manager to pipeline library constructor 2022-07-09 13:41:07 +02:00
Philip Rebohle 498444f1a8
[dxvk] Reuse linked base pipelines if possible
No reason to create identical pipelines multiple times.
2022-07-09 13:41:07 +02:00
Philip Rebohle 5562ff4472
[dxvk] Remove pipeline compile timing
Meaningless now.
2022-07-09 13:41:07 +02:00
Philip Rebohle 5d340e48b4
[dxvk] Improve pipeline state logging 2022-07-09 13:41:07 +02:00
Philip Rebohle 5e1569593a
[dxvk] Create full pipeline layout with INDEPENDENT_SETS_BIT
And use it to link pipelines as well as descriptor binding.
Should fix issues related to descriptors.
2022-07-09 13:41:07 +02:00
Philip Rebohle b51d7a3cc0
[dxvk] Update descriptor sets after binding pipeline 2022-07-09 13:41:07 +02:00
Philip Rebohle 6256ab2a19
[dxvk] Use pipeline libraries to link base pipelines if possible 2022-07-09 13:41:07 +02:00
Philip Rebohle 7f9a04fd59
[dxvk] Don't keep pipeline locked when building optimized variant
Only lock when creating base variant, otherwise we'll have stutter.
2022-07-09 01:53:52 +02:00
Philip Rebohle cc1575e8b7
[dxvk] Compile optimized graphics pipelines on worker threads if necessary 2022-07-09 01:53:52 +02:00
Philip Rebohle b50ed2ceca
[dxvk] Deal with multiple pipeline handles for graphics pipeline instances
Also make the handles atomic since worker threads may access them when
compiling optimized pipeline variants.
2022-07-09 01:53:51 +02:00
Philip Rebohle 90454438b2
[dxvk] Introduce distinction between base and optimized pipelines
We need to know what kind of pipeline we're binding in order to apply
the correct dynamic state.
2022-07-09 01:53:51 +02:00
Philip Rebohle e01ffc02a8
[dxvk] Add more dynamic state to DxvkCommandList 2022-07-09 01:53:51 +02:00
Philip Rebohle a683ecd525
[dxvk] Create pipeline library for null shader 2022-07-09 01:53:51 +02:00
Philip Rebohle a0d1ef7f61
[dxvk] Handle null shader in DxvkShaderPipelineLibrary 2022-07-09 01:53:51 +02:00
Philip Rebohle 2cb9ceba1d
[dxvk] Simplify pipeline instance data 2022-07-09 01:53:51 +02:00
Philip Rebohle a72bf02374
[dxvk] Pass VS and FS libraries to graphics pipelines 2022-07-09 01:53:51 +02:00
Philip Rebohle cb56e16a4b
[dxvk] Use precompiled compute pipelines whenever possible 2022-07-09 01:53:51 +02:00
Philip Rebohle 6265b5b809
[dxvk] Use new shader stage info objects in DxvkShaderPipelineLibrary
Avoids crashing on drivers which do not support NULL modules for compute
pipelines and just reduces the amount of code by a small amount.
2022-07-09 01:53:51 +02:00
Philip Rebohle e6470b6d10
[dxvk] Rework DxvkShaderModule into DxvkShaderStageInfo
Separates the whole thing from DxvkShader instances so that we
can use this in other places too. Only creates a shader module
if necessary for the given pipeline or device.
2022-07-09 01:53:51 +02:00
Philip Rebohle 5019ce4b9c
[dxvk] Compile pipeline libraries in registerShader if supported 2022-07-09 01:53:51 +02:00
Philip Rebohle a49333cd87
[dxvk] Add pass to check whether a shader has spec constants
Pipeline libraries cannot be used for shaders with user spec constants.
2022-07-09 01:53:51 +02:00
Philip Rebohle a6b0783a51
[dxvk] Add config option for graphics pipeline library enablement 2022-07-09 01:53:51 +02:00
Philip Rebohle 06c084616f
[dxvk] Clean up graphics and compute pipeline constructors 2022-07-09 01:53:51 +02:00
Philip Rebohle f2f1f86500
[dxvk] Use new worker thread system in state cache 2022-07-09 01:53:51 +02:00
Philip Rebohle 02e6a212bb
[dxvk] Introduce new pipeline manager worker thread system 2022-07-09 01:53:51 +02:00
Philip Rebohle 1c573a7fd5
[dxvk] Rework state cache object creation 2022-07-09 01:53:51 +02:00
Philip Rebohle 8b645f8563
[dxvk] Rework DxvkPipelineCache 2022-07-09 01:53:51 +02:00
Philip Rebohle dbcd0333d9
[dxvk] Implement shader-based pipeline libraries 2022-07-09 01:53:51 +02:00
Philip Rebohle 30c25ee1f0
[dxvk] Add way to create partial pipeline layouts 2022-07-09 01:53:51 +02:00
Philip Rebohle 3b10efbc30
[dxvk] Implement fragment output pipeline libraries 2022-07-09 01:53:51 +02:00
Philip Rebohle 578c136239
[dxvk] Implement vertex input pipeline libraries 2022-07-09 01:53:51 +02:00
Philip Rebohle 47ac5f49cb
[dxvk] Factor out fragment shader state setup 2022-07-09 01:53:51 +02:00
Philip Rebohle 33067f2a23
[dxvk] Factor out pre-rasterization state setup 2022-07-09 01:53:51 +02:00
Philip Rebohle 08e0e4181b
[dxvk] Factor out fragment output state setup 2022-07-09 01:53:51 +02:00
Philip Rebohle 1e56f2b7a0
[dxvk] Factor out vertex input state setup 2022-07-09 01:53:51 +02:00
Philip Rebohle 6c756c2dbe
[dxvk] Add check whether graphics pipeline libraries can be used 2022-07-09 01:53:51 +02:00
Philip Rebohle d6afe36592
[dxvk] Enable VK_EXT_graphics_pipeline_library if supported 2022-07-09 01:53:51 +02:00
Philip Rebohle 97f2d81b25
[meta] Update Vulkan headers to 1.3.219 2022-07-09 01:53:51 +02:00
Joshua Ashton 2bd062f9d6 [util] Implement LUID helpers for non-Windows platforms Initial commit 2022-07-09 01:14:18 +02:00
Blisto91 3733590756
[util] disable allowDoNotWait for Port Royale 3 (#2668) 2022-07-09 01:00:21 +02:00
Philip Rebohle 21ca9b91d0
[dxvk] Mark VK_EXT_extended_dynamic_state as required
The device feature is already required anyway.
2022-07-08 23:44:05 +02:00
Philip Rebohle fcadaec129
[dxvk] Store clear values inside render pass ops
The previous model was designed around vkCmdBeginRenderPass, which was
somewhat clunky regarding attachment clears. This is no longer needed.
2022-07-07 16:16:51 +02:00
Philip Rebohle d71e85785c
[dxvk] Drop barrier before renderPassBindFramebuffer
Not necessary since that function emits barriers anyway.
2022-07-07 16:16:51 +02:00
Philip Rebohle 0c5773dbb9
[dxvk] Emit smarter post-renderpass barriers
Allows folding the old post-renderpass barrier into the same pipeline
barrier call as layout transitions from prepareImage or from starting
another render pass, thus reducing the overall number of pipeline
barriers. Also no longer uses VK_PIPELINE_STAGE_ALL_COMMANDS_BIT.
2022-07-07 16:16:50 +02:00
Philip Rebohle 67d35ecc8d
[dxvk] Introduce DxvkGlobalPipelineBarrier 2022-07-07 16:16:50 +02:00
Philip Rebohle 95f7aae3e6
[dxvk] Remove viewport state from graphics pipelines
And bump state cache version to v13.
2022-07-07 16:16:50 +02:00
Philip Rebohle 4b82a05e05
[dxvk] Enable and use dynamic viewport and scissor rect count 2022-07-07 16:16:50 +02:00
Philip Rebohle b34421b055
[dxvk] Always enable extendedDynamicState feature 2022-07-07 16:16:50 +02:00
Philip Rebohle f19607c11e
[dxvk] Use dynamic rendering directly for partial image view clears 2022-07-07 16:16:50 +02:00
Philip Rebohle f57a6d485b
[dxvk] Use dynamic rendering directly for render target clears 2022-07-07 16:16:50 +02:00
Philip Rebohle 605fef10b4
[dxvk] Fix render target readback barrier
Dynamic rendering does not allow barriers within a render
pass instance, so we have to actually stop rendering.
2022-07-07 16:16:50 +02:00
Philip Rebohle e8f3d9b040
[dxvk] Remove render pass and framebuffer objects 2022-07-07 16:16:50 +02:00
Philip Rebohle e3a63d4faa
[dxvk] Bump state cache version to v12
And remove its reliance on the old render pass format struct.
2022-07-07 16:16:50 +02:00
Philip Rebohle 39a2b1cb7a
[dxvk] Remove support for state cache versions older than v8
We could technically keep supporting this with Dynamic Rendering, but
it's a huge amount of work and there's no good reason to do so.
2022-07-07 16:16:50 +02:00
Philip Rebohle 343eba693d
[dxvk] Use dynamic rendering for regular graphics pipelines
For now, just do whatever we were previously doing for render passes,
but explicitly.
2022-07-07 16:16:50 +02:00
Philip Rebohle 5b6a598ed6
[dxvk] Use dynamic rendering for resolve operations 2022-07-07 16:16:50 +02:00
Philip Rebohle 96e102beff
[dxvk] Use dynamic rendering for copies
Significantly reworks framebuffer copies as well. We'll no longer
create dummy samplers to work around glslang versions not supporting
texture descriptors without samplers, and copyImageFb was cleaned
up to factor out the part where a temporary image is created.
2022-07-07 16:16:50 +02:00
Philip Rebohle a450c88c72
[dxvk] Use dynamic rendering for blits and mip generation 2022-07-07 16:16:50 +02:00
Philip Rebohle d5cc50f73f
[dxvk] Add dynamic rendering commands to DxvkCommandList 2022-07-07 16:16:50 +02:00
Philip Rebohle 38cf16a5be
[dxvk] Enable and require VK_KHR_dynamic_rendering 2022-07-07 16:16:44 +02:00
Trevonn 4a0a9d6286 [util] Limit Dead Space to 60fps and fix vsync
https://www.pcgamingwiki.com/wiki/Dead_Space#Issues_fixed

The game has mouse acceleration and physics issues above 60 FPS.

Also the game locks to 30 FPS using the built-in vsync. 
Setting presentInterval to 1 blocks this and the game continues to run at 60 FPS
2022-07-07 14:19:20 +01:00
Georg Lehmann 913129d3b6 [d3d9] Add an config option to disable non seamless cube maps. 2022-07-07 14:18:49 +01:00
Georg Lehmann cd8e2360f4 [d3d9] Use non seamless samplers if supported. 2022-07-07 14:18:49 +01:00
Georg Lehmann 0015a34498 [dxvk] Enable VK_EXT_non_seamless_cube_map if requested. 2022-07-07 14:18:49 +01:00
Georg Lehmann f2b1805d7e [dxvk] Allow non seamless samplers. 2022-07-07 14:18:49 +01:00
Georg Lehmann e9ac543627 [include] Update Vulkan headers to 1.3.217. 2022-07-07 14:18:49 +01:00
WinterSnowfall 03ac577577 [util] Add workaround to fix missing sun & light shafts in Beyond Good And Evil 2022-07-07 14:17:52 +01:00
Philip Rebohle 593c6e3fe8
[dxvk] Remove spec constant ID mapping from pipeline layouts
No longer needed.
2022-07-05 13:03:18 +02:00
Philip Rebohle 8d413e2d09
[dxvk] Fix opening state cache files for writing
operator bool() only checks if errors have occured in previous writes,
so we'd be missing out on the first cache entry written.
2022-07-03 15:38:42 +02:00
Philip Rebohle 7c4d602863
[dxvk] Change spec constant IDs
We no longer support per-resource spec constants, so there is no good
reason not to use a 1:1 mapping for user-defined constants.
2022-07-03 13:41:06 +02:00
Philip Rebohle 2e73e46799
[dxvk] Do not remap spec constant IDs when compiling shaders
No longer needed since we don't emit per-binding constants anymore.
2022-07-03 13:41:06 +02:00
Philip Rebohle a637134c56
[d3d11,dxbc] Use push constant instead of spec constant for rasterizer sample count 2022-07-03 13:41:06 +02:00
Philip Rebohle 87e2d70448
[dxbc] Remove bound spec constants from shader code 2022-07-03 13:41:06 +02:00
Philip Rebohle 8abb5ffc77
[dxvk] Remove binding mask from pipeline state 2022-07-03 13:41:06 +02:00
Philip Rebohle 54eaa444a2
[dxvk] Use null descriptors for unbound resources 2022-07-03 13:41:06 +02:00
Philip Rebohle 3349f2d80e
[dxvk] Use custom spec constant for swap chain blitter 2022-07-03 13:41:06 +02:00
Philip Rebohle 185331df9c
[d3d11] Don't use spec constants for video blitter
Store required info in the UBO instead.
2022-07-03 13:41:06 +02:00
Philip Rebohle c7afe0dd23
[dxso] Use new bit mask spec constant to determine whether textures are bound 2022-07-03 13:41:06 +02:00
Philip Rebohle 735e741681
[d3d9] Add spec constant for null samplers
And rework the way spec constants are updated.
2022-07-03 13:41:06 +02:00
Philip Rebohle 186dc29384
[d3d9] Remove bound spec constants from fixed-function shaders
Texture stages are disabled anyway when textures are unbound,
so we will never hit the unbound case.
2022-07-03 13:41:06 +02:00
Philip Rebohle 8f03c3a419
[dxvk] Don't check binding mask when processing barriers 2022-07-03 13:41:06 +02:00
Philip Rebohle 2e7e9eac7a
[dxvk] Require EXT_robustness2 and the null descriptor feature 2022-07-03 13:41:03 +02:00
Blisto91 f95f541852
[util] Limit Bionic Commando to 60fps (#2685) 2022-07-02 16:51:04 +02:00
Blisto91 98dcd722ea
[util] Add workaround for Garden Warfare 2 (#2700) 2022-07-02 16:50:12 +02:00
Philip Rebohle e406484b84
[d3d9] Don't use VK_RESOLVE_MODE_AVERAGE_BIT_KHR for stencil resolves
Doesn't work, always write sample zero instead.
2022-07-02 16:48:10 +02:00
Philip Rebohle 76ba03398d
[d3d9,dxso] Fix push constant validation errors
Derp.
2022-07-01 18:06:47 +02:00
Philip Rebohle e81094533b
[dxvk] Fix gamma texture bind point 2022-06-30 20:49:43 +02:00
Philip Rebohle 1296890083
[dxvk] Remove error logging from updateResourceBindings
It's not super useful to emit log messages in the hottest code path, and
for some reason GCC compiles some stringstream initialization code into
those parts of the function that are unconditionally executed.
2022-06-28 14:35:58 +02:00
Philip Rebohle 0e38b11569
[dxvk] Rework DxvkResource lifetime tracking
Reduces the number of atomic operations required for lifetime tracking by
using a single 64-bit integer for usage tracking and reference counting.
2022-06-28 14:35:58 +02:00
Philip Rebohle 8d1d3d66e0
[dxvk] Optimize descriptor set binding further 2022-06-28 14:35:58 +02:00
Philip Rebohle db07861518
[dxvk] Remove old pipeline layout implementation 2022-06-28 14:35:58 +02:00
Philip Rebohle c67481b904
[hud] Add HUD item for descriptor stats 2022-06-28 14:35:58 +02:00
Philip Rebohle d4a3b823a2
[dxvk] Add stat counters for descriptor sets and pools 2022-06-28 14:35:58 +02:00
Philip Rebohle 758ba5a80d
[dxvk] Inline all frequently-used binding methods 2022-06-28 14:35:58 +02:00
Philip Rebohle d4d87123b4
[dxvk] Add safety mechanism to submit large descriptor pools 2022-06-28 14:35:58 +02:00
Philip Rebohle cfc06405d2
[dxvk] Recycle Vulkan descriptor pools as well
Reduces the number of expensive reallocations when large descriptor
pools get reset and repopulated.
2022-06-28 14:35:58 +02:00
Philip Rebohle eea5c9f0da
[dxvk] Rename new descriptor pool implementation to DxvkDescriptorPool 2022-06-28 14:35:58 +02:00
Philip Rebohle 6aeed40af2
[dxvk] Remove old descriptor pool implementation 2022-06-28 14:35:58 +02:00
Philip Rebohle af418dcffd
[dxvk] Fix pipeline invalidation
We need to update descriptors and other graphics state when changing
between compute and graphics. This happened to work by chance since
any real-world app binds a new set of shaders around mode switches
anyway, but it could theoretically happen that we wouldn't update
descriptor sets on the first draw after a dispatch.
2022-06-28 14:35:58 +02:00
Philip Rebohle a27448bc76
[dxvk] Bind consecutive descriptor sets in one go
Most of the time we'll be able to bind all sets in one iteration. Binding
sets is expected to be cheap in the driver, but we should avoid unnecessary
function call overhead for this frequently called function.
2022-06-28 14:35:58 +02:00
Philip Rebohle e2b7522034
[dxvk] Use persistent descriptor pool for regular descriptor sets 2022-06-28 14:35:57 +02:00
Philip Rebohle f4e9b76515
[dxvk] Add descriptor pool tracking to command list 2022-06-28 14:35:57 +02:00
Philip Rebohle 9b0b1edf74
[dxvk] Introduce persistent descriptor pool 2022-06-28 14:35:57 +02:00
Philip Rebohle 7e42939a4a
[d3d11] Call endFrame at the end of each frame 2022-06-28 14:35:57 +02:00
Philip Rebohle acf70501d2
[d3d9] Call endFrame at the end of each frame 2022-06-28 14:35:57 +02:00
Philip Rebohle 5610b3a742
[dxvk] Introduce endFrame method 2022-06-28 14:35:57 +02:00
Philip Rebohle ab0c15ea54
[dxvk] Introduce DxvkContextType 2022-06-28 14:35:57 +02:00
Philip Rebohle 8dde72da06
[dxvk] Do not allocate descriptor set space for dynamic UBOs 2022-06-28 14:35:57 +02:00
Philip Rebohle f34d1c886a
[dxvk] Only use descriptor update templates in 32-bit builds 2022-06-28 14:35:57 +02:00
Philip Rebohle 15cf130369
[dxvk] Optimize descriptor set binding further 2022-06-28 14:35:57 +02:00
Philip Rebohle f9e6d8e23a
[dxvk] Remove old resource update code 2022-06-28 14:35:57 +02:00
Philip Rebohle 219853aa9f
[dxvk] Rework dirty descriptor state tracking 2022-06-28 14:35:57 +02:00
Philip Rebohle db85de8c91
[dxvk] Add method to query shader stages that can access a buffer 2022-06-28 14:35:45 +02:00
Philip Rebohle 893183a7cc
[dxvk] Remove old pipeline layout from pipeline objects 2022-06-28 14:34:09 +02:00
Philip Rebohle 9be454fd3e
[dxvk] Use new pipeline layout for barrier tracking and other things 2022-06-28 14:34:07 +02:00
Philip Rebohle d5e53d3271
[dxvk] Add resource binding code using new pipeline layouts 2022-06-28 14:32:31 +02:00
Philip Rebohle ef55a7c2a0
[dxvk] Add method to create shader module using new binding layout 2022-06-28 14:32:31 +02:00
Philip Rebohle d65ceb82cf
[dxvk] Rework binding ID patching 2022-06-28 14:32:31 +02:00
Philip Rebohle 955e0cca62
[dxvk] Use native integer size for DxvkBindingSet
May make things a tad faster in 64-bit applications.
2022-06-28 14:32:31 +02:00
Philip Rebohle 16eba45987
[dxvk] Implement 64-bit tzcnt 2022-06-28 14:32:31 +02:00
Philip Rebohle 038ee0416d
[dxvk] Add setRange method to DxvkBindingSet 2022-06-28 14:32:31 +02:00
Philip Rebohle ec5ea71174
[dxvk] Store and create pipeline layout objects in pipeline manager
This should help avoid a lot of duplication.
2022-06-28 14:32:31 +02:00
Philip Rebohle 79ecd4e94a
[dxbc] Pass new binding info struct to shaders 2022-06-28 14:32:31 +02:00
Philip Rebohle cb57c2f7fb
[d3d11] Pass new binding info struct to video processor shader 2022-06-28 14:32:31 +02:00
Philip Rebohle e795f3f33a
[dxso] Pass new binding info struct to shaders 2022-06-28 14:32:31 +02:00
Philip Rebohle ecbada30f5
[d3d9] Pass new binding info struct to fixed-function shaders 2022-06-28 14:32:31 +02:00
Philip Rebohle 5edd8e92a8
[d3d9] Pass new binding info struct to various helper shaders 2022-06-28 14:32:31 +02:00
Philip Rebohle 7b8b50bca6
[hud] Pass new shader binding info struct to HUD shaders 2022-06-28 14:32:31 +02:00
Philip Rebohle 89dadc8453
[dxvk] Pass new shader binding info struct to swapchain blit shaders 2022-06-28 14:32:31 +02:00
Philip Rebohle 70a95d9085
[dxvk] Add DxvkBindingLayout to DxvkShader class
Supposed to replace the old descriptor model eventually.
2022-06-28 14:32:31 +02:00
Philip Rebohle 53519e2bd5
[dxvk] Remove old resource binding methods 2022-06-28 14:32:30 +02:00
Philip Rebohle 4cc559d690
[d3d9] Pass shader stage when binding shader resources 2022-06-28 14:32:30 +02:00
Philip Rebohle 0fb1227792
[d3d9] Pass shader stage when binding format conversion resources 2022-06-28 14:32:30 +02:00
Philip Rebohle d05864cbcb
[d3d11] Pass shader stage for binding video processor resources 2022-06-28 14:32:30 +02:00
Philip Rebohle a1bbc77c04
[d3d11] Pass shader stage for binding resources in context methods 2022-06-28 14:32:30 +02:00
Philip Rebohle ce0a2f08f0
[hud] Pass shader stage when binding HUD shader resources 2022-06-28 14:32:30 +02:00
Philip Rebohle fe03327ecd
[dxvk] Pass shader stage when binding HUD resources 2022-06-28 14:32:30 +02:00
Philip Rebohle 10eabb34da
[dxvk] Add shader stage parameter to binding methods 2022-06-28 14:32:30 +02:00
Philip Rebohle 3751edbe0c
[dxvk] Introduce DxvkBindingLayout and related classes
This is intended to replace the legacy DxvkPipelineLayout, and can support
multiple descriptor sets.
2022-06-28 14:32:30 +02:00
Philip Rebohle 67d03aabd0
[dxvk] Make recycler a ring buffer
Ensures that recycled objects actually get reused soon. Somewhat
important for memory efficiency in descriptor pools.
2022-06-28 14:32:30 +02:00
Philip Rebohle 384a665700
[dxvk] Optimize util::pipelineStages 2022-06-28 14:31:52 +02:00
Justin Kim 972de7c9fb
converting flags from VkShaderStageFlags to VkPipelineStageFlags in commitGraphicsBarriers (#2696) 2022-06-28 13:09:14 +02:00
Federico Dossena dee36be20d
Added config for A Way Out (#2694) 2022-06-25 11:17:42 +02:00
pchome 27163a6a29 [util] Fix built-in config options loging 2022-06-22 18:21:31 +02:00
Blisto91 661f8b5b56 [util] Add Forged Alliance Forever to Supreme Commander 2022-06-20 11:59:40 +01:00
Robin Kertels bd29fbd95d [util] Enable sampler type spec constants for SWTOR
Co-authored-by: Blisto91 <47954800+Blisto91@users.noreply.github.com>
2022-06-13 21:34:28 +01:00
Blisto91 968f0cdbc3 [util] Strict float emulation for Supreme Commander 2022-06-12 20:16:56 +01:00
Robin Kertels 4f56e72d56 [util] Enable strict float emulation for Sonic Adventure 2 2022-06-11 01:31:48 +02:00
Georg Lehmann 2e4caa4c14 [util] Stop using deprecated std::iterator. 2022-06-09 22:07:52 +02:00
Philip Rebohle 9e5c61bf88
[dxvk] Create state cache threads on demand 2022-06-07 11:46:06 +02:00
Andrew Eikum 279b4b7ec2 [d3d9] Defer surface creation if no HWND is given to device
Planetary Annihilation: TITANS creates a device with a NULL HWND and
requires it to succeed.
2022-06-03 13:07:43 +00:00
Philip Rebohle c596738205
[hud] Fix incorrect array length for VS resources 2022-06-02 19:57:22 +02:00
Blisto91 1862e4dc8d [util] Report Nvidia VendorId for Myst V
Game was made before ATI Technologies was bought by AMD and so doesn't recognize AMD as a GPU vendor, which for some reason makes it bug out.
It also works when it sees the word "Radeon" in the device description, which is why this issue doesn't show on amdvlk or wined3d.
2022-06-02 15:11:17 +02:00
Mike Lothian de0f81fcdc [spirv] Add utility include
This fixes a compile issue with GCC 12.1

FAILED: src/spirv/libspirv.a.p/spirv_compression.cpp.obj
i686-w64-mingw32-g++ -Isrc/spirv/libspirv.a.p -Isrc/spirv -I../dxvk-9999/src/spirv -I../dxvk-9999/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -std=c++17 -O0 -DNOMINMAX -D_WIN32_WINNT=0xa00 -msse -msse2 -msse3 -mfpmath=sse -Wimplicit-fallthrough -O3 -march=native -pipe -flto=16 -mno-avx -MD -MQ src/spirv/libspirv.a.p/spirv_compression.cpp.obj -MF src/spirv/libspirv.a.p/spirv_compression.cpp.obj.d -o src/spirv/libspirv.a.p/spirv_compression.cpp.obj -c ../dxvk-9999/src/spirv/spirv_compression.cpp
In file included from ../dxvk-9999/src/spirv/../util/util_flags.h:5,
                 from ../dxvk-9999/src/spirv/spirv_include.h:7,
                 from ../dxvk-9999/src/spirv/spirv_instruction.h:6,
                 from ../dxvk-9999/src/spirv/spirv_code_buffer.h:8,
                 from ../dxvk-9999/src/spirv/spirv_compression.h:5,
                 from ../dxvk-9999/src/spirv/spirv_compression.cpp:1:
../dxvk-9999/src/spirv/../util/util_bit.h:300:33: warning: ‘template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator’ is deprecated [-Wdeprecated-declarations]
  300 |     class iterator: public std::iterator<std::input_iterator_tag,
      |                                 ^~~~~~~~
In file included from /usr/lib/gcc/i686-w64-mingw32/12.1.0/include/g++-v12/bits/stl_algobase.h:65,
                 from /usr/lib/gcc/i686-w64-mingw32/12.1.0/include/g++-v12/vector:60,
                 from ../dxvk-9999/src/spirv/spirv_compression.h:3:
/usr/lib/gcc/i686-w64-mingw32/12.1.0/include/g++-v12/bits/stl_iterator_base_types.h:127:34: note: declared here
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
../dxvk-9999/src/spirv/spirv_code_buffer.h: In member function ‘size_t dxvk::SpirvCodeBuffer::endInsertion()’:
../dxvk-9999/src/spirv/spirv_code_buffer.h:214:19: error: ‘exchange’ is not a member of ‘std’
  214 |       return std::exchange(m_ptr, m_code.size());
      |                   ^~~~~~~~

Signed-off-by: Mike Lothian <mike@fireburn.co.uk>
2022-06-02 15:10:53 +02:00
Philip Rebohle 5d0273f520
[dxvk] Remove interpolation decorations for replaced shader inputs 2022-06-01 14:11:09 +02:00
Philip Rebohle 6d3ba1b7d7
[dxvk] Perform validation on render pass formats read from state cache 2022-06-01 14:11:09 +02:00
Philip Rebohle 80e125a130
[dxvk] Perform more extensive validation on pipeline state vectors 2022-06-01 14:11:06 +02:00
Blisto91 4ff7687dea [util] Force SM1 for the Halo CE SPV3 launcher 2022-05-31 15:45:23 +02:00
Robin Kertels 7bcf3e1062
[util] Force SM1 for the Warhammer ROR Launcher (#2579)
Co-authored-by: Philip Rebohle <25567304+doitsujin@users.noreply.github.com>
2022-05-31 15:19:30 +02:00
Winter Snowfall 8c96830752
Add d3d9.deferSurfaceCreation workaround for Scrapland (Remastered) (#2574) 2022-05-31 15:17:31 +02:00
noneistaken 93eb86aa3e Blend HUD text shadow and center correctly
This fixes incorrect blending between HUD text, which would cause a narrow transparent gap between the text center and border/shadow that is visible at large text sizes.
2022-05-30 18:23:19 +02:00
Masanori Kakura 0678d80e89 [meta] Update Meson requirement (>=0.49) in README 2022-05-25 18:44:49 +02:00
Zhiyi Zhang 8147844aef [dxgi] Return DXGI_ERROR_INVALID_CALL for invalid IDXGIAdapter3::RegisterVideoMemoryBudgetChangeNotificationEvent() parameters
According to wine tests 14237e321b

Signed-off-by: Zhiyi Zhang <zzhang@codeweavers.com>
2022-05-25 18:44:20 +02:00
WinterSnowfall 51e56c0420 [util] Enforce a maxAvailableMemory limit for Majesty 2 2022-05-23 07:54:37 +00:00
Paul Gofman cc11bb8240 [d3d9] Don't adjust window position and size in windowed mode. 2022-05-23 07:53:13 +00:00
Paul Gofman cde0fbe7b0 [util] Enable d3d9.deferSurfaceCreation for Small Radios Big Televisions 2022-05-19 02:51:41 +00:00
Joshua Ashton 5b7406fed5 [d3d9] Fix crash when using StretchRect with NULL rts 2022-05-10 02:02:35 +01:00
pchome 15fa310bb4 [build] Bump required meson version to >=0.49 2022-05-01 18:37:39 +02:00
Philip Rebohle 6ddd0cfe0a
[d3d11] Do not add UINT formats to all UAV format lists
Analogous to vkd3d-proton changes. Allows drivers to use compression more
frequently.
2022-04-25 17:37:10 +02:00
Philip Rebohle a85f7c48a5
[d3d11] Make ClearUnorderedAccessViewUINT fallback more generic 2022-04-25 17:34:45 +02:00
Philip Rebohle 304d0549d5
[dxbc] Implement range check for private array reads
We already do this for stores.
2022-04-21 18:06:41 +02:00
Robin Kertels 3004026db8 [d3d9] Only bind RT if we actually write to it
The alternative render path for shadow maps in Dead Space relies on this.
2022-04-20 00:58:17 +01:00
Robin Kertels bdafa16e39 [d3d9] Only bind depth buffer if the depth or stencil test is enabled 2022-04-20 00:58:17 +01:00
Joshua Ashton d6cbd99141 [util] Add missing include to thread.h 2022-04-19 18:14:58 +01:00
Joshua Ashton 08e2ec6c98 [util] Implement env helpers on non-Windows platforms 2022-04-19 17:08:17 +01:00
Joshua Ashton 147f3738f9 [d3d9] Use strlcpy helper 2022-04-19 17:08:17 +01:00
Joshua Ashton dc6b7fa4a7 [util] Add strlcpy helper
strncpy is not safe.
2022-04-19 17:08:17 +01:00
Joshua Ashton 9ee0f51870 [util] Implement thread helpers on non-Windows platforms 2022-04-19 17:08:06 +01:00
Robin Kertels 9302d33ac7 [d3d9+util] Enable invariant position by default 2022-04-18 12:40:46 +01:00
Philip Rebohle 35e8f4676b [dxvk] Remove old shader creation code 2022-04-18 13:20:16 +02:00
Philip Rebohle a731f5daae [d3d11] Use new DxvkShader constructor for video shaders 2022-04-18 13:20:16 +02:00
Philip Rebohle 69817a84dc [d3d11] Use new DxvkShaderCreateInfo struct to retrieve shader info 2022-04-18 13:20:16 +02:00
Philip Rebohle 427f51eda7 [d3d9] Use new DxvkShader constructor for format conversion 2022-04-18 13:20:16 +02:00
Philip Rebohle 98ec79f6fa [d3d9] Use new DxvkShader constructor for SWVP emulation 2022-04-18 13:20:16 +02:00
Philip Rebohle ab95b61e44 [d3d9] Use new DxvkShader constructor for fixed-function shaders 2022-04-18 13:20:16 +02:00
Philip Rebohle 10bab0c182 [dxso] Use new DxvkShader constructor 2022-04-18 13:20:16 +02:00
Philip Rebohle 8993560cde [dxbc] Use new DxvkShader constructor 2022-04-18 13:20:16 +02:00
Philip Rebohle 81d88a484d [dxvk] Use new DxvkShader constructor for HUD shaders 2022-04-18 13:20:16 +02:00
Philip Rebohle 62e706a6bb [dxvk] Use new DxvkShader constructor for swap chain shaders 2022-04-18 13:20:16 +02:00
Philip Rebohle d0b52f3ac5 [dxvk] Use new DxvkShaderCreateInfo struct to retrieve shader info 2022-04-18 13:20:16 +02:00
Philip Rebohle b0db58f098 [dxvk] Introduce new way to create DxvkShader objects 2022-04-18 13:20:16 +02:00
Philip Rebohle 736f743ae4
[spirv] Implement faster in-memory compression for shaders
Seems to be anything up to 3x as fast to decode than the previous code,
with the compression ratio being slightly worse. Encoding seems faster
as well.
2022-04-11 02:55:12 +02:00
Blisto91 727ba89670 [util] remove allowLockFlagReadonly from conf 2022-04-09 19:44:50 +02:00
Blisto91 2e68b33abd [util] correct enableDebugUtils conf to default False 2022-04-09 19:44:50 +02:00
Blisto91 3672375bc1 [util] Use cached constant buffers for Armored Warfare 2022-04-09 15:19:49 +02:00
Robin Kertels 42c66c410e [d3d9] Calculate slice alignment when uploading straight from the mapping buffer 2022-04-06 18:52:58 +00:00
Paul Gofman 957a305ca8 [d3d9] Ignore multiple app activation window messages. 2022-04-06 18:51:50 +00:00
Paul Gofman b0ed9e30ce [d3d9] Filter window messages when processing WM_ACTIVATEAPP. 2022-04-06 18:51:50 +00:00
Robin Kertels ce87bec412 [util] Force sampler type spec const for Star Wars TFU2
The game tries to binda  2D texture to a slot that is declared
as a 3D texture in the shader. This causes one particle effect
to be completely black because DXVK does not bind the texture
2022-04-05 22:37:04 +00:00
Philip Rebohle 95a3413949
[util] Fix typo in app profiles
Accidentally broke everything.
2022-03-31 18:01:52 +02:00
Philip Rebohle e07157fe72
[d3d11] Only apply anisotropy override to linear samplers
Mirrors D3D9, more or less.
2022-03-30 14:37:33 +02:00
Philip Rebohle e7e7fa231c
[dxvk] GPU query reset path
Require VK_EXT_host_query_reset instead. This fallback path is
untested nowadays and too slow to be useful.
2022-03-30 13:32:18 +02:00
Robin Kertels 6a80b51dc3 [meta] Move apitrace guide over to dxvk repo 2022-03-29 21:33:08 +00:00
Georg Lehmann f0ccd8fe2e [util] Limit Limbo to 60 fps
Fixes: #2564
2022-03-28 21:39:28 +02:00
Derek Lesho d11f0ac77b [d3d11] Always export correct shared handle type from ::GetSharedHandle and ::CreateSharedHandle
Before we just assumed that the calls here would match the corresponding flag value (D3D11_RESOURCE_MISC_SHARED -> ::GetSharedHandle, D3D11_RESOURCE_MISC_SHARED_NTHANDLE -> ::CreateSharedHandle), but it turns out that its possible to set both flags and use both methods.  Now we always tell Vulkan to export a KMT handle if D3D11_RESOURCE_MISC_SHARED is present, and use openKmtHandle to get an NT handle when needed.
2022-03-28 21:38:42 +02:00
Philip Rebohle 1c3736da8c
[dxvk] Filter out unnecessary access flags when recording barriers
Rationale is as follows:
- srcAccess never needs to contain read flags, since any memory being
  read must have been made visible before by a write operation
- dstAccess is only relevant if srcAccess contains a write, because
  reads alone cannot modify memory and thus do not require making the
  same memory available again. An exception are layout transitions.

Doesn't really change performance in anything as far as I can tell, but
we avoid some unnecessary UBO cache flushes in compute-heavy scenarios.
2022-03-28 10:45:29 +02:00
Philip Rebohle ebdaf90fdc
[util] Enable d3d9.deferSurfaceCreation for Atelier Sophie 2
2022 and K-T are still using D3D9 for video stuff.
2022-03-28 04:37:02 +02:00
472 changed files with 42950 additions and 55675 deletions

View File

@ -7,14 +7,9 @@ assignees: ''
---
Please describe your issue as accurately as possible. If you run into a problem with a binary release, make sure to test with latest `master` as well.
Please describe your issue as accurately as possible.
**Important:** When reporting an issue with a specific game or application, such as crashes or rendering issues, please include log files and, if possible, a D3D11/D3D9 Apitrace (see https://github.com/apitrace/apitrace) so that the issue can be reproduced.
In order to create a trace for **D3D11/D3D10**: Run `wine apitrace.exe trace -a dxgi YOURGAME.exe`.
In order to create a trace for **D3D9**: Follow https://github.com/Joshua-Ashton/d9vk/wiki/Making-a-Trace.
Preferably record the trace on Windows, or wined3d if possible.
**Reports with no log files will be ignored.**
If you use Windows, please check the following page: https://github.com/doitsujin/dxvk/wiki/Windows
### Software information
Name of the game, settings used etc.
@ -28,7 +23,9 @@ Name of the game, settings used etc.
### Apitrace file(s)
- Put a link here
For instructions on how to use apitrace, see: https://github.com/doitsujin/dxvk/wiki/Using-Apitrace
### Log files
- d3d9.log:
- d3d11.log:
- dxgi.log:
Please attach Proton or Wine logs as a text file:
- When using Proton, set the Steam launch options for your game to `PROTON_LOG=1 %command%` and attach the corresponding `steam-xxxxx.log` file in your home directory.
- When using regular Wine, use `wine game.exe > game.log 2>&1` and attach the resulting `game.log` file.

View File

@ -3,23 +3,23 @@ name: Artifacts (Package)
on: [push, pull_request, workflow_dispatch]
jobs:
build-artifacts:
artifacts-mingw-w64:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
id: checkout-code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Setup problem matcher
uses: Joshua-Ashton/gcc-problem-matcher@v1
uses: Joshua-Ashton/gcc-problem-matcher@v2
- name: Build release
id: build-release
uses: Joshua-Ashton/arch-mingw-github-action@v7
uses: Joshua-Ashton/arch-mingw-github-action@v8
with:
command: |
export VERSION_NAME="${GITHUB_REF##*/}-${GITHUB_SHA##*/}"
@ -28,8 +28,39 @@ jobs:
- name: Upload artifacts
id: upload-artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: dxvk-${{ env.VERSION_NAME }}
path: build/dxvk-${{ env.VERSION_NAME }}
if-no-files-found: error
artifacts-steamrt-sniper:
runs-on: ubuntu-20.04
container: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:beta
steps:
- name: Checkout code
id: checkout-code
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Setup problem matcher
uses: Joshua-Ashton/gcc-problem-matcher@v2
- name: Build release
id: build-release
shell: bash
run: |
export VERSION_NAME="${GITHUB_REF##*/}-${GITHUB_SHA##*/}"
./package-native.sh ${VERSION_NAME} build --no-package
echo "VERSION_NAME=${VERSION_NAME}" >> $GITHUB_ENV
- name: Upload artifacts
id: upload-artifacts
uses: actions/upload-artifact@v3
with:
name: dxvk-${{ env.VERSION_NAME }}
path: build/dxvk-native-${{ env.VERSION_NAME }}
if-no-files-found: error

View File

@ -9,16 +9,15 @@ jobs:
steps:
- name: Checkout code
id: checkout-code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup glslangValidator
shell: pwsh
run: |
choco install vulkan-sdk -y
Write-Output "$([System.Environment]::GetEnvironmentVariable('VULKAN_SDK', 'Machine'))\Bin" `
| Out-File -FilePath "${Env:GITHUB_PATH}" -Append
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/HansKristian-Work/vkd3d-proton-ci/main/glslangValidator.exe" -OutFile "glslangValidator.exe"
Write-Output "$pwd" | Out-File -FilePath "${Env:GITHUB_PATH}" -Append
- name: Setup Meson
shell: pwsh

13
.gitmodules vendored Normal file
View File

@ -0,0 +1,13 @@
[submodule "include/native/directx"]
path = include/native/directx
url = https://github.com/Joshua-Ashton/mingw-directx-headers
[submodule "include/vulkan"]
path = include/vulkan
url = https://github.com/KhronosGroup/Vulkan-Headers
[submodule "include/spirv"]
path = include/spirv
url = https://github.com/KhronosGroup/SPIRV-Headers.git
[submodule "subprojects/libdisplay-info"]
path = subprojects/libdisplay-info
url = https://gitlab.freedesktop.org/JoshuaAshton/libdisplay-info.git
branch = windows

View File

@ -1,5 +1,5 @@
Copyright (c) 2017-2021 Philip Rebohle
Copyright (c) 2019-2021 Joshua Ashton
Copyright (c) 2017 Philip Rebohle
Copyright (c) 2019 Joshua Ashton
zlib/libpng license

View File

@ -9,34 +9,45 @@ The most recent development builds can be found [here](https://github.com/doitsu
Release builds can be found [here](https://github.com/doitsujin/dxvk/releases).
## How to use
In order to install a DXVK package obtained from the [release](https://github.com/doitsujin/dxvk/releases) page into a given wine prefix, run the following commands from within the DXVK directory:
In order to install a DXVK package obtained from the [release](https://github.com/doitsujin/dxvk/releases) page into a given wine prefix, copy or symlink the DLLs into the following directories as follows, then open `winecfg` and manually add DLL overrides for `d3d11`, `d3d10core`, `dxgi`, and `d3d9`.
In a default Wine prefix that would be as follows:
```
export WINEPREFIX=/path/to/.wine-prefix
./setup_dxvk.sh install
export WINEPREFIX=/path/to/wineprefix
cp x64/*.dll $WINEPREFIX/drive_c/windows/system32
cp x32/*.dll $WINEPREFIX/drive_c/windows/syswow64
winecfg
```
This will **copy** the DLLs into the `system32` and `syswow64` directories of your wine prefix and set up the required DLL overrides. Pure 32-bit prefixes are also supported.
The setup script optionally takes the following arguments:
- `--symlink`: Create symbolic links to the DLL files instead of copying them. This is especially useful for development.
- `--with-d3d10`: Install the `d3d10{_1}.dll` helper libraries.
- `--without-dxgi`: Do not install DXVK's DXGI implementation and use the one provided by wine instead.
Verify that your application uses DXVK instead of wined3d by checking for the presence of the log file `d3d9.log` or `d3d11.log` in the application's directory, or by enabling the HUD (see notes below).
In order to remove DXVK from a prefix, run the following command:
For a pure 32-bit Wine prefix (non default) the 32-bit DLLs instead go to the `system32` directory:
```
export WINEPREFIX=/path/to/.wine-prefix
./setup_dxvk.sh uninstall
export WINEPREFIX=/path/to/wineprefix
cp x32/*.dll $WINEPREFIX/drive_c/windows/system32
winecfg
```
Verify that your application uses DXVK instead of wined3d by enabling the HUD (see notes below).
In order to remove DXVK from a prefix, remove the DLLs and DLL overrides, and run `wineboot -u` to restore the original DLL files.
Tools such as Steam Play, Lutris, Bottles, Heroic Launcher, etc will automatically handle setup of dxvk on their own when enabled.
### Notes on Vulkan drivers
Before reporting an issue, please check the [Wiki](https://github.com/doitsujin/dxvk/wiki/Driver-support) page on the current driver status and make sure you run a recent enough driver version for your hardware.
## Build instructions
In order to pull in all submodules that are needed for building, clone the repository using the following command:
```
git clone --recursive https://github.com/doitsujin/dxvk.git
```
### Requirements:
- [wine 3.10](https://www.winehq.org/) or newer
- [Meson](https://mesonbuild.com/) build system (at least version 0.46)
- [Mingw-w64](https://www.mingw-w64.org) compiler and headers (at least version 8.0)
- [wine 7.1](https://www.winehq.org/) or newer
- [Meson](https://mesonbuild.com/) build system (at least version 0.49)
- [Mingw-w64](https://www.mingw-w64.org) compiler and headers (at least version 10.0)
- [glslang](https://github.com/KhronosGroup/glslang) compiler
### Building DLLs
@ -60,19 +71,21 @@ ninja install
```
# 64-bit build. For 32-bit builds, replace
# build-win64.txt with build-win32.txt
meson --cross-file build-win64.txt --buildtype release --prefix /your/dxvk/directory build.w64
meson setup --cross-file build-win64.txt --buildtype release --prefix /your/dxvk/directory build.w64
cd build.w64
ninja install
```
The D3D9, D3D10, D3D11 and DXGI DLLs will be located in `/your/dxvk/directory/bin`. Setup has to be done manually in this case.
### Notes on Vulkan drivers
Before reporting an issue, please check the [Wiki](https://github.com/doitsujin/dxvk/wiki/Driver-support) page on the current driver status and make sure you run a recent enough driver version for your hardware.
### Online multi-player games
Manipulation of Direct3D libraries in multi-player games may be considered cheating and can get your account **banned**. This may also apply to single-player games with an embedded or dedicated multiplayer portion. **Use at your own risk.**
### Logs
When used with Wine, DXVK will print log messages to `stderr`. Additionally, standalone log files can optionally be generated by setting the `DXVK_LOG_PATH` variable, where log files in the given directory will be called `app_d3d11.log`, `app_dxgi.log` etc., where `app` is the name of the game executable.
On Windows, log files will be created in the game's working directory by default, which is usually next to the game executable.
### HUD
The `DXVK_HUD` environment variable controls a HUD which can display the framerate and some stat counters. It accepts a comma-separated list of the following options:
- `devinfo`: Displays the name of the GPU and the driver version.
@ -81,6 +94,7 @@ The `DXVK_HUD` environment variable controls a HUD which can display the framera
- `submissions`: Shows the number of command buffers submitted per frame.
- `drawcalls`: Shows the number of draw calls and render passes per frame.
- `pipelines`: Shows the total number of graphics and compute pipelines.
- `descriptors`: Shows the number of descriptor pools and descriptor sets.
- `memory`: Shows the amount of device memory allocated and used.
- `gpuload`: Shows estimated GPU load. May be inaccurate.
- `version`: Shows DXVK version.
@ -89,6 +103,7 @@ The `DXVK_HUD` environment variable controls a HUD which can display the framera
- `compiler`: Shows shader compiler activity
- `samplers`: Shows the current number of sampler pairs used *[D3D9 Only]*
- `scale=x`: Scales the HUD by a factor of `x` (e.g. `1.5`)
- `opacity=y`: Adjusts the HUD opacity by a factor of `y` (e.g. `0.5`, `1.0` being fully opaque).
Additionally, `DXVK_HUD=1` has the same effect as `DXVK_HUD=devinfo,fps`, and `DXVK_HUD=full` enables all available HUD elements.
@ -101,20 +116,34 @@ Some applications do not provide a method to select a different GPU. In that cas
**Note:** If the device filter is configured incorrectly, it may filter out all devices and applications will be unable to create a D3D device.
### Graphics Pipeline Library
On drivers which support `VK_EXT_graphics_pipeline_library` Vulkan shaders will be compiled at the time the game loads its D3D shaders, rather than at draw time. This reduces or eliminates shader compile stutter in many games when compared to the previous system.
In games that load their shaders during loading screens or in the menu, this can lead to prolonged periods of very high CPU utilization, especially on weaker CPUs. For affected games it is recommended to wait for shader compilation to finish before starting the game to avoid stutter and low performance. Shader compiler activity can be monitored with `DXVK_HUD=compiler`.
This feature largely replaces the state cache.
**Note:** Games which only load their D3D shaders at draw time (e.g. most Unreal Engine games) will still exhibit some stutter, although it should still be less severe than without this feature.
### State cache
DXVK caches pipeline state by default, so that shaders can be recompiled ahead of time on subsequent runs of an application, even if the driver's own shader cache got invalidated in the meantime. This cache is enabled by default, and generally reduces stuttering.
The following environment variables can be used to control the cache:
- `DXVK_STATE_CACHE=0` Disables the state cache.
- `DXVK_STATE_CACHE`: Controls the state cache. The following values are supported:
- `disable`: Disables the cache entirely.
- `reset`: Clears the cache file.
- `DXVK_STATE_CACHE_PATH=/some/directory` Specifies a directory where to put the cache files. Defaults to the current working directory of the application.
This feature is mostly only relevant on systems without support for `VK_EXT_graphics_pipeline_library`
### Debugging
The following environment variables can be used for **debugging** purposes.
- `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` Enables Vulkan debug layers. Highly recommended for troubleshooting rendering issues and driver crashes. Requires the Vulkan SDK to be installed on the host system.
- `DXVK_LOG_LEVEL=none|error|warn|info|debug` Controls message logging.
- `DXVK_LOG_PATH=/some/directory` Changes path where log files are stored. Set to `none` to disable log file creation entirely, without disabling logging.
- `DXVK_DEBUG=markers|validation` Enables use of the `VK_EXT_debug_utils` extension for translating performance event markers, or to enable Vulkan validation, respecticely.
- `DXVK_CONFIG_FILE=/xxx/dxvk.conf` Sets path to the configuration file.
- `DXVK_PERF_EVENTS=1` Enables use of the VK_EXT_debug_utils extension for translating performance event markers.
- `DXVK_CONFIG="dxgi.hideAmdGpu = True; dxgi.syncInterval = 0"` Can be used to set config variables through the environment instead of a configuration file using the same syntax. `;` is used as a seperator.
## Troubleshooting
DXVK requires threading support from your mingw-w64 build environment. If you
@ -134,3 +163,22 @@ For non debian based distros, make sure that your mingw-w64-gcc cross compiler
does have `--enable-threads=posix` enabled during configure. If your distro does
ship its mingw-w64-gcc binary with `--enable-threads=win32` you might have to
recompile locally or open a bug at your distro's bugtracker to ask for it.
# DXVK Native
DXVK Native is a version of DXVK which allows it to be used natively without Wine.
This is primarily useful for game and application ports to either avoid having to write another rendering backend, or to help with port bringup during development.
[Release builds](https://github.com/doitsujin/dxvk/releases) are built using the Steam Runtime.
### How does it work?
DXVK Native replaces certain Windows-isms with a platform and framework-agnostic replacement, for example, `HWND`s can become `SDL_Window*`s, etc.
All it takes to do that is to add another WSI backend.
**Note:** DXVK Native requires a backend to be explicitly set via the `DXVK_WSI_DRIVER` environment variable. The current built-in options are `SDL2` and `GLFW`.
DXVK Native comes with a slim set of Windows header definitions required for D3D9/11 and the MinGW headers for D3D9/11.
In most cases, it will end up being plug and play with your renderer, but there may be certain teething issues such as:
- `__uuidof(type)` is supported, but `__uuidof(variable)` is not supported. Use `__uuidof_var(variable)` instead.

View File

@ -1 +1 @@
1.10.1
2.3.1

415
VP_DXVK_requirements.json Normal file
View File

@ -0,0 +1,415 @@
{
"$schema": "https://schema.khronos.org/vulkan/profiles-0.8.1-224.json#",
"capabilities": {
"vulkan10requirements": {
"features": {
"VkPhysicalDeviceFeatures": {
"robustBufferAccess": true
}
}
},
"vulkan11requirements": {
"features": {
"VkPhysicalDeviceVulkan11Features": {
"multiview": true
}
},
"properties": {
"VkPhysicalDeviceVulkan11Properties": {
"maxMultiviewViewCount": 6,
"maxMultiviewInstanceIndex": 134217727
}
}
},
"vulkan12requirements": {
"features": {
"VkPhysicalDeviceVulkan12Features": {
"uniformBufferStandardLayout": true,
"subgroupBroadcastDynamicId": true,
"imagelessFramebuffer": true,
"separateDepthStencilLayouts": true,
"hostQueryReset": true,
"timelineSemaphore": true,
"shaderSubgroupExtendedTypes": true
}
},
"properties": {
"VkPhysicalDeviceVulkan12Properties": {
"maxTimelineSemaphoreValueDifference": 2147483647
}
}
},
"vulkan13requirements": {
"features": {
"VkPhysicalDeviceVulkan12Features": {
"vulkanMemoryModel": true,
"vulkanMemoryModelDeviceScope": true,
"bufferDeviceAddress": true
},
"VkPhysicalDeviceVulkan13Features": {
"robustImageAccess": true,
"shaderTerminateInvocation": true,
"shaderZeroInitializeWorkgroupMemory": true,
"synchronization2": true,
"shaderIntegerDotProduct": true,
"maintenance4": true,
"pipelineCreationCacheControl": true,
"subgroupSizeControl": true,
"computeFullSubgroups": true,
"shaderDemoteToHelperInvocation": true,
"inlineUniformBlock": true,
"dynamicRendering": true
}
},
"properties": {
"VkPhysicalDeviceVulkan13Properties": {
"maxBufferSize": 1073741824,
"maxInlineUniformBlockSize": 256,
"maxPerStageDescriptorInlineUniformBlocks": 4,
"maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks": 4,
"maxDescriptorSetInlineUniformBlocks": 4,
"maxDescriptorSetUpdateAfterBindInlineUniformBlocks": 4,
"maxInlineUniformTotalSize": 4
}
}
},
"d3d9_baseline": {
"extensions": {
"VK_EXT_robustness2": 1
},
"features": {
"VkPhysicalDeviceFeatures": {
"geometryShader": true,
"imageCubeArray": true,
"depthClamp": true,
"depthBiasClamp": true,
"fillModeNonSolid": true,
"sampleRateShading": true,
"shaderClipDistance": true,
"shaderCullDistance": true,
"textureCompressionBC": true,
"occlusionQueryPrecise": true,
"independentBlend": true,
"fullDrawIndexUint32": true,
"shaderImageGatherExtended": true
},
"VkPhysicalDeviceVulkan12Features": {
"samplerMirrorClampToEdge": true
},
"VkPhysicalDeviceRobustness2FeaturesEXT": {
"nullDescriptor": true,
"robustBufferAccess2": true
}
}
},
"d3d9_optional": {
"extensions": {
"VK_EXT_memory_priority": 1,
"VK_EXT_vertex_attribute_divisor": 1,
"VK_EXT_depth_clip_enable": 1,
"VK_EXT_custom_border_color": 1,
"VK_EXT_attachment_feedback_loop_layout": 1,
"VK_EXT_non_seamless_cube_map": 1
},
"features": {
"VkPhysicalDeviceFeatures": {
"depthBounds": true,
"vertexPipelineStoresAndAtomics": true,
"pipelineStatisticsQuery": true,
"samplerAnisotropy": true
},
"VkPhysicalDeviceMemoryPriorityFeaturesEXT": {
"memoryPriority": true
},
"VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT": {
"vertexAttributeInstanceRateDivisor": true,
"vertexAttributeInstanceRateZeroDivisor": true
},
"VkPhysicalDeviceDepthClipEnableFeaturesEXT": {
"depthClipEnable": true
},
"VkPhysicalDeviceCustomBorderColorFeaturesEXT": {
"customBorderColors": true,
"customBorderColorWithoutFormat": true
},
"VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT": {
"attachmentFeedbackLoopLayout": true
},
"VkPhysicalDeviceNonSeamlessCubeMapFeaturesEXT": {
"nonSeamlessCubeMap": true
}
}
},
"d3d11_baseline": {
"extensions": {
"VK_EXT_robustness2": 1,
"VK_EXT_transform_feedback": 1
},
"features": {
"VkPhysicalDeviceFeatures": {
"depthBiasClamp": true,
"depthClamp": true,
"dualSrcBlend": true,
"fillModeNonSolid": true,
"fullDrawIndexUint32": true,
"geometryShader": true,
"imageCubeArray": true,
"independentBlend": true,
"multiViewport": true,
"occlusionQueryPrecise": true,
"sampleRateShading": true,
"shaderClipDistance": true,
"shaderCullDistance": true,
"shaderImageGatherExtended": true,
"textureCompressionBC": true
},
"VkPhysicalDeviceVulkan11Features": {
"shaderDrawParameters": true
},
"VkPhysicalDeviceVulkan12Features": {
"samplerMirrorClampToEdge": true
},
"VkPhysicalDeviceRobustness2FeaturesEXT": {
"nullDescriptor": true,
"robustBufferAccess2": true
},
"VkPhysicalDeviceTransformFeedbackFeaturesEXT": {
"transformFeedback": true,
"geometryStreams": true
}
}
},
"d3d11_baseline_optional":{
"extensions": {
"VK_EXT_memory_priority": 1,
"VK_EXT_vertex_attribute_divisor": 1,
"VK_EXT_custom_border_color": 1,
"VK_EXT_depth_clip_enable": 1,
"VK_EXT_swapchain_colorspace": 1,
"VK_EXT_hdr_metadata": 1
},
"features": {
"VkPhysicalDeviceFeatures": {
"depthBounds": true,
"pipelineStatisticsQuery": true,
"logicOp": true,
"samplerAnisotropy": true
},
"VkPhysicalDeviceMemoryPriorityFeaturesEXT": {
"memoryPriority": true
},
"VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT": {
"vertexAttributeInstanceRateDivisor": true,
"vertexAttributeInstanceRateZeroDivisor": true
},
"VkPhysicalDeviceCustomBorderColorFeaturesEXT": {
"customBorderColors": true,
"customBorderColorWithoutFormat": true
},
"VkPhysicalDeviceDepthClipEnableFeaturesEXT": {
"depthClipEnable": true
}
}
},
"d3d11_level11_0": {
"features": {
"VkPhysicalDeviceFeatures": {
"drawIndirectFirstInstance": true,
"fragmentStoresAndAtomics": true,
"multiDrawIndirect": true,
"tessellationShader": true
}
}
},
"d3d11_level11_0_optional": {
"features": {
"VkPhysicalDeviceFeatures": {
"shaderFloat64": true,
"shaderInt64": true
}
}
},
"d3d11_level11_1": {
"features": {
"VkPhysicalDeviceFeatures": {
"logicOp": true,
"vertexPipelineStoresAndAtomics": true
}
}
},
"d3d11_level12_0": {
"features": {
"VkPhysicalDeviceFeatures": {
"shaderResourceResidency": true,
"shaderResourceMinLod": true,
"sparseBinding": true,
"sparseResidencyBuffer": true,
"sparseResidencyAliased": true,
"sparseResidencyImage2D": true
},
"VkPhysicalDeviceVulkan12Features": {
"samplerFilterMinmax": true
}
},
"properties": {
"VkPhysicalDeviceProperties": {
"sparseProperties": {
"residencyStandard2DBlockShape": true,
"residencyAlignedMipSize": false,
"residencyNonResidentStrict": true
}
}
}
}
},
"profiles": {
"VP_DXVK_d3d9_baseline": {
"version": 1,
"api-version": "1.3.204",
"label": "DXVK D3D9 Baseline profile",
"description": "DXVK for D3D9 minimum requirements",
"capabilities": [
"vulkan10requirements",
"vulkan11requirements",
"vulkan12requirements",
"vulkan13requirements",
"d3d9_baseline"
]
},
"VP_DXVK_d3d9_optimal": {
"version": 1,
"api-version": "1.3.224",
"label": "DXVK D3D9 Optimal profile",
"description": "DXVK for D3D9 including optional capabilities",
"capabilities": [
"vulkan10requirements",
"vulkan11requirements",
"vulkan12requirements",
"vulkan13requirements",
"d3d9_baseline",
"d3d9_optional"
]
},
"VP_DXVK_d3d10_level_10_1_baseline": {
"version": 1,
"api-version": "1.3.204",
"label": "DXVK D3D10 Level 10.1 Baseline profile",
"description": "DXVK for D3D10 Feature Level 10.1 minimum requirements",
"capabilities": [
"vulkan10requirements",
"vulkan11requirements",
"vulkan12requirements",
"vulkan13requirements",
"d3d11_baseline"
]
},
"VP_DXVK_d3d11_level_11_0_baseline": {
"version": 1,
"api-version": "1.3.204",
"label": "DXVK D3D11 Level 11.0 Baseline profile",
"description": "DXVK for D3D11 Feature Level 11.0 minimum requirements",
"capabilities": [
"vulkan10requirements",
"vulkan11requirements",
"vulkan12requirements",
"vulkan13requirements",
"d3d11_baseline",
"d3d11_level11_0"
]
},
"VP_DXVK_d3d11_level_11_1_baseline": {
"version": 1,
"api-version": "1.3.204",
"label": "DXVK D3D11 Level 11.1 Baseline profile",
"description": "DXVK for D3D11 Feature Level 11.1 minimum requirements",
"capabilities": [
"vulkan10requirements",
"vulkan11requirements",
"vulkan12requirements",
"vulkan13requirements",
"d3d11_baseline",
"d3d11_level11_0",
"d3d11_level11_1"
]
},
"VP_DXVK_d3d11_level_11_1_optimal": {
"version": 1,
"api-version": "1.3.204",
"label": "DXVK D3D11 Level 11.1 Optimal profile",
"description": "DXVK for D3D11 Feature Level 11.1 including optional capabilities",
"capabilities": [
"vulkan10requirements",
"vulkan11requirements",
"vulkan12requirements",
"vulkan13requirements",
"d3d11_baseline",
"d3d11_baseline_optional",
"d3d11_level11_0",
"d3d11_level11_0_optional",
"d3d11_level11_1"
]
},
"VP_DXVK_d3d11_level_12_0_optimal": {
"version": 1,
"api-version": "1.3.204",
"label": "DXVK D3D11 Level 12.0 Optimal profile",
"description": "DXVK for D3D11 Feature Level 12.0 including optional capabilities",
"capabilities": [
"vulkan10requirements",
"vulkan11requirements",
"vulkan12requirements",
"vulkan13requirements",
"d3d11_baseline",
"d3d11_baseline_optional",
"d3d11_level11_0",
"d3d11_level11_0_optional",
"d3d11_level11_1",
"d3d11_level12_0"
]
}
},
"contributors": {
"Philip Rebohle": {
"company": "Valve"
},
"Joshua Ashton": {
"company": "Valve"
},
"Pierre-Loup A. Griffais": {
"company": "Valve"
},
"Georg Lehmann": {
"company": "DXVK"
},
"Christophe Riccio": {
"company": "LunarG"
}
},
"history": [
{
"revision": 4,
"date": "2022-12-18",
"author": "Joshua Ashton",
"comment": "Add VK_EXT_swapchain_colorspace and VK_EXT_hdr_metadata to d3d11_baseline_optional"
},
{
"revision": 3,
"date": "2022-10-13",
"author": "Christophe Riccio",
"comment": "Factorize history and contributors sections using schema 0.8.1"
},
{
"revision": 2,
"date": "2022-08-30",
"author": "Philip Rebohle",
"comment": "Add VP_DXVK_d3d11_level_12_0_optimal profile"
},
{
"revision": 1,
"date": "2022-08-22",
"author": "Christophe Riccio",
"comment": "Initial revision"
}
]
}

313
dxvk.conf
View File

@ -1,3 +1,15 @@
# Expose the HDR10 ColorSpace (DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020)
# to the application by default.
# This shows to the game that the global Windows 'HDR Mode' is enabled.
# Many (broken) games will need this to be set to consider exposing HDR output
# as determine it based on the DXGIOutput's current ColorSpace instead of
# using CheckColorSpaceSupport.
# This defaults to the value of the DXVK_HDR environment variable.
#
# Supported values: True, False
# dxgi.enableHDR = True
# Create the VkSurface on the first call to IDXGISwapChain::Present,
# rather than when creating the swap chain. Some games that start
# rendering with a different graphics API may require this option,
@ -19,9 +31,10 @@
# d3d9.maxFrameLatency = 0
# Enables a frame rate limiter, unless the game is already
# limited to the same refresh rate by vertical synchronization.
#
# Enables frame rate limiter. The main purpose of this is to work around
# bugs in games that have physics or other simulation tied to their frame
# rate, but do not provide their own limiter.
#
# Supported values : Any non-negative integer
# dxgi.maxFrameRate = 0
@ -48,18 +61,43 @@
# d3d9.customDeviceDesc = ""
# Report Nvidia GPUs as AMD GPUs by default. This is enabled by default
# to work around issues with NVAPI, but may cause issues in some games.
# Report Nvidia GPUs as AMD GPUs. Unless NVAPI support is explicitly
# enabled through Proton, this is done by default in order to work
# around crashes or low performance with Nvidia-speciic code paths
# in games, especially Unreal Engine.
#
# Supported values: True, False
# Supported values: Auto, True, False
# dxgi.nvapiHack = True
# dxgi.hideNvidiaGpu = Auto
# Report Nvidia GPUs running on NVK as AMD GPUs.
#
# Supported values: Auto, True, False
# dxgi.hideNvkGpu = Auto
# Report AMD GPUs as Nvidia GPUs. This is only done for games that are
# known to have issues with AMDAGS or other AMD-specific code paths.
#
# Supported values: Auto, True, False
# dxgi.hideAmdGpu = Auto
# Report Intel GPUs as AMD GPUs. This is only done for games that are
# known to have issues with Intel-specific libraries such as XESS.
#
# Supported values: Auto, True, False
# dxgi.hideIntelGpu = Auto
# Override maximum amount of device memory and shared system memory
# reported to the application. This may fix texture streaming issues
# in games that do not support cards with large amounts of VRAM.
# This is not a hard cap and applications can choose to ignore it.
#
# Supported values: Any number in Megabytes.
@ -109,17 +147,7 @@
#
# Supported values: Auto, True, False
# dxgi.tearFree = Auto
# d3d9.tearFree = Auto
# Performs range check on dynamically indexed constant buffers in shaders.
# This may be needed to work around a certain type of game bug, but may
# also introduce incorrect behaviour.
#
# Supported values: True, False
# d3d11.constantBufferRangeCheck = False
# dxvk.tearFree = Auto
# Assume single-use mode for command lists created on deferred contexts.
@ -135,9 +163,9 @@
# with. Setting this to a higher value may allow some applications to run
# that would otherwise fail to create a D3D11 device.
#
# Supported values: 9_1, 9_2, 9_3, 10_0, 10_1, 11_0, 11_1
# Supported values: 9_1, 9_2, 9_3, 10_0, 10_1, 11_0, 11_1, 12_0, 12_1
# d3d11.maxFeatureLevel = 11_1
# d3d11.maxFeatureLevel = 12_1
# Overrides the maximum allowed tessellation factor. This can be used to
@ -178,13 +206,43 @@
# d3d9.samplerAnisotropy = -1
# Changes the mipmap LOD bias for all samplers. The given number will be
# added to the LOD bias provided by the application, rather than replacing
# it entirely. Positive values will reduce texture detail, while negative
# values may increase sharpness at the cost of shimmer.
#
# Supported values: Any number between -2.0 and 1.0
# d3d11.samplerLodBias = 0.0
# d3d9.samplerLodBias = 0.0
# Clamps any negative LOD bias to 0. Applies after samplerLodBias has been
# applied. May help with games that use a high negative LOD bias by default.
#
# Supported values: True, False
# d3d11.clampNegativeLodBias = False
# d3d9.clampNegativeLodBias = False
# Declares vertex positions as invariant in order to solve
# potential Z-fighting issues at a small performance cost.
#
# Supported values: True, False
# d3d11.invariantPosition = True
# d3d9.invariantPosition = False
# d3d9.invariantPosition = True
# Forces per-sample rate shading when MSAA is enabled, rather than per-pixel
# shading. May improve visual clarity at a significant performance cost, but
# may also introduce visual issues in some games.
#
# Supported values: True, False
# d3d11.forceSampleRateShading = False
# d3d9.forceSampleRateShading = False
# Forces the sample count of all textures to 1, and performs
@ -234,10 +292,34 @@
# d3d11.cachedDynamicResources = ""
# Force-enables the D3D11 context lock via the ID3D10Multithread
# interface. This may be useful to debug race conditions.
#
# Supported values: True, False
# d3d11.enableContextLock = False
# Exposes or hides support for driver command lists
#
# Some games use the feature flag to decide whether to use deferred
# contexts or not. We enable this by default, but in some situations
# this can lead to issues if games detect an AMD GPU where command
# lists are not natively supported on Windows.
#
# Supported values: True, False
# d3d11.exposeDriverCommandLists = True
# Sets number of pipeline compiler threads.
#
# If the graphics pipeline library feature is enabled, the given
# number of threads will be used for shader compilation. Some of
# these threads will be reserved for high-priority work.
#
# Supported values:
# - 0 to automatically determine the number of threads to use
# - 0 to use all available CPU cores
# - any positive number to enforce the thread count
# dxvk.numCompilerThreads = 0
@ -258,18 +340,43 @@
# dxvk.useRawSsbo = Auto
# Controls Nvidia HVV behaviour.
# Changes memory chunk size.
#
# Disables the host-visible, device-local heap on Nvidia drivers. This
# is used to avoid NVIDIA driver bug 3114283 on affected drivers, as
# well as in specific games on newer drivers.being enabled on all
# affected drivers.
# Can be used to override the maximum memory chunk size.
#
# Supported values:
# - Auto: Don't change the default
# - True, False: Always enable / disable
# - 0 to use the defaults
# - any positive integer to limit the chunk size, in MiB
# dxvk.shrinkNvidiaHvvHeap = Auto
# dxvk.maxChunkSize = 0
# Controls graphics pipeline library behaviour
#
# Can be used to change VK_EXT_graphics_pipeline_library usage for
# debugging purpose. Doing so will likely result in increased stutter
# or degraded performance.
#
# Supported values:
# - Auto: Enable if supported, and compile optimized pipelines in the background
# - True: Enable if supported, but do not compile optimized pipelines
# - False: Always disable the feature
# dxvk.enableGraphicsPipelineLibrary = Auto
# Controls pipeline lifetime tracking
#
# If enabled, pipeline libraries will be freed aggressively in order
# save memory and address space. Has no effect if graphics pipeline
# libraries are not supported or disabled.
#
# Supported values:
# - Auto: Enable tracking for 32-bit applications only
# - True: Always enable tracking
# - False: Always disable tracking
# dxvk.trackPipelineLifetime = Auto
# Sets enabled HUD elements
@ -294,17 +401,6 @@
# d3d9.shaderModel = 3
# Evict Managed on Unlock
#
# Decides whether we should evict managed resources from
# system memory when they are unlocked entirely.
#
# Supported values:
# - True, False: Always enable / disable
# d3d9.evictManagedOnUnlock = False
# DPI Awareness
#
# Decides whether we should call SetProcessDPIAware on device
@ -403,18 +499,9 @@
# Supported values:
# - True/False
# d3d11.longMad = False
# d3d9.longMad = False
# Alpha Test Wiggle Room
#
# Workaround for games using alpha test == 1.0, etc due to wonky interpolation or
# misc. imprecision on some vendors
#
# Supported values:
# - True/False
# d3d9.alphaTestWiggleRoom = False
# Device Local Constant Buffers
#
# Enables using device local, host accessible memory for constant buffers in D3D9.
@ -426,38 +513,30 @@
# d3d9.deviceLocalConstantBuffers = False
# Allow Read Only
#
# Enables using the D3DLOCK_READONLY flag. Some apps use this
# incorrectly, and write when they should be reading.
#
# Supported values:
# - True/False
# d3d9.allowLockFlagReadonly = True
# No Explicit Front Buffer
#
# Disables the front buffer
#
# Supported values:
# - True/False
# d3d9.noExplicitFrontBuffer = False
# Support DF formats
#
# Support the vendor extension DF floating point depth formats
# Support the vendor extension DF floating point depth formats on AMD and Intel.
# Note that this config is ignored and disabled by default on Nvidia, or when
# spoofing a Nvidia GPU, as it does not support these formats natively.
#
# Supported values:
# - True/False
# d3d9.supportDFFormats = True
# Use D32f for D24
#
# Useful for reproducing AMD issues on other hw.
#
# Supported values:
# - True/False
# d3d9.useD32forD24 = False
# Support X4R4G4B4
#
# Support the X4R4G4B4 format.
# The Sims 2 is a horrible game made by complete morons.
# The Sims 2 is a very broken game.
#
# Supported values:
# - True/False
@ -476,7 +555,7 @@
# Disable A8 as a Render Target
#
# Disable support for A8 format render targets
# Once again, The Sims 2 is a horrible game made by complete morons.
# Once again, The Sims 2 is a very broken game.
#
# Supported values:
# - True/False
@ -516,26 +595,6 @@
# d3d9.forceAspectRatio = ""
# Allow Do Not Wait
#
# Allow the do not wait lock flag to be used
# Useful if some apps use this incorrectly.
#
# Supported values:
# - True/False
# d3d9.allowDoNotWait = True
# Allow Discard
#
# Allow the discard lock flag to be used
# Useful if some apps use this incorrectly.
#
# Supported values:
# - True/False
# d3d9.allowDiscard = True
# Enumerate by Displays
#
# Whether we should enumerate D3D9 adapters by display (windows behaviour)
@ -547,23 +606,77 @@
# d3d9.enumerateByDisplays = True
# APITrace Mode
# Cached Dynamic Buffers
#
# Makes all host visible buffers cached and coherent
# Improves performance when apitracing, but also can impact
# some dumb games.
# Allocates dynamic resources in D3DPOOL_DEFAULT in
# cached system memory rather than uncached memory or host-visible
# VRAM, in order to allow fast readback from the CPU. This is only
# useful for buggy applications, and may reduce GPU-bound performance.
#
# Supported values:
# - True/False
# d3d9.apitraceMode = False
# d3d9.cachedDynamicBuffers = False
# Seamless Cubes
#
# Don't use non seamless cube maps even if they are supported.
# Non seamless cubes are correct d3d9 behavior, but can produce worse looking edges.
#
# Supported values:
# - True/False
# d3d9.seamlessCubes = False
# Debug Utils
#
# Enables debug utils as this is off by default, this enables user annotations like BeginEvent()/EndEvent().
# Alternatively could be enabled with DXVK_PERF_EVENTS=1 environment variable.
# Alternatively could be enabled with DXVK_DEBUG=markers environment variable.
#
# Supported values:
# - True/False
# dxvk.enableDebugUtils = True
# dxvk.enableDebugUtils = False
# Memory limit for locked D3D9 textures
#
# How much virtual memory will be used for textures (in MB).
# 0 to disable the limit.
# THIS DOES NOT IMPACT ACTUAL MEMORY CONSUMPTION OR TEXTURE QUALITY.
# DO NOT CHANGE THIS UNLESS YOU HAVE A VERY GOOD REASON.
# d3d9.textureMemory = 100
# Hide integrated graphics from applications
#
# Only has an effect when dedicated GPUs are present on the system. It is
# not recommended to use this option at all unless absolutely necessary for
# a game to work; prefer using DXVK_FILTER_DEVICE_NAME whenever possible.
#
# Supported values:
# - True/False
# dxvk.hideIntegratedGraphics = False
# Trigger DEVICELOST when losing focus
#
# D3D9 requires the application to call Device::Reset after
# it loses focus in fullscreen.
# Some games rely on observing a D3DERR_DEVICELOST or D3DERR_NOTRESET.
# Others don't handle it correctly.
#
# Supported values:
# - True/False
# d3d9.deviceLossOnFocusLoss = False
# Reject Device::Reset if any losable resource is still alive
#
# D3D9 rejects Device::Reset if there's still any alive resources of specific types.
# (State blocks, additional swapchains, D3DPOOL_DEFAULT resources)
# Some games leak resources leading to a hang.
#
# Supported values:
# - True/False
# d3d9.countLosableResources = True

@ -0,0 +1 @@
Subproject commit 9df86f2341616ef1888ae59919feaa6d4fad693d

View File

@ -0,0 +1,3 @@
#pragma once
// Don't care.

View File

@ -0,0 +1,3 @@
#pragma once
// Don't care.

View File

@ -0,0 +1,3 @@
#pragma once
// Don't care.

View File

@ -0,0 +1,3 @@
#pragma once
// Don't care.

View File

@ -0,0 +1,8 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#if !(defined(lint) || defined(RC_INVOKED))
#pragma pack(pop)
#endif

View File

@ -0,0 +1,8 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#if !(defined(lint) || defined(RC_INVOKED))
#pragma pack(push,4)
#endif

View File

@ -0,0 +1,3 @@
#pragma once
// Don't care.

View File

@ -0,0 +1,3 @@
#pragma once
// Don't care.

View File

@ -0,0 +1,52 @@
#pragma once
#include "windows_base.h"
typedef interface IUnknown IUnknown;
DEFINE_GUID(IID_IUnknown, 0x00000000,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46)
#ifdef __cplusplus
struct IUnknown {
public:
virtual HRESULT QueryInterface(REFIID riid, void** ppvObject) = 0;
template<class Q>
HRESULT STDMETHODCALLTYPE QueryInterface(Q **pp) {
return QueryInterface(__uuidof(Q), (void **)pp);
}
virtual ULONG AddRef() = 0;
virtual ULONG Release() = 0;
};
#else
typedef struct IUnknownVtbl
{
BEGIN_INTERFACE
HRESULT (STDMETHODCALLTYPE *QueryInterface)(
IUnknown *This,
REFIID riid,
void **ppvObject
);
ULONG (STDMETHODCALLTYPE *AddRef)(IUnknown *This);
ULONG (STDMETHODCALLTYPE *Release)(IUnknown *This);
END_INTERFACE
} IUnknownVtbl;
interface IUnknown
{
CONST_VTBL struct IUnknownVtbl *lpVtbl;
};
#define IUnknown_AddRef(This) ((This)->lpVtbl->AddRef(This))
#define IUnknown_Release(This) ((This)->lpVtbl->Release(This))
#endif // __cplusplus
DECLARE_UUIDOF_HELPER(IUnknown, 0x00000000,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46)
#define IID_PPV_ARGS(ppType) __uuidof(decltype(**(ppType))), [](auto** pp) { (void)static_cast<IUnknown*>(*pp); return reinterpret_cast<void**>(pp); }(ppType)

View File

@ -0,0 +1,4 @@
#pragma once
#include "windows_base.h"
#include "unknwn.h"

View File

@ -0,0 +1,398 @@
#pragma once
#ifdef __cplusplus
#include <cstdint>
#include <cstring>
#else
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#endif // __cplusplus
// GCC complains about the COM interfaces
// not having virtual destructors
// and class conversion for C...DESC helper types
#if defined(__GNUC__) && defined(__cplusplus)
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#pragma GCC diagnostic ignored "-Wclass-conversion"
#endif // __GNUC__ && __cplusplus
typedef int32_t INT;
typedef uint32_t UINT;
typedef int32_t LONG;
typedef uint32_t ULONG;
typedef int32_t *LPLONG;
typedef int32_t HRESULT;
typedef wchar_t WCHAR;
typedef WCHAR *NWPSTR, *LPWSTR, *PWSTR;
typedef unsigned char UCHAR, *PUCHAR;
typedef char CHAR;
typedef const CHAR *LPCSTR, *PCSTR;
typedef INT BOOL;
typedef BOOL WINBOOL;
typedef uint16_t UINT16;
typedef uint32_t UINT32;
typedef uint64_t UINT64;
typedef void VOID;
typedef void* PVOID;
typedef void* LPVOID;
typedef const void* LPCVOID;
typedef size_t SIZE_T;
typedef int8_t INT8;
typedef uint8_t UINT8;
typedef uint8_t BYTE;
typedef int16_t SHORT;
typedef uint16_t USHORT;
typedef int64_t LONGLONG;
typedef int64_t INT64;
typedef uint64_t ULONGLONG;
typedef uint64_t UINT64;
typedef intptr_t LONG_PTR;
typedef uintptr_t ULONG_PTR;
typedef float FLOAT;
#ifndef GUID_DEFINED
#define GUID_DEFINED
typedef struct GUID {
uint32_t Data1;
uint16_t Data2;
uint16_t Data3;
uint8_t Data4[8];
} GUID;
#endif // GUID_DEFINED
typedef GUID UUID;
typedef GUID IID;
#ifdef __cplusplus
#define REFIID const IID&
#define REFGUID const GUID&
#define REFCLSID const GUID&
#else
#define REFIID const IID*
#define REFGUID const GUID*
#define REFCLSID const GUID* const
#endif // __cplusplus
#ifdef __cplusplus
template <typename T>
constexpr GUID __uuidof_helper();
#define __uuidof(T) __uuidof_helper<T>()
#define __uuidof_var(T) __uuidof_helper<decltype(T)>()
inline bool operator==(const GUID& a, const GUID& b) { return std::memcmp(&a, &b, sizeof(GUID)) == 0; }
inline bool operator!=(const GUID& a, const GUID& b) { return std::memcmp(&a, &b, sizeof(GUID)) != 0; }
#endif // __cplusplus
typedef uint32_t DWORD;
typedef uint16_t WORD;
typedef DWORD *LPDWORD;
typedef void* HANDLE;
typedef HANDLE HMONITOR;
typedef HANDLE HDC;
typedef HANDLE HMODULE;
typedef HANDLE HINSTANCE;
typedef HANDLE HWND;
typedef HANDLE HKEY;
typedef HANDLE *LPHANDLE;
typedef DWORD COLORREF;
#if INTPTR_MAX == INT64_MAX
typedef int64_t INT_PTR;
typedef uint64_t UINT_PTR;
#else
typedef int32_t INT_PTR;
typedef uint32_t UINT_PTR;
#endif
typedef INT_PTR* PINT_PTR;
typedef UINT_PTR* PUINT_PTR;
#ifdef STRICT
#define DECLARE_HANDLE(a) typedef struct a##__ { int unused; } *a
#else /*STRICT*/
#define DECLARE_HANDLE(a) typedef HANDLE a
#endif /*STRICT*/
typedef char* LPSTR;
typedef wchar_t* LPWSTR;
typedef const char* LPCSTR;
typedef const wchar_t* LPCWSTR;
typedef struct LUID {
DWORD LowPart;
LONG HighPart;
} LUID;
typedef struct POINT {
LONG x;
LONG y;
} POINT;
typedef POINT* LPPOINT;
typedef struct RECT {
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT,*PRECT,*NPRECT,*LPRECT;
typedef struct SIZE {
LONG cx;
LONG cy;
} SIZE,*PSIZE,*LPSIZE;
typedef union {
struct {
DWORD LowPart;
LONG HighPart;
};
struct {
DWORD LowPart;
LONG HighPart;
} u;
LONGLONG QuadPart;
} LARGE_INTEGER;
typedef struct MEMORYSTATUS {
DWORD dwLength;
SIZE_T dwTotalPhys;
} MEMORYSTATUS;
typedef struct SECURITY_ATTRIBUTES {
DWORD nLength;
void* lpSecurityDescriptor;
BOOL bInheritHandle;
} SECURITY_ATTRIBUTES;
typedef struct PALETTEENTRY {
BYTE peRed;
BYTE peGreen;
BYTE peBlue;
BYTE peFlags;
} PALETTEENTRY, *PPALETTEENTRY, *LPPALETTEENTRY;
typedef struct RGNDATAHEADER {
DWORD dwSize;
DWORD iType;
DWORD nCount;
DWORD nRgnSize;
RECT rcBound;
} RGNDATAHEADER;
typedef struct RGNDATA {
RGNDATAHEADER rdh;
char Buffer[1];
} RGNDATA,*PRGNDATA,*NPRGNDATA,*LPRGNDATA;
// Ignore these.
#define STDMETHODCALLTYPE
#define __stdcall
#define CONST const
#define CONST_VTBL const
#define TRUE 1
#define FALSE 0
#define WAIT_TIMEOUT 0x00000102
#define WAIT_FAILED 0xffffffff
#define WAIT_OBJECT_0 0
#define WAIT_ABANDONED 0x00000080
#define interface struct
#define MIDL_INTERFACE(x) struct
#ifdef __cplusplus
#define DEFINE_GUID(iid, a, b, c, d, e, f, g, h, i, j, k) \
constexpr GUID iid = {a,b,c,{d,e,f,g,h,i,j,k}};
#define DECLARE_UUIDOF_HELPER(type, a, b, c, d, e, f, g, h, i, j, k) \
extern "C++" { template <> constexpr GUID __uuidof_helper<type>() { return GUID{a,b,c,{d,e,f,g,h,i,j,k}}; } } \
extern "C++" { template <> constexpr GUID __uuidof_helper<type*>() { return __uuidof_helper<type>(); } } \
extern "C++" { template <> constexpr GUID __uuidof_helper<const type*>() { return __uuidof_helper<type>(); } } \
extern "C++" { template <> constexpr GUID __uuidof_helper<type&>() { return __uuidof_helper<type>(); } } \
extern "C++" { template <> constexpr GUID __uuidof_helper<const type&>() { return __uuidof_helper<type>(); } }
#else
#define DEFINE_GUID(iid, a, b, c, d, e, f, g, h, i, j, k) \
static const GUID iid = {a,b,c,{d,e,f,g,h,i,j,k}};
#define DECLARE_UUIDOF_HELPER(type, a, b, c, d, e, f, g, h, i, j, k)
#endif // __cplusplus
#define __CRT_UUID_DECL(type, a, b, c, d, e, f, g, h, i, j, k) DECLARE_UUIDOF_HELPER(type, a, b, c, d, e, f, g, h, i, j, k)
#define S_OK 0
#define S_FALSE 1
#define E_INVALIDARG ((HRESULT)0x80070057)
#define E_FAIL ((HRESULT)0x80004005)
#define E_NOINTERFACE ((HRESULT)0x80004002)
#define E_NOTIMPL ((HRESULT)0x80004001)
#define E_OUTOFMEMORY ((HRESULT)0x8007000E)
#define E_POINTER ((HRESULT)0x80004003)
#define DXGI_STATUS_OCCLUDED ((HRESULT)0x087a0001)
#define DXGI_STATUS_CLIPPED ((HRESULT)0x087a0002)
#define DXGI_STATUS_NO_REDIRECTION ((HRESULT)0x087a0004)
#define DXGI_STATUS_NO_DESKTOP_ACCESS ((HRESULT)0x087a0005)
#define DXGI_STATUS_GRAPHICS_VIDPN_SOURCE_IN_USE ((HRESULT)0x087a0006)
#define DXGI_STATUS_MODE_CHANGED ((HRESULT)0x087a0007)
#define DXGI_STATUS_MODE_CHANGE_IN_PROGRESS ((HRESULT)0x087a0008)
#define DXGI_STATUS_UNOCCLUDED ((HRESULT)0x087a0009)
#define DXGI_STATUS_DDA_WAS_STILL_DRAWING ((HRESULT)0x087a000a)
#define DXGI_STATUS_PRESENT_REQUIRED ((HRESULT)0x087a002f)
#define DXGI_ERROR_INVALID_CALL ((HRESULT)0x887A0001)
#define DXGI_ERROR_NOT_FOUND ((HRESULT)0x887A0002)
#define DXGI_ERROR_MORE_DATA ((HRESULT)0x887A0003)
#define DXGI_ERROR_UNSUPPORTED ((HRESULT)0x887A0004)
#define DXGI_ERROR_DEVICE_REMOVED ((HRESULT)0x887A0005)
#define DXGI_ERROR_DEVICE_HUNG ((HRESULT)0x887A0006)
#define DXGI_ERROR_DEVICE_RESET ((HRESULT)0x887A0007)
#define DXGI_ERROR_WAS_STILL_DRAWING ((HRESULT)0x887A000A)
#define DXGI_ERROR_FRAME_STATISTICS_DISJOINT ((HRESULT)0x887A000B)
#define DXGI_ERROR_GRAPHICS_VIDPN_SOURCE_IN_USE ((HRESULT)0x887A000C)
#define DXGI_ERROR_DRIVER_INTERNAL_ERROR ((HRESULT)0x887A0020)
#define DXGI_ERROR_NONEXCLUSIVE ((HRESULT)0x887A0021)
#define DXGI_ERROR_NOT_CURRENTLY_AVAILABLE ((HRESULT)0x887A0022)
#define DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED ((HRESULT)0x887A0023)
#define DXGI_ERROR_REMOTE_OUTOFMEMORY ((HRESULT)0x887A0024)
#define DXGI_ERROR_ACCESS_LOST ((HRESULT)0x887A0026)
#define DXGI_ERROR_WAIT_TIMEOUT ((HRESULT)0x887A0027)
#define DXGI_ERROR_SESSION_DISCONNECTED ((HRESULT)0x887A0028)
#define DXGI_ERROR_RESTRICT_TO_OUTPUT_STALE ((HRESULT)0x887A0029)
#define DXGI_ERROR_CANNOT_PROTECT_CONTENT ((HRESULT)0x887A002A)
#define DXGI_ERROR_ACCESS_DENIED ((HRESULT)0x887A002B)
#define DXGI_ERROR_NAME_ALREADY_EXISTS ((HRESULT)0x887A002C)
#define DXGI_ERROR_SDK_COMPONENT_MISSING ((HRESULT)0x887A002D)
#define WINAPI
#define WINUSERAPI
#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
#define MAKE_HRESULT(sev,fac,code) \
((HRESULT) (((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))) )
#ifdef __cplusplus
#define STDMETHOD(name) virtual HRESULT name
#define STDMETHOD_(type, name) virtual type name
#else
#define STDMETHOD(name) HRESULT (STDMETHODCALLTYPE *name)
#define STDMETHOD_(type, name) type (STDMETHODCALLTYPE *name)
#endif // __cplusplus
#define THIS_
#define THIS
#define __C89_NAMELESSSTRUCTNAME
#define __C89_NAMELESSUNIONNAME
#define __C89_NAMELESSUNIONNAME1
#define __C89_NAMELESSUNIONNAME2
#define __C89_NAMELESSUNIONNAME3
#define __C89_NAMELESSUNIONNAME4
#define __C89_NAMELESSUNIONNAME5
#define __C89_NAMELESSUNIONNAME6
#define __C89_NAMELESSUNIONNAME7
#define __C89_NAMELESSUNIONNAME8
#define __C89_NAMELESS
#define DUMMYUNIONNAME
#define DUMMYSTRUCTNAME
#define DUMMYUNIONNAME1
#define DUMMYUNIONNAME2
#define DUMMYUNIONNAME3
#define DUMMYUNIONNAME4
#define DUMMYUNIONNAME5
#define DUMMYUNIONNAME6
#define DUMMYUNIONNAME7
#define DUMMYUNIONNAME8
#define DUMMYUNIONNAME9
#ifdef __cplusplus
#define DECLARE_INTERFACE(x) struct x
#define DECLARE_INTERFACE_(x, y) struct x : public y
#else
#ifdef CONST_VTABLE
#define DECLARE_INTERFACE(x) \
typedef interface x { \
const struct x##Vtbl *lpVtbl; \
} x; \
typedef const struct x##Vtbl x##Vtbl; \
const struct x##Vtbl
#else
#define DECLARE_INTERFACE(x) \
typedef interface x { \
struct x##Vtbl *lpVtbl; \
} x; \
typedef struct x##Vtbl x##Vtbl; \
struct x##Vtbl
#endif // CONST_VTABLE
#define DECLARE_INTERFACE_(x, y) DECLARE_INTERFACE(x)
#endif // __cplusplus
#define BEGIN_INTERFACE
#define END_INTERFACE
#ifdef __cplusplus
#define PURE = 0
#else
#define PURE
#endif // __cplusplus
#define DECLSPEC_SELECTANY
#define __MSABI_LONG(x) x
#define ENUM_CURRENT_SETTINGS ((DWORD)-1)
#define ENUM_REGISTRY_SETTINGS ((DWORD)-2)
#define INVALID_HANDLE_VALUE ((HANDLE)-1)
#define DUPLICATE_CLOSE_SOURCE ((DWORD)0x1)
#define DUPLICATE_SAME_ACCESS ((DWORD)0x2)
#define FAILED(hr) ((HRESULT)(hr) < 0)
#define SUCCEEDED(hr) ((HRESULT)(hr) >= 0)
#define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
#define ZeroMemory RtlZeroMemory
#ifndef DEFINE_ENUM_FLAG_OPERATORS
#ifdef __cplusplus
# define DEFINE_ENUM_FLAG_OPERATORS(type) \
extern "C++" \
{ \
inline type operator &(type x, type y) { return (type)((int)x & (int)y); } \
inline type operator &=(type &x, type y) { return (type &)((int &)x &= (int)y); } \
inline type operator ~(type x) { return (type)~(int)x; } \
inline type operator |(type x, type y) { return (type)((int)x | (int)y); } \
inline type operator |=(type &x, type y) { return (type &)((int &)x |= (int)y); } \
inline type operator ^(type x, type y) { return (type)((int)x ^ (int)y); } \
inline type operator ^=(type &x, type y) { return (type &)((int &)x ^= (int)y); } \
}
#else
# define DEFINE_ENUM_FLAG_OPERATORS(type)
#endif
#endif /* DEFINE_ENUM_FLAG_OPERATORS */

View File

@ -0,0 +1,25 @@
#include <windows.h>
#include <GLFW/glfw3.h>
namespace dxvk::wsi {
inline GLFWwindow* fromHwnd(HWND hWindow) {
return reinterpret_cast<GLFWwindow*>(hWindow);
}
inline HWND toHwnd(GLFWwindow* pWindow) {
return reinterpret_cast<HWND>(pWindow);
}
// Offset so null HMONITORs go to -1
inline int32_t fromHmonitor(HMONITOR hMonitor) {
return static_cast<int32_t>(reinterpret_cast<intptr_t>(hMonitor)) - 1;
}
// Offset so -1 display id goes to 0 == NULL
inline HMONITOR toHmonitor(int32_t displayId) {
return reinterpret_cast<HMONITOR>(static_cast<intptr_t>(displayId + 1));
}
}

View File

@ -0,0 +1,25 @@
#include <windows.h>
#include <SDL.h>
namespace dxvk::wsi {
inline SDL_Window* fromHwnd(HWND hWindow) {
return reinterpret_cast<SDL_Window*>(hWindow);
}
inline HWND toHwnd(SDL_Window* pWindow) {
return reinterpret_cast<HWND>(pWindow);
}
// Offset so null HMONITORs go to -1
inline int32_t fromHmonitor(HMONITOR hMonitor) {
return static_cast<int32_t>(reinterpret_cast<intptr_t>(hMonitor)) - 1;
}
// Offset so -1 display id goes to 0 == NULL
inline HMONITOR toHmonitor(int32_t displayId) {
return reinterpret_cast<HMONITOR>(static_cast<intptr_t>(displayId + 1));
}
}

View File

@ -0,0 +1,11 @@
#pragma once
#ifdef DXVK_WSI_WIN32
#error You shouldnt be using this code path.
#elif DXVK_WSI_SDL2
#include "wsi/native_sdl2.h"
#elif DXVK_WSI_GLFW
#include "wsi/native_glfw.h"
#else
#error Unknown wsi!
#endif

1
include/spirv Submodule

@ -0,0 +1 @@
Subproject commit 8b246ff75c6615ba4532fe4fde20f1be090c3764

View File

@ -1,131 +0,0 @@
/*
** Copyright (c) 2014-2016 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and/or associated documentation files (the "Materials"),
** to deal in the Materials without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Materials, and to permit persons to whom the
** Materials are 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 Materials.
**
** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
**
** THE MATERIALS ARE 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 MATERIALS OR THE USE OR OTHER DEALINGS
** IN THE MATERIALS.
*/
#ifndef GLSLstd450_H
#define GLSLstd450_H
static const int GLSLstd450Version = 100;
static const int GLSLstd450Revision = 3;
enum GLSLstd450 {
GLSLstd450Bad = 0, // Don't use
GLSLstd450Round = 1,
GLSLstd450RoundEven = 2,
GLSLstd450Trunc = 3,
GLSLstd450FAbs = 4,
GLSLstd450SAbs = 5,
GLSLstd450FSign = 6,
GLSLstd450SSign = 7,
GLSLstd450Floor = 8,
GLSLstd450Ceil = 9,
GLSLstd450Fract = 10,
GLSLstd450Radians = 11,
GLSLstd450Degrees = 12,
GLSLstd450Sin = 13,
GLSLstd450Cos = 14,
GLSLstd450Tan = 15,
GLSLstd450Asin = 16,
GLSLstd450Acos = 17,
GLSLstd450Atan = 18,
GLSLstd450Sinh = 19,
GLSLstd450Cosh = 20,
GLSLstd450Tanh = 21,
GLSLstd450Asinh = 22,
GLSLstd450Acosh = 23,
GLSLstd450Atanh = 24,
GLSLstd450Atan2 = 25,
GLSLstd450Pow = 26,
GLSLstd450Exp = 27,
GLSLstd450Log = 28,
GLSLstd450Exp2 = 29,
GLSLstd450Log2 = 30,
GLSLstd450Sqrt = 31,
GLSLstd450InverseSqrt = 32,
GLSLstd450Determinant = 33,
GLSLstd450MatrixInverse = 34,
GLSLstd450Modf = 35, // second operand needs an OpVariable to write to
GLSLstd450ModfStruct = 36, // no OpVariable operand
GLSLstd450FMin = 37,
GLSLstd450UMin = 38,
GLSLstd450SMin = 39,
GLSLstd450FMax = 40,
GLSLstd450UMax = 41,
GLSLstd450SMax = 42,
GLSLstd450FClamp = 43,
GLSLstd450UClamp = 44,
GLSLstd450SClamp = 45,
GLSLstd450FMix = 46,
GLSLstd450IMix = 47, // Reserved
GLSLstd450Step = 48,
GLSLstd450SmoothStep = 49,
GLSLstd450Fma = 50,
GLSLstd450Frexp = 51, // second operand needs an OpVariable to write to
GLSLstd450FrexpStruct = 52, // no OpVariable operand
GLSLstd450Ldexp = 53,
GLSLstd450PackSnorm4x8 = 54,
GLSLstd450PackUnorm4x8 = 55,
GLSLstd450PackSnorm2x16 = 56,
GLSLstd450PackUnorm2x16 = 57,
GLSLstd450PackHalf2x16 = 58,
GLSLstd450PackDouble2x32 = 59,
GLSLstd450UnpackSnorm2x16 = 60,
GLSLstd450UnpackUnorm2x16 = 61,
GLSLstd450UnpackHalf2x16 = 62,
GLSLstd450UnpackSnorm4x8 = 63,
GLSLstd450UnpackUnorm4x8 = 64,
GLSLstd450UnpackDouble2x32 = 65,
GLSLstd450Length = 66,
GLSLstd450Distance = 67,
GLSLstd450Cross = 68,
GLSLstd450Normalize = 69,
GLSLstd450FaceForward = 70,
GLSLstd450Reflect = 71,
GLSLstd450Refract = 72,
GLSLstd450FindILsb = 73,
GLSLstd450FindSMsb = 74,
GLSLstd450FindUMsb = 75,
GLSLstd450InterpolateAtCentroid = 76,
GLSLstd450InterpolateAtSample = 77,
GLSLstd450InterpolateAtOffset = 78,
GLSLstd450NMin = 79,
GLSLstd450NMax = 80,
GLSLstd450NClamp = 81,
GLSLstd450Count
};
#endif // #ifndef GLSLstd450_H

View File

@ -1,135 +0,0 @@
/*
** Copyright (c) 2014-2016 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and/or associated documentation files (the "Materials"),
** to deal in the Materials without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Materials, and to permit persons to whom the
** Materials are 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 Materials.
**
** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
**
** THE MATERIALS ARE 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 MATERIALS OR THE USE OR OTHER DEALINGS
** IN THE MATERIALS.
*/
#ifndef GLSLstd450_HPP
#define GLSLstd450_HPP
namespace spv {
static const int GLSLstd450Version = 100;
static const int GLSLstd450Revision = 3;
enum GLSLstd450 {
GLSLstd450Bad = 0, // Don't use
GLSLstd450Round = 1,
GLSLstd450RoundEven = 2,
GLSLstd450Trunc = 3,
GLSLstd450FAbs = 4,
GLSLstd450SAbs = 5,
GLSLstd450FSign = 6,
GLSLstd450SSign = 7,
GLSLstd450Floor = 8,
GLSLstd450Ceil = 9,
GLSLstd450Fract = 10,
GLSLstd450Radians = 11,
GLSLstd450Degrees = 12,
GLSLstd450Sin = 13,
GLSLstd450Cos = 14,
GLSLstd450Tan = 15,
GLSLstd450Asin = 16,
GLSLstd450Acos = 17,
GLSLstd450Atan = 18,
GLSLstd450Sinh = 19,
GLSLstd450Cosh = 20,
GLSLstd450Tanh = 21,
GLSLstd450Asinh = 22,
GLSLstd450Acosh = 23,
GLSLstd450Atanh = 24,
GLSLstd450Atan2 = 25,
GLSLstd450Pow = 26,
GLSLstd450Exp = 27,
GLSLstd450Log = 28,
GLSLstd450Exp2 = 29,
GLSLstd450Log2 = 30,
GLSLstd450Sqrt = 31,
GLSLstd450InverseSqrt = 32,
GLSLstd450Determinant = 33,
GLSLstd450MatrixInverse = 34,
GLSLstd450Modf = 35, // second operand needs an OpVariable to write to
GLSLstd450ModfStruct = 36, // no OpVariable operand
GLSLstd450FMin = 37,
GLSLstd450UMin = 38,
GLSLstd450SMin = 39,
GLSLstd450FMax = 40,
GLSLstd450UMax = 41,
GLSLstd450SMax = 42,
GLSLstd450FClamp = 43,
GLSLstd450UClamp = 44,
GLSLstd450SClamp = 45,
GLSLstd450FMix = 46,
GLSLstd450IMix = 47, // Reserved
GLSLstd450Step = 48,
GLSLstd450SmoothStep = 49,
GLSLstd450Fma = 50,
GLSLstd450Frexp = 51, // second operand needs an OpVariable to write to
GLSLstd450FrexpStruct = 52, // no OpVariable operand
GLSLstd450Ldexp = 53,
GLSLstd450PackSnorm4x8 = 54,
GLSLstd450PackUnorm4x8 = 55,
GLSLstd450PackSnorm2x16 = 56,
GLSLstd450PackUnorm2x16 = 57,
GLSLstd450PackHalf2x16 = 58,
GLSLstd450PackDouble2x32 = 59,
GLSLstd450UnpackSnorm2x16 = 60,
GLSLstd450UnpackUnorm2x16 = 61,
GLSLstd450UnpackHalf2x16 = 62,
GLSLstd450UnpackSnorm4x8 = 63,
GLSLstd450UnpackUnorm4x8 = 64,
GLSLstd450UnpackDouble2x32 = 65,
GLSLstd450Length = 66,
GLSLstd450Distance = 67,
GLSLstd450Cross = 68,
GLSLstd450Normalize = 69,
GLSLstd450FaceForward = 70,
GLSLstd450Reflect = 71,
GLSLstd450Refract = 72,
GLSLstd450FindILsb = 73,
GLSLstd450FindSMsb = 74,
GLSLstd450FindUMsb = 75,
GLSLstd450InterpolateAtCentroid = 76,
GLSLstd450InterpolateAtSample = 77,
GLSLstd450InterpolateAtOffset = 78,
GLSLstd450NMin = 79,
GLSLstd450NMax = 80,
GLSLstd450NClamp = 81,
GLSLstd450Count
};
}
#endif // #ifndef GLSLstd450_HPP

File diff suppressed because it is too large Load Diff

1
include/vulkan Submodule

@ -0,0 +1 @@
Subproject commit 46dc0f6e514f5730784bb2cac2a7c731636839e8

View File

@ -1,84 +0,0 @@
//
// File: vk_platform.h
//
/*
** Copyright 2014-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
#ifndef VK_PLATFORM_H_
#define VK_PLATFORM_H_
#ifdef __cplusplus
extern "C"
{
#endif // __cplusplus
/*
***************************************************************************************************
* Platform-specific directives and type declarations
***************************************************************************************************
*/
/* Platform-specific calling convention macros.
*
* Platforms should define these so that Vulkan clients call Vulkan commands
* with the same calling conventions that the Vulkan implementation expects.
*
* VKAPI_ATTR - Placed before the return type in function declarations.
* Useful for C++11 and GCC/Clang-style function attribute syntax.
* VKAPI_CALL - Placed after the return type in function declarations.
* Useful for MSVC-style calling convention syntax.
* VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
*
* Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
* Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
*/
#if defined(_WIN32)
// On Windows, Vulkan commands use the stdcall convention
#define VKAPI_ATTR
#define VKAPI_CALL __stdcall
#define VKAPI_PTR VKAPI_CALL
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
#error "Vulkan isn't supported for the 'armeabi' NDK ABI"
#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
// On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
// calling convention, i.e. float parameters are passed in registers. This
// is true even if the rest of the application passes floats on the stack,
// as it does by default when compiling for the armeabi-v7a NDK ABI.
#define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
#define VKAPI_CALL
#define VKAPI_PTR VKAPI_ATTR
#else
// On other platforms, use the default calling convention
#define VKAPI_ATTR
#define VKAPI_CALL
#define VKAPI_PTR
#endif
#if !defined(VK_NO_STDDEF_H)
#include <stddef.h>
#endif // !defined(VK_NO_STDDEF_H)
#if !defined(VK_NO_STDINT_H)
#if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
#endif // !defined(VK_NO_STDINT_H)
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif

View File

@ -1,92 +0,0 @@
#ifndef VULKAN_H_
#define VULKAN_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
#include "vk_platform.h"
#include "vulkan_core.h"
#ifdef VK_USE_PLATFORM_ANDROID_KHR
#include "vulkan_android.h"
#endif
#ifdef VK_USE_PLATFORM_FUCHSIA
#include <zircon/types.h>
#include "vulkan_fuchsia.h"
#endif
#ifdef VK_USE_PLATFORM_IOS_MVK
#include "vulkan_ios.h"
#endif
#ifdef VK_USE_PLATFORM_MACOS_MVK
#include "vulkan_macos.h"
#endif
#ifdef VK_USE_PLATFORM_METAL_EXT
#include "vulkan_metal.h"
#endif
#ifdef VK_USE_PLATFORM_VI_NN
#include "vulkan_vi.h"
#endif
#ifdef VK_USE_PLATFORM_WAYLAND_KHR
#include <wayland-client.h>
#include "vulkan_wayland.h"
#endif
#ifdef VK_USE_PLATFORM_WIN32_KHR
#include <windows.h>
#include "vulkan_win32.h"
#endif
#ifdef VK_USE_PLATFORM_XCB_KHR
#include <xcb/xcb.h>
#include "vulkan_xcb.h"
#endif
#ifdef VK_USE_PLATFORM_XLIB_KHR
#include <X11/Xlib.h>
#include "vulkan_xlib.h"
#endif
#ifdef VK_USE_PLATFORM_DIRECTFB_EXT
#include <directfb.h>
#include "vulkan_directfb.h"
#endif
#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#include "vulkan_xlib_xrandr.h"
#endif
#ifdef VK_USE_PLATFORM_GGP
#include <ggp_c/vulkan_types.h>
#include "vulkan_ggp.h"
#endif
#ifdef VK_USE_PLATFORM_SCREEN_QNX
#include <screen/screen.h>
#include "vulkan_screen.h"
#endif
#ifdef VK_ENABLE_BETA_EXTENSIONS
#include "vulkan_beta.h"
#endif
#endif // VULKAN_H_

File diff suppressed because it is too large Load Diff

View File

@ -1,315 +0,0 @@
#ifndef VULKAN_WIN32_H_
#define VULKAN_WIN32_H_ 1
/*
** Copyright 2015-2021 The Khronos Group Inc.
**
** SPDX-License-Identifier: Apache-2.0
*/
/*
** This header is generated from the Khronos Vulkan XML API Registry.
**
*/
#ifdef __cplusplus
extern "C" {
#endif
#define VK_KHR_win32_surface 1
#define VK_KHR_WIN32_SURFACE_SPEC_VERSION 6
#define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface"
typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
typedef struct VkWin32SurfaceCreateInfoKHR {
VkStructureType sType;
const void* pNext;
VkWin32SurfaceCreateFlagsKHR flags;
HINSTANCE hinstance;
HWND hwnd;
} VkWin32SurfaceCreateInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
VkInstance instance,
const VkWin32SurfaceCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* pAllocator,
VkSurfaceKHR* pSurface);
VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(
VkPhysicalDevice physicalDevice,
uint32_t queueFamilyIndex);
#endif
#define VK_KHR_external_memory_win32 1
#define VK_KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
#define VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_KHR_external_memory_win32"
typedef struct VkImportMemoryWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
VkExternalMemoryHandleTypeFlagBits handleType;
HANDLE handle;
LPCWSTR name;
} VkImportMemoryWin32HandleInfoKHR;
typedef struct VkExportMemoryWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
const SECURITY_ATTRIBUTES* pAttributes;
DWORD dwAccess;
LPCWSTR name;
} VkExportMemoryWin32HandleInfoKHR;
typedef struct VkMemoryWin32HandlePropertiesKHR {
VkStructureType sType;
void* pNext;
uint32_t memoryTypeBits;
} VkMemoryWin32HandlePropertiesKHR;
typedef struct VkMemoryGetWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
VkDeviceMemory memory;
VkExternalMemoryHandleTypeFlagBits handleType;
} VkMemoryGetWin32HandleInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleKHR)(VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandlePropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleKHR(
VkDevice device,
const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo,
HANDLE* pHandle);
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR(
VkDevice device,
VkExternalMemoryHandleTypeFlagBits handleType,
HANDLE handle,
VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
#endif
#define VK_KHR_win32_keyed_mutex 1
#define VK_KHR_WIN32_KEYED_MUTEX_SPEC_VERSION 1
#define VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_KHR_win32_keyed_mutex"
typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR {
VkStructureType sType;
const void* pNext;
uint32_t acquireCount;
const VkDeviceMemory* pAcquireSyncs;
const uint64_t* pAcquireKeys;
const uint32_t* pAcquireTimeouts;
uint32_t releaseCount;
const VkDeviceMemory* pReleaseSyncs;
const uint64_t* pReleaseKeys;
} VkWin32KeyedMutexAcquireReleaseInfoKHR;
#define VK_KHR_external_semaphore_win32 1
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION 1
#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME "VK_KHR_external_semaphore_win32"
typedef struct VkImportSemaphoreWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
VkSemaphore semaphore;
VkSemaphoreImportFlags flags;
VkExternalSemaphoreHandleTypeFlagBits handleType;
HANDLE handle;
LPCWSTR name;
} VkImportSemaphoreWin32HandleInfoKHR;
typedef struct VkExportSemaphoreWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
const SECURITY_ATTRIBUTES* pAttributes;
DWORD dwAccess;
LPCWSTR name;
} VkExportSemaphoreWin32HandleInfoKHR;
typedef struct VkD3D12FenceSubmitInfoKHR {
VkStructureType sType;
const void* pNext;
uint32_t waitSemaphoreValuesCount;
const uint64_t* pWaitSemaphoreValues;
uint32_t signalSemaphoreValuesCount;
const uint64_t* pSignalSemaphoreValues;
} VkD3D12FenceSubmitInfoKHR;
typedef struct VkSemaphoreGetWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
VkSemaphore semaphore;
VkExternalSemaphoreHandleTypeFlagBits handleType;
} VkSemaphoreGetWin32HandleInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreWin32HandleKHR)(VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo);
typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreWin32HandleKHR)(VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreWin32HandleKHR(
VkDevice device,
const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo);
VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR(
VkDevice device,
const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo,
HANDLE* pHandle);
#endif
#define VK_KHR_external_fence_win32 1
#define VK_KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION 1
#define VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME "VK_KHR_external_fence_win32"
typedef struct VkImportFenceWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
VkFence fence;
VkFenceImportFlags flags;
VkExternalFenceHandleTypeFlagBits handleType;
HANDLE handle;
LPCWSTR name;
} VkImportFenceWin32HandleInfoKHR;
typedef struct VkExportFenceWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
const SECURITY_ATTRIBUTES* pAttributes;
DWORD dwAccess;
LPCWSTR name;
} VkExportFenceWin32HandleInfoKHR;
typedef struct VkFenceGetWin32HandleInfoKHR {
VkStructureType sType;
const void* pNext;
VkFence fence;
VkExternalFenceHandleTypeFlagBits handleType;
} VkFenceGetWin32HandleInfoKHR;
typedef VkResult (VKAPI_PTR *PFN_vkImportFenceWin32HandleKHR)(VkDevice device, const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo);
typedef VkResult (VKAPI_PTR *PFN_vkGetFenceWin32HandleKHR)(VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceWin32HandleKHR(
VkDevice device,
const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo);
VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR(
VkDevice device,
const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo,
HANDLE* pHandle);
#endif
#define VK_NV_external_memory_win32 1
#define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
#define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32"
typedef struct VkImportMemoryWin32HandleInfoNV {
VkStructureType sType;
const void* pNext;
VkExternalMemoryHandleTypeFlagsNV handleType;
HANDLE handle;
} VkImportMemoryWin32HandleInfoNV;
typedef struct VkExportMemoryWin32HandleInfoNV {
VkStructureType sType;
const void* pNext;
const SECURITY_ATTRIBUTES* pAttributes;
DWORD dwAccess;
} VkExportMemoryWin32HandleInfoNV;
typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleNV)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE* pHandle);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV(
VkDevice device,
VkDeviceMemory memory,
VkExternalMemoryHandleTypeFlagsNV handleType,
HANDLE* pHandle);
#endif
#define VK_NV_win32_keyed_mutex 1
#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 2
#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex"
typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV {
VkStructureType sType;
const void* pNext;
uint32_t acquireCount;
const VkDeviceMemory* pAcquireSyncs;
const uint64_t* pAcquireKeys;
const uint32_t* pAcquireTimeoutMilliseconds;
uint32_t releaseCount;
const VkDeviceMemory* pReleaseSyncs;
const uint64_t* pReleaseKeys;
} VkWin32KeyedMutexAcquireReleaseInfoNV;
#define VK_EXT_full_screen_exclusive 1
#define VK_EXT_FULL_SCREEN_EXCLUSIVE_SPEC_VERSION 4
#define VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME "VK_EXT_full_screen_exclusive"
typedef enum VkFullScreenExclusiveEXT {
VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT = 0,
VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT = 1,
VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT = 2,
VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT = 3,
VK_FULL_SCREEN_EXCLUSIVE_MAX_ENUM_EXT = 0x7FFFFFFF
} VkFullScreenExclusiveEXT;
typedef struct VkSurfaceFullScreenExclusiveInfoEXT {
VkStructureType sType;
void* pNext;
VkFullScreenExclusiveEXT fullScreenExclusive;
} VkSurfaceFullScreenExclusiveInfoEXT;
typedef struct VkSurfaceCapabilitiesFullScreenExclusiveEXT {
VkStructureType sType;
void* pNext;
VkBool32 fullScreenExclusiveSupported;
} VkSurfaceCapabilitiesFullScreenExclusiveEXT;
typedef struct VkSurfaceFullScreenExclusiveWin32InfoEXT {
VkStructureType sType;
const void* pNext;
HMONITOR hmonitor;
} VkSurfaceFullScreenExclusiveWin32InfoEXT;
typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes);
typedef VkResult (VKAPI_PTR *PFN_vkAcquireFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain);
typedef VkResult (VKAPI_PTR *PFN_vkReleaseFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain);
typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupSurfacePresentModes2EXT)(VkDevice device, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkDeviceGroupPresentModeFlagsKHR* pModes);
#ifndef VK_NO_PROTOTYPES
VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModes2EXT(
VkPhysicalDevice physicalDevice,
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
uint32_t* pPresentModeCount,
VkPresentModeKHR* pPresentModes);
VKAPI_ATTR VkResult VKAPI_CALL vkAcquireFullScreenExclusiveModeEXT(
VkDevice device,
VkSwapchainKHR swapchain);
VKAPI_ATTR VkResult VKAPI_CALL vkReleaseFullScreenExclusiveModeEXT(
VkDevice device,
VkSwapchainKHR swapchain);
VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModes2EXT(
VkDevice device,
const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
VkDeviceGroupPresentModeFlagsKHR* pModes);
#endif
#ifdef __cplusplus
}
#endif
#endif

Binary file not shown.

View File

@ -1,17 +0,0 @@
; File generated automatically from d3dcompiler_43.spec; do not edit!
LIBRARY d3dcompiler_43.dll
EXPORTS
D3DAssemble @1
D3DCompile @3
D3DCreateBlob @5
D3DDisassemble @8
D3DGetBlobPart @9
D3DGetDebugInfo @10
D3DGetInputAndOutputSignatureBlob @11
D3DGetInputSignatureBlob @12
D3DGetOutputSignatureBlob @13
D3DPreprocess @14
D3DReflect @15
D3DStripShader @17

Binary file not shown.

Binary file not shown.

View File

@ -1,17 +0,0 @@
; File generated automatically from d3dcompiler_43.spec; do not edit!
LIBRARY d3dcompiler_43.dll
EXPORTS
D3DAssemble@32 @1
D3DCompile@44 @3
D3DCreateBlob@8 @5
D3DDisassemble@20 @8
D3DGetBlobPart@20 @9
D3DGetDebugInfo@12 @10
D3DGetInputAndOutputSignatureBlob@12 @11
D3DGetInputSignatureBlob@12 @12
D3DGetOutputSignatureBlob@12 @13
D3DPreprocess@28 @14
D3DReflect@16 @15
D3DStripShader@16 @17

Binary file not shown.

View File

@ -1,40 +1,32 @@
project('dxvk', ['c', 'cpp'], version : 'v1.10.1', meson_version : '>= 0.47', default_options : [ 'cpp_std=c++17' ])
project('dxvk', ['c', 'cpp'], version : 'v2.3.1', meson_version : '>= 0.58', default_options : [ 'cpp_std=c++17', 'warning_level=2' ])
cpu_family = target_machine.cpu_family()
platform = target_machine.system()
fs = import('fs')
cpp = meson.get_compiler('cpp')
cc = meson.get_compiler('c')
dxvk_is_msvc = cpp.get_id() == 'msvc'
dxvk_is_msvc = cpp.get_argument_syntax() == 'msvc'
compiler_args = [
'-DNOMINMAX',
'-D_WIN32_WINNT=0xa00',
'-msse',
'-msse2',
'-msse3',
'-mfpmath=sse',
'-Wimplicit-fallthrough',
# gcc
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
'-Wno-cast-function-type', # Needed for GetProcAddress.
# clang
'-Wno-unused-private-field',
'-Wno-microsoft-exception-spec',
'-Wno-extern-c-compat',
'-Wno-unused-const-variable',
'-Wno-missing-braces',
]
link_args = [
'-static',
'-static-libgcc',
'-static-libstdc++',
# We need to set the section alignment for debug symbols to
# work properly as well as avoiding a memcpy from the Wine loader.
'-Wl,--file-alignment=4096',
]
# Wine's built-in back traces only work with dwarf2 symbols
if get_option('debug') and target_machine.system() == 'windows'
compiler_args += [
'-gstrict-dwarf',
'-gdwarf-2',
]
endif
link_args = []
if get_option('build_id')
link_args += [
@ -42,71 +34,146 @@ if get_option('build_id')
]
endif
if cpu_family == 'x86'
dxvk_include_dirs = ['./include']
if fs.is_dir('./include/vulkan/include')
dxvk_include_dirs += ['./include/vulkan/include']
elif not cpp.check_header('vulkan/vulkan.h')
error('Missing Vulkan-Headers')
endif
if fs.is_dir('./include/spirv/include')
dxvk_include_dirs += ['./include/spirv/include']
elif not cpp.check_header('spirv/unified1/spirv.hpp')
error('Missing SPIRV-Headers')
endif
dep_displayinfo = dependency(
'libdisplay-info',
version: ['>= 0.0.0', '< 0.2.0'],
fallback: ['libdisplay-info', 'di_dep'],
default_options: ['default_library=static'],
)
if platform == 'windows'
compiler_args += [
'-DNOMINMAX',
'-D_WIN32_WINNT=0xa00',
]
if not dxvk_is_msvc
link_args += [
'-static',
'-static-libgcc',
'-static-libstdc++',
# We need to set the section alignment for debug symbols to
# work properly as well as avoiding a memcpy from the Wine loader.
'-Wl,--file-alignment=4096',
]
# Wine's built-in back traces only work with dwarf4 symbols
if get_option('debug')
compiler_args += [
'-gdwarf-4',
]
endif
# Enable stdcall fixup on 32-bit
if cpu_family == 'x86'
link_args += [
'-Wl,--enable-stdcall-fixup',
'-Wl,--kill-at',
]
endif
else
link_args += [
'/FILEALIGN:4096',
]
endif
lib_d3d9 = cpp.find_library('d3d9')
lib_d3d11 = cpp.find_library('d3d11')
lib_dxgi = cpp.find_library('dxgi')
if dxvk_is_msvc
lib_d3dcompiler_47 = cpp.find_library('d3dcompiler')
else
lib_d3dcompiler_47 = cpp.find_library('d3dcompiler_47')
endif
if dxvk_is_msvc
res_ext = '.res'
wrc = find_program('rc')
wrc_generator = generator(wrc,
output : [ '@BASENAME@' + res_ext ],
arguments : [ '/fo', '@OUTPUT@', '@INPUT@' ],
)
else
res_ext = '.o'
wrc = find_program('windres')
wrc_generator = generator(wrc,
output : [ '@BASENAME@' + res_ext ],
arguments : [ '-i', '@INPUT@', '-o', '@OUTPUT@' ],
)
endif
dxvk_name_prefix = ''
compiler_args += ['-DDXVK_WSI_WIN32']
else
wrc = find_program('touch')
wrc_generator = generator(wrc, output : [ '@BASENAME@_ignored.h' ], arguments : [ '@OUTPUT@' ] )
dxvk_include_dirs += [
'./include/native',
'./include/native/windows',
'./include/native/directx'
]
lib_sdl2 = dependency('SDL2', required: false)
lib_glfw = dependency('glfw', required: false)
if lib_sdl2.found()
compiler_args += ['-DDXVK_WSI_SDL2']
endif
if lib_glfw.found()
compiler_args += ['-DDXVK_WSI_GLFW']
endif
if (not lib_sdl2.found() and not lib_glfw.found())
error('SDL2 or GLFW are required to build dxvk-native')
endif
dxvk_name_prefix = 'libdxvk_'
link_args += [
'-Wl,--enable-stdcall-fixup',
'-Wl,--add-stdcall-alias',
'-static-libgcc',
'-static-libstdc++',
]
endif
dxvk_include_path = include_directories(dxvk_include_dirs)
add_project_arguments(cpp.get_supported_arguments(compiler_args), language: 'cpp')
add_project_arguments(cc.get_supported_arguments(compiler_args), language: 'c')
add_project_link_arguments(cpp.get_supported_link_arguments(link_args), language: 'cpp')
add_project_link_arguments(cc.get_supported_link_arguments(link_args), language: 'c')
dxvk_include_path = include_directories('./include')
if (cpu_family == 'x86_64')
dxvk_library_path = meson.source_root() + '/lib'
else
dxvk_library_path = meson.source_root() + '/lib32'
endif
dxvk_extradep = [ ]
lib_vulkan = cpp.find_library('vulkan-1', dirs : dxvk_library_path)
lib_d3d9 = cpp.find_library('d3d9')
lib_d3d11 = cpp.find_library('d3d11')
lib_dxgi = cpp.find_library('dxgi')
lib_d3dcompiler_43 = cpp.find_library('d3dcompiler_43', dirs : dxvk_library_path)
if dxvk_is_msvc
lib_d3dcompiler_47 = cpp.find_library('d3dcompiler')
else
lib_d3dcompiler_47 = cpp.find_library('d3dcompiler_47')
endif
exe_ext = ''
dll_ext = ''
def_spec_ext = '.def'
glsl_compiler = find_program('glslangValidator')
glsl_args = [ '-V', '--vn', '@BASENAME@', '@INPUT@', '-o', '@OUTPUT@' ]
if run_command(glsl_compiler, [ '--quiet', '--version' ], check : false).returncode() == 0
glsl_args += [ '--quiet' ]
endif
glsl_generator = generator(glsl_compiler,
glsl_compiler = find_program('glslang', 'glslangValidator')
glsl_args = [
'--quiet',
'--target-env', 'vulkan1.3',
'--vn', '@BASENAME@',
'--depfile', '@DEPFILE@',
'@INPUT@',
'-o', '@OUTPUT@',
]
glsl_generator = generator(
glsl_compiler,
output : [ '@BASENAME@.h' ],
depfile : '@BASENAME@.h.d',
arguments : glsl_args,
)
if dxvk_is_msvc
res_ext = '.res'
wrc = find_program('rc')
wrc_generator = generator(wrc,
output : [ '@BASENAME@' + res_ext ],
arguments : [ '/fo', '@OUTPUT@', '@INPUT@' ],
)
else
res_ext = '.o'
wrc = find_program('windres')
wrc_generator = generator(wrc,
output : [ '@BASENAME@' + res_ext ],
arguments : [ '-i', '@INPUT@', '-o', '@OUTPUT@' ],
)
endif
dxvk_version = vcs_tag(
command: ['git', 'describe', '--dirty=+'],
input: 'version.h.in',
@ -114,9 +181,3 @@ dxvk_version = vcs_tag(
)
subdir('src')
enable_tests = get_option('enable_tests')
if enable_tests
subdir('tests')
endif

View File

@ -1,6 +1,7 @@
option('enable_tests', type : 'boolean', value : false)
option('enable_dxgi', type : 'boolean', value : true, description: 'Build DXGI')
option('enable_d3d9', type : 'boolean', value : true, description: 'Build D3D9')
option('enable_d3d10', type : 'boolean', value : true, description: 'Build D3D10')
option('enable_d3d11', type : 'boolean', value : true, description: 'Build D3D11')
option('build_id', type : 'boolean', value : false)
option('dxvk_native_wsi', type : 'string', value : 'sdl2', description: 'WSI system to use if building natively.')

89
package-native.sh Executable file
View File

@ -0,0 +1,89 @@
#!/usr/bin/env bash
set -e
shopt -s extglob
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 version destdir [--no-package] [--dev-build]"
exit 1
fi
DXVK_VERSION="$1"
DXVK_SRC_DIR=$(readlink -f "$0")
DXVK_SRC_DIR=$(dirname "$DXVK_SRC_DIR")
DXVK_BUILD_DIR=$(realpath "$2")"/dxvk-native-$DXVK_VERSION"
DXVK_ARCHIVE_PATH=$(realpath "$2")"/dxvk-native-$DXVK_VERSION.tar.gz"
if [ -e "$DXVK_BUILD_DIR" ]; then
echo "Build directory $DXVK_BUILD_DIR already exists"
exit 1
fi
shift 2
opt_nopackage=0
opt_devbuild=0
opt_buildid=false
CC=${CC:="gcc"}
CXX=${CXX:="g++"}
while [ $# -gt 0 ]; do
case "$1" in
"--no-package")
opt_nopackage=1
;;
"--dev-build")
opt_nopackage=1
opt_devbuild=1
;;
"--build-id")
opt_buildid=true
;;
*)
echo "Unrecognized option: $1" >&2
exit 1
esac
shift
done
function build_arch {
cd "$DXVK_SRC_DIR"
opt_strip=
if [ $opt_devbuild -eq 0 ]; then
opt_strip=--strip
fi
CC="$CC -m$1" CXX="$CXX -m$1" meson setup \
--buildtype "release" \
--prefix "$DXVK_BUILD_DIR/usr" \
$opt_strip \
--bindir "$2" \
--libdir "$2" \
-Dbuild_id=$opt_buildid \
--force-fallback-for=libdisplay-info \
"$DXVK_BUILD_DIR/build.$1"
cd "$DXVK_BUILD_DIR/build.$1"
ninja install
if [ $opt_devbuild -eq 0 ]; then
rm -r "$DXVK_BUILD_DIR/build.$1"
fi
}
function package {
cd "$DXVK_BUILD_DIR"
tar -czf "$DXVK_ARCHIVE_PATH" "usr"
cd ".."
rm -R "dxvk-native-$DXVK_VERSION"
}
build_arch 64 lib
build_arch 32 lib32
if [ $opt_nopackage -eq 0 ]; then
package
fi

View File

@ -10,7 +10,8 @@ if [ -z "$1" ] || [ -z "$2" ]; then
fi
DXVK_VERSION="$1"
DXVK_SRC_DIR=`dirname $(readlink -f $0)`
DXVK_SRC_DIR=$(readlink -f "$0")
DXVK_SRC_DIR=$(dirname "$DXVK_SRC_DIR")
DXVK_BUILD_DIR=$(realpath "$2")"/dxvk-$DXVK_VERSION"
DXVK_ARCHIVE_PATH=$(realpath "$2")"/dxvk-$DXVK_VERSION.tar.gz"
@ -57,14 +58,13 @@ function build_arch {
opt_strip=--strip
fi
meson --cross-file "$DXVK_SRC_DIR/$crossfile$1.txt" \
--buildtype "release" \
--prefix "$DXVK_BUILD_DIR" \
$opt_strip \
--bindir "x$1" \
--libdir "x$1" \
-Denable_tests=false \
-Dbuild_id=$opt_buildid \
meson setup --cross-file "$DXVK_SRC_DIR/$crossfile$1.txt" \
--buildtype "release" \
--prefix "$DXVK_BUILD_DIR" \
$opt_strip \
--bindir "x$1" \
--libdir "x$1" \
-Dbuild_id=$opt_buildid \
"$DXVK_BUILD_DIR/build.$1"
cd "$DXVK_BUILD_DIR/build.$1"
@ -77,11 +77,6 @@ function build_arch {
fi
}
function build_script {
cp "$DXVK_SRC_DIR/setup_dxvk.sh" "$DXVK_BUILD_DIR/setup_dxvk.sh"
chmod +x "$DXVK_BUILD_DIR/setup_dxvk.sh"
}
function package {
cd "$DXVK_BUILD_DIR/.."
tar -czf "$DXVK_ARCHIVE_PATH" "dxvk-$DXVK_VERSION"
@ -90,7 +85,6 @@ function package {
build_arch 64
build_arch 32
build_script
if [ $opt_nopackage -eq 0 ]; then
package

View File

@ -1,216 +0,0 @@
#!/usr/bin/env bash
# default directories
dxvk_lib32=${dxvk_lib32:-"x32"}
dxvk_lib64=${dxvk_lib64:-"x64"}
# figure out where we are
basedir=$(dirname "$(readlink -f $0)")
# figure out which action to perform
action="$1"
case "$action" in
install)
;;
uninstall)
;;
*)
echo "Unrecognized action: $action"
echo "Usage: $0 [install|uninstall] [--without-dxgi] [--with-d3d10] [--symlink]"
exit 1
esac
# process arguments
shift
with_dxgi=true
with_d3d10=false
file_cmd="cp -v"
while (($# > 0)); do
case "$1" in
"--without-dxgi")
with_dxgi=false
;;
"--with-d3d10")
with_d3d10=true
;;
"--symlink")
file_cmd="ln -s -v"
;;
esac
shift
done
# check wine prefix before invoking wine, so that we
# don't accidentally create one if the user screws up
if [ -n "$WINEPREFIX" ] && ! [ -f "$WINEPREFIX/system.reg" ]; then
echo "$WINEPREFIX:"' Not a valid wine prefix.' >&2
exit 1
fi
# find wine executable
export WINEDEBUG=-all
# disable mscoree and mshtml to avoid downloading
# wine gecko and mono
export WINEDLLOVERRIDES="mscoree,mshtml="
wine="wine"
wine64="wine64"
wineboot="wineboot"
# $PATH is the way for user to control where wine is located (including custom Wine versions).
# Pure 64-bit Wine (non Wow64) requries skipping 32-bit steps.
# In such case, wine64 and winebooot will be present, but wine binary will be missing,
# however it can be present in other PATHs, so it shouldn't be used, to avoid versions mixing.
wine_path=$(dirname "$(which $wineboot)")
wow64=true
if ! [ -f "$wine_path/$wine" ]; then
wine=$wine64
wow64=false
fi
# resolve 32-bit and 64-bit system32 path
winever=$($wine --version | grep wine)
if [ -z "$winever" ]; then
echo "$wine:"' Not a wine executable. Check your $wine.' >&2
exit 1
fi
# ensure wine placeholder dlls are recreated
# if they are missing
$wineboot -u
win64_sys_path=$($wine64 winepath -u 'C:\windows\system32' 2> /dev/null)
win64_sys_path="${win64_sys_path/$'\r'/}"
if $wow64; then
win32_sys_path=$($wine winepath -u 'C:\windows\system32' 2> /dev/null)
win32_sys_path="${win32_sys_path/$'\r'/}"
fi
if [ -z "$win32_sys_path" ] && [ -z "$win64_sys_path" ]; then
echo 'Failed to resolve C:\windows\system32.' >&2
exit 1
fi
# create native dll override
overrideDll() {
$wine reg add 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v $1 /d native /f >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "Failed to add override for $1"
exit 1
fi
}
# remove dll override
restoreDll() {
$wine reg delete 'HKEY_CURRENT_USER\Software\Wine\DllOverrides' /v $1 /f > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Failed to remove override for $1"
fi
}
# copy or link dxvk dll, back up original file
installFile() {
dstfile="${1}/${3}.dll"
srcfile="${basedir}/${2}/${3}.dll"
if [ -f "${srcfile}.so" ]; then
srcfile="${srcfile}.so"
fi
if ! [ -f "${srcfile}" ]; then
echo "${srcfile}: File not found. Skipping." >&2
return 1
fi
if [ -n "$1" ]; then
if [ -f "${dstfile}" ] || [ -h "${dstfile}" ]; then
if ! [ -f "${dstfile}.old" ]; then
mv -v "${dstfile}" "${dstfile}.old"
else
rm -v "${dstfile}"
fi
$file_cmd "${srcfile}" "${dstfile}"
else
echo "${dstfile}: File not found in wine prefix" >&2
return 1
fi
fi
return 0
}
# remove dxvk dll, restore original file
uninstallFile() {
dstfile="${1}/${3}.dll"
srcfile="${basedir}/${2}/${3}.dll"
if [ -f "${srcfile}.so" ]; then
srcfile="${srcfile}.so"
fi
if ! [ -f "${srcfile}" ]; then
echo "${srcfile}: File not found. Skipping." >&2
return 1
fi
if ! [ -f "${dstfile}" ] && ! [ -h "${dstfile}" ]; then
echo "${dstfile}: File not found. Skipping." >&2
return 1
fi
if [ -f "${dstfile}.old" ]; then
rm -v "${dstfile}"
mv -v "${dstfile}.old" "${dstfile}"
return 0
else
return 1
fi
}
install() {
installFile "$win64_sys_path" "$dxvk_lib64" "$1"
inst64_ret="$?"
inst32_ret=-1
if $wow64; then
installFile "$win32_sys_path" "$dxvk_lib32" "$1"
inst32_ret="$?"
fi
if (( ($inst32_ret == 0) || ($inst64_ret == 0) )); then
overrideDll "$1"
fi
}
uninstall() {
uninstallFile "$win64_sys_path" "$dxvk_lib64" "$1"
uninst64_ret="$?"
uninst32_ret=-1
if $wow64; then
uninstallFile "$win32_sys_path" "$dxvk_lib32" "$1"
uninst32_ret="$?"
fi
if (( ($uninst32_ret == 0) || ($uninst64_ret == 0) )); then
restoreDll "$1"
fi
}
# skip dxgi during install if not explicitly
# enabled, but always try to uninstall it
if $with_dxgi || [ "$action" == "uninstall" ]; then
$action dxgi
fi
$action d3d9
if $with_d3d10 || [ "$action" == "uninstall" ]; then
$action d3d10
$action d3d10_1
fi
$action d3d10core
$action d3d11

View File

@ -1,29 +0,0 @@
LIBRARY D3D10.DLL
EXPORTS
D3D10CreateDevice
D3D10CreateDeviceAndSwapChain
D3D10GetVertexShaderProfile
D3D10GetGeometryShaderProfile
D3D10GetPixelShaderProfile
D3D10CreateBlob
D3D10GetInputSignatureBlob
D3D10GetOutputSignatureBlob
D3D10ReflectShader
D3D10CompileShader
D3D10CreateEffectFromMemory
D3D10CreateEffectPoolFromMemory
D3D10CompileEffectFromMemory
D3D10DisassembleEffect
D3D10DisassembleShader
D3D10PreprocessShader
D3D10CreateStateBlock
D3D10StateBlockMaskDifference
D3D10StateBlockMaskDisableAll
D3D10StateBlockMaskDisableCapture
D3D10StateBlockMaskEnableAll
D3D10StateBlockMaskEnableCapture
D3D10StateBlockMaskGetSetting
D3D10StateBlockMaskIntersect
D3D10StateBlockMaskUnion
D3D10GetVersion
D3D10RegisterLayers

View File

@ -1,29 +0,0 @@
LIBRARY D3D10_1.DLL
EXPORTS
D3D10CreateDevice1
D3D10CreateDeviceAndSwapChain1
D3D10GetVertexShaderProfile
D3D10GetGeometryShaderProfile
D3D10GetPixelShaderProfile
D3D10CreateBlob
D3D10GetInputSignatureBlob
D3D10GetOutputSignatureBlob
D3D10ReflectShader
D3D10CompileShader
D3D10CreateEffectFromMemory
D3D10CreateEffectPoolFromMemory
D3D10CompileEffectFromMemory
D3D10DisassembleEffect
D3D10DisassembleShader
D3D10PreprocessShader
D3D10CreateStateBlock
D3D10StateBlockMaskDifference
D3D10StateBlockMaskDisableAll
D3D10StateBlockMaskDisableCapture
D3D10StateBlockMaskEnableAll
D3D10StateBlockMaskEnableCapture
D3D10StateBlockMaskGetSetting
D3D10StateBlockMaskIntersect
D3D10StateBlockMaskUnion
D3D10GetVersion
D3D10RegisterLayers

View File

@ -9,10 +9,14 @@ extern "C" {
HRESULT __stdcall D3D11CoreCreateDevice(
IDXGIFactory* pFactory,
IDXGIAdapter* pAdapter,
D3D_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
const D3D_FEATURE_LEVEL* pFeatureLevels,
UINT FeatureLevels,
ID3D11Device** ppDevice);
UINT SDKVersion,
ID3D11Device** ppDevice,
D3D_FEATURE_LEVEL* pFeatureLevel);
DLLEXPORT HRESULT __stdcall D3D10CoreCreateDevice(
@ -31,8 +35,8 @@ extern "C" {
if (FAILED(hr))
return hr;
hr = D3D11CoreCreateDevice(pFactory, pAdapter,
Flags, &FeatureLevel, 1, &d3d11Device);
hr = D3D11CoreCreateDevice(pFactory, pAdapter, D3D_DRIVER_TYPE_UNKNOWN,
nullptr, Flags, &FeatureLevel, 1, D3D11_SDK_VERSION, &d3d11Device, nullptr);
if (FAILED(hr))
return hr;

View File

@ -1,9 +0,0 @@
#pragma once
#include "d3d10_include.h"
#ifdef _MSC_VER
struct __declspec(uuid("0803425a-57f5-4dd6-9465-a87570834a08")) ID3D10StateBlock;
#else
__CRT_UUID_DECL(ID3D10StateBlock, 0x0803425a,0x57f5,0x4dd6,0x94,0x65,0xa8,0x75,0x70,0x83,0x4a,0x08);
#endif

View File

@ -1,335 +0,0 @@
#include <d3dcompiler.h>
#include "d3d10_include.h"
#include "d3d10_reflection.h"
#include "../dxgi/dxgi_adapter.h"
namespace dxvk {
Logger Logger::s_instance("d3d10.log");
}
extern "C" {
using namespace dxvk;
HRESULT __stdcall D3D10CoreCreateDevice(
IDXGIFactory* pFactory,
IDXGIAdapter* pAdapter,
UINT Flags,
D3D_FEATURE_LEVEL FeatureLevel,
ID3D10Device** ppDevice);
static HRESULT D3D10InternalCreateDeviceAndSwapChain(
IDXGIAdapter* pAdapter,
D3D10_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
D3D10_FEATURE_LEVEL1 HardwareLevel,
UINT SDKVersion,
DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
IDXGISwapChain** ppSwapChain,
REFIID deviceIID,
void** ppDevice) {
InitReturnPtr(ppDevice);
InitReturnPtr(ppSwapChain);
if (ppSwapChain && !pSwapChainDesc)
return E_INVALIDARG;
HRESULT hr;
// Get DXGI factory and adapter. This is mostly
// copied from the equivalent D3D11 functions.
Com<IDXGIFactory> dxgiFactory = nullptr;
Com<IDXGIAdapter> dxgiAdapter = pAdapter;
Com<ID3D10Device> device = nullptr;
if (!pAdapter) {
if (DriverType != D3D10_DRIVER_TYPE_HARDWARE)
Logger::warn("D3D10CreateDevice: Unsupported driver type");
hr = CreateDXGIFactory(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&dxgiFactory));
if (FAILED(hr)) {
Logger::err("D3D10CreateDevice: Failed to create a DXGI factory");
return hr;
}
hr = dxgiFactory->EnumAdapters(0, &dxgiAdapter);
if (FAILED(hr)) {
Logger::err("D3D10CreateDevice: No default adapter available");
return hr;
}
} else {
if (FAILED(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), reinterpret_cast<void**>(&dxgiFactory)))) {
Logger::err("D3D10CreateDevice: Failed to query DXGI factory from DXGI adapter");
return E_INVALIDARG;
}
if (DriverType != D3D10_DRIVER_TYPE_HARDWARE || Software)
return E_INVALIDARG;
}
hr = D3D10CoreCreateDevice(
dxgiFactory.ptr(), dxgiAdapter.ptr(),
Flags, D3D_FEATURE_LEVEL(HardwareLevel),
&device);
if (FAILED(hr))
return hr;
if (ppSwapChain) {
DXGI_SWAP_CHAIN_DESC desc = *pSwapChainDesc;
hr = dxgiFactory->CreateSwapChain(device.ptr(), &desc, ppSwapChain);
if (FAILED(hr)) {
Logger::err("D3D10CreateDevice: Failed to create swap chain");
return hr;
}
}
if (ppDevice) {
// Just assume that this succeeds
device->QueryInterface(deviceIID, ppDevice);
}
if (!ppDevice && !ppSwapChain)
return S_FALSE;
return S_OK;
}
DLLEXPORT HRESULT __stdcall D3D10CreateDevice(
IDXGIAdapter* pAdapter,
D3D10_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
UINT SDKVersion,
ID3D10Device** ppDevice) {
return D3D10InternalCreateDeviceAndSwapChain(
pAdapter, DriverType, Software, Flags,
D3D10_FEATURE_LEVEL_10_0, SDKVersion,
nullptr, nullptr,
__uuidof(ID3D10Device),
reinterpret_cast<void**>(ppDevice));
}
DLLEXPORT HRESULT __stdcall D3D10CreateDevice1(
IDXGIAdapter* pAdapter,
D3D10_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
D3D10_FEATURE_LEVEL1 HardwareLevel,
UINT SDKVersion,
ID3D10Device1** ppDevice) {
return D3D10InternalCreateDeviceAndSwapChain(
pAdapter, DriverType, Software, Flags,
HardwareLevel, SDKVersion,
nullptr, nullptr,
__uuidof(ID3D10Device1),
reinterpret_cast<void**>(ppDevice));
}
DLLEXPORT HRESULT __stdcall D3D10CreateDeviceAndSwapChain(
IDXGIAdapter* pAdapter,
D3D10_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
UINT SDKVersion,
DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
IDXGISwapChain** ppSwapChain,
ID3D10Device** ppDevice) {
return D3D10InternalCreateDeviceAndSwapChain(
pAdapter, DriverType, Software, Flags,
D3D10_FEATURE_LEVEL_10_0, SDKVersion,
pSwapChainDesc, ppSwapChain,
__uuidof(ID3D10Device),
reinterpret_cast<void**>(ppDevice));
}
DLLEXPORT HRESULT __stdcall D3D10CreateDeviceAndSwapChain1(
IDXGIAdapter* pAdapter,
D3D10_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
D3D10_FEATURE_LEVEL1 HardwareLevel,
UINT SDKVersion,
DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
IDXGISwapChain** ppSwapChain,
ID3D10Device1** ppDevice) {
return D3D10InternalCreateDeviceAndSwapChain(
pAdapter, DriverType, Software, Flags,
HardwareLevel, SDKVersion,
pSwapChainDesc, ppSwapChain,
__uuidof(ID3D10Device1),
reinterpret_cast<void**>(ppDevice));
}
const char* STDMETHODCALLTYPE D3D10GetVertexShaderProfile (ID3D10Device*) { return "vs_4_1"; }
const char* STDMETHODCALLTYPE D3D10GetGeometryShaderProfile (ID3D10Device*) { return "gs_4_1"; }
const char* STDMETHODCALLTYPE D3D10GetPixelShaderProfile (ID3D10Device*) { return "ps_4_1"; }
HRESULT STDMETHODCALLTYPE D3D10CreateBlob(SIZE_T size, LPD3D10BLOB* ppBuffer) {
return D3DCreateBlob(size, ppBuffer);
}
HRESULT STDMETHODCALLTYPE D3D10GetInputSignatureBlob(
const void* pShaderBytecode,
SIZE_T BytecodeLength,
ID3D10Blob** ppSignatureBlob) {
return D3DGetInputSignatureBlob(
pShaderBytecode,
BytecodeLength,
ppSignatureBlob);
}
HRESULT STDMETHODCALLTYPE D3D10GetOutputSignatureBlob(
const void* pShaderBytecode,
SIZE_T BytecodeLength,
ID3D10Blob** ppSignatureBlob) {
return D3DGetOutputSignatureBlob(
pShaderBytecode,
BytecodeLength,
ppSignatureBlob);
}
HRESULT STDMETHODCALLTYPE D3D10ReflectShader(
const void* pShaderBytecode,
SIZE_T BytecodeLength,
ID3D10ShaderReflection** ppReflector) {
static const GUID IID_ID3D11ShaderReflection =
{0x0a233719,0x3960,0x4578,{0x9d,0x7c,0x20,0x3b,0x8b,0x1d,0x9c,0xc1}};
InitReturnPtr(ppReflector);
Com<ID3D11ShaderReflection> d3d11Reflector = nullptr;
HRESULT hr = D3DReflect(pShaderBytecode,
BytecodeLength, IID_ID3D11ShaderReflection,
reinterpret_cast<void**>(&d3d11Reflector));
if (FAILED(hr)) {
Logger::err("D3D10ReflectShader: Failed to create ID3D11ShaderReflection");
return hr;
}
*ppReflector = ref(new D3D10ShaderReflection(d3d11Reflector.ptr()));
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D10CompileShader(
LPCSTR pSrcData,
SIZE_T SrcDataSize,
LPCSTR pFileName,
const D3D10_SHADER_MACRO* pDefines,
LPD3D10INCLUDE pInclude,
LPCSTR pFunctionName,
LPCSTR pProfile,
UINT Flags,
ID3D10Blob** ppShader,
ID3D10Blob** ppErrorMsgs) {
return D3DCompile(pSrcData, SrcDataSize, pFileName,
pDefines, pInclude, pFunctionName, pProfile, Flags,
0, ppShader, ppErrorMsgs);
}
HRESULT STDMETHODCALLTYPE D3D10CreateEffectFromMemory(
void* pData,
SIZE_T DataSize,
UINT EffectFlags,
ID3D10Device* pDevice,
ID3D10EffectPool* pEffectPool,
ID3D10Effect** ppEffect) {
Logger::warn("D3D10CreateEffectFromMemory: Not implemented");
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE D3D10CreateEffectPoolFromMemory(
void* pData,
SIZE_T DataSize,
UINT EffectFlags,
ID3D10Device* pDevice,
ID3D10EffectPool** ppEffectPool) {
Logger::warn("D3D10CreateEffectPoolFromMemory: Not implemented");
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE D3D10CompileEffectFromMemory(
void* pData,
SIZE_T DataLength,
LPCSTR pSrcFileName,
const D3D10_SHADER_MACRO* pDefines,
ID3D10Include* pInclude,
UINT ShaderFlags,
UINT EffectFlags,
ID3D10Blob** ppCompiledEffect,
ID3D10Blob** ppErrors) {
Logger::warn("D3D10CompileEffectFromMemory: Not implemented");
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE D3D10DisassembleEffect(
ID3D10Effect* pEffect,
BOOL EnableColorCode,
ID3D10Blob** ppDisassembly) {
Logger::warn("D3D10DisassembleEffect: Not implemented");
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE D3D10DisassembleShader(
const void* pShader,
SIZE_T BytecodeLength,
BOOL EnableColorCode,
LPCSTR pComments,
ID3D10Blob** ppDisassembly) {
return D3DDisassemble(
pShader, BytecodeLength,
0, pComments, ppDisassembly);
}
HRESULT STDMETHODCALLTYPE D3D10PreprocessShader(
LPCSTR pSrcData,
SIZE_T SrcDataSize,
LPCSTR pFileName,
const D3D10_SHADER_MACRO* pDefines,
LPD3D10INCLUDE pInclude,
ID3D10Blob** ppShaderText,
ID3D10Blob** ppErrorMsgs) {
return D3DPreprocess(
pSrcData, SrcDataSize,
pFileName, pDefines,
pInclude,
ppShaderText,
ppErrorMsgs);
}
UINT64 STDMETHODCALLTYPE D3D10GetVersion() {
return 0xa000100041770ull;
}
HRESULT STDMETHODCALLTYPE D3D10RegisterLayers() {
return E_NOTIMPL;
}
}

View File

@ -6,9 +6,12 @@ namespace dxvk {
D3D10Multithread::D3D10Multithread(
IUnknown* pParent,
BOOL Protected)
BOOL Protected,
BOOL Force)
: m_parent (pParent),
m_protected (Protected) {
m_protected (Protected || Force),
m_enabled (Protected),
m_forced (Force) {
}
@ -49,12 +52,18 @@ namespace dxvk {
BOOL STDMETHODCALLTYPE D3D10Multithread::SetMultithreadProtected(
BOOL bMTProtect) {
return std::exchange(m_protected, bMTProtect);
BOOL result = m_enabled;
m_enabled = bMTProtect;
if (!m_forced)
m_protected = m_enabled;
return result;
}
BOOL STDMETHODCALLTYPE D3D10Multithread::GetMultithreadProtected() {
return m_protected;
return m_enabled;
}
}

View File

@ -64,7 +64,8 @@ namespace dxvk {
D3D10Multithread(
IUnknown* pParent,
BOOL Protected);
BOOL Protected,
BOOL Force);
~D3D10Multithread();
@ -95,6 +96,8 @@ namespace dxvk {
IUnknown* m_parent;
BOOL m_protected;
BOOL m_enabled;
BOOL m_forced;
sync::RecursiveSpinlock m_mutex;

View File

@ -6,7 +6,6 @@ namespace dxvk {
class D3D10Device;
class D3D11Device;
class D3D11DeviceContext;
class D3D11Query;
class D3D10Query : public ID3D10Predicate {

View File

@ -1,326 +0,0 @@
#include "d3d10_reflection.h"
namespace dxvk {
D3D10ShaderReflectionType::D3D10ShaderReflectionType(
ID3D11ShaderReflectionType* d3d11)
: m_d3d11(d3d11) {
}
D3D10ShaderReflectionType::~D3D10ShaderReflectionType() {
}
HRESULT STDMETHODCALLTYPE D3D10ShaderReflectionType::GetDesc(
D3D10_SHADER_TYPE_DESC* pDesc) {
D3D11_SHADER_TYPE_DESC d3d11Desc;
HRESULT hr = m_d3d11->GetDesc(&d3d11Desc);
if (FAILED(hr))
return hr;
pDesc->Class = D3D10_SHADER_VARIABLE_CLASS(d3d11Desc.Class);
pDesc->Type = D3D10_SHADER_VARIABLE_TYPE (d3d11Desc.Type);
pDesc->Rows = d3d11Desc.Rows;
pDesc->Columns = d3d11Desc.Columns;
pDesc->Elements = d3d11Desc.Elements;
pDesc->Members = d3d11Desc.Members;
pDesc->Offset = d3d11Desc.Offset;
return S_OK;
}
ID3D10ShaderReflectionType* STDMETHODCALLTYPE D3D10ShaderReflectionType::GetMemberTypeByIndex(
UINT Index) {
return FindMemberType(m_d3d11->GetMemberTypeByIndex(Index));
}
ID3D10ShaderReflectionType* STDMETHODCALLTYPE D3D10ShaderReflectionType::GetMemberTypeByName(
const char* Name) {
return FindMemberType(m_d3d11->GetMemberTypeByName(Name));
}
const char* STDMETHODCALLTYPE D3D10ShaderReflectionType::GetMemberTypeName(
UINT Index) {
return m_d3d11->GetMemberTypeName(Index);
}
ID3D10ShaderReflectionType* D3D10ShaderReflectionType::FindMemberType(
ID3D11ShaderReflectionType* pMemberType) {
if (!pMemberType)
return nullptr;
auto entry = m_members.find(pMemberType);
if (entry == m_members.end()) {
entry = m_members.insert({ pMemberType,
std::make_unique<D3D10ShaderReflectionType>(pMemberType) }).first;
}
return entry->second.get();
}
D3D10ShaderReflectionVariable::D3D10ShaderReflectionVariable(ID3D11ShaderReflectionVariable* d3d11)
: m_d3d11(d3d11), m_type(m_d3d11->GetType()) {
}
D3D10ShaderReflectionVariable::~D3D10ShaderReflectionVariable() {
}
HRESULT STDMETHODCALLTYPE D3D10ShaderReflectionVariable::GetDesc(
D3D10_SHADER_VARIABLE_DESC* pDesc) {
D3D11_SHADER_VARIABLE_DESC d3d11Desc;
HRESULT hr = m_d3d11->GetDesc(&d3d11Desc);
if (FAILED(hr))
return hr;
pDesc->Name = d3d11Desc.Name;
pDesc->StartOffset = d3d11Desc.StartOffset;
pDesc->Size = d3d11Desc.Size;
pDesc->uFlags = d3d11Desc.uFlags;
pDesc->DefaultValue = d3d11Desc.DefaultValue;
return S_OK;
}
ID3D10ShaderReflectionType* STDMETHODCALLTYPE D3D10ShaderReflectionVariable::GetType() {
return &m_type;
}
D3D10ShaderReflectionConstantBuffer::D3D10ShaderReflectionConstantBuffer(
ID3D11ShaderReflectionConstantBuffer* d3d11)
: m_d3d11(d3d11) {
}
D3D10ShaderReflectionConstantBuffer::~D3D10ShaderReflectionConstantBuffer() {
}
HRESULT STDMETHODCALLTYPE D3D10ShaderReflectionConstantBuffer::GetDesc(
D3D10_SHADER_BUFFER_DESC* pDesc) {
D3D11_SHADER_BUFFER_DESC d3d11Desc;
HRESULT hr = m_d3d11->GetDesc(&d3d11Desc);
if (FAILED(hr))
return hr;
pDesc->Name = d3d11Desc.Name;
pDesc->Type = D3D10_CBUFFER_TYPE(d3d11Desc.Type);
pDesc->Variables = d3d11Desc.Variables;
pDesc->Size = d3d11Desc.Size;
pDesc->uFlags = d3d11Desc.uFlags;
return S_OK;
}
ID3D10ShaderReflectionVariable* STDMETHODCALLTYPE D3D10ShaderReflectionConstantBuffer::GetVariableByIndex(
UINT Index) {
return FindVariable(m_d3d11->GetVariableByIndex(Index));
}
ID3D10ShaderReflectionVariable* STDMETHODCALLTYPE D3D10ShaderReflectionConstantBuffer::GetVariableByName(
LPCSTR Name) {
return FindVariable(m_d3d11->GetVariableByName(Name));
}
ID3D10ShaderReflectionVariable* D3D10ShaderReflectionConstantBuffer::FindVariable(
ID3D11ShaderReflectionVariable* pVariable) {
if (!pVariable)
return nullptr;
auto entry = m_variables.find(pVariable);
if (entry == m_variables.end()) {
entry = m_variables.emplace(
std::piecewise_construct,
std::forward_as_tuple(pVariable),
std::forward_as_tuple(pVariable)).first;
}
return &entry->second;
}
D3D10ShaderReflection::D3D10ShaderReflection(ID3D11ShaderReflection* d3d11)
: m_d3d11(d3d11) {
}
D3D10ShaderReflection::~D3D10ShaderReflection() {
}
HRESULT STDMETHODCALLTYPE D3D10ShaderReflection::QueryInterface(
REFIID riid,
void** ppvObject) {
if (ppvObject == nullptr)
return E_POINTER;
static const GUID IID_ID3D10ShaderReflection
= {0xd40e20b6,0xf8f7,0x42ad,{0xab,0x20,0x4b,0xaf,0x8f,0x15,0xdf,0xaa}};
if (riid == __uuidof(IUnknown)
|| riid == IID_ID3D10ShaderReflection) {
*ppvObject = ref(this);
return S_OK;
}
return E_NOINTERFACE;
}
HRESULT STDMETHODCALLTYPE D3D10ShaderReflection::GetDesc(
D3D10_SHADER_DESC* pDesc) {
D3D11_SHADER_DESC d3d11Desc;
HRESULT hr = m_d3d11->GetDesc(&d3d11Desc);
if (FAILED(hr))
return hr;
pDesc->Version = d3d11Desc.Version;
pDesc->Creator = d3d11Desc.Creator;
pDesc->Flags = d3d11Desc.Flags;
pDesc->ConstantBuffers = d3d11Desc.ConstantBuffers;
pDesc->BoundResources = d3d11Desc.BoundResources;
pDesc->InputParameters = d3d11Desc.InputParameters;
pDesc->OutputParameters = d3d11Desc.OutputParameters;
pDesc->InstructionCount = d3d11Desc.InstructionCount;
pDesc->TempRegisterCount = d3d11Desc.TempRegisterCount;
pDesc->TempArrayCount = d3d11Desc.TempArrayCount;
pDesc->DefCount = d3d11Desc.DefCount;
pDesc->DclCount = d3d11Desc.DclCount;
pDesc->TextureNormalInstructions = d3d11Desc.TextureNormalInstructions;
pDesc->TextureLoadInstructions = d3d11Desc.TextureLoadInstructions;
pDesc->TextureCompInstructions = d3d11Desc.TextureCompInstructions;
pDesc->TextureBiasInstructions = d3d11Desc.TextureBiasInstructions;
pDesc->TextureGradientInstructions = d3d11Desc.TextureGradientInstructions;
pDesc->FloatInstructionCount = d3d11Desc.FloatInstructionCount;
pDesc->IntInstructionCount = d3d11Desc.IntInstructionCount;
pDesc->UintInstructionCount = d3d11Desc.UintInstructionCount;
pDesc->StaticFlowControlCount = d3d11Desc.StaticFlowControlCount;
pDesc->DynamicFlowControlCount = d3d11Desc.DynamicFlowControlCount;
pDesc->MacroInstructionCount = d3d11Desc.MacroInstructionCount;
pDesc->ArrayInstructionCount = d3d11Desc.ArrayInstructionCount;
pDesc->CutInstructionCount = d3d11Desc.CutInstructionCount;
pDesc->EmitInstructionCount = d3d11Desc.EmitInstructionCount;
pDesc->GSOutputTopology = D3D10_PRIMITIVE_TOPOLOGY(d3d11Desc.GSOutputTopology);
pDesc->GSMaxOutputVertexCount = d3d11Desc.GSMaxOutputVertexCount;
return S_OK;
}
ID3D10ShaderReflectionConstantBuffer* STDMETHODCALLTYPE
D3D10ShaderReflection::GetConstantBufferByIndex(
UINT Index) {
return FindConstantBuffer(m_d3d11->GetConstantBufferByIndex(Index));
}
ID3D10ShaderReflectionConstantBuffer* STDMETHODCALLTYPE
D3D10ShaderReflection::GetConstantBufferByName(
LPCSTR Name) {
return FindConstantBuffer(m_d3d11->GetConstantBufferByName(Name));
}
HRESULT STDMETHODCALLTYPE D3D10ShaderReflection::GetInputParameterDesc(
UINT ParameterIndex,
D3D10_SIGNATURE_PARAMETER_DESC* pDesc) {
D3D11_SIGNATURE_PARAMETER_DESC d3d11Desc;
HRESULT hr = m_d3d11->GetInputParameterDesc(ParameterIndex, &d3d11Desc);
if (FAILED(hr))
return hr;
ConvertSignatureParameterDesc(&d3d11Desc, pDesc);
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D10ShaderReflection::GetOutputParameterDesc(
UINT ParameterIndex,
D3D10_SIGNATURE_PARAMETER_DESC* pDesc) {
D3D11_SIGNATURE_PARAMETER_DESC d3d11Desc;
HRESULT hr = m_d3d11->GetOutputParameterDesc(ParameterIndex, &d3d11Desc);
if (FAILED(hr))
return hr;
ConvertSignatureParameterDesc(&d3d11Desc, pDesc);
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D10ShaderReflection::GetResourceBindingDesc(
UINT ResourceIndex,
D3D10_SHADER_INPUT_BIND_DESC* pDesc) {
D3D11_SHADER_INPUT_BIND_DESC d3d11Desc;
HRESULT hr = m_d3d11->GetResourceBindingDesc(
ResourceIndex, &d3d11Desc);
if (FAILED(hr))
return hr;
pDesc->Name = d3d11Desc.Name;
pDesc->Type = D3D10_SHADER_INPUT_TYPE(d3d11Desc.Type);
pDesc->BindPoint = d3d11Desc.BindPoint;
pDesc->BindCount = d3d11Desc.BindCount;
pDesc->uFlags = d3d11Desc.uFlags;
pDesc->ReturnType = D3D10_RESOURCE_RETURN_TYPE(d3d11Desc.ReturnType);
pDesc->Dimension = D3D10_SRV_DIMENSION (d3d11Desc.Dimension);
pDesc->NumSamples = d3d11Desc.NumSamples;
return S_OK;
}
ID3D10ShaderReflectionConstantBuffer* D3D10ShaderReflection::FindConstantBuffer(
ID3D11ShaderReflectionConstantBuffer* pConstantBuffer) {
if (!pConstantBuffer)
return nullptr;
auto entry = m_constantBuffers.find(pConstantBuffer);
if (entry == m_constantBuffers.end()) {
entry = m_constantBuffers.emplace(
std::piecewise_construct,
std::forward_as_tuple(pConstantBuffer),
std::forward_as_tuple(pConstantBuffer)).first;
}
return &entry->second;
}
void D3D10ShaderReflection::ConvertSignatureParameterDesc(
const D3D11_SIGNATURE_PARAMETER_DESC* pSrcDesc,
D3D10_SIGNATURE_PARAMETER_DESC* pDstDesc) {
pDstDesc->SemanticName = pSrcDesc->SemanticName;
pDstDesc->SemanticIndex = pSrcDesc->SemanticIndex;
pDstDesc->Register = pSrcDesc->Register;
pDstDesc->SystemValueType = D3D10_NAME(pSrcDesc->SystemValueType);
pDstDesc->ComponentType = D3D10_REGISTER_COMPONENT_TYPE(pSrcDesc->ComponentType);
pDstDesc->Mask = pSrcDesc->Mask;
pDstDesc->ReadWriteMask = pSrcDesc->ReadWriteMask;
}
}

View File

@ -1,163 +0,0 @@
#pragma once
#include <unordered_map>
#include <vector>
#include "d3d10_include.h"
#include <d3d10shader.h>
#include <d3d11shader.h>
namespace dxvk {
class D3D10ShaderReflectionType : public ID3D10ShaderReflectionType {
public:
D3D10ShaderReflectionType(
ID3D11ShaderReflectionType* d3d11);
~D3D10ShaderReflectionType();
HRESULT STDMETHODCALLTYPE GetDesc(
D3D10_SHADER_TYPE_DESC* pDesc);
ID3D10ShaderReflectionType* STDMETHODCALLTYPE GetMemberTypeByIndex(
UINT Index);
ID3D10ShaderReflectionType* STDMETHODCALLTYPE GetMemberTypeByName(
const char* Name);
const char* STDMETHODCALLTYPE GetMemberTypeName(
UINT Index);
ID3D11ShaderReflectionType* GetD3D11Iface() {
return m_d3d11;
}
private:
ID3D11ShaderReflectionType* m_d3d11;
std::unordered_map<
ID3D11ShaderReflectionType*,
std::unique_ptr<D3D10ShaderReflectionType>> m_members;
ID3D10ShaderReflectionType* FindMemberType(
ID3D11ShaderReflectionType* pMemberType);
};
class D3D10ShaderReflectionVariable : public ID3D10ShaderReflectionVariable {
public:
D3D10ShaderReflectionVariable(
ID3D11ShaderReflectionVariable* d3d11);
~D3D10ShaderReflectionVariable();
HRESULT STDMETHODCALLTYPE GetDesc(
D3D10_SHADER_VARIABLE_DESC* pDesc);
ID3D10ShaderReflectionType* STDMETHODCALLTYPE GetType();
ID3D11ShaderReflectionVariable* STDMETHODCALLTYPE GetD3D11Iface() {
return m_d3d11;
}
private:
ID3D11ShaderReflectionVariable* m_d3d11;
D3D10ShaderReflectionType m_type;
};
class D3D10ShaderReflectionConstantBuffer : public ID3D10ShaderReflectionConstantBuffer {
public:
D3D10ShaderReflectionConstantBuffer(
ID3D11ShaderReflectionConstantBuffer* d3d11);
~D3D10ShaderReflectionConstantBuffer();
HRESULT STDMETHODCALLTYPE GetDesc(
D3D10_SHADER_BUFFER_DESC* pDesc);
ID3D10ShaderReflectionVariable* STDMETHODCALLTYPE GetVariableByIndex(
UINT Index);
ID3D10ShaderReflectionVariable* STDMETHODCALLTYPE GetVariableByName(
LPCSTR Name);
ID3D11ShaderReflectionConstantBuffer* STDMETHODCALLTYPE GetD3D11Iface() {
return m_d3d11;
}
private:
ID3D11ShaderReflectionConstantBuffer* m_d3d11;
std::unordered_map<
ID3D11ShaderReflectionVariable*,
D3D10ShaderReflectionVariable> m_variables;
ID3D10ShaderReflectionVariable* FindVariable(
ID3D11ShaderReflectionVariable* pVariable);
};
class D3D10ShaderReflection : public ComObject<ID3D10ShaderReflection> {
public:
D3D10ShaderReflection(ID3D11ShaderReflection* d3d11);
~D3D10ShaderReflection();
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject);
HRESULT STDMETHODCALLTYPE GetDesc(
D3D10_SHADER_DESC* pDesc);
ID3D10ShaderReflectionConstantBuffer* STDMETHODCALLTYPE GetConstantBufferByIndex(
UINT Index);
ID3D10ShaderReflectionConstantBuffer* STDMETHODCALLTYPE GetConstantBufferByName(
LPCSTR Name);
HRESULT STDMETHODCALLTYPE GetInputParameterDesc(
UINT ParameterIndex,
D3D10_SIGNATURE_PARAMETER_DESC* pDesc);
HRESULT STDMETHODCALLTYPE GetOutputParameterDesc(
UINT ParameterIndex,
D3D10_SIGNATURE_PARAMETER_DESC* pDesc);
HRESULT STDMETHODCALLTYPE GetResourceBindingDesc(
UINT ResourceIndex,
D3D10_SHADER_INPUT_BIND_DESC* pDesc);
private:
Com<ID3D11ShaderReflection> m_d3d11;
std::unordered_map<
ID3D11ShaderReflectionConstantBuffer*,
D3D10ShaderReflectionConstantBuffer> m_constantBuffers;
ID3D10ShaderReflectionConstantBuffer* FindConstantBuffer(
ID3D11ShaderReflectionConstantBuffer* pConstantBuffer);
void ConvertSignatureParameterDesc(
const D3D11_SIGNATURE_PARAMETER_DESC* pSrcDesc,
D3D10_SIGNATURE_PARAMETER_DESC* pDstDesc);
};
}

View File

@ -1,432 +0,0 @@
#include "d3d10_state_block.h"
#define MAKE_STATE_TYPE(field, count) { offsetof(D3D10_STATE_BLOCK_MASK, field), count }
namespace dxvk {
static const std::array<std::pair<size_t, size_t>, 24> g_stateTypes = {{
MAKE_STATE_TYPE(SOBuffers, 1),
MAKE_STATE_TYPE(OMRenderTargets, 1),
MAKE_STATE_TYPE(OMDepthStencilState, 1),
MAKE_STATE_TYPE(OMBlendState, 1),
MAKE_STATE_TYPE(VS, 1),
MAKE_STATE_TYPE(VSSamplers, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT),
MAKE_STATE_TYPE(VSShaderResources, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT),
MAKE_STATE_TYPE(VSConstantBuffers, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT),
MAKE_STATE_TYPE(GS, 1),
MAKE_STATE_TYPE(GSSamplers, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT),
MAKE_STATE_TYPE(GSShaderResources, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT),
MAKE_STATE_TYPE(GSConstantBuffers, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT),
MAKE_STATE_TYPE(PS, 1),
MAKE_STATE_TYPE(PSSamplers, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT),
MAKE_STATE_TYPE(PSShaderResources, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT),
MAKE_STATE_TYPE(PSConstantBuffers, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT),
MAKE_STATE_TYPE(IAVertexBuffers, D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT),
MAKE_STATE_TYPE(IAIndexBuffer, 1),
MAKE_STATE_TYPE(IAInputLayout, 1),
MAKE_STATE_TYPE(IAPrimitiveTopology, 1),
MAKE_STATE_TYPE(RSViewports, 1),
MAKE_STATE_TYPE(RSScissorRects, 1),
MAKE_STATE_TYPE(RSRasterizerState, 1),
MAKE_STATE_TYPE(Predication, 1),
}};
D3D10StateBlock::D3D10StateBlock(
ID3D10Device* pDevice,
const D3D10_STATE_BLOCK_MASK* pMask)
: m_device(pDevice), m_mask(*pMask) {
}
D3D10StateBlock::~D3D10StateBlock() {
}
HRESULT STDMETHODCALLTYPE D3D10StateBlock::QueryInterface(
REFIID riid,
void** ppvObject) {
if (ppvObject == nullptr)
return E_POINTER;
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D10StateBlock)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D10StateBlock::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
return E_NOINTERFACE;
}
HRESULT STDMETHODCALLTYPE D3D10StateBlock::Capture() {
m_state = D3D10_STATE_BLOCK_STATE();
if (TestBit(&m_mask.VS, 0)) m_device->VSGetShader(&m_state.vs);
if (TestBit(&m_mask.GS, 0)) m_device->GSGetShader(&m_state.gs);
if (TestBit(&m_mask.PS, 0)) m_device->PSGetShader(&m_state.ps);
for (uint32_t i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; i++) {
if (TestBit(m_mask.VSSamplers, i)) m_device->VSGetSamplers(i, 1, &m_state.vsSso[i]);
if (TestBit(m_mask.GSSamplers, i)) m_device->GSGetSamplers(i, 1, &m_state.gsSso[i]);
if (TestBit(m_mask.PSSamplers, i)) m_device->PSGetSamplers(i, 1, &m_state.psSso[i]);
}
for (uint32_t i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; i++) {
if (TestBit(m_mask.VSShaderResources, i)) m_device->VSGetShaderResources(i, 1, &m_state.vsSrv[i]);
if (TestBit(m_mask.GSShaderResources, i)) m_device->GSGetShaderResources(i, 1, &m_state.gsSrv[i]);
if (TestBit(m_mask.PSShaderResources, i)) m_device->PSGetShaderResources(i, 1, &m_state.psSrv[i]);
}
for (uint32_t i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; i++) {
if (TestBit(m_mask.VSConstantBuffers, i)) m_device->VSGetConstantBuffers(i, 1, &m_state.vsCbo[i]);
if (TestBit(m_mask.GSConstantBuffers, i)) m_device->GSGetConstantBuffers(i, 1, &m_state.gsCbo[i]);
if (TestBit(m_mask.PSConstantBuffers, i)) m_device->PSGetConstantBuffers(i, 1, &m_state.psCbo[i]);
}
for (uint32_t i = 0; i < D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; i++) {
if (TestBit(m_mask.IAVertexBuffers, i)) {
m_device->IAGetVertexBuffers(i, 1,
&m_state.iaVertexBuffers[i],
&m_state.iaVertexOffsets[i],
&m_state.iaVertexStrides[i]);
}
}
if (TestBit(&m_mask.IAIndexBuffer, 0)) {
m_device->IAGetIndexBuffer(
&m_state.iaIndexBuffer,
&m_state.iaIndexFormat,
&m_state.iaIndexOffset);
}
if (TestBit(&m_mask.IAInputLayout, 0))
m_device->IAGetInputLayout(&m_state.iaInputLayout);
if (TestBit(&m_mask.IAPrimitiveTopology, 0))
m_device->IAGetPrimitiveTopology(&m_state.iaTopology);
if (TestBit(&m_mask.OMRenderTargets, 0)) {
m_device->OMGetRenderTargets(
D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT,
&m_state.omRtv[0], &m_state.omDsv);
}
if (TestBit(&m_mask.OMDepthStencilState, 0)) {
m_device->OMGetDepthStencilState(
&m_state.omDepthStencilState,
&m_state.omStencilRef);
}
if (TestBit(&m_mask.OMBlendState, 0)) {
m_device->OMGetBlendState(
&m_state.omBlendState,
m_state.omBlendFactor,
&m_state.omSampleMask);
}
if (TestBit(&m_mask.RSViewports, 0)) {
m_device->RSGetViewports(&m_state.rsViewportCount, nullptr);
m_device->RSGetViewports(&m_state.rsViewportCount, m_state.rsViewports);
}
if (TestBit(&m_mask.RSScissorRects, 0)) {
m_device->RSGetScissorRects(&m_state.rsScissorCount, nullptr);
m_device->RSGetScissorRects(&m_state.rsScissorCount, m_state.rsScissors);
}
if (TestBit(&m_mask.RSRasterizerState, 0))
m_device->RSGetState(&m_state.rsState);
if (TestBit(&m_mask.SOBuffers, 0)) {
m_device->SOGetTargets(
D3D10_SO_BUFFER_SLOT_COUNT,
&m_state.soBuffers[0],
&m_state.soOffsets[0]);
}
if (TestBit(&m_mask.Predication, 0))
m_device->GetPredication(&m_state.predicate, &m_state.predicateInvert);
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D10StateBlock::Apply() {
if (TestBit(&m_mask.VS, 0)) m_device->VSSetShader(m_state.vs.ptr());
if (TestBit(&m_mask.GS, 0)) m_device->GSSetShader(m_state.gs.ptr());
if (TestBit(&m_mask.PS, 0)) m_device->PSSetShader(m_state.ps.ptr());
for (uint32_t i = 0; i < D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT; i++) {
if (TestBit(m_mask.VSSamplers, i)) m_device->VSSetSamplers(i, 1, &m_state.vsSso[i]);
if (TestBit(m_mask.GSSamplers, i)) m_device->GSSetSamplers(i, 1, &m_state.gsSso[i]);
if (TestBit(m_mask.PSSamplers, i)) m_device->PSSetSamplers(i, 1, &m_state.psSso[i]);
}
for (uint32_t i = 0; i < D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; i++) {
if (TestBit(m_mask.VSShaderResources, i)) m_device->VSSetShaderResources(i, 1, &m_state.vsSrv[i]);
if (TestBit(m_mask.GSShaderResources, i)) m_device->GSSetShaderResources(i, 1, &m_state.gsSrv[i]);
if (TestBit(m_mask.PSShaderResources, i)) m_device->PSSetShaderResources(i, 1, &m_state.psSrv[i]);
}
for (uint32_t i = 0; i < D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; i++) {
if (TestBit(m_mask.VSConstantBuffers, i)) m_device->VSSetConstantBuffers(i, 1, &m_state.vsCbo[i]);
if (TestBit(m_mask.GSConstantBuffers, i)) m_device->GSSetConstantBuffers(i, 1, &m_state.gsCbo[i]);
if (TestBit(m_mask.PSConstantBuffers, i)) m_device->PSSetConstantBuffers(i, 1, &m_state.psCbo[i]);
}
for (uint32_t i = 0; i < D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; i++) {
if (TestBit(m_mask.IAVertexBuffers, i)) {
m_device->IASetVertexBuffers(i, 1,
&m_state.iaVertexBuffers[i],
&m_state.iaVertexOffsets[i],
&m_state.iaVertexStrides[i]);
}
}
if (TestBit(&m_mask.IAIndexBuffer, 0)) {
m_device->IASetIndexBuffer(
m_state.iaIndexBuffer.ptr(),
m_state.iaIndexFormat,
m_state.iaIndexOffset);
}
if (TestBit(&m_mask.IAInputLayout, 0))
m_device->IASetInputLayout(m_state.iaInputLayout.ptr());
if (TestBit(&m_mask.IAPrimitiveTopology, 0))
m_device->IASetPrimitiveTopology(m_state.iaTopology);
if (TestBit(&m_mask.OMRenderTargets, 0)) {
m_device->OMSetRenderTargets(
D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT,
&m_state.omRtv[0], m_state.omDsv.ptr());
}
if (TestBit(&m_mask.OMDepthStencilState, 0)) {
m_device->OMSetDepthStencilState(
m_state.omDepthStencilState.ptr(),
m_state.omStencilRef);
}
if (TestBit(&m_mask.OMBlendState, 0)) {
m_device->OMSetBlendState(
m_state.omBlendState.ptr(),
m_state.omBlendFactor,
m_state.omSampleMask);
}
if (TestBit(&m_mask.RSViewports, 0))
m_device->RSSetViewports(m_state.rsViewportCount, m_state.rsViewports);
if (TestBit(&m_mask.RSScissorRects, 0))
m_device->RSSetScissorRects(m_state.rsScissorCount, m_state.rsScissors);
if (TestBit(&m_mask.RSRasterizerState, 0))
m_device->RSSetState(m_state.rsState.ptr());
if (TestBit(&m_mask.SOBuffers, 0)) {
m_device->SOSetTargets(
D3D10_SO_BUFFER_SLOT_COUNT,
&m_state.soBuffers[0],
&m_state.soOffsets[0]);
}
if (TestBit(&m_mask.Predication, 0))
m_device->SetPredication(m_state.predicate.ptr(), m_state.predicateInvert);
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D10StateBlock::GetDevice(
ID3D10Device** ppDevice) {
Logger::err("D3D10StateBlock::GetDevice: Stub");
return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE D3D10StateBlock::ReleaseAllDeviceObjects() {
// Not entirely sure if this is correct?
m_state = D3D10_STATE_BLOCK_STATE();
return S_OK;
}
BOOL D3D10StateBlock::TestBit(
const BYTE* pMask,
UINT Idx) {
uint32_t byte = Idx / 8;
uint32_t bit = Idx % 8;
return (pMask[byte] & (1 << bit)) != 0;
}
}
extern "C" {
using namespace dxvk;
HRESULT STDMETHODCALLTYPE D3D10CreateStateBlock(
ID3D10Device* pDevice,
D3D10_STATE_BLOCK_MASK* pStateBlockMask,
ID3D10StateBlock** ppStateBlock) {
InitReturnPtr(ppStateBlock);
if (!pDevice || !pStateBlockMask || !ppStateBlock)
return E_INVALIDARG;
*ppStateBlock = ref(new D3D10StateBlock(pDevice, pStateBlockMask));
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D10StateBlockMaskEnableCapture(
D3D10_STATE_BLOCK_MASK* pMask,
D3D10_DEVICE_STATE_TYPES StateType,
UINT StartIdx,
UINT Count) {
if (!pMask || !StateType || StateType > g_stateTypes.size())
return E_INVALIDARG;
auto pair = g_stateTypes[uint32_t(StateType) - 1];
auto mask = reinterpret_cast<BYTE*>(pMask) + pair.first;
if (StartIdx + Count > pair.second)
return E_INVALIDARG;
for (uint32_t i = StartIdx; i < StartIdx + Count; i++) {
uint32_t byte = i / 8;
uint32_t bit = i % 8;
mask[byte] |= 1 << bit;
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D10StateBlockMaskDisableCapture(
D3D10_STATE_BLOCK_MASK* pMask,
D3D10_DEVICE_STATE_TYPES StateType,
UINT StartIdx,
UINT Count) {
if (!pMask || !StateType || StateType > g_stateTypes.size())
return E_INVALIDARG;
auto pair = g_stateTypes[uint32_t(StateType) - 1];
auto mask = reinterpret_cast<BYTE*>(pMask) + pair.first;
if (StartIdx + Count > pair.second)
return E_INVALIDARG;
for (uint32_t i = StartIdx; i < StartIdx + Count; i++) {
uint32_t byte = i / 8;
uint32_t bit = i % 8;
mask[byte] &= ~(1 << bit);
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D10StateBlockMaskEnableAll(
D3D10_STATE_BLOCK_MASK* pMask) {
if (!pMask)
return E_INVALIDARG;
*pMask = D3D10_STATE_BLOCK_MASK();
for (size_t i = 0; i < g_stateTypes.size(); i++) {
D3D10StateBlockMaskEnableCapture(pMask,
D3D10_DEVICE_STATE_TYPES(i + 1),
0, g_stateTypes[i].second);
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D10StateBlockMaskDisableAll(
D3D10_STATE_BLOCK_MASK* pMask) {
if (!pMask)
return E_INVALIDARG;
*pMask = D3D10_STATE_BLOCK_MASK();
return S_OK;
}
BOOL STDMETHODCALLTYPE D3D10StateBlockMaskGetSetting(
D3D10_STATE_BLOCK_MASK* pMask,
D3D10_DEVICE_STATE_TYPES StateType,
UINT Idx) {
if (!pMask || !StateType || StateType > g_stateTypes.size())
return FALSE;
auto pair = g_stateTypes[uint32_t(StateType) - 1];
auto mask = reinterpret_cast<BYTE*>(pMask) + pair.first;
if (Idx >= pair.second)
return FALSE;
uint32_t byte = Idx / 8;
uint32_t bit = Idx % 8;
return (mask[byte] & (1 << bit)) != 0;
}
HRESULT STDMETHODCALLTYPE D3D10StateBlockMaskDifference(
D3D10_STATE_BLOCK_MASK* pA,
D3D10_STATE_BLOCK_MASK* pB,
D3D10_STATE_BLOCK_MASK* pResult) {
if (!pA || !pB || !pResult)
return E_INVALIDARG;
auto a = reinterpret_cast<const BYTE*>(pA);
auto b = reinterpret_cast<const BYTE*>(pB);
auto r = reinterpret_cast<BYTE*>(pResult);
for (size_t i = 0; i < sizeof(D3D10_STATE_BLOCK_MASK); i++)
r[i] = a[i] ^ b[i];
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D10StateBlockMaskIntersect(
D3D10_STATE_BLOCK_MASK* pA,
D3D10_STATE_BLOCK_MASK* pB,
D3D10_STATE_BLOCK_MASK* pResult) {
if (!pA || !pB || !pResult)
return E_INVALIDARG;
auto a = reinterpret_cast<const BYTE*>(pA);
auto b = reinterpret_cast<const BYTE*>(pB);
auto r = reinterpret_cast<BYTE*>(pResult);
for (size_t i = 0; i < sizeof(D3D10_STATE_BLOCK_MASK); i++)
r[i] = a[i] & b[i];
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D10StateBlockMaskUnion(
D3D10_STATE_BLOCK_MASK* pA,
D3D10_STATE_BLOCK_MASK* pB,
D3D10_STATE_BLOCK_MASK* pResult) {
if (!pA || !pB || !pResult)
return E_INVALIDARG;
auto a = reinterpret_cast<const BYTE*>(pA);
auto b = reinterpret_cast<const BYTE*>(pB);
auto r = reinterpret_cast<BYTE*>(pResult);
for (size_t i = 0; i < sizeof(D3D10_STATE_BLOCK_MASK); i++)
r[i] = a[i] | b[i];
return S_OK;
}
}

View File

@ -1,82 +0,0 @@
#pragma once
#include "d3d10_include.h"
#include "d3d10_interfaces.h"
namespace dxvk {
struct D3D10_STATE_BLOCK_STATE {
Com<ID3D10VertexShader> vs = { };
Com<ID3D10SamplerState> vsSso[D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT] = { };
Com<ID3D10ShaderResourceView> vsSrv[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = { };
Com<ID3D10Buffer> vsCbo[D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT] = { };
Com<ID3D10GeometryShader> gs = { };
Com<ID3D10SamplerState> gsSso[D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT] = { };
Com<ID3D10ShaderResourceView> gsSrv[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = { };
Com<ID3D10Buffer> gsCbo[D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT] = { };
Com<ID3D10PixelShader> ps = { };
Com<ID3D10SamplerState> psSso[D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT] = { };
Com<ID3D10ShaderResourceView> psSrv[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = { };
Com<ID3D10Buffer> psCbo[D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT] = { };
Com<ID3D10Buffer> iaVertexBuffers[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT] = { };
UINT iaVertexOffsets[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT] = { };
UINT iaVertexStrides[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT] = { };
Com<ID3D10Buffer> iaIndexBuffer = { };
DXGI_FORMAT iaIndexFormat = DXGI_FORMAT_UNKNOWN;
UINT iaIndexOffset = 0;
Com<ID3D10InputLayout> iaInputLayout = nullptr;
D3D10_PRIMITIVE_TOPOLOGY iaTopology = D3D10_PRIMITIVE_TOPOLOGY_UNDEFINED;
Com<ID3D10RenderTargetView> omRtv[D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT] = { };
Com<ID3D10DepthStencilView> omDsv = { };
Com<ID3D10DepthStencilState> omDepthStencilState = { };
UINT omStencilRef = 0;
Com<ID3D10BlendState> omBlendState = { };
FLOAT omBlendFactor[4] = { };
UINT omSampleMask = 0;
UINT rsViewportCount = 0;
D3D10_VIEWPORT rsViewports[D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE] = { };
UINT rsScissorCount = 0;
RECT rsScissors [D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE] = { };
Com<ID3D10RasterizerState> rsState = { };
Com<ID3D10Buffer> soBuffers[D3D10_SO_BUFFER_SLOT_COUNT] = { };
UINT soOffsets[D3D10_SO_BUFFER_SLOT_COUNT] = { };
Com<ID3D10Predicate> predicate = { };
BOOL predicateInvert = FALSE;
};
class D3D10StateBlock : public ComObject<ID3D10StateBlock> {
public:
D3D10StateBlock(
ID3D10Device* pDevice,
const D3D10_STATE_BLOCK_MASK* pMask);
~D3D10StateBlock();
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject);
HRESULT STDMETHODCALLTYPE Capture();
HRESULT STDMETHODCALLTYPE Apply();
HRESULT STDMETHODCALLTYPE GetDevice(
ID3D10Device** ppDevice);
HRESULT STDMETHODCALLTYPE ReleaseAllDeviceObjects();
private:
Com<ID3D10Device> m_device;
D3D10_STATE_BLOCK_MASK m_mask;
D3D10_STATE_BLOCK_STATE m_state;
static BOOL TestBit(
const BYTE* pMask,
UINT Idx);
};
}

9
src/d3d10/d3d10core.sym Normal file
View File

@ -0,0 +1,9 @@
{
global:
D3D10CoreCreateDevice;
D3D10CoreGetVersion;
D3D10CoreRegisterLayers;
local:
*;
};

View File

@ -1,48 +1,30 @@
d3d10_res = wrc_generator.process('version10.rc')
d3d10_1_res = wrc_generator.process('version10_1.rc')
d3d10_core_res = wrc_generator.process('version10_core.rc')
d3d10_core_src = [
'd3d10_core.cpp',
]
d3d10_main_src = [
'd3d10_main.cpp',
'd3d10_reflection.cpp',
'd3d10_state_block.cpp',
]
d3d10_core_ld_args = []
d3d10_core_link_depends = []
if platform == 'windows'
d3d10_d3d11_dep = lib_d3d11
else
d3d10_core_ld_args += [ '-Wl,--version-script', join_paths(meson.current_source_dir(), 'd3d10core.sym') ]
d3d10_core_link_depends += files('d3d10core.sym')
d3d10_d3d11_dep = d3d11_dep
endif
d3d10_core_dll = shared_library('d3d10core'+dll_ext, d3d10_core_src, d3d10_core_res,
name_prefix : '',
dependencies : [ d3d11_dep ],
name_prefix : dxvk_name_prefix,
dependencies : [ d3d10_d3d11_dep ],
include_directories : dxvk_include_path,
install : true,
vs_module_defs : 'd3d10core'+def_spec_ext,
link_args : d3d10_core_ld_args,
link_depends : [ d3d10_core_link_depends ],
)
d3d10_core_dep = declare_dependency(
link_with : [ d3d10_core_dll ],
)
d3d10_deps = [ lib_d3dcompiler_43, lib_dxgi, dxbc_dep, dxvk_dep, d3d10_core_dep ]
d3d10_dll = shared_library('d3d10'+dll_ext, d3d10_main_src, d3d10_res,
name_prefix : '',
dependencies : [ d3d10_deps ],
include_directories : dxvk_include_path,
install : true,
vs_module_defs : 'd3d10'+def_spec_ext,
)
d3d10_1_dll = shared_library('d3d10_1'+dll_ext, d3d10_main_src, d3d10_1_res,
name_prefix : '',
dependencies : [ d3d10_deps ],
include_directories : dxvk_include_path,
install : true,
vs_module_defs : 'd3d10_1'+def_spec_ext,
)
d3d10_dep = declare_dependency(
link_with : [ d3d10_dll, d3d10_1_dll, d3d10_core_dll ],
include_directories : [ dxvk_include_path ],
)

View File

@ -1,32 +0,0 @@
#include <windows.h>
// DLL version information.
VS_VERSION_INFO VERSIONINFO
FILEVERSION 10,0,17763,1
PRODUCTVERSION 10,0,17763,1
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080904b0"
BEGIN
VALUE "CompanyName", "DXVK"
VALUE "FileDescription", "Direct3D 10 Runtime"
VALUE "FileVersion", "10.0.17763.1 (WinBuild.160101.0800)"
VALUE "InternalName", "D3D10.dll"
VALUE "LegalCopyright", "zlib/libpng license"
VALUE "OriginalFilename", "D3D10.dll"
VALUE "ProductName", "DXVK"
VALUE "ProductVersion", "10.0.17763.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0809, 1200
END
END

View File

@ -1,32 +0,0 @@
#include <windows.h>
// DLL version information.
VS_VERSION_INFO VERSIONINFO
FILEVERSION 10,0,17763,1
PRODUCTVERSION 10,0,17763,1
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080904b0"
BEGIN
VALUE "CompanyName", "DXVK"
VALUE "FileDescription", "Direct3D 10.1 Runtime"
VALUE "FileVersion", "10.0.17763.1 (WinBuild.160101.0800)"
VALUE "InternalName", "D3D10_1.dll"
VALUE "LegalCopyright", "zlib/libpng license"
VALUE "OriginalFilename", "D3D10_1.dll"
VALUE "ProductName", "DXVK"
VALUE "ProductVersion", "10.0.17763.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0809, 1200
END
END

10
src/d3d11/d3d11.sym Normal file
View File

@ -0,0 +1,10 @@
{
global:
D3D11CoreCreateDevice;
D3D11CreateDevice;
D3D11CreateDeviceAndSwapChain;
D3D11On12CreateDevice;
local:
*;
};

View File

@ -1,8 +1,10 @@
#include "d3d11_annotation.h"
#include "d3d11_context.h"
#include "d3d11_context_def.h"
#include "d3d11_context_imm.h"
#include "d3d11_device.h"
#include "../util/util_misc.h"
#include "../util/util_win32_compat.h"
namespace dxvk {
@ -30,46 +32,50 @@ namespace dxvk {
registrationFunction(annotation);
}
D3D11UserDefinedAnnotation::D3D11UserDefinedAnnotation(D3D11DeviceContext* ctx)
: m_container(ctx),
m_eventDepth(0) {
if (m_container->IsAnnotationEnabled())
template<typename ContextType>
D3D11UserDefinedAnnotation<ContextType>::D3D11UserDefinedAnnotation(
ContextType* container,
const Rc<DxvkDevice>& dxvkDevice)
: m_container(container), m_eventDepth(0),
m_annotationsEnabled(dxvkDevice->instance()->extensions().extDebugUtils) {
if (!IsDeferred && m_annotationsEnabled)
RegisterUserDefinedAnnotation<true>(this);
}
D3D11UserDefinedAnnotation::D3D11UserDefinedAnnotation(const D3D11UserDefinedAnnotation&)
{
if (m_container->IsAnnotationEnabled())
RegisterUserDefinedAnnotation<true>(this);
}
D3D11UserDefinedAnnotation::~D3D11UserDefinedAnnotation() {
if (m_container->IsAnnotationEnabled())
template<typename ContextType>
D3D11UserDefinedAnnotation<ContextType>::~D3D11UserDefinedAnnotation() {
if (!IsDeferred && m_annotationsEnabled)
RegisterUserDefinedAnnotation<false>(this);
}
ULONG STDMETHODCALLTYPE D3D11UserDefinedAnnotation::AddRef() {
template<typename ContextType>
ULONG STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::AddRef() {
return m_container->AddRef();
}
ULONG STDMETHODCALLTYPE D3D11UserDefinedAnnotation::Release() {
template<typename ContextType>
ULONG STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::Release() {
return m_container->Release();
}
HRESULT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::QueryInterface(
template<typename ContextType>
HRESULT STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::QueryInterface(
REFIID riid,
void** ppvObject) {
return m_container->QueryInterface(riid, ppvObject);
}
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::BeginEvent(
template<typename ContextType>
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::BeginEvent(
D3DCOLOR Color,
LPCWSTR Name) {
if (!m_container->IsAnnotationEnabled())
if (!m_annotationsEnabled)
return -1;
D3D10DeviceLock lock = m_container->LockContext();
@ -88,8 +94,9 @@ namespace dxvk {
}
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation::EndEvent() {
if (!m_container->IsAnnotationEnabled())
template<typename ContextType>
INT STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::EndEvent() {
if (!m_annotationsEnabled)
return -1;
D3D10DeviceLock lock = m_container->LockContext();
@ -102,10 +109,11 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11UserDefinedAnnotation::SetMarker(
template<typename ContextType>
void STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::SetMarker(
D3DCOLOR Color,
LPCWSTR Name) {
if (!m_container->IsAnnotationEnabled())
if (!m_annotationsEnabled)
return;
D3D10DeviceLock lock = m_container->LockContext();
@ -122,8 +130,13 @@ namespace dxvk {
}
BOOL STDMETHODCALLTYPE D3D11UserDefinedAnnotation::GetStatus() {
return m_container->IsAnnotationEnabled();
template<typename ContextType>
BOOL STDMETHODCALLTYPE D3D11UserDefinedAnnotation<ContextType>::GetStatus() {
return m_annotationsEnabled;
}
template class D3D11UserDefinedAnnotation<D3D11DeferredContext>;
template class D3D11UserDefinedAnnotation<D3D11ImmediateContext>;
}

View File

@ -1,20 +1,31 @@
#pragma once
#include <type_traits>
#include "d3d11_include.h"
#include "../dxvk/dxvk_annotation.h"
#include "../dxvk/dxvk_device.h"
namespace dxvk {
class D3D11DeviceContext;
class D3D11DeferredContext;
class D3D11ImmediateContext;
template<typename ContextType>
class D3D11UserDefinedAnnotation final : public IDXVKUserDefinedAnnotation {
constexpr static bool IsDeferred = std::is_same_v<ContextType, D3D11DeferredContext>;
public:
D3D11UserDefinedAnnotation(D3D11DeviceContext* ctx);
D3D11UserDefinedAnnotation(const D3D11UserDefinedAnnotation&);
D3D11UserDefinedAnnotation(
ContextType* container,
const Rc<DxvkDevice>& dxvkDevice);
~D3D11UserDefinedAnnotation();
D3D11UserDefinedAnnotation (const D3D11UserDefinedAnnotation&) = delete;
D3D11UserDefinedAnnotation& operator = (const D3D11UserDefinedAnnotation&) = delete;
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
@ -37,10 +48,9 @@ namespace dxvk {
private:
D3D11DeviceContext* m_container;
// Stack depth for non-finalized BeginEvent calls
int32_t m_eventDepth;
ContextType* m_container;
int32_t m_eventDepth;
bool m_annotationsEnabled;
};
}

View File

@ -58,8 +58,11 @@ namespace dxvk {
return S_OK;
}
Logger::warn("D3D11BlendState::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
if (logQueryInterfaceError(__uuidof(ID3D11BlendState), riid)) {
Logger::warn("D3D11BlendState::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
}
return E_NOINTERFACE;
}
@ -87,7 +90,7 @@ namespace dxvk {
void D3D11BlendState::BindToContext(
const Rc<DxvkContext>& ctx,
DxvkContext* ctx,
uint32_t sampleMask) const {
// We handled Independent Blend during object creation
// already, so if it is disabled, all elements in the

View File

@ -33,7 +33,7 @@ namespace dxvk {
D3D11_BLEND_DESC1* pDesc) final;
void BindToContext(
const Rc<DxvkContext>& ctx,
DxvkContext* ctx,
UINT sampleMask) const;
D3D10BlendState* GetD3D10Iface() {

View File

@ -8,12 +8,14 @@ namespace dxvk {
D3D11Buffer::D3D11Buffer(
D3D11Device* pDevice,
const D3D11_BUFFER_DESC* pDesc)
const D3D11_BUFFER_DESC* pDesc,
const D3D11_ON_12_RESOURCE_INFO* p11on12Info)
: D3D11DeviceChild<ID3D11Buffer>(pDevice),
m_desc (*pDesc),
m_resource (this),
m_resource (this, pDevice),
m_d3d10 (this) {
DxvkBufferCreateInfo info;
DxvkBufferCreateInfo info;
info.flags = 0;
info.size = pDesc->ByteWidth;
info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT
| VK_BUFFER_USAGE_TRANSFER_DST_BIT;
@ -37,9 +39,6 @@ namespace dxvk {
info.usage |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
info.stages |= m_parent->GetEnabledShaderStages();
info.access |= VK_ACCESS_UNIFORM_READ_BIT;
if (m_parent->GetOptions()->constantBufferRangeCheck)
info.usage |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
}
if (pDesc->BindFlags & D3D11_BIND_SHADER_RESOURCE) {
@ -69,12 +68,50 @@ namespace dxvk {
info.access |= VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
}
// Create the buffer and set the entire buffer slice as mapped,
// so that we only have to update it when invalidating th buffer
m_buffer = m_parent->GetDXVKDevice()->createBuffer(info, GetMemoryFlags());
m_mapped = m_buffer->getSliceHandle();
if (pDesc->MiscFlags & D3D11_RESOURCE_MISC_TILED) {
info.flags |= VK_BUFFER_CREATE_SPARSE_BINDING_BIT
| VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT
| VK_BUFFER_CREATE_SPARSE_ALIASED_BIT;
}
m_mapMode = DetermineMapMode();
// Set host read bit as necessary. We may internally read staging
// buffer contents even if the buffer is not marked for reading.
if (pDesc->CPUAccessFlags && pDesc->Usage != D3D11_USAGE_DYNAMIC) {
info.stages |= VK_PIPELINE_STAGE_HOST_BIT;
info.access |= VK_ACCESS_HOST_READ_BIT;
if (pDesc->CPUAccessFlags & D3D11_CPU_ACCESS_WRITE)
info.access |= VK_ACCESS_HOST_WRITE_BIT;
}
if (p11on12Info) {
m_11on12 = *p11on12Info;
DxvkBufferImportInfo importInfo;
importInfo.buffer = VkBuffer(m_11on12.VulkanHandle);
importInfo.offset = m_11on12.VulkanOffset;
if (m_desc.CPUAccessFlags)
m_11on12.Resource->Map(0, nullptr, &importInfo.mapPtr);
m_buffer = m_parent->GetDXVKDevice()->importBuffer(info, importInfo, GetMemoryFlags());
m_mapped = m_buffer->getSliceHandle();
m_mapMode = DetermineMapMode();
} else if (!(pDesc->MiscFlags & D3D11_RESOURCE_MISC_TILE_POOL)) {
// Create the buffer and set the entire buffer slice as mapped,
// so that we only have to update it when invalidating the buffer
m_buffer = m_parent->GetDXVKDevice()->createBuffer(info, GetMemoryFlags());
m_mapped = m_buffer->getSliceHandle();
m_mapMode = DetermineMapMode();
} else {
m_sparseAllocator = m_parent->GetDXVKDevice()->createSparsePageAllocator();
m_sparseAllocator->setCapacity(info.size / SparseMemoryPageSize);
m_mapped = DxvkBufferSliceHandle();
m_mapMode = D3D11_COMMON_BUFFER_MAP_MODE_NONE;
}
// For Stream Output buffers we need a counter
if (pDesc->BindFlags & D3D11_BIND_STREAM_OUTPUT)
@ -83,7 +120,8 @@ namespace dxvk {
D3D11Buffer::~D3D11Buffer() {
if (m_desc.CPUAccessFlags && m_11on12.Resource != nullptr)
m_11on12.Resource->Unmap(0, nullptr);
}
@ -116,8 +154,11 @@ namespace dxvk {
return S_OK;
}
Logger::warn("D3D11Buffer::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
if (logQueryInterfaceError(__uuidof(ID3D11Buffer), riid)) {
Logger::warn("D3D11Buffer::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
}
return E_NOINTERFACE;
}
@ -159,7 +200,7 @@ namespace dxvk {
// Check whether the given combination of buffer view
// type and view format is supported by the device
DXGI_VK_FORMAT_INFO viewFormat = m_parent->LookupFormat(Format, DXGI_VK_FORMAT_MODE_ANY);
VkFormatFeatureFlags features = GetBufferFormatFeatures(BindFlags);
VkFormatFeatureFlags2 features = GetBufferFormatFeatures(BindFlags);
return CheckFormatFeatureSupport(viewFormat.Format, features);
}
@ -167,13 +208,9 @@ namespace dxvk {
HRESULT D3D11Buffer::NormalizeBufferProperties(D3D11_BUFFER_DESC* pDesc) {
// Zero-sized buffers are illegal
if (!pDesc->ByteWidth)
if (!pDesc->ByteWidth && !(pDesc->MiscFlags & D3D11_RESOURCE_MISC_TILE_POOL))
return E_INVALIDARG;
// We don't support tiled resources
if (pDesc->MiscFlags & (D3D11_RESOURCE_MISC_TILE_POOL | D3D11_RESOURCE_MISC_TILED))
return E_INVALIDARG;
// Constant buffer size must be a multiple of 16
if ((pDesc->BindFlags & D3D11_BIND_CONSTANT_BUFFER)
&& (pDesc->ByteWidth & 0xF))
@ -194,7 +231,25 @@ namespace dxvk {
// Mip generation obviously doesn't work for buffers
if (pDesc->MiscFlags & D3D11_RESOURCE_MISC_GENERATE_MIPS)
return E_INVALIDARG;
// Basic validation for tiled buffers
if (pDesc->MiscFlags & D3D11_RESOURCE_MISC_TILED) {
if ((pDesc->MiscFlags & D3D11_RESOURCE_MISC_TILE_POOL)
|| (pDesc->Usage != D3D11_USAGE_DEFAULT)
|| (pDesc->CPUAccessFlags))
return E_INVALIDARG;
}
// Basic validation for tile pools
if (pDesc->MiscFlags & D3D11_RESOURCE_MISC_TILE_POOL) {
if ((pDesc->MiscFlags & ~D3D11_RESOURCE_MISC_TILE_POOL)
|| (pDesc->ByteWidth % SparseMemoryPageSize)
|| (pDesc->Usage != D3D11_USAGE_DEFAULT)
|| (pDesc->BindFlags)
|| (pDesc->CPUAccessFlags))
return E_INVALIDARG;
}
if (!(pDesc->MiscFlags & D3D11_RESOURCE_MISC_BUFFER_STRUCTURED))
pDesc->StructureByteStride = 0;
@ -202,17 +257,50 @@ namespace dxvk {
}
HRESULT D3D11Buffer::GetDescFromD3D12(
ID3D12Resource* pResource,
const D3D11_RESOURCE_FLAGS* pResourceFlags,
D3D11_BUFFER_DESC* pBufferDesc) {
D3D12_RESOURCE_DESC desc12 = pResource->GetDesc();
pBufferDesc->ByteWidth = desc12.Width;
pBufferDesc->Usage = D3D11_USAGE_DEFAULT;
pBufferDesc->BindFlags = D3D11_BIND_SHADER_RESOURCE;
pBufferDesc->MiscFlags = 0;
pBufferDesc->CPUAccessFlags = 0;
pBufferDesc->StructureByteStride = 0;
if (desc12.Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET)
pBufferDesc->BindFlags |= D3D11_BIND_RENDER_TARGET;
if (desc12.Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)
pBufferDesc->BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
if (pResourceFlags) {
pBufferDesc->BindFlags = pResourceFlags->BindFlags;
pBufferDesc->MiscFlags |= pResourceFlags->MiscFlags;
pBufferDesc->CPUAccessFlags = pResourceFlags->CPUAccessFlags;
pBufferDesc->StructureByteStride = pResourceFlags->StructureByteStride;
}
return S_OK;
}
BOOL D3D11Buffer::CheckFormatFeatureSupport(
VkFormat Format,
VkFormatFeatureFlags Features) const {
VkFormatProperties properties = m_parent->GetDXVKDevice()->adapter()->formatProperties(Format);
return (properties.bufferFeatures & Features) == Features;
VkFormatFeatureFlags2 Features) const {
DxvkFormatFeatures support = m_parent->GetDXVKDevice()->getFormatFeatures(Format);
return (support.buffer & Features) == Features;
}
VkMemoryPropertyFlags D3D11Buffer::GetMemoryFlags() const {
VkMemoryPropertyFlags memoryFlags = 0;
if (m_desc.MiscFlags & (D3D11_RESOURCE_MISC_TILE_POOL | D3D11_RESOURCE_MISC_TILED))
return VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
switch (m_desc.Usage) {
case D3D11_USAGE_IMMUTABLE:
memoryFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
@ -251,6 +339,7 @@ namespace dxvk {
|| (m_parent->GetOptions()->cachedDynamicResources & m_desc.BindFlags);
if ((memoryFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) && useCached) {
memoryFlags &= ~VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
memoryFlags |= VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
| VK_MEMORY_PROPERTY_HOST_CACHED_BIT;
}

View File

@ -7,12 +7,12 @@
#include "d3d11_device_child.h"
#include "d3d11_interfaces.h"
#include "d3d11_on_12.h"
#include "d3d11_resource.h"
namespace dxvk {
class D3D11Device;
class D3D11DeviceContext;
/**
@ -42,7 +42,9 @@ namespace dxvk {
D3D11Buffer(
D3D11Device* pDevice,
const D3D11_BUFFER_DESC* pDesc);
const D3D11_BUFFER_DESC* pDesc,
const D3D11_ON_12_RESOURCE_INFO* p11on12Info);
~D3D11Buffer();
HRESULT STDMETHODCALLTYPE QueryInterface(
@ -67,6 +69,10 @@ namespace dxvk {
return &m_desc;
}
BOOL IsTilePool() const {
return bool(m_desc.MiscFlags & D3D11_RESOURCE_MISC_TILE_POOL);
}
D3D11_COMMON_BUFFER_MAP_MODE GetMapMode() const {
return m_mapMode;
}
@ -74,6 +80,10 @@ namespace dxvk {
Rc<DxvkBuffer> GetBuffer() const {
return m_buffer;
}
Rc<DxvkSparsePageAllocator> GetSparseAllocator() const {
return m_sparseAllocator;
}
DxvkBufferSlice GetBufferSlice() const {
return DxvkBufferSlice(m_buffer, 0, m_desc.ByteWidth);
@ -81,18 +91,20 @@ namespace dxvk {
DxvkBufferSlice GetBufferSlice(VkDeviceSize offset) const {
VkDeviceSize size = m_desc.ByteWidth;
return likely(offset < size)
? DxvkBufferSlice(m_buffer, offset, size - offset)
: DxvkBufferSlice();
offset = std::min(offset, size);
return DxvkBufferSlice(m_buffer, offset, size - offset);
}
DxvkBufferSlice GetBufferSlice(VkDeviceSize offset, VkDeviceSize length) const {
VkDeviceSize size = m_desc.ByteWidth;
offset = std::min(offset, size);
return DxvkBufferSlice(m_buffer, offset, std::min(length, size - offset));
}
return likely(offset < size)
? DxvkBufferSlice(m_buffer, offset, std::min(length, size - offset))
: DxvkBufferSlice();
VkDeviceSize GetRemainingSize(VkDeviceSize offset) const {
VkDeviceSize size = m_desc.ByteWidth;
offset = std::min(offset, size);
return size - offset;
}
DxvkBufferSlice GetSOCounter() {
@ -133,6 +145,14 @@ namespace dxvk {
: DxvkCsThread::SynchronizeAll;
}
/**
* \brief Retrieves D3D11on12 resource info
* \returns 11on12 resource info
*/
D3D11_ON_12_RESOURCE_INFO Get11on12Info() const {
return m_11on12;
}
/**
* \brief Normalizes buffer description
*
@ -142,13 +162,28 @@ namespace dxvk {
static HRESULT NormalizeBufferProperties(
D3D11_BUFFER_DESC* pDesc);
/**
* \brief Initializes D3D11 buffer description from D3D12
*
* \param [in] pResource D3D12 resource
* \param [in] pResourceFlags D3D11 flag overrides
* \param [out] pBufferDesc D3D11 buffer description
* \returns \c S_OK if the parameters are valid
*/
static HRESULT GetDescFromD3D12(
ID3D12Resource* pResource,
const D3D11_RESOURCE_FLAGS* pResourceFlags,
D3D11_BUFFER_DESC* pBufferDesc);
private:
D3D11_BUFFER_DESC m_desc;
D3D11_ON_12_RESOURCE_INFO m_11on12;
D3D11_COMMON_BUFFER_MAP_MODE m_mapMode;
Rc<DxvkBuffer> m_buffer;
Rc<DxvkBuffer> m_soCounter;
Rc<DxvkSparsePageAllocator> m_sparseAllocator;
DxvkBufferSliceHandle m_mapped;
uint64_t m_seq = 0ull;
@ -157,7 +192,7 @@ namespace dxvk {
BOOL CheckFormatFeatureSupport(
VkFormat Format,
VkFormatFeatureFlags Features) const;
VkFormatFeatureFlags2 Features) const;
VkMemoryPropertyFlags GetMemoryFlags() const;

View File

@ -28,8 +28,11 @@ namespace dxvk {
return S_OK;
}
Logger::warn("D3D11ClassLinkage::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
if (logQueryInterfaceError(__uuidof(ID3D11ClassLinkage), riid)) {
Logger::warn("D3D11ClassLinkage::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
}
return E_NOINTERFACE;
}

View File

@ -30,8 +30,11 @@ namespace dxvk {
return S_OK;
}
Logger::warn("D3D11CommandList::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
if (logQueryInterfaceError(__uuidof(ID3D11CommandList), riid)) {
Logger::warn("D3D11CommandList::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
}
return E_NOINTERFACE;
}
@ -41,54 +44,79 @@ namespace dxvk {
}
void D3D11CommandList::AddChunk(DxvkCsChunkRef&& Chunk) {
m_chunks.push_back(std::move(Chunk));
}
void D3D11CommandList::AddQuery(D3D11Query* pQuery) {
m_queries.emplace_back(pQuery);
}
void D3D11CommandList::EmitToCommandList(ID3D11CommandList* pCommandList) {
auto cmdList = static_cast<D3D11CommandList*>(pCommandList);
for (const auto& chunk : m_chunks)
cmdList->m_chunks.push_back(chunk);
for (const auto& query : m_queries)
cmdList->m_queries.push_back(query);
for (const auto& resource : m_resources)
cmdList->m_resources.push_back(resource);
MarkSubmitted();
uint64_t D3D11CommandList::AddChunk(DxvkCsChunkRef&& Chunk) {
m_chunks.push_back(std::move(Chunk));
return m_chunks.size() - 1;
}
uint64_t D3D11CommandList::EmitToCsThread(DxvkCsThread* CsThread) {
uint64_t seq = 0;
uint64_t D3D11CommandList::AddCommandList(
D3D11CommandList* pCommandList) {
// This will be the chunk ID of the first chunk
// added, for the purpose of resource tracking.
uint64_t baseChunkId = m_chunks.size();
for (const auto& chunk : pCommandList->m_chunks)
m_chunks.push_back(chunk);
for (const auto& query : pCommandList->m_queries)
m_queries.push_back(query);
for (const auto& resource : pCommandList->m_resources) {
TrackedResource entry = resource;
entry.chunkId += baseChunkId;
m_resources.push_back(std::move(entry));
}
pCommandList->MarkSubmitted();
// Return ID of the last chunk added. The command list
// added can never be empty, so do not handle zero.
return m_chunks.size() - 1;
}
void D3D11CommandList::EmitToCsThread(
const D3D11ChunkDispatchProc& DispatchProc) {
for (const auto& query : m_queries)
query->DoDeferredEnd();
for (const auto& chunk : m_chunks)
seq = CsThread->dispatchChunk(DxvkCsChunkRef(chunk));
for (const auto& resource : m_resources)
TrackResourceSequenceNumber(resource, seq);
for (size_t i = 0, j = 0; i < m_chunks.size(); i++) {
// If there are resources to track for the current chunk,
// use a strong flush hint to dispatch GPU work quickly.
GpuFlushType flushType = GpuFlushType::ImplicitWeakHint;
if (j < m_resources.size() && m_resources[j].chunkId == i)
flushType = GpuFlushType::ImplicitStrongHint;
// Dispatch the chunk and capture its sequence number
uint64_t seq = DispatchProc(DxvkCsChunkRef(m_chunks[i]), flushType);
// Track resource sequence numbers for the added chunk
while (j < m_resources.size() && m_resources[j].chunkId == i)
TrackResourceSequenceNumber(m_resources[j++].ref, seq);
}
MarkSubmitted();
return seq;
}
void D3D11CommandList::TrackResourceUsage(
ID3D11Resource* pResource,
D3D11_RESOURCE_DIMENSION ResourceType,
UINT Subresource) {
m_resources.emplace_back(pResource, Subresource, ResourceType);
UINT Subresource,
uint64_t ChunkId) {
TrackedResource entry;
entry.ref = D3D11ResourceRef(pResource, Subresource, ResourceType);
entry.chunkId = ChunkId;
m_resources.push_back(std::move(entry));
}
@ -96,7 +124,6 @@ namespace dxvk {
const D3D11ResourceRef& Resource,
uint64_t Seq) {
ID3D11Resource* iface = Resource.Get();
UINT subresource = Resource.GetSubresource();
switch (Resource.GetType()) {
case D3D11_RESOURCE_DIMENSION_UNKNOWN:
@ -109,17 +136,17 @@ namespace dxvk {
case D3D11_RESOURCE_DIMENSION_TEXTURE1D: {
auto impl = static_cast<D3D11Texture1D*>(iface)->GetCommonTexture();
impl->TrackSequenceNumber(subresource, Seq);
impl->TrackSequenceNumber(Resource.GetSubresource(), Seq);
} break;
case D3D11_RESOURCE_DIMENSION_TEXTURE2D: {
auto impl = static_cast<D3D11Texture2D*>(iface)->GetCommonTexture();
impl->TrackSequenceNumber(subresource, Seq);
impl->TrackSequenceNumber(Resource.GetSubresource(), Seq);
} break;
case D3D11_RESOURCE_DIMENSION_TEXTURE3D: {
auto impl = static_cast<D3D11Texture3D*>(iface)->GetCommonTexture();
impl->TrackSequenceNumber(subresource, Seq);
impl->TrackSequenceNumber(Resource.GetSubresource(), Seq);
} break;
}
}

View File

@ -1,9 +1,13 @@
#pragma once
#include <functional>
#include "d3d11_context.h"
namespace dxvk {
using D3D11ChunkDispatchProc = std::function<uint64_t (DxvkCsChunkRef&&, GpuFlushType)>;
class D3D11CommandList : public D3D11DeviceChild<ID3D11CommandList> {
public:
@ -20,30 +24,36 @@ namespace dxvk {
UINT STDMETHODCALLTYPE GetContextFlags() final;
void AddChunk(
DxvkCsChunkRef&& Chunk);
void AddQuery(
D3D11Query* pQuery);
void EmitToCommandList(
ID3D11CommandList* pCommandList);
uint64_t EmitToCsThread(
DxvkCsThread* CsThread);
uint64_t AddChunk(
DxvkCsChunkRef&& Chunk);
uint64_t AddCommandList(
D3D11CommandList* pCommandList);
void EmitToCsThread(
const D3D11ChunkDispatchProc& DispatchProc);
void TrackResourceUsage(
ID3D11Resource* pResource,
D3D11_RESOURCE_DIMENSION ResourceType,
UINT Subresource);
UINT Subresource,
uint64_t ChunkId);
private:
UINT const m_contextFlags;
struct TrackedResource {
D3D11ResourceRef ref;
uint64_t chunkId;
};
UINT m_contextFlags;
std::vector<DxvkCsChunkRef> m_chunks;
std::vector<Com<D3D11Query, false>> m_queries;
std::vector<D3D11ResourceRef> m_resources;
std::vector<TrackedResource> m_resources;
std::atomic<bool> m_submitted = { false };
std::atomic<bool> m_warned = { false };

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -7,20 +7,9 @@ namespace dxvk {
D3D11Device* pParent,
const Rc<DxvkDevice>& Device,
UINT ContextFlags)
: D3D11DeviceContext(pParent, Device, GetCsChunkFlags(pParent)),
m_contextFlags(ContextFlags),
: D3D11CommonContext<D3D11DeferredContext>(pParent, Device, ContextFlags, GetCsChunkFlags(pParent)),
m_commandList (CreateCommandList()) {
ClearState();
}
D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE D3D11DeferredContext::GetType() {
return D3D11_DEVICE_CONTEXT_DEFERRED;
}
UINT STDMETHODCALLTYPE D3D11DeferredContext::GetContextFlags() {
return m_contextFlags;
ResetContextState();
}
@ -146,14 +135,26 @@ namespace dxvk {
BOOL RestoreContextState) {
D3D10DeviceLock lock = LockContext();
// Clear state so that the command list can't observe any
// current context state. The command list itself will clean
// up after execution to ensure that no state changes done
// by the command list are visible to the immediate context.
ResetCommandListState();
// Flush any outstanding commands so that
// we don't mess up the execution order
FlushCsChunk();
static_cast<D3D11CommandList*>(pCommandList)->EmitToCommandList(m_commandList.ptr());
// Record any chunks from the given command list into the
// current command list and deal with context state
auto commandList = static_cast<D3D11CommandList*>(pCommandList);
m_chunkId = m_commandList->AddCommandList(commandList);
// Restore deferred context state
if (RestoreContextState)
RestoreState();
RestoreCommandListState();
else
ClearState();
ResetContextState();
}
@ -162,17 +163,31 @@ namespace dxvk {
ID3D11CommandList **ppCommandList) {
D3D10DeviceLock lock = LockContext();
// End all queries that were left active by the app
FinalizeQueries();
// Clean up command list state so that the any state changed
// by this command list does not affect the calling context.
// This also ensures that the command list is never empty.
ResetCommandListState();
// Make sure all commands are visible to the command list
FlushCsChunk();
if (ppCommandList != nullptr)
if (ppCommandList)
*ppCommandList = m_commandList.ref();
// Create a clean command list, and if requested, restore all
// previously set context state. Otherwise, reset the context.
// Any use of ExecuteCommandList will reset command list state
// before the command list is actually executed.
m_commandList = CreateCommandList();
m_chunkId = 0;
if (RestoreDeferredContextState)
RestoreState();
RestoreCommandListState();
else
ClearState();
ResetContextState();
m_mappedResources.clear();
ResetStagingBuffer();
@ -236,31 +251,6 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11DeferredContext::UpdateSubresource(
ID3D11Resource* pDstResource,
UINT DstSubresource,
const D3D11_BOX* pDstBox,
const void* pSrcData,
UINT SrcRowPitch,
UINT SrcDepthPitch) {
UpdateResource<D3D11DeferredContext>(this, pDstResource,
DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch, 0);
}
void STDMETHODCALLTYPE D3D11DeferredContext::UpdateSubresource1(
ID3D11Resource* pDstResource,
UINT DstSubresource,
const D3D11_BOX* pDstBox,
const void* pSrcData,
UINT SrcRowPitch,
UINT SrcDepthPitch,
UINT CopyFlags) {
UpdateResource<D3D11DeferredContext>(this, pDstResource,
DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch, CopyFlags);
}
void STDMETHODCALLTYPE D3D11DeferredContext::SwapDeviceContextState(
ID3DDeviceContextState* pState,
ID3DDeviceContextState** ppPreviousState) {
@ -333,7 +323,7 @@ namespace dxvk {
VkFormat packedFormat = pTexture->GetPackedFormat();
auto formatInfo = imageFormatInfo(packedFormat);
auto formatInfo = lookupFormatInfo(packedFormat);
auto subresource = pTexture->GetSubresourceFromIndex(
formatInfo->aspectMask, Subresource);
@ -396,12 +386,17 @@ namespace dxvk {
Com<D3D11CommandList> D3D11DeferredContext::CreateCommandList() {
return new D3D11CommandList(m_parent, m_contextFlags);
return new D3D11CommandList(m_parent, m_flags);
}
void D3D11DeferredContext::EmitCsChunk(DxvkCsChunkRef&& chunk) {
m_commandList->AddChunk(std::move(chunk));
m_chunkId = m_commandList->AddChunk(std::move(chunk));
}
uint64_t D3D11DeferredContext::GetCurrentChunkId() const {
return m_csChunk->empty() ? m_chunkId : m_chunkId + 1;
}
@ -411,14 +406,15 @@ namespace dxvk {
m_commandList->TrackResourceUsage(
pResource->GetInterface(),
pResource->GetDimension(),
Subresource);
Subresource, GetCurrentChunkId());
}
void D3D11DeferredContext::TrackBufferSequenceNumber(
D3D11Buffer* pResource) {
m_commandList->TrackResourceUsage(
pResource, D3D11_RESOURCE_DIMENSION_BUFFER, 0);
m_commandList->TrackResourceUsage(pResource,
D3D11_RESOURCE_DIMENSION_BUFFER, 0,
GetCurrentChunkId());
}

View File

@ -1,9 +1,7 @@
#pragma once
#include "d3d11_buffer.h"
#include "d3d11_cmdlist.h"
#include "d3d11_context.h"
#include "d3d11_texture.h"
#include <vector>
@ -23,8 +21,8 @@ namespace dxvk {
D3D11_MAPPED_SUBRESOURCE MapInfo;
};
class D3D11DeferredContext : public D3D11DeviceContext {
friend class D3D11DeviceContext;
class D3D11DeferredContext : public D3D11CommonContext<D3D11DeferredContext> {
friend class D3D11CommonContext<D3D11DeferredContext>;
public:
D3D11DeferredContext(
@ -32,10 +30,6 @@ namespace dxvk {
const Rc<DxvkDevice>& Device,
UINT ContextFlags);
D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE GetType();
UINT STDMETHODCALLTYPE GetContextFlags();
HRESULT STDMETHODCALLTYPE GetData(
ID3D11Asynchronous* pAsync,
void* pData,
@ -81,31 +75,16 @@ namespace dxvk {
ID3D11Resource* pResource,
UINT Subresource);
void STDMETHODCALLTYPE UpdateSubresource(
ID3D11Resource* pDstResource,
UINT DstSubresource,
const D3D11_BOX* pDstBox,
const void* pSrcData,
UINT SrcRowPitch,
UINT SrcDepthPitch);
void STDMETHODCALLTYPE UpdateSubresource1(
ID3D11Resource* pDstResource,
UINT DstSubresource,
const D3D11_BOX* pDstBox,
const void* pSrcData,
UINT SrcRowPitch,
UINT SrcDepthPitch,
UINT CopyFlags);
void STDMETHODCALLTYPE SwapDeviceContextState(
ID3DDeviceContextState* pState,
ID3DDeviceContextState** ppPreviousState);
D3D10DeviceLock LockContext() {
return D3D10DeviceLock();
}
private:
const UINT m_contextFlags;
// Command list that we're recording
Com<D3D11CommandList> m_commandList;
@ -117,6 +96,9 @@ namespace dxvk {
// Begun and ended queries, will also be stored in command list
std::vector<Com<D3D11Query, false>> m_queriesBegun;
// Chunk ID within the current command list
uint64_t m_chunkId = 0ull;
HRESULT MapBuffer(
ID3D11Resource* pResource,
D3D11_MAPPED_SUBRESOURCE* pMappedResource);
@ -139,6 +121,8 @@ namespace dxvk {
void EmitCsChunk(DxvkCsChunkRef&& chunk);
uint64_t GetCurrentChunkId() const;
void TrackTextureSequenceNumber(
D3D11CommonTexture* pResource,
UINT Subresource);

View File

@ -3,38 +3,44 @@
#include <cstring>
#include "d3d11_device.h"
#include "d3d11_context.h"
#include "d3d11_context_imm.h"
#include "d3d11_context_def.h"
#include "d3d11_cuda.h"
#include "../util/log/log.h"
namespace dxvk {
D3D11DeviceContextExt::D3D11DeviceContextExt(
D3D11DeviceContext* pContext)
template<typename ContextType>
D3D11DeviceContextExt<ContextType>::D3D11DeviceContextExt(
ContextType* pContext)
: m_ctx(pContext) {
}
ULONG STDMETHODCALLTYPE D3D11DeviceContextExt::AddRef() {
template<typename ContextType>
ULONG STDMETHODCALLTYPE D3D11DeviceContextExt<ContextType>::AddRef() {
return m_ctx->AddRef();
}
ULONG STDMETHODCALLTYPE D3D11DeviceContextExt::Release() {
template<typename ContextType>
ULONG STDMETHODCALLTYPE D3D11DeviceContextExt<ContextType>::Release() {
return m_ctx->Release();
}
HRESULT STDMETHODCALLTYPE D3D11DeviceContextExt::QueryInterface(
template<typename ContextType>
HRESULT STDMETHODCALLTYPE D3D11DeviceContextExt<ContextType>::QueryInterface(
REFIID riid,
void** ppvObject) {
return m_ctx->QueryInterface(riid, ppvObject);
}
void STDMETHODCALLTYPE D3D11DeviceContextExt::MultiDrawIndirect(
template<typename ContextType>
void STDMETHODCALLTYPE D3D11DeviceContextExt<ContextType>::MultiDrawIndirect(
UINT DrawCount,
ID3D11Buffer* pBufferForArgs,
UINT ByteOffsetForArgs,
@ -52,7 +58,8 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11DeviceContextExt::MultiDrawIndexedIndirect(
template<typename ContextType>
void STDMETHODCALLTYPE D3D11DeviceContextExt<ContextType>::MultiDrawIndexedIndirect(
UINT DrawCount,
ID3D11Buffer* pBufferForArgs,
UINT ByteOffsetForArgs,
@ -70,7 +77,8 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11DeviceContextExt::MultiDrawIndirectCount(
template<typename ContextType>
void STDMETHODCALLTYPE D3D11DeviceContextExt<ContextType>::MultiDrawIndirectCount(
UINT MaxDrawCount,
ID3D11Buffer* pBufferForCount,
UINT ByteOffsetForCount,
@ -91,7 +99,8 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11DeviceContextExt::MultiDrawIndexedIndirectCount(
template<typename ContextType>
void STDMETHODCALLTYPE D3D11DeviceContextExt<ContextType>::MultiDrawIndexedIndirectCount(
UINT MaxDrawCount,
ID3D11Buffer* pBufferForCount,
UINT ByteOffsetForCount,
@ -112,7 +121,8 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11DeviceContextExt::SetDepthBoundsTest(
template<typename ContextType>
void STDMETHODCALLTYPE D3D11DeviceContextExt<ContextType>::SetDepthBoundsTest(
BOOL Enable,
FLOAT MinDepthBounds,
FLOAT MaxDepthBounds) {
@ -129,7 +139,8 @@ namespace dxvk {
}
void STDMETHODCALLTYPE D3D11DeviceContextExt::SetBarrierControl(
template<typename ContextType>
void STDMETHODCALLTYPE D3D11DeviceContextExt<ContextType>::SetBarrierControl(
UINT ControlFlags) {
D3D10DeviceLock lock = m_ctx->LockContext();
DxvkBarrierControlFlags flags;
@ -146,7 +157,8 @@ namespace dxvk {
}
bool STDMETHODCALLTYPE D3D11DeviceContextExt::LaunchCubinShaderNVX(IUnknown* hShader, uint32_t GridX, uint32_t GridY, uint32_t GridZ,
template<typename ContextType>
bool STDMETHODCALLTYPE D3D11DeviceContextExt<ContextType>::LaunchCubinShaderNVX(IUnknown* hShader, uint32_t GridX, uint32_t GridY, uint32_t GridZ,
const void* pParams, uint32_t ParamSize, void* const* pReadResources, uint32_t NumReadResources, void* const* pWriteResources, uint32_t NumWriteResources) {
D3D10DeviceLock lock = m_ctx->LockContext();
@ -202,4 +214,9 @@ namespace dxvk {
return true;
}
template class D3D11DeviceContextExt<D3D11DeferredContext>;
template class D3D11DeviceContextExt<D3D11ImmediateContext>;
}

View File

@ -4,14 +4,16 @@
namespace dxvk {
class D3D11DeviceContext;
class D3D11DeferredContext;
class D3D11ImmediateContext;
template<typename ContextType>
class D3D11DeviceContextExt : public ID3D11VkExtContext1 {
public:
D3D11DeviceContextExt(
D3D11DeviceContext* pContext);
ContextType* pContext);
ULONG STDMETHODCALLTYPE AddRef();
@ -71,7 +73,7 @@ namespace dxvk {
private:
D3D11DeviceContext* m_ctx;
ContextType* m_ctx;
};

View File

@ -1,8 +1,11 @@
#include "d3d11_cmdlist.h"
#include "d3d11_context_imm.h"
#include "d3d11_device.h"
#include "d3d11_fence.h"
#include "d3d11_texture.h"
#include "../util/util_win32_compat.h"
constexpr static uint32_t MinFlushIntervalUs = 750;
constexpr static uint32_t IncFlushIntervalUs = 250;
constexpr static uint32_t MaxPendingSubmits = 6;
@ -12,9 +15,11 @@ namespace dxvk {
D3D11ImmediateContext::D3D11ImmediateContext(
D3D11Device* pParent,
const Rc<DxvkDevice>& Device)
: D3D11DeviceContext(pParent, Device, DxvkCsChunkFlag::SingleUse),
m_csThread(Device, Device->createContext()),
: D3D11CommonContext<D3D11ImmediateContext>(pParent, Device, 0, DxvkCsChunkFlag::SingleUse),
m_csThread(Device, Device->createContext(DxvkContextType::Primary)),
m_maxImplicitDiscardSize(pParent->GetOptions()->maxImplicitDiscardSize),
m_submissionFence(new sync::CallbackFence()),
m_multithread(this, false, pParent->GetOptions()->enableContextLock),
m_videoContext(this, Device) {
EmitCs([
cDevice = m_device,
@ -39,32 +44,32 @@ namespace dxvk {
D3D11ImmediateContext::~D3D11ImmediateContext() {
Flush();
// Avoids hanging when in this state, see comment
// in DxvkDevice::~DxvkDevice.
if (this_thread::isInModuleDetachment())
return;
ExecuteFlush(GpuFlushType::ExplicitFlush, nullptr, true);
SynchronizeCsThread(DxvkCsThread::SynchronizeAll);
SynchronizeDevice();
}
HRESULT STDMETHODCALLTYPE D3D11ImmediateContext::QueryInterface(REFIID riid, void** ppvObject) {
if (riid == __uuidof(ID3D10Multithread)) {
*ppvObject = ref(&m_multithread);
return S_OK;
}
if (riid == __uuidof(ID3D11VideoContext)) {
*ppvObject = ref(&m_videoContext);
return S_OK;
}
return D3D11DeviceContext::QueryInterface(riid, ppvObject);
return D3D11CommonContext<D3D11ImmediateContext>::QueryInterface(riid, ppvObject);
}
D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE D3D11ImmediateContext::GetType() {
return D3D11_DEVICE_CONTEXT_IMMEDIATE;
}
UINT STDMETHODCALLTYPE D3D11ImmediateContext::GetContextFlags() {
return 0;
}
HRESULT STDMETHODCALLTYPE D3D11ImmediateContext::GetData(
ID3D11Asynchronous* pAsync,
void* pData,
@ -95,7 +100,8 @@ namespace dxvk {
// Ignore the DONOTFLUSH flag here as some games will spin
// on queries without ever flushing the context otherwise.
FlushImplicit(FALSE);
D3D10DeviceLock lock = LockContext();
ConsiderFlush(GpuFlushType::ImplicitSynchronization);
}
return hr;
@ -144,57 +150,69 @@ namespace dxvk {
query->NotifyEnd();
if (query->IsStalling())
Flush();
ExecuteFlush(GpuFlushType::ImplicitSynchronization, nullptr, false);
else if (query->IsEvent())
FlushImplicit(TRUE);
ConsiderFlush(GpuFlushType::ImplicitStrongHint);
}
}
void STDMETHODCALLTYPE D3D11ImmediateContext::Flush() {
Flush1(D3D11_CONTEXT_TYPE_ALL, nullptr);
D3D10DeviceLock lock = LockContext();
ExecuteFlush(GpuFlushType::ExplicitFlush, nullptr, true);
}
void STDMETHODCALLTYPE D3D11ImmediateContext::Flush1(
D3D11_CONTEXT_TYPE ContextType,
HANDLE hEvent) {
m_parent->FlushInitContext();
if (hEvent)
SignalEvent(hEvent);
D3D10DeviceLock lock = LockContext();
if (m_csIsBusy || !m_csChunk->empty()) {
// Add commands to flush the threaded
// context, then flush the command list
EmitCs([] (DxvkContext* ctx) {
ctx->flushCommandList();
});
FlushCsChunk();
// Reset flush timer used for implicit flushes
m_lastFlush = dxvk::high_resolution_clock::now();
m_csIsBusy = false;
}
ExecuteFlush(GpuFlushType::ExplicitFlush, hEvent, true);
}
HRESULT STDMETHODCALLTYPE D3D11ImmediateContext::Signal(
ID3D11Fence* pFence,
UINT64 Value) {
Logger::err("D3D11ImmediateContext::Signal: Not implemented");
return E_NOTIMPL;
D3D10DeviceLock lock = LockContext();
auto fence = static_cast<D3D11Fence*>(pFence);
if (!fence)
return E_INVALIDARG;
EmitCs([
cFence = fence->GetFence(),
cValue = Value
] (DxvkContext* ctx) {
ctx->signalFence(cFence, cValue);
});
ExecuteFlush(GpuFlushType::ExplicitFlush, nullptr, true);
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D11ImmediateContext::Wait(
ID3D11Fence* pFence,
UINT64 Value) {
Logger::err("D3D11ImmediateContext::Wait: Not implemented");
return E_NOTIMPL;
D3D10DeviceLock lock = LockContext();
auto fence = static_cast<D3D11Fence*>(pFence);
if (!fence)
return E_INVALIDARG;
ExecuteFlush(GpuFlushType::ExplicitFlush, nullptr, true);
EmitCs([
cFence = fence->GetFence(),
cValue = Value
] (DxvkContext* ctx) {
ctx->waitFence(cFence, cValue);
});
return S_OK;
}
@ -205,27 +223,39 @@ namespace dxvk {
auto commandList = static_cast<D3D11CommandList*>(pCommandList);
// Clear state so that the command list can't observe any
// current context state. The command list itself will clean
// up after execution to ensure that no state changes done
// by the command list are visible to the immediate context.
ResetCommandListState();
// Flush any outstanding commands so that
// we don't mess up the execution order
FlushCsChunk();
// As an optimization, flush everything if the
// number of pending draw calls is high enough.
FlushImplicit(FALSE);
// Dispatch command list to the CS thread and
// restore the immediate context's state
uint64_t csSeqNum = commandList->EmitToCsThread(&m_csThread);
m_csSeqNum = std::max(m_csSeqNum, csSeqNum);
ConsiderFlush(GpuFlushType::ImplicitWeakHint);
// Dispatch command list to the CS thread
commandList->EmitToCsThread([this] (DxvkCsChunkRef&& chunk, GpuFlushType flushType) {
EmitCsChunk(std::move(chunk));
// Return the sequence number from before the flush since
// that is actually going to be needed for resource tracking
uint64_t csSeqNum = m_csSeqNum;
// Consider a flush after every chunk in case the app
// submits a very large command list or the GPU is idle
ConsiderFlush(flushType);
return csSeqNum;
});
// Restore the immediate context's state
if (RestoreContextState)
RestoreState();
RestoreCommandListState();
else
ClearState();
// Mark CS thread as busy so that subsequent
// flush operations get executed correctly.
m_csIsBusy = true;
ResetContextState();
}
@ -290,59 +320,7 @@ namespace dxvk {
}
}
void STDMETHODCALLTYPE D3D11ImmediateContext::UpdateSubresource(
ID3D11Resource* pDstResource,
UINT DstSubresource,
const D3D11_BOX* pDstBox,
const void* pSrcData,
UINT SrcRowPitch,
UINT SrcDepthPitch) {
UpdateResource<D3D11ImmediateContext>(this, pDstResource,
DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch, 0);
}
void STDMETHODCALLTYPE D3D11ImmediateContext::UpdateSubresource1(
ID3D11Resource* pDstResource,
UINT DstSubresource,
const D3D11_BOX* pDstBox,
const void* pSrcData,
UINT SrcRowPitch,
UINT SrcDepthPitch,
UINT CopyFlags) {
UpdateResource<D3D11ImmediateContext>(this, pDstResource,
DstSubresource, pDstBox, pSrcData, SrcRowPitch, SrcDepthPitch, CopyFlags);
}
void STDMETHODCALLTYPE D3D11ImmediateContext::OMSetRenderTargets(
UINT NumViews,
ID3D11RenderTargetView* const* ppRenderTargetViews,
ID3D11DepthStencilView* pDepthStencilView) {
FlushImplicit(TRUE);
D3D11DeviceContext::OMSetRenderTargets(
NumViews, ppRenderTargetViews, pDepthStencilView);
}
void STDMETHODCALLTYPE D3D11ImmediateContext::OMSetRenderTargetsAndUnorderedAccessViews(
UINT NumRTVs,
ID3D11RenderTargetView* const* ppRenderTargetViews,
ID3D11DepthStencilView* pDepthStencilView,
UINT UAVStartSlot,
UINT NumUAVs,
ID3D11UnorderedAccessView* const* ppUnorderedAccessViews,
const UINT* pUAVInitialCounts) {
FlushImplicit(TRUE);
D3D11DeviceContext::OMSetRenderTargetsAndUnorderedAccessViews(
NumRTVs, ppRenderTargetViews, pDepthStencilView,
UAVStartSlot, NumUAVs, ppUnorderedAccessViews,
pUAVInitialCounts);
}
HRESULT D3D11ImmediateContext::MapBuffer(
D3D11Buffer* pResource,
D3D11_MAP MapType,
@ -407,8 +385,6 @@ namespace dxvk {
}
if (doInvalidatePreserve) {
FlushImplicit(TRUE);
auto prevSlice = pResource->GetMappedSlice();
auto physSlice = pResource->DiscardSlice();
@ -472,7 +448,7 @@ namespace dxvk {
uint64_t sequenceNumber = pResource->GetSequenceNumber(Subresource);
auto formatInfo = imageFormatInfo(packedFormat);
auto formatInfo = lookupFormatInfo(packedFormat);
void* mapPtr;
if (mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT) {
@ -495,6 +471,20 @@ namespace dxvk {
constexpr uint32_t DoWait = (1u << 2);
uint32_t doFlags;
if (mapMode == D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER) {
// If the image can be written by the GPU, we need to update the
// mapped staging buffer to reflect the current image contents.
if (pResource->Desc()->Usage == D3D11_USAGE_DEFAULT) {
bool needsReadback = !pResource->NeedsDirtyRegionTracking();
needsReadback |= MapType == D3D11_MAP_READ
|| MapType == D3D11_MAP_READ_WRITE;
if (needsReadback)
ReadbackImageBuffer(pResource, Subresource);
}
}
if (MapType == D3D11_MAP_READ) {
// Reads will not change the image content, so we only need
// to wait for the GPU to finish writing to the mapped buffer.
@ -540,8 +530,6 @@ namespace dxvk {
}
if (doFlags & DoInvalidate) {
FlushImplicit(TRUE);
DxvkBufferSliceHandle prevSlice = pResource->GetMappedSlice(Subresource);
DxvkBufferSliceHandle physSlice = pResource->DiscardSlice(Subresource);
@ -600,20 +588,116 @@ namespace dxvk {
// the given subresource is actually mapped right now
m_mappedImageCount -= 1;
if ((mapType != D3D11_MAP_READ) &&
(pResource->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER)) {
// Now that data has been written into the buffer,
// we need to copy its contents into the image
VkImageAspectFlags aspectMask = imageFormatInfo(pResource->GetPackedFormat())->aspectMask;
VkImageSubresource subresource = pResource->GetSubresourceFromIndex(aspectMask, Subresource);
if ((mapType != D3D11_MAP_READ) && (pResource->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_BUFFER)) {
if (pResource->NeedsDirtyRegionTracking()) {
for (uint32_t i = 0; i < pResource->GetDirtyRegionCount(Subresource); i++) {
D3D11_COMMON_TEXTURE_REGION region = pResource->GetDirtyRegion(Subresource, i);
UpdateDirtyImageRegion(pResource, Subresource, &region);
}
UpdateImage(pResource, &subresource, VkOffset3D { 0, 0, 0 },
pResource->MipLevelExtent(subresource.mipLevel),
DxvkBufferSlice(pResource->GetMappedBuffer(Subresource)));
pResource->ClearDirtyRegions(Subresource);
} else {
UpdateDirtyImageRegion(pResource, Subresource, nullptr);
}
}
}
void D3D11ImmediateContext::ReadbackImageBuffer(
D3D11CommonTexture* pResource,
UINT Subresource) {
VkImageAspectFlags aspectMask = lookupFormatInfo(pResource->GetPackedFormat())->aspectMask;
VkImageSubresource subresource = pResource->GetSubresourceFromIndex(aspectMask, Subresource);
EmitCs([
cSrcImage = pResource->GetImage(),
cSrcSubresource = vk::makeSubresourceLayers(subresource),
cDstBuffer = pResource->GetMappedBuffer(Subresource),
cPackedFormat = pResource->GetPackedFormat()
] (DxvkContext* ctx) {
VkOffset3D offset = { 0, 0, 0 };
VkExtent3D extent = cSrcImage->mipLevelExtent(cSrcSubresource.mipLevel);
if (cSrcSubresource.aspectMask != (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
ctx->copyImageToBuffer(cDstBuffer, 0, 0, 0,
cSrcImage, cSrcSubresource, offset, extent);
} else {
ctx->copyDepthStencilImageToPackedBuffer(cDstBuffer, 0,
VkOffset2D { 0, 0 },
VkExtent2D { extent.width, extent.height },
cSrcImage, cSrcSubresource,
VkOffset2D { 0, 0 },
VkExtent2D { extent.width, extent.height },
cPackedFormat);
}
});
if (pResource->HasSequenceNumber())
TrackTextureSequenceNumber(pResource, Subresource);
}
void D3D11ImmediateContext::UpdateDirtyImageRegion(
D3D11CommonTexture* pResource,
UINT Subresource,
const D3D11_COMMON_TEXTURE_REGION* pRegion) {
auto formatInfo = lookupFormatInfo(pResource->GetPackedFormat());
auto subresource = vk::makeSubresourceLayers(
pResource->GetSubresourceFromIndex(formatInfo->aspectMask, Subresource));
// Update the entire image if no dirty region was specified
D3D11_COMMON_TEXTURE_REGION region;
if (pRegion) {
region = *pRegion;
} else {
region.Offset = VkOffset3D { 0, 0, 0 };
region.Extent = pResource->MipLevelExtent(subresource.mipLevel);
}
auto subresourceLayout = pResource->GetSubresourceLayout(formatInfo->aspectMask, Subresource);
// Update dirty region one aspect at a time, due to
// how the data is laid out in the staging buffer.
for (uint32_t i = 0; i < pResource->GetPlaneCount(); i++) {
subresource.aspectMask = formatInfo->aspectMask;
if (formatInfo->flags.test(DxvkFormatFlag::MultiPlane))
subresource.aspectMask = vk::getPlaneAspect(i);
EmitCs([
cDstImage = pResource->GetImage(),
cDstSubresource = subresource,
cDstOffset = region.Offset,
cDstExtent = region.Extent,
cSrcBuffer = pResource->GetMappedBuffer(Subresource),
cSrcOffset = pResource->ComputeMappedOffset(Subresource, i, region.Offset),
cSrcRowPitch = subresourceLayout.RowPitch,
cSrcDepthPitch = subresourceLayout.DepthPitch,
cPackedFormat = pResource->GetPackedFormat()
] (DxvkContext* ctx) {
if (cDstSubresource.aspectMask != (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
ctx->copyBufferToImage(
cDstImage, cDstSubresource, cDstOffset, cDstExtent,
cSrcBuffer, cSrcOffset, cSrcRowPitch, cSrcDepthPitch);
} else {
ctx->copyPackedBufferToDepthStencilImage(
cDstImage, cDstSubresource,
VkOffset2D { cDstOffset.x, cDstOffset.y },
VkExtent2D { cDstExtent.width, cDstExtent.height },
cSrcBuffer, 0,
VkOffset2D { cDstOffset.x, cDstOffset.y },
VkExtent2D { cDstExtent.width, cDstExtent.height },
cPackedFormat);
}
});
}
if (pResource->HasSequenceNumber())
TrackTextureSequenceNumber(pResource, Subresource);
}
void D3D11ImmediateContext::UpdateMappedBuffer(
D3D11Buffer* pDstBuffer,
UINT Offset,
@ -646,9 +730,12 @@ namespace dxvk {
if (!pState)
return;
Com<D3D11DeviceContextState> oldState = std::move(m_stateObject);
Com<D3D11DeviceContextState> newState = static_cast<D3D11DeviceContextState*>(pState);
// Reset all state affected by the current context state
ResetCommandListState();
Com<D3D11DeviceContextState, false> oldState = std::move(m_stateObject);
Com<D3D11DeviceContextState, false> newState = static_cast<D3D11DeviceContextState*>(pState);
if (oldState == nullptr)
oldState = new D3D11DeviceContextState(m_parent);
@ -661,7 +748,76 @@ namespace dxvk {
oldState->SetState(m_state);
newState->GetState(m_state);
RestoreState();
// Restore all state affected by the new context state
RestoreCommandListState();
}
void D3D11ImmediateContext::Acquire11on12Resource(
ID3D11Resource* pResource,
VkImageLayout SrcLayout) {
D3D10DeviceLock lock = LockContext();
auto texture = GetCommonTexture(pResource);
auto buffer = GetCommonBuffer(pResource);
if (buffer) {
EmitCs([
cBuffer = buffer->GetBuffer()
] (DxvkContext* ctx) {
ctx->emitBufferBarrier(cBuffer,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT,
cBuffer->info().stages,
cBuffer->info().access);
});
} else if (texture) {
EmitCs([
cImage = texture->GetImage(),
cLayout = SrcLayout
] (DxvkContext* ctx) {
ctx->emitImageBarrier(cImage, cLayout,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT,
cImage->info().layout,
cImage->info().stages,
cImage->info().access);
});
}
}
void D3D11ImmediateContext::Release11on12Resource(
ID3D11Resource* pResource,
VkImageLayout DstLayout) {
D3D10DeviceLock lock = LockContext();
auto texture = GetCommonTexture(pResource);
auto buffer = GetCommonBuffer(pResource);
if (buffer) {
EmitCs([
cBuffer = buffer->GetBuffer()
] (DxvkContext* ctx) {
ctx->emitBufferBarrier(cBuffer,
cBuffer->info().stages,
cBuffer->info().access,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT);
});
} else if (texture) {
EmitCs([
cImage = texture->GetImage(),
cLayout = DstLayout
] (DxvkContext* ctx) {
ctx->emitImageBarrier(cImage,
cImage->info().layout,
cImage->info().stages,
cImage->info().access,
cLayout, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_MEMORY_READ_BIT);
});
}
}
@ -682,6 +838,15 @@ namespace dxvk {
}
void D3D11ImmediateContext::EndFrame() {
D3D10DeviceLock lock = LockContext();
EmitCs<false>([] (DxvkContext* ctx) {
ctx->endFrame();
});
}
bool D3D11ImmediateContext::WaitForResource(
const Rc<DxvkResource>& Resource,
uint64_t SequenceNumber,
@ -707,14 +872,14 @@ namespace dxvk {
// We don't have to wait, but misbehaving games may
// still try to spin on `Map` until the resource is
// idle, so we should flush pending commands
FlushImplicit(FALSE);
ConsiderFlush(GpuFlushType::ImplicitSynchronization);
return false;
}
} else {
if (isInUse) {
// Make sure pending commands using the resource get
// executed on the the GPU if we have to wait for it
Flush();
ExecuteFlush(GpuFlushType::ImplicitSynchronization, nullptr, false);
SynchronizeCsThread(SequenceNumber);
m_device->waitForResource(Resource, access);
@ -727,7 +892,6 @@ namespace dxvk {
void D3D11ImmediateContext::EmitCsChunk(DxvkCsChunkRef&& chunk) {
m_csSeqNum = m_csThread.dispatchChunk(std::move(chunk));
m_csIsBusy = true;
}
@ -737,7 +901,7 @@ namespace dxvk {
uint64_t sequenceNumber = GetCurrentSequenceNumber();
pResource->TrackSequenceNumber(Subresource, sequenceNumber);
FlushImplicit(TRUE);
ConsiderFlush(GpuFlushType::ImplicitStrongHint);
}
@ -746,7 +910,7 @@ namespace dxvk {
uint64_t sequenceNumber = GetCurrentSequenceNumber();
pResource->TrackSequenceNumber(sequenceNumber);
FlushImplicit(TRUE);
ConsiderFlush(GpuFlushType::ImplicitStrongHint);
}
@ -758,40 +922,67 @@ namespace dxvk {
}
void D3D11ImmediateContext::FlushImplicit(BOOL StrongHint) {
// Flush only if the GPU is about to go idle, in
// order to keep the number of submissions low.
uint32_t pending = m_device->pendingSubmissions();
if (StrongHint || pending <= MaxPendingSubmits) {
auto now = dxvk::high_resolution_clock::now();
uint32_t delay = MinFlushIntervalUs
+ IncFlushIntervalUs * pending;
// Prevent flushing too often in short intervals.
if (now - m_lastFlush >= std::chrono::microseconds(delay))
Flush();
}
uint64_t D3D11ImmediateContext::GetPendingCsChunks() {
return GetCurrentSequenceNumber() - m_flushSeqNum;
}
void D3D11ImmediateContext::SignalEvent(HANDLE hEvent) {
uint64_t value = ++m_eventCount;
void D3D11ImmediateContext::ConsiderFlush(
GpuFlushType FlushType) {
uint64_t chunkId = GetCurrentSequenceNumber();
uint64_t submissionId = m_submissionFence->value();
if (m_eventSignal == nullptr)
m_eventSignal = new sync::CallbackFence();
if (m_flushTracker.considerFlush(FlushType, chunkId, submissionId))
ExecuteFlush(FlushType, nullptr, false);
}
m_eventSignal->setCallback(value, [hEvent] {
SetEvent(hEvent);
});
EmitCs([
cSignal = m_eventSignal,
cValue = value
void D3D11ImmediateContext::ExecuteFlush(
GpuFlushType FlushType,
HANDLE hEvent,
BOOL Synchronize) {
bool synchronizeSubmission = Synchronize && m_parent->Is11on12Device();
if (synchronizeSubmission)
m_submitStatus.result = VK_NOT_READY;
// Flush init context so that new resources are fully initialized
// before the app can access them in any way. This has to happen
// unconditionally since we may otherwise deadlock on Map.
m_parent->FlushInitContext();
// Exit early if there's nothing to do
if (!GetPendingCsChunks() && !hEvent)
return;
// Signal the submission fence and flush the command list
uint64_t submissionId = ++m_submissionId;
if (hEvent) {
m_submissionFence->setCallback(submissionId, [hEvent] {
SetEvent(hEvent);
});
}
EmitCs<false>([
cSubmissionFence = m_submissionFence,
cSubmissionId = submissionId,
cSubmissionStatus = synchronizeSubmission ? &m_submitStatus : nullptr
] (DxvkContext* ctx) {
ctx->signal(cSignal, cValue);
ctx->signal(cSubmissionFence, cSubmissionId);
ctx->flushCommandList(cSubmissionStatus);
});
FlushCsChunk();
// Notify flush tracker about the flush
m_flushSeqNum = m_csSeqNum;
m_flushTracker.notifyFlush(m_flushSeqNum, submissionId);
// If necessary, block calling thread until the
// Vulkan queue submission is performed.
if (synchronizeSubmission)
m_device->waitForSubmission(&m_submitStatus);
}
}

View File

@ -12,11 +12,12 @@ namespace dxvk {
class D3D11Buffer;
class D3D11CommonTexture;
class D3D11ImmediateContext : public D3D11DeviceContext {
class D3D11ImmediateContext : public D3D11CommonContext<D3D11ImmediateContext> {
friend class D3D11CommonContext<D3D11ImmediateContext>;
friend class D3D11SwapChain;
friend class D3D11VideoContext;
friend class D3D11DeviceContext;
friend class D3D11DXGIKeyedMutex;
public:
D3D11ImmediateContext(
@ -28,10 +29,6 @@ namespace dxvk {
REFIID riid,
void** ppvObject);
D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE GetType();
UINT STDMETHODCALLTYPE GetContextFlags();
HRESULT STDMETHODCALLTYPE GetData(
ID3D11Asynchronous* pAsync,
void* pData,
@ -77,61 +74,49 @@ namespace dxvk {
ID3D11Resource* pResource,
UINT Subresource);
void STDMETHODCALLTYPE UpdateSubresource(
ID3D11Resource* pDstResource,
UINT DstSubresource,
const D3D11_BOX* pDstBox,
const void* pSrcData,
UINT SrcRowPitch,
UINT SrcDepthPitch);
void STDMETHODCALLTYPE UpdateSubresource1(
ID3D11Resource* pDstResource,
UINT DstSubresource,
const D3D11_BOX* pDstBox,
const void* pSrcData,
UINT SrcRowPitch,
UINT SrcDepthPitch,
UINT CopyFlags);
void STDMETHODCALLTYPE OMSetRenderTargets(
UINT NumViews,
ID3D11RenderTargetView* const* ppRenderTargetViews,
ID3D11DepthStencilView* pDepthStencilView);
void STDMETHODCALLTYPE OMSetRenderTargetsAndUnorderedAccessViews(
UINT NumRTVs,
ID3D11RenderTargetView* const* ppRenderTargetViews,
ID3D11DepthStencilView* pDepthStencilView,
UINT UAVStartSlot,
UINT NumUAVs,
ID3D11UnorderedAccessView* const* ppUnorderedAccessViews,
const UINT* pUAVInitialCounts);
void STDMETHODCALLTYPE SwapDeviceContextState(
ID3DDeviceContextState* pState,
ID3DDeviceContextState** ppPreviousState);
void Acquire11on12Resource(
ID3D11Resource* pResource,
VkImageLayout SrcLayout);
void Release11on12Resource(
ID3D11Resource* pResource,
VkImageLayout DstLayout);
void SynchronizeCsThread(
uint64_t SequenceNumber);
D3D10Multithread& GetMultithread() {
return m_multithread;
}
D3D10DeviceLock LockContext() {
return m_multithread.AcquireLock();
}
private:
DxvkCsThread m_csThread;
uint64_t m_csSeqNum = 0ull;
bool m_csIsBusy = false;
Rc<sync::CallbackFence> m_eventSignal;
uint64_t m_eventCount = 0ull;
uint32_t m_mappedImageCount = 0u;
VkDeviceSize m_maxImplicitDiscardSize = 0ull;
dxvk::high_resolution_clock::time_point m_lastFlush
= dxvk::high_resolution_clock::now();
D3D11VideoContext m_videoContext;
Com<D3D11DeviceContextState> m_stateObject;
Rc<sync::CallbackFence> m_submissionFence;
uint64_t m_submissionId = 0ull;
DxvkSubmitStatus m_submitStatus;
uint64_t m_flushSeqNum = 0ull;
GpuFlushTracker m_flushTracker;
D3D10Multithread m_multithread;
D3D11VideoContext m_videoContext;
Com<D3D11DeviceContextState, false> m_stateObject;
HRESULT MapBuffer(
D3D11Buffer* pResource,
@ -150,20 +135,31 @@ namespace dxvk {
D3D11CommonTexture* pResource,
UINT Subresource);
void ReadbackImageBuffer(
D3D11CommonTexture* pResource,
UINT Subresource);
void UpdateDirtyImageRegion(
D3D11CommonTexture* pResource,
UINT Subresource,
const D3D11_COMMON_TEXTURE_REGION* pRegion);
void UpdateMappedBuffer(
D3D11Buffer* pDstBuffer,
UINT Offset,
UINT Length,
const void* pSrcData,
UINT CopyFlags);
D3D11Buffer* pDstBuffer,
UINT Offset,
UINT Length,
const void* pSrcData,
UINT CopyFlags);
void SynchronizeDevice();
void EndFrame();
bool WaitForResource(
const Rc<DxvkResource>& Resource,
uint64_t SequenceNumber,
D3D11_MAP MapType,
UINT MapFlags);
const Rc<DxvkResource>& Resource,
uint64_t SequenceNumber,
D3D11_MAP MapType,
UINT MapFlags);
void EmitCsChunk(DxvkCsChunkRef&& chunk);
@ -176,10 +172,16 @@ namespace dxvk {
uint64_t GetCurrentSequenceNumber();
void FlushImplicit(BOOL StrongHint);
uint64_t GetPendingCsChunks();
void ConsiderFlush(
GpuFlushType FlushType);
void ExecuteFlush(
GpuFlushType FlushType,
HANDLE hEvent,
BOOL Synchronize);
void SignalEvent(HANDLE hEvent);
};
}

View File

@ -15,128 +15,237 @@
namespace dxvk {
/**
* \brief Per-stage state
*
* Stores an object of the given type for each shader stage.
* \tparam Object type
*/
template<typename T>
class D3D11ShaderStageState {
public:
T& operator [] (DxbcProgramType type) { return m_state[uint32_t(type)]; }
const T& operator [] (DxbcProgramType type) const { return m_state[uint32_t(type)]; }
/**
* \brief Calls reset method on all objects
*/
void reset() {
for (auto& state : m_state)
state.reset();
}
private:
std::array<T, 6> m_state = { };
};
/**
* \brief Constant buffer bindings
*
* Stores the bound buffer range from a runtime point of view,
* as well as the range that is actually bound to the context.
*/
struct D3D11ConstantBufferBinding {
Com<D3D11Buffer> buffer = nullptr;
Com<D3D11Buffer, false> buffer = nullptr;
UINT constantOffset = 0;
UINT constantCount = 0;
UINT constantBound = 0;
};
using D3D11ConstantBufferBindings = std::array<
D3D11ConstantBufferBinding, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT>;
using D3D11SamplerBindings = std::array<
D3D11SamplerState*, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT>;
struct D3D11ShaderResourceBindings {
std::array<Com<D3D11ShaderResourceView>, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT> views = { };
DxvkBindingSet<D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT> hazardous = { };
};
using D3D11UnorderedAccessBindings = std::array<
Com<D3D11UnorderedAccessView>, D3D11_1_UAV_SLOT_COUNT>;
struct D3D11ContextStateVS {
Com<D3D11VertexShader> shader = nullptr;
D3D11ConstantBufferBindings constantBuffers = { };
D3D11SamplerBindings samplers = { };
D3D11ShaderResourceBindings shaderResources = { };
};
struct D3D11ContextStateHS {
Com<D3D11HullShader> shader = nullptr;
D3D11ConstantBufferBindings constantBuffers = { };
D3D11SamplerBindings samplers = { };
D3D11ShaderResourceBindings shaderResources = { };
};
struct D3D11ContextStateDS {
Com<D3D11DomainShader> shader = nullptr;
D3D11ConstantBufferBindings constantBuffers = { };
D3D11SamplerBindings samplers = { };
D3D11ShaderResourceBindings shaderResources = { };
};
struct D3D11ContextStateGS {
Com<D3D11GeometryShader> shader = nullptr;
D3D11ConstantBufferBindings constantBuffers = { };
D3D11SamplerBindings samplers = { };
D3D11ShaderResourceBindings shaderResources = { };
};
struct D3D11ContextStatePS {
Com<D3D11PixelShader> shader = nullptr;
D3D11ConstantBufferBindings constantBuffers = { };
D3D11SamplerBindings samplers = { };
D3D11ShaderResourceBindings shaderResources = { };
D3D11UnorderedAccessBindings unorderedAccessViews = { };
};
struct D3D11ContextStateCS {
Com<D3D11ComputeShader> shader = nullptr;
D3D11ConstantBufferBindings constantBuffers = { };
D3D11SamplerBindings samplers = { };
D3D11ShaderResourceBindings shaderResources = { };
D3D11UnorderedAccessBindings unorderedAccessViews = { };
struct D3D11ShaderStageCbvBinding {
std::array<D3D11ConstantBufferBinding, D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT> buffers = { };
DxvkBindingSet<D3D11_1_UAV_SLOT_COUNT> uavMask = { };
uint32_t maxCount = 0;
void reset() {
for (uint32_t i = 0; i < maxCount; i++)
buffers[i] = D3D11ConstantBufferBinding();
maxCount = 0;
}
};
using D3D11CbvBindings = D3D11ShaderStageState<D3D11ShaderStageCbvBinding>;
/**
* \brief Shader resource bindings
*
* Stores bound shader resource views, as well as a bit
* set of views that are potentially hazardous.
*/
struct D3D11ShaderStageSrvBinding {
std::array<Com<D3D11ShaderResourceView, false>, D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT> views = { };
DxvkBindingSet<D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT> hazardous = { };
uint32_t maxCount = 0;
void reset() {
for (uint32_t i = 0; i < maxCount; i++)
views[i] = nullptr;
hazardous.clear();
maxCount = 0;
}
};
using D3D11SrvBindings = D3D11ShaderStageState<D3D11ShaderStageSrvBinding>;
/**
* \brief Sampler bindings
*
* Stores bound samplers.
*/
struct D3D11ShaderStageSamplerBinding {
std::array<D3D11SamplerState*, D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT> samplers = { };
uint32_t maxCount = 0;
void reset() {
for (uint32_t i = 0; i < maxCount; i++)
samplers[i] = nullptr;
maxCount = 0;
}
};
using D3D11SamplerBindings = D3D11ShaderStageState<D3D11ShaderStageSamplerBinding>;
/**
* \brief UAV bindings
*
* Stores bound UAVs. For compute shader UAVs,
* we also store a bit mask of bound UAVs.
*/
using D3D11ShaderStageUavBinding = std::array<Com<D3D11UnorderedAccessView, false>, D3D11_1_UAV_SLOT_COUNT>;
struct D3D11UavBindings {
D3D11ShaderStageUavBinding views = { };
DxvkBindingSet<D3D11_1_UAV_SLOT_COUNT> mask = { };
uint32_t maxCount = 0;
void reset() {
for (uint32_t i = 0; i < maxCount; i++)
views[i] = nullptr;
mask.clear();
maxCount = 0;
}
};
/**
* \brief Input assembly state
*
* Stores vertex buffers, the index buffer, the
* input layout, and the dynamic primitive topology.
*/
struct D3D11VertexBufferBinding {
Com<D3D11Buffer> buffer = nullptr;
UINT offset = 0;
UINT stride = 0;
Com<D3D11Buffer, false> buffer = nullptr;
UINT offset = 0;
UINT stride = 0;
};
struct D3D11IndexBufferBinding {
Com<D3D11Buffer> buffer = nullptr;
UINT offset = 0;
DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN;
Com<D3D11Buffer, false> buffer = nullptr;
UINT offset = 0;
DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN;
};
struct D3D11ContextStateID {
Com<D3D11Buffer> argBuffer = nullptr;
Com<D3D11Buffer> cntBuffer = nullptr;
};
struct D3D11ContextStateIA {
Com<D3D11InputLayout> inputLayout = nullptr;
D3D11_PRIMITIVE_TOPOLOGY primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED;
Com<D3D11InputLayout, false> inputLayout = nullptr;
D3D11_PRIMITIVE_TOPOLOGY primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED;
std::array<D3D11VertexBufferBinding, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT> vertexBuffers = { };
D3D11IndexBufferBinding indexBuffer = { };
uint32_t maxVbCount = 0;
void reset() {
inputLayout = nullptr;
primitiveTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED;
for (uint32_t i = 0; i < maxVbCount; i++)
vertexBuffers[i] = D3D11VertexBufferBinding();
indexBuffer = D3D11IndexBufferBinding();
}
};
/**
* \brief Output merger state
*
* Stores RTV, DSV, and graphics UAV bindings, as well as related state.
*/
using D3D11RenderTargetViewBinding = std::array<Com<D3D11RenderTargetView, false>, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT>;
struct D3D11ContextStateOM {
std::array<Com<D3D11RenderTargetView, false>, D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT> renderTargetViews = { };
Com<D3D11DepthStencilView, false> depthStencilView = { };
D3D11ShaderStageUavBinding uavs = { };
D3D11RenderTargetViewBinding rtvs = { };
Com<D3D11DepthStencilView, false> dsv = { };
D3D11BlendState* cbState = nullptr;
D3D11DepthStencilState* dsState = nullptr;
FLOAT blendFactor[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
UINT sampleMask = 0xFFFFFFFFu;
UINT stencilRef = 0u;
UINT sampleCount = 0u;
UINT sampleMask = D3D11_DEFAULT_SAMPLE_MASK;
UINT stencilRef = D3D11_DEFAULT_STENCIL_REFERENCE;
UINT maxRtv = 0u;
UINT maxUav = 0u;
void reset() {
for (uint32_t i = 0; i < maxUav; i++)
uavs[i] = nullptr;
for (uint32_t i = 0; i < maxRtv; i++)
rtvs[i] = nullptr;
dsv = nullptr;
cbState = nullptr;
dsState = nullptr;
for (uint32_t i = 0; i < 4; i++)
blendFactor[i] = 1.0f;
sampleCount = 0u;
sampleMask = D3D11_DEFAULT_SAMPLE_MASK;
stencilRef = D3D11_DEFAULT_STENCIL_REFERENCE;
maxRtv = 0;
maxUav = 0;
}
};
/**
* \brief Indirect draw state
*
* Stores the current indirct draw
* argument and draw count buffer.
*/
struct D3D11ContextStateID {
Com<D3D11Buffer, false> argBuffer = nullptr;
Com<D3D11Buffer, false> cntBuffer = nullptr;
void reset() {
argBuffer = nullptr;
cntBuffer = nullptr;
}
};
/**
* \brief Rasterizer state
*
* Stores viewport info and the rasterizer state object.
*/
struct D3D11ContextStateRS {
uint32_t numViewports = 0;
uint32_t numScissors = 0;
@ -145,43 +254,97 @@ namespace dxvk {
std::array<D3D11_RECT, D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE> scissors = { };
D3D11RasterizerState* state = nullptr;
void reset() {
for (uint32_t i = 0; i < numViewports; i++)
viewports[i] = D3D11_VIEWPORT();
for (uint32_t i = 0; i < numScissors; i++)
scissors[i] = D3D11_RECT();
numViewports = 0;
numScissors = 0;
state = nullptr;
}
};
/**
* \brief Stream output binding
*
* Stores stream output buffers with offset.
*/
struct D3D11ContextSoTarget {
Com<D3D11Buffer> buffer = nullptr;
UINT offset = 0;
Com<D3D11Buffer, false> buffer = nullptr;
UINT offset = 0;
};
struct D3D11ContextStateSO {
std::array<D3D11ContextSoTarget, D3D11_SO_BUFFER_SLOT_COUNT> targets = { };
void reset() {
for (uint32_t i = 0; i < targets.size(); i++)
targets[i] = D3D11ContextSoTarget();
}
};
/**
* \brief Predication state
*
* Stores predication info.
*/
struct D3D11ContextStatePR {
Com<D3D11Query> predicateObject = nullptr;
BOOL predicateValue = FALSE;
Com<D3D11Query, false> predicateObject = nullptr;
BOOL predicateValue = false;
void reset() {
predicateObject = nullptr;
predicateValue = false;
}
};
/**
* \brief Context state
*/
struct D3D11ContextState {
D3D11ContextStateCS cs;
D3D11ContextStateDS ds;
D3D11ContextStateGS gs;
D3D11ContextStateHS hs;
D3D11ContextStatePS ps;
D3D11ContextStateVS vs;
Com<D3D11VertexShader, false> vs;
Com<D3D11HullShader, false> hs;
Com<D3D11DomainShader, false> ds;
Com<D3D11GeometryShader, false> gs;
Com<D3D11PixelShader, false> ps;
Com<D3D11ComputeShader, false> cs;
D3D11ContextStateID id;
D3D11ContextStateIA ia;
D3D11ContextStateOM om;
D3D11ContextStateRS rs;
D3D11ContextStateSO so;
D3D11ContextStatePR pr;
D3D11CbvBindings cbv;
D3D11SrvBindings srv;
D3D11UavBindings uav;
D3D11SamplerBindings samplers;
};
/**
* \brief Maximum used binding numbers in a shader stage
*/
struct D3D11MaxUsedStageBindings {
uint32_t cbvCount : 5;
uint32_t srvCount : 9;
uint32_t uavCount : 7;
uint32_t samplerCount : 5;
uint32_t reserved : 6;
};
/**
* \brief Maximum used binding numbers for all context state
*/
struct D3D11MaxUsedBindings {
std::array<D3D11MaxUsedStageBindings, 6> stages;
uint32_t vbCount;
uint32_t soCount;
};
}

View File

@ -37,12 +37,15 @@ namespace dxvk {
if (riid == __uuidof(ID3D10DeviceChild)
|| riid == __uuidof(ID3D10DepthStencilState)) {
*ppvObject = ref(this);
*ppvObject = ref(&m_d3d10);
return S_OK;
}
Logger::warn("D3D11DepthStencilState::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
if (logQueryInterfaceError(__uuidof(ID3D11DepthStencilState), riid)) {
Logger::warn("D3D11DepthStencilState::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
}
return E_NOINTERFACE;
}
@ -52,7 +55,7 @@ namespace dxvk {
}
void D3D11DepthStencilState::BindToContext(const Rc<DxvkContext>& ctx) {
void D3D11DepthStencilState::BindToContext(DxvkContext* ctx) {
ctx->setDepthStencilState(m_state);
}

View File

@ -29,8 +29,7 @@ namespace dxvk {
void STDMETHODCALLTYPE GetDesc(
D3D11_DEPTH_STENCIL_DESC* pDesc) final;
void BindToContext(
const Rc<DxvkContext>& ctx);
void BindToContext(DxvkContext* ctx);
D3D10DepthStencilState* GetD3D10Iface() {
return &m_d3d10;

File diff suppressed because it is too large Load Diff

View File

@ -16,9 +16,11 @@
#include "d3d11_cmdlist.h"
#include "d3d11_cuda.h"
#include "d3d11_features.h"
#include "d3d11_initializer.h"
#include "d3d11_interfaces.h"
#include "d3d11_interop.h"
#include "d3d11_on_12.h"
#include "d3d11_options.h"
#include "d3d11_shader.h"
#include "d3d11_state.h"
@ -31,7 +33,6 @@ namespace dxvk {
class D3D11CommonShader;
class D3D11CommonTexture;
class D3D11Counter;
class D3D11DeviceContext;
class D3D11DXGIDevice;
class D3D11ImmediateContext;
class D3D11Predicate;
@ -260,7 +261,7 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE CreateFence(
UINT64 InitialValue,
D3D11_FENCE_FLAG Flags,
REFIID ReturnedInterface,
REFIID riid,
void** ppFence);
void STDMETHODCALLTYPE ReadFromSubresource(
@ -420,19 +421,23 @@ namespace dxvk {
D3D10Device* GetD3D10Interface() const {
return m_d3d10Device;
}
static bool CheckFeatureLevelSupport(
const Rc<DxvkInstance>& instance,
const Rc<DxvkAdapter>& adapter,
D3D_FEATURE_LEVEL featureLevel);
D3D11ImmediateContext* GetContext() const {
return m_context.ptr();
}
bool Is11on12Device() const;
static D3D_FEATURE_LEVEL GetMaxFeatureLevel(
const Rc<DxvkInstance>& Instance,
const Rc<DxvkAdapter>& Adapter);
static DxvkDeviceFeatures GetDeviceFeatures(
const Rc<DxvkAdapter>& adapter,
D3D_FEATURE_LEVEL featureLevel);
const Rc<DxvkAdapter>& Adapter);
private:
IDXGIObject* m_container;
D3D11DXGIDevice* m_container;
D3D_FEATURE_LEVEL m_featureLevel;
UINT m_featureFlags;
@ -455,7 +460,10 @@ namespace dxvk {
D3D11StateObjectSet<D3D11RasterizerState> m_rsStateObjects;
D3D11StateObjectSet<D3D11SamplerState> m_samplerObjects;
D3D11ShaderModuleSet m_shaderModules;
D3D_FEATURE_LEVEL m_maxFeatureLevel;
D3D11DeviceFeatures m_deviceFeatures;
HRESULT CreateShaderModule(
D3D11CommonShader* pShaderModule,
DxvkShaderKey ShaderKey,
@ -465,13 +473,14 @@ namespace dxvk {
const DxbcModuleInfo* pModuleInfo);
HRESULT GetFormatSupportFlags(
DXGI_FORMAT Format,
UINT* pFlags1,
UINT* pFlags2) const;
DXGI_FORMAT Format,
UINT* pFlags1,
UINT* pFlags2) const;
BOOL GetImageTypeSupport(
VkFormat Format,
VkImageType Type) const;
VkFormat Format,
VkImageType Type,
VkImageCreateFlags Flags) const;
template<bool IsKmtHandle>
HRESULT OpenSharedResourceGeneric(
@ -488,13 +497,10 @@ namespace dxvk {
Void* pData,
UINT RowPitch,
UINT DepthPitch,
ID3D11Resource* pResource,
D3D11CommonTexture* pTexture,
UINT Subresource,
const D3D11_BOX* pBox);
static D3D_FEATURE_LEVEL GetMaxFeatureLevel(
const Rc<DxvkInstance>& pInstance);
};
@ -692,39 +698,36 @@ namespace dxvk {
/**
* \brief DXGI swap chain factory
* \brief DXVK swap chain factory
*/
class WineDXGISwapChainFactory : public IWineDXGISwapChainFactory {
class DXGIVkSwapChainFactory : public IDXGIVkSwapChainFactory {
public:
WineDXGISwapChainFactory(
DXGIVkSwapChainFactory(
D3D11DXGIDevice* pContainer,
D3D11Device* pDevice);
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject);
HRESULT STDMETHODCALLTYPE CreateSwapChainForHwnd(
IDXGIFactory* pFactory,
HWND hWnd,
const DXGI_SWAP_CHAIN_DESC1* pDesc,
const DXGI_SWAP_CHAIN_FULLSCREEN_DESC* pFullscreenDesc,
IDXGIOutput* pRestrictToOutput,
IDXGISwapChain1** ppSwapChain);
HRESULT STDMETHODCALLTYPE CreateSwapChain(
IDXGIVkSurfaceFactory* pSurfaceFactory,
const DXGI_SWAP_CHAIN_DESC1* pDesc,
IDXGIVkSwapChain** ppSwapChain);
private:
D3D11DXGIDevice* m_container;
D3D11Device* m_device;
};
/**
* \brief D3D11 device metadata shenanigans
@ -768,8 +771,11 @@ namespace dxvk {
D3D11DXGIDevice(
IDXGIAdapter* pAdapter,
const Rc<DxvkInstance>& pDxvkInstance,
const Rc<DxvkAdapter>& pDxvkAdapter,
ID3D12Device* pD3D12Device,
ID3D12CommandQueue* pD3D12Queue,
Rc<DxvkInstance> pDxvkInstance,
Rc<DxvkAdapter> pDxvkAdapter,
Rc<DxvkDevice> pDxvkDevice,
D3D_FEATURE_LEVEL FeatureLevel,
UINT FeatureFlags);
@ -838,6 +844,10 @@ namespace dxvk {
Rc<DxvkDevice> STDMETHODCALLTYPE GetDXVKDevice();
BOOL Is11on12Device() const {
return m_d3d11on12.Is11on12Device();
}
private:
Com<IDXGIAdapter> m_dxgiAdapter;
@ -850,14 +860,13 @@ namespace dxvk {
D3D11DeviceExt m_d3d11DeviceExt;
D3D11VkInterop m_d3d11Interop;
D3D11VideoDevice m_d3d11Video;
D3D11on12Device m_d3d11on12;
DXGIDXVKDevice m_metaDevice;
WineDXGISwapChainFactory m_wineFactory;
DXGIVkSwapChainFactory m_dxvkFactory;
uint32_t m_frameLatency = DefaultFrameLatency;
Rc<DxvkDevice> CreateDevice(D3D_FEATURE_LEVEL FeatureLevel);
};
}

View File

@ -0,0 +1,401 @@
#include <array>
#include "d3d11_features.h"
namespace dxvk {
D3D11DeviceFeatures::D3D11DeviceFeatures() {
}
D3D11DeviceFeatures::D3D11DeviceFeatures(
const Rc<DxvkInstance>& Instance,
const Rc<DxvkAdapter>& Adapter,
const D3D11Options& Options,
D3D_FEATURE_LEVEL FeatureLevel)
: m_features (Adapter->features()),
m_properties (Adapter->devicePropertiesExt()) {
// Assume no TBDR. DXVK does not optimize for TBDR architectures
// anyway, and D3D11 does not really provide meaningful support.
m_architectureInfo.TileBasedDeferredRenderer = FALSE;
// D3D9 options. We unconditionally support all of these.
m_d3d9Options.FullNonPow2TextureSupport = TRUE;
m_d3d9Options1.FullNonPow2TextureSupported = TRUE;
m_d3d9Options1.DepthAsTextureWithLessEqualComparisonFilterSupported = TRUE;
m_d3d9Options1.SimpleInstancingSupported = TRUE;
m_d3d9Options1.TextureCubeFaceRenderTargetWithNonCubeDepthStencilSupported = TRUE;
m_d3d9Shadow.SupportsDepthAsTextureWithLessEqualComparisonFilter = TRUE;
m_d3d9SimpleInstancing.SimpleInstancingSupported = TRUE;
// D3D10 options. We unconditionally support compute shaders.
m_d3d10Options.ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x = TRUE;
// D3D11.1 options. All of these are required for Feature Level 11_1.
auto sharedResourceTier = DetermineSharedResourceTier(Adapter, FeatureLevel);
bool hasDoublePrecisionSupport = m_features.core.features.shaderFloat64
&& m_features.core.features.shaderInt64;
m_d3d11Options.DiscardAPIsSeenByDriver = TRUE;
m_d3d11Options.FlagsForUpdateAndCopySeenByDriver = TRUE;
m_d3d11Options.ClearView = TRUE;
m_d3d11Options.CopyWithOverlap = TRUE;
m_d3d11Options.ConstantBufferPartialUpdate = TRUE;
m_d3d11Options.ConstantBufferOffsetting = TRUE;
m_d3d11Options.MapNoOverwriteOnDynamicConstantBuffer = TRUE;
m_d3d11Options.MapNoOverwriteOnDynamicBufferSRV = TRUE;
m_d3d11Options.ExtendedResourceSharing = sharedResourceTier > D3D11_SHARED_RESOURCE_TIER_0;
if (FeatureLevel >= D3D_FEATURE_LEVEL_10_0) {
m_d3d11Options.OutputMergerLogicOp = m_features.core.features.logicOp;
m_d3d11Options.MultisampleRTVWithForcedSampleCountOne = TRUE; // Not really
}
if (FeatureLevel >= D3D_FEATURE_LEVEL_11_0) {
m_d3d11Options.UAVOnlyRenderingForcedSampleCount = TRUE;
m_d3d11Options.SAD4ShaderInstructions = TRUE;
m_d3d11Options.ExtendedDoublesShaderInstructions = hasDoublePrecisionSupport;
}
// D3D11.2 options.
auto tiledResourcesTier = DetermineTiledResourcesTier(FeatureLevel);
m_d3d11Options1.TiledResourcesTier = tiledResourcesTier;
m_d3d11Options1.MinMaxFiltering = tiledResourcesTier >= D3D11_TILED_RESOURCES_TIER_2;
m_d3d11Options1.ClearViewAlsoSupportsDepthOnlyFormats = TRUE;
if (FeatureLevel >= D3D_FEATURE_LEVEL_11_0)
m_d3d11Options1.MapOnDefaultBuffers = TRUE;
// D3D11.3 options
m_d3d11Options2.TypedUAVLoadAdditionalFormats = DetermineUavExtendedTypedLoadSupport(Adapter, FeatureLevel);
m_d3d11Options2.ConservativeRasterizationTier = DetermineConservativeRasterizationTier(FeatureLevel);
m_d3d11Options2.TiledResourcesTier = tiledResourcesTier;
m_d3d11Options2.StandardSwizzle = FALSE;
m_d3d11Options2.UnifiedMemoryArchitecture = FALSE;
if (FeatureLevel >= D3D_FEATURE_LEVEL_11_0)
m_d3d11Options2.MapOnDefaultTextures = TRUE;
if (FeatureLevel >= D3D_FEATURE_LEVEL_11_1) {
m_d3d11Options2.ROVsSupported = m_features.extFragmentShaderInterlock.fragmentShaderPixelInterlock;
m_d3d11Options2.PSSpecifiedStencilRefSupported = m_features.extShaderStencilExport;
}
// More D3D11.3 options
if (FeatureLevel >= D3D_FEATURE_LEVEL_11_0) {
m_d3d11Options3.VPAndRTArrayIndexFromAnyShaderFeedingRasterizer =
m_features.vk12.shaderOutputViewportIndex &&
m_features.vk12.shaderOutputLayer;
}
// D3D11.4 options
m_d3d11Options4.ExtendedNV12SharedTextureSupported = sharedResourceTier > D3D11_SHARED_RESOURCE_TIER_0;
// More D3D11.4 options
m_d3d11Options5.SharedResourceTier = sharedResourceTier;
// Double-precision support
if (FeatureLevel >= D3D_FEATURE_LEVEL_11_0)
m_doubles.DoublePrecisionFloatShaderOps = hasDoublePrecisionSupport;
// These numbers are not accurate, but we have no real way to query these
m_gpuVirtualAddress.MaxGPUVirtualAddressBitsPerResource = 32;
m_gpuVirtualAddress.MaxGPUVirtualAddressBitsPerProcess = 40;
// Marker support only depends on the debug utils extension
m_marker.Profile = static_cast<bool>(Instance->extensions().extDebugUtils);
// DXVK will keep all shaders in memory once created, and all Vulkan
// drivers that we know of that can run DXVK have an on-disk cache.
m_shaderCache.SupportFlags = D3D11_SHADER_CACHE_SUPPORT_AUTOMATIC_INPROC_CACHE
| D3D11_SHADER_CACHE_SUPPORT_AUTOMATIC_DISK_CACHE;
// DXVK does not support min precision
m_shaderMinPrecision.PixelShaderMinPrecision = 0;
m_shaderMinPrecision.AllOtherShaderStagesMinPrecision = 0;
// Report native support for command lists by default. Deferred context
// usage can be beneficial for us as ExecuteCommandList has low overhead,
// and we avoid having to deal with known UpdateSubresource bugs this way.
m_threading.DriverConcurrentCreates = TRUE;
m_threading.DriverCommandLists = Options.exposeDriverCommandLists;
}
D3D11DeviceFeatures::~D3D11DeviceFeatures() {
}
HRESULT D3D11DeviceFeatures::GetFeatureData(
D3D11_FEATURE Feature,
UINT FeatureDataSize,
void* pFeatureData) const {
switch (Feature) {
case D3D11_FEATURE_ARCHITECTURE_INFO:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_architectureInfo);
case D3D11_FEATURE_D3D9_OPTIONS:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_d3d9Options);
case D3D11_FEATURE_D3D9_OPTIONS1:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_d3d9Options1);
case D3D11_FEATURE_D3D9_SHADOW_SUPPORT:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_d3d9Shadow);
case D3D11_FEATURE_D3D9_SIMPLE_INSTANCING_SUPPORT:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_d3d9SimpleInstancing);
case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_d3d10Options);
case D3D11_FEATURE_D3D11_OPTIONS:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_d3d11Options);
case D3D11_FEATURE_D3D11_OPTIONS1:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_d3d11Options1);
case D3D11_FEATURE_D3D11_OPTIONS2:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_d3d11Options2);
case D3D11_FEATURE_D3D11_OPTIONS3:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_d3d11Options3);
case D3D11_FEATURE_D3D11_OPTIONS4:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_d3d11Options4);
case D3D11_FEATURE_D3D11_OPTIONS5:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_d3d11Options5);
case D3D11_FEATURE_DOUBLES:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_doubles);
case D3D11_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_gpuVirtualAddress);
case D3D11_FEATURE_MARKER_SUPPORT:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_marker);
case D3D11_FEATURE_SHADER_CACHE:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_shaderCache);
case D3D11_FEATURE_SHADER_MIN_PRECISION_SUPPORT:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_shaderMinPrecision);
case D3D11_FEATURE_THREADING:
return GetTypedFeatureData(FeatureDataSize, pFeatureData, &m_threading);
default:
Logger::err(str::format("D3D11: Unknown feature: ", Feature));
return E_INVALIDARG;
}
}
D3D_FEATURE_LEVEL D3D11DeviceFeatures::GetMaxFeatureLevel(
const Rc<DxvkInstance>& Instance,
const Rc<DxvkAdapter>& Adapter) {
D3D11Options options(Instance->config());
D3D11DeviceFeatures features(Instance, Adapter, options, D3D_FEATURE_LEVEL_12_1);
return features.GetMaxFeatureLevel();
}
D3D11_CONSERVATIVE_RASTERIZATION_TIER D3D11DeviceFeatures::DetermineConservativeRasterizationTier(
D3D_FEATURE_LEVEL FeatureLevel) {
if (FeatureLevel < D3D_FEATURE_LEVEL_11_1
|| !m_features.extConservativeRasterization)
return D3D11_CONSERVATIVE_RASTERIZATION_NOT_SUPPORTED;
// We don't really have a way to query uncertainty regions,
// so just check degenerate triangle behaviour
if (!m_properties.extConservativeRasterization.degenerateTrianglesRasterized)
return D3D11_CONSERVATIVE_RASTERIZATION_TIER_1;
// Inner coverage is required for Tier 3 support
if (!m_properties.extConservativeRasterization.fullyCoveredFragmentShaderInputVariable)
return D3D11_CONSERVATIVE_RASTERIZATION_TIER_2;
return D3D11_CONSERVATIVE_RASTERIZATION_TIER_3;
}
D3D11_SHARED_RESOURCE_TIER D3D11DeviceFeatures::DetermineSharedResourceTier(
const Rc<DxvkAdapter>& Adapter,
D3D_FEATURE_LEVEL FeatureLevel) {
static std::atomic<bool> s_errorShown = { false };
// Lie about supporting Tier 1 since that's the
// minimum required tier for Feature Level 11_1
if (!Adapter->features().khrExternalMemoryWin32) {
if (!s_errorShown.exchange(true))
Logger::warn("D3D11DeviceFeatures: External memory features not supported");
return D3D11_SHARED_RESOURCE_TIER_1;
}
// Check support for extended formats. Ignore multi-plane
// formats here since driver support varies too much.
std::array<VkFormat, 30> requiredFormats = {{
VK_FORMAT_R16G16B16A16_SFLOAT,
VK_FORMAT_R32G32B32A32_SFLOAT,
VK_FORMAT_R32G32B32A32_UINT,
VK_FORMAT_R32G32B32A32_SINT,
VK_FORMAT_R16G16B16A16_SFLOAT,
VK_FORMAT_R16G16B16A16_UNORM,
VK_FORMAT_R16G16B16A16_UINT,
VK_FORMAT_R16G16B16A16_SNORM,
VK_FORMAT_R16G16B16A16_SINT,
VK_FORMAT_A2B10G10R10_UNORM_PACK32,
VK_FORMAT_A2B10G10R10_UINT_PACK32,
VK_FORMAT_R8G8B8A8_UNORM,
VK_FORMAT_R8G8B8A8_SRGB,
VK_FORMAT_R8G8B8A8_UINT,
VK_FORMAT_R8G8B8A8_SNORM,
VK_FORMAT_R8G8B8A8_SINT,
VK_FORMAT_B8G8R8A8_UNORM,
VK_FORMAT_B8G8R8A8_SRGB,
VK_FORMAT_R32_SFLOAT,
VK_FORMAT_R32_UINT,
VK_FORMAT_R32_SINT,
VK_FORMAT_R16_SFLOAT,
VK_FORMAT_R16_UNORM,
VK_FORMAT_R16_UINT,
VK_FORMAT_R16_SNORM,
VK_FORMAT_R16_SINT,
VK_FORMAT_R8_UNORM,
VK_FORMAT_R8_UINT,
VK_FORMAT_R8_SNORM,
VK_FORMAT_R8_SINT,
}};
bool allKmtHandlesSupported = true;
bool allNtHandlesSupported = true;
for (auto f : requiredFormats) {
allKmtHandlesSupported &= CheckFormatSharingSupport(Adapter, f, VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT);
allNtHandlesSupported &= CheckFormatSharingSupport(Adapter, f, VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT);
}
// Again, lie about at least tier 1 support
if (!allKmtHandlesSupported) {
if (!s_errorShown.exchange(true))
Logger::warn("D3D11DeviceFeatures: Some formats not supported for resource sharing");
return D3D11_SHARED_RESOURCE_TIER_1;
}
// Tier 2 requires all the above formats to be shareable
// with NT handles in order to support D3D12 interop
if (!allNtHandlesSupported)
return D3D11_SHARED_RESOURCE_TIER_1;
// Tier 3 additionally requires R11G11B10 to be
// shareable with D3D12
if (!CheckFormatSharingSupport(Adapter, VK_FORMAT_B10G11R11_UFLOAT_PACK32, VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT))
return D3D11_SHARED_RESOURCE_TIER_2;
return D3D11_SHARED_RESOURCE_TIER_3;
}
D3D11_TILED_RESOURCES_TIER D3D11DeviceFeatures::DetermineTiledResourcesTier(
D3D_FEATURE_LEVEL FeatureLevel) {
if (FeatureLevel < D3D_FEATURE_LEVEL_11_0
|| !m_features.core.features.sparseBinding
|| !m_features.core.features.sparseResidencyBuffer
|| !m_features.core.features.sparseResidencyImage2D
|| !m_features.core.features.sparseResidencyAliased
|| !m_properties.core.properties.sparseProperties.residencyStandard2DBlockShape)
return D3D11_TILED_RESOURCES_NOT_SUPPORTED;
if (FeatureLevel < D3D_FEATURE_LEVEL_11_1
|| !m_features.core.features.shaderResourceResidency
|| !m_features.core.features.shaderResourceMinLod
|| !m_features.vk12.samplerFilterMinmax
|| !m_properties.vk12.filterMinmaxSingleComponentFormats
|| !m_properties.core.properties.sparseProperties.residencyNonResidentStrict
|| m_properties.core.properties.sparseProperties.residencyAlignedMipSize)
return D3D11_TILED_RESOURCES_TIER_1;
if (!m_features.core.features.sparseResidencyImage3D
|| !m_properties.core.properties.sparseProperties.residencyStandard3DBlockShape)
return D3D11_TILED_RESOURCES_TIER_2;
return D3D11_TILED_RESOURCES_TIER_3;
}
BOOL D3D11DeviceFeatures::DetermineUavExtendedTypedLoadSupport(
const Rc<DxvkAdapter>& Adapter,
D3D_FEATURE_LEVEL FeatureLevel) {
static const std::array<VkFormat, 18> s_formats = {{
VK_FORMAT_R32_SFLOAT,
VK_FORMAT_R32_UINT,
VK_FORMAT_R32_SINT,
VK_FORMAT_R32G32B32A32_SFLOAT,
VK_FORMAT_R32G32B32A32_UINT,
VK_FORMAT_R32G32B32A32_SINT,
VK_FORMAT_R16G16B16A16_SFLOAT,
VK_FORMAT_R16G16B16A16_UINT,
VK_FORMAT_R16G16B16A16_SINT,
VK_FORMAT_R8G8B8A8_UNORM,
VK_FORMAT_R8G8B8A8_UINT,
VK_FORMAT_R8G8B8A8_SINT,
VK_FORMAT_R16_SFLOAT,
VK_FORMAT_R16_UINT,
VK_FORMAT_R16_SINT,
VK_FORMAT_R8_UNORM,
VK_FORMAT_R8_UINT,
VK_FORMAT_R8_SINT,
}};
if (FeatureLevel < D3D_FEATURE_LEVEL_11_0)
return FALSE;
for (auto f : s_formats) {
DxvkFormatFeatures features = Adapter->getFormatFeatures(f);
VkFormatFeatureFlags2 imgFeatures = features.optimal | features.linear;
if (!(imgFeatures & VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT))
return FALSE;
}
return TRUE;
}
BOOL D3D11DeviceFeatures::CheckFormatSharingSupport(
const Rc<DxvkAdapter>& Adapter,
VkFormat Format,
VkExternalMemoryHandleTypeFlagBits HandleType) {
DxvkFormatQuery query = { };
query.format = Format;
query.type = VK_IMAGE_TYPE_2D;
query.tiling = VK_IMAGE_TILING_OPTIMAL;
query.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
query.handleType = HandleType;
constexpr VkExternalMemoryFeatureFlags featureMask
= VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT
| VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT;
auto limits = Adapter->getFormatLimits(query);
return limits && (limits->externalFeatures & featureMask);
}
D3D_FEATURE_LEVEL D3D11DeviceFeatures::GetMaxFeatureLevel() const {
// Check Feature Level 11_0 features
if (!m_features.core.features.drawIndirectFirstInstance
|| !m_features.core.features.fragmentStoresAndAtomics
|| !m_features.core.features.multiDrawIndirect
|| !m_features.core.features.tessellationShader)
return D3D_FEATURE_LEVEL_10_1;
// Check Feature Level 11_1 features
if (!m_d3d11Options.OutputMergerLogicOp
|| !m_features.core.features.vertexPipelineStoresAndAtomics)
return D3D_FEATURE_LEVEL_11_0;
// Check Feature Level 12_0 features
if (m_d3d11Options2.TiledResourcesTier < D3D11_TILED_RESOURCES_TIER_2
|| !m_d3d11Options2.TypedUAVLoadAdditionalFormats)
return D3D_FEATURE_LEVEL_11_1;
// Check Feature Level 12_1 features
if (!m_d3d11Options2.ConservativeRasterizationTier
|| !m_d3d11Options2.ROVsSupported)
return D3D_FEATURE_LEVEL_12_0;
return D3D_FEATURE_LEVEL_12_1;
}
}

126
src/d3d11/d3d11_features.h Normal file
View File

@ -0,0 +1,126 @@
#pragma once
#include "d3d11_include.h"
#include "d3d11_options.h"
#include "../dxvk/dxvk_adapter.h"
#include "../dxvk/dxvk_instance.h"
namespace dxvk {
/**
* \brief Device features
*
* Stores D3D device feature structs.
*/
class D3D11DeviceFeatures {
public:
D3D11DeviceFeatures();
D3D11DeviceFeatures(
const Rc<DxvkInstance>& Instance,
const Rc<DxvkAdapter>& Adapter,
const D3D11Options& Options,
D3D_FEATURE_LEVEL FeatureLevel);
~D3D11DeviceFeatures();
/**
* \brief Retrieves feature support data
*
* \param [in] Feature D3D feature to query
* \param [in] FeatureDataSize Data size, in bytes
* \param [out] pFeatureData Data
* \returns Status of the operation
*/
HRESULT GetFeatureData(
D3D11_FEATURE Feature,
UINT FeatureDataSize,
void* pFeatureData) const;
/**
* \brief Queries tiled resources tier
* \returns Tiled resources tier
*/
D3D11_TILED_RESOURCES_TIER GetTiledResourcesTier() const {
return m_d3d11Options2.TiledResourcesTier;
}
/**
* \brief Queries conservative rasterization tier
* \returns Conservative rasterization tier
*/
D3D11_CONSERVATIVE_RASTERIZATION_TIER GetConservativeRasterizationTier() const {
return m_d3d11Options2.ConservativeRasterizationTier;
}
/**
* \brief Tests maximum supported feature level
*
* \param [in] Instance DXVK instance
* \param [in] Adapter DXVK adapter
* \returns Highest supported feature level
*/
static D3D_FEATURE_LEVEL GetMaxFeatureLevel(
const Rc<DxvkInstance>& Instance,
const Rc<DxvkAdapter>& Adapter);
private:
DxvkDeviceFeatures m_features;
DxvkDeviceInfo m_properties;
D3D11_FEATURE_DATA_ARCHITECTURE_INFO m_architectureInfo = { };
D3D11_FEATURE_DATA_D3D9_OPTIONS m_d3d9Options = { };
D3D11_FEATURE_DATA_D3D9_OPTIONS1 m_d3d9Options1 = { };
D3D11_FEATURE_DATA_D3D9_SHADOW_SUPPORT m_d3d9Shadow = { };
D3D11_FEATURE_DATA_D3D9_SIMPLE_INSTANCING_SUPPORT m_d3d9SimpleInstancing = { };
D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS m_d3d10Options = { };
D3D11_FEATURE_DATA_D3D11_OPTIONS m_d3d11Options = { };
D3D11_FEATURE_DATA_D3D11_OPTIONS1 m_d3d11Options1 = { };
D3D11_FEATURE_DATA_D3D11_OPTIONS2 m_d3d11Options2 = { };
D3D11_FEATURE_DATA_D3D11_OPTIONS3 m_d3d11Options3 = { };
D3D11_FEATURE_DATA_D3D11_OPTIONS4 m_d3d11Options4 = { };
D3D11_FEATURE_DATA_D3D11_OPTIONS5 m_d3d11Options5 = { };
D3D11_FEATURE_DATA_DOUBLES m_doubles = { };
D3D11_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT m_gpuVirtualAddress = { };
D3D11_FEATURE_DATA_MARKER_SUPPORT m_marker = { };
D3D11_FEATURE_DATA_SHADER_CACHE m_shaderCache = { };
D3D11_FEATURE_DATA_SHADER_MIN_PRECISION_SUPPORT m_shaderMinPrecision = { };
D3D11_FEATURE_DATA_THREADING m_threading = { };
template<typename T>
static HRESULT GetTypedFeatureData(UINT Size, void* pDstData, const T* pSrcData) {
if (Size != sizeof(T))
return E_INVALIDARG;
*(reinterpret_cast<T*>(pDstData)) = *pSrcData;
return S_OK;
}
D3D11_CONSERVATIVE_RASTERIZATION_TIER DetermineConservativeRasterizationTier(
D3D_FEATURE_LEVEL FeatureLevel);
D3D11_SHARED_RESOURCE_TIER DetermineSharedResourceTier(
const Rc<DxvkAdapter>& Adapter,
D3D_FEATURE_LEVEL FeatureLevel);
D3D11_TILED_RESOURCES_TIER DetermineTiledResourcesTier(
D3D_FEATURE_LEVEL FeatureLevel);
BOOL DetermineUavExtendedTypedLoadSupport(
const Rc<DxvkAdapter>& Adapter,
D3D_FEATURE_LEVEL FeatureLevel);
BOOL CheckFormatSharingSupport(
const Rc<DxvkAdapter>& Adapter,
VkFormat Format,
VkExternalMemoryHandleTypeFlagBits HandleType);
D3D_FEATURE_LEVEL GetMaxFeatureLevel() const;
};
}

105
src/d3d11/d3d11_fence.cpp Normal file
View File

@ -0,0 +1,105 @@
#include "d3d11_fence.h"
#include "d3d11_device.h"
#include "../util/util_win32_compat.h"
namespace dxvk {
D3D11Fence::D3D11Fence(
D3D11Device* pDevice,
UINT64 InitialValue,
D3D11_FENCE_FLAG Flags,
HANDLE hFence)
: D3D11DeviceChild<ID3D11Fence>(pDevice) {
DxvkFenceCreateInfo fenceInfo;
fenceInfo.initialValue = InitialValue;
m_flags = Flags;
if (Flags & D3D11_FENCE_FLAG_SHARED) {
fenceInfo.sharedType = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE_BIT;
if (hFence == nullptr)
hFence = INVALID_HANDLE_VALUE;
fenceInfo.sharedHandle = hFence;
}
if (Flags & ~D3D11_FENCE_FLAG_SHARED)
Logger::err(str::format("Fence flags 0x", std::hex, Flags, " not supported"));
m_fence = pDevice->GetDXVKDevice()->createFence(fenceInfo);
}
D3D11Fence::~D3D11Fence() {
}
HRESULT STDMETHODCALLTYPE D3D11Fence::QueryInterface(
REFIID riid,
void** ppvObject) {
if (ppvObject == nullptr)
return E_POINTER;
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11Fence)) {
*ppvObject = ref(this);
return S_OK;
}
if (logQueryInterfaceError(__uuidof(ID3D11Fence), riid)) {
Logger::warn("D3D11Fence: Unknown interface query");
Logger::warn(str::format(riid));
}
return E_NOINTERFACE;
}
HRESULT STDMETHODCALLTYPE D3D11Fence::CreateSharedHandle(
const SECURITY_ATTRIBUTES* pAttributes,
DWORD dwAccess,
LPCWSTR lpName,
HANDLE* pHandle) {
if (!(m_flags & D3D11_FENCE_FLAG_SHARED))
return E_INVALIDARG;
if (pAttributes)
Logger::warn(str::format("CreateSharedHandle: attributes ", pAttributes, " not handled"));
if (dwAccess)
Logger::warn(str::format("CreateSharedHandle: access ", dwAccess, " not handled"));
if (lpName)
Logger::warn(str::format("CreateSharedHandle: name ", dxvk::str::fromws(lpName), " not handled"));
HANDLE sharedHandle = m_fence->sharedHandle();
if (sharedHandle == INVALID_HANDLE_VALUE)
return E_INVALIDARG;
*pHandle = sharedHandle;
return S_OK;
}
HRESULT STDMETHODCALLTYPE D3D11Fence::SetEventOnCompletion(
UINT64 Value,
HANDLE hEvent) {
if (hEvent) {
m_fence->enqueueWait(Value, [hEvent] {
SetEvent(hEvent);
});
} else {
m_fence->wait(Value);
}
return S_OK;
}
UINT64 STDMETHODCALLTYPE D3D11Fence::GetCompletedValue() {
// TODO in the case of rewinds, the stored value may be higher.
// For shared fences, calling vkGetSemaphoreCounterValue here could alleviate the issue.
return m_fence->getValue();
}
}

49
src/d3d11/d3d11_fence.h Normal file
View File

@ -0,0 +1,49 @@
#pragma once
#include "../dxvk/dxvk_fence.h"
#include "../dxvk/dxvk_gpu_query.h"
#include "d3d11_device_child.h"
namespace dxvk {
class D3D11Fence : public D3D11DeviceChild<ID3D11Fence> {
public:
D3D11Fence(
D3D11Device* pDevice,
UINT64 InitialValue,
D3D11_FENCE_FLAG Flags,
HANDLE hFence);
~D3D11Fence();
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject);
HRESULT STDMETHODCALLTYPE CreateSharedHandle(
const SECURITY_ATTRIBUTES* pAttributes,
DWORD dwAccess,
LPCWSTR lpName,
HANDLE* pHandle);
HRESULT STDMETHODCALLTYPE SetEventOnCompletion(
UINT64 Value,
HANDLE hEvent);
UINT64 STDMETHODCALLTYPE GetCompletedValue();
Rc<DxvkFence> GetFence() const {
return m_fence;
}
private:
Rc<DxvkFence> m_fence;
D3D11_FENCE_FLAG m_flags;
};
}

View File

@ -3,6 +3,7 @@
#include "d3d11_gdi.h"
#include "../util/util_gdi.h"
#include "../util/util_win32_compat.h"
namespace dxvk {
@ -149,11 +150,8 @@ namespace dxvk {
HRESULT D3D11GDISurface::CreateReadbackResource() {
auto tex = GetCommonTexture(m_resource);
Com<ID3D11Device> device;
Com<ID3D11DeviceContext> context;
Com<ID3D11Device> device;
m_resource->GetDevice(&device);
device->GetImmediateContext(&context);
D3D11_RESOURCE_DIMENSION dim = { };
m_resource->GetType(&dim);

View File

@ -3,44 +3,3 @@
#include "../dxgi/dxgi_include.h"
#include <d3d11_4.h>
// This is not defined in the mingw headers
#ifndef D3D11_1_UAV_SLOT_COUNT
#define D3D11_1_UAV_SLOT_COUNT 64
#endif
#ifndef D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL
#define D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL 0xFFFFFFFF
#endif
#ifndef D3D11_KEEP_UNORDERED_ACCESS_VIEWS
#define D3D11_KEEP_UNORDERED_ACCESS_VIEWS 0xFFFFFFFF
#endif
#define D3D11_DXVK_USE_REMAINING_LAYERS 0xFFFFFFFF
#define D3D11_DXVK_USE_REMAINING_LEVELS 0xFFFFFFFF
// Most of these were copied from d3d11.h
// For some strange reason, we cannot use the structures
// directly, although others from the same header work.
// Some structures are missing from the mingw headers.
#ifndef _MSC_VER
#if !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 9
typedef enum D3D11_FORMAT_SUPPORT2 {
D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_ADD = 0x1,
D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS = 0x2,
D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE = 0x4,
D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_EXCHANGE = 0x8,
D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_SIGNED_MIN_OR_MAX = 0x10,
D3D11_FORMAT_SUPPORT2_UAV_ATOMIC_UNSIGNED_MIN_OR_MAX = 0x20,
D3D11_FORMAT_SUPPORT2_UAV_TYPED_LOAD = 0x40,
D3D11_FORMAT_SUPPORT2_UAV_TYPED_STORE = 0x80,
D3D11_FORMAT_SUPPORT2_OUTPUT_MERGER_LOGIC_OP = 0x100,
D3D11_FORMAT_SUPPORT2_TILED = 0x200,
D3D11_FORMAT_SUPPORT2_SHAREABLE = 0x400,
D3D11_FORMAT_SUPPORT2_MULTIPLANE_OVERLAY = 0x4000
} D3D11_FORMAT_SUPPORT2;
#define D3D11_RESOURCE_MISC_TILE_POOL (0x20000)
#define D3D11_RESOURCE_MISC_TILED (0x40000)
#endif // !defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 9
#endif // _MSC_VER

View File

@ -9,7 +9,7 @@ namespace dxvk {
D3D11Device* pParent)
: m_parent(pParent),
m_device(pParent->GetDXVKDevice()),
m_context(m_device->createContext()) {
m_context(m_device->createContext(DxvkContextType::Supplementary)) {
m_context->beginRecording(
m_device->createCommandList());
}
@ -30,37 +30,47 @@ namespace dxvk {
void D3D11Initializer::InitBuffer(
D3D11Buffer* pBuffer,
const D3D11_SUBRESOURCE_DATA* pInitialData) {
VkMemoryPropertyFlags memFlags = pBuffer->GetBuffer()->memFlags();
if (!(pBuffer->Desc()->MiscFlags & D3D11_RESOURCE_MISC_TILED)) {
VkMemoryPropertyFlags memFlags = pBuffer->GetBuffer()->memFlags();
(memFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
? InitHostVisibleBuffer(pBuffer, pInitialData)
: InitDeviceLocalBuffer(pBuffer, pInitialData);
(memFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
? InitHostVisibleBuffer(pBuffer, pInitialData)
: InitDeviceLocalBuffer(pBuffer, pInitialData);
}
}
void D3D11Initializer::InitTexture(
D3D11CommonTexture* pTexture,
const D3D11_SUBRESOURCE_DATA* pInitialData) {
(pTexture->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT)
? InitHostVisibleTexture(pTexture, pInitialData)
: InitDeviceLocalTexture(pTexture, pInitialData);
if (pTexture->Desc()->MiscFlags & D3D11_RESOURCE_MISC_TILED)
InitTiledTexture(pTexture);
else if (pTexture->GetMapMode() == D3D11_COMMON_TEXTURE_MAP_MODE_DIRECT)
InitHostVisibleTexture(pTexture, pInitialData);
else
InitDeviceLocalTexture(pTexture, pInitialData);
SyncKeyedMutex(pTexture->GetInterface());
}
void D3D11Initializer::InitUavCounter(
D3D11UnorderedAccessView* pUav) {
auto counterBuffer = pUav->GetCounterSlice();
auto counterView = pUav->GetCounterView();
if (!counterBuffer.defined())
if (counterView == nullptr)
return;
auto counterSlice = counterView->slice();
std::lock_guard<dxvk::mutex> lock(m_mutex);
m_transferCommands += 1;
const uint32_t zero = 0;
m_context->updateBuffer(
counterBuffer.buffer(),
0, sizeof(zero), &zero);
counterSlice.buffer(),
counterSlice.offset(),
sizeof(zero), &zero);
FlushImplicit();
}
@ -123,7 +133,7 @@ namespace dxvk {
auto desc = pTexture->Desc();
VkFormat packedFormat = m_parent->LookupPackedFormat(desc->Format, pTexture->GetFormatMode()).Format;
auto formatInfo = imageFormatInfo(packedFormat);
auto formatInfo = lookupFormatInfo(packedFormat);
if (pInitialData != nullptr && pInitialData->pSysMem != nullptr) {
// pInitialData is an array that stores an entry for
@ -253,6 +263,15 @@ namespace dxvk {
}
void D3D11Initializer::InitTiledTexture(
D3D11CommonTexture* pTexture) {
m_context->initSparseImage(pTexture->GetImage());
m_transferCommands += 1;
FlushImplicit();
}
void D3D11Initializer::FlushImplicit() {
if (m_transferCommands > MaxTransferCommands
|| m_transferMemory > MaxTransferMemory)
@ -261,10 +280,20 @@ namespace dxvk {
void D3D11Initializer::FlushInternal() {
m_context->flushCommandList();
m_context->flushCommandList(nullptr);
m_transferCommands = 0;
m_transferMemory = 0;
}
void D3D11Initializer::SyncKeyedMutex(ID3D11Resource *pResource) {
Com<IDXGIKeyedMutex> keyedMutex;
if (pResource->QueryInterface(__uuidof(IDXGIKeyedMutex), reinterpret_cast<void**>(&keyedMutex)) != S_OK)
return;
keyedMutex->AcquireSync(0, 0);
keyedMutex->ReleaseSync(0);
}
}

View File

@ -64,10 +64,15 @@ namespace dxvk {
void InitHostVisibleTexture(
D3D11CommonTexture* pTexture,
const D3D11_SUBRESOURCE_DATA* pInitialData);
void InitTiledTexture(
D3D11CommonTexture* pTexture);
void FlushImplicit();
void FlushInternal();
void SyncKeyedMutex(ID3D11Resource *pResource);
};
}

View File

@ -46,13 +46,16 @@ namespace dxvk {
return S_OK;
}
Logger::warn("D3D11InputLayout::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
if (logQueryInterfaceError(__uuidof(ID3D11InputLayout), riid)) {
Logger::warn("D3D11InputLayout::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
}
return E_NOINTERFACE;
}
void D3D11InputLayout::BindToContext(const Rc<DxvkContext>& ctx) {
void D3D11InputLayout::BindToContext(DxvkContext* ctx) {
ctx->setInputLayout(
m_attributes.size(),
m_attributes.data(),

View File

@ -25,8 +25,7 @@ namespace dxvk {
REFIID riid,
void** ppvObject) final;
void BindToContext(
const Rc<DxvkContext>& ctx);
void BindToContext(DxvkContext* ctx);
bool Compare(
const D3D11InputLayout* pOther) const;

View File

@ -28,6 +28,26 @@ enum D3D11_VK_BARRIER_CONTROL : uint32_t {
};
/**
* \brief Extended shader interface
*/
MIDL_INTERFACE("bb8a4fb9-3935-4762-b44b-35189a26414a")
ID3D11VkExtShader : public IUnknown {
/**
* \brief Retrieves SPIR-V code from a shader object
*
* \param [in,out] pCodeSize Shader code size, in bytes. If
* \ref pCode is \c nullptr, this will return the total
* code size, otherwise the number of bytes written.
* \param [out] pCode SPIR-V shader code
* \returns \c S_OK, or \c S_FALSE if the buffer was too small
*/
virtual HRESULT STDMETHODCALLTYPE GetSpirvCode(
SIZE_T* pCodeSize,
void* pCode) = 0;
};
/**
* \brief Extended D3D11 device
*
@ -163,12 +183,8 @@ ID3D11VkExtContext1 : public ID3D11VkExtContext {
};
#ifdef _MSC_VER
struct __declspec(uuid("8a6e3c42-f74c-45b7-8265-a231b677ca17")) ID3D11VkExtDevice;
struct __declspec(uuid("cfcf64ef-9586-46d0-bca4-97cf2ca61b06")) ID3D11VkExtDevice1;
struct __declspec(uuid("fd0bca13-5cb6-4c3a-987e-4750de2ca791")) ID3D11VkExtContext;
struct __declspec(uuid("874b09b2-ae0b-41d8-8476-5f3b7a0e879d")) ID3D11VkExtContext1;
#else
#ifndef _MSC_VER
__CRT_UUID_DECL(ID3D11VkExtShader, 0xbb8a4fb9,0x3935,0x4762,0xb4,0x4b,0x35,0x18,0x9a,0x26,0x41,0x4a);
__CRT_UUID_DECL(ID3D11VkExtDevice, 0x8a6e3c42,0xf74c,0x45b7,0x82,0x65,0xa2,0x31,0xb6,0x77,0xca,0x17);
__CRT_UUID_DECL(ID3D11VkExtDevice1, 0xcfcf64ef,0x9586,0x46d0,0xbc,0xa4,0x97,0xcf,0x2c,0xa6,0x1b,0x06);
__CRT_UUID_DECL(ID3D11VkExtContext, 0xfd0bca13,0x5cb6,0x4c3a,0x98,0x7e,0x47,0x50,0xde,0x2c,0xa7,0x91);

View File

@ -75,21 +75,15 @@ namespace dxvk {
const VkImageSubresourceRange* pSubresources,
VkImageLayout OldLayout,
VkImageLayout NewLayout) {
Com<ID3D11DeviceContext> deviceContext = nullptr;
m_device->GetImmediateContext(&deviceContext);
auto immediateContext = static_cast<D3D11ImmediateContext*>(deviceContext.ptr());
auto immediateContext = m_device->GetContext();
immediateContext->TransitionSurfaceLayout(
pSurface, pSubresources, OldLayout, NewLayout);
}
void STDMETHODCALLTYPE D3D11VkInterop::FlushRenderingCommands() {
Com<ID3D11DeviceContext> deviceContext = nullptr;
m_device->GetImmediateContext(&deviceContext);
auto immediateContext = static_cast<D3D11ImmediateContext*>(deviceContext.ptr());
auto immediateContext = m_device->GetContext();
immediateContext->Flush();
immediateContext->SynchronizeCsThread(DxvkCsThread::SynchronizeAll);
}

View File

@ -15,7 +15,7 @@ namespace dxvk {
extern "C" {
using namespace dxvk;
DLLEXPORT HRESULT __stdcall D3D11CoreCreateDevice(
HRESULT D3D11InternalCreateDevice(
IDXGIFactory* pFactory,
IDXGIAdapter* pAdapter,
UINT Flags,
@ -34,11 +34,11 @@ extern "C" {
dxvkAdapter = dxgiVkAdapter->GetDXVKAdapter();
dxvkInstance = dxgiVkAdapter->GetDXVKInstance();
} else {
Logger::warn("D3D11CoreCreateDevice: Adapter is not a DXVK adapter");
Logger::warn("D3D11InternalCreateDevice: Adapter is not a DXVK adapter");
DXGI_ADAPTER_DESC desc;
pAdapter->GetDesc(&desc);
dxvkInstance = new DxvkInstance();
dxvkInstance = new DxvkInstance(0);
dxvkAdapter = dxvkInstance->findAdapterByLuid(&desc.AdapterLuid);
if (dxvkAdapter == nullptr)
@ -59,40 +59,49 @@ extern "C" {
D3D_FEATURE_LEVEL_9_2, D3D_FEATURE_LEVEL_9_1,
};
if (pFeatureLevels == nullptr || FeatureLevels == 0) {
if (!pFeatureLevels || !FeatureLevels) {
pFeatureLevels = defaultFeatureLevels.data();
FeatureLevels = defaultFeatureLevels.size();
}
// Find the highest feature level supported by the device.
// This works because the feature level array is ordered.
UINT flId;
D3D_FEATURE_LEVEL maxFeatureLevel = D3D11Device::GetMaxFeatureLevel(dxvkInstance, dxvkAdapter);
D3D_FEATURE_LEVEL minFeatureLevel = D3D_FEATURE_LEVEL();
D3D_FEATURE_LEVEL devFeatureLevel = D3D_FEATURE_LEVEL();
for (flId = 0 ; flId < FeatureLevels; flId++) {
Logger::info(str::format("D3D11CoreCreateDevice: Probing ", pFeatureLevels[flId]));
if (D3D11Device::CheckFeatureLevelSupport(dxvkInstance, dxvkAdapter, pFeatureLevels[flId]))
Logger::info(str::format("D3D11InternalCreateDevice: Maximum supported feature level: ", maxFeatureLevel));
for (uint32_t flId = 0 ; flId < FeatureLevels; flId++) {
minFeatureLevel = pFeatureLevels[flId];
if (minFeatureLevel <= maxFeatureLevel) {
devFeatureLevel = minFeatureLevel;
break;
}
}
if (flId == FeatureLevels) {
Logger::err("D3D11CoreCreateDevice: Requested feature level not supported");
if (!devFeatureLevel) {
Logger::err(str::format("D3D11InternalCreateDevice: Minimum required feature level ", minFeatureLevel, " not supported"));
return E_INVALIDARG;
}
// Try to create the device with the given parameters.
const D3D_FEATURE_LEVEL fl = pFeatureLevels[flId];
try {
Logger::info(str::format("D3D11CoreCreateDevice: Using feature level ", fl));
Logger::info(str::format("D3D11InternalCreateDevice: Using feature level ", devFeatureLevel));
DxvkDeviceFeatures deviceFeatures = D3D11Device::GetDeviceFeatures(dxvkAdapter);
Rc<DxvkDevice> dxvkDevice = dxvkAdapter->createDevice(dxvkInstance, deviceFeatures);
Com<D3D11DXGIDevice> device = new D3D11DXGIDevice(
pAdapter, dxvkInstance, dxvkAdapter, fl, Flags);
pAdapter, nullptr, nullptr,
dxvkInstance, dxvkAdapter, dxvkDevice,
devFeatureLevel, Flags);
return device->QueryInterface(
__uuidof(ID3D11Device),
reinterpret_cast<void**>(ppDevice));
} catch (const DxvkError& e) {
Logger::err("D3D11CoreCreateDevice: Failed to create D3D11 device");
Logger::err("D3D11InternalCreateDevice: Failed to create D3D11 device");
return E_FAIL;
}
}
@ -164,7 +173,7 @@ extern "C" {
}
// Create the actual device
hr = D3D11CoreCreateDevice(
hr = D3D11InternalCreateDevice(
dxgiFactory.ptr(), dxgiAdapter.ptr(),
Flags, pFeatureLevels, FeatureLevels,
&device);
@ -203,6 +212,25 @@ extern "C" {
}
DLLEXPORT HRESULT __stdcall D3D11CoreCreateDevice(
IDXGIFactory* pFactory,
IDXGIAdapter* pAdapter,
D3D_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
const D3D_FEATURE_LEVEL* pFeatureLevels,
UINT FeatureLevels,
UINT SDKVersion,
ID3D11Device** ppDevice,
D3D_FEATURE_LEVEL* pFeatureLevel) {
return D3D11InternalCreateDeviceAndSwapChain(
pAdapter, DriverType, Software, Flags,
pFeatureLevels, FeatureLevels, SDKVersion,
nullptr, nullptr,
ppDevice, pFeatureLevel, nullptr);
}
DLLEXPORT HRESULT __stdcall D3D11CreateDevice(
IDXGIAdapter* pAdapter,
D3D_DRIVER_TYPE DriverType,
@ -254,12 +282,169 @@ extern "C" {
ID3D11Device** ppDevice,
ID3D11DeviceContext** ppImmediateContext,
D3D_FEATURE_LEVEL* pChosenFeatureLevel) {
static bool s_errorShown = false;
InitReturnPtr(ppDevice);
InitReturnPtr(ppImmediateContext);
if (!std::exchange(s_errorShown, true))
Logger::err("D3D11On12CreateDevice: Not implemented");
if (pChosenFeatureLevel)
*pChosenFeatureLevel = D3D_FEATURE_LEVEL(0);
return E_NOTIMPL;
if (!pDevice)
return E_INVALIDARG;
// Figure out D3D12 objects
Com<ID3D12Device> d3d12Device;
Com<ID3D12CommandQueue> d3d12Queue;
if (FAILED(pDevice->QueryInterface(__uuidof(ID3D12Device), reinterpret_cast<void**>(&d3d12Device)))) {
Logger::err("D3D11On12CreateDevice: Device is not a valid D3D12 device");
return E_INVALIDARG;
}
if (NodeMask & (NodeMask - 1)) {
Logger::err("D3D11On12CreateDevice: Invalid node mask");
return E_INVALIDARG;
}
if (!NumQueues || !ppCommandQueues || !ppCommandQueues[0]) {
Logger::err("D3D11On12CreateDevice: No command queue specified");
return E_INVALIDARG;
}
if (NumQueues > 1) {
// Not sure what to do with more than one graphics queue
Logger::warn("D3D11On12CreateDevice: Only one queue supported");
}
if (FAILED(ppCommandQueues[0]->QueryInterface(__uuidof(ID3D12CommandQueue), reinterpret_cast<void**>(&d3d12Queue)))) {
Logger::err("D3D11On12CreateDevice: Queue is not a valid D3D12 command queue");
return E_INVALIDARG;
}
// Determine feature level for the D3D11 device
std::array<D3D_FEATURE_LEVEL, 4> defaultFeatureLevels = {{
D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_12_0, D3D_FEATURE_LEVEL_12_1,
}};
D3D12_FEATURE_DATA_FEATURE_LEVELS featureLevel = { };
if (!FeatureLevels || !pFeatureLevels) {
featureLevel.NumFeatureLevels = defaultFeatureLevels.size();
featureLevel.pFeatureLevelsRequested = defaultFeatureLevels.data();
} else {
featureLevel.NumFeatureLevels = FeatureLevels;
featureLevel.pFeatureLevelsRequested = pFeatureLevels;
}
HRESULT hr = d3d12Device->CheckFeatureSupport(D3D12_FEATURE_FEATURE_LEVELS, &featureLevel, sizeof(featureLevel));
if (FAILED(hr) || !featureLevel.MaxSupportedFeatureLevel) {
Logger::err(str::format("D3D11On12CreateDevice: Minimum required feature level not supported"));
return hr;
}
Logger::info(str::format("D3D11On12CreateDevice: Chosen feature level: ", featureLevel.MaxSupportedFeatureLevel));
Com<ID3D12DXVKInteropDevice> interopDevice;
if (FAILED(d3d12Device->QueryInterface(__uuidof(ID3D12DXVKInteropDevice), reinterpret_cast<void**>(&interopDevice)))) {
Logger::err("D3D11On12CreateDevice: Device not a vkd3d-proton device.");
return E_INVALIDARG;
}
Com<IDXGIAdapter> dxgiAdapter;
if (FAILED(interopDevice->GetDXGIAdapter(IID_PPV_ARGS(&dxgiAdapter)))) {
Logger::err("D3D11On12CreateDevice: Failed to query DXGI adapter.");
return E_INVALIDARG;
}
try {
// Initialize DXVK instance
DxvkInstanceImportInfo instanceInfo = { };
DxvkDeviceImportInfo deviceInfo = { };
VkPhysicalDevice vulkanAdapter = VK_NULL_HANDLE;
interopDevice->GetVulkanHandles(&instanceInfo.instance, &vulkanAdapter, &deviceInfo.device);
uint32_t instanceExtensionCount = 0;
interopDevice->GetInstanceExtensions(&instanceExtensionCount, nullptr);
std::vector<const char*> instanceExtensions(instanceExtensionCount);
interopDevice->GetInstanceExtensions(&instanceExtensionCount, instanceExtensions.data());
instanceInfo.extensionCount = instanceExtensions.size();
instanceInfo.extensionNames = instanceExtensions.data();
Rc<DxvkInstance> dxvkInstance = new DxvkInstance(instanceInfo, 0);
// Find adapter by physical device handle
Rc<DxvkAdapter> dxvkAdapter;
for (uint32_t i = 0; i < dxvkInstance->adapterCount(); i++) {
Rc<DxvkAdapter> curr = dxvkInstance->enumAdapters(i);
if (curr->handle() == vulkanAdapter)
dxvkAdapter = std::move(curr);
}
if (dxvkAdapter == nullptr) {
Logger::err("D3D11On12CreateDevice: No matching adapter found");
return E_INVALIDARG;
}
interopDevice->GetVulkanQueueInfo(d3d12Queue.ptr(), &deviceInfo.queue, &deviceInfo.queueFamily);
interopDevice->GetDeviceFeatures(&deviceInfo.features);
uint32_t deviceExtensionCount = 0;
interopDevice->GetDeviceExtensions(&deviceExtensionCount, nullptr);
std::vector<const char*> deviceExtensions(deviceExtensionCount);
interopDevice->GetDeviceExtensions(&deviceExtensionCount, deviceExtensions.data());
deviceInfo.extensionCount = deviceExtensions.size();
deviceInfo.extensionNames = deviceExtensions.data();
deviceInfo.queueCallback = [
cDevice = interopDevice,
cQueue = d3d12Queue
] (bool doLock) {
HRESULT hr = doLock
? cDevice->LockCommandQueue(cQueue.ptr())
: cDevice->UnlockCommandQueue(cQueue.ptr());
if (FAILED(hr))
Logger::err(str::format("Failed to lock vkd3d-proton device queue: ", hr));
};
Rc<DxvkDevice> dxvkDevice = dxvkAdapter->importDevice(dxvkInstance, deviceInfo);
// Create and return the actual D3D11 device
Com<D3D11DXGIDevice> device = new D3D11DXGIDevice(
dxgiAdapter.ptr(), d3d12Device.ptr(), d3d12Queue.ptr(),
dxvkInstance, dxvkAdapter, dxvkDevice,
featureLevel.MaxSupportedFeatureLevel, Flags);
Com<ID3D11Device> d3d11Device;
device->QueryInterface(__uuidof(ID3D11Device), reinterpret_cast<void**>(&d3d11Device));
if (ppDevice)
*ppDevice = d3d11Device.ref();
if (ppImmediateContext)
d3d11Device->GetImmediateContext(ppImmediateContext);
if (pChosenFeatureLevel)
*pChosenFeatureLevel = d3d11Device->GetFeatureLevel();
if (!ppDevice && !ppImmediateContext)
return S_FALSE;
return S_OK;
} catch (const DxvkError& e) {
Logger::err("D3D11On12CreateDevice: Failed to create D3D11 device");
return E_FAIL;
}
}
}

150
src/d3d11/d3d11_on_12.cpp Normal file
View File

@ -0,0 +1,150 @@
#include "d3d11_context_imm.h"
#include "d3d11_device.h"
#include "d3d11_on_12.h"
namespace dxvk {
D3D11on12Device::D3D11on12Device(
D3D11DXGIDevice* pContainer,
D3D11Device* pDevice,
ID3D12Device* pD3D12Device,
ID3D12CommandQueue* pD3D12Queue)
: m_container (pContainer),
m_device (pDevice),
m_d3d12Device (pD3D12Device),
m_d3d12Queue (pD3D12Queue) {
}
D3D11on12Device::~D3D11on12Device() {
}
ULONG STDMETHODCALLTYPE D3D11on12Device::AddRef() {
return m_container->AddRef();
}
ULONG STDMETHODCALLTYPE D3D11on12Device::Release() {
return m_container->Release();
}
HRESULT STDMETHODCALLTYPE D3D11on12Device::QueryInterface(
REFIID riid,
void** ppvObject) {
return m_container->QueryInterface(riid, ppvObject);
}
HRESULT STDMETHODCALLTYPE D3D11on12Device::CreateWrappedResource(
IUnknown* pResource12,
const D3D11_RESOURCE_FLAGS* pResourceFlags,
D3D12_RESOURCE_STATES InputState,
D3D12_RESOURCE_STATES OutputState,
REFIID riid,
void** ppResource11) {
Com<ID3D12DXVKInteropDevice> interopDevice;
m_d3d12Device->QueryInterface(__uuidof(ID3D12DXVKInteropDevice), reinterpret_cast<void**>(&interopDevice));
D3D11_ON_12_RESOURCE_INFO info = { };
info.InputState = InputState;
info.OutputState = OutputState;
info.IsWrappedResource = TRUE;
// 11on12 technically allows importing D3D12 heaps as tile pools,
// but we don't support importing sparse resources at this time.
if (FAILED(pResource12->QueryInterface(__uuidof(ID3D12Resource), reinterpret_cast<void**>(&info.Resource)))) {
Logger::err("D3D11on12Device::CreateWrappedResource: Resource not a valid D3D12 resource");
return E_INVALIDARG;
}
// Query Vulkan resource handle and buffer offset as necessary
if (FAILED(interopDevice->GetVulkanResourceInfo(info.Resource.ptr(), &info.VulkanHandle, &info.VulkanOffset))) {
Logger::err("D3D11on12Device::CreateWrappedResource: Failed to retrieve Vulkan resource info");
return E_INVALIDARG;
}
Com<ID3D11Resource> resource;
D3D12_RESOURCE_DESC desc = info.Resource->GetDesc();
if (desc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) {
D3D11_BUFFER_DESC bufferDesc;
if (FAILED(D3D11Buffer::GetDescFromD3D12(info.Resource.ptr(), pResourceFlags, &bufferDesc)))
return E_INVALIDARG;
resource = new D3D11Buffer(m_device, &bufferDesc, &info);
} else {
D3D11_COMMON_TEXTURE_DESC textureDesc;
if (FAILED(D3D11CommonTexture::GetDescFromD3D12(info.Resource.ptr(), pResourceFlags, &textureDesc)))
return E_INVALIDARG;
switch (desc.Dimension) {
case D3D12_RESOURCE_DIMENSION_TEXTURE1D:
resource = new D3D11Texture1D(m_device, &textureDesc, &info);
break;
case D3D12_RESOURCE_DIMENSION_TEXTURE2D:
resource = new D3D11Texture2D(m_device, &textureDesc, &info, nullptr);
break;
case D3D12_RESOURCE_DIMENSION_TEXTURE3D:
resource = new D3D11Texture3D(m_device, &textureDesc, &info);
break;
default:
Logger::err("D3D11on12Device::CreateWrappedResource: Unhandled resource dimension");
return E_INVALIDARG;
}
}
return resource->QueryInterface(riid, ppResource11);
}
void STDMETHODCALLTYPE D3D11on12Device::ReleaseWrappedResources(
ID3D11Resource* const* ppResources,
UINT ResourceCount) {
Com<ID3D12DXVKInteropDevice> interopDevice;
m_d3d12Device->QueryInterface(__uuidof(ID3D12DXVKInteropDevice), reinterpret_cast<void**>(&interopDevice));
for (uint32_t i = 0; i < ResourceCount; i++) {
D3D11_ON_12_RESOURCE_INFO info;
if (FAILED(GetResource11on12Info(ppResources[i], &info)) || !info.IsWrappedResource) {
Logger::warn("D3D11on12Device::ReleaseWrappedResources: Resource not a wrapped resource, skipping");
continue;
}
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
interopDevice->GetVulkanImageLayout(info.Resource.ptr(), info.OutputState, &layout);
m_device->GetContext()->Release11on12Resource(ppResources[i], layout);
}
}
void STDMETHODCALLTYPE D3D11on12Device::AcquireWrappedResources(
ID3D11Resource* const* ppResources,
UINT ResourceCount) {
Com<ID3D12DXVKInteropDevice> interopDevice;
m_d3d12Device->QueryInterface(__uuidof(ID3D12DXVKInteropDevice), reinterpret_cast<void**>(&interopDevice));
for (uint32_t i = 0; i < ResourceCount; i++) {
D3D11_ON_12_RESOURCE_INFO info;
if (FAILED(GetResource11on12Info(ppResources[i], &info)) || !info.IsWrappedResource) {
Logger::warn("D3D11on12Device::AcquireWrappedResources: Resource not a wrapped resource, skipping");
continue;
}
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
interopDevice->GetVulkanImageLayout(info.Resource.ptr(), info.InputState, &layout);
m_device->GetContext()->Acquire11on12Resource(ppResources[i], layout);
}
}
}

75
src/d3d11/d3d11_on_12.h Normal file
View File

@ -0,0 +1,75 @@
#pragma once
#include "d3d11_on_12_interfaces.h"
#include "../util/log/log.h"
namespace dxvk {
class D3D11Device;
class D3D11DXGIDevice;
/**
* \brief Resource info for 11on12 resources
*/
struct D3D11_ON_12_RESOURCE_INFO {
Com<ID3D12Resource> Resource;
UINT64 VulkanHandle = 0;
UINT64 VulkanOffset = 0;
BOOL IsWrappedResource = FALSE;
D3D12_RESOURCE_STATES InputState = D3D12_RESOURCE_STATE_COMMON;
D3D12_RESOURCE_STATES OutputState = D3D12_RESOURCE_STATE_COMMON;
};
class D3D11on12Device : public ID3D11On12Device {
public:
D3D11on12Device(
D3D11DXGIDevice* pContainer,
D3D11Device* pDevice,
ID3D12Device* pD3D12Device,
ID3D12CommandQueue* pD3D12Queue);
~D3D11on12Device();
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject);
HRESULT STDMETHODCALLTYPE CreateWrappedResource(
IUnknown* pResource12,
const D3D11_RESOURCE_FLAGS* pResourceFlags,
D3D12_RESOURCE_STATES InputState,
D3D12_RESOURCE_STATES OutputState,
REFIID riid,
void** ppResource11);
void STDMETHODCALLTYPE ReleaseWrappedResources(
ID3D11Resource* const* ppResources,
UINT ResourceCount);
void STDMETHODCALLTYPE AcquireWrappedResources(
ID3D11Resource* const* ppResources,
UINT ResourceCount);
bool Is11on12Device() const {
return m_d3d12Device != nullptr;
}
private:
D3D11DXGIDevice* m_container;
D3D11Device* m_device;
Com<ID3D12Device> m_d3d12Device;
Com<ID3D12CommandQueue> m_d3d12Queue;
};
}

View File

@ -0,0 +1,54 @@
#pragma once
#include "../vulkan/vulkan_loader.h"
#include <d3d11on12.h>
MIDL_INTERFACE("39da4e09-bd1c-4198-9fae-86bbe3be41fd")
ID3D12DXVKInteropDevice : public IUnknown {
virtual HRESULT STDMETHODCALLTYPE GetDXGIAdapter(
REFIID iid,
void** ppvObject) = 0;
virtual HRESULT STDMETHODCALLTYPE GetInstanceExtensions(
UINT* pExtensionCount,
const char** ppExtensions) = 0;
virtual HRESULT STDMETHODCALLTYPE GetDeviceExtensions(
UINT* pExtensionCount,
const char** ppExtensions) = 0;
virtual HRESULT STDMETHODCALLTYPE GetDeviceFeatures(
const VkPhysicalDeviceFeatures2** ppFeatures) = 0;
virtual HRESULT STDMETHODCALLTYPE GetVulkanHandles(
VkInstance* pVkInstance,
VkPhysicalDevice* pVkPhysicalDevice,
VkDevice* pVkDevice) = 0;
virtual HRESULT STDMETHODCALLTYPE GetVulkanQueueInfo(
ID3D12CommandQueue* pCommandQueue,
VkQueue* pVkQueue,
UINT32* pVkQueueFamily) = 0;
virtual void STDMETHODCALLTYPE GetVulkanImageLayout(
ID3D12Resource* pResource,
D3D12_RESOURCE_STATES State,
VkImageLayout* pVkLayout) = 0;
virtual HRESULT STDMETHODCALLTYPE GetVulkanResourceInfo(
ID3D12Resource* pResource,
UINT64* pVkHandle,
UINT64* pBufferOffset) = 0;
virtual HRESULT STDMETHODCALLTYPE LockCommandQueue(
ID3D12CommandQueue* pCommandQueue) = 0;
virtual HRESULT STDMETHODCALLTYPE UnlockCommandQueue(
ID3D12CommandQueue* pCommandQueue) = 0;
};
#ifndef _MSC_VER
__CRT_UUID_DECL(ID3D12DXVKInteropDevice, 0x39da4e09, 0xbd1c, 0x4198, 0x9f,0xae, 0x86,0xbb,0xe3,0xbe,0x41,0xfd)
#endif

View File

@ -1,29 +1,41 @@
#include <unordered_map>
#include "../util/util_math.h"
#include "d3d11_options.h"
namespace dxvk {
D3D11Options::D3D11Options(const Config& config, const Rc<DxvkDevice>& device) {
const DxvkDeviceInfo& devInfo = device->properties();
static bool IsAPITracingDXGI() {
#ifdef _WIN32
return !!::GetModuleHandle("dxgitrace.dll");
#else
return false;
#endif
}
D3D11Options::D3D11Options(const Config& config) {
this->dcSingleUseMode = config.getOption<bool>("d3d11.dcSingleUseMode", true);
this->enableRtOutputNanFixup = config.getOption<bool>("d3d11.enableRtOutputNanFixup", false);
this->zeroInitWorkgroupMemory = config.getOption<bool>("d3d11.zeroInitWorkgroupMemory", false);
this->forceTgsmBarriers = config.getOption<bool>("d3d11.forceTgsmBarriers", false);
this->forceVolatileTgsmAccess = config.getOption<bool>("d3d11.forceVolatileTgsmAccess", false);
this->relaxedBarriers = config.getOption<bool>("d3d11.relaxedBarriers", false);
this->ignoreGraphicsBarriers = config.getOption<bool>("d3d11.ignoreGraphicsBarriers", false);
this->maxTessFactor = config.getOption<int32_t>("d3d11.maxTessFactor", 0);
this->samplerAnisotropy = config.getOption<int32_t>("d3d11.samplerAnisotropy", -1);
this->samplerLodBias = config.getOption<float>("d3d11.samplerLodBias", 0.0f);
this->clampNegativeLodBias = config.getOption<bool>("d3d11.clampNegativeLodBias", false);
this->invariantPosition = config.getOption<bool>("d3d11.invariantPosition", true);
this->floatControls = config.getOption<bool>("d3d11.floatControls", true);
this->forceSampleRateShading = config.getOption<bool>("d3d11.forceSampleRateShading", false);
this->disableMsaa = config.getOption<bool>("d3d11.disableMsaa", false);
this->enableContextLock = config.getOption<bool>("d3d11.enableContextLock", false);
this->deferSurfaceCreation = config.getOption<bool>("dxgi.deferSurfaceCreation", false);
this->numBackBuffers = config.getOption<int32_t>("dxgi.numBackBuffers", 0);
this->maxFrameLatency = config.getOption<int32_t>("dxgi.maxFrameLatency", 0);
this->maxFrameRate = config.getOption<int32_t>("dxgi.maxFrameRate", 0);
this->syncInterval = config.getOption<int32_t>("dxgi.syncInterval", -1);
this->tearFree = config.getOption<Tristate>("dxgi.tearFree", Tristate::Auto);
this->exposeDriverCommandLists = config.getOption<bool>("d3d11.exposeDriverCommandLists", true);
this->longMad = config.getOption<bool>("d3d11.longMad", false);
// Clamp LOD bias so that people don't abuse this in unintended ways
this->samplerLodBias = dxvk::fclamp(this->samplerLodBias, -2.0f, 1.0f);
int32_t maxImplicitDiscardSize = config.getOption<int32_t>("d3d11.maxImplicitDiscardSize", 256);
this->maxImplicitDiscardSize = maxImplicitDiscardSize >= 0
@ -35,12 +47,9 @@ namespace dxvk {
? VkDeviceSize(maxDynamicImageBufferSize) << 10
: VkDeviceSize(~0ull);
this->constantBufferRangeCheck = config.getOption<bool>("d3d11.constantBufferRangeCheck", false)
&& DxvkGpuVendor(devInfo.core.properties.vendorID) != DxvkGpuVendor::Amd;
auto cachedDynamicResources = config.getOption<std::string>("d3d11.cachedDynamicResources", std::string());
if (::GetModuleHandle("dxgitrace.dll")) {
if (IsAPITracingDXGI()) {
// apitrace reads back all mapped resources on the CPU, so
// allocating everything in cached memory is necessary to
// achieve acceptable performance
@ -59,6 +68,9 @@ namespace dxvk {
}
}
}
// Shader dump path is only available via an environment variable
this->shaderDumpPath = env::getEnvVar("DXVK_SHADER_DUMP_PATH");
}
}

Some files were not shown because too many files have changed in this diff Show More