mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-29 10:24:10 +01:00
[dxbc] Refactor DxbcOptions
A bit mask isn't good enough going forward, and we also don't need application-specific options for now.
This commit is contained in:
parent
ab3ba776e0
commit
bd03225c14
@ -103,8 +103,7 @@ namespace dxvk {
|
||||
m_dxvkDevice (pDxgiDevice->GetDXVKDevice()),
|
||||
m_dxvkAdapter (m_dxvkDevice->adapter()),
|
||||
m_d3d11Options (m_dxvkAdapter->instance()->config()),
|
||||
m_dxbcOptions (getDxbcAppOptions(env::getExeName()) |
|
||||
getDxbcDeviceOptions(m_dxvkDevice)) {
|
||||
m_dxbcOptions (m_dxvkDevice) {
|
||||
Com<IDXGIAdapter> adapter;
|
||||
|
||||
if (FAILED(pDxgiDevice->GetAdapter(&adapter))
|
||||
|
@ -852,7 +852,7 @@ namespace dxvk {
|
||||
const bool isUav = ins.op == DxbcOpcode::DclUavTyped;
|
||||
|
||||
if (isUav) {
|
||||
if (m_moduleInfo.options.test(DxbcOption::UseStorageImageReadWithoutFormat))
|
||||
if (m_moduleInfo.options.useStorageImageReadWithoutFormat)
|
||||
m_module.enableCapability(spv::CapabilityStorageImageReadWithoutFormat);
|
||||
m_module.enableCapability(spv::CapabilityStorageImageWriteWithoutFormat);
|
||||
}
|
||||
@ -913,7 +913,7 @@ namespace dxvk {
|
||||
if (isUav) {
|
||||
if ((m_analysis->uavInfos[registerId].accessAtomicOp)
|
||||
|| (m_analysis->uavInfos[registerId].accessTypedLoad
|
||||
&& !m_moduleInfo.options.test(DxbcOption::UseStorageImageReadWithoutFormat)))
|
||||
&& !m_moduleInfo.options.useStorageImageReadWithoutFormat))
|
||||
imageFormat = getScalarImageFormat(sampledType);
|
||||
}
|
||||
|
||||
@ -952,7 +952,7 @@ namespace dxvk {
|
||||
// On GPUs which don't support storageImageReadWithoutFormat,
|
||||
// we have to decorate untyped UAVs as write-only
|
||||
if (isUav && imageFormat == spv::ImageFormatUnknown
|
||||
&& !m_moduleInfo.options.test(DxbcOption::UseStorageImageReadWithoutFormat))
|
||||
&& !m_moduleInfo.options.useStorageImageReadWithoutFormat)
|
||||
m_module.decorate(varId, spv::DecorationNonReadable);
|
||||
|
||||
// Declare a specialization constant which will
|
||||
@ -6147,7 +6147,7 @@ namespace dxvk {
|
||||
|
||||
// We may have to defer kill operations to the end of
|
||||
// the shader in order to keep derivatives correct.
|
||||
if (m_analysis->usesKill && m_analysis->usesDerivatives && m_moduleInfo.options.test(DxbcOption::DeferKill)) {
|
||||
if (m_analysis->usesKill && m_analysis->usesDerivatives && m_moduleInfo.options.deferKill) {
|
||||
m_ps.killState = m_module.newVarInit(
|
||||
m_module.defPointerType(m_module.defBoolType(), spv::StorageClassPrivate),
|
||||
spv::StorageClassPrivate, m_module.constBool(false));
|
||||
|
@ -4,30 +4,16 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
const static std::unordered_map<std::string, DxbcOptions> g_dxbcAppOptions = {{
|
||||
|
||||
}};
|
||||
|
||||
|
||||
DxbcOptions getDxbcAppOptions(const std::string& appName) {
|
||||
auto appOptions = g_dxbcAppOptions.find(appName);
|
||||
|
||||
return appOptions != g_dxbcAppOptions.end()
|
||||
? appOptions->second
|
||||
: DxbcOptions();
|
||||
DxbcOptions::DxbcOptions() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
DxbcOptions getDxbcDeviceOptions(const Rc<DxvkDevice>& device) {
|
||||
DxbcOptions flags;
|
||||
|
||||
|
||||
|
||||
DxbcOptions::DxbcOptions(const Rc<DxvkDevice>& device) {
|
||||
const DxvkDeviceFeatures& devFeatures = device->features();
|
||||
|
||||
if (devFeatures.core.features.shaderStorageImageReadWithoutFormat)
|
||||
flags.set(DxbcOption::UseStorageImageReadWithoutFormat);
|
||||
|
||||
flags.set(DxbcOption::DeferKill);
|
||||
return flags;
|
||||
|
||||
useStorageImageReadWithoutFormat = devFeatures.core.features.shaderStorageImageReadWithoutFormat;
|
||||
deferKill = true;
|
||||
}
|
||||
|
||||
}
|
@ -4,33 +4,18 @@
|
||||
|
||||
namespace dxvk {
|
||||
|
||||
enum class DxbcOption : uint64_t {
|
||||
struct DxbcOptions {
|
||||
DxbcOptions();
|
||||
DxbcOptions(const Rc<DxvkDevice>& device);
|
||||
|
||||
/// Use the ShaderImageReadWithoutFormat capability.
|
||||
/// Enabled by default on GPUs which support this.
|
||||
UseStorageImageReadWithoutFormat,
|
||||
bool useStorageImageReadWithoutFormat = false;
|
||||
|
||||
/// Defer kill operation to the end of the shader.
|
||||
/// Fixes derivatives that are undefined due to
|
||||
/// non-uniform control flow in fragment shaders.
|
||||
DeferKill,
|
||||
bool deferKill = false;
|
||||
};
|
||||
|
||||
using DxbcOptions = Flags<DxbcOption>;
|
||||
|
||||
/**
|
||||
* \brief Gets app-specific DXBC options
|
||||
*
|
||||
* \param [in] appName Application name
|
||||
* \returns DXBC options for this application
|
||||
*/
|
||||
DxbcOptions getDxbcAppOptions(const std::string& appName);
|
||||
|
||||
/**
|
||||
* \brief Gets device-specific options
|
||||
*
|
||||
* \param [in] device The device
|
||||
* \returns Device options
|
||||
*/
|
||||
DxbcOptions getDxbcDeviceOptions(const Rc<DxvkDevice>& device);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user