1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[dxvk] Use global user config for backend options

This commit is contained in:
Philip Rebohle 2018-08-07 16:42:21 +02:00
parent 10f7e4d91b
commit b2c4855490
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
8 changed files with 54 additions and 14 deletions

View File

@ -8,12 +8,13 @@ namespace dxvk {
const Rc<vk::DeviceFn>& vkd, const Rc<vk::DeviceFn>& vkd,
const DxvkDeviceExtensions& extensions, const DxvkDeviceExtensions& extensions,
const DxvkDeviceFeatures& features) const DxvkDeviceFeatures& features)
: m_adapter (adapter), : m_options (adapter->instance()->config()),
m_adapter (adapter),
m_vkd (vkd), m_vkd (vkd),
m_extensions (extensions), m_extensions (extensions),
m_features (features), m_features (features),
m_properties (adapter->deviceProperties()), m_properties (adapter->deviceProperties()),
m_memory (new DxvkMemoryAllocator (adapter, vkd)), m_memory (new DxvkMemoryAllocator (this)),
m_renderPassPool (new DxvkRenderPassPool (vkd)), m_renderPassPool (new DxvkRenderPassPool (vkd)),
m_pipelineManager (new DxvkPipelineManager (this)), m_pipelineManager (new DxvkPipelineManager (this)),
m_metaClearObjects (new DxvkMetaClearObjects (vkd)), m_metaClearObjects (new DxvkMetaClearObjects (vkd)),

View File

@ -10,6 +10,7 @@
#include "dxvk_image.h" #include "dxvk_image.h"
#include "dxvk_memory.h" #include "dxvk_memory.h"
#include "dxvk_meta_clear.h" #include "dxvk_meta_clear.h"
#include "dxvk_options.h"
#include "dxvk_pipecache.h" #include "dxvk_pipecache.h"
#include "dxvk_pipemanager.h" #include "dxvk_pipemanager.h"
#include "dxvk_queue.h" #include "dxvk_queue.h"
@ -84,6 +85,14 @@ namespace dxvk {
VkDevice handle() const { VkDevice handle() const {
return m_vkd->device(); return m_vkd->device();
} }
/**
* \brief Device options
* \returns Device options
*/
const DxvkOptions& config() const {
return m_options;
}
/** /**
* \brief Graphics queue properties * \brief Graphics queue properties
@ -371,6 +380,8 @@ namespace dxvk {
private: private:
DxvkOptions m_options;
Rc<DxvkAdapter> m_adapter; Rc<DxvkAdapter> m_adapter;
Rc<vk::DeviceFn> m_vkd; Rc<vk::DeviceFn> m_vkd;
DxvkDeviceExtensions m_extensions; DxvkDeviceExtensions m_extensions;

View File

@ -1,3 +1,4 @@
#include "dxvk_device.h"
#include "dxvk_memory.h" #include "dxvk_memory.h"
namespace dxvk { namespace dxvk {
@ -141,12 +142,11 @@ namespace dxvk {
} }
DxvkMemoryAllocator::DxvkMemoryAllocator( DxvkMemoryAllocator::DxvkMemoryAllocator(const DxvkDevice* device)
const Rc<DxvkAdapter>& adapter, : m_vkd (device->vkd()),
const Rc<vk::DeviceFn>& vkd) m_devProps (device->adapter()->deviceProperties()),
: m_vkd (vkd), m_memProps (device->adapter()->memoryProperties()),
m_devProps(adapter->deviceProperties()), m_allowOvercommit (device->config().allowMemoryOvercommit) {
m_memProps(adapter->memoryProperties()) {
for (uint32_t i = 0; i < m_memProps.memoryHeapCount; i++) { for (uint32_t i = 0; i < m_memProps.memoryHeapCount; i++) {
VkDeviceSize heapSize = m_memProps.memoryHeaps[i].size; VkDeviceSize heapSize = m_memProps.memoryHeaps[i].size;
@ -269,7 +269,8 @@ namespace dxvk {
VkDeviceSize size, VkDeviceSize size,
const VkMemoryDedicatedAllocateInfoKHR* dedAllocInfo) { const VkMemoryDedicatedAllocateInfoKHR* dedAllocInfo) {
if ((type->memType.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) if ((type->memType.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)
&& (type->heap->stats.memoryAllocated + size > type->heap->properties.size)) && (type->heap->stats.memoryAllocated + size > type->heap->properties.size)
&& (!m_allowOvercommit))
return DxvkDeviceMemory(); return DxvkDeviceMemory();
DxvkDeviceMemory result; DxvkDeviceMemory result;

View File

@ -213,9 +213,7 @@ namespace dxvk {
friend class DxvkMemoryChunk; friend class DxvkMemoryChunk;
public: public:
DxvkMemoryAllocator( DxvkMemoryAllocator(const DxvkDevice* device);
const Rc<DxvkAdapter>& adapter,
const Rc<vk::DeviceFn>& vkd);
~DxvkMemoryAllocator(); ~DxvkMemoryAllocator();
/** /**
@ -256,6 +254,7 @@ namespace dxvk {
const Rc<vk::DeviceFn> m_vkd; const Rc<vk::DeviceFn> m_vkd;
const VkPhysicalDeviceProperties m_devProps; const VkPhysicalDeviceProperties m_devProps;
const VkPhysicalDeviceMemoryProperties m_memProps; const VkPhysicalDeviceMemoryProperties m_memProps;
const bool m_allowOvercommit;
std::mutex m_mutex; std::mutex m_mutex;
std::array<DxvkMemoryHeap, VK_MAX_MEMORY_HEAPS> m_memHeaps; std::array<DxvkMemoryHeap, VK_MAX_MEMORY_HEAPS> m_memHeaps;

10
src/dxvk/dxvk_options.cpp Normal file
View File

@ -0,0 +1,10 @@
#include "dxvk_options.h"
namespace dxvk {
DxvkOptions::DxvkOptions(const Config& config) {
allowMemoryOvercommit = config.getOption<bool>("dxvk.allowMemoryOvercommit", false);
useAsyncPipeCompiler = config.getOption<bool>("dxvk.useAsyncPipeCompiler", false);
}
}

18
src/dxvk/dxvk_options.h Normal file
View File

@ -0,0 +1,18 @@
#pragma once
#include "../util/config/config.h"
namespace dxvk {
struct DxvkOptions {
DxvkOptions(const Config& config);
/// Allow allocating more memory from
/// a heap than the device supports.
bool allowMemoryOvercommit;
/// Enable asynchronous pipeline compilation.
bool useAsyncPipeCompiler;
};
}

View File

@ -42,8 +42,7 @@ namespace dxvk {
: m_device (device), : m_device (device),
m_cache (new DxvkPipelineCache(device->vkd())), m_cache (new DxvkPipelineCache(device->vkd())),
m_compiler(nullptr) { m_compiler(nullptr) {
// Async shader compilation is opt-in for now if (m_device->config().useAsyncPipeCompiler)
if (env::getEnvVar(L"DXVK_USE_PIPECOMPILER") == "1")
m_compiler = new DxvkPipelineCompiler(); m_compiler = new DxvkPipelineCompiler();
} }

View File

@ -56,6 +56,7 @@ dxvk_src = files([
'dxvk_meta_mipgen.cpp', 'dxvk_meta_mipgen.cpp',
'dxvk_meta_resolve.cpp', 'dxvk_meta_resolve.cpp',
'dxvk_openvr.cpp', 'dxvk_openvr.cpp',
'dxvk_options.cpp',
'dxvk_pipecache.cpp', 'dxvk_pipecache.cpp',
'dxvk_pipecompiler.cpp', 'dxvk_pipecompiler.cpp',
'dxvk_pipelayout.cpp', 'dxvk_pipelayout.cpp',