Skip to content

Commit

Permalink
Update to 1.9.4 (#6)
Browse files Browse the repository at this point in the history
* Enabled strict float emulation for BlazBlue Centralfiction

* [dxvk] Explicitly intiialize framebuffer info

* [d3d11] Lock context before EmitCs for annotations

* [build] Update arch-mingw-github-action to v6

* Added config for James Cameron's Avatar (DX9)

* [dxgi] Fix refresh rate filtering in FindClosestMatchingMode

We need to operate on the pre-filtered list, or otherwise we may run into
problems where not all refresh rates are supported for all display modes.

* [d3d9] Always upload all managed texture mips after AddDirtyBox call

Co-authored-by: Paul Gofman <[email protected]>

* [d3d9] Update FFVS when D3DFVF_PSIZE is specified.

This fixes doitsujin#2387

* [d3d9] Dirty FF vertex shader if any  D3D9VertexDeclFlags change.

The vertex shader depends on all of these in some way.

* [meta] Release 1.9.3

* WIP

* [dxvk] Display allocated memory in HUD again

* [dxvk] Free empty memory chunks

* [dxvk] Replace allocation priority with allocation flags

* [dxvk] Be smarter about which chunks to free

Freeing all empty chunks immediately may cause issues if an app constantly
allocates and frees a small number of resources that don't fit into any
existing chunk, so try to keep one around. Aggressively free everything
under memory pressure if necessary.

* [dxvk] Reduce size up to which device-local buffers can be invalidated

* [dxvk] Reduce maximum size of multi-slice buffers

* [util] Enable performance options for God of War

* [util] Disable NVAPI hack for God of War

Needed for DLSS support.

* [dxvk] Don't shrink HVV heap if it's the main video memory heap

May fix issues on RBAR-enabled Nvidia systems.

* [d3d9] Enable strict float emulation by default for new radv.

* [d3d9] Fix float emulation detection.

ffs

* WIP

* [dxvk] Remove options to disable OpenVR/XR support

No longer needed since we no longer load vrclient.so into the game's
process just to query extensions.

* [meta] Release 1.9.4

* [d3d11] Add FL12+ enum names

* [d3d9] Only enable FETCH4 for single channel formats

* [build] MSVC CI

* [dxvk] Fix MSVC build.

* [dxvk] Rework driver version fixup to use driver ID instead of vendor ID

* [dxvk] Add version fixup for proprietary Intel drivers

* [d3d11] Add D3D11On12CreateDevice stub

* [d3d11] Remove unused parameters from deferred context Map functions

* [d3d11] Fix confusing code in deferred context Map

This did work, but we shouldn't use an object that was already moved.

* [d3d11] Implement suballocation from staging buffer for small updates

* [d3d11] Optimize UpdateSubresource for small buffer updates

Some games use UpdateSubresource to upload constant buffers in
between draws, so this path should be as fast as possible.

Also fixes a potential issue when using D3D11_COPY_NO_OVERWRITE
on deferred contexts, since the Map requirements don't hold here.

* [build] Use MSBuild backend on Windows CI

Also merge Prepare and Build steps to prevent environment variable leaks and apply some minor formatting changes.

* [build] Avoid meson warning.

WARNING: You should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.

Stupid change, stupid warning, stupid fix.

* [util] Enable apitrace mode for AoE2 Definitive Edition

Fixes doitsujin#2491.

* [dxvk] Introduce sequence numbers for CS submissions

* [dxvk] Reorganize DxvkBuffer data structure

Should hopefully reduce CPU cache conflicts.

* [d3d11] Add ResourceAddRef/ReleasePrivate with known resource type

* [d3d11] Add D3D11ResourceRef

Implements private ref counting for arbitrary resource types.

* [d3d11] Store buffer map mode in D3D11Buffer

Matches what we do for textures, and makes it so that we don't
have to dereference the resource pointer to figure this out.

* [d3d11] Store ID3D11Resource interface in D3D11CommonTexture

Going full circle here, but it's actually useful now.

* [d3d11] Add method to query D3D11 resource dimension from texture

* [d3d11] Track last staging resource usage with a sequence number

* [d3d11] Increment sequence number when submitting command lists

This does not do any tracking on deferred contexts just yet.

* [d3d11] Implement sequence number tracking on deferred contexts

* [d3d11] Track resources when dispatching Cubin shaders as well

* [d3d11] Synchronize only to given sequence number in WaitForResources

Avoids costly thread synchronization when mapping staging resources
for reading, as well as some other scenarios.

* [d3d11] Optimize Unmap on immediate contexts

* [d3d11] Change D3D11ResourceRef constructor to be more useful

* [d3d11] Further simplify D3D11DeferredContextMapEntry

And no longer create a strong reference to the given resource.

* [d3d11] Avoid GPU synchronization on mapping buffers when possible

* [d3d11] Avoid GPU synchronization on mapping images when possible

* [dxvk] Expose a way to increment stat counters

In case the counters come from external sources.

* [dxvk] Store DXVK device inside DxvkCsThread object

* [dxvk] Add CS thread stat counters

* [hud] Add HUD item to show CS thread stats

* [d3d11] Only use updateBuffer for very small buffer updates

Otherwise we may end up with significant copy overhead on the CS thread.

* [d3d9] Exit early in ProcessVertices if the vertex count is 0

We don't want to pass a zero-sized copy to the backend.

* [dxvk] Repurpose updateBuffer

Only allow it for very small updates where scheduling a copy command would
likely be slower. Some drivers have special paths for tiny updates.

* [dxvk] Introduce tryInvalidateDeviceLocalBuffer

* [dxvk] Discard buffer slice in copyBuffer if possible

* [dxvk] Introduce DxvkStagingBuffer

* [d3d11] Use DxvkStagingBuffer in D3D11DeviceContext

* [dxvk] Use staging buffer for gamma ramp uploads

* [dxvk] Remove unused updateImage function

* [dxvk] Use DxvkStagingBuffer in DxvkContext

* [dxvk] Remove DxvkStagingDataAlloc

Unused and overly clunky.

* [dxvk] Allow large sysmem allocations on 64-bit platforms again

Since we frequently discard staging buffers now, having larger chunks
is actually beneficial again.

* [dxvk] Introduce transient memory flag for staging buffers

Potentially reduces fragmentation by putting short-lived staging buffers
and sysmem resources created by the application into different memory pools.

* [dxvk] Rework HUD font texture initialization

We really shouldn't need a separate context for this.

* [dxvk] Remove unused trimStagingBuffers method

* [dxvk] Don't suballocate large staging buffer allocations

Otherwise we'll risk wasting almost half the staging buffer memory.
Creating a temporary buffer is cheap enough, so just do that.

* [dxvk] Reduce context staging buffer size to 4 MiB

Same idea as before, just create a temporary buffer for larger resources.

This can avoid frequent Vulkan memory allocations and deallocations since
many small buffers are more likely to fit into a single memory chunk than
a small number of large buffers, thus reducing the overall memory footprint.

* [dxvk] Add stat counter for pipeline barriers

* [dxvk] Display barrier count in draw call HUD item

* [dxvk] Introduce DxvkDevice::waitForResource

Blocks on the queue thread's condition variable instead of busy-waiting,
and tracks synchronization with new stat counters. Cleanup is rearranged
to minimize delays before signals and resources are notified.

* [d3d11] Use new waitForResource method

* [d3d9] Use new waitForResource method

* [hud] Display GPU synchronization in HUD

* [d3d11] Add d3d11.maxImplicitDiscardSize option

* [util] Bump maxImplicitDiscardSize for Quantum Break

Otherwise we're synchronizing and frame times are garbage.

* [util] Enable apitrace mode for Nier Replicant

Game is broken and reads back dynamic vertex/index buffers over PCI-E.

* [d3d11] Handle subresource field in copy/move operations

Derp.

* [d3d11] Enable stall tracking for timestamp queries

Because games are dumb and don't understand that the GPU doesn't
work synchronously with the render thread.

* [d3d11] Add implicit flush after tracking sequence numbers

Flushing early when using a tracked resource may reduce stalls.

* [dxvk] Repurpose initImage method

This is now supposed to clear images of any type, and only to be
used for resource initialization after creation.

* [d3d11] Use initImage to clear uninitialized image resources

* [d3d9] Use initImage to clear uninitialized image resources

* [dxvk] Remove unused clear methods

* [dxvk] Add command buffer parameter to cmdFillBuffer

* [dxvk] Add initBuffer method

* [d3d11] Use initBuffer method

* [d3d9] Use initBuffer method

* [dxvk] Track buffer as used in initBuffer

Git ate my commit when I was testing something...

* [d3d11] Consider empty CS chunks when tracking resources

Avoids deadlocks if we track multiple resources and flush in between.

* [dxvk] Free existing staging buffer before creating a new one

* WIP

* WIP

Co-authored-by: Supreeeme <[email protected]>
Co-authored-by: Philip Rebohle <[email protected]>
Co-authored-by: Joshua Ashton <[email protected]>
Co-authored-by: dosse91 <[email protected]>
Co-authored-by: Robin Kertels <[email protected]>
Co-authored-by: Paul Gofman <[email protected]>
Co-authored-by: Christopher Egert <[email protected]>
Co-authored-by: Georg Lehmann <[email protected]>
Co-authored-by: Krzysztof Bogacki <[email protected]>
  • Loading branch information
10 people authored Feb 19, 2022
1 parent 1502584 commit 5fb7517
Show file tree
Hide file tree
Showing 71 changed files with 2,224 additions and 1,129 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/test-build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Test Builds on Windows

on: [push, pull_request, workflow_dispatch]

jobs:
build-set-windows:
runs-on: windows-2022

steps:
- name: Checkout code
id: checkout-code
uses: actions/checkout@v2
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
- name: Setup Meson
shell: pwsh
run: pip install meson

- name: Find Visual Studio
shell: pwsh
run: |
$installationPath = Get-VSSetupInstance `
| Select-VSSetupInstance -Require Microsoft.VisualStudio.Workload.NativeDesktop -Latest `
| Select-Object -ExpandProperty InstallationPath
Write-Output "VSDEVCMD=${installationPath}\Common7\Tools\VsDevCmd.bat" `
| Out-File -FilePath "${Env:GITHUB_ENV}" -Append
- name: Build MSVC x86
shell: pwsh
run: |
& "${Env:COMSPEC}" /s /c "`"${Env:VSDEVCMD}`" -arch=x86 -host_arch=x64 -no_logo && set" `
| % { , ($_ -Split '=', 2) } `
| % { [System.Environment]::SetEnvironmentVariable($_[0], $_[1]) }
meson --buildtype release --backend vs2022 build-msvc-x86
msbuild -m build-msvc-x86/dxvk.sln
- name: Build MSVC x64
shell: pwsh
run: |
& "${Env:COMSPEC}" /s /c "`"${Env:VSDEVCMD}`" -arch=x64 -host_arch=x64 -no_logo && set" `
| % { , ($_ -Split '=', 2) } `
| % { [System.Environment]::SetEnvironmentVariable($_[0], $_[1]) }
meson --buildtype release --backend vs2022 build-msvc-x64
msbuild -m build-msvc-x64/dxvk.sln
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9.3
1.9.4
10 changes: 9 additions & 1 deletion dxvk.conf
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,14 @@
# d3d11.zeroWorkgroupMemory = False


# Resource size limit for implicit discards, in kilobytes. For small staging
# resources mapped with MAP_WRITE, DXVK will sometimes allocate new backing
# storage in order to avoid GPU synchronization, so setting this too high
# may cause memory issues, setting it to 0 disables the feature.

# d3d11.maxImplicitDiscardSize = 256


# Sets number of pipeline compiler threads.
#
# Supported values:
Expand Down Expand Up @@ -343,7 +351,7 @@
# - Strict: Use a slower but more correct approach. Necessary for some games
# - Auto: DXVK will pick automatically

# d3d9.floatEmulation = True
# d3d9.floatEmulation = Auto


# Enable dialog box mode
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('dxvk', ['c', 'cpp'], version : 'v1.9.3', meson_version : '>= 0.46')
project('dxvk', ['c', 'cpp'], version : 'v1.9.4', meson_version : '>= 0.47')

cpu_family = target_machine.cpu_family()

Expand Down Expand Up @@ -111,7 +111,7 @@ def_spec_ext = '.def'

glsl_compiler = find_program('glslangValidator')
glsl_args = [ '-V', '--vn', '@BASENAME@', '@INPUT@', '-o', '@OUTPUT@' ]
if run_command(glsl_compiler, [ '--quiet', '--version' ]).returncode() == 0
if run_command(glsl_compiler, [ '--quiet', '--version' ], check : false).returncode() == 0
glsl_args += [ '--quiet' ]
endif
glsl_generator = generator(glsl_compiler,
Expand Down
1 change: 1 addition & 0 deletions src/d3d11/d3d11.def
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ EXPORTS
D3D11CoreCreateDevice @18
D3D11CreateDevice @22
D3D11CreateDeviceAndSwapChain @23
D3D11On12CreateDevice @24
9 changes: 9 additions & 0 deletions src/d3d11/d3d11_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ namespace dxvk {
m_buffer = m_parent->GetDXVKDevice()->createBuffer(info, GetMemoryFlags());
m_mapped = m_buffer->getSliceHandle();

m_mapMode = DetermineMapMode();

// For Stream Output buffers we need a counter
if (pDesc->BindFlags & D3D11_BIND_STREAM_OUTPUT)
m_soCounter = CreateSoCounterBuffer();
Expand Down Expand Up @@ -273,6 +275,13 @@ namespace dxvk {
| VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT;
return device->createBuffer(info, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
}


D3D11_COMMON_BUFFER_MAP_MODE D3D11Buffer::DetermineMapMode() {
return (m_buffer->memFlags() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
? D3D11_COMMON_BUFFER_MAP_MODE_DIRECT
: D3D11_COMMON_BUFFER_MAP_MODE_NONE;
}


D3D11Buffer* GetCommonBuffer(ID3D11Resource* pResource) {
Expand Down
36 changes: 27 additions & 9 deletions src/d3d11/d3d11_buffer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "../dxvk/dxvk_cs.h"
#include "../dxvk/dxvk_device.h"

#include "../d3d10/d3d10_buffer.h"
Expand Down Expand Up @@ -67,9 +68,7 @@ namespace dxvk {
}

D3D11_COMMON_BUFFER_MAP_MODE GetMapMode() const {
return (m_buffer->memFlags() & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
? D3D11_COMMON_BUFFER_MAP_MODE_DIRECT
: D3D11_COMMON_BUFFER_MAP_MODE_NONE;
return m_mapMode;
}

Rc<DxvkBuffer> GetBuffer() const {
Expand Down Expand Up @@ -119,6 +118,21 @@ namespace dxvk {
return &m_d3d10;
}

bool HasSequenceNumber() const {
return m_mapMode != D3D11_COMMON_BUFFER_MAP_MODE_NONE
&& !(m_desc.MiscFlags & D3D11_RESOURCE_MISC_DRAWINDIRECT_ARGS)
&& !(m_desc.BindFlags);
}

void TrackSequenceNumber(uint64_t Seq) {
m_seq = Seq;
}

uint64_t GetSequenceNumber() {
return HasSequenceNumber() ? m_seq
: DxvkCsThread::SynchronizeAll;
}

/**
* \brief Normalizes buffer description
*
Expand All @@ -130,14 +144,16 @@ namespace dxvk {

private:

const D3D11_BUFFER_DESC m_desc;
D3D11_BUFFER_DESC m_desc;
D3D11_COMMON_BUFFER_MAP_MODE m_mapMode;

Rc<DxvkBuffer> m_buffer;
Rc<DxvkBuffer> m_soCounter;
DxvkBufferSliceHandle m_mapped;
Rc<DxvkBuffer> m_buffer;
Rc<DxvkBuffer> m_soCounter;
DxvkBufferSliceHandle m_mapped;
uint64_t m_seq = 0ull;

D3D11DXGIResource m_resource;
D3D10Buffer m_d3d10;
D3D11DXGIResource m_resource;
D3D10Buffer m_d3d10;

BOOL CheckFormatFeatureSupport(
VkFormat Format,
Expand All @@ -147,6 +163,8 @@ namespace dxvk {

Rc<DxvkBuffer> CreateSoCounterBuffer();

D3D11_COMMON_BUFFER_MAP_MODE DetermineMapMode();

};


Expand Down
56 changes: 54 additions & 2 deletions src/d3d11/d3d11_cmdlist.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "d3d11_cmdlist.h"
#include "d3d11_device.h"
#include "d3d11_buffer.h"
#include "d3d11_texture.h"

namespace dxvk {

Expand Down Expand Up @@ -58,21 +60,71 @@ namespace dxvk {
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();
}


void D3D11CommandList::EmitToCsThread(DxvkCsThread* CsThread) {
uint64_t D3D11CommandList::EmitToCsThread(DxvkCsThread* CsThread) {
uint64_t seq = 0;

for (const auto& query : m_queries)
query->DoDeferredEnd();

for (const auto& chunk : m_chunks)
CsThread->dispatchChunk(DxvkCsChunkRef(chunk));
seq = CsThread->dispatchChunk(DxvkCsChunkRef(chunk));

for (const auto& resource : m_resources)
TrackResourceSequenceNumber(resource, seq);

MarkSubmitted();
return seq;
}


void D3D11CommandList::TrackResourceUsage(
ID3D11Resource* pResource,
D3D11_RESOURCE_DIMENSION ResourceType,
UINT Subresource) {
m_resources.emplace_back(pResource, Subresource, ResourceType);
}


void D3D11CommandList::TrackResourceSequenceNumber(
const D3D11ResourceRef& Resource,
uint64_t Seq) {
ID3D11Resource* iface = Resource.Get();
UINT subresource = Resource.GetSubresource();

switch (Resource.GetType()) {
case D3D11_RESOURCE_DIMENSION_UNKNOWN:
break;

case D3D11_RESOURCE_DIMENSION_BUFFER: {
auto impl = static_cast<D3D11Buffer*>(iface);
impl->TrackSequenceNumber(Seq);
} break;

case D3D11_RESOURCE_DIMENSION_TEXTURE1D: {
auto impl = static_cast<D3D11Texture1D*>(iface)->GetCommonTexture();
impl->TrackSequenceNumber(subresource, Seq);
} break;

case D3D11_RESOURCE_DIMENSION_TEXTURE2D: {
auto impl = static_cast<D3D11Texture2D*>(iface)->GetCommonTexture();
impl->TrackSequenceNumber(subresource, Seq);
} break;

case D3D11_RESOURCE_DIMENSION_TEXTURE3D: {
auto impl = static_cast<D3D11Texture3D*>(iface)->GetCommonTexture();
impl->TrackSequenceNumber(subresource, Seq);
} break;
}
}


void D3D11CommandList::MarkSubmitted() {
if (m_submitted.exchange(true) && !m_warned.exchange(true)
&& m_parent->GetOptions()->dcSingleUseMode) {
Expand Down
16 changes: 13 additions & 3 deletions src/d3d11/d3d11_cmdlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,29 @@ namespace dxvk {
void EmitToCommandList(
ID3D11CommandList* pCommandList);

void EmitToCsThread(
uint64_t EmitToCsThread(
DxvkCsThread* CsThread);


void TrackResourceUsage(
ID3D11Resource* pResource,
D3D11_RESOURCE_DIMENSION ResourceType,
UINT Subresource);

private:

UINT const m_contextFlags;

std::vector<DxvkCsChunkRef> m_chunks;
std::vector<Com<D3D11Query, false>> m_queries;
std::vector<D3D11ResourceRef> m_resources;

std::atomic<bool> m_submitted = { false };
std::atomic<bool> m_warned = { false };

void TrackResourceSequenceNumber(
const D3D11ResourceRef& Resource,
uint64_t Seq);

void MarkSubmitted();

};
Expand Down
Loading

0 comments on commit 5fb7517

Please sign in to comment.