Skip to content

[mlir][dxsa] Add root dxsa.module#155

Open
tagolog wants to merge 1 commit into
access-softek:dxsa-mlirfrom
tagolog:dxsa-mlir-program-header
Open

[mlir][dxsa] Add root dxsa.module#155
tagolog wants to merge 1 commit into
access-softek:dxsa-mlirfrom
tagolog:dxsa-mlir-program-header

Conversation

@tagolog
Copy link
Copy Markdown

@tagolog tagolog commented May 31, 2026

Wraps the program into a module with optional attributes program type and shader version. When the binary has no header both attributes are omitted.

Example:
dxsa.module pixel_shader 5 0 {
dxsa.dcl_global_flags
}

dxsa.module {
dxsa.dcl_global_flags
}

@tagolog tagolog requested a review from asavonic May 31, 2026 08:02
Copy link
Copy Markdown
Contributor

@asavonic asavonic left a comment

Choose a reason for hiding this comment

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

LGTM overall.

Comment thread mlir/lib/Dialect/DXSA/IR/DXSA.cpp
Comment thread mlir/lib/Dialect/DXSA/IR/DXSA.cpp Outdated
Comment thread mlir/lib/Target/DXSA/BinaryParser.cpp Outdated
Comment thread mlir/lib/Target/DXSA/BinaryParser.cpp Outdated
Comment thread mlir/include/mlir/Target/DXSA/BinaryParser.h Outdated
Wraps the program into a module with optional attributes program type and shader version.
When the binary has no header both attributes are omitted.

Example:
  dxsa.module pixel_shader 5 0 {
    dxsa.dcl_global_flags <refactoringAllowed>
  }

  dxsa.module {
    dxsa.dcl_global_flags <refactoringAllowed>
  }

Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
@tagolog tagolog force-pushed the dxsa-mlir-program-header branch from 82eb011 to 6b59659 Compare June 1, 2026 23:28
@tagolog tagolog requested a review from asavonic June 1, 2026 23:32
Copy link
Copy Markdown
Contributor

@asavonic asavonic left a comment

Choose a reason for hiding this comment

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

LGTM overall.

if (DECODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(versionToken) != 0)
return std::optional<ProgramHeader>{};

auto rawType = static_cast<uint32_t>(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems concise to me:

uint32_t rawType = DECODE_D3D10_SB_TOKENIZED_PROGRAM_TYPE(versionToken);


auto versionToken = support::endian::read<uint32_t>(
buffer.begin() + currentTokenOffset, endianness::little);
if (DECODE_D3D10_SB_TOKENIZED_INSTRUCTION_LENGTH(versionToken) != 0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we expect PROGRAM_TYPE length to always be 0, then it should be an error. If it is not followed by a length token, it is also an error.

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.

2 participants