feat(compiler): refuse programmable blending by name as an Apple GPU family feature
This commit is contained in:
1 parent
704c099c7b
commit
d12e67ceab
3 files changed
+28
-3
No files matched your search
@@ -1615,6 +1615,12 @@ metadata_arguments(struct stela_air_metadata *t, LLVMValueRef fn, LLVMValueRef a
|
||||
bool payload = (object || mesh_stage) && stela_air_md_string(fields[1], "air.payload");
|
||||
bool mesh = mesh_stage && stela_air_md_string(fields[1], "air.mesh");
|
||||
bool grid = object && stela_air_md_string(fields[1], "air.mesh_grid_properties");
|
||||
/* A fragment input of a render target's color is programmable
|
||||
* blending, which reads the target in raster order. */
|
||||
if (render && render->entry.stage == STELA_AIR_FRAGMENT &&
|
||||
stela_air_md_string(fields[1], "air.render_target"))
|
||||
return fail(t, STELA_AIR_ARGUMENT,
|
||||
"programmable blending ([[color(n)]] inputs) needs an Apple GPU family");
|
||||
if (!buffer && !builtin && !interpolated && !vertex_input && !texture && !sampler &&
|
||||
!payload && !mesh && !grid && !control_points && !in_patch) {
|
||||
unsigned length;
|
||||
|
||||
@@ -457,6 +457,17 @@ static const char *fragment =
|
||||
"!40 = !{i32 0, !\"air.fragment_input\", !\"user(uv)\", !\"air.center\", !\"air.perspective\","
|
||||
" !\"air.arg_type_name\", !\"float2\", !\"air.arg_name\", !\"uv\"}\n";
|
||||
|
||||
/* Returns the color its render target holds: programmable blending. */
|
||||
static const char *blended =
|
||||
"define <4 x float> @blended(<4 x float> %previous) {\nret <4 x float> %previous\n}\n"
|
||||
"!air.fragment = !{!2}\n"
|
||||
"!2 = !{ptr @blended, !3, !4}\n!3 = !{!30}\n"
|
||||
"!30 = !{!\"air.render_target\", i32 0, i32 0, !\"air.arg_type_name\", !\"float4\","
|
||||
" !\"air.arg_name\", !\"color\"}\n"
|
||||
"!4 = !{!40}\n"
|
||||
"!40 = !{i32 0, !\"air.render_target\", i32 0, !\"air.arg_type_name\", !\"float4\","
|
||||
" !\"air.arg_name\", !\"previous\"}\n";
|
||||
|
||||
/* Reads its barycentric coordinates and interpolates its uv at the
|
||||
* centroid. */
|
||||
static const char *pulled =
|
||||
@@ -662,6 +673,9 @@ render_stages_compile_at_their_linked_locations(void)
|
||||
assert(!compile(fragment, "fragment", &unlinked, &error) && error.kind == STELA_AIR_ARGUMENT);
|
||||
/* As are entries no AIR list names. */
|
||||
assert(!reflect(vertex, "missing", &reflection, &error) && error.kind == STELA_AIR_ARGUMENT);
|
||||
/* Only Apple GPU families blend programmably. */
|
||||
assert(!reflect(blended, "blended", &reflection, &error) && error.kind == STELA_AIR_ARGUMENT &&
|
||||
strstr(error.detail, "programmable blending"));
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -75,13 +75,12 @@ struct FragmentOut {
|
||||
fragment FragmentOut fragment_main(FragmentIn in [[stage_in]], texture2d<float> tex [[texture(0)]],
|
||||
sampler s [[sampler(0)]], bool front [[front_facing]],
|
||||
uint sample [[sample_id]], float2 point [[point_coord]],
|
||||
uint primitive [[primitive_id]], uint coverage [[sample_mask]],
|
||||
float4 previous [[color(0)]])
|
||||
uint primitive [[primitive_id]], uint coverage [[sample_mask]])
|
||||
{
|
||||
FragmentOut out;
|
||||
float4 c = tex.sample(s, in.uv) * in.color;
|
||||
c += float4(dfdx(in.uv), dfdy(in.uv)) + float4(fwidth(in.sample_value));
|
||||
c += float4(front, sample, primitive, in.flat_id) + float4(point, in.position.xy) + previous;
|
||||
c += float4(front, sample, primitive, in.flat_id) + float4(point, in.position.xy);
|
||||
if (c.a < 0.01f)
|
||||
discard_fragment();
|
||||
out.color0 = c;
|
||||
@@ -92,6 +91,12 @@ fragment FragmentOut fragment_main(FragmentIn in [[stage_in]], texture2d<float>
|
||||
return out;
|
||||
}
|
||||
|
||||
// Programmable blending, which only Apple GPU families have: refused.
|
||||
fragment float4 fragment_blended(FragmentIn in [[stage_in]], float4 previous [[color(0)]])
|
||||
{
|
||||
return previous * in.color;
|
||||
}
|
||||
|
||||
fragment float4 fragment_interpolated(FragmentIn in [[stage_in]],
|
||||
float3 bary [[barycentric_coord]])
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user