From 50d223e614ab01332807eaee3446b1e67fc4b3f1 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Sat, 27 Feb 2021 19:29:52 +0000 Subject: [PATCH] [d3d9] Add option to use device local memory for constant buffers Useful for testing performance. --- dxvk.conf | 12 ++++++++++++ src/d3d9/d3d9_device.cpp | 3 +++ src/d3d9/d3d9_options.cpp | 2 ++ src/d3d9/d3d9_options.h | 3 +++ 4 files changed, 20 insertions(+) diff --git a/dxvk.conf b/dxvk.conf index 1cd42564..a6c925c3 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -342,3 +342,15 @@ # - True/False # d3d9.alphaTestWiggleRoom = False + +# Device Local Constant Buffers +# +# Enables using device local, host accessible memory for constant buffers in D3D9. +# This tends to actually be slower for some reason on AMD, +# and the exact same performance on NVIDIA. +# +# Supported values: +# - True/False + +# d3d9.deviceLocalConstantBuffers = False + diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index d74f01e3..a6b300fe 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -4627,6 +4627,9 @@ namespace dxvk { VkMemoryPropertyFlags memoryFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + if (m_d3d9Options.deviceLocalConstantBuffers) + memoryFlags |= VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + Rc buffer = m_dxvkDevice->createBuffer(info, memoryFlags); const uint32_t slotId = computeResourceSlotId( diff --git a/src/d3d9/d3d9_options.cpp b/src/d3d9/d3d9_options.cpp index f49259dc..ac2de14e 100644 --- a/src/d3d9/d3d9_options.cpp +++ b/src/d3d9/d3d9_options.cpp @@ -75,6 +75,8 @@ namespace dxvk { this->apitraceMode = config.getOption("d3d9.apitraceMode", false); + this->deviceLocalConstantBuffers = config.getOption("d3d9.deviceLocalConstantBuffers", false); + // If we are not Nvidia, enable general hazards. this->generalHazards = adapter == nullptr || !adapter->matchesDriver(DxvkGpuVendor::Nvidia, VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR, 0, 0); applyTristate(this->generalHazards, config.getOption("d3d9.generalHazards", Tristate::Auto)); diff --git a/src/d3d9/d3d9_options.h b/src/d3d9/d3d9_options.h index d27fdddd..8ff661da 100644 --- a/src/d3d9/d3d9_options.h +++ b/src/d3d9/d3d9_options.h @@ -154,6 +154,9 @@ namespace dxvk { /// Apitrace mode: Maps all buffers in cached memory. bool apitraceMode; + + /// Use device local memory for constant buffers. + bool deviceLocalConstantBuffers; }; } \ No newline at end of file