Skip to content

Commit ed204f4

Browse files
committed
inline image intrinsics: compiletest for image writes with disasm
1 parent ba15d4c commit ed204f4

File tree

4 files changed

+189
-0
lines changed

4 files changed

+189
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// build-pass
2+
// compile-flags: -C target-feature=+StorageImageWriteWithoutFormat
3+
// compile-flags: -C llvm-args=--disassemble
4+
// normalize-stderr-test "OpSource .*\n" -> ""
5+
// normalize-stderr-test "OpLine .*\n" -> ""
6+
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
7+
// normalize-stderr-test "; .*\n" -> ""
8+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
9+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
10+
// ignore-vulkan1.0
11+
// ignore-vulkan1.1
12+
// ignore-spv1.0
13+
// ignore-spv1.1
14+
// ignore-spv1.2
15+
// ignore-spv1.3
16+
17+
use spirv_std::glam::*;
18+
use spirv_std::spirv;
19+
use spirv_std::{Image, arch};
20+
21+
#[spirv(compute(threads(8, 8)))]
22+
pub fn main(
23+
#[spirv(global_invocation_id)] global_id: UVec3,
24+
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] fill_color: &Vec4,
25+
#[spirv(descriptor_set = 0, binding = 1)] image: &Image!(2D, type=f32, sampled=false),
26+
) {
27+
unsafe {
28+
image.write(global_id.xy(), *fill_color);
29+
}
30+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
OpCapability Shader
2+
OpCapability StorageImageWriteWithoutFormat
3+
OpMemoryModel Logical Simple
4+
OpEntryPoint GLCompute %1 "main" %2 %3 %4
5+
OpExecutionMode %1 LocalSize 8 8 1
6+
OpName %2 "global_id"
7+
OpName %3 "fill_color"
8+
OpName %4 "image"
9+
OpName %8 "<spirv_std::image::Image<f32, 1, 2, 0, 0, 2, 0, 4>>::write::<u32, glam::u32::uvec2::UVec2>"
10+
OpDecorate %9 Block
11+
OpMemberDecorate %9 0 Offset 0
12+
OpDecorate %2 BuiltIn GlobalInvocationId
13+
OpDecorate %3 NonWritable
14+
OpDecorate %3 Binding 0
15+
OpDecorate %3 DescriptorSet 0
16+
OpDecorate %4 Binding 1
17+
OpDecorate %4 DescriptorSet 0
18+
%10 = OpTypeInt 32 0
19+
%11 = OpTypeVector %10 3
20+
%12 = OpTypePointer Input %11
21+
%13 = OpTypeFloat 32
22+
%14 = OpTypeVector %13 4
23+
%9 = OpTypeStruct %14
24+
%15 = OpTypePointer StorageBuffer %9
25+
%16 = OpTypeImage %13 2D 2 0 0 2 Unknown
26+
%17 = OpTypePointer UniformConstant %16
27+
%18 = OpTypeVoid
28+
%19 = OpTypeFunction %18
29+
%2 = OpVariable %12 Input
30+
%20 = OpTypePointer StorageBuffer %14
31+
%3 = OpVariable %15 StorageBuffer
32+
%21 = OpConstant %10 0
33+
%22 = OpTypeVector %10 2
34+
%23 = OpTypeFunction %18 %17 %22 %14
35+
%4 = OpVariable %17 UniformConstant
36+
%1 = OpFunction %18 None %19
37+
%24 = OpLabel
38+
%25 = OpLoad %11 %2
39+
%26 = OpInBoundsAccessChain %20 %3 %21
40+
%27 = OpCompositeExtract %10 %25 0
41+
%28 = OpCompositeExtract %10 %25 1
42+
%29 = OpLoad %14 %26
43+
%30 = OpCompositeConstruct %22 %27 %28
44+
%31 = OpFunctionCall %18 %8 %4 %30 %29
45+
OpNoLine
46+
OpReturn
47+
OpFunctionEnd
48+
%8 = OpFunction %18 None %23
49+
%32 = OpFunctionParameter %17
50+
%33 = OpFunctionParameter %22
51+
%34 = OpFunctionParameter %14
52+
%35 = OpLabel
53+
%36 = OpCompositeExtract %10 %33 0
54+
%37 = OpCompositeExtract %10 %33 1
55+
%38 = OpCompositeConstruct %22 %36 %37
56+
%39 = OpLoad %16 %32
57+
OpImageWrite %39 %38 %34
58+
OpNoLine
59+
OpReturn
60+
OpFunctionEnd
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// build-pass
2+
// compile-flags: -C target-feature=+StorageImageExtendedFormats
3+
// compile-flags: -C llvm-args=--disassemble
4+
// normalize-stderr-test "OpSource .*\n" -> ""
5+
// normalize-stderr-test "OpLine .*\n" -> ""
6+
// normalize-stderr-test "%\d+ = OpString .*\n" -> ""
7+
// normalize-stderr-test "; .*\n" -> ""
8+
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
9+
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
10+
// ignore-vulkan1.0
11+
// ignore-vulkan1.1
12+
// ignore-spv1.0
13+
// ignore-spv1.1
14+
// ignore-spv1.2
15+
// ignore-spv1.3
16+
17+
use spirv_std::glam::*;
18+
use spirv_std::spirv;
19+
use spirv_std::{Image, arch};
20+
21+
#[spirv(compute(threads(8, 8)))]
22+
pub fn main(
23+
#[spirv(global_invocation_id)] global_id: UVec3,
24+
#[spirv(descriptor_set = 0, binding = 0, storage_buffer)] fill_color: &Vec2,
25+
#[spirv(descriptor_set = 0, binding = 1)] image: &Image!(2D, format = rg32f, sampled = false),
26+
) {
27+
unsafe {
28+
image.write(global_id.xy(), *fill_color);
29+
}
30+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
OpCapability Shader
2+
OpCapability StorageImageExtendedFormats
3+
OpMemoryModel Logical Simple
4+
OpEntryPoint GLCompute %1 "main" %2 %3 %4
5+
OpExecutionMode %1 LocalSize 8 8 1
6+
OpName %2 "global_id"
7+
OpName %3 "fill_color"
8+
OpName %4 "image"
9+
OpName %8 "<spirv_std::image::Image<f32, 1, 2, 0, 0, 2, 6, 2>>::write::<u32, glam::u32::uvec2::UVec2>"
10+
OpDecorate %9 Block
11+
OpMemberDecorate %9 0 Offset 0
12+
OpDecorate %2 BuiltIn GlobalInvocationId
13+
OpDecorate %3 NonWritable
14+
OpDecorate %3 Binding 0
15+
OpDecorate %3 DescriptorSet 0
16+
OpDecorate %4 Binding 1
17+
OpDecorate %4 DescriptorSet 0
18+
%10 = OpTypeInt 32 0
19+
%11 = OpTypeVector %10 3
20+
%12 = OpTypePointer Input %11
21+
%13 = OpTypeFloat 32
22+
%14 = OpTypeVector %13 2
23+
%9 = OpTypeStruct %14
24+
%15 = OpTypePointer StorageBuffer %9
25+
%16 = OpTypeImage %13 2D 2 0 0 2 Rg32f
26+
%17 = OpTypePointer UniformConstant %16
27+
%18 = OpTypeVoid
28+
%19 = OpTypeFunction %18
29+
%2 = OpVariable %12 Input
30+
%20 = OpTypePointer StorageBuffer %14
31+
%3 = OpVariable %15 StorageBuffer
32+
%21 = OpConstant %10 0
33+
%22 = OpTypePointer StorageBuffer %13
34+
%23 = OpConstant %10 1
35+
%24 = OpTypeVector %10 2
36+
%25 = OpTypeFunction %18 %17 %24 %14
37+
%4 = OpVariable %17 UniformConstant
38+
%1 = OpFunction %18 None %19
39+
%26 = OpLabel
40+
%27 = OpLoad %11 %2
41+
%28 = OpInBoundsAccessChain %20 %3 %21
42+
%29 = OpCompositeExtract %10 %27 0
43+
%30 = OpCompositeExtract %10 %27 1
44+
%31 = OpInBoundsAccessChain %22 %28 %21
45+
%32 = OpLoad %13 %31
46+
%33 = OpInBoundsAccessChain %22 %28 %23
47+
%34 = OpLoad %13 %33
48+
%35 = OpCompositeConstruct %24 %29 %30
49+
%36 = OpCompositeConstruct %14 %32 %34
50+
%37 = OpFunctionCall %18 %8 %4 %35 %36
51+
OpNoLine
52+
OpReturn
53+
OpFunctionEnd
54+
%8 = OpFunction %18 None %25
55+
%38 = OpFunctionParameter %17
56+
%39 = OpFunctionParameter %24
57+
%40 = OpFunctionParameter %14
58+
%41 = OpLabel
59+
%42 = OpCompositeExtract %10 %39 0
60+
%43 = OpCompositeExtract %10 %39 1
61+
%44 = OpCompositeConstruct %24 %42 %43
62+
%45 = OpCompositeExtract %13 %40 0
63+
%46 = OpCompositeExtract %13 %40 1
64+
%47 = OpCompositeConstruct %14 %45 %46
65+
%48 = OpLoad %16 %38
66+
OpImageWrite %48 %44 %47
67+
OpNoLine
68+
OpReturn
69+
OpFunctionEnd

0 commit comments

Comments
 (0)