forked from Nukepayload2/OpenCLBasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleCode.vb
More file actions
31 lines (24 loc) · 1.06 KB
/
Copy pathSampleCode.vb
File metadata and controls
31 lines (24 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Option Strict Off
Imports System.Runtime.CompilerServices
Imports System.Runtime.InteropServices
Imports OpenCLBasic.ClCodeGenerator.FakeRuntime
Public Module SampleProgram
Const sampler As Sampler = CLK.NORMALIZED_COORDS_FALSE Or CLK.ADDRESS_CLAMP Or CLK.FILTER_NEAREST
' 比较 BGRA32 像素格式的图片 A 和 B。如果颜色不一样, 则输出与 A 反色的像素点。否则输出透明像素点。
' Public -> __kernel, ByVal -> __read_only, <Out> ByRef -> __write_only, GetGlobalId 变量 -> const
' 其中的内容应该被阻止直接执行。
<MethodImpl(MethodImplOptions.ForwardRef)>
Public Sub ImageDiffBlend(imageA As Image2D, imageB As Image2D, <Out> ByRef imageC As Image2D)
Dim x As Integer = GetGlobalId(0)
Dim y As Integer = GetGlobalId(1)
Dim coord As Int2 = (x, y)
Dim A As UInt4 = ReadImageUI(imageA, sampler, coord)
Dim B As UInt4 = ReadImageUI(imageB, sampler, coord)
Dim C As UInt4 = 0
If A <> B Then
C = -A
C.w = 255
End If
WriteImageUI(imageC, coord, A - B)
End Sub
End Module