Skip to content

[mlir][dxsa] Add dcl_function_body and dcl_function_table#134

Open
asavonic wants to merge 2 commits into
dxsa-mlirfrom
dxsa-mlir-functions
Open

[mlir][dxsa] Add dcl_function_body and dcl_function_table#134
asavonic wants to merge 2 commits into
dxsa-mlirfrom
dxsa-mlir-functions

Conversation

@asavonic
Copy link
Copy Markdown
Contributor

DX assembly programs support "virtual" inlining of subroutines by defining a set of functions that might be called for a call site.
The compiler then prepares an inlined specialization for every possible callee. The actual specialization is selected at runtime.

On DXBC level, functions are declared and identified by numbers, grouped into tables, and tables are grouped as interfaces:

// Function table for AmbientLight.
dcl_function_body fb0
dcl_function_table ft0 = { fb0 }

// Function table for DirectionalLight.
dcl_function_body fb1
dcl_function_table ft1 = { fb1 }

// main's MyMaterial parameter.
dcl_interface fp0[1][1] = { ft0, ft1 };

// main shader code

// call AmbientLight or DirectionalLight based on function pointer bound
fcall fp0[0][0]

This patchset adds only dcl_function_body and dcl_function_table. Interfaces are going to be in a separate patch.

@asavonic asavonic requested a review from tagolog May 22, 2026 15:31
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.

1 participant