Open metarutaiga opened 2 months ago
How to check what code generated ?
If you set the MoltenVK configuration parameters:
MVK_CONFIG_LOG_LEVEL=3
MVK_CONFIG_DEBUG=1
MoltenVK will log the incoming SPIR-V and outgoing MSL.
The Configuring MoltenVK section of the Docs/MoltenVK_Runtime_UserGuide.md
document explains how to set MoltenVK configuration parameters.
It seems be not supported for DX9 HLSL style.
Converted MSL:
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Varying
{
float4 Position;
float4 Color;
float2 UV0;
};
struct main0_out
{
float4 _entryPointOutput [[color(0)]];
};
struct main0_in
{
float4 vary_Color [[user(locn0)]];
float2 vary_UV0 [[user(locn1)]];
};
static inline __attribute__((always_inline))
float4 _main(thread const Varying& vary, sampler samDiffuse)
{
float4 varyColor = vary.Color;
float4 color = float4(1.0);
color = varyColor;
color *= samDiffuse.sample(samDiffuseSmplr, float2(vary.UV0.x, 0.5));
return color;
}
fragment main0_out main0(main0_in in [[stage_in]], sampler samDiffuse [[sampler(0)]], float4 gl_FragCoord [[position]])
{
main0_out out = {};
Varying vary;
vary.Position = gl_FragCoord;
vary.Color = in.vary_Color;
vary.UV0 = in.vary_UV0;
Varying param = vary;
out._entryPointOutput = _main(param, samDiffuse);
return out;
}
End MSL
Estimated original GLSL:
#version 450
struct Varying
{
vec4 Position;
vec4 Color;
vec2 UV0;
};
layout(set = 0, binding = 0) uniform sampler samDiffuse;
layout(location = 0) in vec4 vary_Color;
layout(location = 1) in vec2 vary_UV0;
layout(location = 0) out vec4 _entryPointOutput;
vec4 _main(Varying vary)
{
vec4 varyColor = vary.Color;
vec4 color = vec4(1.0);
color = varyColor;
color *= texture(samDiffuse, vary.UV0.x);
return color;
}
void main()
{
Varying vary;
vary.Position = gl_FragCoord;
vary.Color = vary_Color;
vary.UV0 = vary_UV0;
Varying param = vary;
_entryPointOutput = _main(param);
}
End GLSL
Based on the shaders you posted, it looks like you're using a standalone sampler, which in SPIR-V must be combined with an image to be able to sample a texture, but you're using it as though it were a combined image-sampler. Your SPIR-V is likely invalid.
Based on your initial post, this may be a bug in glslang
's HLSL support.
What does the original HLSL look like?
I used HLSL10 style instead of HLSL style, and it works.
Yeah, that's almost certainly a bug in glslang
. You should file a bug with them.
How to check what code generated ? I used glslang to compile HLSL into my project.
Here is my repo : https://github.com/metarutaiga/Minamoto To select xxGraphic and Vulkan