Metal: Implement suppot for clip plane toggling via GPU_clip_distances.

The Metal backend already supports output for the 6 clipping planes via gl_ClipDistances equivalent, however, functionality to toggle clipping plane enablement was missing.

Authored by Apple: Michael Parkin-White

Ref T96261
Depends on D16777

Reviewed By: fclem

Maniphest Tasks: T96261

Differential Revision: https://developer.blender.org/D16813
This commit is contained in:
Jason Fielder
2022-12-20 14:15:52 +01:00
committed by Clément Foucault
parent df1fe18ed7
commit b3464fe152
8 changed files with 113 additions and 12 deletions

View File

@@ -42,6 +42,22 @@ constant int MTL_AttributeConvert15 [[function_constant(17)]];
* Unused if function constant not set. */
constant int MTL_transform_feedback_buffer_index [[function_constant(18)]];
/** Clip distance enablement. */
/* General toggle to control whether any clipping distanes are written at all.
* This is an optimization to avoid having the clipping distance shader output
* paramter if it is not needed. */
constant int MTL_clip_distances_enabled [[function_constant(19)]];
/* If clipping planes are enabled at all, then we require an enablement
* flag per clipping plane. If enabled, then gl_ClipDistances[N] will
* control clipping for a given plane, otherwise the value is ignored. */
constant int MTL_clip_distance_enabled0 [[function_constant(20)]];
constant int MTL_clip_distance_enabled1 [[function_constant(21)]];
constant int MTL_clip_distance_enabled2 [[function_constant(22)]];
constant int MTL_clip_distance_enabled3 [[function_constant(23)]];
constant int MTL_clip_distance_enabled4 [[function_constant(24)]];
constant int MTL_clip_distance_enabled5 [[function_constant(25)]];
/** Internal attribute conversion functionality. */
/* Following descriptions in mtl_shader.hh, Metal only supports some implicit
* attribute type conversions. These conversions occur when there is a difference