Skip to content

Wrap compiler options, module loading and global queries - #21

Merged
RefuX merged 2 commits into
mainfrom
feat/api-gaps
Oct 2, 2026
Merged

RefuX merged 2 commits into
mainfrom
feat/api-gaps

Conversation

@RefuX

@RefuX RefuX commented Oct 2, 2026

Copy link
Copy Markdown
Owner

Wraps three groups of Slang API in the higher-level layer for 0.0.11. Until now it covered 14 of Slang's ~80 COM methods and none of its ~160 compiler options.

Compiler options

  • Typed setters on SessionBuilder: optimization, debugInfo, warningsAsErrors, disableWarnings, languageVersion, capability(name) and bitfieldPacking (Slang 2026.19's MSVC-compatible packing).
  • Raw option(name, value): on SessionBuilder and TargetOptions, taking ffi.gen.CompilerOptionName constants for everything else.
  • Session vs. target: targets inherit session options and override them. Floating-point mode, line-directive mode and GLSL scalar layout only work per target, because Slang re-applies them from each target's descriptor; the javadoc says so.
  • New enums: OptimizationLevel, DebugInfoLevel, BitfieldPacking.

Module loading and introspection

  • Session.loadModule(name): resolves through search paths or a SlangFileSystem; loading a name again returns the module already loaded.
  • On Module: name(), filePath(), dependencyFiles() (including the sources of imported modules), entryPoints() ([shader] functions plus [numthreads]-only compute functions), and entryPoint(name, stage) for undecorated functions.
  • Session.isIrUpToDate(path, ir): whether a cached .slang-module is stale. A session keeps files it has read, so edits only show from a fresh session.

Global queries and whole-program code

  • On GlobalSession: findCapability, isTargetSupported, isPassThroughSupported and downstreamCompilerPath (new in 2026.17), plus a PassThrough enum.
  • ComponentType.targetCode(target): one artifact covering every entry point.

Verification

:slang:test 64/64 locally against the 2026.19 macos-aarch64 payload, including 21 new tests that check effects rather than calls: debug info in the SPIR-V, code size at each optimization level, warnings failing or silenced, MSVC bitfield storage in the generated HLSL, and per-target options landing on one target only. Javadoc builds without warnings. Qodana couldn't run locally, so this PR's run is the first check with the stricter gate.

🤖 Generated with Claude Code

The idiomatic layer wrapped 14 of Slang's ~80 COM methods and none of its
~160 compiler options. This adds the three groups chosen for 0.0.11.

Compiler options. SessionBuilder gains typed setters for the common ones --
optimization, debugInfo, warningsAsErrors, disableWarnings, languageVersion,
capability (by name, resolved through findCapability) and bitfieldPacking, the
last being Slang 2026.19's fix for MSVC-compatible packing -- plus raw
option(name, value) overloads taking ffi.gen.CompilerOptionName constants for
everything else. TargetOptions gets the same raw overloads, per target. Slang
loads the session's entries before adding targets, so each target inherits
them and its own entries override; the javadoc warns that FloatingPointMode,
LineDirectiveMode and GLSLForceScalarLayout are re-applied from TargetDesc
fields after inheritance, so those only work per target. New enums
OptimizationLevel, DebugInfoLevel and BitfieldPacking follow Stage's
value()/of(int)/UNKNOWN convention; passing UNKNOWN is refused.

Module loading and introspection. Session.loadModule(name) resolves an import
name through the search paths or a SlangFileSystem, and returns an
already-loaded module rather than recompiling. Module gains name(), filePath(),
dependencyFiles() (its source, #includes, and the sources of modules it
imports -- checked, not assumed), entryPoints() (what Slang found:
[shader(...)] functions and, as Slang infers, [numthreads]-only compute
functions) and entryPoint(name, stage) for undecorated functions.
Session.isIrUpToDate(path, ir) wraps isBinaryModuleUpToDate; its javadoc
records that a session keeps the files it has read, so an edit is only seen
from a fresh session.

Global queries and whole-program code. GlobalSession gains findCapability,
isTargetSupported, isPassThroughSupported and downstreamCompilerPath (the
2026.17 replacement for getDownstreamCompilerVersion), with a PassThrough enum;
ComponentType.targetCode(target) returns code for every entry point at once.
Entry points from getDefinedEntryPoint and findAndCheckEntryPoint are
caller-owned, as upstream's detached ComPtrs make them.

Tests: CompilerOptionsTest checks each typed option by its effect (debug info
in the SPIR-V, NONE vs MAXIMAL code size, warnings failing or vanishing, MSVC
bitfield storage in generated HLSL, per-target entries landing on one target
only); ModuleLoadingTest and GlobalQueriesTest cover the rest, including that
glslang resolves to the payload's library. 64 of 64 pass against the 2026.19
macos-aarch64 payload; javadoc builds warning-free.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Qodana for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2026.1.3
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

Qodana (Declaration has problems in Javadoc references) flagged
Session.loadModule's javadoc: {@link SessionBuilder#fileSystem} without a
signature resolves to the builder's private fileSystem field, which is
inaccessible from Session. Both links now name their method signatures, so
neither depends on how a bare member name resolves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@RefuX
RefuX merged commit 8a8c29f into main Oct 2, 2026
7 checks passed
@RefuX
RefuX deleted the feat/api-gaps branch October 2, 2026 09:37
@RefuX RefuX mentioned this pull request Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant