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:
parent
3fff5d56b3
commit
a0de90861c
@ -800,6 +800,7 @@ namespace dxvk {
|
|||||||
resource.slot = bindingId;
|
resource.slot = bindingId;
|
||||||
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||||
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
|
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
|
||||||
|
resource.access = VK_ACCESS_UNIFORM_READ_BIT;
|
||||||
m_resourceSlots.push_back(resource);
|
m_resourceSlots.push_back(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -836,6 +837,7 @@ namespace dxvk {
|
|||||||
resource.slot = bindingId;
|
resource.slot = bindingId;
|
||||||
resource.type = VK_DESCRIPTOR_TYPE_SAMPLER;
|
resource.type = VK_DESCRIPTOR_TYPE_SAMPLER;
|
||||||
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
|
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
|
||||||
|
resource.access = 0;
|
||||||
m_resourceSlots.push_back(resource);
|
m_resourceSlots.push_back(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1008,11 +1010,13 @@ namespace dxvk {
|
|||||||
DxvkResourceSlot resource;
|
DxvkResourceSlot resource;
|
||||||
resource.slot = bindingId;
|
resource.slot = bindingId;
|
||||||
resource.view = typeInfo.vtype;
|
resource.view = typeInfo.vtype;
|
||||||
|
resource.access = VK_ACCESS_SHADER_READ_BIT;
|
||||||
|
|
||||||
if (isUav) {
|
if (isUav) {
|
||||||
resource.type = resourceType == DxbcResourceDim::Buffer
|
resource.type = resourceType == DxbcResourceDim::Buffer
|
||||||
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
|
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
|
||||||
: VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
|
: VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
|
||||||
|
resource.access |= VK_ACCESS_SHADER_WRITE_BIT;
|
||||||
} else {
|
} else {
|
||||||
resource.type = resourceType == DxbcResourceDim::Buffer
|
resource.type = resourceType == DxbcResourceDim::Buffer
|
||||||
? VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
|
? VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
|
||||||
@ -1121,6 +1125,11 @@ namespace dxvk {
|
|||||||
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
|
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
|
||||||
: VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
: VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
|
||||||
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
|
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);
|
m_resourceSlots.push_back(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1357,6 +1366,8 @@ namespace dxvk {
|
|||||||
resource.slot = bindingId;
|
resource.slot = bindingId;
|
||||||
resource.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
resource.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
|
||||||
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
|
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);
|
m_resourceSlots.push_back(resource);
|
||||||
|
|
||||||
return varId;
|
return varId;
|
||||||
|
@ -13,17 +13,20 @@ namespace dxvk {
|
|||||||
uint32_t slot,
|
uint32_t slot,
|
||||||
VkDescriptorType type,
|
VkDescriptorType type,
|
||||||
VkImageViewType view,
|
VkImageViewType view,
|
||||||
VkShaderStageFlagBits stage) {
|
VkShaderStageFlagBits stage,
|
||||||
|
VkAccessFlags access) {
|
||||||
uint32_t bindingId = this->getBindingId(slot);
|
uint32_t bindingId = this->getBindingId(slot);
|
||||||
|
|
||||||
if (bindingId != InvalidBinding) {
|
if (bindingId != InvalidBinding) {
|
||||||
m_descriptorSlots[bindingId].stages |= stage;
|
m_descriptorSlots[bindingId].stages |= stage;
|
||||||
|
m_descriptorSlots[bindingId].access |= access;
|
||||||
} else {
|
} else {
|
||||||
DxvkDescriptorSlot slotInfo;
|
DxvkDescriptorSlot slotInfo;
|
||||||
slotInfo.slot = slot;
|
slotInfo.slot = slot;
|
||||||
slotInfo.type = type;
|
slotInfo.type = type;
|
||||||
slotInfo.view = view;
|
slotInfo.view = view;
|
||||||
slotInfo.stages = stage;
|
slotInfo.stages = stage;
|
||||||
|
slotInfo.access = access;
|
||||||
m_descriptorSlots.push_back(slotInfo);
|
m_descriptorSlots.push_back(slotInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ namespace dxvk {
|
|||||||
uint32_t slot;
|
uint32_t slot;
|
||||||
VkDescriptorType type;
|
VkDescriptorType type;
|
||||||
VkImageViewType view;
|
VkImageViewType view;
|
||||||
|
VkAccessFlags access;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,6 +31,7 @@ namespace dxvk {
|
|||||||
VkDescriptorType type; ///< Descriptor type (aka resource type)
|
VkDescriptorType type; ///< Descriptor type (aka resource type)
|
||||||
VkImageViewType view; ///< Compatible image view type
|
VkImageViewType view; ///< Compatible image view type
|
||||||
VkShaderStageFlags stages; ///< Stages that can use the resource
|
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] type Resource type
|
||||||
* \param [in] view Image view type
|
* \param [in] view Image view type
|
||||||
* \param [in] stage Shader stage
|
* \param [in] stage Shader stage
|
||||||
|
* \param [in] access Access flags
|
||||||
*/
|
*/
|
||||||
void defineSlot(
|
void defineSlot(
|
||||||
uint32_t slot,
|
uint32_t slot,
|
||||||
VkDescriptorType type,
|
VkDescriptorType type,
|
||||||
VkImageViewType view,
|
VkImageViewType view,
|
||||||
VkShaderStageFlagBits stage);
|
VkShaderStageFlagBits stage,
|
||||||
|
VkAccessFlags access);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Gets binding ID for a slot
|
* \brief Gets binding ID for a slot
|
||||||
@ -230,13 +234,7 @@ namespace dxvk {
|
|||||||
VkShaderStageFlags stages = 0;
|
VkShaderStageFlags stages = 0;
|
||||||
|
|
||||||
for (const auto& slot : m_bindingSlots) {
|
for (const auto& slot : m_bindingSlots) {
|
||||||
bool isStorageDescriptor =
|
if (slot.access & VK_ACCESS_SHADER_WRITE_BIT)
|
||||||
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)
|
|
||||||
stages |= slot.stages;
|
stages |= slot.stages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ namespace dxvk {
|
|||||||
void DxvkShader::defineResourceSlots(
|
void DxvkShader::defineResourceSlots(
|
||||||
DxvkDescriptorSlotMapping& mapping) const {
|
DxvkDescriptorSlotMapping& mapping) const {
|
||||||
for (const auto& slot : m_slots)
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user