Fixes for Vulkan descriptors binding
This commit is contained in:
@@ -452,6 +452,7 @@ void GPUContextVulkan::UpdateDescriptorSets(const SpirvShaderDescriptorInfo& des
|
|||||||
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
case VK_DESCRIPTOR_TYPE_SAMPLER:
|
||||||
{
|
{
|
||||||
// Sampler
|
// Sampler
|
||||||
|
ASSERT_LOW_LAYER(slot < GPU_MAX_SAMPLER_BINDED);
|
||||||
const VkSampler sampler = _samplerHandles[slot];
|
const VkSampler sampler = _samplerHandles[slot];
|
||||||
ASSERT(sampler);
|
ASSERT(sampler);
|
||||||
needsWrite |= dsWriter.WriteSampler(descriptorIndex, sampler, index);
|
needsWrite |= dsWriter.WriteSampler(descriptorIndex, sampler, index);
|
||||||
@@ -460,6 +461,7 @@ void GPUContextVulkan::UpdateDescriptorSets(const SpirvShaderDescriptorInfo& des
|
|||||||
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||||
{
|
{
|
||||||
// Shader Resource (Texture)
|
// Shader Resource (Texture)
|
||||||
|
ASSERT_LOW_LAYER(slot < GPU_MAX_SR_BINDED);
|
||||||
auto handle = (GPUTextureViewVulkan*)handles[slot];
|
auto handle = (GPUTextureViewVulkan*)handles[slot];
|
||||||
if (!handle)
|
if (!handle)
|
||||||
{
|
{
|
||||||
@@ -490,6 +492,7 @@ void GPUContextVulkan::UpdateDescriptorSets(const SpirvShaderDescriptorInfo& des
|
|||||||
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
||||||
{
|
{
|
||||||
// Shader Resource (Buffer)
|
// Shader Resource (Buffer)
|
||||||
|
ASSERT_LOW_LAYER(slot < GPU_MAX_SR_BINDED);
|
||||||
auto sr = handles[slot];
|
auto sr = handles[slot];
|
||||||
if (!sr)
|
if (!sr)
|
||||||
{
|
{
|
||||||
@@ -505,6 +508,7 @@ void GPUContextVulkan::UpdateDescriptorSets(const SpirvShaderDescriptorInfo& des
|
|||||||
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
case VK_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||||
{
|
{
|
||||||
// Unordered Access (Texture)
|
// Unordered Access (Texture)
|
||||||
|
ASSERT_LOW_LAYER(slot < GPU_MAX_UA_BINDED);
|
||||||
auto ua = handles[slot];
|
auto ua = handles[slot];
|
||||||
ASSERT(ua);
|
ASSERT(ua);
|
||||||
VkImageView imageView;
|
VkImageView imageView;
|
||||||
@@ -516,6 +520,7 @@ void GPUContextVulkan::UpdateDescriptorSets(const SpirvShaderDescriptorInfo& des
|
|||||||
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||||
{
|
{
|
||||||
// Unordered Access (Buffer)
|
// Unordered Access (Buffer)
|
||||||
|
ASSERT_LOW_LAYER(slot < GPU_MAX_UA_BINDED);
|
||||||
auto ua = handles[slot];
|
auto ua = handles[slot];
|
||||||
if (!ua)
|
if (!ua)
|
||||||
{
|
{
|
||||||
@@ -531,6 +536,7 @@ void GPUContextVulkan::UpdateDescriptorSets(const SpirvShaderDescriptorInfo& des
|
|||||||
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
||||||
{
|
{
|
||||||
// Unordered Access (Buffer)
|
// Unordered Access (Buffer)
|
||||||
|
ASSERT_LOW_LAYER(slot < GPU_MAX_UA_BINDED);
|
||||||
auto ua = handles[slot];
|
auto ua = handles[slot];
|
||||||
if (!ua)
|
if (!ua)
|
||||||
{
|
{
|
||||||
@@ -546,6 +552,7 @@ void GPUContextVulkan::UpdateDescriptorSets(const SpirvShaderDescriptorInfo& des
|
|||||||
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
|
||||||
{
|
{
|
||||||
// Constant Buffer
|
// Constant Buffer
|
||||||
|
ASSERT_LOW_LAYER(slot < GPU_MAX_CB_BINDED);
|
||||||
auto cb = handles[slot];
|
auto cb = handles[slot];
|
||||||
ASSERT(cb);
|
ASSERT(cb);
|
||||||
VkBuffer buffer;
|
VkBuffer buffer;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "Engine/Platform/Platform.h"
|
#include "Engine/Platform/Platform.h"
|
||||||
#include "Engine/Threading/Threading.h"
|
#include "Engine/Threading/Threading.h"
|
||||||
#include "Engine/Serialization/MemoryWriteStream.h"
|
#include "Engine/Serialization/MemoryWriteStream.h"
|
||||||
|
#include "Engine/Graphics/Config.h"
|
||||||
#include "Engine/GraphicsDevice/Vulkan/Types.h"
|
#include "Engine/GraphicsDevice/Vulkan/Types.h"
|
||||||
|
|
||||||
// Use glslang for HLSL to SPIR-V translation
|
// Use glslang for HLSL to SPIR-V translation
|
||||||
@@ -682,6 +683,10 @@ bool ShaderCompilerVulkan::CompileShader(ShaderFunctionMeta& meta, WritePermutat
|
|||||||
{
|
{
|
||||||
auto& descriptor = descriptorsCollector.Descriptors[i];
|
auto& descriptor = descriptorsCollector.Descriptors[i];
|
||||||
|
|
||||||
|
// Skip cases (eg. AppendStructuredBuffer counter buffer)
|
||||||
|
if (descriptor.Slot == MAX_uint16)
|
||||||
|
continue;
|
||||||
|
|
||||||
auto& d = header.DescriptorInfo.DescriptorTypes[header.DescriptorInfo.DescriptorTypesCount++];
|
auto& d = header.DescriptorInfo.DescriptorTypes[header.DescriptorInfo.DescriptorTypesCount++];
|
||||||
d.Binding = descriptor.Binding;
|
d.Binding = descriptor.Binding;
|
||||||
d.Set = stageSet;
|
d.Set = stageSet;
|
||||||
@@ -694,12 +699,15 @@ bool ShaderCompilerVulkan::CompileShader(ShaderFunctionMeta& meta, WritePermutat
|
|||||||
switch (descriptor.BindingType)
|
switch (descriptor.BindingType)
|
||||||
{
|
{
|
||||||
case SpirvShaderResourceBindingType::CB:
|
case SpirvShaderResourceBindingType::CB:
|
||||||
|
ASSERT_LOW_LAYER(descriptor.Slot >= 0 && descriptor.Slot < GPU_MAX_CB_BINDED);
|
||||||
bindings.UsedCBsMask |= 1 << descriptor.Slot;
|
bindings.UsedCBsMask |= 1 << descriptor.Slot;
|
||||||
break;
|
break;
|
||||||
case SpirvShaderResourceBindingType::SRV:
|
case SpirvShaderResourceBindingType::SRV:
|
||||||
|
ASSERT_LOW_LAYER(descriptor.Slot >= 0 && descriptor.Slot < GPU_MAX_SR_BINDED);
|
||||||
bindings.UsedSRsMask |= 1 << descriptor.Slot;
|
bindings.UsedSRsMask |= 1 << descriptor.Slot;
|
||||||
break;
|
break;
|
||||||
case SpirvShaderResourceBindingType::UAV:
|
case SpirvShaderResourceBindingType::UAV:
|
||||||
|
ASSERT_LOW_LAYER(descriptor.Slot >= 0 && descriptor.Slot < GPU_MAX_UA_BINDED);
|
||||||
bindings.UsedUAsMask |= 1 << descriptor.Slot;
|
bindings.UsedUAsMask |= 1 << descriptor.Slot;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user