Sfoglia il codice sorgente

* refactored Vulkan initialization

* implemented DebugReporter
master
Bergmann89 10 anni fa
parent
commit
da6e22a74c
9 ha cambiato i file con 504 aggiunte e 201 eliminazioni
  1. +5
    -1
      projects/triangle/triangle.lpi
  2. +1
    -1
      projects/triangle/triangle.lpr
  3. +160
    -149
      projects/triangle/triangle.lps
  4. +151
    -43
      projects/triangle/uMainForm.pas
  5. +4
    -1
      projects/utils/VulkanUtils.pas
  6. +25
    -6
      projects/utils/uvkuAllocationHandler.pas
  7. +21
    -0
      projects/utils/uvkuCommandBuffer.pas
  8. +3
    -0
      projects/utils/uvkuCommandPoolFactory.pas
  9. +134
    -0
      projects/utils/uvkuDebugReporter.pas

+ 5
- 1
projects/triangle/triangle.lpi Vedi File

@@ -33,7 +33,7 @@
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="43">
<Units Count="44">
<Unit0>
<Filename Value="triangle.lpr"/>
<IsPartOfProject Value="True"/>
@@ -209,6 +209,10 @@
<Filename Value="..\utils\uvkuPipelineFactory.pas"/>
<IsPartOfProject Value="True"/>
</Unit42>
<Unit43>
<Filename Value="..\utils\uvkuDebugReporter.pas"/>
<IsPartOfProject Value="True"/>
</Unit43>
</Units>
</ProjectOptions>
<CompilerOptions>


+ 1
- 1
projects/triangle/triangle.lpr Vedi File

@@ -8,7 +8,7 @@ uses
cthreads,
{$ENDIF}{$ENDIF}
SysUtils, Interfaces, Dialogs, Forms,
uMainForm, Vulkan;
uMainForm, Vulkan, uvkuDebugReporter;

{$R *.res}



+ 160
- 149
projects/triangle/triangle.lps Vedi File

