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 ObjectRayDirection HLSL Function #99190

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

Implement the ObjectRayDirection HLSL Function #99190

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

DirectX

DXIL Opcode DXIL OpName Shader Model Shader Stages
150 ObjectRayDirection 6.3 ('library', 'intersection', 'anyhit', 'closesthit')

SPIR-V

ObjectRayDirectionKHR

Short Description

ObjectRayDirectionKHR - Ray direction in object space

Description

ObjectRayDirectionKHR
A variable decorated with the ObjectRayDirectionKHR decoration will
specify the direction of the ray being processed, in object space.

Valid Usage



  • VUID-ObjectRayDirectionKHR-ObjectRayDirectionKHR-04299

    The ObjectRayDirectionKHR decoration must be used only within
    the IntersectionKHR , AnyHitKHR , or ClosestHitKHR
    Execution Model



  • VUID-ObjectRayDirectionKHR-ObjectRayDirectionKHR-04300

    The variable decorated with ObjectRayDirectionKHR must be
    declared using the Input Storage Class



  • VUID-ObjectRayDirectionKHR-ObjectRayDirectionKHR-04301

    The variable decorated with ObjectRayDirectionKHR must be
    declared as a three-component vector of 32-bit floating-point values

Test Case(s)

Example 1

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

export float3 fn() {
    return ObjectRayDirection();
}

SPIRV Example(s):

Example 2

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

[shader("intersection")]
void fn() {
float3 	ret = ObjectRayDirection();
}

HLSL:

The object-space direction for the current ray. Object-space refers to the space of the current bottom-level acceleration structure.

Syntax

float3 ObjectRayDirection();

Remarks

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

See also

Direct3D 12 Raytracing HLSL Reference

@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