Skip to content

Conversation

@tex3d
Copy link
Contributor

@tex3d tex3d commented Nov 25, 2025

Implements: https://github.com/microsoft/hlsl-specs/blob/main/proposals/0052-experimental-dxil-ops.md

This change adds support for an experimental DXIL operation table, which provides an independent numeric space from the main OpCode set.

It adds support for indexing into OpCode tables using the high 16-bits as the table index, and the low 16-bits as the index into the OpCode table.

While the fundamental change could support more tables for individual experimental features or extensions, it's currently limited to tables 0 for CoreOps and 0x8000 for ExperimentalOps without additional work to unlock more tables. This maps to the existing opcodes for CoreOps and opcodes with the high bit set for ExperimentalOps.

Now, db_dxil_op_table manages dxil op lists, and DXIL ops are built using table methods.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

✅ With the latest revision this PR passed the Python code formatter.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Member

@damyanp damyanp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I think you should try and get a review from someone with some more hands-on experience of how this works than I have.

To prove I really read it though:

I'm surprised by the amount of changes in hctdb.py, but since the generated code hasn't changed in surprising ways I think we can be confident that those changes are ok.

@tex3d
Copy link
Contributor Author

tex3d commented Nov 26, 2025

I'm surprised by the amount of changes in hctdb.py, but since the generated code hasn't changed in surprising ways I think we can be confident that those changes are ok.

There were some complicating changes needed that contributed:

  • Inclusion of experimental OpCodes in the main DXIL::OpCode enum
    • This was desired because it makes the code transition from experimental to release ops trivial (no manual code changes required).
    • It complicated things because of the generalization of enums and their code gen in hctdb[_instrhelp].py. Limitations were worked around with the addition of a postfix section to tack onto the end of the main enum values. This also allowed for a stable Invalid value, instead of using the latest count.
    • It also means the core ops and any other ops would need to be handled differently when constructing the enums.
  • Refactor of dxil_version_info into enum where it applies and is used. Plus, removal of versioning of the OpCodeClass where it didn't make sense (not a stable, ordered enum, or part of the DXIL interface).
  • Split off experimental definitions from populate_dxil_operations, moving epilog code to finalize_dxil_operations
    • Keep separate to ensure they aren't interspersed with core ops, and that upon conversion to released ops they don't end up disrupting core op ordering accidentally.
  • Following the ugly patterns used in populate_categories_and_models for populate_categories_and_models_ExperimentalOps.
  • Extra assertions for structural assumptions.
  • Added validation rule and modified existing one to account for experimental op table.

Copy link
Collaborator

@bogner bogner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I don't really see the use case for 65000 different op tables, the logic here all looks correct. LGTM with a couple of fairly minor comments.

tex3d added 9 commits December 4, 2025 12:20
db_dxil_enum_value constructor arg order made consistent with db_dxil_enum constructor's valNameDocTuples arg.

Move dxil_version_info into enum, as it tracks version markers for that enum. Removed version tracking for OpCodeClass because it didn't make sense and wasn't really usable (not stable, internal compiler enum). This causes a change in DxilConstants.h which removes these unused enum values.

db_dxil_enum.add_value to construct, add, and return new enum value.

Removed build_indices, adding to *_idx maps in add_enum_type and new add_inst now used by add_dxil_op and related functions. They show up in the index immediately, without having to call build_indices() to update multiple times during initialization.
…tions

Inside populate_dxil_operations, use local assigned add_dxil_op,
reserve_dxil_op_range, and set_op_count_for_version for initial NFC change,
which will minimize changes when moving to DXIL opcode tables.
This change creates separate lists for llvm instructions and dxil operations, and adds accessors for these.
- db_dxil_op_table manages dxil op lists, build ops using table now.
- split off llvm instruction list, use generators for supersets, remove unused accessors (get_instr_by_llvm_name, get_dxil_insts), cleaned references.
- Move OpCodeClass verification to verify_dxil_op_classes, with a few additions. Enable with exception for known conflict that's fortunately not serious. Fixed conflicts in RayQuery and HitObject accessors, which fortunately will cause no DXIL differences.
- consistency improvements for enums
- add to indexes when adding insts or enums
@tex3d tex3d force-pushed the experimental-dxil-op-tables branch from 80c1813 to c51b44b Compare December 4, 2025 22:56
@tex3d tex3d merged commit 8d87631 into microsoft:main Dec 5, 2025
12 checks passed
@github-project-automation github-project-automation bot moved this from New to Done in HLSL Roadmap Dec 5, 2025
@tex3d tex3d deleted the experimental-dxil-op-tables branch December 5, 2025 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants