mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-30 20:52:11 +01:00
[dxbc] Repurpose useRawSsbo option
Basically, abuse the minSsboAlignment property to convince the compiler to always/never emit raw SSBOs for raw and structured buffers, and use the actual device limit by default.
This commit is contained in:
parent
0f7c23c022
commit
d755b18ccb
@ -1077,8 +1077,7 @@ namespace dxvk {
|
|||||||
: computeSrvBinding(m_programInfo.type(), registerId);
|
: computeSrvBinding(m_programInfo.type(), registerId);
|
||||||
|
|
||||||
// Test whether we should use a raw SSBO for this resource
|
// Test whether we should use a raw SSBO for this resource
|
||||||
bool useRawSsbo = m_moduleInfo.options.useRawSsbo
|
bool useRawSsbo = m_moduleInfo.options.minSsboAlignment <= resAlign;
|
||||||
&& m_moduleInfo.options.minSsboAlignment <= resAlign;
|
|
||||||
|
|
||||||
if (useRawSsbo) {
|
if (useRawSsbo) {
|
||||||
uint32_t elemType = getScalarTypeId(DxbcScalarType::Uint32);
|
uint32_t elemType = getScalarTypeId(DxbcScalarType::Uint32);
|
||||||
@ -2696,8 +2695,7 @@ namespace dxvk {
|
|||||||
// (src0) The buffer register to query
|
// (src0) The buffer register to query
|
||||||
const DxbcBufferInfo bufferInfo = getBufferInfo(ins.src[0]);
|
const DxbcBufferInfo bufferInfo = getBufferInfo(ins.src[0]);
|
||||||
|
|
||||||
bool isSsbo = m_moduleInfo.options.useRawSsbo
|
bool isSsbo = m_moduleInfo.options.minSsboAlignment <= bufferInfo.align
|
||||||
&& m_moduleInfo.options.minSsboAlignment <= bufferInfo.align
|
|
||||||
&& bufferInfo.type != DxbcResourceType::Typed;
|
&& bufferInfo.type != DxbcResourceType::Typed;
|
||||||
|
|
||||||
// We'll store this as a scalar unsigned integer
|
// We'll store this as a scalar unsigned integer
|
||||||
@ -4839,8 +4837,7 @@ namespace dxvk {
|
|||||||
// For UAVs and shared memory, different methods
|
// For UAVs and shared memory, different methods
|
||||||
// of obtaining the final pointer are used.
|
// of obtaining the final pointer are used.
|
||||||
bool isTgsm = operand.type == DxbcOperandType::ThreadGroupSharedMemory;
|
bool isTgsm = operand.type == DxbcOperandType::ThreadGroupSharedMemory;
|
||||||
bool isSsbo = m_moduleInfo.options.useRawSsbo
|
bool isSsbo = m_moduleInfo.options.minSsboAlignment <= resourceInfo.align
|
||||||
&& m_moduleInfo.options.minSsboAlignment <= resourceInfo.align
|
|
||||||
&& resourceInfo.type != DxbcResourceType::Typed
|
&& resourceInfo.type != DxbcResourceType::Typed
|
||||||
&& !isTgsm;
|
&& !isTgsm;
|
||||||
|
|
||||||
@ -4905,8 +4902,7 @@ namespace dxvk {
|
|||||||
// Shared memory is the only type of buffer that
|
// Shared memory is the only type of buffer that
|
||||||
// is not accessed through a texel buffer view
|
// is not accessed through a texel buffer view
|
||||||
bool isTgsm = operand.type == DxbcOperandType::ThreadGroupSharedMemory;
|
bool isTgsm = operand.type == DxbcOperandType::ThreadGroupSharedMemory;
|
||||||
bool isSsbo = m_moduleInfo.options.useRawSsbo
|
bool isSsbo = m_moduleInfo.options.minSsboAlignment <= bufferInfo.align
|
||||||
&& m_moduleInfo.options.minSsboAlignment <= bufferInfo.align
|
|
||||||
&& !isTgsm;
|
&& !isTgsm;
|
||||||
|
|
||||||
// Common types and IDs used while loading the data
|
// Common types and IDs used while loading the data
|
||||||
@ -4993,8 +4989,7 @@ namespace dxvk {
|
|||||||
|
|
||||||
// Thread Group Shared Memory is not accessed through a texel buffer view
|
// Thread Group Shared Memory is not accessed through a texel buffer view
|
||||||
bool isTgsm = operand.type == DxbcOperandType::ThreadGroupSharedMemory;
|
bool isTgsm = operand.type == DxbcOperandType::ThreadGroupSharedMemory;
|
||||||
bool isSsbo = m_moduleInfo.options.useRawSsbo
|
bool isSsbo = m_moduleInfo.options.minSsboAlignment <= bufferInfo.align
|
||||||
&& m_moduleInfo.options.minSsboAlignment <= bufferInfo.align
|
|
||||||
&& !isTgsm;
|
&& !isTgsm;
|
||||||
|
|
||||||
// Perform UAV writes only if the UAV is bound and if there
|
// Perform UAV writes only if the UAV is bound and if there
|
||||||
|
@ -28,11 +28,14 @@ namespace dxvk {
|
|||||||
= (devInfo.coreSubgroup.subgroupSize >= 4)
|
= (devInfo.coreSubgroup.subgroupSize >= 4)
|
||||||
&& (devInfo.coreSubgroup.supportedStages & VK_SHADER_STAGE_FRAGMENT_BIT)
|
&& (devInfo.coreSubgroup.supportedStages & VK_SHADER_STAGE_FRAGMENT_BIT)
|
||||||
&& (devInfo.coreSubgroup.supportedOperations & VK_SUBGROUP_FEATURE_BALLOT_BIT);
|
&& (devInfo.coreSubgroup.supportedOperations & VK_SUBGROUP_FEATURE_BALLOT_BIT);
|
||||||
useRawSsbo
|
|
||||||
= (devInfo.core.properties.limits.minStorageBufferOffsetAlignment <= sizeof(uint32_t));
|
|
||||||
useSdivForBufferIndex
|
useSdivForBufferIndex
|
||||||
= adapter->matchesDriver(DxvkGpuVendor::Nvidia, VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR, 0, 0);
|
= adapter->matchesDriver(DxvkGpuVendor::Nvidia, VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR, 0, 0);
|
||||||
minSsboAlignment = devInfo.core.properties.limits.minStorageBufferOffsetAlignment;
|
|
||||||
|
switch (device->config().useRawSsbo) {
|
||||||
|
case Tristate::Auto: minSsboAlignment = devInfo.core.properties.limits.minStorageBufferOffsetAlignment; break;
|
||||||
|
case Tristate::True: minSsboAlignment = 4u;
|
||||||
|
case Tristate::False: minSsboAlignment = ~0u;
|
||||||
|
}
|
||||||
|
|
||||||
strictDivision = options.strictDivision;
|
strictDivision = options.strictDivision;
|
||||||
zeroInitWorkgroupMemory = options.zeroInitWorkgroupMemory;
|
zeroInitWorkgroupMemory = options.zeroInitWorkgroupMemory;
|
||||||
@ -48,7 +51,6 @@ namespace dxvk {
|
|||||||
|
|
||||||
// Apply shader-related options
|
// Apply shader-related options
|
||||||
applyTristate(useSubgroupOpsForEarlyDiscard, device->config().useEarlyDiscard);
|
applyTristate(useSubgroupOpsForEarlyDiscard, device->config().useEarlyDiscard);
|
||||||
applyTristate(useRawSsbo, device->config().useRawSsbo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -25,10 +25,6 @@ namespace dxvk {
|
|||||||
/// shader invocations if derivatives remain valid.
|
/// shader invocations if derivatives remain valid.
|
||||||
bool useSubgroupOpsForEarlyDiscard = false;
|
bool useSubgroupOpsForEarlyDiscard = false;
|
||||||
|
|
||||||
/// Use SSBOs instead of texel buffers
|
|
||||||
/// for raw and structured buffers.
|
|
||||||
bool useRawSsbo = false;
|
|
||||||
|
|
||||||
/// Use SDiv instead of SHR to converte byte offsets to
|
/// Use SDiv instead of SHR to converte byte offsets to
|
||||||
/// dword offsets. Fixes RE2 and DMC5 on Nvidia drivers.
|
/// dword offsets. Fixes RE2 and DMC5 on Nvidia drivers.
|
||||||
bool useSdivForBufferIndex = false;
|
bool useSdivForBufferIndex = false;
|
||||||
|
@ -44,7 +44,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
|
|||||||
DxbcModuleInfo moduleInfo;
|
DxbcModuleInfo moduleInfo;
|
||||||
moduleInfo.options.useSubgroupOpsForAtomicCounters = true;
|
moduleInfo.options.useSubgroupOpsForAtomicCounters = true;
|
||||||
moduleInfo.options.useSubgroupOpsForEarlyDiscard = true;
|
moduleInfo.options.useSubgroupOpsForEarlyDiscard = true;
|
||||||
moduleInfo.options.useRawSsbo = true;
|
moduleInfo.options.minSsboAlignment = 4;
|
||||||
moduleInfo.xfb = nullptr;
|
moduleInfo.xfb = nullptr;
|
||||||
|
|
||||||
Rc<DxvkShader> shader = module.compile(moduleInfo, ifileName);
|
Rc<DxvkShader> shader = module.compile(moduleInfo, ifileName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user