-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpenCL.pas
84 lines (52 loc) · 2.07 KB
/
OpenCL.pas
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
{%../../Common/LicenseHeader.txt%}
unit OpenCL;
{$zerobasedstrings}
interface
uses System;
uses System.Runtime.InteropServices;
uses System.Runtime.CompilerServices;
type
{$region Вспомогательные типы}
{%Types.Interface!Pack Essentials.pas%}
{$endregion Вспомогательные типы}
{$region Особые типы}
{%!!}clErrorCode = record procedure RaiseIfError; end;{%}
OpenCLException = sealed class(Exception)
private ec: clErrorCode;
public property Code: clErrorCode read ec;
public constructor(ec: clErrorCode; message: string);
begin
inherited Create(message);
self.ec := ec;
end;
public constructor(ec: clErrorCode) :=
Create(ec, $'Ошибка OpenCL: {ec}');
end;
{$endregion Особые типы}
{$region Подпрограммы ядра}
{%Feature.Interface!Pack Essentials.pas%}
{$endregion Подпрограммы ядра}
{$region Подпрограммы расширений}
{%Extension.Interface!Pack Essentials.pas%}
{$endregion Подпрограммы расширений}
implementation
{$region Особые типы}
type
platform_id = {%>cl_platform_id!!}IntPtr{%};
loadable_platform = record
private id: platform_id;
private static function clGetExtensionFunctionAddressForPlatform(pl: platform_id; name: string): IntPtr; external 'OpenCL';
public function GetProcAddress(name: string) := clGetExtensionFunctionAddressForPlatform(self.id, name);
end;
cl_extension_base = abstract class
public pl: loadable_platform;
public constructor(pl: platform_id) := self.pl.id := pl;
end;
procedure clErrorCode.RaiseIfError :=
{%>if IS_ERROR then%} raise new OpenCLException(self);
{$endregion Особые типы}
{$region Инициализаторы расширений}
{%Extension.Implementation!Pack Essentials.pas%}
{$endregion Инициализаторы расширений}
end.