Fix GPU particles on Vulkan

#478
This commit is contained in:
Wojtek Figat
2021-05-17 13:41:08 +02:00
parent ec806a2009
commit 0a25b71437
8 changed files with 74 additions and 20 deletions

View File

@@ -234,6 +234,13 @@ SpirvShaderResourceType GetTextureType(const glslang::TSampler& sampler)
}
}
bool IsUavType(const glslang::TType& type)
{
if (type.getQualifier().isReadOnly())
return false;
return (type.getBasicType() == glslang::EbtSampler && type.getSampler().isImage()) || (type.getQualifier().storage == glslang::EvqBuffer);
}
class DescriptorsCollector
{
public:
@@ -295,10 +302,20 @@ public:
}
else if (type.getSampler().dim == glslang::EsdBuffer)
{
// Buffer SRV
descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
resourceType = SpirvShaderResourceType::Buffer;
resourceBindingType = SpirvShaderResourceBindingType::SRV;
if (IsUavType(type))
{
// Buffer UAV
descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
resourceType = SpirvShaderResourceType::Buffer;
resourceBindingType = SpirvShaderResourceBindingType::UAV;
}
else
{
// Buffer SRV
descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
resourceType = SpirvShaderResourceType::Buffer;
resourceBindingType = SpirvShaderResourceBindingType::SRV;
}
}
else if (type.isTexture())
{