Просмотр исходного кода

* implemented vkuSwapChain and vkuSwapChainFactory

master
Bergmann89 10 лет назад
Родитель
Сommit
e1091caa24
18 измененных файлов: 2317 добавлений и 1476 удалений
  1. +1
    -0
      data/vulkan.tpl
  2. +1424
    -1142
      projects/Vulkan.pas
  3. +125
    -42
      projects/generator/HeaderGenerator.pas
  4. +72
    -57
      projects/generator/generator.lps
  5. +9
    -1
      projects/triangle/triangle.lpi
  6. +1
    -1
      projects/triangle/triangle.lpr
  7. +185
    -152
      projects/triangle/triangle.lps
  8. +91
    -3
      projects/triangle/uMainForm.pas
  9. +4
    -3
      projects/utils/uvkuDevice.pas
  10. +13
    -8
      projects/utils/uvkuDeviceFactory.pas
  11. +1
    -1
      projects/utils/uvkuInstance.pas
  12. +0
    -22
      projects/utils/uvkuInstanceFactory.pas
  13. +35
    -27
      projects/utils/uvkuPhysicalDevice.pas
  14. +23
    -1
      projects/utils/uvkuSurface.pas
  15. +14
    -5
      projects/utils/uvkuSurfaceFactory.pas
  16. +130
    -0
      projects/utils/uvkuSwapChain.pas
  17. +178
    -0
      projects/utils/uvkuSwapChainFactory.pas
  18. +11
    -11
      projects/utils/uvkuUtils.pas

+ 1
- 0
data/vulkan.tpl Просмотреть файл

@@ -27,6 +27,7 @@ unit Vulkan;
{$LINKLIB c} {$LINKLIB c}
{$ENDIF} {$ENDIF}
{$MINENUMSIZE 4} {$MINENUMSIZE 4}
{$PACKSET 4}
{$ENDIF} {$ENDIF}


{$I Vulkan.inc} {$I Vulkan.inc}


+ 1424
- 1142
projects/Vulkan.pas
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 125
- 42
projects/generator/HeaderGenerator.pas Просмотреть файл

@@ -98,13 +98,17 @@ type
private private
fParent: WideString; fParent: WideString;
fAlias: WideString; fAlias: WideString;
fBitmask: Boolean;
fRequires: WideString;
protected protected
function GetDependencyOrder: Integer; override; function GetDependencyOrder: Integer; override;
procedure GenPascalName(var aName: WideString; const aPointer: Integer; const aArrSize: WideString); override; procedure GenPascalName(var aName: WideString; const aPointer: Integer; const aArrSize: WideString); override;
public public
property Parent: WideString read fParent write fParent; property Parent: WideString read fParent write fParent;
property Alias: WideString read fAlias write fAlias; property Alias: WideString read fAlias write fAlias;

property BitMask: Boolean read fBitmask write fBitmask;
property Requires: WideString read fRequires write fRequires;
procedure ReadXml(const xml: TDOMNode); override;
procedure GenerateCode(const aCode: TStringTree); override; procedure GenerateCode(const aCode: TStringTree); override;
end; end;


@@ -112,6 +116,7 @@ type
TvkType = class(TvkTypeBase) TvkType = class(TvkTypeBase)
public public
procedure ReadXml(const xml: TDOMNode); override; procedure ReadXml(const xml: TDOMNode); override;
procedure GenerateCode(const aCode: TStringTree); override;
constructor Create; constructor Create;
end; end;


@@ -208,11 +213,13 @@ type
TValueList = specialize TutlList<TValue>; TValueList = specialize TutlList<TValue>;
private private
fExpands: WideString; fExpands: WideString;
fBitmask: Boolean;
fValues: TValueList; fValues: TValueList;
protected protected
procedure GenPascalName(var aName: WideString; const aPointer: Integer; const aArrSize: WideString); override; procedure GenPascalName(var aName: WideString; const aPointer: Integer; const aArrSize: WideString); override;
public public
property Expands: WideString read fExpands write fExpands; property Expands: WideString read fExpands write fExpands;
property Bitmask: Boolean read fBitmask write fBitmask;
property Values: TValueList read fValues; property Values: TValueList read fValues;
procedure ReadXml(const xml: TDOMNode); override; procedure ReadXml(const xml: TDOMNode); override;
procedure GenerateCode(const aCode: TStringTree); override; procedure GenerateCode(const aCode: TStringTree); override;
@@ -276,6 +283,7 @@ const
KEYWORD_COMMENT = 'COMMENT'; KEYWORD_COMMENT = 'COMMENT';
KEYWORD_VAR = 'VAR'; KEYWORD_VAR = 'VAR';
KEYWORD_CODE = 'CODE'; KEYWORD_CODE = 'CODE';
KEYWORD_SETS = 'SETS';


KEYWORD_INSTANCE_COMMANDS = 'INSTANCE_COMMANDS'; KEYWORD_INSTANCE_COMMANDS = 'INSTANCE_COMMANDS';
KEYWORD_DEVICE_COMMANDS = 'DEVICE_COMMANDS'; KEYWORD_DEVICE_COMMANDS = 'DEVICE_COMMANDS';
@@ -304,19 +312,24 @@ begin
try try
result := Unassigned; result := Unassigned;


rx.Expression := '^-?([0-9]+)$';
if rx.Exec(s) then
rx.Expression := '^-?\s*([0-9]+)\s*$';
if rx.Exec(s) then begin
result := StrToInt(rx.Match[0]); result := StrToInt(rx.Match[0]);
exit;
end;


rx.Expression := '^0x([0-9A-Fa-f]+)$'; rx.Expression := '^0x([0-9A-Fa-f]+)$';
if rx.Exec(s) then
if rx.Exec(s) then begin
result := '$' + rx.Match[1]; result := '$' + rx.Match[1];
exit;
end;


rx.Expression := '^([0-9\.]+)(f|d)?$'; rx.Expression := '^([0-9\.]+)(f|d)?$';
if rx.Exec(s) then begin if rx.Exec(s) then begin
result := StrToFloat(rx.Match[1], f); result := StrToFloat(rx.Match[1], f);
if (rx.Match[2] = 'd') then if (rx.Match[2] = 'd') then
result := Double(result); result := Double(result);
exit;
end; end;


rx.Expression := '^\(~0U([L]*)\)$'; rx.Expression := '^\(~0U([L]*)\)$';
@@ -839,27 +852,24 @@ begin
inherited GenPascalName(aName, aPointer, aArrSize); inherited GenPascalName(aName, aPointer, aArrSize);
end; end;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure THeaderGenerator.TvkTypeBase.ReadXml(const xml: TDOMNode);
begin
inherited ReadXml(xml);
fRequires := GetNodeAttrib(xml, 'requires', '');
fBitmask := (GetNodeAttrib(xml, 'category', '') = 'bitmask');
end;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure THeaderGenerator.TvkTypeBase.GenerateCode(const aCode: TStringTree); procedure THeaderGenerator.TvkTypeBase.GenerateCode(const aCode: TStringTree);
var st: TStringTree;
begin begin
inherited GenerateCode(aCode); inherited GenerateCode(aCode);

if Assigned(fList) and (fParent <> '') then if Assigned(fList) and (fParent <> '') then
fList.GenerateCode(fParent, aCode); fList.GenerateCode(fParent, aCode);
if Assigned(fList) and (fAlias <> '') then if Assigned(fList) and (fAlias <> '') then
fList.GenerateCode(fAlias, aCode); fList.GenerateCode(fAlias, aCode);

st := aCode.GetOrCreateItem(KEYWORD_INTF).GetOrCreateItem(KEYWORD_TYPES);
if (st.LinesBefore.Count = 0) then
st.LinesBefore.Add('type { simple types }');
st := st.GetOrCreateItem(String(fName));
if (st.LinesBefore.Count = 0) and (fParent <> '') and Assigned(List) then begin
st.LinesBefore.Add(Format(' %-62s = %s;', [ fName, List.GetPascalName(fParent, 0) ]));
st.LinesBefore.Add(Format(' P%-61s = ^%0:s;', [ fName ]));
st.LinesBefore.Add(Format(' PP%-60s = ^P%0:s;', [ fName ]));
st.LinesBefore.Add('');
end;
if Assigned(fList) and (fRequires <> '') then
fList.GenerateCode(fRequires, aCode);
end; end;


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -872,6 +882,29 @@ begin
Parent := GetNodeValue(xml, 'type'); Parent := GetNodeValue(xml, 'type');
end; end;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure THeaderGenerator.TvkType.GenerateCode(const aCode: TStringTree);
var
st: TStringTree;
n: String;
begin
inherited GenerateCode(aCode);

st := aCode.GetOrCreateItem(KEYWORD_INTF).GetOrCreateItem(KEYWORD_TYPES);
if (st.LinesBefore.Count = 0) then
st.LinesBefore.Add('type { simple types }');
st := st.GetOrCreateItem(String(fName));
n := List.GetPascalName(fParent, 0);
if fBitmask and (fRequires <> '') then
n := 'T' + fRequires;
if (st.LinesBefore.Count = 0) and (fParent <> '') and Assigned(List) then begin
st.LinesBefore.Add(Format(' %-62s = %s;', [ fName, n ]));
st.LinesBefore.Add(Format(' P%-61s = ^%0:s;', [ fName ]));
st.LinesBefore.Add(Format(' PP%-60s = ^P%0:s;', [ fName ]));
st.LinesBefore.Add('');
end;
end;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor THeaderGenerator.TvkType.Create; constructor THeaderGenerator.TvkType.Create;
begin begin
@@ -901,10 +934,7 @@ var
st: TStringTree; st: TStringTree;
s: String; s: String;
begin begin
if Assigned(fList) and (fParent <> '') then
fList.GenerateCode(fParent, aCode);
if Assigned(fList) and (fAlias <> '') then
fList.GenerateCode(fAlias, aCode);
inherited GenerateCode(aCode);


st := aCode.GetOrCreateItem(KEYWORD_INTF).GetOrCreateItem(KEYWORD_TYPES); st := aCode.GetOrCreateItem(KEYWORD_INTF).GetOrCreateItem(KEYWORD_TYPES);
if (st.LinesBefore.Count = 0) then if (st.LinesBefore.Count = 0) then
@@ -1383,9 +1413,11 @@ procedure THeaderGenerator.TvkEnum.ReadXml(const xml: TDOMNode);
var var
x, p: TDOMNode; x, p: TDOMNode;
v: TValue; v: TValue;
i: Integer;
begin begin
Name := GetNodeAttrib(xml, 'name');
Expands := GetNodeAttrib(xml, 'expand', '');
Name := GetNodeAttrib(xml, 'name');
Expands := GetNodeAttrib(xml, 'expand', '');
Bitmask := (GetNodeAttrib(xml, 'type', '') = 'bitmask');
x := xml.FirstChild; x := xml.FirstChild;
while Assigned(x) do begin while Assigned(x) do begin
if (x.NodeName = 'enum') then begin if (x.NodeName = 'enum') then begin
@@ -1407,6 +1439,16 @@ begin
if (v.Value = Unassigned) then if (v.Value = Unassigned) then
raise XmlException.Create(WideString('invalid enum value (' + p.TextContent + ')'), xml); raise XmlException.Create(WideString('invalid enum value (' + p.TextContent + ')'), xml);


if (Expands <> '') then begin
i := 1;
while (i <= Length(Expands)) and (i <= Length(v.Name)) and (v.Name[i] = Expands[i]) do
inc(i);
if (i <= Length(Expands)) and (Expands[i] = '_') then
dec(i);
Expands := copy(Expands, 1, i-1);
end else
Expands := v.Name;

