Skip to content

Commit 52508ef

Browse files
committed
Work on MixKhronosData docs
1 parent de9704b commit 52508ef

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

docs/for-contributors/Generator/generator-mods.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,48 @@ such as `[PrettifyNames]`.
369369

370370
Mod categories: Creation, Metadata, Naming, Transformation
371371

372+
This is a monolithic mod that handles behavior specific to Khronos APIs such as OpenGL, OpenAL, Vulkan, and much more.
373+
374+
Because this mod is intended more for internal use rather than public use, the documentation here will focus on
375+
decisions made during the development of the mod and other internal details rather than the exact usage of the mod.
376+
For information relating to how the mod should be used, please use Silk's `generator.json` configuration, source code,
377+
and `MixKhronosDataTests` as a reference.
378+
379+
(TODO: Document major decisions relating to MixKhronosData. This is difficult because of the mod's long development
380+
history. This should be done over time as further changes are made to the mod.)
381+
382+
To combat the monolithic nature of the mod, the mod is split into multiple phases. This refers to both the
383+
`InitializeAsync` and `ExecuteAsync` phases, as well as the use of multiple rewriters. The mod also implements
384+
multiple interfaces that integrate `MixKhronosData` into the behavior of other mods.
385+
386+
`InitializeAsync` is where `MixKhronosData` initializes its data by reading the Khronos-style XML specification file
387+
containing data relating to the API that the generator is generating bindings for. A list of such specifications is
388+
provided below. These XML specs roughly follow the same format, but have subtle or major differences depending on the
389+
history of that API. For example, OpenGL is similar to OpenAL, but differs greatly from Vulkan and OpenXR who are
390+
themselves similar. As such, it is best to have all of the specification files open for reference when working on
391+
parsing. It may also be helpful to have the corresponding header files open.
392+
393+
`ExecuteAsync` is where `MixKhronosData` does multiple sequential transformation steps on the source code representing
394+
the generated bindings. These steps are split into different rewriter phases in a way that focuses on balancing
395+
performance with maintainability. Performance-wise, these rewriters should be combined as much as possible. This is
396+
because repeated loops over the project source code has an associated time cost. However, for sake of maintainability,
397+
it is much easier to understand how transformations are done when they are separated out into different phases.
398+
Fortunately, as long as the transformations do not use the symbol representation (eg: `ISymbol`, `SemanticModel`) of
399+
the source code, the transformation is fairly lightweight and only adds a few seconds to the total execution time of
400+
the mod.
401+
402+
Khronos-style XML specifications:
403+
404+
OpenAL: https://raw.githubusercontent.com/kcat/openal-soft/refs/heads/master/registry/xml/al.xml
405+
OpenCL: https://raw.githubusercontent.com/KhronosGroup/OpenCL-Docs/refs/heads/main/xml/cl.xml
406+
OpenGL Windows: https://raw.githubusercontent.com/KhronosGroup/OpenGL-Registry/main/xml/wgl.xml
407+
OpenGL X11: https://github.com/KhronosGroup/OpenGL-Registry/blob/main/xml/glx.xml
408+
OpenGL: https://raw.githubusercontent.com/KhronosGroup/OpenGL-Registry/refs/heads/main/xml/gl.xml
409+
OpenXR: https://raw.githubusercontent.com/KhronosGroup/OpenXR-SDK-Source/main/specification/registry/xr.xml
410+
Vulkan: https://raw.githubusercontent.com/KhronosGroup/Vulkan-Docs/refs/heads/main/xml/vk.xml
411+
412+
Be aware that these link to the latest version. Silk's repo may be using an older version of these XML files.
413+
372414
Name affix categories:
373415

374416
- `KhronosFunctionDataType` - TODO

0 commit comments

Comments
 (0)