2023-05-20 13:47:10 +02:00
|
|
|
#include "../util/util_math.h"
|
|
|
|
|
2019-12-16 04:28:01 +01:00
|
|
|
#include "d3d9_options.h"
|
|
|
|
|
|
|
|
#include "d3d9_caps.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
|
|
|
static int32_t parsePciId(const std::string& str) {
|
|
|
|
if (str.size() != 4)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
int32_t id = 0;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < str.size(); i++) {
|
|
|
|
id *= 16;
|
|
|
|
|
|
|
|
if (str[i] >= '0' && str[i] <= '9')
|
|
|
|
id += str[i] - '0';
|
|
|
|
else if (str[i] >= 'A' && str[i] <= 'F')
|
|
|
|
id += str[i] - 'A' + 10;
|
|
|
|
else if (str[i] >= 'a' && str[i] <= 'f')
|
|
|
|
id += str[i] - 'a' + 10;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
D3D9Options::D3D9Options(const Rc<DxvkDevice>& device, const Config& config) {
|
|
|
|
const Rc<DxvkAdapter> adapter = device != nullptr ? device->adapter() : nullptr;
|
|
|
|
|
|
|
|
// Fetch these as a string representing a hexadecimal number and parse it.
|
|
|
|
this->customVendorId = parsePciId(config.getOption<std::string>("d3d9.customVendorId"));
|
|
|
|
this->customDeviceId = parsePciId(config.getOption<std::string>("d3d9.customDeviceId"));
|
2021-02-27 21:35:37 +01:00
|
|
|
this->customDeviceDesc = config.getOption<std::string>("d3d9.customDeviceDesc");
|
|
|
|
|
|
|
|
const int32_t vendorId = this->customDeviceId != -1
|
|
|
|
? this->customDeviceId
|
|
|
|
: (adapter != nullptr ? adapter->deviceProperties().vendorID : 0);
|
|
|
|
|
|
|
|
this->maxFrameLatency = config.getOption<int32_t> ("d3d9.maxFrameLatency", 0);
|
2021-06-09 08:05:55 +02:00
|
|
|
this->maxFrameRate = config.getOption<int32_t> ("d3d9.maxFrameRate", 0);
|
2021-02-27 21:35:37 +01:00
|
|
|
this->presentInterval = config.getOption<int32_t> ("d3d9.presentInterval", -1);
|
|
|
|
this->shaderModel = config.getOption<int32_t> ("d3d9.shaderModel", 3);
|
|
|
|
this->dpiAware = config.getOption<bool> ("d3d9.dpiAware", true);
|
|
|
|
this->strictConstantCopies = config.getOption<bool> ("d3d9.strictConstantCopies", false);
|
|
|
|
this->strictPow = config.getOption<bool> ("d3d9.strictPow", true);
|
|
|
|
this->lenientClear = config.getOption<bool> ("d3d9.lenientClear", false);
|
|
|
|
this->numBackBuffers = config.getOption<int32_t> ("d3d9.numBackBuffers", 0);
|
|
|
|
this->deferSurfaceCreation = config.getOption<bool> ("d3d9.deferSurfaceCreation", false);
|
|
|
|
this->samplerAnisotropy = config.getOption<int32_t> ("d3d9.samplerAnisotropy", -1);
|
|
|
|
this->maxAvailableMemory = config.getOption<int32_t> ("d3d9.maxAvailableMemory", 4096);
|
|
|
|
this->supportDFFormats = config.getOption<bool> ("d3d9.supportDFFormats", true);
|
|
|
|
this->supportX4R4G4B4 = config.getOption<bool> ("d3d9.supportX4R4G4B4", true);
|
|
|
|
this->supportD32 = config.getOption<bool> ("d3d9.supportD32", true);
|
2022-09-26 10:41:21 +02:00
|
|
|
this->useD32forD24 = config.getOption<bool> ("d3d9.useD32forD24", false);
|
2021-02-27 21:35:37 +01:00
|
|
|
this->disableA8RT = config.getOption<bool> ("d3d9.disableA8RT", false);
|
2022-04-09 13:40:46 +02:00
|
|
|
this->invariantPosition = config.getOption<bool> ("d3d9.invariantPosition", true);
|
2021-02-27 21:35:37 +01:00
|
|
|
this->memoryTrackTest = config.getOption<bool> ("d3d9.memoryTrackTest", false);
|
|
|
|
this->supportVCache = config.getOption<bool> ("d3d9.supportVCache", vendorId == 0x10de);
|
|
|
|
this->enableDialogMode = config.getOption<bool> ("d3d9.enableDialogMode", false);
|
|
|
|
this->forceSamplerTypeSpecConstants = config.getOption<bool> ("d3d9.forceSamplerTypeSpecConstants", false);
|
|
|
|
this->forceSwapchainMSAA = config.getOption<int32_t> ("d3d9.forceSwapchainMSAA", -1);
|
2023-01-08 01:05:50 +01:00
|
|
|
this->forceSampleRateShading = config.getOption<bool> ("d3d9.forceSampleRateShading", false);
|
2021-02-27 21:35:37 +01:00
|
|
|
this->forceAspectRatio = config.getOption<std::string> ("d3d9.forceAspectRatio", "");
|
|
|
|
this->enumerateByDisplays = config.getOption<bool> ("d3d9.enumerateByDisplays", true);
|
|
|
|
this->longMad = config.getOption<bool> ("d3d9.longMad", false);
|
2023-05-26 12:33:36 +02:00
|
|
|
this->cachedDynamicBuffers = config.getOption<bool> ("d3d9.cachedDynamicBuffers", false);
|
2021-02-27 21:35:37 +01:00
|
|
|
this->deviceLocalConstantBuffers = config.getOption<bool> ("d3d9.deviceLocalConstantBuffers", false);
|
2022-01-26 17:25:24 +01:00
|
|
|
this->allowDirectBufferMapping = config.getOption<bool> ("d3d9.allowDirectBufferMapping", true);
|
2022-07-05 17:24:46 +02:00
|
|
|
this->seamlessCubes = config.getOption<bool> ("d3d9.seamlessCubes", false);
|
2023-06-10 01:18:05 +02:00
|
|
|
this->textureMemory = config.getOption<int32_t> ("d3d9.textureMemory", 100) << 20;
|
|
|
|
this->deviceLossOnFocusLoss = config.getOption<bool> ("d3d9.deviceLossOnFocusLoss", false);
|
2023-05-20 13:47:10 +02:00
|
|
|
this->samplerLodBias = config.getOption<float> ("d3d9.samplerLodBias", 0.0f);
|
|
|
|
|
|
|
|
// Clamp LOD bias so that people don't abuse this in unintended ways
|
|
|
|
this->samplerLodBias = dxvk::fclamp(this->samplerLodBias, -2.0f, 1.0f);
|
2021-02-27 20:29:52 +01:00
|
|
|
|
2022-01-21 00:41:08 +01:00
|
|
|
std::string floatEmulation = Config::toLower(config.getOption<std::string>("d3d9.floatEmulation", "auto"));
|
2021-09-02 22:46:35 +02:00
|
|
|
if (floatEmulation == "strict") {
|
2022-01-21 00:41:08 +01:00
|
|
|
d3d9FloatEmulation = D3D9FloatEmulation::Strict;
|
2021-09-02 22:46:35 +02:00
|
|
|
} else if (floatEmulation == "false") {
|
2022-01-21 00:41:08 +01:00
|
|
|
d3d9FloatEmulation = D3D9FloatEmulation::Disabled;
|
|
|
|
} else if (floatEmulation == "true") {
|
|
|
|
d3d9FloatEmulation = D3D9FloatEmulation::Enabled;
|
2021-09-02 22:46:35 +02:00
|
|
|
} else {
|
2022-01-21 15:40:06 +01:00
|
|
|
bool hasMulz = adapter != nullptr
|
2022-07-14 20:30:39 +02:00
|
|
|
&& adapter->matchesDriver(VK_DRIVER_ID_MESA_RADV, 0, 0);
|
2022-01-21 00:41:08 +01:00
|
|
|
d3d9FloatEmulation = hasMulz ? D3D9FloatEmulation::Strict : D3D9FloatEmulation::Enabled;
|
2021-09-02 22:46:35 +02:00
|
|
|
}
|
2022-10-24 18:01:48 +02:00
|
|
|
|
|
|
|
this->shaderDumpPath = env::getEnvVar("DXVK_SHADER_DUMP_PATH");
|
2019-12-16 04:28:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|