Values.Add(v); Values.Add(v);
except except
FreeAndNil(v); FreeAndNil(v);
@@ -1420,10 +1462,11 @@ end;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure THeaderGenerator.TvkEnum.GenerateCode(const aCode: TStringTree); procedure THeaderGenerator.TvkEnum.GenerateCode(const aCode: TStringTree);
var var
st, vt: TStringTree;
st, st2, vt: TStringTree;
s, bitName, s2: String;
i: Integer; i: Integer;
v: TValue;
postfix: String;
tmp: QWord;
v, v2: TValue;
begin begin
inherited GenerateCode(aCode); inherited GenerateCode(aCode);
st := aCode st := aCode
@@ -1433,22 +1476,56 @@ begin
st.LinesBefore.Add('type { enumerations }'); st.LinesBefore.Add('type { enumerations }');
st := st.GetOrCreateItem(String(fName)); st := st.GetOrCreateItem(String(fName));
if (st.LinesBefore.Count = 0) then begin if (st.LinesBefore.Count = 0) then begin
st.LinesBefore.Add(Format(' %s = (', [GetPascalName(0, '')]));
postfix := ',';
bitName := GetPascalName(0, '');
if fBitmask then
bitName := StringReplace(bitName, 'Bits', 'Bit', [rfReplaceAll]);
st.LinesBefore.Add(Format(' %s = (', [bitName]));
vt := st.GetOrCreateItem(KEYWORD_ENUM_VALUES); vt := st.GetOrCreateItem(KEYWORD_ENUM_VALUES);
s := '';
for i := 0 to fValues.Count-1 do begin for i := 0 to fValues.Count-1 do begin
v := fValues[i]; v := fValues[i];
if (i = fValues.Count-1) and (fExpands = '') then
postfix := '';
if (v.IsBit)
then vt.LinesBefore.Add(Format(' %-60s = (1 shl %s)%s', [v.Name, v.Value, postfix]))
else vt.LinesBefore.Add(Format(' %-60s = %s%s', [v.Name, v.Value, postfix]));
if not v.IsBit and fBitmask then begin
st2 := aCode
.GetOrCreateItem(KEYWORD_INTF)
.GetOrCreateItem(KEYWORD_SETS);
if (st2.LinesBefore.Count = 0) then
st2.LinesBefore.Add('const { predefined flags / sets }');
st2 := st2.GetOrCreateItem(v.Name);
if (st2.LinesBefore.Count = 0) then begin
tmp := StrToInt(v.Value);
s2 := '';
for v2 in fValues do begin
if v2.IsBit and ((tmp and (1 shl v2.Value)) <> 0) then begin
if (s2 <> '') then
s2 := s2 + ',' + sLineBreak;
s2 := s2 + ' ' + v2.Name;
end;
end;
if (s2 <> '') then
s2 := sLineBreak + s2 + sLineBreak;
st2.LinesBefore.Text := Format(' %s: %s = [' +
'%s' +
' ];', [v.Name, GetPascalName(0, ''), s2]);
end;
end else begin
if (s <> '') then
s := s + ',' + sLineBreak;
s := s + Format(' %-60s = %s', [v.Name, v.Value]);
end;
end; end;
if (fExpands <> '') then
st.LinesAfter.Add(Format(' %-60s = %s', [fExpands + '_MAX_ENUM', '$7FFFFFFF']));
if (fExpands <> '') then begin
if fBitmask
then s := s + ',' + sLineBreak + Format(' %-60s = 31', [fExpands+'MAX_BIT'])
else s := s + ',' + sLineBreak + Format(' %-60s = %s', [fExpands + '_MAX_ENUM', '$7FFFFFFF']);
end;

vt.LinesBefore.Text := s;
st.LinesAfter.Add(' );'); st.LinesAfter.Add(' );');
st.LinesAfter.Add(' P%s = ^T%0:s;', [ fName ]);
st.LinesAfter.Add(' PP%s = ^P%0:s;', [ fName ]);
if not fBitmask then begin
st.LinesAfter.Add(' P%s = ^T%0:s;', [ fName ]);
st.LinesAfter.Add(' PP%s = ^P%0:s;', [ fName ]);
end else
st.LinesAfter.Add(' %s = set of %s;', [ GetPascalName(0, ''), bitName ]);
st.LinesAfter.Add(''); st.LinesAfter.Add('');
end; end;
end; end;
@@ -1531,8 +1608,8 @@ var
procedure UpdateComments; procedure UpdateComments;
begin begin
UpdateComment([KEYWORD_INTF, KEYWORD_CONST]); UpdateComment([KEYWORD_INTF, KEYWORD_CONST]);
UpdateComment([KEYWORD_INTF, KEYWORD_TYPES]);
UpdateComment([KEYWORD_INTF, KEYWORD_ENUM]); UpdateComment([KEYWORD_INTF, KEYWORD_ENUM]);
UpdateComment([KEYWORD_INTF, KEYWORD_TYPES]);
UpdateComment([KEYWORD_INTF, KEYWORD_FUNCPTR]); UpdateComment([KEYWORD_INTF, KEYWORD_FUNCPTR]);
UpdateComment([KEYWORD_INTF, KEYWORD_STRUCT]); UpdateComment([KEYWORD_INTF, KEYWORD_STRUCT]);
UpdateComment([KEYWORD_INTF, KEYWORD_COMMAND]); UpdateComment([KEYWORD_INTF, KEYWORD_COMMAND]);
@@ -1604,6 +1681,7 @@ var
value: WideString; value: WideString;
offset: Integer; offset: Integer;
s: String; s: String;
i: Integer;
c: TvkConst; c: TvkConst;
begin begin
result := false; result := false;
@@ -1615,12 +1693,17 @@ var
offset := 1000000000 + 1000 * (CurrentNumber-1) + offset; offset := 1000000000 + 1000 * (CurrentNumber-1) + offset;
if (GetNodeAttrib(xml, 'dir', '') = '-') then if (GetNodeAttrib(xml, 'dir', '') = '-') then
offset := -1 * offset; offset := -1 * offset;
Code
with Code
.GetOrCreateItem(KEYWORD_INTF) .GetOrCreateItem(KEYWORD_INTF)
.GetOrCreateItem(KEYWORD_ENUM) .GetOrCreateItem(KEYWORD_ENUM)
.GetOrCreateItem(String(ex)) .GetOrCreateItem(String(ex))
.GetOrCreateItem(KEYWORD_ENUM_VALUES)
.LinesBefore.Add(Format(' %-60s = %s,', [name, IntToStr(offset)]));
.GetOrCreateItem(KEYWORD_ENUM_VALUES) do
begin
i := LinesBefore.Count-1;
if (i >= 0) and (Pos('MAX_ENUM', LinesBefore[i]) > 0) then
dec(i);
LinesBefore.Insert(i+1, Format(' %-60s = %s,', [name, IntToStr(offset)]));
end;
end else begin end else begin
if not TryGetNodeAttrib(xml, 'value', value) then if not TryGetNodeAttrib(xml, 'value', value) then
exit; exit;
@@ -1802,8 +1885,8 @@ begin
Code.GetOrCreateItem(KEYWORD_COMMENT).LinesBefore.Text := Trim(String(fComment)); Code.GetOrCreateItem(KEYWORD_COMMENT).LinesBefore.Text := Trim(String(fComment));
with Code.GetOrCreateItem(KEYWORD_INTF) do begin with Code.GetOrCreateItem(KEYWORD_INTF) do begin
GetOrCreateItem(KEYWORD_CONST).LinesAfter.Add(''); GetOrCreateItem(KEYWORD_CONST).LinesAfter.Add('');
GetOrCreateItem(KEYWORD_TYPES).LinesAfter.Add('');
GetOrCreateItem(KEYWORD_ENUM).LinesAfter.Add(''); GetOrCreateItem(KEYWORD_ENUM).LinesAfter.Add('');
GetOrCreateItem(KEYWORD_TYPES).LinesAfter.Add('');
GetOrCreateItem(KEYWORD_FUNCPTR).LinesAfter.Add(''); GetOrCreateItem(KEYWORD_FUNCPTR).LinesAfter.Add('');
GetOrCreateItem(KEYWORD_STRUCT).LinesAfter.Add(''); GetOrCreateItem(KEYWORD_STRUCT).LinesAfter.Add('');
GetOrCreateItem(KEYWORD_COMMAND).LinesAfter.Add(''); GetOrCreateItem(KEYWORD_COMMAND).LinesAfter.Add('');


+ 72
- 57
projects/generator/generator.lps Просмотреть файл

@@ -8,161 +8,176 @@
<Unit0> <Unit0>
<Filename Value="generator.lpr"/> <Filename Value="generator.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<CursorPos X="3" Y="11"/>
<UsageCount Value="21"/>
<TopLine Value="63"/>
<CursorPos Y="78"/>
<UsageCount Value="23"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
<Filename Value="HeaderGenerator.pas"/> <Filename Value="HeaderGenerator.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<UsageCount Value="21"/>
<TopLine Value="1494"/>
<CursorPos X="78" Y="1518"/>
<UsageCount Value="23"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit1> </Unit1>
<Unit2> <Unit2>
<Filename Value="uutlGenerics.pas"/> <Filename Value="uutlGenerics.pas"/>
<EditorIndex Value="3"/>
<EditorIndex Value="4"/>
<TopLine Value="1374"/> <TopLine Value="1374"/>
<CursorPos X="63" Y="1393"/> <CursorPos X="63" Y="1393"/>
<UsageCount Value="10"/>
<UsageCount Value="11"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="..\Vulkan.pas"/> <Filename Value="..\Vulkan.pas"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<TopLine Value="3935"/>
<CursorPos X="33" Y="4655"/>
<UsageCount Value="10"/>
<TopLine Value="666"/>
<CursorPos X="41" Y="691"/>
<UsageCount Value="11"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
<Filename Value="..\utils\uvkuSurfaceFactory.pas"/> <Filename Value="..\utils\uvkuSurfaceFactory.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="247"/>
<CursorPos X="4" Y="275"/>
<EditorIndex Value="3"/>
<CursorPos X="68"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit4> </Unit4>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="HeaderGenerator.pas"/> <Filename Value="HeaderGenerator.pas"/>
<Caret Line="1193" Column="73" TopLine="1178"/>
<Caret Line="1446" TopLine="1432"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="HeaderGenerator.pas"/> <Filename Value="HeaderGenerator.pas"/>
<Caret Line="997" Column="33" TopLine="984"/>
<Caret Line="1450" TopLine="1432"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="HeaderGenerator.pas"/> <Filename Value="HeaderGenerator.pas"/>
<Caret Line="989" Column="35" TopLine="974"/>
<Caret Line="1446" TopLine="1432"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="HeaderGenerator.pas"/> <Filename Value="HeaderGenerator.pas"/>
<Caret Line="986" Column="7" TopLine="971"/>
<Caret Line="1450" TopLine="1432"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="HeaderGenerator.pas"/> <Filename Value="HeaderGenerator.pas"/>
<Caret Line="961" Column="3" TopLine="945"/>
<Caret Line="1446" Column="19" TopLine="1432"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="HeaderGenerator.pas"/> <Filename Value="HeaderGenerator.pas"/>
<Caret Line="912" Column="41" TopLine="897"/>
<Caret Line="215" Column="27" TopLine="205"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="914" Column="17" TopLine="899"/>
<Filename Value="..\Vulkan.pas"/>
<Caret TopLine="69"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="970" Column="59" TopLine="955"/>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="528" Column="31" TopLine="503"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="HeaderGenerator.pas"/> <Filename Value="HeaderGenerator.pas"/>
<Caret Line="977" Column="33" TopLine="963"/>
<Caret Line="1447" Column="20" TopLine="1432"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="uutlGenerics.pas"/>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="1186" Column="75" TopLine="1175"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="uutlGenerics.pas"/>
<Caret Line="777" Column="19" TopLine="762"/>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="215" Column="70" TopLine="200"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="uutlGenerics.pas"/>
<Caret Line="791" Column="28" TopLine="776"/>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1447" TopLine="1431"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="uutlGenerics.pas"/>
<Caret Line="817" Column="10" TopLine="802"/>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1518" Column="89" TopLine="1504"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="uutlGenerics.pas"/>
<Caret Line="885" Column="77" TopLine="870"/>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1449" Column="49" TopLine="1431"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="uutlGenerics.pas"/>
<Caret Line="830" TopLine="819"/>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1448" TopLine="1431"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="uutlGenerics.pas"/>
<Caret Line="885" Column="90" TopLine="870"/>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1452" TopLine="1431"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="uutlGenerics.pas"/>
<Caret Line="889" Column="77" TopLine="874"/>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1446" TopLine="1431"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="uutlGenerics.pas"/>
<Caret Line="920" Column="27" TopLine="905"/>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="527" Column="31" TopLine="504"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="uutlGenerics.pas"/>
<Caret Line="1014" Column="29" TopLine="999"/>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="557" Column="28" TopLine="532"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="uutlGenerics.pas"/>
<Caret Line="1027" Column="12" TopLine="1012"/>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="567" Column="29" TopLine="542"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="uutlGenerics.pas"/>
<Caret Line="1038" Column="19" TopLine="1023"/>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="579" Column="29" TopLine="554"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="uutlGenerics.pas"/>
<Caret Line="1073" Column="46" TopLine="1058"/>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="599" Column="22" TopLine="574"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="generator.lpr"/>
<Caret Line="9" Column="58"/>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="609" Column="32" TopLine="584"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="..\Vulkan.pas"/> <Filename Value="..\Vulkan.pas"/>
<Caret Line="4455" Column="18" TopLine="4434"/>
<Caret Line="615" Column="44" TopLine="590"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="..\Vulkan.pas"/> <Filename Value="..\Vulkan.pas"/>
<Caret Line="4644" Column="115" TopLine="4641"/>
<Caret Line="637" Column="31" TopLine="612"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="..\Vulkan.pas"/> <Filename Value="..\Vulkan.pas"/>
<Caret Line="646" Column="29" TopLine="621"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="..\Vulkan.pas"/> <Filename Value="..\Vulkan.pas"/>
<Caret Line="4306" Column="20" TopLine="4299"/>
<Caret Line="654" Column="36" TopLine="629"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="..\Vulkan.pas"/> <Filename Value="..\Vulkan.pas"/>
<Caret Line="4663" Column="5" TopLine="4649"/>
<Caret Line="660" Column="47" TopLine="635"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="..\Vulkan.pas"/> <Filename Value="..\Vulkan.pas"/>
<Caret Line="690" Column="70" TopLine="675"/>
<Caret Line="666" Column="41" TopLine="641"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="4565" Column="21" TopLine="4550"/>
<Filename Value="HeaderGenerator.pas"/>
<Caret Line="1446" TopLine="1431"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectSession> </ProjectSession>
<Debugging>
<Watches Count="2">
<Item1>
<Expression Value="s"/>
</Item1>
<Item2>
<Expression Value="fExpands"/>
</Item2>
</Watches>
</Debugging>
</CONFIG> </CONFIG>

+ 9
- 1
projects/triangle/triangle.lpi Просмотреть файл

@@ -33,7 +33,7 @@
<PackageName Value="LCL"/> <PackageName Value="LCL"/>
</Item1> </Item1>
</RequiredPackages> </RequiredPackages>
<Units Count="12">
<Units Count="14">
<Unit0> <Unit0>
<Filename Value="triangle.lpr"/> <Filename Value="triangle.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
@@ -85,6 +85,14 @@
<Filename Value="..\utils\uvkuSurfaceFactory.pas"/> <Filename Value="..\utils\uvkuSurfaceFactory.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
</Unit11> </Unit11>
<Unit12>
<Filename Value="..\utils\uvkuSwapChainFactory.pas"/>
<IsPartOfProject Value="True"/>
</Unit12>
<Unit13>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<IsPartOfProject Value="True"/>
</Unit13>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>


+ 1
- 1
projects/triangle/triangle.lpr Просмотреть файл

@@ -7,7 +7,7 @@ uses
{$IFDEF UNIX}{$IFDEF UseCThreads} {$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads, cthreads,
{$ENDIF}{$ENDIF} {$ENDIF}{$ENDIF}
Interfaces, Dialogs, Forms, uMainForm, Vulkan, uvkuDevice, uvkuDeviceFactory;
Interfaces, Dialogs, Forms, uMainForm, Vulkan;


{$R *.res} {$R *.res}




+ 185
- 152
projects/triangle/triangle.lps Просмотреть файл

@@ -4,14 +4,13 @@
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="9"/> <Version Value="9"/>
<BuildModes Active="Default"/> <BuildModes Active="Default"/>
<Units Count="30">
<Units Count="32">
<Unit0> <Unit0>
<Filename Value="triangle.lpr"/> <Filename Value="triangle.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="7"/>
<CursorPos X="79" Y="10"/>
<UsageCount Value="51"/>
<Loaded Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="48" Y="10"/>
<UsageCount Value="55"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
@@ -19,353 +18,387 @@
<ComponentName Value="MainForm"/> <ComponentName Value="MainForm"/>
<HasResources Value="True"/> <HasResources Value="True"/>
<ResourceBaseClass Value="Form"/> <ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<TopLine Value="65"/>
<CursorPos X="28" Y="79"/>
<UsageCount Value="51"/>
<TopLine Value="20"/>
<CursorPos X="5" Y="36"/>
<UsageCount Value="55"/>
<Loaded Value="True"/> <Loaded Value="True"/>
<LoadedDesigner Value="True"/> <LoadedDesigner Value="True"/>
</Unit1> </Unit1>
<Unit2> <Unit2>
<Filename Value="..\Vulkan.pas"/> <Filename Value="..\Vulkan.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="5"/>
<TopLine Value="163"/>
<CursorPos X="63" Y="188"/>
<EditorIndex Value="7"/>
<TopLine Value="4263"/>
<CursorPos X="61" Y="4268"/>
<ExtraEditorCount Value="1"/> <ExtraEditorCount Value="1"/>
<ExtraEditor1> <ExtraEditor1>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="4282"/>
<CursorPos X="79" Y="4295"/>
<TopLine Value="42"/>
<CursorPos X="12" Y="50"/>
</ExtraEditor1> </ExtraEditor1>
<UsageCount Value="51"/>
<UsageCount Value="55"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="..\utils\uvkuInstance.pas"/> <Filename Value="..\utils\uvkuInstance.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="8"/>
<TopLine Value="12"/>
<CursorPos X="10" Y="24"/>
<UsageCount Value="49"/>
<Loaded Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="98"/>
<CursorPos X="33" Y="117"/>
<UsageCount Value="53"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
<Filename Value="..\utils\uvkuInstanceFactory.pas"/> <Filename Value="..\utils\uvkuInstanceFactory.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="4"/>
<CursorPos X="58" Y="160"/>
<UsageCount Value="43"/>
<Loaded Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="42"/>
<CursorPos Y="55"/>
<UsageCount Value="47"/>
</Unit4> </Unit4>
<Unit5> <Unit5>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/> <Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="10"/>
<TopLine Value="241"/>
<CursorPos Y="250"/>
<UsageCount Value="43"/>
<EditorIndex Value="4"/>
<TopLine Value="154"/>
<CursorPos X="3" Y="163"/>
<UsageCount Value="47"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit5> </Unit5>
<Unit6> <Unit6>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/> <Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<EditorIndex Value="5"/>
<TopLine Value="73"/> <TopLine Value="73"/>
<CursorPos X="23" Y="93"/>
<UsageCount Value="33"/>
<CursorPos Y="100"/>
<UsageCount Value="37"/>
<Loaded Value="True"/>
</Unit6> </Unit6>
<Unit7> <Unit7>
<Filename Value="..\utils\uvkuUtils.pas"/>
<EditorIndex Value="-1"/>
<UsageCount Value="43"/>
</Unit7>
<Unit8>
<Filename Value="..\utils\uvkuDevice.pas"/> <Filename Value="..\utils\uvkuDevice.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="18"/>
<CursorPos X="17" Y="32"/>
<UsageCount Value="36"/>
<EditorIndex Value="3"/>
<TopLine Value="21"/>
<CursorPos Y="50"/>
<UsageCount Value="41"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit7>
<Unit8>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="165"/>
<CursorPos Y="158"/>
<UsageCount Value="39"/>
</Unit8> </Unit8>
<Unit9> <Unit9>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<Filename Value="..\utils\uvkuPhysicalDeviceFactory.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="2"/>
<TopLine Value="44"/>
<CursorPos X="73" Y="58"/>
<UsageCount Value="34"/>
<Loaded Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="74" Y="30"/>
<UsageCount Value="40"/>
</Unit9> </Unit9>
<Unit10> <Unit10>
<Filename Value="..\utils\uvkuPhysicalDeviceFactory.pas"/>
<Filename Value="..\utils\uvkuSurface.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="9"/>
<CursorPos X="74" Y="30"/>
<UsageCount Value="35"/>
<EditorIndex Value="2"/>
<TopLine Value="11"/>
<CursorPos X="71" Y="66"/>
<UsageCount Value="34"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit10> </Unit10>
<Unit11> <Unit11>
<Filename Value="..\utils\uvkuSurface.pas"/>
<Filename Value="..\utils\uvkuSurfaceFactory.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="3"/>
<CursorPos Y="59"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="187"/>
<CursorPos Y="200"/>
<UsageCount Value="33"/>
</Unit11> </Unit11>
<Unit12> <Unit12>
<Filename Value="..\utils\uvkuSurfaceFactory.pas"/>
<Filename Value="..\utils\uvkuSwapChainFactory.pas"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<EditorIndex Value="6"/>
<TopLine Value="9"/>
<CursorPos X="20" Y="18"/>
<UsageCount Value="28"/>
<EditorIndex Value="1"/>
<TopLine Value="128"/>
<CursorPos Y="152"/>
<UsageCount Value="24"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit12> </Unit12>
<Unit13> <Unit13>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="6"/>
<CursorPos X="65" Y="93"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
<Filename Value="..\utils\uvkuUtils.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="423"/>
<CursorPos X="61" Y="447"/>
<UsageCount Value="43"/>
</Unit14>
<Unit15>
<Filename Value="..\..\data\Vulkan.tpl"/> <Filename Value="..\..\data\Vulkan.tpl"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="44"/> <TopLine Value="44"/>
<CursorPos X="27" Y="22"/> <CursorPos X="27" Y="22"/>
<UsageCount Value="14"/> <UsageCount Value="14"/>
<DefaultSyntaxHighlighter Value="None"/> <DefaultSyntaxHighlighter Value="None"/>
</Unit13>
<Unit14>
</Unit15>
<Unit16>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\packages\fcl-base\src\custapp.pp"/> <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\packages\fcl-base\src\custapp.pp"/>
<UnitName Value="CustApp"/> <UnitName Value="CustApp"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="13"/> <TopLine Value="13"/>
<CursorPos X="3" Y="30"/> <CursorPos X="3" Y="30"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit14>
<Unit15>
</Unit16>
<Unit17>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\inc\objpash.inc"/> <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\inc\objpash.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="213"/> <TopLine Value="213"/>
<CursorPos X="21" Y="224"/> <CursorPos X="21" Y="224"/>
<UsageCount Value="9"/> <UsageCount Value="9"/>
</Unit15>
<Unit16>
</Unit17>
<Unit18>
<Filename Value="C:\Zusatzprogramme\Lazarus\lcl\include\customform.inc"/> <Filename Value="C:\Zusatzprogramme\Lazarus\lcl\include\customform.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="138"/> <TopLine Value="138"/>
<CursorPos Y="154"/> <CursorPos Y="154"/>
<UsageCount Value="9"/> <UsageCount Value="9"/>
</Unit16>
<Unit17>
</Unit18>
<Unit19>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\objpas\sysutils\sysstrh.inc"/> <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\objpas\sysutils\sysstrh.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="96"/> <TopLine Value="96"/>
<CursorPos X="10" Y="112"/> <CursorPos X="10" Y="112"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit17>
<Unit18>
</Unit19>
<Unit20>
<Filename Value="..\Vulkan_old.pas"/> <Filename Value="..\Vulkan_old.pas"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<WindowIndex Value="-1"/> <WindowIndex Value="-1"/>
<TopLine Value="2195"/> <TopLine Value="2195"/>
<CursorPos X="3" Y="2211"/> <CursorPos X="3" Y="2211"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit18>
<Unit19>
</Unit20>
<Unit21>
<Filename Value="..\Vulkan.inc"/> <Filename Value="..\Vulkan.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<CursorPos X="9" Y="5"/> <CursorPos X="9" Y="5"/>
<UsageCount Value="11"/> <UsageCount Value="11"/>
</Unit19>
<Unit20>
</Unit21>
<Unit22>
<Filename Value="C:\Zusatzprogramme\Lazarus\lcl\forms.pp"/> <Filename Value="C:\Zusatzprogramme\Lazarus\lcl\forms.pp"/>
<UnitName Value="Forms"/> <UnitName Value="Forms"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="1249"/> <TopLine Value="1249"/>
<CursorPos X="3" Y="1268"/> <CursorPos X="3" Y="1268"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit20>
<Unit21>
</Unit22>
<Unit23>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\objpas\classes\classesh.inc"/> <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\objpas\classes\classesh.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="2100"/> <TopLine Value="2100"/>
<CursorPos X="38" Y="2125"/> <CursorPos X="38" Y="2125"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit21>
<Unit22>
</Unit23>
<Unit24>
<Filename Value="C:\Zusatzprogramme\Lazarus\lcl\extctrls.pp"/> <Filename Value="C:\Zusatzprogramme\Lazarus\lcl\extctrls.pp"/>
<UnitName Value="ExtCtrls"/> <UnitName Value="ExtCtrls"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="1023"/> <TopLine Value="1023"/>
<CursorPos X="3" Y="1038"/> <CursorPos X="3" Y="1038"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit22>
<Unit23>
</Unit24>
<Unit25>
<Filename Value="C:\Zusatzprogramme\Lazarus\lcl\controls.pp"/> <Filename Value="C:\Zusatzprogramme\Lazarus\lcl\controls.pp"/>
<UnitName Value="Controls"/> <UnitName Value="Controls"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="2240"/> <TopLine Value="2240"/>
<CursorPos X="3" Y="2255"/> <CursorPos X="3" Y="2255"/>
<UsageCount Value="10"/> <UsageCount Value="10"/>
</Unit23>
<Unit24>
</Unit25>
<Unit26>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\objpas\sysutils\sysutilh.inc"/> <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\objpas\sysutils\sysutilh.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="22"/> <TopLine Value="22"/>
<CursorPos X="4" Y="37"/> <CursorPos X="4" Y="37"/>
<UsageCount Value="12"/> <UsageCount Value="12"/>
</Unit24>
<Unit25>
</Unit26>
<Unit27>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win\sysosh.inc"/> <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win\sysosh.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="7"/> <TopLine Value="7"/>
<CursorPos X="3" Y="22"/> <CursorPos X="3" Y="22"/>
<UsageCount Value="12"/> <UsageCount Value="12"/>
</Unit25>
<Unit26>
</Unit27>
<Unit28>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\inc\systemh.inc"/> <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\inc\systemh.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="93"/> <TopLine Value="93"/>
<CursorPos X="19" Y="108"/> <CursorPos X="19" Y="108"/>
<UsageCount Value="12"/> <UsageCount Value="12"/>
</Unit26>
<Unit27>
</Unit28>
<Unit29>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win\wininc\ascdef.inc"/> <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win\wininc\ascdef.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="57"/> <TopLine Value="57"/>
<CursorPos X="10" Y="72"/> <CursorPos X="10" Y="72"/>
<UsageCount Value="12"/> <UsageCount Value="12"/>
</Unit27>
<Unit28>
</Unit29>
<Unit30>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win32\windows.pp"/> <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win32\windows.pp"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<UsageCount Value="12"/> <UsageCount Value="12"/>
</Unit28>
<Unit29>
</Unit30>
<Unit31>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win\wininc\base.inc"/> <Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\win\wininc\base.inc"/>
<EditorIndex Value="-1"/> <EditorIndex Value="-1"/>
<TopLine Value="84"/> <TopLine Value="84"/>
<CursorPos X="6" Y="99"/> <CursorPos X="6" Y="99"/>
<UsageCount Value="12"/> <UsageCount Value="12"/>
</Unit29>
</Unit31>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="28">
<JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="272" Column="3" TopLine="246"/>
<Filename Value="..\utils\uvkuSwapChainFactory.pas"/>
<Caret Line="134" TopLine="127"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="258" Column="10" TopLine="239"/>
<Filename Value="..\utils\uvkuSwapChainFactory.pas"/>
<Caret Line="135" TopLine="127"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="262" Column="79" TopLine="244"/>
<Filename Value="..\utils\uvkuSwapChainFactory.pas"/>
<Caret Line="136" TopLine="127"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="62" Column="63" TopLine="48"/>
<Filename Value="..\utils\uvkuSwapChainFactory.pas"/>
<Caret Line="151" TopLine="127"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="262" Column="101" TopLine="244"/>
<Filename Value="..\utils\uvkuSwapChainFactory.pas"/>
<Caret Line="152" TopLine="128"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="..\utils\uvkuSurface.pas"/>
<Caret Line="14" Column="3"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="93" TopLine="73"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="..\utils\uvkuSurface.pas"/>
<Caret Line="57" Column="51" TopLine="42"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="94" TopLine="73"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="..\utils\uvkuSurface.pas"/>
<Caret Line="69" Column="12" TopLine="63"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="95" TopLine="73"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="..\utils\uvkuSurface.pas"/>
<Caret Line="24" Column="67" TopLine="14"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="96" TopLine="73"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="..\utils\uvkuSurfaceFactory.pas"/>
<Caret Line="198" Column="87" TopLine="176"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="97" TopLine="73"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="triangle.lpr"/>
<Caret Line="10" Column="48"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="98" TopLine="73"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="uMainForm.pas"/>
<Caret Line="100" Column="60" TopLine="76"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="99" TopLine="73"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="..\utils\uvkuInstance.pas"/>
<Caret Line="31" Column="27" TopLine="14"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="100" TopLine="73"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="..\utils\uvkuSurfaceFactory.pas"/>
<Caret Line="161" Column="87" TopLine="115"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="74" TopLine="61"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="..\utils\uvkuSurfaceFactory.pas"/>
<Caret Line="150" Column="14" TopLine="136"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="79" TopLine="61"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="..\utils\uvkuSurfaceFactory.pas"/>
<Caret Line="188" Column="24" TopLine="174"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="76" TopLine="61"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="uMainForm.pas"/>
<Caret Line="11" Column="34" TopLine="90"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="77" TopLine="61"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="uMainForm.pas"/>
<Caret Line="101" TopLine="91"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="78" TopLine="61"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="96" Column="15" TopLine="56"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="51" TopLine="36"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="55" Column="11" TopLine="40"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="52" TopLine="36"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="4454" Column="11" TopLine="4439"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="53" TopLine="36"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="..\Vulkan.pas"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="55" TopLine="36"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="86" Column="30" TopLine="61"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="57" TopLine="36"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<Caret Line="76" Column="22" TopLine="58"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="78" TopLine="63"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<Caret Line="179" TopLine="215"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="203" TopLine="190"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="uMainForm.pas"/> <Filename Value="uMainForm.pas"/>
<Caret Line="30" Column="5" TopLine="4"/>
<Caret Line="36" Column="5" TopLine="20"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<Caret Line="198" Column="96" TopLine="187"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="15" Column="28" TopLine="11"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="uMainForm.pas"/>
<Caret Line="12" Column="32"/>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="1635" Column="61" TopLine="1626"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="uMainForm.pas"/>
<Caret Line="111" Column="6" TopLine="89"/>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="3089" Column="61" TopLine="3081"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<Caret Line="58" Column="73" TopLine="44"/>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
<Caret Line="29" Column="20" TopLine="20"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectSession> </ProjectSession>
<Debugging>
<BreakPoints Count="1">
<Item1>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="uMainForm.pas"/>
<Line Value="203"/>
</Item1>
</BreakPoints>
<Watches Count="1">
<Item1>
<Expression Value="self"/>
</Item1>
</Watches>
</Debugging>
</CONFIG> </CONFIG>

+ 91
- 3
projects/triangle/uMainForm.pas Просмотреть файл

@@ -8,8 +8,10 @@ uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
Vulkan, uvkuAllocationHandler, Vulkan, uvkuAllocationHandler,
uvkuInstance, uvkuInstanceFactory, uvkuInstance, uvkuInstanceFactory,
uvkuPhysicalDevice, uvkuPhysicalDeviceFactory,
uvkuSurface, uvkuSurfaceFactory, uvkuSurface, uvkuSurfaceFactory,
uvkuDevice, uvkuDeviceFactory;
uvkuDevice, uvkuDeviceFactory,
uvkuSwapChain, uvkuSwapChainFactory;


type type
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -28,8 +30,10 @@ type
private private
fAllocHandler: TCustomAllocHandler; fAllocHandler: TCustomAllocHandler;
fInstance: TvkuInstance; fInstance: TvkuInstance;
fPhyDevice: TvkuPhysicalDevice;
fDevice: TvkuDevice; fDevice: TvkuDevice;
fSurface: TvkuSurface; fSurface: TvkuSurface;
fSwapChain: TvkuSwapChain;
public public
{ public declarations } { public declarations }
end; end;
@@ -74,25 +78,42 @@ procedure TMainForm.FormCreate(Sender: TObject);
var var
PhyDevices: TvkuPhysicalDeviceArr; PhyDevices: TvkuPhysicalDeviceArr;
iFactory: TvkuInstanceFactory; iFactory: TvkuInstanceFactory;
pdFactory: TvkuPhysicalDeviceFactory;
dFactory: TvkuDeviceFactory; dFactory: TvkuDeviceFactory;
sFactory: TvkuSurfaceFactory; sFactory: TvkuSurfaceFactory;
scFactory: TvkuSwapChainFactory;

qci: TvkuQueueCreateInfo; qci: TvkuQueueCreateInfo;
SrfFormats: TvkuSurfaceFormatArr;
SurfaceCapabilities: TVkSurfaceCapabilitiesKHR;
PresentModes: TvkuPresentModeArr;
pm: TVkPresentModeKHR;
begin begin
fAllocHandler := TCustomAllocHandler.Create; fAllocHandler := TCustomAllocHandler.Create;



WriteLn('create vulkan instance'); WriteLn('create vulkan instance');
iFactory := TvkuInstanceFactory.Create; iFactory := TvkuInstanceFactory.Create;
try try
iFactory.Extensions.Add(VK_KHR_SURFACE_EXTENSION_NAME); iFactory.Extensions.Add(VK_KHR_SURFACE_EXTENSION_NAME);
iFactory.Extensions.Add(TvkuInstanceFactory.GetPlatformSurfaceExtensionName);
iFactory.Extensions.Add(TvkuSurface.GetPlatformSurfaceExtensionName);
fInstance := iFactory.CreateInstance(fAllocHandler, false); fInstance := iFactory.CreateInstance(fAllocHandler, false);
finally finally
FreeAndNil(iFactory); FreeAndNil(iFactory);
end; end;



WriteLn('check physical devices');
PhyDevices := fInstance.GetPhysicalDevices; PhyDevices := fInstance.GetPhysicalDevices;
if (Length(PhyDevices) <= 0) then if (Length(PhyDevices) <= 0) then
raise Exception.Create('unable to get physical device'); raise Exception.Create('unable to get physical device');
pdFactory := TvkuPhysicalDeviceFactory.Create(fInstance);
try
fPhyDevice := pdFactory.CreatePhysicalDevice(PhyDevices[0]);
finally
FreeAndNil(pdFactory);
end;



WriteLn('create vulkan surface'); WriteLn('create vulkan surface');
sFactory := TvkuSurfaceFactory.Create(fInstance); sFactory := TvkuSurfaceFactory.Create(fInstance);
@@ -103,6 +124,7 @@ begin
FreeAndNil(sFactory); FreeAndNil(sFactory);
end; end;



WriteLn('create vulkan device'); WriteLn('create vulkan device');
dFactory := TvkuDeviceFactory.Create(fInstance); dFactory := TvkuDeviceFactory.Create(fInstance);
try try
@@ -114,17 +136,83 @@ begin
dFactory.QueueCreateInfoCount := 1; dFactory.QueueCreateInfoCount := 1;
dFactory.QueueCreateInfo[0] := qci; dFactory.QueueCreateInfo[0] := qci;


fDevice := dFactory.CreateDevice(PhyDevices[0], fAllocHandler, false);
fDevice := dFactory.CreateDevice(fPhyDevice.Handle, fAllocHandler, false);
finally finally
FreeAndNil(dFactory); FreeAndNil(dFactory);
end; end;

WriteLn('create swap chain');
scFactory := TvkuSwapChainFactory.Create(fDevice);
try
scFactory.Surface := fSurface.Handle;
scFactory.ImageUsage := [ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT ];
scFactory.ImageArrayLayers := 1;
scFactory.ImageSharingMode := VK_SHARING_MODE_EXCLUSIVE;
scFactory.Clipped := true;
scFactory.ComposideAlpha := [ VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR ];

WriteLn(' get surface capabilities');
SurfaceCapabilities := fPhyDevice.GetSurfaceCapabilities(fSurface.Handle);
if (SurfaceCapabilities.currentExtent.width = High(VkUint32)) then begin
SurfaceCapabilities.currentExtent.width := ClientWidth;
SurfaceCapabilities.currentExtent.height := ClientHeight;
end else begin
ClientWidth := SurfaceCapabilities.currentExtent.width;
ClientHeight := SurfaceCapabilities.currentExtent.height;
end;
scFactory.ImageExtent := SurfaceCapabilities.currentExtent;

WriteLn(' set min image count');
scFactory.MinImageCount := SurfaceCapabilities.minImageCount + 1;
if (SurfaceCapabilities.maxImageCount > 0) and
(scFactory.MinImageCount > SurfaceCapabilities.maxImageCount) then
scFactory.MinImageCount := SurfaceCapabilities.maxImageCount;

WriteLn(' find suitable image format');
SrfFormats := fPhyDevice.GetSurfaceFormats(fSurface.Handle);
if (Length(SrfFormats) = 0) then begin
WriteLn('no suitable formats found');
halt;
end;
if (Length(SrfFormats) = 1) and (SrfFormats[0].format = VK_FORMAT_UNDEFINED) then begin
scFactory.ImageFormat := VK_FORMAT_R8G8B8A8_UNORM;
scFactory.ImageColorSpace := VK_COLORSPACE_SRGB_NONLINEAR_KHR;
end else begin
scFactory.ImageFormat := SrfFormats[0].format;
scFactory.ImageColorSpace := SrfFormats[0].colorSpace;
end;

WriteLn(' set pre transform');
scFactory.PreTransform := SurfaceCapabilities.currentTransform;
if (VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR in SurfaceCapabilities.supportedTransforms) then
scFactory.PreTransform := scFactory.PreTransform + [ VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR ];

WriteLn(' find suitable present mode');
PresentModes := fPhyDevice.GetSurfacePresentModes(fSurface.Handle);
if (Length(PresentModes) = 0) then begin
WriteLn('unable to get present modes');
halt;
end;
for pm in PresentModes do begin
if (pm = VK_PRESENT_MODE_MAILBOX_KHR) then begin
scFactory.PresentMode := pm;
break;
end;
end;

fSwapChain := scFactory.CreateSwapchain(fAllocHandler, false);
finally
FreeAndNil(scFactory);
end;
end; end;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TMainForm.FormDestroy(Sender: TObject); procedure TMainForm.FormDestroy(Sender: TObject);
begin begin
FreeAndNil(fSwapChain);
FreeAndNil(fDevice); FreeAndNil(fDevice);
FreeAndNil(fSurface); FreeAndNil(fSurface);
FreeAndNil(fPhyDevice);
FreeAndNil(fInstance); FreeAndNil(fInstance);
FreeAndNil(fAllocHandler); FreeAndNil(fAllocHandler);
end; end;


+ 4
- 3
projects/utils/uvkuDevice.pas Просмотреть файл

@@ -22,8 +22,9 @@ type
const aCreateInfo: PVkDeviceCreateInfo; const aCreateInfo: PVkDeviceCreateInfo;
const aAllocCallbacks: PVkAllocationCallbacks); const aAllocCallbacks: PVkAllocationCallbacks);
public public
property Handle: VkDevice read fHandle;
property PhysicalDevice: VkPhysicalDevice read fPhysicalDevice;
property Handle: VkDevice read fHandle;
property PhysicalDevice: VkPhysicalDevice read fPhysicalDevice;
property DeviceCommands: TVkDeviceCommands read fDeviceCommands;


constructor Create( constructor Create(
const aPhysicalDevice: VkPhysicalDevice; const aPhysicalDevice: VkPhysicalDevice;
@@ -89,7 +90,7 @@ destructor TvkuDevice.Destroy;
begin begin
if (fHandle <> VK_INVALID_HANDLE) then begin if (fHandle <> VK_INVALID_HANDLE) then begin
fDeviceCommands.vkDestroyDevice(fHandle, fAllocCallbacks); fDeviceCommands.vkDestroyDevice(fHandle, fAllocCallbacks);
fHandle := nil;
fHandle := VK_INVALID_HANDLE;
end; end;
if Assigned(fAllocCallbacks) then begin if Assigned(fAllocCallbacks) then begin
Dispose(fAllocCallbacks); Dispose(fAllocCallbacks);


+ 13
- 8
projects/utils/uvkuDeviceFactory.pas Просмотреть файл

@@ -30,7 +30,7 @@ type
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuDeviceFactory = class(TObject) TvkuDeviceFactory = class(TObject)
private private
fInstance: TvkuInstance;
fInstanceCommands: TVkInstanceCommands;
fFeatures: TVkPhysicalDeviceFeatures; fFeatures: TVkPhysicalDeviceFeatures;
fFlags: VkDeviceCreateFlags; fFlags: VkDeviceCreateFlags;
fLayers: TStringList; fLayers: TStringList;
@@ -65,6 +65,7 @@ type
const aOwnsHandler: Boolean): TvkuDevice; const aOwnsHandler: Boolean): TvkuDevice;


constructor Create(const aInstance: TvkuInstance); constructor Create(const aInstance: TvkuInstance);
constructor Create(const aInstanceCommands: TVkInstanceCommands);
destructor Destroy; override; destructor Destroy; override;
end; end;


@@ -154,8 +155,6 @@ var
lay: array of PVkChar; lay: array of PVkChar;
ext: array of PVkChar; ext: array of PVkChar;
i: Integer; i: Integer;
prio: VkFloat;
err: TVkResult;
begin begin
if (Length(fQueueCreateInfos) <= 0) then if (Length(fQueueCreateInfos) <= 0) then
raise TvkuException.Create('no queue create infos assigned'); raise TvkuException.Create('no queue create infos assigned');
@@ -194,8 +193,8 @@ begin
CreateInfo.pEnabledFeatures := @fFeatures; CreateInfo.pEnabledFeatures := @fFeatures;


if Assigned(aAllocHandler) if Assigned(aAllocHandler)
then result := TvkuDeviceEx.Create(aPhysicalDevice, CreateInfo, fInstance.InstanceCommands, aAllocHandler.GetAllocationCallbacks)
else result := TvkuDeviceEx.Create(aPhysicalDevice, CreateInfo, fInstance.InstanceCommands);
then result := TvkuDeviceEx.Create(aPhysicalDevice, CreateInfo, fInstanceCommands, aAllocHandler.GetAllocationCallbacks)
else result := TvkuDeviceEx.Create(aPhysicalDevice, CreateInfo, fInstanceCommands);
try try
TvkuDeviceEx(result).fAllocHandler := aAllocHandler; TvkuDeviceEx(result).fAllocHandler := aAllocHandler;
TvkuDeviceEx(result).fOwnsHandler := aOwnsHandler; TvkuDeviceEx(result).fOwnsHandler := aOwnsHandler;
@@ -207,12 +206,18 @@ end;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuDeviceFactory.Create(const aInstance: TvkuInstance); constructor TvkuDeviceFactory.Create(const aInstance: TvkuInstance);
begin
Create(aInstance.InstanceCommands);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuDeviceFactory.Create(const aInstanceCommands: TVkInstanceCommands);
begin begin
inherited Create; inherited Create;
FillByte(fFeatures, SizeOf(fFeatures), 0); FillByte(fFeatures, SizeOf(fFeatures), 0);
fInstance := aInstance;
fLayers := TStringList.Create;
fExtensions := TStringList.Create;
fInstanceCommands := aInstanceCommands;
fLayers := TStringList.Create;
fExtensions := TStringList.Create;
end; end;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


+ 1
- 1
projects/utils/uvkuInstance.pas Просмотреть файл

@@ -114,7 +114,7 @@ destructor TvkuInstance.Destroy;
begin begin
if (fHandle <> VK_INVALID_HANDLE) then begin if (fHandle <> VK_INVALID_HANDLE) then begin
InstanceCommands.vkDestroyInstance(fHandle, fAllocCallbacks); InstanceCommands.vkDestroyInstance(fHandle, fAllocCallbacks);
fHandle := nil;
fHandle := VK_INVALID_HANDLE;
end; end;
if Assigned(fAllocCallbacks) then begin if Assigned(fAllocCallbacks) then begin
Dispose(fAllocCallbacks); Dispose(fAllocCallbacks);


+ 0
- 22
projects/utils/uvkuInstanceFactory.pas Просмотреть файл

@@ -52,8 +52,6 @@ type


constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
public
class function GetPlatformSurfaceExtensionName: String;
end; end;


function vkuApplicationInfo: TvkuApplicationInfo; function vkuApplicationInfo: TvkuApplicationInfo;
@@ -183,25 +181,5 @@ begin
inherited Destroy; inherited Destroy;
end; end;


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class function TvkuInstanceFactory.GetPlatformSurfaceExtensionName: String;
begin
{$IF DEFINED(VK_USE_PLATFORM_XLIB_KHR)}
result := VK_KHR_XLIB_SURFACE_EXTENSION_NAME;
{$ELSEIF DEFINED(VK_USE_PLATFORM_XCB_KHR)}
result := VK_KHR_XCB_SURFACE_EXTENSION_NAME;
{$ELSEIF DEFINED(VK_USE_PLATFORM_WAYLAND_KHR)}
result := VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME;
{$ELSEIF DEFINED(VK_USE_PLATFORM_MIR_KHR)}
result := VK_KHR_MIR_SURFACE_EXTENSION_NAME;
{$ELSEIF DEFINED(VK_USE_PLATFORM_ANDROID_KHR)}
result := VK_KHR_ANDROID_SURFACE_EXTENSION_NAME;
{$ELSEIF DEFINED(VK_USE_PLATFORM_WIN32_KHR)}
result := VK_KHR_WIN32_SURFACE_EXTENSION_NAME;
{$ELSE}
{$ERROR 'unknown or unsupportet platform'}
{$ENDIF}
end;

end. end.



+ 35
- 27
projects/utils/uvkuPhysicalDevice.pas Просмотреть файл

@@ -10,14 +10,14 @@ uses


type type
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TVkQueueFamilyPropertiesArr = array of TVkQueueFamilyProperties;
TVkSparseImageFormatPropertiesArr = array of TVkSparseImageFormatProperties;
TVkSurfaceFormatArr = array of TVkSurfaceFormatKHR;
TVkPresentModeArr = array of TVkPresentModeKHR;
TVkDisplayPropertiesArr = array of TVkDisplayPropertiesKHR;
TVkDisplayPlanePropertiesArr = array of TVkDisplayPlanePropertiesKHR;
TVkDisplayArr = array of VkDisplayKHR;
TVkDisplayModePropertiesArr = array of TVkDisplayModePropertiesKHR;
TvkuQueueFamilyPropertiesArr = array of TVkQueueFamilyProperties;
TvkuSparseImageFormatPropertiesArr = array of TVkSparseImageFormatProperties;
TvkuSurfaceFormatArr = array of TVkSurfaceFormatKHR;
TvkuPresentModeArr = array of TVkPresentModeKHR;
TvkuDisplayPropertiesArr = array of TVkDisplayPropertiesKHR;
TvkuDisplayPlanePropertiesArr = array of TVkDisplayPlanePropertiesKHR;
TvkuDisplayArr = array of VkDisplayKHR;
TvkuDisplayModePropertiesArr = array of TVkDisplayModePropertiesKHR;


TvkuPhysicalDevice = class(TObject) TvkuPhysicalDevice = class(TObject)
private private
@@ -28,7 +28,7 @@ type
function GetFeatures: TVkPhysicalDeviceFeatures; function GetFeatures: TVkPhysicalDeviceFeatures;
function GetProperties: TVkPhysicalDeviceProperties; function GetProperties: TVkPhysicalDeviceProperties;
function GetMemoryProperties: TVkPhysicalDeviceMemoryProperties; function GetMemoryProperties: TVkPhysicalDeviceMemoryProperties;
function GetQueueFamilyProperties: TVkQueueFamilyPropertiesArr;
function GetQueueFamilyProperties: TvkuQueueFamilyPropertiesArr;
function GetFormatProperties(const aFormat: TVkFormat): TVkFormatProperties; function GetFormatProperties(const aFormat: TVkFormat): TVkFormatProperties;
function GetImageFormatProperties( function GetImageFormatProperties(
const aFormat: TVkFormat; const aFormat: TVkFormat;
@@ -41,19 +41,19 @@ type
const aImageType: TVkImageType; const aImageType: TVkImageType;
const aSamples: TVkSampleCountFlagBits; const aSamples: TVkSampleCountFlagBits;
const aUsage: VkImageUsageFlags; const aUsage: VkImageUsageFlags;
const aTiling: TVkImageTiling): TVkSparseImageFormatPropertiesArr;
const aTiling: TVkImageTiling): TvkuSparseImageFormatPropertiesArr;


public { VK_KHR_surface } public { VK_KHR_surface }
function GetSurfaceSupport(const aQueueFamilyIndex: VkUint32; const aSurface: VkSurfaceKHR): Boolean; function GetSurfaceSupport(const aQueueFamilyIndex: VkUint32; const aSurface: VkSurfaceKHR): Boolean;
function GetSurfaceCapabilities(const aSurface: VkSurfaceKHR): TVkSurfaceCapabilitiesKHR; function GetSurfaceCapabilities(const aSurface: VkSurfaceKHR): TVkSurfaceCapabilitiesKHR;
function GetSurfaceFormats(const aSurface: VkSurfaceKHR): TVkSurfaceFormatArr;
function GetSurfacePresentModes(const aSurface: VkSurfaceKHR): TVkPresentModeArr;
function GetSurfaceFormats(const aSurface: VkSurfaceKHR): TvkuSurfaceFormatArr;
function GetSurfacePresentModes(const aSurface: VkSurfaceKHR): TvkuPresentModeArr;


public { VK_KHR_display } public { VK_KHR_display }
function GetDisplayProperties: TVkDisplayPropertiesArr;
function GetDisplayPlaneProperties: TVkDisplayPlanePropertiesArr;
function GetDisplayPlaneSupportedDisplays(const aPlaneIndex: VkUint32): TVkDisplayArr;
function GetDisplayModeProperties(const aDisplay: VkDisplayKHR): TVkDisplayModePropertiesArr;
function GetDisplayProperties: TvkuDisplayPropertiesArr;
function GetDisplayPlaneProperties: TvkuDisplayPlanePropertiesArr;
function GetDisplayPlaneSupportedDisplays(const aPlaneIndex: VkUint32): TvkuDisplayArr;
function GetDisplayModeProperties(const aDisplay: VkDisplayKHR): TvkuDisplayModePropertiesArr;


public public
property Handle: VkPhysicalDevice read fHandle; property Handle: VkPhysicalDevice read fHandle;
@@ -94,9 +94,10 @@ begin
end; end;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetQueueFamilyProperties: TVkQueueFamilyPropertiesArr;
function TvkuPhysicalDevice.GetQueueFamilyProperties: TvkuQueueFamilyPropertiesArr;
var c: VkUint32; var c: VkUint32;
begin begin
result := nil;
if not Assigned(fInstanceCommands.vkGetPhysicalDeviceQueueFamilyProperties) then if not Assigned(fInstanceCommands.vkGetPhysicalDeviceQueueFamilyProperties) then
raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceQueueFamilyProperties; did you load the vulkan core commands?'); raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceQueueFamilyProperties; did you load the vulkan core commands?');
fInstanceCommands.vkGetPhysicalDeviceQueueFamilyProperties(fHandle, @c, nil); fInstanceCommands.vkGetPhysicalDeviceQueueFamilyProperties(fHandle, @c, nil);
@@ -126,9 +127,10 @@ end;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetSparseImageFormatProperties(const aFormat: TVkFormat; const aImageType: TVkImageType; function TvkuPhysicalDevice.GetSparseImageFormatProperties(const aFormat: TVkFormat; const aImageType: TVkImageType;
const aSamples: TVkSampleCountFlagBits; const aUsage: VkImageUsageFlags; const aTiling: TVkImageTiling): TVkSparseImageFormatPropertiesArr;
const aSamples: TVkSampleCountFlagBits; const aUsage: VkImageUsageFlags; const aTiling: TVkImageTiling): TvkuSparseImageFormatPropertiesArr;
var c: VkUint32; var c: VkUint32;
begin begin
result := nil;
if not Assigned(fInstanceCommands.vkGetPhysicalDeviceSparseImageFormatProperties) then if not Assigned(fInstanceCommands.vkGetPhysicalDeviceSparseImageFormatProperties) then
raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceSparseImageFormatProperties; did you load the vulkan core commands?'); raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceSparseImageFormatProperties; did you load the vulkan core commands?');
fInstanceCommands.vkGetPhysicalDeviceSparseImageFormatProperties(fHandle, aFormat, aImageType, aSamples, aUsage, aTiling, @c, nil); fInstanceCommands.vkGetPhysicalDeviceSparseImageFormatProperties(fHandle, aFormat, aImageType, aSamples, aUsage, aTiling, @c, nil);
@@ -163,22 +165,24 @@ begin
end; end;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetSurfaceFormats(const aSurface: VkSurfaceKHR): TVkSurfaceFormatArr;
function TvkuPhysicalDevice.GetSurfaceFormats(const aSurface: VkSurfaceKHR): TvkuSurfaceFormatArr;
var c: VkUint32; var c: VkUint32;
begin begin
result := nil;
if not Assigned(fInstanceCommands.vkGetPhysicalDeviceSurfaceFormatsKHR) then if not Assigned(fInstanceCommands.vkGetPhysicalDeviceSurfaceFormatsKHR) then
raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceSurfaceFormatsKHR; did you enabled the VK_KHR_surface extension?'); raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceSurfaceFormatsKHR; did you enabled the VK_KHR_surface extension?');
fInstanceCommands.vkGetPhysicalDeviceSurfaceFormatsKHR(fHandle, aSurface, @c, nil);
SetLength(result, c);
fInstanceCommands.vkGetPhysicalDeviceSurfaceFormatsKHR(fHandle, aSurface, @c, @result[0]);
fInstanceCommands.vkGetPhysicalDeviceSurfaceFormatsKHR(fHandle, aSurface, @c, nil);
SetLength(result, c);
fInstanceCommands.vkGetPhysicalDeviceSurfaceFormatsKHR(fHandle, aSurface, @c, @result[0]);
end; end;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetSurfacePresentModes(const aSurface: VkSurfaceKHR): TVkPresentModeArr;
function TvkuPhysicalDevice.GetSurfacePresentModes(const aSurface: VkSurfaceKHR): TvkuPresentModeArr;
var var
c: VkUint32; c: VkUint32;
err: TVkResult; err: TVkResult;
begin begin
result := nil;
if not Assigned(fInstanceCommands.vkGetPhysicalDeviceSurfacePresentModesKHR) then if not Assigned(fInstanceCommands.vkGetPhysicalDeviceSurfacePresentModesKHR) then
raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceSurfacePresentModesKHR; did you enabled the VK_KHR_surface extension?'); raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceSurfacePresentModesKHR; did you enabled the VK_KHR_surface extension?');
err := fInstanceCommands.vkGetPhysicalDeviceSurfacePresentModesKHR(fHandle, aSurface, @c, nil); err := fInstanceCommands.vkGetPhysicalDeviceSurfacePresentModesKHR(fHandle, aSurface, @c, nil);
@@ -191,11 +195,12 @@ begin
end; end;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetDisplayProperties: TVkDisplayPropertiesArr;
function TvkuPhysicalDevice.GetDisplayProperties: TvkuDisplayPropertiesArr;
var var
err: TVkResult; err: TVkResult;
c: VkUint32; c: VkUint32;
begin begin
result := nil;
if not Assigned(fInstanceCommands.vkGetPhysicalDeviceDisplayPropertiesKHR) then if not Assigned(fInstanceCommands.vkGetPhysicalDeviceDisplayPropertiesKHR) then
raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceDisplayPropertiesKHR; did you enabled the VK_KHR_display extension?'); raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceDisplayPropertiesKHR; did you enabled the VK_KHR_display extension?');
err := fInstanceCommands.vkGetPhysicalDeviceDisplayPropertiesKHR(fHandle, @c, nil); err := fInstanceCommands.vkGetPhysicalDeviceDisplayPropertiesKHR(fHandle, @c, nil);
@@ -208,11 +213,12 @@ begin
end; end;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetDisplayPlaneProperties: TVkDisplayPlanePropertiesArr;
function TvkuPhysicalDevice.GetDisplayPlaneProperties: TvkuDisplayPlanePropertiesArr;
var var
err: TVkResult; err: TVkResult;
c: VkUint32; c: VkUint32;
begin begin
result := nil;
if not Assigned(fInstanceCommands.vkGetPhysicalDeviceDisplayPlanePropertiesKHR) then if not Assigned(fInstanceCommands.vkGetPhysicalDeviceDisplayPlanePropertiesKHR) then
raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceDisplayPlanePropertiesKHR; did you enabled the VK_KHR_display extension?'); raise TvkuException.Create('invalid function pointer: vkGetPhysicalDeviceDisplayPlanePropertiesKHR; did you enabled the VK_KHR_display extension?');
err := fInstanceCommands.vkGetPhysicalDeviceDisplayPlanePropertiesKHR(fHandle, @c, nil); err := fInstanceCommands.vkGetPhysicalDeviceDisplayPlanePropertiesKHR(fHandle, @c, nil);
@@ -225,11 +231,12 @@ begin
end; end;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetDisplayPlaneSupportedDisplays(const aPlaneIndex: VkUint32): TVkDisplayArr;
function TvkuPhysicalDevice.GetDisplayPlaneSupportedDisplays(const aPlaneIndex: VkUint32): TvkuDisplayArr;
var var
err: TVkResult; err: TVkResult;
c: VkUint32; c: VkUint32;
begin begin
result := nil;
if not Assigned(fInstanceCommands.vkGetDisplayPlaneSupportedDisplaysKHR) then if not Assigned(fInstanceCommands.vkGetDisplayPlaneSupportedDisplaysKHR) then
raise TvkuException.Create('invalid function pointer: vkGetDisplayPlaneSupportedDisplaysKHR; did you enabled the VK_KHR_display extension?'); raise TvkuException.Create('invalid function pointer: vkGetDisplayPlaneSupportedDisplaysKHR; did you enabled the VK_KHR_display extension?');
err := fInstanceCommands.vkGetDisplayPlaneSupportedDisplaysKHR(fHandle, aPlaneIndex, @c, nil); err := fInstanceCommands.vkGetDisplayPlaneSupportedDisplaysKHR(fHandle, aPlaneIndex, @c, nil);
@@ -242,11 +249,12 @@ begin
end; end;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDevice.GetDisplayModeProperties(const aDisplay: VkDisplayKHR): TVkDisplayModePropertiesArr;
function TvkuPhysicalDevice.GetDisplayModeProperties(const aDisplay: VkDisplayKHR): TvkuDisplayModePropertiesArr;
var var
err: TVkResult; err: TVkResult;
c: VkUint32; c: VkUint32;
begin begin
result := nil;
if not Assigned(fInstanceCommands.vkGetDisplayModePropertiesKHR) then if not Assigned(fInstanceCommands.vkGetDisplayModePropertiesKHR) then
raise TvkuException.Create('invalid function pointer: vkGetDisplayModePropertiesKHR; did you enabled the VK_KHR_display extension?'); raise TvkuException.Create('invalid function pointer: vkGetDisplayModePropertiesKHR; did you enabled the VK_KHR_display extension?');
err := fInstanceCommands.vkGetDisplayModePropertiesKHR(fHandle, aDisplay, @c, nil); err := fInstanceCommands.vkGetDisplayModePropertiesKHR(fHandle, aDisplay, @c, nil);


