tess-fixed-input-array-builtin-array.invalid.asm.tesc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma clang diagnostic ignored "-Wmissing-prototypes"
  2. #include <metal_stdlib>
  3. #include <simd/simd.h>
  4. using namespace metal;
  5. struct VertexOutput
  6. {
  7. float4 pos;
  8. float2 uv;
  9. };
  10. struct VertexOutput_1
  11. {
  12. float2 uv;
  13. };
  14. struct HSOut
  15. {
  16. float2 uv;
  17. };
  18. struct main0_out
  19. {
  20. HSOut _entryPointOutput;
  21. float4 gl_Position;
  22. };
  23. struct main0_in
  24. {
  25. float2 VertexOutput_uv [[attribute(0)]];
  26. float4 gl_Position [[attribute(1)]];
  27. };
  28. // Implementation of an array copy function to cover GLSL's ability to copy an array via assignment.
  29. template<typename T, uint N>
  30. void spvArrayCopyFromStack1(thread T (&dst)[N], thread const T (&src)[N])
  31. {
  32. for (uint i = 0; i < N; dst[i] = src[i], i++);
  33. }
  34. template<typename T, uint N>
  35. void spvArrayCopyFromConstant1(thread T (&dst)[N], constant T (&src)[N])
  36. {
  37. for (uint i = 0; i < N; dst[i] = src[i], i++);
  38. }
  39. kernel void main0(main0_in in [[stage_in]], uint gl_InvocationID [[thread_index_in_threadgroup]], uint gl_PrimitiveID [[threadgroup_position_in_grid]], device main0_out* spvOut [[buffer(28)]], constant uint* spvIndirectParams [[buffer(29)]], device MTLTriangleTessellationFactorsHalf* spvTessLevel [[buffer(26)]], threadgroup main0_in* gl_in [[threadgroup(0)]])
  40. {
  41. device main0_out* gl_out = &spvOut[gl_PrimitiveID * 3];
  42. if (gl_InvocationID < spvIndirectParams[0])
  43. gl_in[gl_InvocationID] = in;
  44. threadgroup_barrier(mem_flags::mem_threadgroup);
  45. if (gl_InvocationID >= 3)
  46. return;
  47. VertexOutput _223[3] = { VertexOutput{ gl_in[0].gl_Position, gl_in[0].VertexOutput_uv }, VertexOutput{ gl_in[1].gl_Position, gl_in[1].VertexOutput_uv }, VertexOutput{ gl_in[2].gl_Position, gl_in[2].VertexOutput_uv } };
  48. VertexOutput param[3];
  49. spvArrayCopyFromStack1(param, _223);
  50. gl_out[gl_InvocationID].gl_Position = param[gl_InvocationID].pos;
  51. gl_out[gl_InvocationID]._entryPointOutput.uv = param[gl_InvocationID].uv;
  52. threadgroup_barrier(mem_flags::mem_device);
  53. if (int(gl_InvocationID) == 0)
  54. {
  55. float2 _174 = float2(1.0) + gl_in[0].VertexOutput_uv;
  56. float _175 = _174.x;
  57. spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(_175);
  58. spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(_175);
  59. spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(_175);
  60. spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_175);
  61. }
  62. }