@@ -4,14 +4,13 @@
<PathDelim Value="\"/>
<Version Value="9"/>
<BuildModes Active="Default"/>
<Units Count="63">
<Units Count="64">
<Unit0>
<Filename Value="triangle.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="5"/>
<EditorIndex Value="-1"/>
<CursorPos X="3" Y="31"/>
<UsageCount Value="93"/>
<Loaded Value="True"/>
<UsageCount Value="98"/>
</Unit0>
<Unit1>
<Filename Value="uMainForm.pas"/>
@@ -20,25 +19,25 @@
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<IsVisibleTab Value="True"/>
<TopLine Value="104"/>
<CursorPos Y="118"/>
<UsageCount Value="93"/>
<EditorIndex Value="4"/>
<TopLine Value="327"/>
<CursorPos X="35" Y="349"/>
<UsageCount Value="98"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="..\Vulkan.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="7"/>
<TopLine Value="4295"/>
<CursorPos X="41" Y="4316"/>
<EditorIndex Value="3"/>
<TopLine Value="712"/>
<CursorPos X="17" Y="727"/>
<ExtraEditorCount Value="1"/>
<ExtraEditor1>
<EditorIndex Value="-1"/>
<TopLine Value="1857"/>
<CursorPos X="75" Y="1873"/>
<TopLine Value="3271"/>
<CursorPos X="80" Y="3291"/>
</ExtraEditor1>
<UsageCount Value="93"/>
<UsageCount Value="98"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
@@ -46,49 +45,47 @@
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="45" Y="16"/>
<UsageCount Value="91"/>
<UsageCount Value="96"/>
</Unit3>
<Unit4>
<Filename Value="..\utils\uvkuInstanceFactory.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="2"/>
<EditorIndex Value="-1"/>
<TopLine Value="13"/>
<CursorPos X="3" Y="29"/>
<UsageCount Value="85"/>
<Loaded Value="True"/>
<UsageCount Value="90"/>
</Unit4>
<Unit5>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="6"/>
<TopLine Value="159"/>
<CursorPos X="16" Y="210"/>
<UsageCount Value="85"/>
<Loaded Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="6"/>
<CursorPos X="67" Y="22"/>
<UsageCount Value="90"/>
</Unit5>
<Unit6>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="4"/>
<CursorPos X="3" Y="93"/>
<UsageCount Value="75"/>
<TopLine Value="90"/>
<CursorPos X="15" Y="72"/>
<UsageCount Value="80"/>
<Loaded Value="True"/>
</Unit6>
<Unit7>
<Filename Value="..\utils\uvkuDevice.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="54"/>
<CursorPos Y="81"/>
<UsageCount Value="79"/>
<TopLine Value="62"/>
<CursorPos X="35" Y="67"/>
<UsageCount Value="84"/>
</Unit7>
<Unit8>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="353"/>
<CursorPos Y="377"/>
<UsageCount Value="77"/>
<TopLine Value="11"/>
<CursorPos X="10" Y="18"/>
<UsageCount Value="82"/>
</Unit8>
<Unit9>
<Filename Value="..\utils\uvkuSurface.pas"/>
@@ -96,7 +93,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="41"/>
<CursorPos X="94" Y="56"/>
<UsageCount Value="72"/>
<UsageCount Value="77"/>
</Unit9>
<Unit10>
<Filename Value="..\utils\uvkuSurfaceFactory.pas"/>
@@ -104,15 +101,15 @@
<EditorIndex Value="-1"/>
<TopLine Value="44"/>
<CursorPos X="33" Y="60"/>
<UsageCount Value="71"/>
<UsageCount Value="76"/>
</Unit10>
<Unit11>
<Filename Value="..\utils\uvkuSwapChainFactory.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="64"/>
<CursorPos X="63" Y="51"/>
<UsageCount Value="62"/>
<EditorIndex Value="6"/>
<CursorPos X="3" Y="13"/>
<UsageCount Value="67"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
<Filename Value="..\utils\uvkuSwapChain.pas"/>
@@ -120,7 +117,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="7"/>
<CursorPos X="36" Y="23"/>
<UsageCount Value="61"/>
<UsageCount Value="66"/>
</Unit12>
<Unit13>
<Filename Value="..\utils\uvkuImageView.pas"/>
@@ -128,7 +125,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="29"/>
<CursorPos X="64" Y="47"/>
<UsageCount Value="58"/>
<UsageCount Value="63"/>
</Unit13>
<Unit14>
<Filename Value="..\utils\uvkuImageViewFactory.pas"/>
@@ -136,7 +133,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="24"/>
<CursorPos X="60" Y="88"/>
<UsageCount Value="58"/>
<UsageCount Value="63"/>
</Unit14>
<Unit15>
<Filename Value="..\utils\uvkuImage.pas"/>
@@ -144,15 +141,16 @@
<EditorIndex Value="-1"/>
<TopLine Value="48"/>
<CursorPos X="17" Y="64"/>
<UsageCount Value="57"/>
<UsageCount Value="62"/>
</Unit15>
<Unit16>
<Filename Value="..\utils\uvkuBase.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="21"/>
<CursorPos Y="82"/>
<UsageCount Value="56"/>
<EditorIndex Value="2"/>
<TopLine Value="16"/>
<CursorPos X="15" Y="32"/>
<UsageCount Value="61"/>
<Loaded Value="True"/>
</Unit16>
<Unit17>
<Filename Value="..\utils\uvkuDeviceMemory.pas"/>
@@ -160,7 +158,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="33"/>
<CursorPos X="79" Y="44"/>
<UsageCount Value="54"/>
<UsageCount Value="59"/>
</Unit17>
<Unit18>
<Filename Value="..\utils\uvkuBuffer.pas"/>
@@ -168,7 +166,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="10"/>
<CursorPos X="3" Y="13"/>
<UsageCount Value="53"/>
<UsageCount Value="58"/>
</Unit18>
<Unit19>
<Filename Value="..\utils\uvkuImageFactory.pas"/>
@@ -176,7 +174,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="20"/>
<CursorPos X="60" Y="74"/>
<UsageCount Value="53"/>
<UsageCount Value="58"/>
</Unit19>
<Unit20>
<Filename Value="..\utils\uvkuTypes.pas"/>
@@ -184,7 +182,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="79"/>
<CursorPos Y="95"/>
<UsageCount Value="53"/>
<UsageCount Value="58"/>
</Unit20>
<Unit21>
<Filename Value="..\utils\uvkuBufferFactory.pas"/>
@@ -192,7 +190,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="20"/>
<CursorPos X="60" Y="58"/>
<UsageCount Value="52"/>
<UsageCount Value="57"/>
</Unit21>
<Unit22>
<Filename Value="..\utils\uvkuBufferView.pas"/>
@@ -200,52 +198,57 @@
<EditorIndex Value="-1"/>
<TopLine Value="52"/>
<CursorPos X="56" Y="76"/>
<UsageCount Value="52"/>
<UsageCount Value="57"/>
</Unit22>
<Unit23>
<Filename Value="..\utils\uvkuBufferViewFactory.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="31" Y="45"/>
<UsageCount Value="51"/>
<UsageCount Value="56"/>
</Unit23>
<Unit24>
<Filename Value="..\utils\uvkuCommandPool.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="57"/>
<CursorPos X="21" Y="73"/>
<UsageCount Value="51"/>
<EditorIndex Value="8"/>
<TopLine Value="61"/>
<CursorPos X="39" Y="77"/>
<UsageCount Value="56"/>
<Loaded Value="True"/>
</Unit24>
<Unit25>
<Filename Value="..\utils\uvkuCommandPoolFactory.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="46" Y="42"/>
<UsageCount Value="50"/>
<EditorIndex Value="9"/>
<TopLine Value="23"/>
<CursorPos X="3" Y="34"/>
<UsageCount Value="55"/>
<Loaded Value="True"/>
</Unit25>
<Unit26>
<Filename Value="..\utils\uvkuCommandBuffer.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="39" Y="13"/>
<UsageCount Value="50"/>
<EditorIndex Value="7"/>
<TopLine Value="45"/>
<CursorPos X="91" Y="71"/>
<UsageCount Value="55"/>
<Loaded Value="True"/>
</Unit26>
<Unit27>
<Filename Value="..\utils\uvkuQueue.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="7"/>
<CursorPos X="22" Y="23"/>
<UsageCount Value="50"/>
<TopLine Value="5"/>
<CursorPos Y="12"/>
<UsageCount Value="55"/>
</Unit27>
<Unit28>
<Filename Value="..\utils\VulkanUtils.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="32"/>
<CursorPos X="3" Y="48"/>
<UsageCount Value="49"/>
<EditorIndex Value="5"/>
<TopLine Value="50"/>
<CursorPos X="3" Y="66"/>
<UsageCount Value="54"/>
<Loaded Value="True"/>
</Unit28>
<Unit29>
@@ -253,30 +256,29 @@
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="14"/>
<UsageCount Value="66"/>
<UsageCount Value="71"/>
</Unit29>
<Unit30>
<Filename Value="..\utils\uvkuRenderPass.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="3" Y="13"/>
<UsageCount Value="47"/>
<UsageCount Value="52"/>
</Unit30>
<Unit31>
<Filename Value="..\utils\uvkuRenderPassFactory.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="82" Y="11"/>
<UsageCount Value="47"/>
<UsageCount Value="52"/>
</Unit31>
<Unit32>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="3"/>
<EditorIndex Value="-1"/>
<TopLine Value="69"/>
<CursorPos X="12" Y="82"/>
<UsageCount Value="47"/>
<Loaded Value="True"/>
<UsageCount Value="52"/>
</Unit32>
<Unit33>
<Filename Value="..\utils\uvkuFrameBuffer.pas"/>
@@ -284,7 +286,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="33"/>
<CursorPos X="150" Y="40"/>
<UsageCount Value="45"/>
<UsageCount Value="50"/>
</Unit33>
<Unit34>
<Filename Value="..\utils\uvkuFrameBufferFactory.pas"/>
@@ -292,14 +294,14 @@
<EditorIndex Value="-1"/>
<TopLine Value="12"/>
<CursorPos X="25" Y="27"/>
<UsageCount Value="45"/>
<UsageCount Value="50"/>
</Unit34>
<Unit35>
<Filename Value="..\utils\uvkuDescriptorSetLayout.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="150" Y="12"/>
<UsageCount Value="45"/>
<UsageCount Value="50"/>
</Unit35>
<Unit36>
<Filename Value="..\utils\uvkuDescriptorSetLayoutFactory.pas"/>
@@ -307,7 +309,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="89"/>
<CursorPos X="3" Y="106"/>
<UsageCount Value="44"/>
<UsageCount Value="49"/>
</Unit36>
<Unit37>
<Filename Value="..\utils\uvkuPipelineLayout.pas"/>
@@ -315,7 +317,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="48"/>
<CursorPos X="150" Y="53"/>
<UsageCount Value="44"/>
<UsageCount Value="49"/>
</Unit37>
<Unit38>
<Filename Value="..\utils\uvkuPipelineLayoutFactory.pas"/>
@@ -323,7 +325,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="10"/>
<CursorPos X="37" Y="112"/>
<UsageCount Value="44"/>
<UsageCount Value="49"/>
</Unit38>
<Unit39>
<Filename Value="..\utils\uvkuShaderModule.pas"/>
@@ -331,7 +333,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="54"/>
<CursorPos X="3" Y="67"/>
<UsageCount Value="42"/>
<UsageCount Value="47"/>
</Unit39>
<Unit40>
<Filename Value="..\utils\uvkuShaderModuleFactory.pas"/>
@@ -339,15 +341,15 @@
<EditorIndex Value="-1"/>
<TopLine Value="117"/>
<CursorPos X="37" Y="127"/>
<UsageCount Value="42"/>
<UsageCount Value="47"/>
</Unit40>
<Unit41>
<Filename Value="..\utils\uvkuPipeline.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<TopLine Value="79"/>
<CursorPos X="17" Y="91"/>
<UsageCount Value="40"/>
<TopLine Value="7"/>
<CursorPos X="23" Y="92"/>
<UsageCount Value="45"/>
</Unit41>
<Unit42>
<Filename Value="..\utils\uvkuPipelineFactory.pas"/>
@@ -355,7 +357,7 @@
<EditorIndex Value="-1"/>
<TopLine Value="7"/>
<CursorPos X="3" Y="23"/>
<UsageCount Value="39"/>
<UsageCount Value="44"/>
</Unit42>
<Unit43>
<Filename Value="..\utils\uvkuPhysicalDeviceFactory.pas"/>
@@ -412,8 +414,7 @@
<Unit50>
<Filename Value="..\Vulkan.inc"/>
<EditorIndex Value="-1"/>
<CursorPos X="9" Y="5"/>
<UsageCount Value="7"/>
<UsageCount Value="10"/>
</Unit50>
<Unit51>
<Filename Value="C:\Zusatzprogramme\Lazarus\lcl\forms.pp"/>
@@ -500,126 +501,136 @@
<CursorPos Y="2163"/>
<UsageCount Value="10"/>
</Unit62>
<Unit63>
<Filename Value="..\utils\uvkuDebugReporter.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="102"/>
<CursorPos Y="119"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit63>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<JumpHistory Count="30" HistoryIndex="25">
<Position1>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="47" Column="97" TopLine="32"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="122" Column="83" TopLine="107"/>
</Position1>
<Position2>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="260" Column="23" TopLine="241"/>
<Filename Value="..\utils\uvkuDebugReporter.pas"/>
<Caret Line="109" TopLine="90"/>
</Position2>
<Position3>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="257" Column="83" TopLine="241"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="512" Column="22" TopLine="486"/>
</Position3>
<Position4>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="245" Column="60" TopLine="229"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="33" Column="5" TopLine="16"/>
</Position4>
<Position5>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="257" Column="83" TopLine="241"/>
<Filename Value="..\utils\VulkanUtils.pas"/>
<Caret Line="47" Column="3" TopLine="31"/>
</Position5>
<Position6>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="4540" Column="93" TopLine="4525"/>
<Filename Value="..\utils\uvkuDebugReporter.pas"/>
<Caret Line="117" TopLine="102"/>
</Position6>
<Position7>
<Filename Value="..\Vulkan.pas"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="512" TopLine="486"/>
</Position7>
<Position8>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="257" Column="83" TopLine="241"/>
<Filename Value="..\utils\uvkuDebugReporter.pas"/>
<Caret Line="117" TopLine="102"/>
</Position8>
<Position9>
<Filename Value="uMainForm.pas"/>
<Caret Line="106" Column="10" TopLine="88"/>
<Filename Value="..\utils\uvkuDebugReporter.pas"/>
<Caret Line="118" Column="83" TopLine="102"/>
</Position9>
<Position10>
<Filename Value="uMainForm.pas"/>
<Caret Line="13" Column="3"/>
<Caret Line="512" TopLine="486"/>
</Position10>
<Position11>
<Filename Value="..\utils\VulkanUtils.pas"/>
<Caret Line="44" Column="3" TopLine="28"/>
<Filename Value="..\utils\uvkuDebugReporter.pas"/>
<Caret Line="117" TopLine="102"/>
</Position11>
<Position12>
<Filename Value="uMainForm.pas"/>
<Caret Line="117" Column="21" TopLine="104"/>
<Filename Value="..\utils\uvkuDebugReporter.pas"/>
<Caret Line="118" TopLine="102"/>
</Position12>
<Position13>
<Filename Value="..\utils\VulkanUtils.pas"/>
<Caret Line="48" Column="3" TopLine="32"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="253" Column="27" TopLine="242"/>
</Position13>
<Position14>
<Filename Value="..\utils\uvkuInstanceFactory.pas"/>
<Caret Line="163" Column="27" TopLine="144"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="94" Column="3" TopLine="77"/>
</Position14>
<Position15>
<Filename Value="..\utils\uvkuInstanceFactory.pas"/>
<Caret Line="29" Column="3" TopLine="13"/>
<Filename Value="..\utils\VulkanUtils.pas"/>
<Caret Line="82" Column="3" TopLine="66"/>
</Position15>
<Position16>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="74" TopLine="66"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="261" TopLine="248"/>
</Position16>
<Position17>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="82" TopLine="66"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="49" Column="5" TopLine="34"/>
</Position17>
<Position18>
<Filename Value="uMainForm.pas"/>
<Caret Line="111" TopLine="104"/>
<Filename Value="..\utils\VulkanUtils.pas"/>
<Caret Line="83" Column="3" TopLine="67"/>
</Position18>
<Position19>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="82" TopLine="66"/>
<Filename Value="..\utils\uvkuCommandBuffer.pas"/>
<Caret Line="23" Column="28" TopLine="4"/>
</Position19>
<Position20>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="66" TopLine="50"/>
<Filename Value="..\utils\uvkuCommandBuffer.pas"/>
<Caret Line="43" Column="22" TopLine="23"/>
</Position20>
<Position21>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="68" TopLine="50"/>
<Filename Value="..\utils\uvkuCommandBuffer.pas"/>
<Caret Line="45" Column="28" TopLine="23"/>
</Position21>
<Position22>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="69" TopLine="50"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="304" Column="42" TopLine="292"/>
</Position22>
<Position23>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="83" TopLine="67"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="259" Column="16" TopLine="244"/>
</Position23>
<Position24>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="77" Column="26" TopLine="69"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="261" Column="33" TopLine="245"/>
</Position24>
<Position25>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="83" TopLine="69"/>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="2887" Column="86" TopLine="2871"/>
</Position25>
<Position26>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="84" TopLine="69"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="315" Column="60" TopLine="300"/>
</Position26>
<Position27>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="85" TopLine="69"/>
<Filename Value="uMainForm.pas"/>
<Caret Line="95" Column="3" TopLine="78"/>
</Position27>
<Position28>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="86" TopLine="69"/>
<Filename Value="..\utils\VulkanUtils.pas"/>
<Caret Line="66" Column="3" TopLine="50"/>
</Position28>
<Position29>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="87" TopLine="69"/>
<Filename Value="..\utils\uvkuSwapChainFactory.pas"/>
<Caret Line="13" Column="3"/>
</Position29>
<Position30>
<Filename Value="..\utils\uvkuFactoryBase.pas"/>
<Caret Line="88" TopLine="69"/>
<Filename Value="..\utils\uvkuSwapChainFactory.pas"/>
<Caret Line="23" Column="38"/>
</Position30>
</JumpHistory>
</ProjectSession>