+ 23
- 1
projects/utils/uvkuSurface.pas Просмотреть файл

@@ -38,6 +38,8 @@ type
{$ERROR 'unknown or unsupportet platform'} {$ERROR 'unknown or unsupportet platform'}
{$ENDIF} {$ENDIF}
destructor Destroy; override; destructor Destroy; override;
public
class function GetPlatformSurfaceExtensionName: String;
end; end;


implementation implementation
@@ -91,7 +93,7 @@ destructor TvkuSurface.Destroy;
begin begin
if (fHandle <> VK_INVALID_NDP_HANDLE) then begin if (fHandle <> VK_INVALID_NDP_HANDLE) then begin
fInstanceCommands.vkDestroySurfaceKHR(fInstance, fHandle, fAllocCallbacks); fInstanceCommands.vkDestroySurfaceKHR(fInstance, fHandle, fAllocCallbacks);
fHandle := 0;
fHandle := VK_INVALID_NDP_HANDLE;
end; end;
if Assigned(fAllocCallbacks) then begin if Assigned(fAllocCallbacks) then begin
Dispose(fAllocCallbacks); Dispose(fAllocCallbacks);
@@ -100,5 +102,25 @@ begin
inherited Destroy; inherited Destroy;
end; end;


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class function TvkuSurface.GetPlatformSurfaceExtensionName: String;
begin
{$IF DEFINED(VK_USE_PLATFORM_XLIB_KHR)}
result := VK_KHR_XLIB_SURFACE_EXTENSION_NAME;
{$ELSEIF DEFINED(VK_USE_PLATFORM_XCB_KHR)}
result := VK_KHR_XCB_SURFACE_EXTENSION_NAME;
{$ELSEIF DEFINED(VK_USE_PLATFORM_WAYLAND_KHR)}
result := VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME;
{$ELSEIF DEFINED(VK_USE_PLATFORM_MIR_KHR)}
result := VK_KHR_MIR_SURFACE_EXTENSION_NAME;
{$ELSEIF DEFINED(VK_USE_PLATFORM_ANDROID_KHR)}
result := VK_KHR_ANDROID_SURFACE_EXTENSION_NAME;
{$ELSEIF DEFINED(VK_USE_PLATFORM_WIN32_KHR)}
result := VK_KHR_WIN32_SURFACE_EXTENSION_NAME;
{$ELSE}
{$ERROR 'unknown or unsupportet platform'}
{$ENDIF}
end;

end. end.



+ 14
- 5
projects/utils/uvkuSurfaceFactory.pas Просмотреть файл

@@ -34,7 +34,8 @@ type
private private
fFlags: VkFlags; fFlags: VkFlags;
fWinControl: TWinControl; fWinControl: TWinControl;
fInstance: TvkuInstance;
fInstance: VkInstance;
fInstanceCommands: TVkInstanceCommands;
procedure SetWinControl(aValue: TWinControl); procedure SetWinControl(aValue: TWinControl);
public public
property WinControl: TWinControl read fWinControl write SetWinControl; property WinControl: TWinControl read fWinControl write SetWinControl;
@@ -46,6 +47,7 @@ type
const aOwnsHandler: Boolean): TvkuSurface; const aOwnsHandler: Boolean): TvkuSurface;


constructor Create(const aInstance: TvkuInstance); constructor Create(const aInstance: TvkuInstance);
constructor Create(const aInstance: VkInstance; const aInstanceCommands: TVkInstanceCommands);
end; end;


implementation implementation
@@ -193,8 +195,8 @@ begin
CreateInfo.hwnd := fHwnd; CreateInfo.hwnd := fHwnd;
{$ENDIF} {$ENDIF}
if Assigned(aAllocHandler) if Assigned(aAllocHandler)
then srf := TvkuSurfaceEx.Create(fInstance.Handle, CreateInfo, fInstance.InstanceCommands, aAllocHandler.GetAllocationCallbacks)
else srf := TvkuSurfaceEx.Create(fInstance.Handle, CreateInfo, fInstance.InstanceCommands);
then srf := TvkuSurfaceEx.Create(fInstance, CreateInfo, fInstanceCommands, aAllocHandler.GetAllocationCallbacks)
else srf := TvkuSurfaceEx.Create(fInstance, CreateInfo, fInstanceCommands);
try try
srf.fAllocHandler := aAllocHandler; srf.fAllocHandler := aAllocHandler;
srf.fOwnsHandler := aOwnsHandler; srf.fOwnsHandler := aOwnsHandler;
@@ -206,6 +208,12 @@ end;


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuSurfaceFactory.Create(const aInstance: TvkuInstance); constructor TvkuSurfaceFactory.Create(const aInstance: TvkuInstance);
begin
Create(aInstance.Handle, aInstance.InstanceCommands);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuSurfaceFactory.Create(const aInstance: VkInstance; const aInstanceCommands: TVkInstanceCommands);
begin begin
inherited Create; inherited Create;
{$IF DEFINED(VK_USE_PLATFORM_XLIB_KHR)} {$IF DEFINED(VK_USE_PLATFORM_XLIB_KHR)}
@@ -221,8 +229,9 @@ begin
{$ELSEIF DEFINED(VK_USE_PLATFORM_WIN32_KHR)} {$ELSEIF DEFINED(VK_USE_PLATFORM_WIN32_KHR)}
fHInstance := Vulkan.HINSTANCE(GetModuleHandle(nil)); fHInstance := Vulkan.HINSTANCE(GetModuleHandle(nil));
{$ENDIF} {$ENDIF}
fInstance := aInstance;
fFlags := 0;
fInstance := aInstance;
fInstanceCommands := aInstanceCommands;
fFlags := 0;
end; end;


end. end.


+ 130
- 0
projects/utils/uvkuSwapChain.pas Просмотреть файл

@@ -0,0 +1,130 @@
unit uvkuSwapChain;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils,
Vulkan;

type
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuImageArr = array of VkImage;
TvkuSwapChain = class(TObject)
private
fHandle: VkSwapchainKHR;
fDevice: VkDevice;
fAllocCallbacks: PVkAllocationCallbacks;
fDeviceCommands: TVkDeviceCommands;

procedure CreateHandle(
const aCreateInfo: PVkSwapchainCreateInfoKHR;
const aAllocCallbacks: PVkAllocationCallbacks);
public
property Handle: VkSwapchainKHR read fHandle;
property Device: VkDevice read fDevice;
property DeviceCommands: TVkDeviceCommands read fDeviceCommands;

function GetImages: TvkuImageArr;
function AcquireNextImage(const aTimeout: VkUint64; const aSemaphore: VkSemaphore; const aFence: VkFence): VkUint32;

constructor Create(
const aDevice: VkDevice;
const aCreateInfo: TVkSwapchainCreateInfoKHR;
const aDeviceCommands: TVkDeviceCommands);
constructor Create(
const aDevice: VkDevice;
const aCreateInfo: TVkSwapchainCreateInfoKHR;
const aDeviceCommands: TVkDeviceCommands;
const aAllocCallbacks: TVkAllocationCallbacks);
destructor Destroy; override;
end;

implementation

uses
uvkuUtils;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuSwapChain//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuSwapChain.CreateHandle(const aCreateInfo: PVkSwapchainCreateInfoKHR; const aAllocCallbacks: PVkAllocationCallbacks);
var err: TVkResult;
begin
if Assigned(aAllocCallbacks) then begin
new(fAllocCallbacks);
fAllocCallbacks^ := aAllocCallbacks^;
end;
if not Assigned(fDeviceCommands.vkCreateSwapchainKHR) then
raise TvkuException.Create('invalid function pointer: vkCreateSwapchainKHR; did you enabled the VK_KHR_swapchain extension?');
err := fDeviceCommands.vkCreateSwapchainKHR(fDevice, aCreateInfo, fAllocCallbacks, @fHandle);
if (err < VK_SUCCESS) then
raise TvkuErrorException.Create('unable to create surface', err);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuSwapChain.GetImages: TvkuImageArr;
var
c: VkUint32;
err: TVkResult;
begin
if not Assigned(fDeviceCommands.vkGetSwapchainImagesKHR) then
raise TvkuException.Create('invalid function pointer: vkGetSwapchainImagesKHR; did you enabled the VK_KHR_swapchain extension?');
err := fDeviceCommands.vkGetSwapchainImagesKHR(fDevice, fHandle, @c, nil);
if (err < VK_SUCCESS) then
raise TvkuErrorException.Create('unable to get swap chain image count', err);
SetLength(result, c);
err := fDeviceCommands.vkGetSwapchainImagesKHR(fDevice, fHandle, @c, @result[0]);
if (err < VK_SUCCESS) then
raise TvkuErrorException.Create('unable to get swap chain images', err);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuSwapChain.AcquireNextImage(const aTimeout: VkUint64; const aSemaphore: VkSemaphore; const aFence: VkFence): VkUint32;
var
c: VkUint32;
err: TVkResult;
begin
if not Assigned(fDeviceCommands.vkAcquireNextImageKHR) then
raise TvkuException.Create('invalid function pointer: vkAcquireNextImageKHR; did you enabled the VK_KHR_swapchain extension?');
err := fDeviceCommands.vkAcquireNextImageKHR(fDevice, fHandle, aTimeout, aSemaphore, aFence, @result);
if (err < VK_SUCCESS) then
raise TvkuErrorException.Create('unable to aquire next image', err);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuSwapChain.Create(const aDevice: VkDevice; const aCreateInfo: TVkSwapchainCreateInfoKHR; const aDeviceCommands: TVkDeviceCommands);
begin
inherited Create;
fDevice := aDevice;
fDeviceCommands := aDeviceCommands;
CreateHandle(@aCreateInfo, nil);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuSwapChain.Create(const aDevice: VkDevice; const aCreateInfo: TVkSwapchainCreateInfoKHR;
const aDeviceCommands: TVkDeviceCommands; const aAllocCallbacks: TVkAllocationCallbacks);
begin
inherited Create;
fDevice := aDevice;
fDeviceCommands := aDeviceCommands;
CreateHandle(@aCreateInfo, @aAllocCallbacks);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
destructor TvkuSwapChain.Destroy;
begin
if (fHandle <> VK_INVALID_NDP_HANDLE) then begin
fDeviceCommands.vkDestroySwapchainKHR(fDevice, fHandle, fAllocCallbacks);
fHandle := VK_INVALID_NDP_HANDLE;
end;
if Assigned(fAllocCallbacks) then begin
Dispose(fAllocCallbacks);
fAllocCallbacks := nil;
end;
inherited Destroy;
end;

