This introduces `__builtin_hlsl_resource_getpointer`, which lowers to `llvm.dx.resource.getpointer` and is used to implement indexing into resources. This will only work through the backend for typed buffers at this point, but the changes to structured buffers should be correct as far as the frontend is concerned. Note: We probably want this to return a reference in the HLSL device address space, but for now we're just using address space 0. Creating a device address space and updating this code can be done later as necessary. Fixes #95956
26 lines
1.2 KiB
HLSL
26 lines
1.2 KiB
HLSL
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-DXIL
|
|
// RUN-DISABLED: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-SPIRV
|
|
|
|
// NOTE: SPIRV codegen for resource methods is not yet implemented
|
|
|
|
RWStructuredBuffer<float> RWSB1 : register(u0);
|
|
RWStructuredBuffer<float> RWSB2 : register(u1);
|
|
|
|
// CHECK: %"class.hlsl::RWStructuredBuffer" = type { target("dx.RawBuffer", float, 1, 0) }
|
|
|
|
export void TestIncrementCounter() {
|
|
RWSB1.IncrementCounter();
|
|
}
|
|
|
|
// CHECK: define void @_Z20TestIncrementCounterv()
|
|
// CHECK-DXIL: call i32 @llvm.dx.bufferUpdateCounter.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", float, 1, 0) %{{[0-9]+}}, i8 1)
|
|
|
|
export void TestDecrementCounter() {
|
|
RWSB2.DecrementCounter();
|
|
}
|
|
|
|
// CHECK: define void @_Z20TestDecrementCounterv()
|
|
// CHECK-DXIL: call i32 @llvm.dx.bufferUpdateCounter.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", float, 1, 0) %{{[0-9]+}}, i8 -1)
|
|
|
|
// CHECK: declare i32 @llvm.dx.bufferUpdateCounter.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", float, 1, 0), i8)
|