+ 151
- 43
projects/triangle/uMainForm.pas Vedi File

@@ -23,7 +23,14 @@ type
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
fGraphicsQueueFamilyIndex: VkUint32;
fGraphicsQueueNodeIndex: VkUint32;
fPresentQueueNodeIndex: VkUint32;
fSurfaceFormat: TVkFormat;
fSurfaceColorSpace: TVkColorSpaceKHR;

fAllocHandler: TCustomAllocHandler;
fDebugReporter: TvkuConsoleDebugReporter;
fInstance: TvkuInstance;
fPhyDevice: TvkuPhysicalDevice;
fDevice: TvkuDevice;
@@ -38,6 +45,8 @@ type
fVertexShader: TvkuShaderModule;
fFragmentShader: TvkuShaderModule;
fPipeline: TvkuGraphicsPipeline;
fCommandPool: TvkuCommandPool;
fCommandBuffer: TvkuCommandBuffer;
end;

var
@@ -54,7 +63,7 @@ implementation
function TCustomAllocHandler.AllocateMemory(const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid;
begin
result := inherited AllocateMemory(aSize, aAlignment, aScope);
WriteLn(Format(' %d bytes of memory allocated at %p', [ aSize, result ]));
WriteLn(Format(' MEM - %d bytes of memory allocated at %p', [ aSize, result ]));
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -63,13 +72,13 @@ var p: PVkVoid;
begin
p := aOriginal;
result := inherited ReallocateMemory(aOriginal, aSize, aAlignment, aScope);
WriteLn(Format(' %d bytes of memory (from %p) reallocated at %p', [ aSize, p, result ]));
WriteLn(Format(' MEM - %d bytes of memory (from %p) reallocated at %p', [ aSize, p, result ]));
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TCustomAllocHandler.FreeMemory(const aMemory: PVkVoid);
begin
WriteLn(Format(' free memory at %p', [ aMemory ]));
WriteLn(Format(' MEM - free memory at %p', [ aMemory ]));
inherited FreeMemory(aMemory);
end;

@@ -82,6 +91,7 @@ var
InstanceFactory: TvkuInstanceFactory;
DeviceFactory: TvkuDeviceFactory;
SurfaceFactory: TvkuSurfaceFactory;
CommandPoolFactory: TvkuCommandPoolFactory;
SwapChainFactory: TvkuSwapChainFactory;
ImageViewFactory: TvkuImageViewFactory;
RenderPassFactory: TvkuRenderPassFactory;
@@ -91,9 +101,9 @@ var
ShaderModuleFactory: TvkuShaderModuleFactory;
PipelineFactory: TvkuGraphicsPipelineFactory;

QueueFamProps: TVkQueueFamilyPropertiesArr;
DepthFormat: TVkFormat;
f: TVkFormat;
SurcafeFormat: TVkSurfaceFormatKHR;
i: Integer;
SrfFormats: TVkSurfaceFormatArr;
SurfaceCapabilities: TVkSurfaceCapabilitiesKHR;
@@ -105,23 +115,44 @@ begin
fAllocHandler := TCustomAllocHandler.Create;

//////////////////////////////////////////////////////////////////////////////
WriteLn('create instance');
WriteLn('create instance: ');
InstanceFactory := TvkuInstanceFactory.Create;
try
InstanceFactory.AllocHandler := fAllocHandler;
InstanceFactory.EnabledExtensionNames.Add(VK_KHR_SURFACE_EXTENSION_NAME);
InstanceFactory.EnabledExtensionNames.Add(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
InstanceFactory.EnabledExtensionNames.Add(TvkuSurface.GetPlatformSurfaceExtensionName);
fInstance := InstanceFactory.CreateInstance;
WriteLn(' handle: ', PtrUInt(fInstance.Handle));
WriteLn(' done');
finally
FreeAndNil(InstanceFactory);
end;

fDebugReporter := TvkuConsoleDebugReporter.Create(fInstance.InstanceCommands, fAllocHandler);

//////////////////////////////////////////////////////////////////////////////
WriteLn('find suitable physical device');
PhyDevices := fInstance.GetPhysicalDevices;
if (Length(PhyDevices) <= 0) then
raise Exception.Create('unable to get physical device');
raise TvkuException.Create('unable to get physical device');
fPhyDevice := TvkuPhysicalDevice.Create(PhyDevices[0], fInstance.InstanceCommands);
WriteLn(' handle: ', PtrUInt(fPhyDevice.Handle));

Write(' find suitable graphics queue index... ');
QueueFamProps := fPhyDevice.GetQueueFamilyProperties;
fGraphicsQueueFamilyIndex := high(fGraphicsQueueFamilyIndex);
for i := low(QueueFamProps) to high(QueueFamProps) do begin
if (VK_QUEUE_GRAPHICS_BIT in QueueFamProps[i].queueFlags) then begin
fGraphicsQueueFamilyIndex := i;
WriteLn(fGraphicsQueueFamilyIndex);
break;
end;
end;
if (fGraphicsQueueFamilyIndex = high(fGraphicsQueueFamilyIndex)) then
raise TvkuException.Create('unable to find graphics queue index');

Write(' find suitable depth format... ');
f := VK_FORMAT_UNDEFINED;
for f in [ VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D16_UNORM ] do begin
if (VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT in fPhyDevice.GetFormatProperties(f).optimalTilingFeatures) then begin
@@ -129,39 +160,111 @@ begin
break;
end;
end;
WriteLn(DepthFormat);
WriteLn(' done');

//////////////////////////////////////////////////////////////////////////////
WriteLn('create device');
DeviceFactory := TvkuDeviceFactory.Create(fInstance);
try
DeviceFactory.AllocHandler := fAllocHandler;
DeviceFactory.EnabledExtensions.Add('VK_KHR_swapchain');
DeviceFactory.QueueCreateInfos.Length := 1;
with DeviceFactory.QueueCreateInfos[0] do begin
Flags := 0;
QueueFamilyIndex := 0;
QueueFamilyIndex := fGraphicsQueueFamilyIndex;
QueuePriorities.Length := 1;
QueuePriorities[0] := 1.0;
end;
fDevice := DeviceFactory.CreateDevice(fPhyDevice.Handle);
WriteLn(' handle: ', PtrUInt(fDevice.Handle));
WriteLn(' done');
finally
FreeAndNil(DeviceFactory);
end;

//////////////////////////////////////////////////////////////////////////////
WriteLn('find suitable queue');
fQueue := TvkuQueue.Create(fDevice.GetQueue(0, 0), fDevice.DeviceCommands);
fQueue := TvkuQueue.Create(fDevice.GetQueue(fGraphicsQueueFamilyIndex, 0), fDevice.DeviceCommands);
WriteLn(' handle: ', PtrUInt(fQueue.Handle));
WriteLn(' done');

//////////////////////////////////////////////////////////////////////////////
WriteLn('create surface');
WriteLn('create surface: ');
SurfaceFactory := TvkuSurfaceFactory.Create(fInstance);
try
SurfaceFactory.AllocHandler := fAllocHandler;
SurfaceFactory.WinControl := RenderPanel;
fSurface := SurfaceFactory.CreateSurface;
WriteLn(' handle: ', PtrUInt(fSurface.Handle));

WriteLn(' find suitable graphics and present queue node index');
fGraphicsQueueNodeIndex := high(fGraphicsQueueNodeIndex);
fPresentQueueNodeIndex := high(fPresentQueueNodeIndex);
QueueFamProps := fPhyDevice.GetQueueFamilyProperties;
for i := low(QueueFamProps) to high(QueueFamProps) do begin
if (VK_QUEUE_GRAPHICS_BIT in QueueFamProps[i].queueFlags) then
fGraphicsQueueNodeIndex := i;

if fPhyDevice.GetSurfaceSupport(i, fSurface.Handle) then begin
fGraphicsQueueNodeIndex := i;
fPresentQueueNodeIndex := i;
break;
end;
end;
if (fPresentQueueNodeIndex = high(fPresentQueueNodeIndex)) then begin
for i := low(QueueFamProps) to high(QueueFamProps) do begin
if fPhyDevice.GetSurfaceSupport(i, fSurface.Handle) then begin
fPresentQueueNodeIndex := i;
break;
end;
end;
end;
WriteLn(' graphics queue node index: ', fGraphicsQueueNodeIndex);
WriteLn(' present queue node index: ', fPresentQueueNodeIndex);
if (fGraphicsQueueNodeIndex = high(fGraphicsQueueNodeIndex)) or
(fPresentQueueNodeIndex = high(fPresentQueueNodeIndex)) or
(fPresentQueueNodeIndex <> fGraphicsQueueNodeIndex) then
raise TvkuException.Create('different graphic and present queue node index is not supported yet');

WriteLn(' find suitable image format');
SrfFormats := fPhyDevice.GetSurfaceFormats(fSurface.Handle);
if (Length(SrfFormats) = 0) then
raise TvkuException.Create('no suitable formats found');
if (Length(SrfFormats) = 1) and (SrfFormats[0].format = VK_FORMAT_UNDEFINED) then begin
fSurfaceFormat := VK_FORMAT_R8G8B8A8_UNORM;
fSurfaceColorSpace := VK_COLORSPACE_SRGB_NONLINEAR_KHR;
end else begin
fSurfaceFormat := SrfFormats[0].format;
fSurfaceColorSpace := SrfFormats[0].colorSpace;
end;
WriteLn(' format: ', fSurfaceFormat);
WriteLn(' color space: ', fSurfaceColorSpace);

WriteLn(' done');
finally
FreeAndNil(SurfaceFactory);
end;

//////////////////////////////////////////////////////////////////////////////
WriteLn('create command pool');
CommandPoolFactory := TvkuCommandPoolFactory.Create(fDevice);
try
CommandPoolFactory.Flags := [ VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT ];
CommandPoolFactory.QueueFamilyIndex := fGraphicsQueueNodeIndex;
fCommandPool := CommandPoolFactory.CreateCommandPool;
WriteLn(' handle: ', PtrUInt(fCommandPool.Handle));

WriteLn(' alloc command buffer');
fCommandBuffer := TvkuCommandBuffer.Create(
fCommandPool.CreateCommandBuffer(VK_COMMAND_BUFFER_LEVEL_PRIMARY),
true, fCommandPool.Handle, fDevice.DeviceCommands);
WriteLn(' handle: ', PtrUInt(fCommandBuffer.Handle));
WriteLn(' done');
finally
FreeAndNil(CommandPoolFactory);
end;

//////////////////////////////////////////////////////////////////////////////
WriteLn('create swap chain');
SwapChainFactory := TvkuSwapChainFactory.Create(fDevice);
@@ -173,6 +276,8 @@ begin
SwapChainFactory.ImageSharingMode := VK_SHARING_MODE_EXCLUSIVE;
SwapChainFactory.Clipped := true;
SwapChainFactory.ComposideAlpha := [ VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR ];
SwapChainFactory.ImageFormat := fSurfaceFormat;
SwapChainFactory.ImageColorSpace := fSurfaceColorSpace;

WriteLn(' get surface capabilities');
SurfaceCapabilities := fPhyDevice.GetSurfaceCapabilities(fSurface.Handle);
@@ -183,50 +288,37 @@ begin
ClientWidth := SurfaceCapabilities.currentExtent.width;
ClientHeight := SurfaceCapabilities.currentExtent.height;
end;
WriteLn(' width: ', SurfaceCapabilities.currentExtent.width);
WriteLn(' height: ', SurfaceCapabilities.currentExtent.height);
SwapChainFactory.ImageExtent := SurfaceCapabilities.currentExtent;

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

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
SurcafeFormat.format := VK_FORMAT_R8G8B8A8_UNORM;
SurcafeFormat.colorSpace := VK_COLORSPACE_SRGB_NONLINEAR_KHR;
end else begin
SurcafeFormat.format := SrfFormats[0].format;
SurcafeFormat.colorSpace := SrfFormats[0].colorSpace;
end;
SwapChainFactory.ImageFormat := SurcafeFormat.format;
SwapChainFactory.ImageColorSpace := SurcafeFormat.colorSpace;


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

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

fSwapChain := SwapChainFactory.CreateSwapchain;
WriteLn(' handle: ', PtrUInt(fSwapChain.Handle));
WriteLn(' done');
finally
FreeAndNil(SwapChainFactory);
end;
@@ -237,14 +329,8 @@ begin
SetLength(fImageViews, Length(Images));
ImageViewFactory := TvkuImageViewFactory.Create(fDevice);
try
ComponentMapping.r := VK_COMPONENT_SWIZZLE_R;
ComponentMapping.g := VK_COMPONENT_SWIZZLE_G;
ComponentMapping.b := VK_COMPONENT_SWIZZLE_B;
ComponentMapping.a := VK_COMPONENT_SWIZZLE_A;

ImageViewFactory.AllocHandler := fAllocHandler;
ImageViewFactory.Format := SurcafeFormat.format;
ImageViewFactory.Components := ComponentMapping;
ImageViewFactory.Format := fSurfaceFormat;
ImageViewFactory.ViewType := VK_IMAGE_VIEW_TYPE_2D;
with ImageViewFactory.SubresourceRange do begin
AspectMask := [ VK_IMAGE_ASPECT_COLOR_BIT ];
@@ -253,10 +339,19 @@ begin
BaseArrayLayer := 0;
LayerCount := 1;
end;
with ImageViewFactory.Components do begin
r := VK_COMPONENT_SWIZZLE_R;
g := VK_COMPONENT_SWIZZLE_G;
b := VK_COMPONENT_SWIZZLE_B;
a := VK_COMPONENT_SWIZZLE_A;
end;
for i := Low(fImageViews) to High(fImageViews) do begin
// TODO create image barrier
ImageViewFactory.Image := Images[i];
fImageViews[i] := ImageViewFactory.CreateImageView;
WriteLn(' handle: ', PtrUInt(fImageViews[i].Handle));
end;
WriteLn(' done');
finally
FreeAndNil(ImageViewFactory);
end;
@@ -267,7 +362,7 @@ begin
try
RenderPassFactory.Attachments.Length := 2;
with RenderPassFactory.Attachments[0] do begin
Format := SurcafeFormat.format;
Format := fSurfaceFormat;
Samples := [ VK_SAMPLE_COUNT_1_BIT ];
LoadOp := VK_ATTACHMENT_LOAD_OP_CLEAR;
StoreOp := VK_ATTACHMENT_STORE_OP_STORE;
@@ -303,6 +398,9 @@ begin

RenderPassFactory.AllocHandler := fAllocHandler;
fRenderPass := RenderPassFactory.CreateRenderPass;

WriteLn(' handle: ', PtrUInt(fRenderPass.Handle));
WriteLn(' done');
finally
FreeAndNil(RenderPassFactory);
end;
@@ -323,7 +421,9 @@ begin
for i := low(fFrameBuffers) to high(fFrameBuffers) do begin
FrameBufferFactory.Attachments[0] := fImageViews[i].Handle;
fFrameBuffers[i] := FrameBufferFactory.CreateFrameBuffer;
WriteLn(' handle: ', PtrUInt(fFrameBuffers[i].Handle));
end;
WriteLn(' done');
finally
FreeAndNil(FrameBufferFactory);
end;
@@ -343,6 +443,8 @@ begin
DescSetLayoutFactory.AllocHandler := fAllocHandler;

fDescSetLayout := DescSetLayoutFactory.CreateDescriptorSetLayout;
WriteLn(' handle: ', PtrUInt(fDescSetLayout.Handle));
WriteLn(' done');
finally
FreeAndNil(DescSetLayoutFactory);
end;
@@ -355,6 +457,8 @@ begin
PipelineLayoutFactory.SetLayouts.Length := 1;
PipelineLayoutFactory.SetLayouts[0] := fDescSetLayout.Handle;
fPipelineLayout := PipelineLayoutFactory.CreatePipelineLayout;
WriteLn(' handle: ', PtrUInt(fPipelineLayout.Handle));
WriteLn(' done');
finally
FreeAndNil(PipelineLayoutFactory);
end;
@@ -367,9 +471,12 @@ begin

ShaderModuleFactory.LoadGlslCode(ExtractFilePath(Application.ExeName) + '../../data/shaders/triangle.vert', [ VK_SHADER_STAGE_VERTEX_BIT ]);
fVertexShader := ShaderModuleFactory.CreateShaderModule;
WriteLn(' vertex handle: ', PtrUInt(fVertexShader.Handle));

ShaderModuleFactory.LoadGlslCode(ExtractFilePath(Application.ExeName) + '../../data/shaders/triangle.frag', [ VK_SHADER_STAGE_FRAGMENT_BIT ]);
fFragmentShader := ShaderModuleFactory.CreateShaderModule;
WriteLn(' fragment handle: ', PtrUInt(fFragmentShader.Handle));
WriteLn(' done');
finally
FreeAndNil(ShaderModuleFactory);
end;
@@ -379,7 +486,7 @@ begin
PipelineFactory := TvkuGraphicsPipelineFactory.Create(fDevice);
try
PipelineFactory.AllocHandler := fAllocHandler;
fPipeline := PipelineFactory.CreateGraphicsPipeline(VK_INVALID_NDP_HANDLE);
// TODO fPipeline := PipelineFactory.CreateGraphicsPipeline(VK_INVALID_NDP_HANDLE);
finally
FreeAndNil(PipelineFactory);
end;
@@ -418,6 +525,7 @@ begin
FreeAndNil(fQueue);
FreeAndNil(fDevice);
FreeAndNil(fPhyDevice);
FreeAndNil(fDebugReporter);
FreeAndNil(fInstance);
FreeAndNil(fAllocHandler);
end;


+ 4
- 1
projects/utils/VulkanUtils.pas Vedi File

@@ -6,7 +6,7 @@ interface

uses
Classes, SysUtils,
uvkuTypes, uvkuAllocationHandler,
uvkuTypes, uvkuAllocationHandler, uvkuDebugReporter,
uvkuInstance, uvkuInstanceFactory,
uvkuPhysicalDevice, uvkuDevice, uvkuDeviceFactory, uvkuDeviceMemory, uvkuQueue,
uvkuSurface, uvkuSurfaceFactory,
@@ -43,6 +43,9 @@ type

TvkuAllocationHandler = uvkuAllocationHandler.TvkuAllocationHandler;

TvkuDebugReporter = uvkuDebugReporter.TvkuDebugReporter;
TvkuConsoleDebugReporter = uvkuDebugReporter.TvkuConsoleDebugReporter;

{ Instance }
TvkuInstance = uvkuInstance.TvkuInstance;
TvkuInstanceFactory = uvkuInstanceFactory.TvkuInstanceFactory;


+ 25
- 6
projects/utils/uvkuAllocationHandler.pas Vedi File

@@ -1,6 +1,7 @@
unit uvkuAllocationHandler;

{$mode objfpc}{$H+}
{$I Vulkan.inc}

interface

@@ -25,32 +26,50 @@ type
implementation

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function AllocateMemoryCallback(aUserData: PVkVoid; aSize: VkSize; aAlignment: VkSize; aScope: TVkSystemAllocationScope): PVkVoid; stdcall;
function AllocateMemoryCallback(
aUserData: PVkVoid;
aSize: VkSize;
aAlignment: VkSize;
aScope: TVkSystemAllocationScope): PVkVoid; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
begin
result := TvkuAllocationHandler(aUserData).AllocateMemory(aSize, aAlignment, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ReallocateMemoryCallback(aUserData: PVkVoid; aOriginal: PVkVoid; aSize: VkSize;
aAlignment: VkSize; aScope: TVkSystemAllocationScope): PVkVoid; stdcall;
function ReallocateMemoryCallback(
aUserData: PVkVoid;
aOriginal: PVkVoid;
aSize: VkSize;
aAlignment: VkSize;
aScope: TVkSystemAllocationScope): PVkVoid; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
begin
result := TvkuAllocationHandler(aUserData).ReallocateMemory(aOriginal, aSize, aAlignment, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure FreeMemoryCallback(aUserData: PVkVoid; aMemory: PVkVoid); stdcall;
procedure FreeMemoryCallback(
aUserData: PVkVoid;
aMemory: PVkVoid); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
begin
TvkuAllocationHandler(aUserData).FreeMemory(aMemory);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure InternalAllocationCallback(aUserData: PVkVoid; aSize: VkSize; aType: TVkInternalAllocationType; aScope: TVkSystemAllocationScope); stdcall;
procedure InternalAllocationCallback(
aUserData: PVkVoid;
aSize: VkSize;
aType: TVkInternalAllocationType;
aScope: TVkSystemAllocationScope); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
begin
TvkuAllocationHandler(aUserData).InternalAllocationNotification(aSize, aType, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure InternalFreeCallback(aUserData: PVkVoid; aSize: VkSize; aType: TVkInternalAllocationType; aScope: TVkSystemAllocationScope); stdcall;
procedure InternalFreeCallback(
aUserData: PVkVoid;
aSize: VkSize;
aType: TVkInternalAllocationType;
aScope: TVkSystemAllocationScope); {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
begin
TvkuAllocationHandler(aUserData).InternalFreeNotification(aSize, aType, aScope);
end;


+ 21
- 0
projects/utils/uvkuCommandBuffer.pas Vedi File

@@ -20,6 +20,8 @@ type
property CommandPool: VkCommandPool read fCommandPool;
property DeviceCommands: TVkDeviceCommands read fDeviceCommands;

procedure BeginCommand;

constructor Create(
const aHandle: VkCommandBuffer;
const aOwnsHandle: Boolean;
@@ -30,8 +32,27 @@ type

implementation

uses
uvkuUtils;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuCommandBuffer//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuCommandBuffer.BeginCommand;
var
Info: TVkCommandBufferBeginInfo;
err: TVkResult;
begin
FillByte(Info, SizeOf(Info), 0);
Info.sType := VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
Info.pNext := nil;
Info.flags := []; // TODO
Info.pInheritanceInfo := nil; // TODO
err := DeviceCommands.vkBeginCommandBuffer(fHandle, @Info);
if (err < VK_SUCCESS) then
raise TvkuErrorException.Create('unable to begin command buffer', err);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuCommandBuffer.Create(const aHandle: VkCommandBuffer; const aOwnsHandle: Boolean;
const aCommandPool: VkCommandPool; const aDeviceCommands: TVkDeviceCommands);


+ 3
- 0
projects/utils/uvkuCommandPoolFactory.pas Vedi File

@@ -15,6 +15,9 @@ type
fFlags: VkCommandPoolCreateFlags;
fQueueFamilyIndex: VkUint32;
public
property Flags: VkCommandPoolCreateFlags read fFlags write fFlags;
property QueueFamilyIndex: VkUint32 read fQueueFamilyIndex write fQueueFamilyIndex;

function GetStructure: TVkCommandPoolCreateInfo;
procedure SetStructure(const aData: TVkCommandPoolCreateInfo);



+ 134
- 0
projects/utils/uvkuDebugReporter.pas Vedi File

@@ -0,0 +1,134 @@
unit uvkuDebugReporter;

{$mode objfpc}{$H+}
{$I Vulkan.inc}

interface

uses
Classes, SysUtils,
Vulkan, uvkuBase, uvkuAllocationHandler;

type
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuDebugReporter = class(TvkuAllocHandle)
private
fHandle: VkDebugReportCallbackEXT;
fInstanceCommands: TVkInstanceCommands;
protected
function DebugMessage(
aFlags: VkDebugReportFlagsEXT;
aObjectType: TVkDebugReportObjectTypeEXT;
aObject: VkUint64;
aLocation: VkSize;
aMessageCode: VkInt32;
aLayerPrefix: String;
aMessage: String): Boolean; virtual;
public
property Handle: VkDebugReportCallbackEXT read fHandle;

constructor Create(
const aInstanceCommands: TVkInstanceCommands;
const aAllocHandler: TvkuAllocationHandler = nil);
destructor Destroy; override;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuConsoleDebugReporter = class(TvkuDebugReporter)
protected
function DebugMessage(aFlags: VkDebugReportFlagsEXT; aObjectType: TVkDebugReportObjectTypeEXT; aObject: VkUint64;
aLocation: VkSize; aMessageCode: VkInt32; aLayerPrefix: String; aMessage: String): Boolean; override;
end;

implementation

uses
uvkuUtils;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function DebugReportCallback(
flags: VkDebugReportFlagsEXT;
objectType: TVkDebugReportObjectTypeEXT;
uObject: VkUint64;
location: VkSize;
messageCode: VkInt32;
pLayerPrefix: PVkChar;
pMessage: PVkChar;
pUserData: PVkVoid): VkBool32; {$IFDEF VK_CDECL}cdecl{$ELSE}stdcall{$ENDIF};
var ret: Boolean;
begin
ret := TvkuDebugReporter(pUserData).DebugMessage(
flags,
objectType,
uObject,
location,
messageCode,
String(pLayerPrefix),
String(pMessage));
if ret
then result := VK_TRUE
else result := VK_FALSE;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuDebugReporter//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuDebugReporter.DebugMessage(aFlags: VkDebugReportFlagsEXT; aObjectType: TVkDebugReportObjectTypeEXT;
aObject: VkUint64; aLocation: VkSize; aMessageCode: VkInt32; aLayerPrefix: String; aMessage: String): Boolean;
begin
result := true;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuDebugReporter.Create(
const aInstanceCommands: TVkInstanceCommands;
const aAllocHandler: TvkuAllocationHandler);
var
CreateInfo: TVkDebugReportCallbackCreateInfoEXT;
err: TVkResult;
begin
inherited Create;
if Assigned(aAllocHandler) then
SetAllocCallbacks(aAllocHandler.MakeStructure);
fInstanceCommands := aInstanceCommands;

FillByte(CreateInfo, SizeOf(CreateInfo), 0);
CreateInfo.sType := VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
CreateInfo.pNext := nil;
CreateInfo.pfnCallback := @DebugReportCallback;
CreateInfo.pUserData := self;
CreateInfo.flags := [
VK_DEBUG_REPORT_INFORMATION_BIT_EXT,
VK_DEBUG_REPORT_WARNING_BIT_EXT,
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
VK_DEBUG_REPORT_ERROR_BIT_EXT,
VK_DEBUG_REPORT_DEBUG_BIT_EXT
];
err := fInstanceCommands.vkCreateDebugReportCallbackEXT(fInstanceCommands.Instance, @CreateInfo, AllocCallbacks, @fHandle);
if (err < VK_SUCCESS) then
raise TvkuErrorException.Create('unable to create debug report handle', err);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
destructor TvkuDebugReporter.Destroy;
begin
if (fHandle <> VK_INVALID_NDP_HANDLE) then
fInstanceCommands.vkDestroyDebugReportCallbackEXT(fInstanceCommands.Instance, fHandle, AllocCallbacks);
fHandle := VK_INVALID_NDP_HANDLE;
inherited Destroy;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuConsoleDebugReporter///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuConsoleDebugReporter.DebugMessage(
aFlags: VkDebugReportFlagsEXT; aObjectType: TVkDebugReportObjectTypeEXT;
aObject: VkUint64; aLocation: VkSize; aMessageCode: VkInt32; aLayerPrefix: String; aMessage: String): Boolean;
begin
WriteLn(Format(' DBG - [%03d] %10s: %s', [ Integer(aFlags), aLayerPrefix, aMessage ]));
end;

end.


Caricamento…
Annulla
Salva