Commit Graph

900 Commits

Author SHA1 Message Date
Philip Rebohle 7ba7178d14
[d3d11] Implement ID3D11Device2
Adds some extra validation to resource creation so that
apps cannot accidentally create tiled resources.
2019-09-16 12:42:14 +02:00
Philip Rebohle c1a7243811
[d3d11] Implement ID3D11DeviceContext2
We don't support tiled resources nor markers for now.
Marker support could be added through debug layers.
2019-09-16 12:42:14 +02:00
Philip Rebohle 6e28ab956d
[d3d11] Implement D3D11.2 feature queries 2019-09-16 12:42:14 +02:00
Philip Rebohle d7476f3fb8
[d3d11] Include D3D11.2 headers 2019-09-16 12:42:14 +02:00
Philip Rebohle f2d461ab5b
[d3d11] Prevent log spam from repeated Get/SetResourceMinLOD calls 2019-09-16 12:41:44 +02:00
Philip Rebohle 3e17ccfaaa
[d3d11] Implement missing D3D11_FEATURE_D3D9_OPTIONS feature query 2019-09-16 02:21:46 +02:00
Philip Rebohle c852b6de34
[d3d11] Optimize viewport updates if there is only one single viewport 2019-09-13 14:38:51 +02:00
Philip Rebohle 160b684d5a
[d3d11] Add range check for scissors and make failing it unlikely 2019-09-13 11:49:00 +02:00
Philip Rebohle b8888ffe6a
[d3d11] Don't create linearly tiled compressed images
Quantum Break uses this for texture uploads, which causes unnecessary
GPU synchronization and queue submissions when doing texture uploads.
2019-09-07 20:16:16 +02:00
Philip Rebohle b0552751ad
[d3d11] Fix incorrect AddRef -> Release
Spotted by @jp7677
2019-08-29 21:24:47 +02:00
Philip Rebohle 30d19cd0f2
[d3d11] Rename some hazard tracking methods for clarity 2019-08-29 19:10:53 +02:00
Philip Rebohle 6be124e2cd
[d3d11] Check for conflicts withing RTV and UAV lists upon binding them 2019-08-29 19:10:53 +02:00
Philip Rebohle e07ef1ec40
[d3d11] Resolve pipeline hazards when binding render targets 2019-08-29 19:10:53 +02:00
Philip Rebohle a36f056572
[d3d11] Resolve pipeline hazards when binding compute shader UAVs 2019-08-29 19:10:53 +02:00
Philip Rebohle c8c781c88b
[d3d11] Add check whether a viewed resource has a given bind flag 2019-08-29 19:10:50 +02:00
Philip Rebohle afc8e4c29d
[d3d11] Filter redundant OMSetRenderTargets calls
Since rebinding render targets is a rather expensive
operation, we should avoid doing so whenever possible.

Affects Resident Evil 2 and Devil May Cry 5.
2019-08-26 23:59:08 +02:00
Philip Rebohle 4789790087
[d3d11] Remove outdated comment
We actually handle this properly now.
2019-08-26 23:43:47 +02:00
Philip Rebohle 5756e5c921
[d3d11] Check for shader resource view hazards
Fixes incorrect behaviour in games that try to use a currently bound
UAV or render target as a shader resource at the same time.

Fixes visual artifacts in Shining Resonance Refrain on AMD hardware.
2019-08-26 23:43:47 +02:00
Philip Rebohle 137589d755
[d3d11] Add state to track potentially hazardous bound SRVs 2019-08-26 23:29:01 +02:00
Philip Rebohle 4064dd3737
[d3d11] Add bound compute shader UAV mask
Will be used for efficient hazard tracking.
2019-08-26 23:29:01 +02:00
Philip Rebohle 8208cedfa9
[d3d11] Add common view info struct to all view types
Will be used for hazard detection.
2019-08-26 23:29:01 +02:00
Philip Rebohle 5ae5053a2a
[d3d11] Remove templated SetUnorderedAccessViews
Not needed because the CS and OM paths are separate anyway.
2019-08-26 23:29:01 +02:00
Philip Rebohle 08e3500beb
[d3d11] Don't use .at() 2019-08-26 23:29:01 +02:00
Philip Rebohle 4cce07ccd9
[d3d11] Update resources mapped on deferred contexts in Map()
Apparently it is legal to use mapped buffers on deferred contexts
in D3D11, so we have to execute our update code immediately.

Fixes #1160.
2019-08-10 11:11:44 +02:00
Philip Rebohle bd40b05720
[d3d11] Recreate swap chain immediately after synchronous present fails
Fully restores pre-1.3 behaviour in case async present is disabled.
Apparently this is necessary to avoid hangs on Nvidia for some reason.
2019-08-06 09:11:04 +02:00
Philip Rebohle bc0537df37 [d3d11] Remove d3d11.asyncPresent option 2019-08-04 21:49:55 +02:00
Philip Rebohle 6b2f4f93cc [d3d11] Fix incorrect tracking of mapped image subresources
When returnig DXGI_ERROR_WAS_STILL_DRAWING, we should not mark
the subresource as mapped, and instead ignore subsequent calls
to Unmap.
2019-08-03 19:11:19 +02:00
Philip Rebohle 140a2c1017 Revert "[d3d11] Return error when mapping an already mapped image"
This reverts commit 1cc531eaf8.

Even though an FFXIV apitrace clearly indicates that mapping an
already mapped subresource returns E_OUTOFMEMORY in that game,
this doesn't always seem to be correct behaviour.

Fixes #1148, #1149.
2019-08-03 19:08:22 +02:00
Philip Rebohle 00cf2a20a3
[d3d11] Don't allow the creation of buffers with a size of zero 2019-07-21 20:47:42 +02:00
Philip Rebohle 92d6f26130
[d3d11] Always enable depth-stencil attachment usage for depth-stencil images
Allows us to use framebuffer copies even if the game itself does not
intend to render to the image.

Improves performance in Final Fantasy XIV on RADV.
2019-07-18 17:26:02 +02:00
Philip Rebohle f16ba4794b
[d3d11] Use unlikely() for some query code
This is a somewhat hot path in some games, so why not.
2019-07-17 20:35:00 +02:00
Philip Rebohle c4b56b9d8d
[d3d11] Use private temporary references for queries
Like the previous commit, just with queries.
2019-07-17 20:16:19 +02:00
Philip Rebohle 7225674088
[d3d11] Use private temporary references for state objects
We really shouldn't be altering the application-visible ref
count when sending these objects to the CS thread.
2019-07-17 20:01:57 +02:00
Philip Rebohle af8e1a3d47
[d3d11] Simplify ApplyPrimitiveTopology code 2019-07-17 15:54:59 +02:00
Philip Rebohle 3f30fbd098
[d3d11] Simplify BindIndexBuffer code 2019-07-17 14:41:00 +02:00
Philip Rebohle b6c395c013
[dxvk] Don't track command count in CS chunks
We weren't using this at all, and it's not necessary
to check whether the chunk is empty either.
2019-07-17 12:52:25 +02:00
Philip Rebohle 11b7fc8914
[d3d11] Catch invalid ClearUnorderedAccessViewFloat calls
This method cannot be called on integer UAVs.
2019-07-17 11:47:42 +02:00
Philip Rebohle b20ceec727
[d3d11] Handle integer formats in ClearRenderTargetView correctly
We're supposed to apply the same color conversion as in ClearView.
2019-07-17 11:47:42 +02:00
Philip Rebohle ad8fdcac07
[dxvk] Don't mark queries as stalling if DONOTFLUSH is set 2019-07-16 01:19:02 +02:00
Philip Rebohle 03c6df56c1
[d3d11] Initialize subresourceLayers in the inner loop
Not doing so causes Dirt Rally to fail uploading some textures
properly for some extremely weird reason.
2019-07-13 23:39:58 +02:00
Philip Rebohle 7b34b8515b
[d3d11] Enable shaderDemoteToHelperInvocation feature 2019-07-11 19:33:17 +02:00
Robin Kertels 47f7333c18
[d3d11] Fix RSGetViewports and RSGetScissorRects behaviour
Fixes #1116.
2019-07-08 13:14:42 +02:00
Philip Rebohle 15072afa1f
[d3d11] Use new signals as frame synchronization events 2019-07-08 00:16:03 +02:00
Philip Rebohle c631953ab6
[d3d11] Don't immediately synchronize after present
This will actually enable asynchronous presentation.
Improves performance in Quake Champions.
2019-07-05 21:20:09 +02:00
Philip Rebohle 77db8158c8
[dxvk] Add option to toggle asynchronous presentation 2019-07-05 21:20:09 +02:00
Philip Rebohle ed5c43a14d
[dxvk] Implement asynchronous presentation
Off-loads the vkQueuePresentKHR call to the queue submission thread
to avoid synchronization with that thread on a present call.
2019-07-05 15:11:59 +02:00
Philip Rebohle 1cc531eaf8
[d3d11] Return error when mapping an already mapped image
Final Fantasy XIV does this. Should avoid some unnecessary work.
2019-07-05 10:25:06 +02:00
Philip Rebohle 2f64f5b4e7
[dxvk] Check whether CS thread is busy before synchronizing with it
Reduces unnecessary locking overhead, which may be relevant if this
function gets called frequently by GetData or WaitForResource.
2019-07-04 21:37:17 +02:00
Philip Rebohle 67122d9246
[d3d11] Enable initial image uploads over SDMA 2019-06-29 01:53:43 +02:00
Philip Rebohle 9d902418c0
[d3d11] Enable initial buffer uploads over SDMA 2019-06-29 01:53:43 +02:00
Philip Rebohle 191bba660b
[dxvk] Provide way to access queue properties from device 2019-06-29 01:53:32 +02:00
Philip Rebohle 770ec2c4db
[dxvk] Get rid of array in present vertex shader 2019-06-29 01:34:16 +02:00
Philip Rebohle 42e61020e4
[d3d11] Remove unused SetRenderTargets method 2019-06-27 15:54:42 +02:00
Philip Rebohle 2148619f3c
[d3d11] Spill render pass when restoring context state as needed 2019-06-27 15:54:42 +02:00
Philip Rebohle a704e6d27e
[d3d11] Fix UAV binding in OMSetRenderTargets{,AndUnorderedAccessViews}
Unlike for compute shaders, we're supposed to replace all UAV bindings
when binding render targets. We also should spill the render pass when
disabling UAV rendering to avoid read-after-write hazards.

Fixes a potential synchronization bug encountered in Devil May Cry 5.
2019-06-27 15:54:42 +02:00
Philip Rebohle 5728d10587
[d3d11] Copy initial texture data to mapped buffer, if available
Otherwise, if an application maps the image right after creating it,
we might end up reading garbage data or overriding the image data.
2019-06-25 14:22:47 +02:00
Philip Rebohle 4d4db6c683
[dxvk] Use void pointers for packImageData
Makes this function a bit less annoying to use.
2019-06-25 14:17:03 +02:00
Philip Rebohle a41bd8c4a0
[d3d11] Further optimize constant buffer binding
Saves a few CPU cycles on the more common SetConstantBuffers method,
compared to SetConstantBuffers1.
2019-06-20 22:49:19 +02:00
Philip Rebohle 3141467c37
[d3d11] Template all functions that take ShaderStage as an argument
Basically what D9VK does. Doesn't seem to affect performance, but why not.
2019-06-20 22:09:02 +02:00
Philip Rebohle 684355dfca
[d3d11] Fix GetData parameter validation
We're supposed to return an error if a null pointer is
passed along with a non-zero DataSize. Fixes more wine
test failures.
2019-06-16 19:24:44 +02:00
Philip Rebohle 43389d8ef4
[d3d11] Implement timestamp disjoint queries 2019-06-16 17:14:39 +02:00
Philip Rebohle 1c718402f8
[d3d11] Use an array for query and event objects
We're going to need multiple queries to implement certain query types.
2019-06-16 17:14:24 +02:00
Philip Rebohle c8a429b9e1
[d3d11] Fix CheckMultisampleQualityLevels return code
We're supposed to return E_FAIL for unsupported sample counts,
and not zero-initialize the returned quality level count if the
format is invalid. Fixes wine test failures.
2019-06-14 13:37:01 +02:00
Philip Rebohle 5a66da8ef8
[dxvk] Fix various issues in GetFormatSupportFlags
- Support DXGI_FORMAT_UNKNOWN for buffer resources
- Report D3D11_FORMAT_SUPPORT_CPU_LOCKABLE for all supported formats
- Report support for linear-only image formats properly
- Return E_FAIL in case the format is not supported

