Skip to content

Dxsa mlir dcl constant buffer and other ops#133

Open
tagolog wants to merge 1 commit into
access-softek:dxsa-mlirfrom
tagolog:dxsa-mlir-dcl_constant_buffer-and-other-ops
Open

Dxsa mlir dcl constant buffer and other ops#133
tagolog wants to merge 1 commit into
access-softek:dxsa-mlirfrom
tagolog:dxsa-mlir-dcl_constant_buffer-and-other-ops

Conversation

@tagolog
Copy link
Copy Markdown

@tagolog tagolog commented May 21, 2026

No description provided.

@tagolog tagolog requested a review from asavonic May 21, 2026 05:34
return builder.buildDclOutput(*operand, loc);
}

FailureOr<Instruction> parseDclConstantBuffer(uint32_t opcodeToken,
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.

For Shader Model 5.1 and later, constant buffer opcode is followed by 3 operands: range, size and index.
Looks like we only handle Shader Model 4.0 through 5.0.

if (!accessPattern)
return emitError(loc, "unknown constant buffer access pattern: ")
<< rawAccessPattern;
auto operand = parseInlineOperand();
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.

The operand for dcl_constantBuffer is fake - it can only be D3D10_SB_OPERAND_TYPE_CONSTANT_BUFFER, and we only need indices from it. The second index is also fake: it defines size of a buffer. Other properties of operands are meaningless - components, mask, swizzle. I don't think they are used for this instruction.

LogicalResult
InlineOperandAttr::verify(function_ref<InFlightDiagnostic()> emitError,
::mlir::dxsa::InlineOperandType /*type*/,
uint32_t components,
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.

Do we verify that components can only be 0, 1, or 4?

ctx, static_cast<dxsa::ComponentName>(comp.swizzle[0]),
static_cast<dxsa::ComponentName>(comp.swizzle[1]),
static_cast<dxsa::ComponentName>(comp.swizzle[2]),
static_cast<dxsa::ComponentName>(comp.swizzle[3]));
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.

Can we use symbolize to verify range?

def DXSA_SystemValueNameAttr :
EnumAttr<DXSADialect, DXSA_SystemValueName, "system_value_name"> {
let assemblyFormat = "$value";
let assemblyFormat = "`<` $value `>`";
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.

Why do we need angle brackets here?

}];
let parameters = (ins
EnumParameter<DXSA_InlineOperandType>:$type,
"uint32_t":$components,
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.

Why uint32_t and not, say, I32Attr?

…t, dcl_hs_join_phase_instance_count, dcl_hs_max_tessfactor, dcl_index_range, dcl_output_sgv, dcl_output_siv and dcl_tgsm_raw instructions

Example:
  dxsa.dcl_constant_buffer <type = constant_buffer, components = 4, swizzle = <x, y, z, w>, index = [0, 1]>, <immediateIndexed>
  dxsa.dcl_hs_fork_phase_instance_count 4
  dxsa.dcl_hs_join_phase_instance_count 2
  dxsa.dcl_hs_max_tessfactor 6.400000e+01
  dxsa.dcl_index_range <type = input, components = 4, mask = <x, y, z, w>, index = [4]>, 6
  dxsa.dcl_output_sgv <type = output, components = 4, mask = <x>, index = [0]>, <primitiveID>
  dxsa.dcl_output_siv <type = output, components = 4, mask = <x, y, z, w>, index = [0]>, <position>
  dxsa.dcl_tgsm_raw <type = thread_group_shared_memory, components = 0, index = [0]>, 1024

Signed-off-by: Vladimir Shiryaev <tagolog@users.noreply.github.com>
@tagolog tagolog force-pushed the dxsa-mlir-dcl_constant_buffer-and-other-ops branch from f593309 to 62108d3 Compare May 21, 2026 19:45
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