Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85949

Shader debug info, optimizations, strip/remap

    XMLWordPrintable

Details

    Description

      • Generated SPIR-V binaries should get stripped after the SPIRV-Cross step.

      Even though we do not invoke glslang with debug info enabled, there are OpName instructions and others that describe variable and block member names, which is unnecessary bloat when shipped in a .qsb file (but are very nice for SPIRV-Cross since it can generate more human readable GLSL/HLSL/MSL, hence should strip after that step)

      This is mostly implemented (QSpirvShader::remappedSpirvBinary with StripOnly) but not used yet. (other remapping steps are probably not that important now)

      This is important because it reduces the size of the .qsb files a bit.

      • On the other hand, there must be an option (QShaderBaker flag + qsb command line arg) to enable full debug info. This will become useful when using tools like RenderDoc, because one can see the full source instead of just the SPIR-V disassembly.
      • When invoking fxc from qsb, optimization and debug info related arguments should be controlled, so that one can get optimized or full debug info DXBC in the .qsb files. The default is /O1 so that's no so bad. But for debugging we'd need /Od and /Zi.

      In addition we should consider what to do when HLSL compilation happens at run time (because then it is the D3DCompile() call that needs those settings), but that's less important for now.

      The end result should be that when opting in, e.g. by passing a familiarly named -g flag to qsb, both SPIR-V and, if enabled, DXBC has full debug information embedded. (under the hood this involves embedding the source code in practice, adding OpLine etc.) Then RenderDoc and other tools can pick this up. This leads to wonderful things, f.ex. here pixel shader debugging with the original (SPIRV-Cross generated) HLSL source in RenderDoc:

      • We should consider pulling in the optimizer from https://github.com/KhronosGroup/SPIRV-Tools To be investigated how to do this with minimum 3rd party content.
        The performance optimizations are the ones we are interested in. At minimum there should be an option to opt in for those since that's what we want to use for Quick / Quick 3D shaders in production.

      As a compromise, add an option to qsb that invokes spirv-opt when available from the Vulkan SDK or somewhere else. Shipping SPIRV-Tools with qtshadertools is deemed to complicated now for 6.0.

      Attachments

        For Gerrit Dashboard: QTBUG-85949
        # Subject Branch Project Status CR V

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes