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 CallShader HLSL Function #99180

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

Implement the CallShader HLSL Function #99180

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 CallShader clang builtin,
  • Link CallShader clang builtin with hlsl_intrinsics.h
  • Add sema checks for CallShader to CheckHLSLBuiltinFunctionCall in SemaChecking.cpp
  • Add codegen for CallShader to EmitHLSLBuiltinExpr in CGBuiltin.cpp
  • Add codegen tests to clang/test/CodeGenHLSL/builtins/CallShader.hlsl
  • Add sema tests to clang/test/SemaHLSL/BuiltIns/CallShader-errors.hlsl
  • Create the int_dx_CallShader intrinsic in IntrinsicsDirectX.td
  • Create the DXILOpMapping of int_dx_CallShader to 159 in DXIL.td
  • Create the CallShader.ll and CallShader_errors.ll tests in llvm/test/CodeGen/DirectX/
  • Create the int_spv_CallShader intrinsic in IntrinsicsSPIRV.td
  • In SPIRVInstructionSelector.cpp create the CallShader lowering and map it to int_spv_CallShader in SPIRVInstructionSelector::selectIntrinsic.
  • Create SPIR-V backend test case in llvm/test/CodeGen/SPIRV/hlsl-intrinsics/CallShader.ll

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
159 CallShader 6.3 ('library', 'closesthit', 'raygeneration', 'miss', 'callable')

SPIR-V

OpExecuteCallableKHR:

Description:

Reserved.

Capability:
RayTracingKHR

Reserved.

Word Count Opcode Results Operands

3

4446

<id>
SBT Index

<id>
Callable Data

Test Case(s)

Example 1

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

struct RayPayload
{
	float4 color;
	float distance;
};
export void fn(uint p1, RayPayload p2) {
    return CallShader(p1, p2);
}

HLSL:

Invokes another shader from within a shader.

Syntax

This intrinsic function definition is equivalent to the following function template:

template<param_t>
void CallShader(uint ShaderIndex, inout param_t Parameter);

Parameters

ShaderIndex

An unsigned integer representing the index into the callable shader table specified in the call to DispatchRays.

Parameter

The user-defined parameters to pass to the callable shader. This parameter structure must match the parameter structure used in the callable shader pointed to in the shader table.

Return Value

void

Remarks

This function can be called from the following raytracing shader types:

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