forked from red-prig/fpPS4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsrRefId.pas
86 lines (68 loc) · 1.46 KB
/
srRefId.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
85
unit srRefId;
{$mode objfpc}{$H+}
interface
uses
sysutils,
srNode;
type
ntRefId=class(TsrNodeVmt)
class function GetPrintName(node:PsrNode):RawByteString; override;
class function GetRef(node:PsrNode):Pointer; override;
end;
PsrRefId=^TsrRefId;
TsrRefId=object
ID:DWORD;
function Alloc:Boolean; inline;
end;
PsrRefNode=^TsrRefNode;
TsrRefNode=object(TsrNode)
ID:TsrRefId;
Procedure Init; inline;
function GetPrintName:RawByteString;
end;
PsrRefIdAlloc=^TsrRefIdAlloc;
TsrRefIdAlloc=object
FSpirvID:DWORD;
function FetchSpirvID:DWORD; inline;
procedure FetchSpirvID(P:PsrRefId);
function GetSpirvIDBound:DWORD; inline;
end;
implementation
class function ntRefId.GetPrintName(node:PsrNode):RawByteString;
begin
Result:=PsrRefNode(node)^.GetPrintName;
end;
class function ntRefId.GetRef(node:PsrNode):Pointer;
begin
Result:=@PsrRefNode(node)^.ID;
end;
Procedure TsrRefNode.Init; inline;
begin
fntype:=ntRefId;
end;
function TsrRefNode.GetPrintName:RawByteString;
begin
Assert(ID.ID<>0);
Result:=IntToStr(ID.ID);
end;
function TsrRefId.Alloc:Boolean; inline;
begin
Result:=(ID<>0);
end;
function TsrRefIdAlloc.FetchSpirvID:DWORD; inline;
begin
Inc(FSpirvID);
Result:=FSpirvID;
end;
procedure TsrRefIdAlloc.FetchSpirvID(P:PsrRefId);
begin
if (P<>nil) and (not P^.Alloc) then
begin
P^.ID:=FetchSpirvID;
end;
end;
function TsrRefIdAlloc.GetSpirvIDBound:DWORD; inline;
begin
Result:=FSpirvID+1;
end;
end.