1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00

[dxvk] Store access flags in resource slots

Makes distinguishing read-only resources from read-write
resources significantly easier.
This commit is contained in:
Philip Rebohle 2018-12-13 14:40:38 +01:00
parent 3fff5d56b3
commit a0de90861c
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 22 additions and 10 deletions

View File

@ -800,6 +800,7 @@ namespace dxvk {
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_UNIFORM_READ_BIT;
m_resourceSlots.push_back(resource);
}
@ -836,6 +837,7 @@ namespace dxvk {
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_SAMPLER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = 0;
m_resourceSlots.push_back(resource);
}
@ -1008,11 +1010,13 @@ namespace dxvk {
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.view = typeInfo.vtype;
resource.access = VK_ACCESS_SHADER_READ_BIT;
if (isUav) {
resource.type = resourceType == DxbcResourceDim::Buffer
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
: VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
resource.access |= VK_ACCESS_SHADER_WRITE_BIT;
} else {
resource.type = resourceType == DxbcResourceDim::Buffer
? VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
@ -1121,6 +1125,11 @@ namespace dxvk {
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
: VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_SHADER_READ_BIT;
if (isUav)
resource.access |= VK_ACCESS_SHADER_WRITE_BIT;
m_resourceSlots.push_back(resource);
}
@ -1357,6 +1366,8 @@ namespace dxvk {
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_SHADER_READ_BIT
| VK_ACCESS_SHADER_WRITE_BIT;
m_resourceSlots.push_back(resource);
return varId;

View File

@ -13,17 +13,20 @@ namespace dxvk {
uint32_t slot,
VkDescriptorType type,
VkImageViewType view,
VkShaderStageFlagBits stage) {
VkShaderStageFlagBits stage,
VkAccessFlags access) {
uint32_t bindingId = this->getBindingId(slot);
if (bindingId != InvalidBinding) {
m_descriptorSlots[bindingId].stages |= stage;
m_descriptorSlots[bindingId].access |= access;
} else {
DxvkDescriptorSlot slotInfo;
slotInfo.slot = slot;
slotInfo.type = type;
slotInfo.view = view;
slotInfo.stages = stage;
slotInfo.access = access;
m_descriptorSlots.push_back(slotInfo);
}
}

View File

@ -16,6 +16,7 @@ namespace dxvk {
uint32_t slot;
VkDescriptorType type;
VkImageViewType view;
VkAccessFlags access;
};
/**
@ -30,6 +31,7 @@ namespace dxvk {
VkDescriptorType type; ///< Descriptor type (aka resource type)
VkImageViewType view; ///< Compatible image view type
VkShaderStageFlags stages; ///< Stages that can use the resource
VkAccessFlags access; ///< Access flags
};
@ -75,12 +77,14 @@ namespace dxvk {
* \param [in] type Resource type
* \param [in] view Image view type
* \param [in] stage Shader stage
* \param [in] access Access flags
*/
void defineSlot(
uint32_t slot,
VkDescriptorType type,
VkImageViewType view,
VkShaderStageFlagBits stage);
VkShaderStageFlagBits stage,
VkAccessFlags access);
/**
* \brief Gets binding ID for a slot
@ -230,13 +234,7 @@ namespace dxvk {
VkShaderStageFlags stages = 0;
for (const auto& slot : m_bindingSlots) {
bool isStorageDescriptor =
slot.type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER ||
slot.type == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC ||
slot.type == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER ||
slot.type == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
if (isStorageDescriptor)
if (slot.access & VK_ACCESS_SHADER_WRITE_BIT)
stages |= slot.stages;
}

View File

@ -133,7 +133,7 @@ namespace dxvk {
void DxvkShader::defineResourceSlots(
DxvkDescriptorSlotMapping& mapping) const {
for (const auto& slot : m_slots)
mapping.defineSlot(slot.slot, slot.type, slot.view, m_stage);
mapping.defineSlot(slot.slot, slot.type, slot.view, m_stage, slot.access);
}