Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the DispatchMesh HLSL Function #99232

Open
12 tasks
Tracked by #99235
farzonl opened this issue Jul 16, 2024 · 0 comments
Open
12 tasks
Tracked by #99235

Implement the DispatchMesh HLSL Function #99232

farzonl opened this issue Jul 16, 2024 · 0 comments
Labels
backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.

Comments

@farzonl
Copy link
Member

farzonl commented Jul 16, 2024

  • Implement DispatchMesh clang builtin,
  • Link DispatchMesh clang builtin with hlsl_intrinsics.h
  • Add sema checks for DispatchMesh to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for DispatchMesh to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/DispatchMesh.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/DispatchMesh-errors.hlsl
  • Create the int_dx_DispatchMesh intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_DispatchMesh to 173 in DXIL.td
  • Create the DispatchMesh.ll and DispatchMesh_errors.ll tests in llvm/test/CodeGen/DirectX/
  • Create the int_spv_DispatchMesh intrinsic in IntrinsicsSPIRV.td
  • In SPIRVInstructionSelector.cpp create the DispatchMesh lowering and map it to int_spv_DispatchMesh in SPIRVInstructionSelector::selectIntrinsic.
  • Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/DispatchMesh.ll

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
173 DispatchMesh 6.5 ('amplification',)

SPIR-V

OpEmitMeshTasksEXT:

Description:

Reserved.

Capability:
MeshShadingEXT

Reserved.

Word Count Opcode Results Operands

4 + variable

5294

<id>
Group Count X

<id>
Group Count Y

<id>
Group Count Z

Optional
<id>
Payload

Test Case(s)

Example 1

//dxc DispatchMesh_test.hlsl -T lib_6_8 -enable-16bit-types -O0

[numthreads(1, 1, 1)]
[shader("amplification")]
export void fn(uint gtid : SV_GroupIndex) {

struct RayPayload
{
	float4 color;
	float distance;
};
uint p1;
uint p2;
uint p3;
RayPayload p4;

DispatchMesh(p1, p2, p3, p4);
}

SPIRV Example(s):

Example 2

//dxc DispatchMesh_spirv_test.hlsl -T lib_6_8 -E fn -enable-16bit-types -spirv -fspv-target-env=universal1.5 -fcgl -O0

struct RayPayload
{
	float4 color;
	float distance;
};

groupshared RayPayload p4;

[numthreads(1, 1, 1)]
[shader("amplification")]
void fn(uint gtid : SV_GroupIndex) {

uint p1;
uint p2;
uint p3;

DispatchMesh(p1, p2, p3, p4);
}

HLSL:

Syntax

void DispatchMesh(uint threadGroupCountX, uint threadGroupCountY, uint threadGroupCountZ, udt meshPayload);

Type Description

Name Template Type Component Type Size
ret void void 0
threadGroupCountX scalar uint 1
threadGroupCountY scalar uint 1
threadGroupCountZ scalar uint 1
meshPayload RayPayload Struct RayPayload 1

Minimum Shader Model

This function is supported in the following shader models.

Shader Model Supported
Shader Model 6.5 and higher shader models yes

Shader Stages

See also

@farzonl farzonl added backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues. labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:DirectX backend:SPIR-V bot:HLSL HLSL HLSL Language Support metabug Issue to collect references to a group of similar or related issues.
Projects
Status: No status
Development

No branches or pull requests

1 participant