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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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)]], device 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. 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 } };
  46. VertexOutput param[3];
  47. spvArrayCopyFromStack1(param, _223);
  48. gl_out[gl_InvocationID].gl_Position = param[gl_InvocationID].pos;
  49. gl_out[gl_InvocationID]._entryPointOutput.uv = param[gl_InvocationID].uv;
  50. threadgroup_barrier(mem_flags::mem_device);
  51. if (int(gl_InvocationID) == 0)
  52. {
  53. float2 _174 = float2(1.0) + gl_in[0].VertexOutput_uv;
  54. float _175 = _174.x;
  55. spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[0] = half(_175);
  56. spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[1] = half(_175);
  57. spvTessLevel[gl_PrimitiveID].edgeTessellationFactor[2] = half(_175);
  58. spvTessLevel[gl_PrimitiveID].insideTessellationFactor = half(_175);
  59. }
  60. }