diff --git a/reference/shaders-msl/comp/array-length.msl2.argument.discrete.comp b/reference/shaders-msl/comp/array-length.msl2.argument.discrete.comp index 31f5d4bd..89d9809e 100644 --- a/reference/shaders-msl/comp/array-length.msl2.argument.discrete.comp +++ b/reference/shaders-msl/comp/array-length.msl2.argument.discrete.comp @@ -39,7 +39,7 @@ struct spvDescriptorSetBuffer1 device SSBO1* ssbos [[id(2)]][2]; }; -uint get_size(device SSBO& v_16, constant uint& v_16BufferSize, device SSBO1* constant (&ssbos)[2], constant uint* ssbosBufferSize, device SSBO2& v_38, constant uint& v_38BufferSize, device SSBO3* constant (&ssbos2)[2], constant uint* ssbos2BufferSize) +uint get_size(device SSBO& v_16, constant uint& v_16BufferSize, device SSBO1* constant (&ssbos)[2], constant uint* ssbosBufferSize, device SSBO2& v_38, constant uint& v_38BufferSize, device SSBO3* (&ssbos2)[2], constant uint* ssbos2BufferSize) { uint len = uint(int((v_16BufferSize - 16) / 16)); len += uint(int((ssbosBufferSize[1] - 0) / 4)); diff --git a/spirv_msl.cpp b/spirv_msl.cpp index 320684d9..5fd4224e 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -6454,17 +6454,21 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg) if (msl_options.argument_buffers) { - // An awkward case where we need to emit *more* address space declarations (yay!). - // An example is where we pass down an array of buffer pointers to leaf functions. - // It's a constant array containing pointers to constants. - // The pointer array is always constant however. E.g. - // device SSBO * constant (&array)[N]. - // const device SSBO * constant (&array)[N]. - // constant SSBO * constant (&array)[N]. - // However, this only matters for argument buffers, since for MSL 1.0 style codegen, - // we emit the buffer array on stack instead, and that seems to work just fine apparently. - if (storage == StorageClassUniform || storage == StorageClassStorageBuffer) + uint32_t desc_set = get_decoration(name_id, DecorationDescriptorSet); + if ((storage == StorageClassUniform || storage == StorageClassStorageBuffer) && + descriptor_set_is_argument_buffer(desc_set)) + { + // An awkward case where we need to emit *more* address space declarations (yay!). + // An example is where we pass down an array of buffer pointers to leaf functions. + // It's a constant array containing pointers to constants. + // The pointer array is always constant however. E.g. + // device SSBO * constant (&array)[N]. + // const device SSBO * constant (&array)[N]. + // constant SSBO * constant (&array)[N]. + // However, this only matters for argument buffers, since for MSL 1.0 style codegen, + // we emit the buffer array on stack instead, and that seems to work just fine apparently. decl += " constant"; + } } decl += " (&";