Skip to content

Support compilation of multiple DVLEs into a single DVLB #39

@neobrain

Description

@neobrain

The DVLB format supports the definition of multiple shaders (DVLEs). Currently, nihstro supports only generation of DVLBs with a single DVLE, which is created solely from the input source file. Anything more advanced is a nontrivial task, because it's not entirely clear how to approach this.

Workflows which should be supported:

  • Generating a DVLB containing a single DVLE obtained from a single source file
  • Generating a DVLB containing multiple DVLEs obtained from a single source file using different compile settings (e.g. entry point, macros, definitions, ...)
  • Generating a DVLB containing multiple DVLEs, each of which was obtained from a separate source file
  • Any combination of the things above

Additional features to consider:

  • common-code detection. This will become particularly important whenever common assembly code is included through .include.
  • dead-code elimination. This will become important for "uber-shaders" which implement lots of things, but only use a small subset for each entry-point.

I thought about this issue for a while, and I think the most sensible approach to solve it is the following:

  • Introduce a separated compiler-linker model: Source code is compiled to a DVOJ, multiple DVOJs are then linked into a DVLB.
  • Compile each input source file once per input configuration (i.e. compile a file multiple times if it's supposed to be compiled with different entry points).
  • Finally, link all compiled sources together: Since each DVLB may only contain one code binary, this involves relocating each compiled shader blob to a particular offset. To make sure we don't waste too much space (the shader binary is limited to something in the order of 1024 words), dead-code elimination and common-code detection will be required. These may be omitted for an initial implementation, however.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions