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.

@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.

db_dxil_enum_value(n, v, d) for v, n, d in valNameDocTuples
] # Note transmutation
self.is_internal = False # whether this is never serialized
self.last_value_name = None # optional last value name for dense enums
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This replaces custom enum name matching code in hctdb_instrhelp.py

] # Note transmutation
self.is_internal = False # whether this is never serialized
self.last_value_name = None # optional last value name for dense enums
self.dxil_version_info = {} # version info for this enum
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This replaces single dxil-level global map which was used for OpCode and OpCodeClass. It makes more sense to be localized to the enum, which allows it to be supported for non-core ops as well.

Use for OpCodeClass dropped because that is an internal/not stable enumeration where such versioned sizes could not even be used for anything.

self.is_internal = False # whether this is never serialized
self.last_value_name = None # optional last value name for dense enums
self.dxil_version_info = {} # version info for this enum
self.postfix_lines = [] # optional postfix to include inside enum declaration
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the mechanism used to append experimental opcode definitions to the core OpCode enum, while keeping them separate from the dense core enumerated values. It also allows us to add a stable OpCode::Invalid value.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

2 participants