This patch fixes four issues with Metal tessellation.
a) Shader resource binding
The Metal tessellation implementation assumes identical SPIRV-Cross
native Metal resource binding mapping for vertex, tessellation control,
and tessellation evaluation shaders. These mappings are independently
generated by SPIRV-Cross for each shader stage, and may not always be
identical. This patch allows for different resource bindings for each
of the vert/tesc/tese stages.
b) Tessellation evaluation vertex descriptors
The Metal tessellation evaluation render pipeline vertex descriptor
generation code contains a bug where attribute offsets and built in
variable locations could be calculated incorrectly if the tessellation
control shader output variables are not provided in ascending location
order. This patch fixes this by sorting the variables by location
before processing.
c) Render pass descriptor
Metal tessellation draw ends the current render pass encoder to perform
tessellation compute tasks on a compute pass encoder. When the compute
pass is completed, a new render pass encoder is created to continue
rendering. A bug exists where the new render pass encoder uses a render
pass descriptor that clears the color, depth and stencil attachements.
This patch fixes this bug by changing the render pass descriptor color,
depth and stencil attachment load actions to MTLLoadActionLoad when
appropriate.
d) drawIndexed
A bug exists where when drawIndexed is called, the Metal tessellation
vertex as compute stage input descriptor buffer layout step function
gets set to MTLStepFunctionThreadPositionInGridX rather than the indexed
version MTLStepFunctionThreadPositionInGridXIndexed. This patch fixes
this by selecting the appropriate step function.
Pick-to: 6.5
Change-Id: I122c67394719ad6b4801cd7643043839fd186bf2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>