-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DirectX] Implement the resource.load.rawbuffer intrinsic (#121012)
This introduces `@llvm.dx.resource.load.rawbuffer` and generalizes the buffer load docs under DirectX/DXILResources. This resolves the "load" parts of #106188
- Loading branch information
Showing
9 changed files
with
519 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
; RUN: opt -S -dxil-op-lower %s | FileCheck %s | ||
; Before SM6.2 ByteAddressBuffer and StructuredBuffer lower to bufferLoad. | ||
|
||
target triple = "dxil-pc-shadermodel6.1-compute" | ||
|
||
; CHECK-LABEL: define void @loadf32_struct | ||
define void @loadf32_struct(i32 %index) { | ||
%buffer = call target("dx.RawBuffer", float, 0, 0, 0) | ||
@llvm.dx.resource.handlefrombinding.tdx.RawBuffer_f32_0_0_0( | ||
i32 0, i32 0, i32 1, i32 0, i1 false) | ||
|
||
; CHECK: [[DATA:%.*]] = call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle %{{.*}}, i32 %index, i32 0) | ||
%load = call {float, i1} | ||
@llvm.dx.resource.load.rawbuffer.f32.tdx.RawBuffer_f32_0_0_0t( | ||
target("dx.RawBuffer", float, 0, 0, 0) %buffer, | ||
i32 %index, | ||
i32 0) | ||
|
||
ret void | ||
} | ||
|
||
; CHECK-LABEL: define void @loadv4f32_byte | ||
define void @loadv4f32_byte(i32 %offset) { | ||
%buffer = call target("dx.RawBuffer", i8, 0, 0, 0) | ||
@llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i8_0_0_0( | ||
i32 0, i32 0, i32 1, i32 0, i1 false) | ||
|
||
; CHECK: [[DATA:%.*]] = call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle %{{.*}}, i32 %offset, i32 0) | ||
%load = call {<4 x float>, i1} | ||
@llvm.dx.resource.load.rawbuffer.f32.tdx.RawBuffer_i8_0_0_0t( | ||
target("dx.RawBuffer", i8, 0, 0, 0) %buffer, | ||
i32 %offset, | ||
i32 0) | ||
|
||
ret void | ||
} | ||
|
||
; CHECK-LABEL: define void @loadnested | ||
define void @loadnested(i32 %index) { | ||
%buffer = call | ||
target("dx.RawBuffer", {i32, {<4 x float>, <3 x half>}}, 0, 0, 0) | ||
@llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, i1 false) | ||
|
||
; CHECK: [[DATAI32:%.*]] = call %dx.types.ResRet.i32 @dx.op.bufferLoad.i32(i32 68, %dx.types.Handle %{{.*}}, i32 %index, i32 0) | ||
%loadi32 = call {i32, i1} @llvm.dx.resource.load.rawbuffer.i32( | ||
target("dx.RawBuffer", {i32, {<4 x float>, <3 x half>}}, 0, 0, 0) %buffer, | ||
i32 %index, i32 0) | ||
|
||
; CHECK: [[DATAF32:%.*]] = call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle %{{.*}}, i32 %index, i32 4) | ||
%loadf32 = call {<4 x float>, i1} @llvm.dx.resource.load.rawbuffer.v4f32( | ||
target("dx.RawBuffer", {i32, {<4 x float>, <3 x half>}}, 0, 0, 0) %buffer, | ||
i32 %index, i32 4) | ||
|
||
; CHECK: [[DATAF16:%.*]] = call %dx.types.ResRet.f16 @dx.op.bufferLoad.f16(i32 68, %dx.types.Handle %{{.*}}, i32 %index, i32 20) | ||
%loadf16 = call {<3 x half>, i1} @llvm.dx.resource.load.rawbuffer.v3f16( | ||
target("dx.RawBuffer", {i32, {<4 x float>, <3 x half>}}, 0, 0, 0) %buffer, | ||
i32 %index, i32 20) | ||
|
||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; We use llc for this test so that we don't abort after the first error. | ||
; RUN: not llc %s -o /dev/null 2>&1 | FileCheck %s | ||
|
||
target triple = "dxil-pc-shadermodel6.2-compute" | ||
|
||
declare void @v4f64_user(<4 x double>) | ||
|
||
; Can't load 64 bit types directly until SM6.3 (byteaddressbuf.Load<int64_t4>) | ||
; CHECK: error: | ||
; CHECK-SAME: in function loadv4f64_byte | ||
; CHECK-SAME: Cannot create RawBufferLoad operation: Invalid overload type | ||
define void @loadv4f64_byte(i32 %offset) "hlsl.export" { | ||
%buffer = call target("dx.RawBuffer", i8, 0, 0, 0) | ||
@llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i8_0_0_0( | ||
i32 0, i32 0, i32 1, i32 0, i1 false) | ||
|
||
%load = call {<4 x double>, i1} @llvm.dx.resource.load.rawbuffer.v4i64( | ||
target("dx.RawBuffer", i8, 0, 0, 0) %buffer, i32 %offset, i32 0) | ||
%data = extractvalue {<4 x double>, i1} %load, 0 | ||
|
||
call void @v4f64_user(<4 x double> %data) | ||
|
||
ret void | ||
} |
Oops, something went wrong.