Closed rayanht closed 2 years ago
I wonder if this is a spirv-cross issue.
"mvk-error" means that MoltenVk - an implementation of Vulkan on top of Apple's Metal, is going wrong.
I believe MoltenVk uses spirv-cross to compile SPIR-V into the Metal shading language (msl).
It looks to me like perhaps spirv-cross has generated:
kernel main0_out main0()
and that the Metal compiler isn't happy with this. (I don't know msl syntax.)
I suggest you try the following:
If this indeed turns out to look like a spirv-cross problem then find a minimal example that exposes the problem (you could use spirv-reduce to help you), and report it to spirv-cross (but always make sure the SPIR-V is definitely valid before reporting any SPIR-V-related bug!)
Thanks @afd, this seems to be a spirv-cross
error indeed. spirv-cross
generates correct-ish GLSL which can be run with Amber but seems to have issues translating to MSL. The generated MSL is as follows:
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#pragma clang diagnostic ignored "-Wmissing-braces"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
template<typename T, size_t Num>
struct spvUnsafeArray
{
T elements[Num ? Num : 1];
thread T& operator [] (size_t pos) thread
{
return elements[pos];
}
constexpr const thread T& operator [] (size_t pos) const thread
{
return elements[pos];
}
device T& operator [] (size_t pos) device
{
return elements[pos];
}
constexpr const device T& operator [] (size_t pos) const device
{
return elements[pos];
}
constexpr const constant T& operator [] (size_t pos) const constant
{
return elements[pos];
}
threadgroup T& operator [] (size_t pos) threadgroup
{
return elements[pos];
}
constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
{
return elements[pos];
}
};
struct _13
{
int _m0;
float _m1;
spvUnsafeArray<uint, 1> _m2;
uint _m3;
};
struct _16
{
float3 _m0;
float _m1;
spvUnsafeArray<bool, 1> _m2;
bool _m3;
};
struct _20
{
bool _m0;
bool _m1;
};
struct _23
{
float _m0;
thread bool* _m1;
_20 _m2;
spvUnsafeArray<float, 25> _m3;
};
struct _24
{
float _m0;
uint _m1;
_23 _m2;
};
struct _29
{
int _m0;
uint _m1;
float _m2;
};
struct _30
{
_29 _m0;
};
struct _31
{
spvUnsafeArray<uint, 1> _m0;
int _m1;
spvUnsafeArray<float, 1> _m2;
bool _m3;
_30 _m4;
};
struct _34
{
bool _m0;
uint _m1;
};
struct main0_out
{
float m_3;
};
kernel main0_out main0()
{
main0_out out = {};
return out;
}
The MSL spec Section 5.1.3. states that kernel functions should return void
in MSL but here the return type is a struct containing a float, even though the original spirv assembly specifies a void
return type on the function.
The output buffer in that spirv program is however a float so I'm guessing spirv-cross
thinks that it should be the return type of the kernel in MSL.
Closing this as it is not an issue in Amber per se.
Hi I'm trying to use Amber to run spirv compute shaders but I am running into compilation errors.
Running this code with
amber -d out.amber
, fails with the following error: