mirror of
https://github.com/KhronosGroup/SPIRV-Cross.git
synced 2024-11-15 08:20:07 +00:00
MSL: Support Invariant qualifier on position.
This commit is contained in:
parent
fccf1d0462
commit
a7b2ba28a0
17
reference/opt/shaders-msl/asm/vert/invariant.msl21.asm.vert
Normal file
17
reference/opt/shaders-msl/asm/vert/invariant.msl21.asm.vert
Normal file
@ -0,0 +1,17 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 gl_Position [[position, invariant]];
|
||||
};
|
||||
|
||||
vertex main0_out main0()
|
||||
{
|
||||
main0_out out = {};
|
||||
out.gl_Position = float4(1.0);
|
||||
return out;
|
||||
}
|
||||
|
26
reference/opt/shaders-msl/vert/invariant.msl21.vert
Normal file
26
reference/opt/shaders-msl/vert/invariant.msl21.vert
Normal file
@ -0,0 +1,26 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 gl_Position [[position, invariant]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float4 vInput0 [[attribute(0)]];
|
||||
float4 vInput1 [[attribute(1)]];
|
||||
float4 vInput2 [[attribute(2)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float4 _20 = in.vInput1 * in.vInput2;
|
||||
float4 _21 = in.vInput0 + _20;
|
||||
out.gl_Position = _21;
|
||||
return out;
|
||||
}
|
||||
|
25
reference/shaders-msl/asm/vert/invariant.msl21.asm.vert
Normal file
25
reference/shaders-msl/asm/vert/invariant.msl21.asm.vert
Normal file
@ -0,0 +1,25 @@
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 gl_Position [[position, invariant]];
|
||||
};
|
||||
|
||||
float4 _main()
|
||||
{
|
||||
return float4(1.0);
|
||||
}
|
||||
|
||||
vertex main0_out main0()
|
||||
{
|
||||
main0_out out = {};
|
||||
float4 _14 = _main();
|
||||
out.gl_Position = _14;
|
||||
return out;
|
||||
}
|
||||
|
26
reference/shaders-msl/vert/invariant.msl21.vert
Normal file
26
reference/shaders-msl/vert/invariant.msl21.vert
Normal file
@ -0,0 +1,26 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct main0_out
|
||||
{
|
||||
float4 gl_Position [[position, invariant]];
|
||||
};
|
||||
|
||||
struct main0_in
|
||||
{
|
||||
float4 vInput0 [[attribute(0)]];
|
||||
float4 vInput1 [[attribute(1)]];
|
||||
float4 vInput2 [[attribute(2)]];
|
||||
};
|
||||
|
||||
vertex main0_out main0(main0_in in [[stage_in]])
|
||||
{
|
||||
main0_out out = {};
|
||||
float4 _20 = in.vInput1 * in.vInput2;
|
||||
float4 _21 = in.vInput0 + _20;
|
||||
out.gl_Position = _21;
|
||||
return out;
|
||||
}
|
||||
|
34
shaders-msl/asm/vert/invariant.msl21.asm.vert
Normal file
34
shaders-msl/asm/vert/invariant.msl21.asm.vert
Normal file
@ -0,0 +1,34 @@
|
||||
; SPIR-V
|
||||
; Version: 1.0
|
||||
; Generator: Khronos Glslang Reference Front End; 3
|
||||
; Bound: 18
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint Vertex %main "main" %_entryPointOutput
|
||||
OpSource HLSL 500
|
||||
OpName %main "main"
|
||||
OpName %_main_ "@main("
|
||||
OpName %_entryPointOutput "@entryPointOutput"
|
||||
OpDecorate %_entryPointOutput Invariant
|
||||
OpDecorate %_entryPointOutput BuiltIn Position
|
||||
%void = OpTypeVoid
|
||||
%3 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%v4float = OpTypeVector %float 4
|
||||
%8 = OpTypeFunction %v4float
|
||||
%float_1 = OpConstant %float 1
|
||||
%12 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
|
||||
%_ptr_Output_v4float = OpTypePointer Output %v4float
|
||||
%_entryPointOutput = OpVariable %_ptr_Output_v4float Output
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
%17 = OpFunctionCall %v4float %_main_
|
||||
OpStore %_entryPointOutput %17
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
%_main_ = OpFunction %v4float None %8
|
||||
%10 = OpLabel
|
||||
OpReturnValue %12
|
||||
OpFunctionEnd
|
11
shaders-msl/vert/invariant.msl21.vert
Normal file
11
shaders-msl/vert/invariant.msl21.vert
Normal file
@ -0,0 +1,11 @@
|
||||
#version 310 es
|
||||
|
||||
invariant gl_Position;
|
||||
layout(location = 0) in vec4 vInput0;
|
||||
layout(location = 1) in vec4 vInput1;
|
||||
layout(location = 2) in vec4 vInput2;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vInput0 + vInput1 * vInput2;
|
||||
}
|
@ -7598,7 +7598,14 @@ string CompilerMSL::builtin_qualifier(BuiltIn builtin)
|
||||
case BuiltInPointSize:
|
||||
return "point_size";
|
||||
case BuiltInPosition:
|
||||
return "position";
|
||||
if (position_invariant)
|
||||
{
|
||||
if (!msl_options.supports_msl_version(2, 1))
|
||||
SPIRV_CROSS_THROW("Invariant position is only supported on MSL 2.1 and up.");
|
||||
return "position, invariant";
|
||||
}
|
||||
else
|
||||
return "position";
|
||||
case BuiltInLayer:
|
||||
return "render_target_array_index";
|
||||
case BuiltInViewportIndex:
|
||||
|
Loading…
Reference in New Issue
Block a user