Skip to content

Commit

Permalink
Merge branch 'attempt-merge-v2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
allfoxwy committed Nov 12, 2024
2 parents 129fd34 + 5fd608b commit 31e3bec
Show file tree
Hide file tree
Showing 241 changed files with 21,517 additions and 11,945 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, pull_request, workflow_dispatch]

jobs:
artifacts-mingw-w64:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: Checkout code
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
if-no-files-found: error

artifacts-steamrt-sniper:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
container: registry.gitlab.steamos.cloud/steamrt/sniper/sdk:beta

steps:
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:
if-no-files-found: error

merge-artifacts:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
needs: [artifacts-mingw-w64, artifacts-steamrt-sniper]
steps:
- name: Get version
Expand Down
25 changes: 24 additions & 1 deletion .github/workflows/test-build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ on: [push, pull_request, workflow_dispatch]

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

steps:
- name: Checkout code
id: checkout-code
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Setup glslangValidator
shell: pwsh
Expand All @@ -38,6 +39,12 @@ jobs:
Invoke-WebRequest -URI https://raw.githubusercontent.com/NovaRain/DXSDK_Collection/master/DXSDK_Aug2007/Include/d3d8.h -OutFile include/d3d8.h
Invoke-WebRequest -URI https://raw.githubusercontent.com/NovaRain/DXSDK_Collection/master/DXSDK_Aug2007/Include/d3d8types.h -OutFile include/d3d8types.h
Invoke-WebRequest -URI https://raw.githubusercontent.com/NovaRain/DXSDK_Collection/master/DXSDK_Aug2007/Include/d3d8caps.h -OutFile include/d3d8caps.h
- name: Get version
id: get-version
shell: bash
run: |
echo "VERSION_NAME=${GITHUB_REF##*/}-${GITHUB_SHA##*/}" >> $GITHUB_ENV
- name: Build MSVC x86
shell: pwsh
Expand All @@ -56,3 +63,19 @@ jobs:
| % { [System.Environment]::SetEnvironmentVariable($_[0], $_[1]) }
meson --buildtype release --backend vs2022 build-msvc-x64
msbuild -m build-msvc-x64/dxvk.sln
- name: Prepare artifacts
shell: pwsh
run: |
mkdir artifacts\x32
ls -Path build-msvc-x86\src -Include *.dll,*.pdb -Recurse
| cp -Destination (Join-Path -Path (pwd) -ChildPath artifacts\x32)
mkdir artifacts\x64
ls -Path build-msvc-x64\src -Include *.dll,*.pdb -Recurse
| cp -Destination (Join-Path -Path (pwd) -ChildPath artifacts\x64)
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: dxvk-${{ env.VERSION_NAME }}-msvc-output
path: artifacts\*
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.1
2.5
6 changes: 6 additions & 0 deletions buildenv.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once

#define DXVK_TARGET "@BUILD_TARGET@"
#define DXVK_COMPILER "@BUILD_COMPILER@"
#define DXVK_COMPILER_VERSION "@BUILD_COMPILER_VERSION@"

42 changes: 26 additions & 16 deletions dxvk.conf
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@
# dxvk.tearFree = Auto


# Assume single-use mode for command lists created on deferred contexts.
# This may need to be disabled for some applications to avoid rendering
# issues, which may come at a significant performance cost.
# Assume that command lists created from deferred contexts are only used
# once. This is extremely common and may improve performance while reducing
# the amount of memory wasted if games keep their command list objects alive
# for too long, but may also lead to rendering issues if command lists are
# submitted multiple times.
#
# Supported values: True, False

Expand Down Expand Up @@ -265,20 +267,13 @@
# 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 -1 disables the feature.

# d3d11.maxImplicitDiscardSize = 256


# Resource size limit for buffer-mapped dynamic images, in kilobytes.
# A higher threshold may reduce memory usage and PCI-E bandwidth in
# some games, but may also increase GPU synchronizations. Setting it
# to -1 disables the feature.
# Clears mapped memory to zero when suballocated memory is freed. This will
# drastically increase CPU overhead and should only be used as a last resort
# if a game does not properly initialize mapped buffers on its own.
#
# Supported values: True, False

# d3d11.maxDynamicImageBufferSize = -1
# dxvk.zeroMappedMemory = False


# Allocates dynamic resources with the given set of bind flags in
Expand Down Expand Up @@ -386,6 +381,21 @@
# dxvk.trackPipelineLifetime = Auto


# Controls memory defragmentation
#
# By default, DXVK will try to defragment video memory if there is a
# significant amount of memory wasted, or if the allocation budget of
# the application is exceeded. This option is provided solely for
# debug purposes.
#
# Supported values:
# - True: Enable defragmentation
# - Auto: Enable defragmentation, except on blocked drivers
# - False: Disable defragmentation

# dxvk.enableMemoryDefrag = Auto


# Sets enabled HUD elements
#
# Behaves like the DXVK_HUD environment variable if the
Expand Down
1 change: 1 addition & 0 deletions include/native/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ install_subdir(

install_headers(
'wsi/native_wsi.h',
'wsi/native_sdl3.h',
'wsi/native_sdl2.h',
'wsi/native_glfw.h',
subdir: 'dxvk/wsi',
Expand Down
2 changes: 2 additions & 0 deletions include/native/windows/windows_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ typedef struct RGNDATA {
#define DXGI_ERROR_NAME_ALREADY_EXISTS ((HRESULT)0x887A002C)
#define DXGI_ERROR_SDK_COMPONENT_MISSING ((HRESULT)0x887A002D)

#define D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD ((HRESULT)0x887C0004)

#define WINAPI
#define WINUSERAPI

Expand Down
25 changes: 25 additions & 0 deletions include/native/wsi/native_sdl3.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <windows.h>

#include <SDL3/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 SDL_DisplayID fromHmonitor(HMONITOR hMonitor) {
return SDL_DisplayID(reinterpret_cast<uintptr_t>(hMonitor));
}

// Offset so -1 display id goes to 0 == NULL
inline HMONITOR toHmonitor(SDL_DisplayID display) {
return reinterpret_cast<HMONITOR>(uintptr_t(display));
}

}
2 changes: 2 additions & 0 deletions include/native/wsi/native_wsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#ifdef DXVK_WSI_WIN32
#error You shouldnt be using this code path.
#elif DXVK_WSI_SDL3
#include "wsi/native_sdl3.h"
#elif DXVK_WSI_SDL2
#include "wsi/native_sdl2.h"
#elif DXVK_WSI_GLFW
Expand Down
26 changes: 23 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('dxvk', ['c', 'cpp'], version : 'v2.4.1', meson_version : '>= 0.58', default_options : [ 'cpp_std=c++17', 'warning_level=2' ])
project('dxvk', ['c', 'cpp'], version : 'v2.5', meson_version : '>= 0.58', default_options : [ 'cpp_std=c++17', 'b_vscrt=static_from_buildtype', 'warning_level=2' ])

pkg = import('pkgconfig')
cpu_family = target_machine.cpu_family()
Expand Down Expand Up @@ -87,8 +87,14 @@ if platform == 'windows'
]
endif
else
# setup file alignment + enable PDB output for MSVC builds
# PDBs are useful for Windows consumers of DXVK
compiler_args += [
'/Z7'
]
link_args += [
'/FILEALIGN:4096',
'/DEBUG:FULL'
]
endif

Expand Down Expand Up @@ -142,16 +148,20 @@ else
'./include/native/directx'
]

lib_sdl3 = dependency('SDL3', required: false)
lib_sdl2 = dependency('SDL2', required: false)
lib_glfw = dependency('glfw', required: false)
if lib_sdl3.found()
compiler_args += ['-DDXVK_WSI_SDL3']
endif
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')
if (not lib_sdl3.found() and not lib_sdl2.found() and not lib_glfw.found())
error('SDL3, SDL2, or GLFW are required to build dxvk-native')
endif

dxvk_name_prefix = 'dxvk_'
Expand Down Expand Up @@ -195,6 +205,16 @@ dxvk_version = vcs_tag(
output: 'version.h',
)

conf_data = configuration_data()
conf_data.set('BUILD_COMPILER', cpp.get_id())
conf_data.set('BUILD_COMPILER_VERSION', cpp.version())
conf_data.set('BUILD_TARGET', cpu_family)
dxvk_buildenv = configure_file(
configuration : conf_data,
input: 'buildenv.h.in',
output: 'buildenv.h',
)

if platform != 'windows'
subdir('include/native')
endif
Expand Down
1 change: 1 addition & 0 deletions package-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function build_arch {
$opt_strip \
--bindir "x$1" \
--libdir "x$1" \
-Db_ndebug=if-release \
-Dbuild_id=$opt_buildid \
"$DXVK_BUILD_DIR/build.$1"

Expand Down
25 changes: 10 additions & 15 deletions src/d3d11/d3d11_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#include "d3d11_context.h"
#include "d3d11_device.h"

#include "../dxvk/dxvk_data.h"

namespace dxvk {

D3D11Buffer::D3D11Buffer(
Expand Down Expand Up @@ -84,6 +82,10 @@ namespace dxvk {
info.access |= VK_ACCESS_HOST_WRITE_BIT;
}

// Always enable BDA usage if available so that CUDA interop can work
if (m_parent->GetDXVKDevice()->features().vk12.bufferDeviceAddress)
info.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;

if (p11on12Info) {
m_11on12 = *p11on12Info;

Expand All @@ -94,32 +96,25 @@ namespace dxvk {
if (m_desc.CPUAccessFlags)
m_11on12.Resource->Map(0, nullptr, &importInfo.mapPtr);

// D3D12 will always have BDA enabled
info.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;

m_buffer = m_parent->GetDXVKDevice()->importBuffer(info, importInfo, GetMemoryFlags());
m_mapped = m_buffer->getSliceHandle();

m_cookie = m_buffer->cookie();
m_mapPtr = m_buffer->mapPtr(0);
m_mapMode = DetermineMapMode(m_buffer->memFlags());
} else if (!(pDesc->MiscFlags & D3D11_RESOURCE_MISC_TILE_POOL)) {
VkMemoryPropertyFlags memoryFlags = GetMemoryFlags();
m_mapMode = DetermineMapMode(memoryFlags);

// Prevent buffer renaming for buffers that are not mappable, so
// that interop interfaces can safely query the GPU address.
if (m_mapMode == D3D11_COMMON_BUFFER_MAP_MODE_NONE
&& m_parent->GetDXVKDevice()->features().vk12.bufferDeviceAddress)
info.usage |= VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT;

// 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, memoryFlags);
m_mapped = m_buffer->getSliceHandle();
m_cookie = m_buffer->cookie();
m_mapPtr = m_buffer->mapPtr(0);
} else {
m_sparseAllocator = m_parent->GetDXVKDevice()->createSparsePageAllocator();
m_sparseAllocator->setCapacity(info.size / SparseMemoryPageSize);

m_mapped = DxvkBufferSliceHandle();
m_cookie = 0u;
m_mapPtr = nullptr;
m_mapMode = D3D11_COMMON_BUFFER_MAP_MODE_NONE;
}

Expand Down
24 changes: 16 additions & 8 deletions src/d3d11/d3d11_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ namespace dxvk {
return m_mapMode;
}

uint64_t GetCookie() const {
return m_cookie;
}

Rc<DxvkBuffer> GetBuffer() const {
return m_buffer;
}
Expand Down Expand Up @@ -113,17 +117,18 @@ namespace dxvk {
: DxvkBufferSlice();
}

DxvkBufferSliceHandle AllocSlice() {
return m_buffer->allocSlice();
Rc<DxvkResourceAllocation> AllocSlice(DxvkLocalAllocationCache* cache) {
return m_buffer->allocateStorage(cache);
}

DxvkBufferSliceHandle DiscardSlice() {
m_mapped = m_buffer->allocSlice();
return m_mapped;
Rc<DxvkResourceAllocation> DiscardSlice(DxvkLocalAllocationCache* cache) {
auto allocation = m_buffer->allocateStorage(cache);
m_mapPtr = allocation->mapPtr();
return allocation;
}

DxvkBufferSliceHandle GetMappedSlice() const {
return m_mapped;
void* GetMapPtr() const {
return m_mapPtr;
}

D3D10Buffer* GetD3D10Iface() {
Expand Down Expand Up @@ -182,11 +187,14 @@ namespace dxvk {
D3D11_COMMON_BUFFER_MAP_MODE m_mapMode;

Rc<DxvkBuffer> m_buffer;
uint64_t m_cookie = 0u;

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

void* m_mapPtr = nullptr;

D3D11DXGIResource m_resource;
D3D10Buffer m_d3d10;

Expand Down
Loading

0 comments on commit 31e3bec

Please sign in to comment.