This patch implements the SPIR-V lowering for the following HLSL intrinsics: - SampleBias - SampleGrad - SampleLevel - SampleCmp - SampleCmpLevelZero It defines the required LLVM intrinsics in 'IntrinsicsDirectX.td' and 'IntrinsicsSPIRV.td'. It updates 'SPIRVInstructionSelector.cpp' to handle the new intrinsics and generates the correct 'OpImageSample*' instructions with the required operands (Bias, Grad, Lod, ConstOffset, MinLod, etc.). CodeGen tests are added to verify the implementation for images with dimension 1D, 2D, 3D, and Cube. Assisted-by: Gemini
19 lines
1.4 KiB
LLVM
19 lines
1.4 KiB
LLVM
; RUN: not llc -O0 -mtriple=spirv-vulkan-compute %s -o /dev/null 2>&1 | FileCheck %s
|
|
|
|
; CHECK: error: {{.*}} Non-constant offsets are not supported in sample instructions.
|
|
|
|
@.str = private unnamed_addr constant [4 x i8] c"img\00", align 1
|
|
@.str.1 = private unnamed_addr constant [5 x i8] c"samp\00", align 1
|
|
|
|
define <4 x float> @sample_no_debug(<2 x i32> %offset) {
|
|
entry:
|
|
%img = tail call target("spirv.Image", float, 1, 2, 0, 0, 1, 0) @llvm.spv.resource.handlefrombinding.tspirv.Image_f32_1_2_0_0_1_0t(i32 0, i32 0, i32 1, i32 0, ptr @.str)
|
|
%sampler = tail call target("spirv.Sampler") @llvm.spv.resource.handlefrombinding.tspirv.Samplert(i32 0, i32 1, i32 1, i32 0, ptr @.str.1)
|
|
%res = call <4 x float> @llvm.spv.resource.sample.v4f32.tspirv.Image_f32_1_2_0_0_1_0t.tspirv.Samplert.v2f32.v2i32(target("spirv.Image", float, 1, 2, 0, 0, 1, 0) %img, target("spirv.Sampler") %sampler, <2 x float> zeroinitializer, <2 x i32> %offset)
|
|
ret <4 x float> %res
|
|
}
|
|
|
|
declare target("spirv.Image", float, 1, 2, 0, 0, 1, 0) @llvm.spv.resource.handlefrombinding.tspirv.Image_f32_1_2_0_0_1_0t(i32, i32, i32, i32, ptr)
|
|
declare target("spirv.Sampler") @llvm.spv.resource.handlefrombinding.tspirv.Samplert(i32, i32, i32, i32, ptr)
|
|
declare <4 x float> @llvm.spv.resource.sample.v4f32.tspirv.Image_f32_1_2_0_0_1_0t.tspirv.Samplert.v2f32.v2i32(target("spirv.Image", float, 1, 2, 0, 0, 1, 0), target("spirv.Sampler"), <2 x float>, <2 x i32>)
|