Skip to content

Instantly share code, notes, and snippets.

@legumbre
Created April 5, 2021 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save legumbre/0e66052579e59c9e507f3141c26ec91a to your computer and use it in GitHub Desktop.
Save legumbre/0e66052579e59c9e507f3141c26ec91a to your computer and use it in GitHub Desktop.
SPIRVCross | GLSL specialization constants -> MSL
#version 310 es
precision mediump float;
layout (constant_id = 0) const bool kSomeFlag = true;
layout(location = 0) out vec4 FragColor;
void main()
{
if (kSomeFlag)
FragColor = vec4(1.0);
else
FragColor = vec4(0.0);
}
/*
* Automatically generated from input_glsl.spv.
* cmd: `spirv-cross input_glsl.spv --msl'
*
*/
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
constant bool kSomeFlag_tmp [[function_constant(0)]];
constant bool kSomeFlag = is_function_constant_defined(kSomeFlag_tmp) ? kSomeFlag_tmp : true;
struct main0_out
{
float4 FragColor [[color(0)]];
};
fragment main0_out main0()
{
main0_out out = {};
if (kSomeFlag)
{
out.FragColor = float4(1.0);
}
else
{
out.FragColor = float4(0.0);
}
return out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment