Skip to content

Omit reserved DXIL ops from OpCode enum#8143

Open
tex3d wants to merge 3 commits intomicrosoft:mainfrom
tex3d:omit-dxil-reserved-ops
Open

Omit reserved DXIL ops from OpCode enum#8143
tex3d wants to merge 3 commits intomicrosoft:mainfrom
tex3d:omit-dxil-reserved-ops

Conversation

@tex3d
Copy link
Contributor

@tex3d tex3d commented Feb 5, 2026

This change excludes reserved ops from DXIL::OpCode enum, so they don't need a unique name. They should never be referenced, so this makes using them impossible. The reserved values will be listed in a comment at the end of the enum, before NumOpCodes.

Also fixed the validator to catch and reject reserved opcodes.

Since the OpCodeProperty table entries corresponding to their opcode must still be occupied due to the way ops are looked up by indexing the table, there's a new single ReservedOpCodeProps value, with opcode set to OpCode::Invalid, supplied for each reserved slot. This way the slot is occupied (reserved), but not valid for use.

For instance, for a reserved opcode, now:

  • DecodeOpCode returns false (for invalid)
  • IsValidOpCode returns false
  • IsOverloadLegal returns false
  • getOpCode on instruction returns OpCode::Invalid
  • GetDxilOpFuncCallInst on instruction returns OpCode::Invalid
  • new IsReservedOpCode returns true

Added a validation test. Previously, it would have incorrectly accepted the reserved opcode as valid.

Fixes #8144

tex3d added 2 commits February 4, 2026 14:23
Switching DXIL ops to reserved will become common when they are retired from experimental. This change makes it trivial to do so without depending on or changing other reserved op names or numbers elsewhere.
This change excludes reserved ops from DXIL::OpCode enum, so they don't need a unique name. They should never be referenced, so this makes that using them basically impossible. The reserved values will be listed in a comment at the end of the enum, before NumOpCodes. Catch and reject reserved opcodes during validation.

Since the OpCodeProperty table entries corresponding to their opcode must still be occupied due to the way ops are looked up by indexing the table, there's a new single ReservedOpCodeProps value, with opcode set to OpCode::Invalid, supplied for each reserved slot. This way the slot is occupied (reserved), but not valid for use.

For instance, for a reserved opcode, now:
- DecodeOpCode will return false (for invalid)
- IsValidOpCode will return false
- IsOverloadLegal will return false
- getOpCode on instruction will return OpCode::Invalid
- GetDxilOpFuncCallInst on instruction will return OpCode::Invalid
- new IsReservedOpCode function will return true

Added a validation test. Previously, it would have incorrectly accepted the reserved opcode as valid.
@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

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

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.

DXIL Validator fails to catch reserved OpCode

1 participant