added metal keyworld: "level" (#1501)

* added metal keyworld: "level"

* added more metal keywords

* updated test case.
This commit is contained in:
Yuwen Wu 2020-10-30 15:07:25 +08:00 committed by GitHub
parent 78c6d2d628
commit c8a43876c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 7 deletions

View File

@ -56,8 +56,8 @@ float lod_factor(thread const float2& pos_, constant UBO& v_41)
{
float2 pos = pos_ * v_41.uScale.xy;
float3 dist_to_cam = v_41.uCamPos - float3(pos.x, 0.0, pos.y);
float level = log2((length(dist_to_cam) + 9.9999997473787516355514526367188e-05) * v_41.uDistanceMod);
return fast::clamp(level, 0.0, v_41.uMaxTessLevel.x);
float level0 = log2((length(dist_to_cam) + 9.9999997473787516355514526367188e-05) * v_41.uDistanceMod);
return fast::clamp(level0, 0.0, v_41.uMaxTessLevel.x);
}
static inline __attribute__((always_inline))

View File

@ -55,8 +55,8 @@ float lod_factor(thread const float2& pos_, constant UBO& v_41)
{
float2 pos = pos_ * v_41.uScale.xy;
float3 dist_to_cam = v_41.uCamPos - float3(pos.x, 0.0, pos.y);
float level = log2((length(dist_to_cam) + 9.9999997473787516355514526367188e-05) * v_41.uDistanceMod);
return fast::clamp(level, 0.0, v_41.uMaxTessLevel.x);
float level0 = log2((length(dist_to_cam) + 9.9999997473787516355514526367188e-05) * v_41.uDistanceMod);
return fast::clamp(level0, 0.0, v_41.uMaxTessLevel.x);
}
static inline __attribute__((always_inline))

View File

@ -38,9 +38,9 @@ static inline __attribute__((always_inline))
float2 lod_factor(thread const float2& tess_coord, thread float4& vPatchLods)
{
float2 x = mix(vPatchLods.yx, vPatchLods.zw, float2(tess_coord.x));
float level = mix(x.x, x.y, tess_coord.y);
float floor_level = floor(level);
float fract_level = level - floor_level;
float level0 = mix(x.x, x.y, tess_coord.y);
float floor_level = floor(level0);
float fract_level = level0 - floor_level;
return float2(floor_level, fract_level);
}

View File

@ -11326,6 +11326,11 @@ void CompilerMSL::replace_illegal_names()
"fragment",
"compute",
"bias",
"level",
"gradient2d",
"gradientcube",
"gradient3d",
"min_lod_clamp",
"assert",
"VARIABLE_TRACEPOINT",
"STATIC_DATA_TRACEPOINT",