mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxbc] Set float control bits as necessary
This commit is contained in:
parent
849fb329ec
commit
f5fa7a9099
@ -235,6 +235,9 @@ namespace dxvk {
|
|||||||
case DxbcProgramType::PixelShader: this->emitPsFinalize(); break;
|
case DxbcProgramType::PixelShader: this->emitPsFinalize(); break;
|
||||||
case DxbcProgramType::ComputeShader: this->emitCsFinalize(); break;
|
case DxbcProgramType::ComputeShader: this->emitCsFinalize(); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Emit float control mode if the extension is supported
|
||||||
|
this->emitFloatControl();
|
||||||
|
|
||||||
// Declare the entry point, we now have all the
|
// Declare the entry point, we now have all the
|
||||||
// information we need, including the interfaces
|
// information we need, including the interfaces
|
||||||
@ -7467,7 +7470,32 @@ namespace dxvk {
|
|||||||
return varId;
|
return varId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxbcCompiler::emitFloatControl() {
|
||||||
|
DxbcFloatControlFlags flags = m_moduleInfo.options.floatControl;
|
||||||
|
|
||||||
|
if (flags.isClear())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const uint32_t width32 = 32;
|
||||||
|
const uint32_t width64 = 64;
|
||||||
|
|
||||||
|
m_module.enableExtension("SPV_KHR_float_controls");
|
||||||
|
|
||||||
|
if (flags.test(DxbcFloatControlFlag::DenormFlushToZero32))
|
||||||
|
m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeDenormFlushToZero, 1, &width32);
|
||||||
|
|
||||||
|
if (flags.test(DxbcFloatControlFlag::DenormPreserve64))
|
||||||
|
m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeDenormPreserve, 1, &width64);
|
||||||
|
|
||||||
|
if (flags.test(DxbcFloatControlFlag::PreserveNan32))
|
||||||
|
m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeSignedZeroInfNanPreserve, 1, &width32);
|
||||||
|
|
||||||
|
if (flags.test(DxbcFloatControlFlag::PreserveNan64))
|
||||||
|
m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeSignedZeroInfNanPreserve, 1, &width64);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t DxbcCompiler::emitNewVariable(const DxbcRegisterInfo& info) {
|
uint32_t DxbcCompiler::emitNewVariable(const DxbcRegisterInfo& info) {
|
||||||
const uint32_t ptrTypeId = this->getPointerTypeId(info);
|
const uint32_t ptrTypeId = this->getPointerTypeId(info);
|
||||||
return m_module.newVar(ptrTypeId, info.sclass);
|
return m_module.newVar(ptrTypeId, info.sclass);
|
||||||
|
@ -1173,6 +1173,8 @@ namespace dxvk {
|
|||||||
|
|
||||||
uint32_t emitSamplePosArray();
|
uint32_t emitSamplePosArray();
|
||||||
|
|
||||||
|
void emitFloatControl();
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// Variable definition methods
|
// Variable definition methods
|
||||||
uint32_t emitNewVariable(
|
uint32_t emitNewVariable(
|
||||||
|
@ -57,6 +57,19 @@ namespace dxvk {
|
|||||||
|
|
||||||
// Apply shader-related options
|
// Apply shader-related options
|
||||||
applyTristate(useSubgroupOpsForEarlyDiscard, device->config().useEarlyDiscard);
|
applyTristate(useSubgroupOpsForEarlyDiscard, device->config().useEarlyDiscard);
|
||||||
|
|
||||||
|
// Figure out float control flags to match D3D11 rules
|
||||||
|
if (devInfo.khrShaderFloatControls.shaderSignedZeroInfNanPreserveFloat32)
|
||||||
|
floatControl.set(DxbcFloatControlFlag::PreserveNan32);
|
||||||
|
if (devInfo.khrShaderFloatControls.shaderSignedZeroInfNanPreserveFloat64)
|
||||||
|
floatControl.set(DxbcFloatControlFlag::PreserveNan64);
|
||||||
|
|
||||||
|
if (devInfo.khrShaderFloatControls.denormBehaviorIndependence != VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE) {
|
||||||
|
if (devInfo.khrShaderFloatControls.shaderDenormFlushToZeroFloat32)
|
||||||
|
floatControl.set(DxbcFloatControlFlag::DenormFlushToZero32);
|
||||||
|
if (devInfo.khrShaderFloatControls.shaderDenormPreserveFloat64)
|
||||||
|
floatControl.set(DxbcFloatControlFlag::DenormPreserve64);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -5,7 +5,16 @@
|
|||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
struct D3D11Options;
|
struct D3D11Options;
|
||||||
|
|
||||||
|
enum class DxbcFloatControlFlag : uint32_t {
|
||||||
|
DenormFlushToZero32,
|
||||||
|
DenormPreserve64,
|
||||||
|
PreserveNan32,
|
||||||
|
PreserveNan64,
|
||||||
|
};
|
||||||
|
|
||||||
|
using DxbcFloatControlFlags = Flags<DxbcFloatControlFlag>;
|
||||||
|
|
||||||
struct DxbcOptions {
|
struct DxbcOptions {
|
||||||
DxbcOptions();
|
DxbcOptions();
|
||||||
DxbcOptions(const Rc<DxvkDevice>& device, const D3D11Options& options);
|
DxbcOptions(const Rc<DxvkDevice>& device, const D3D11Options& options);
|
||||||
@ -48,6 +57,9 @@ namespace dxvk {
|
|||||||
/// Insert memory barriers after TGSM stoes
|
/// Insert memory barriers after TGSM stoes
|
||||||
bool forceTgsmBarriers = false;
|
bool forceTgsmBarriers = false;
|
||||||
|
|
||||||
|
/// Float control flags
|
||||||
|
DxbcFloatControlFlags floatControl;
|
||||||
|
|
||||||
/// Minimum storage buffer alignment
|
/// Minimum storage buffer alignment
|
||||||
VkDeviceSize minSsboAlignment = 0;
|
VkDeviceSize minSsboAlignment = 0;
|
||||||
};
|
};
|
||||||
|
@ -93,6 +93,20 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SpirvModule::setExecutionMode(
|
||||||
|
uint32_t entryPointId,
|
||||||
|
spv::ExecutionMode executionMode,
|
||||||
|
uint32_t argCount,
|
||||||
|
const uint32_t* args) {
|
||||||
|
m_execModeInfo.putIns (spv::OpExecutionMode, 3 + argCount);
|
||||||
|
m_execModeInfo.putWord(entryPointId);
|
||||||
|
m_execModeInfo.putWord(executionMode);
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < argCount; i++)
|
||||||
|
m_execModeInfo.putWord(args[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SpirvModule::setInvocations(
|
void SpirvModule::setInvocations(
|
||||||
uint32_t entryPointId,
|
uint32_t entryPointId,
|
||||||
uint32_t invocations) {
|
uint32_t invocations) {
|
||||||
|
@ -86,6 +86,12 @@ namespace dxvk {
|
|||||||
uint32_t entryPointId,
|
uint32_t entryPointId,
|
||||||
spv::ExecutionMode executionMode);
|
spv::ExecutionMode executionMode);
|
||||||
|
|
||||||
|
void setExecutionMode(
|
||||||
|
uint32_t entryPointId,
|
||||||
|
spv::ExecutionMode executionMode,
|
||||||
|
uint32_t argCount,
|
||||||
|
const uint32_t* args);
|
||||||
|
|
||||||
void setInvocations(
|
void setInvocations(
|
||||||
uint32_t entryPointId,
|
uint32_t entryPointId,
|
||||||
uint32_t invocations);
|
uint32_t invocations);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user