1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-01 07:24:12 +01:00

[dxvk] Added app and device specific options

This commit is contained in:
Philip Rebohle 2018-01-16 13:58:57 +01:00
parent bc5dfc1cad
commit 27573e9b25
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
7 changed files with 147 additions and 0 deletions

View File

@ -17,6 +17,10 @@ namespace dxvk {
m_pipelineCache (new DxvkPipelineCache (vkd)),
m_pipelineManager (new DxvkPipelineManager(vkd)),
m_submissionQueue (this) {
m_options.adjustAppOptions(env::getExeName());
m_options.adjustDeviceOptions(m_adapter);
m_options.logOptions();
m_vkd->vkGetDeviceQueue(m_vkd->device(),
m_adapter->graphicsQueueFamily(), 0,
&m_graphicsQueue);

View File

@ -9,6 +9,7 @@
#include "dxvk_framebuffer.h"
#include "dxvk_image.h"
#include "dxvk_memory.h"
#include "dxvk_options.h"
#include "dxvk_pipecache.h"
#include "dxvk_pipemanager.h"
#include "dxvk_queue.h"
@ -73,6 +74,16 @@ namespace dxvk {
return m_adapter;
}
/**
* \brief Checks whether an option is enabled
*
* \param [in] option The option to check for
* \returns \c true if the option is enabled
*/
bool hasOption(DxvkOption option) const {
return m_options.test(option);
}
/**
* \brief Enabled device extensions
* \returns Enabled device extensions
@ -318,6 +329,8 @@ namespace dxvk {
Rc<DxvkPipelineCache> m_pipelineCache;
Rc<DxvkPipelineManager> m_pipelineManager;
DxvkOptions m_options;
std::mutex m_submissionLock;
VkQueue m_graphicsQueue = VK_NULL_HANDLE;
VkQueue m_presentQueue = VK_NULL_HANDLE;

View File

@ -129,6 +129,7 @@ namespace dxvk {
* used by DXVK if supported by the implementation.
*/
struct DxvkDeviceExtensions : public DxvkExtensionList {
DxvkExtension amdRasterizationOrder = { this, VK_AMD_RASTERIZATION_ORDER_EXTENSION_NAME, DxvkExtensionType::Optional };
DxvkExtension khrMaintenance1 = { this, VK_KHR_MAINTENANCE1_EXTENSION_NAME, DxvkExtensionType::Required };
DxvkExtension khrMaintenance2 = { this, VK_KHR_MAINTENANCE2_EXTENSION_NAME, DxvkExtensionType::Desired };
DxvkExtension khrShaderDrawParameters = { this, VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME, DxvkExtensionType::Required };

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

@ -0,0 +1,39 @@
#include <unordered_map>
#include "dxvk_options.h"
namespace dxvk {
const static std::unordered_map<std::string, DxvkOptionSet> g_appOptions = {{
}};
void DxvkOptions::adjustAppOptions(const std::string& appName) {
auto appOptions = g_appOptions.find(appName);
if (appOptions != g_appOptions.end())
m_options.set(appOptions->second);
}
void DxvkOptions::adjustDeviceOptions(const Rc<DxvkAdapter>& adapter) {
}
void DxvkOptions::logOptions() const {
#define LOG_OPTION(opt) this->logOption(DxvkOption::opt, #opt)
LOG_OPTION(AssumeNoZfight);
#undef LOG_OPTION
}
void DxvkOptions::logOption(
DxvkOption option,
const std::string& name) const {
if (m_options.test(option))
Logger::info(str::format("Using option ", name));
}
}

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

@ -0,0 +1,81 @@
#pragma once
#include "dxvk_adapter.h"
namespace dxvk {
/**
* \brief App- and driver-specific options
*/
enum class DxvkOption : uint64_t {
/// Assume that the application will not render
/// multiple polygons with the exact same depth
/// value. Allows out-of-order rasterization to
/// be enabled for more rendering modes.
AssumeNoZfight = 0,
};
using DxvkOptionSet = Flags<DxvkOption>;
/**
* \brief Option collection
*
* Stores the options enabled for a given
* device when running a given application.
*/
class DxvkOptions {
public:
/**
* \brief Checks whether an option is enabled
* \returns \c true if the option is enabled
*/
bool test(DxvkOption opt) const {
return m_options.test(opt);
}
/**
* \brief Sets app-specific options
*
* Application bugs and performance characteristics
* may require workarounds to be enabled, or allow
* for certain non-standard optimizations to be used.
* \param [in] appName Application name
* \returns Application options
*/
void adjustAppOptions(
const std::string& appName);
/**
* \brief Adjusts options for a specific driver
*
* Driver bugs and performance characteristics may
* require some options to be enabled or disabled.
* \param [in] options Application options
* \param [in] adapter The adapter
* \returns Device options
*/
void adjustDeviceOptions(
const Rc<DxvkAdapter>& adapter);
/**
* \brief Logs enabled options
*
* Informs the user about any options that
* are enabled. May help with debugging.
*/
void logOptions() const;
private:
DxvkOptionSet m_options = { 0ull };
void logOption(
DxvkOption option,
const std::string& name) const;
};
}

View File

@ -23,6 +23,7 @@ dxvk_src = files([
'dxvk_lifetime.cpp',
'dxvk_main.cpp',
'dxvk_memory.cpp',
'dxvk_options.cpp',
'dxvk_pipecache.cpp',
'dxvk_pipelayout.cpp',
'dxvk_pipemanager.cpp',

View File

@ -28,11 +28,19 @@ namespace dxvk {
m_bits |= bits(fx...);
}
void set(Flags flags) {
m_bits |= flags.m_bits;
}
template<typename... Tx>
void clr(Tx... fx) {
m_bits &= ~bits(fx...);
}
void clr(Flags flags) {
m_bits &= ~flags.m_bits;
}
template<typename... Tx>
bool any(Tx... fx) const {
return (m_bits & bits(fx...)) != 0;