Details

    • Sub-task
    • Resolution: Fixed
    • P2: Important
    • 6.7.0 FF
    • Qt RHI
    • None
    • 00f0384f7 (dev), 74bd7a701 (dev), 71a524e59 (dev)

    Description

      Maybe https://developer.apple.com/documentation/metal/render_passes/rendering_to_multiple_texture_slices_in_a_draw_command?language=objc
      with the SPIRV-Cross options https://github.com/KhronosGroup/SPIRV-Cross/blob/main/spirv_msl.hpp#L336

      Experiment what kind of shader those generates and what kind of extra buffers are needed.

      Initial investigation:

      With https://codereview.qt-project.org/c/qt/qtshadertools/+/487281 passing --view-count 2 generates the following shader. This would mean instancing must be used (and when the application uses instancing, it needs to be internally adjusted), combined with an additional buffer than contains the view offset and divisor to calculate gl_ViewIndex.

      Shader 1: MSL 12 [Standard]
      Entry point: main0
      Native resource binding map:
      0 -> [0, -1]
      Native shader extra buffer bindings:
      [view-mask-buffer-binding] = 24
      Contents:
      #include <metal_stdlib>
      #include <simd/simd.h>
      
      using namespace metal;
      
      struct buf
      {
          float4x4 mvp[2];
      };
      
      struct main0_out
      {
          float4 gl_Position [[position]];
          uint gl_Layer [[render_target_array_index]];
      };
      
      struct main0_in
      {
          float4 pos [[attribute(0)]];
      };
      
      vertex main0_out main0(main0_in in [[stage_in]], constant uint* spvViewMask [[buffer(24)]], constant buf& _21 [[buffer(0)]], uint gl_InstanceIndex [[instance_id]], uint gl_BaseInstance [[base_instance]])
      {
          main0_out out = {};
          uint gl_ViewIndex = spvViewMask[0] + (gl_InstanceIndex - gl_BaseInstance) % spvViewMask[1];
          gl_InstanceIndex = (gl_InstanceIndex - gl_BaseInstance) / spvViewMask[1] + gl_BaseInstance;
          out.gl_Position = _21.mvp[int(gl_ViewIndex)] * in.pos;
          out.gl_Layer = gl_ViewIndex - spvViewMask[0];
          return out;
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            lagocs Laszlo Agocs
            lagocs Laszlo Agocs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes