MSL: Fixup buffer array case issue on MSL 1.0.

This commit is contained in:
Hans-Kristian Arntzen 2019-03-15 11:37:34 +01:00
parent af8a9ccdcb
commit 969566aff5
2 changed files with 15 additions and 10 deletions

View File

@ -22,7 +22,7 @@ struct constant_block
#endif #endif
constant int arraySize = SPIRV_CROSS_CONSTANT_ID_0; constant int arraySize = SPIRV_CROSS_CONSTANT_ID_0;
void doWork(device storage_block* constant (&storage)[2], constant constant_block* constant (&constants)[4], thread const array<texture2d<int>, 3> images) void doWork(device storage_block* (&storage)[2], constant constant_block* (&constants)[4], thread const array<texture2d<int>, 3> images)
{ {
storage[0]->baz = uint4(constants[3]->foo); storage[0]->baz = uint4(constants[3]->foo);
storage[1]->quux = images[2].read(uint2(int2(constants[1]->bar))).xy; storage[1]->quux = images[2].read(uint2(int2(constants[1]->bar))).xy;

View File

@ -5968,6 +5968,8 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg)
if (!address_space.empty()) if (!address_space.empty())
decl = join(address_space, " ", decl); decl = join(address_space, " ", decl);
if (msl_options.argument_buffers)
{
// 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.
// It's a constant array containing pointers to constants. // It's a constant array containing pointers to constants.
@ -5975,8 +5977,11 @@ string CompilerMSL::argument_decl(const SPIRFunction::Parameter &arg)
// device SSBO * constant (&array)[N]. // device SSBO * constant (&array)[N].
// const device SSBO * constant (&array)[N]. // const device SSBO * constant (&array)[N].
// constant 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) if (storage == StorageClassUniform || storage == StorageClassStorageBuffer)
decl += " constant"; decl += " constant";
}
decl += " (&"; decl += " (&";
decl += to_expression(name_id); decl += to_expression(name_id);