end.


+ 178
- 0
projects/utils/uvkuSwapChainFactory.pas Просмотреть файл

@@ -0,0 +1,178 @@
unit uvkuSwapChainFactory;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils,
Vulkan, uvkuSwapChain, uvkuAllocationHandler, uvkuDevice;

type
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuSwapChainEx = class(TvkuSwapChain)
private
fAllocHandler: TvkuAllocationHandler;
fOwnsHandler: Boolean;
public
destructor Destroy; override;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuUint32Arr = array of VkUint32;
TvkuSwapChainFactory = class(TObject)
private
fDevice: VkDevice;
fDeviceCommands: TVkDeviceCommands;

fFlags: VkSwapchainCreateFlagsKHR;
fSurface: VkSurfaceKHR;
fMinImageCount: VkUint32;
fImageFormat: TVkFormat;
fImageColorSpace: TVkColorSpaceKHR;
fImageExtent: TVkExtent2D;
fImageArrayLayers: VkUint32;
fImageUsage: VkImageUsageFlags;
fImageSharingMode: TVkSharingMode;
fQueueFamilyIndices: TvkuUint32Arr;
fPreTransform: TVkSurfaceTransformFlagBitsKHR;
fComposideAlpha: TVkCompositeAlphaFlagBitsKHR;
fPresentMode: TVkPresentModeKHR;
fClipped: Boolean;
fOldSwapChain: VkSwapchainKHR;

function GetQueueFamilyIndexCount: Integer;
function GetQueueFamilyIndex(const aIndex: Integer): VkUint32;
procedure SetQueueFamilyIndex(const aIndex: Integer; aValue: VkUint32);
public
property Device: VkDevice read fDevice;
property DeviceCommands: TVkDeviceCommands read fDeviceCommands;

property Flags: VkSwapchainCreateFlagsKHR read fFlags write fFlags;
property Surface: VkSurfaceKHR read fSurface write fSurface;
property MinImageCount: VkUint32 read fMinImageCount write fMinImageCount;
property ImageFormat: TVkFormat read fImageFormat write fImageFormat;
property ImageColorSpace: TVkColorSpaceKHR read fImageColorSpace write fImageColorSpace;
property ImageExtent: TVkExtent2D read fImageExtent write fImageExtent;
property ImageArrayLayers: VkUint32 read fImageArrayLayers write fImageArrayLayers;
property ImageUsage: VkImageUsageFlags read fImageUsage write fImageUsage;
property ImageSharingMode: TVkSharingMode read fImageSharingMode write fImageSharingMode;
property PreTransform: TVkSurfaceTransformFlagBitsKHR read fPreTransform write fPreTransform;
property ComposideAlpha: TVkCompositeAlphaFlagBitsKHR read fComposideAlpha write fComposideAlpha;
property PresentMode: TVkPresentModeKHR read fPresentMode write fPresentMode;
property Clipped: Boolean read fClipped write fClipped;
property OldSwapChain: VkSwapchainKHR read fOldSwapChain write fOldSwapChain;

property QueueFamilyIndices: TvkuUint32Arr read fQueueFamilyIndices write fQueueFamilyIndices;
property QueueFamilyIndexCount: Integer read GetQueueFamilyIndexCount;
property QueueFamilyIndex[const aIndex: Integer]: VkUint32 read GetQueueFamilyIndex write SetQueueFamilyIndex;

function CreateSwapchain: TvkuSwapChain;
function CreateSwapchain(
const aAllocHandler: TvkuAllocationHandler;
const aOwnsHandler: Boolean): TvkuSwapChain;

constructor Create(const aDevice: TvkuDevice);
constructor Create(const aDevice: VkDevice; const aDeviceCommands: TVkDeviceCommands);
end;

implementation

uses
uvkuUtils;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuSwapChainEx////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
destructor TvkuSwapChainEx.Destroy;
begin
inherited Destroy;
if fOwnsHandler then
FreeAndNil(fAllocHandler);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuSwapChainFactory///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuSwapChainFactory.GetQueueFamilyIndexCount: Integer;
begin
result := Length(fQueueFamilyIndices);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuSwapChainFactory.GetQueueFamilyIndex(const aIndex: Integer): VkUint32;
begin
if (aIndex < low(fQueueFamilyIndices)) or (aIndex > high(fQueueFamilyIndices)) then
raise TvkuException.CreateFmt('index (%d) out of range (%d : %d)', [aIndex, Low(fQueueFamilyIndices), High(fQueueFamilyIndices)]);
result := fQueueFamilyIndices[aIndex];
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuSwapChainFactory.SetQueueFamilyIndex(const aIndex: Integer; aValue: VkUint32);
begin
if (aIndex < low(fQueueFamilyIndices)) or (aIndex > high(fQueueFamilyIndices)) then
raise TvkuException.CreateFmt('index (%d) out of range (%d : %d)', [aIndex, Low(fQueueFamilyIndices), High(fQueueFamilyIndices)]);
fQueueFamilyIndices[aIndex] := aValue;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuSwapChainFactory.CreateSwapchain: TvkuSwapChain;
begin
result := CreateSwapchain(nil, false);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuSwapChainFactory.CreateSwapchain(const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean): TvkuSwapChain;
var
CreateInfo: TVkSwapchainCreateInfoKHR;
begin
FillByte(CreateInfo, SizeOf(CreateInfo), 0);
CreateInfo.sType := VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
CreateInfo.pNext := nil;
CreateInfo.flags := fFlags;
CreateInfo.surface := fSurface;
CreateInfo.minImageCount := fMinImageCount;
CreateInfo.imageFormat := fImageFormat;
CreateInfo.imageColorSpace := fImageColorSpace;
CreateInfo.imageExtent := fImageExtent;
CreateInfo.imageArrayLayers := fImageArrayLayers;
CreateInfo.imageUsage := fImageUsage;
CreateInfo.imageSharingMode := fImageSharingMode;
CreateInfo.queueFamilyIndexCount := Length(fQueueFamilyIndices);
CreateInfo.pQueueFamilyIndices := @fQueueFamilyIndices[0];
CreateInfo.preTransform := fPreTransform;
CreateInfo.compositeAlpha := fComposideAlpha;
CreateInfo.presentMode := fPresentMode;
CreateInfo.oldSwapchain := fOldSwapChain;
if fClipped
then CreateInfo.clipped := VK_TRUE
else CreateInfo.clipped := VK_FALSE;

if Assigned(aAllocHandler)
then result := TvkuSwapChainEx.Create(fDevice, CreateInfo, fDeviceCommands, aAllocHandler.GetAllocationCallbacks)
else result := TvkuSwapChainEx.Create(fDevice, CreateInfo, fDeviceCommands);
try
TvkuSwapChainEx(result).fAllocHandler := aAllocHandler;
TvkuSwapChainEx(result).fOwnsHandler := aOwnsHandler;
except
FreeAndNil(result);
end;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuSwapChainFactory.Create(const aDevice: TvkuDevice);
begin
Create(aDevice.Handle, aDevice.DeviceCommands);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuSwapChainFactory.Create(const aDevice: VkDevice; const aDeviceCommands: TVkDeviceCommands);
begin
inherited Create;
fDevice := aDevice;
fDeviceCommands := aDeviceCommands;
fPresentMode := VK_PRESENT_MODE_FIFO_KHR;
end;

end.


+ 11
- 11
projects/utils/uvkuUtils.pas Просмотреть файл

@@ -380,16 +380,16 @@ begin
toString(aProperties.limits.maxFramebufferWidth), toString(aProperties.limits.maxFramebufferWidth),
toString(aProperties.limits.maxFramebufferHeight), toString(aProperties.limits.maxFramebufferHeight),
toString(aProperties.limits.maxFramebufferLayers), toString(aProperties.limits.maxFramebufferLayers),
toString(aProperties.limits.framebufferColorSampleCounts),
toString(aProperties.limits.framebufferDepthSampleCounts),
toString(aProperties.limits.framebufferStencilSampleCounts),
toString(aProperties.limits.framebufferNoAttachmentsSampleCounts),
toString(PVkUint32(@aProperties.limits.framebufferColorSampleCounts)^),
toString(PVkUint32(@aProperties.limits.framebufferDepthSampleCounts)^),
toString(PVkUint32(@aProperties.limits.framebufferStencilSampleCounts)^),
toString(PVkUint32(@aProperties.limits.framebufferNoAttachmentsSampleCounts)^),
toString(aProperties.limits.maxColorAttachments), toString(aProperties.limits.maxColorAttachments),
toString(aProperties.limits.sampledImageColorSampleCounts),
toString(aProperties.limits.sampledImageIntegerSampleCounts),
toString(aProperties.limits.sampledImageDepthSampleCounts),
toString(aProperties.limits.sampledImageStencilSampleCounts),
toString(aProperties.limits.storageImageSampleCounts),
toString(PVkUint32(@aProperties.limits.sampledImageColorSampleCounts)^),
toString(PVkUint32(@aProperties.limits.sampledImageIntegerSampleCounts)^),
toString(PVkUint32(@aProperties.limits.sampledImageDepthSampleCounts)^),
toString(PVkUint32(@aProperties.limits.sampledImageStencilSampleCounts)^),
toString(PVkUint32(@aProperties.limits.storageImageSampleCounts)^),
toString(aProperties.limits.maxSampleMaskWords), toString(aProperties.limits.maxSampleMaskWords),
toString(aProperties.limits.timestampComputeAndGraphics), toString(aProperties.limits.timestampComputeAndGraphics),
toString(aProperties.limits.timestampPeriod), toString(aProperties.limits.timestampPeriod),
@@ -436,7 +436,7 @@ begin
' Type %d:' + sLineBreak + ' Type %d:' + sLineBreak +
' PropertyFlags: 0x%.16X' + sLineBreak + ' PropertyFlags: 0x%.16X' + sLineBreak +
' HeapIndex: %d (0x%2:.16X)' + sLineBreak, ' HeapIndex: %d (0x%2:.16X)' + sLineBreak,
[i, aMemoryProperties.memoryTypes[i].propertyFlags, aMemoryProperties.memoryTypes[i].heapIndex]);
[i, PVkUint32(@aMemoryProperties.memoryTypes[i].propertyFlags)^, aMemoryProperties.memoryTypes[i].heapIndex]);
end; end;
result := result + 'Heaps:' + sLineBreak; result := result + 'Heaps:' + sLineBreak;
for i := 0 to aMemoryProperties.memoryHeapCount-1 do begin for i := 0 to aMemoryProperties.memoryHeapCount-1 do begin
@@ -444,7 +444,7 @@ begin
' Heap %d:' + sLineBreak + ' Heap %d:' + sLineBreak +
' Size: %d (0x%1:.16X)' + sLineBreak + ' Size: %d (0x%1:.16X)' + sLineBreak +
' Flags: 0x%.16X' + sLineBreak, ' Flags: 0x%.16X' + sLineBreak,
[i, aMemoryProperties.memoryHeaps[i].size, aMemoryProperties.memoryHeaps[i].flags]);
[i, aMemoryProperties.memoryHeaps[i].size, PVkUint32(@aMemoryProperties.memoryHeaps[i].flags)^]);
end; end;
end; end;




Загрузка…
Отмена
Сохранить