floooh / sokol-tools

Command line tools for use with sokol headers
MIT License
219 stars 54 forks source link

sokol-shdc produced YAML has incorrect indentation for fragment shader #127

Closed johnb-odplot closed 4 months ago

johnb-odplot commented 4 months ago

When compiling a shader that includes a storage buffer in the vertex stage, the produced yaml reflection has the fragment stage indented once too far in. In this example, the fragment 'fs' stage is considered one of the objects of 'vs'. I am using javascript to convert the yaml to a javascript object, and this indentation produces the incorrect result

shaders:
  -
    slang: metal_macos
    programs:
      -
        name: p
        vs:
          path: simple_particle.shader_p_metal_macos_vs.metal
          is_binary: false
          entry_point: main0
          inputs:
            -
              slot: 0
              name: a_pos
              sem_name: TEXCOORD
              sem_index: 0
            -
              slot: 1
              name: a_uv
              sem_name: TEXCOORD
              sem_index: 1
          outputs:
            -
              slot: 0
              name: uv
              sem_name: TEXCOORD
              sem_index: 0
            -
              slot: 1
              name: color0
              sem_name: TEXCOORD
              sem_index: 1
          uniform_blocks:
            -
              slot: 0
              size: 64
              struct_name: _projection
              inst_name: _103
              uniforms:
                -
                  name: projection
                  type: vec4
                  array_count: 4
                  offset: 0
            -
              slot: 1
              size: 64
              struct_name: _model
              inst_name: _109
              uniforms:
                -
                  name: model
                  type: vec4
                  array_count: 4
                  offset: 0
          storage_buffers:
            -
              slot: 0
              size: 32
              align: 16
              struct_name: ssbo
              inst_name: _21
              readonly: true
              inner_struct_name: particle
          fs:
            path: simple_particle.shader_p_metal_macos_fs.metal
            is_binary: false
            entry_point: main0
            inputs:
              -
                slot: 0
                name: uv
                sem_name: TEXCOORD
                sem_index: 0
              -
                slot: 1
                name: color0
                sem_name: TEXCOORD
                sem_index: 1
            outputs:
              -
                slot: 0
                name: color
                sem_name: TEXCOORD
                sem_index: 0
floooh commented 4 months ago

Thanks for the bug report! This is fallout from the big code gen refactoring. I'll try to provide a fix later today.

floooh commented 4 months ago

Ok, this should be fixed now. I was just missing a call which pops the indentation level after a storage block.

Binaries in sokol-tools-bin will be updated after this CI pipeline has finished: https://github.com/floooh/sokol-tools/actions/runs/9030397572