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

[dxbc] Always use raw storage buffers if alignment requirements are met

This commit is contained in:
Philip Rebohle 2019-06-05 01:09:39 +02:00
parent 163e6aaa50
commit 0f7c23c022
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 19 additions and 5 deletions

View File

@ -1076,7 +1076,11 @@ namespace dxvk {
? computeUavBinding(m_programInfo.type(), registerId)
: computeSrvBinding(m_programInfo.type(), registerId);
if (m_moduleInfo.options.useRawSsbo) {
// Test whether we should use a raw SSBO for this resource
bool useRawSsbo = m_moduleInfo.options.useRawSsbo
&& m_moduleInfo.options.minSsboAlignment <= resAlign;
if (useRawSsbo) {
uint32_t elemType = getScalarTypeId(DxbcScalarType::Uint32);
uint32_t arrayType = m_module.defRuntimeArrayTypeUnique(elemType);
uint32_t structType = m_module.defStructTypeUnique(1, &arrayType);
@ -1159,7 +1163,7 @@ namespace dxvk {
// Store descriptor info for the shader interface
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = m_moduleInfo.options.useRawSsbo
resource.type = useRawSsbo
? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
: (isUav
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
@ -2693,7 +2697,8 @@ namespace dxvk {
const DxbcBufferInfo bufferInfo = getBufferInfo(ins.src[0]);
bool isSsbo = m_moduleInfo.options.useRawSsbo
&& bufferInfo.type != DxbcResourceType::Typed;
&& m_moduleInfo.options.minSsboAlignment <= bufferInfo.align
&& bufferInfo.type != DxbcResourceType::Typed;
// We'll store this as a scalar unsigned integer
DxbcRegisterValue result = isSsbo
@ -4835,6 +4840,7 @@ namespace dxvk {
// of obtaining the final pointer are used.
bool isTgsm = operand.type == DxbcOperandType::ThreadGroupSharedMemory;
bool isSsbo = m_moduleInfo.options.useRawSsbo
&& m_moduleInfo.options.minSsboAlignment <= resourceInfo.align
&& resourceInfo.type != DxbcResourceType::Typed
&& !isTgsm;
@ -4899,7 +4905,9 @@ namespace dxvk {
// Shared memory is the only type of buffer that
// is not accessed through a texel buffer view
bool isTgsm = operand.type == DxbcOperandType::ThreadGroupSharedMemory;
bool isSsbo = m_moduleInfo.options.useRawSsbo && !isTgsm;
bool isSsbo = m_moduleInfo.options.useRawSsbo
&& m_moduleInfo.options.minSsboAlignment <= bufferInfo.align
&& !isTgsm;
// Common types and IDs used while loading the data
uint32_t bufferId = isTgsm || isSsbo ? 0 : m_module.opLoad(bufferInfo.typeId, bufferInfo.varId);
@ -4985,7 +4993,9 @@ namespace dxvk {
// Thread Group Shared Memory is not accessed through a texel buffer view
bool isTgsm = operand.type == DxbcOperandType::ThreadGroupSharedMemory;
bool isSsbo = m_moduleInfo.options.useRawSsbo && !isTgsm;
bool isSsbo = m_moduleInfo.options.useRawSsbo
&& m_moduleInfo.options.minSsboAlignment <= bufferInfo.align
&& !isTgsm;
// Perform UAV writes only if the UAV is bound and if there
// is nothing else preventing us from writing to it.

View File

@ -32,6 +32,7 @@ namespace dxvk {
= (devInfo.core.properties.limits.minStorageBufferOffsetAlignment <= sizeof(uint32_t));
useSdivForBufferIndex
= adapter->matchesDriver(DxvkGpuVendor::Nvidia, VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR, 0, 0);
minSsboAlignment = devInfo.core.properties.limits.minStorageBufferOffsetAlignment;
strictDivision = options.strictDivision;
zeroInitWorkgroupMemory = options.zeroInitWorkgroupMemory;

View File

@ -42,6 +42,9 @@ namespace dxvk {
/// Clear thread-group shared memory to zero
bool zeroInitWorkgroupMemory = false;
/// Minimum storage buffer alignment
VkDeviceSize minSsboAlignment = 0;
};
}