diff --git a/AnKi/Gr/Common.h b/AnKi/Gr/Common.h index 1664a85de..6fca8e81d 100644 --- a/AnKi/Gr/Common.h +++ b/AnKi/Gr/Common.h @@ -1104,8 +1104,8 @@ U32 computeMaxMipmapCount2d(U32 w, U32 h, U32 minSizeOfLastMip = 1); U32 computeMaxMipmapCount3d(U32 w, U32 h, U32 d, U32 minSizeOfLastMip = 1); /// Visit a SPIR-V binary. -template typename TArray, typename TFunc> -static void visitSpirv(TArray spv, TFunc func) +template +static void visitSpirv(TArray spv, TFunc func) { ANKI_ASSERT(spv.getSize() > 5); @@ -1115,7 +1115,7 @@ static void visitSpirv(TArray spv, TFunc func) const U32 instructionCount = *it >> 16u; const U32 opcode = *it & 0xFFFFu; - TArray instructions(it + 1, instructionCount - 1); + TArray instructions(it + 1, instructionCount - 1); func(opcode, instructions); diff --git a/AnKi/Gr/Texture.h b/AnKi/Gr/Texture.h index a47d224c9..e139abfea 100644 --- a/AnKi/Gr/Texture.h +++ b/AnKi/Gr/Texture.h @@ -274,9 +274,9 @@ class TextureSubresourceDescriptor private: constexpr TextureSubresourceDescriptor(U32 mip, U32 face, U32 layer, Bool allSurfs, DepthStencilAspectBit aspect) - : m_mipmap(mip) - , m_face(face) - , m_layer(layer) + : m_mipmap(mip & ((1u << 5u) - 1u)) + , m_face(face & ((1u << 3u) - 1u)) + , m_layer(layer & ((1u << 24u) - 1u)) , m_allSurfacesOrVolumes(allSurfs) , m_depthStencilAspect(aspect) { diff --git a/AnKi/Gr/Vulkan/VkShaderProgram.cpp b/AnKi/Gr/Vulkan/VkShaderProgram.cpp index 137645ed3..7ec5bac12 100644 --- a/AnKi/Gr/Vulkan/VkShaderProgram.cpp +++ b/AnKi/Gr/Vulkan/VkShaderProgram.cpp @@ -483,7 +483,7 @@ void ShaderProgramImpl::rewriteSpirv(ShaderReflectionDescriptorRelated& refl, Gr outSpv.resize(inSpirv.getSize()); memcpy(outSpv.getBegin(), inSpirv.getBegin(), inSpirv.getSizeInBytes()); - visitSpirv(WeakArray(outSpv), [&](U32 cmd, WeakArray instructions) { + visitSpirv(WeakArray(outSpv), [&](U32 cmd, WeakArray instructions) { if(cmd == spv::OpDecorate && instructions[1] == spv::DecorationBinding && instructions[2] >= kDxcVkBindingShifts[0][HlslResourceType::kFirst] && instructions[2] < kDxcVkBindingShifts[kMaxDescriptorSets - 1][HlslResourceType::kCount - 1]) diff --git a/AnKi/ShaderCompiler/ShaderCompiler.cpp b/AnKi/ShaderCompiler/ShaderCompiler.cpp index 304e034f4..1c6596a59 100644 --- a/AnKi/ShaderCompiler/ShaderCompiler.cpp +++ b/AnKi/ShaderCompiler/ShaderCompiler.cpp @@ -346,13 +346,13 @@ Error doReflectionSpirv(ConstWeakArray spirv, ShaderType type, ShaderReflect // Discards? if(type == ShaderType::kFragment) { - visitSpirv(ConstWeakArray(reinterpret_cast(&spirv[0]), spirv.getSize() / sizeof(U32)), - [&](U32 cmd, [[maybe_unused]] ConstWeakArray instructions) { - if(cmd == spv::OpKill) - { - refl.m_fragment.m_discards = true; - } - }); + visitSpirv(ConstWeakArray(reinterpret_cast(&spirv[0]), spirv.getSize() / sizeof(U32)), + [&](U32 cmd, [[maybe_unused]] ConstWeakArray instructions) { + if(cmd == spv::OpKill) + { + refl.m_fragment.m_discards = true; + } + }); } return Error::kNone;