Fixes a crash in Planet Coaster (#1091).
2019-06-13 16:32:41 +02:00
Philip Rebohle 1bc0b51262
[d3d11] Implement IDXGISurface2 for ID3D11Texture1D 2019-06-13 04:37:35 +02:00
Philip Rebohle 586d0de7bb
[d3d11] Fix default blend factor 2019-06-13 04:15:23 +02:00
Philip Rebohle 089d47e02e
[d3d11] Fix WSize computation for UAV creation 2019-06-13 04:01:15 +02:00
Philip Rebohle f02a5a7453
[d3d11] Don't create SRVs and UAVs with a size of 0
This is illegal and triggers invalid Vulkan usage.
2019-06-13 03:47:10 +02:00
Philip Rebohle 4ffddd1e40
[d3d11] Skip GenerateMips if mip gen flag is not set on resource 2019-06-13 03:31:31 +02:00
Philip Rebohle ce03384ba9
[d3d11] Validate bind flags for D3D11_RESOURCE_MISC_GENERATE_MIPS 2019-06-13 03:31:31 +02:00
Philip Rebohle 63d8d9c3db
[d3d11] Validate buffer descriptions 2019-06-13 03:31:26 +02:00
Philip Rebohle 6a76577f15
[d3d11] Fix behaviour with a viewport count of zero 2019-06-13 02:22:07 +02:00
Philip Rebohle 5ff9c33855
[d3d11] Fix incorrect behaviour when a scissor rect is not specified 2019-06-13 02:16:12 +02:00
Philip Rebohle 78071c750d
[d3d11] Fix crash when setting too many viewports 2019-06-13 01:54:55 +02:00
Philip Rebohle acab2bd8ce
[d3d11] Fix crash in GetMaximumFrameLatency with a nullptr argument 2019-06-11 16:36:43 +02:00
Philip Rebohle 7e66dc61b9 [d3d11] Avoid buffer ref count changes when only changing offsets
Saves a few CPU cycles in the somewhat common situation where the
currently bound vertex, index or constant buffer is re-bound with
a different offset.
2019-06-04 17:53:54 +02:00
Philip Rebohle e4e82007b1 [d3d11] Fix inconsistencies in Map/Unmap on immediate/deferred contexts
Should save a few CPU cycles, and also fixes incorrect behaviour when an
application passes null pointers to Map on a deferred context.
2019-06-03 15:31:13 +02:00
Philip Rebohle 58d838b915 [d3d11] Avoid emitting redundant vertex and index buffer updates 2019-06-03 00:18:54 +02:00
Philip Rebohle 818704d413 [d3d11] Add some likely/unlikely around CS flushes 2019-06-02 20:29:22 +02:00
Philip Rebohle 6cbd611190 [d3d11] Don't clear DSV aspects that are marked as read-only
Saint's Row 4 appears to be doing this. Ref #24.
2019-06-02 16:34:50 +02:00
Philip Rebohle c59a8e6e48 [d3d11] Initialize depth images to zero rather than one
Matches Windows behaviour.
2019-06-02 16:33:54 +02:00
Philip Rebohle 40d4922682 [d3d11] Fix initial swap chain image count
Reported-by: Joshua Ashton <joshua@froggi.es>
2019-06-02 15:00:15 +02:00
Philip Rebohle 1e0fe36cae
[d3d11] Respect COPY_FLAG_NO_OVERWRITE when updating constant buffers
Heavy Rain uses this to update constan buffers on deferred contexts.
2019-05-25 14:42:32 +02:00
Philip Rebohle 754cf6da30
[d3d11] Validate subresource index in MapImage
Fixes crashes when passing an invalid subresource index.
2019-05-20 19:27:27 +02:00
Philip Rebohle 3168626f4b
[d3d11] Support mapping multiple image subresources at the same time
Fixes #1066.
2019-05-20 19:27:11 +02:00
Philip Rebohle 9004fde78d
[d3d11] Remove useless 'virtual' keyword 2019-05-19 14:38:48 +02:00
Philip Rebohle e1610f81dc
Revert "[d3d11] Use STDMETHODCALLTYPE for private virtual method"
For some reason, this produces broken binaries for some Gentoo
users. Fixes #1067.

This reverts commit e5fa55cbb5.
2019-05-19 13:22:04 +02:00
Philip Rebohle 8e9e7963a2
[d3d11] Update mapped buffers of staging textures immediately
Improves performance in Lords of the Fallen and The Surge.
Closes #1049.

Co-authored-by: Robin <robin.kertels@outlook.com>
2019-05-17 12:44:36 +02:00
Philip Rebohle e5fa55cbb5
[d3d11] Use STDMETHODCALLTYPE for private virtual method
Improves code generation on some compilers.
2019-05-15 22:01:19 +02:00
pchome 32e1afc7a1 [build] Add options to disable dxgi/d3d* build 2019-05-15 21:44:39 +02:00
Philip Rebohle 8cae607db0
[d3d11] Add static method implementing D3D11CreateDeviceAndSwapChain
ReShade requires this as it hooks both D3D11CreateDevice and *AndSwapChain,
which means that we can't call D3D11CreateDevice without entering infinite
recursion. Fixes #1057.

Suggested-by: Riesi <riesi@opentrash.com>
2019-05-15 16:46:48 +02:00
Philip Rebohle 8784ed673b
[d3d11] Use private references for render targets
Matches Windows behaviour and fixes a crash in Yakuza Kiwami 2,
which calls Release() on RTVs and DSVs until the public reference
count reaches zero. Close #1053.
2019-05-14 15:22:24 +02:00
Philip Rebohle a54548dae9
[d3d11] Flush more aggressively when CPU bound
Submitting GPU work early is especially important if there is
a CPU<>GPU synchronization point somewhere.
2019-05-09 18:04:36 +02:00
Philip Rebohle 45be1dfb53
[d3d11] Flush more aggressively on stalling Event queries
Increases GPU utilization in Quake Champions.
2019-05-09 18:04:36 +02:00
Philip Rebohle af45f810b2
[dxvk] Change flushing behaviour of immediate context methods
Should fix some inappropriate flushing, while flushing more
aggressively on render target changes.

We still keep the flush on UpdateSubresource since some games
use it to update large quantities of data.
2019-05-09 18:04:36 +02:00
Philip Rebohle a1feaa6748
[dxvk] Add aspect mask parameter to clearImageView 2019-05-09 09:10:06 +02:00
Philip Rebohle 644f33a82b
[dxvk] Optimize unbound vertex buffer handling
We can actually just set the stride to 0 when binding a null
buffer, so that we can avoid all the runtime tracking.
2019-05-08 00:52:30 +02:00
Philip Rebohle 7687db0303
[dxvk] Remove extra pipeline state
This can be expressed with specialization constants now.
2019-05-06 00:18:59 +02:00
Philip Rebohle a0c67191a7
[d3d11] Implement depth bounds extension 2019-05-06 00:08:58 +02:00
Philip Rebohle 3867270812
[d3d11] Implement MultiDrawIndirectCount extension 2019-05-06 00:08:58 +02:00