MSL: Use correct address space when passing array-of-buffers.

Need to check if the descriptor set is actually an argument buffer.
This commit is contained in:
Hans-Kristian Arntzen 2019-05-27 16:53:30 +02:00
parent 42e64597a7
commit fd0feb1ec1
2 changed files with 15 additions and 11 deletions

View File

@ -39,7 +39,7 @@ struct spvDescriptorSetBuffer1
device SSBO1* ssbos [[id(2)]][2]; 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)); uint len = uint(int((v_16BufferSize - 16) / 16));
len += uint(int((ssbosBufferSize[1] - 0) / 4)); len += uint(int((ssbosBufferSize[1] - 0) / 4));

View File

@ -6453,6 +6453,10 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg)
decl = join(address_space, " ", decl); decl = join(address_space, " ", decl);
if (msl_options.argument_buffers) if (msl_options.argument_buffers)
{
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 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. // An example is where we pass down an array of buffer pointers to leaf functions.
@ -6463,9 +6467,9 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg)
// constant SSBO * constant (&array)[N]. // constant SSBO * constant (&array)[N].
// However, this only matters for argument buffers, since for MSL 1.0 style codegen, // 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. // we emit the buffer array on stack instead, and that seems to work just fine apparently.
if (storage == StorageClassUniform || storage == StorageClassStorageBuffer)
decl += " constant"; decl += " constant";
} }
}
decl += " (&"; decl += " (&";
decl += to_expression(name_id); decl += to_expression(name_id);