Browse Source

* implemented device and device factory

master
Bergmann89 8 years ago
parent
commit
94762fdb2a
12 changed files with 1052 additions and 190 deletions
  1. +407
    -0
      doc/utils_overview.graphml
  2. BIN
     
  3. +13
    -1
      projects/triangle/triangle.lpi
  4. +2
    -1
      projects/triangle/triangle.lpr
  5. +153
    -80
      projects/triangle/triangle.lps
  6. +32
    -3
      projects/triangle/uMainForm.pas
  7. +103
    -0
      projects/utils/uvkuAllocationHandler.pas
  8. +52
    -5
      projects/utils/uvkuDevice.pas
  9. +242
    -0
      projects/utils/uvkuDeviceFactory.pas
  10. +2
    -2
      projects/utils/uvkuInstance.pas
  11. +17
    -98
      projects/utils/uvkuInstanceFactory.pas
  12. +29
    -0
      projects/utils/uvkuPhysicalDeviceFactory.pas

+ 407
- 0
doc/utils_overview.graphml View File

@@ -0,0 +1,407 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:y="http://www.yworks.com/xml/graphml" xmlns:yed="http://www.yworks.com/xml/yed/3" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://www.yworks.com/xml/schema/graphml/1.1/ygraphml.xsd">
<!--Created by yEd 3.14-->
<key attr.name="Beschreibung" attr.type="string" for="graph" id="d0"/>
<key for="port" id="d1" yfiles.type="portgraphics"/>
<key for="port" id="d2" yfiles.type="portgeometry"/>
<key for="port" id="d3" yfiles.type="portuserdata"/>
<key attr.name="url" attr.type="string" for="node" id="d4"/>
<key attr.name="description" attr.type="string" for="node" id="d5"/>
<key for="node" id="d6" yfiles.type="nodegraphics"/>
<key for="graphml" id="d7" yfiles.type="resources"/>
<key attr.name="url" attr.type="string" for="edge" id="d8"/>
<key attr.name="description" attr.type="string" for="edge" id="d9"/>
<key for="edge" id="d10" yfiles.type="edgegraphics"/>
<graph edgedefault="directed" id="G">
<data key="d0"/>
<node id="n0">
<data key="d5"/>
<data key="d6">
<y:GenericNode configuration="com.yworks.bpmn.Activity.withShadow">
<y:Geometry height="30.0" width="130.0" x="385.0" y="255.0"/>
<y:Fill color="#FFFFFFE6" color2="#D4D4D4CC" transparent="false"/>
<y:BorderStyle color="#123EA2" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="custom" textColor="#000000" visible="true" width="49.36328125" x="40.318359375" y="5.6494140625">Instance<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:StyleProperties>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.line.color" value="#000000"/>
<y:Property class="com.yworks.yfiles.bpmn.view.TaskTypeEnum" name="com.yworks.bpmn.taskType" value="TASK_TYPE_ABSTRACT"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill2" value="#d4d4d4cc"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill" value="#ffffffe6"/>
<y:Property class="com.yworks.yfiles.bpmn.view.BPMNTypeEnum" name="com.yworks.bpmn.type" value="ACTIVITY_TYPE"/>
<y:Property class="com.yworks.yfiles.bpmn.view.ActivityTypeEnum" name="com.yworks.bpmn.activityType" value="ACTIVITY_TYPE_TASK"/>
</y:StyleProperties>
</y:GenericNode>
</data>
</node>
<node id="n1">
<data key="d5"/>
<data key="d6">
<y:GenericNode configuration="com.yworks.bpmn.Activity.withShadow">
<y:Geometry height="30.0" width="130.0" x="385.0" y="165.0"/>
<y:Fill color="#FFFFFFE6" color2="#D4D4D4CC" transparent="false"/>
<y:BorderStyle color="#123EA2" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="custom" textColor="#000000" visible="true" width="89.37109375" x="20.314453125" y="5.6494140625">InstanceFactory<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:StyleProperties>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.line.color" value="#000000"/>
<y:Property class="com.yworks.yfiles.bpmn.view.TaskTypeEnum" name="com.yworks.bpmn.taskType" value="TASK_TYPE_ABSTRACT"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill2" value="#d4d4d4cc"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill" value="#ffffffe6"/>
<y:Property class="com.yworks.yfiles.bpmn.view.BPMNTypeEnum" name="com.yworks.bpmn.type" value="ACTIVITY_TYPE"/>
<y:Property class="com.yworks.yfiles.bpmn.view.ActivityTypeEnum" name="com.yworks.bpmn.activityType" value="ACTIVITY_TYPE_TASK"/>
</y:StyleProperties>
</y:GenericNode>
</data>
</node>
<node id="n2">
<data key="d5"/>
<data key="d6">
<y:GenericNode configuration="com.yworks.bpmn.Activity.withShadow">
<y:Geometry height="30.0" width="130.0" x="565.0" y="165.0"/>
<y:Fill color="#FFFFFFE6" color2="#D4D4D4CC" transparent="false"/>
<y:BorderStyle color="#123EA2" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="custom" textColor="#000000" visible="true" width="125.37109375" x="2.314453125" y="5.6494140625">PhysicalDeviceFactory<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:StyleProperties>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.line.color" value="#000000"/>
<y:Property class="com.yworks.yfiles.bpmn.view.TaskTypeEnum" name="com.yworks.bpmn.taskType" value="TASK_TYPE_ABSTRACT"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill2" value="#d4d4d4cc"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill" value="#ffffffe6"/>
<y:Property class="com.yworks.yfiles.bpmn.view.BPMNTypeEnum" name="com.yworks.bpmn.type" value="ACTIVITY_TYPE"/>
<y:Property class="com.yworks.yfiles.bpmn.view.ActivityTypeEnum" name="com.yworks.bpmn.activityType" value="ACTIVITY_TYPE_TASK"/>
</y:StyleProperties>
</y:GenericNode>
</data>
</node>
<node id="n3">
<data key="d5"/>
<data key="d6">
<y:GenericNode configuration="com.yworks.bpmn.Activity.withShadow">
<y:Geometry height="30.0" width="130.0" x="565.0" y="255.0"/>
<y:Fill color="#FFFFFFE6" color2="#D4D4D4CC" transparent="false"/>
<y:BorderStyle color="#123EA2" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="custom" textColor="#000000" visible="true" width="85.36328125" x="22.318359375" y="5.6494140625">PhysicalDevice<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:StyleProperties>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.line.color" value="#000000"/>
<y:Property class="com.yworks.yfiles.bpmn.view.TaskTypeEnum" name="com.yworks.bpmn.taskType" value="TASK_TYPE_ABSTRACT"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill2" value="#d4d4d4cc"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill" value="#ffffffe6"/>
<y:Property class="com.yworks.yfiles.bpmn.view.BPMNTypeEnum" name="com.yworks.bpmn.type" value="ACTIVITY_TYPE"/>
<y:Property class="com.yworks.yfiles.bpmn.view.ActivityTypeEnum" name="com.yworks.bpmn.activityType" value="ACTIVITY_TYPE_TASK"/>
</y:StyleProperties>
</y:GenericNode>
</data>
</node>
<node id="n4">
<data key="d5"/>
<data key="d6">
<y:GenericNode configuration="com.yworks.bpmn.Activity.withShadow">
<y:Geometry height="30.0" width="130.0" x="745.0" y="165.0"/>
<y:Fill color="#FFFFFFE6" color2="#D4D4D4CC" transparent="false"/>
<y:BorderStyle color="#123EA2" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="custom" textColor="#000000" visible="true" width="80.6875" x="24.65625" y="5.6494140625">DeviceFactory<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:StyleProperties>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.line.color" value="#000000"/>
<y:Property class="com.yworks.yfiles.bpmn.view.TaskTypeEnum" name="com.yworks.bpmn.taskType" value="TASK_TYPE_ABSTRACT"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill2" value="#d4d4d4cc"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill" value="#ffffffe6"/>
<y:Property class="com.yworks.yfiles.bpmn.view.BPMNTypeEnum" name="com.yworks.bpmn.type" value="ACTIVITY_TYPE"/>
<y:Property class="com.yworks.yfiles.bpmn.view.ActivityTypeEnum" name="com.yworks.bpmn.activityType" value="ACTIVITY_TYPE_TASK"/>
</y:StyleProperties>
</y:GenericNode>
</data>
</node>
<node id="n5">
<data key="d5"/>
<data key="d6">
<y:GenericNode configuration="com.yworks.bpmn.Activity.withShadow">
<y:Geometry height="30.0" width="130.0" x="745.0" y="255.0"/>
<y:Fill color="#FFFFFFE6" color2="#D4D4D4CC" transparent="false"/>
<y:BorderStyle color="#123EA2" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="custom" textColor="#000000" visible="true" width="40.6796875" x="44.66015625" y="5.6494140625">Device<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:StyleProperties>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.line.color" value="#000000"/>
<y:Property class="com.yworks.yfiles.bpmn.view.TaskTypeEnum" name="com.yworks.bpmn.taskType" value="TASK_TYPE_ABSTRACT"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill2" value="#d4d4d4cc"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill" value="#ffffffe6"/>
<y:Property class="com.yworks.yfiles.bpmn.view.BPMNTypeEnum" name="com.yworks.bpmn.type" value="ACTIVITY_TYPE"/>
<y:Property class="com.yworks.yfiles.bpmn.view.ActivityTypeEnum" name="com.yworks.bpmn.activityType" value="ACTIVITY_TYPE_TASK"/>
</y:StyleProperties>
</y:GenericNode>
</data>
</node>
<node id="n6">
<data key="d5"/>
<data key="d6">
<y:GenericNode configuration="com.yworks.bpmn.Activity.withShadow">
<y:Geometry height="30.0" width="130.0" x="235.0" y="315.0"/>
<y:Fill color="#FFFFFFE6" color2="#D4D4D4CC" transparent="false"/>
<y:BorderStyle color="#123EA2" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="custom" textColor="#000000" visible="true" width="98.0546875" x="15.97265625" y="5.6494140625">AllocationHandler<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:StyleProperties>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.line.color" value="#000000"/>
<y:Property class="com.yworks.yfiles.bpmn.view.TaskTypeEnum" name="com.yworks.bpmn.taskType" value="TASK_TYPE_ABSTRACT"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill2" value="#d4d4d4cc"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill" value="#ffffffe6"/>
<y:Property class="com.yworks.yfiles.bpmn.view.BPMNTypeEnum" name="com.yworks.bpmn.type" value="ACTIVITY_TYPE"/>
<y:Property class="com.yworks.yfiles.bpmn.view.ActivityTypeEnum" name="com.yworks.bpmn.activityType" value="ACTIVITY_TYPE_TASK"/>
</y:StyleProperties>
</y:GenericNode>
</data>
</node>
<node id="n7">
<data key="d5"/>
<data key="d6">
<y:GenericNode configuration="com.yworks.bpmn.Activity.withShadow">
<y:Geometry height="30.0" width="30.0" x="405.0" y="405.0"/>
<y:Fill hasColor="false" transparent="false"/>
<y:BorderStyle hasColor="false" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" hasText="false" height="4.0" modelName="custom" textColor="#000000" visible="true" width="4.0" x="13.0" y="13.0">
<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:StyleProperties>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.line.color" value="#000000"/>
<y:Property class="com.yworks.yfiles.bpmn.view.TaskTypeEnum" name="com.yworks.bpmn.taskType" value="TASK_TYPE_ABSTRACT"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill2" value="#d4d4d4cc"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill" value="#ffffffe6"/>
<y:Property class="com.yworks.yfiles.bpmn.view.BPMNTypeEnum" name="com.yworks.bpmn.type" value="ACTIVITY_TYPE"/>
<y:Property class="com.yworks.yfiles.bpmn.view.ActivityTypeEnum" name="com.yworks.bpmn.activityType" value="ACTIVITY_TYPE_TASK"/>
</y:StyleProperties>
</y:GenericNode>
</data>
</node>
<node id="n8">
<data key="d5"/>
<data key="d6">
<y:GenericNode configuration="com.yworks.bpmn.Activity.withShadow">
<y:Geometry height="30.0" width="30.0" x="555.0" y="405.0"/>
<y:Fill hasColor="false" transparent="false"/>
<y:BorderStyle hasColor="false" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" hasText="false" height="4.0" modelName="custom" textColor="#000000" visible="true" width="4.0" x="13.0" y="13.0">
<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:StyleProperties>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.line.color" value="#000000"/>
<y:Property class="com.yworks.yfiles.bpmn.view.TaskTypeEnum" name="com.yworks.bpmn.taskType" value="TASK_TYPE_ABSTRACT"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill2" value="#d4d4d4cc"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill" value="#ffffffe6"/>
<y:Property class="com.yworks.yfiles.bpmn.view.BPMNTypeEnum" name="com.yworks.bpmn.type" value="ACTIVITY_TYPE"/>
<y:Property class="com.yworks.yfiles.bpmn.view.ActivityTypeEnum" name="com.yworks.bpmn.activityType" value="ACTIVITY_TYPE_TASK"/>
</y:StyleProperties>
</y:GenericNode>
</data>
</node>
<node id="n9">
<data key="d5"/>
<data key="d6">
<y:GenericNode configuration="com.yworks.bpmn.Activity.withShadow">
<y:Geometry height="30.0" width="30.0" x="405.0" y="465.0"/>
<y:Fill hasColor="false" transparent="false"/>
<y:BorderStyle hasColor="false" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" hasText="false" height="4.0" modelName="custom" textColor="#000000" visible="true" width="4.0" x="13.0" y="13.0">
<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:StyleProperties>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.line.color" value="#000000"/>
<y:Property class="com.yworks.yfiles.bpmn.view.TaskTypeEnum" name="com.yworks.bpmn.taskType" value="TASK_TYPE_ABSTRACT"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill2" value="#d4d4d4cc"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill" value="#ffffffe6"/>
<y:Property class="com.yworks.yfiles.bpmn.view.BPMNTypeEnum" name="com.yworks.bpmn.type" value="ACTIVITY_TYPE"/>
<y:Property class="com.yworks.yfiles.bpmn.view.ActivityTypeEnum" name="com.yworks.bpmn.activityType" value="ACTIVITY_TYPE_TASK"/>
</y:StyleProperties>
</y:GenericNode>
</data>
</node>
<node id="n10">
<data key="d5"/>
<data key="d6">
<y:GenericNode configuration="com.yworks.bpmn.Activity.withShadow">
<y:Geometry height="30.0" width="30.0" x="555.0" y="465.0"/>
<y:Fill hasColor="false" transparent="false"/>
<y:BorderStyle hasColor="false" type="line" width="1.0"/>
<y:NodeLabel alignment="center" autoSizePolicy="content" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" hasText="false" height="4.0" modelName="custom" textColor="#000000" visible="true" width="4.0" x="13.0" y="13.0">
<y:LabelModel>
<y:SmartNodeLabelModel distance="4.0"/>
</y:LabelModel>
<y:ModelParameter>
<y:SmartNodeLabelModelParameter labelRatioX="0.0" labelRatioY="0.0" nodeRatioX="0.0" nodeRatioY="0.0" offsetX="0.0" offsetY="0.0" upX="0.0" upY="-1.0"/>
</y:ModelParameter>
</y:NodeLabel>
<y:StyleProperties>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.line.color" value="#000000"/>
<y:Property class="com.yworks.yfiles.bpmn.view.TaskTypeEnum" name="com.yworks.bpmn.taskType" value="TASK_TYPE_ABSTRACT"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill2" value="#d4d4d4cc"/>
<y:Property class="java.awt.Color" name="com.yworks.bpmn.icon.fill" value="#ffffffe6"/>
<y:Property class="com.yworks.yfiles.bpmn.view.BPMNTypeEnum" name="com.yworks.bpmn.type" value="ACTIVITY_TYPE"/>
<y:Property class="com.yworks.yfiles.bpmn.view.ActivityTypeEnum" name="com.yworks.bpmn.activityType" value="ACTIVITY_TYPE_TASK"/>
</y:StyleProperties>
</y:GenericNode>
</data>
</node>
<edge id="e0" source="n1" target="n0">
<data key="d9"/>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
<y:LineStyle color="#000000" type="line" width="1.0"/>
<y:Arrows source="none" target="standard"/>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
<edge id="e1" source="n2" target="n3">
<data key="d9"/>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
<y:LineStyle color="#000000" type="line" width="1.0"/>
<y:Arrows source="none" target="standard"/>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
<edge id="e2" source="n4" target="n5">
<data key="d9"/>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
<y:LineStyle color="#000000" type="line" width="1.0"/>
<y:Arrows source="none" target="standard"/>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
<edge id="e3" source="n0" target="n6">
<data key="d9"/>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">
<y:Point x="450.0" y="330.0"/>
</y:Path>
<y:LineStyle color="#000000" type="dashed" width="1.0"/>
<y:Arrows source="none" target="standard"/>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
<edge id="e4" source="n5" target="n6">
<data key="d9"/>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0">
<y:Point x="810.0" y="330.0"/>
</y:Path>
<y:LineStyle color="#000000" type="dashed" width="1.0"/>
<y:Arrows source="none" target="standard"/>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
<edge id="e5" source="n7" target="n8">
<data key="d9"/>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
<y:LineStyle color="#000000" type="line" width="1.0"/>
<y:Arrows source="none" target="standard"/>
<y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="side_slider" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="43.3515625" x="38.34619140625" y="-19.701171875">creates<y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/>
</y:EdgeLabel>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
<edge id="e6" source="n9" target="n10">
<data key="d9"/>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
<y:LineStyle color="#000000" type="dashed" width="1.0"/>
<y:Arrows source="none" target="standard"/>
<y:EdgeLabel alignment="center" configuration="AutoFlippingLabel" distance="2.0" fontFamily="Dialog" fontSize="12" fontStyle="plain" hasBackgroundColor="false" hasLineColor="false" height="18.701171875" modelName="side_slider" preferredPlacement="anywhere" ratio="0.5" textColor="#000000" visible="true" width="29.34765625" x="45.34814453125" y="-19.701171875">uses<y:PreferredPlacementDescriptor angle="0.0" angleOffsetOnRightSide="0" angleReference="absolute" angleRotationOnRightSide="co" distance="-1.0" frozen="true" placement="anywhere" side="anywhere" sideReference="relative_to_edge_flow"/>
</y:EdgeLabel>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
<edge id="e7" source="n3" target="n0">
<data key="d9"/>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
<y:LineStyle color="#000000" type="dashed" width="1.0"/>
<y:Arrows source="none" target="standard"/>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
<edge id="e8" source="n5" target="n3">
<data key="d9"/>
<data key="d10">
<y:PolyLineEdge>
<y:Path sx="0.0" sy="0.0" tx="0.0" ty="0.0"/>
<y:LineStyle color="#000000" type="dashed" width="1.0"/>
<y:Arrows source="none" target="standard"/>
<y:BendStyle smoothed="false"/>
</y:PolyLineEdge>
</data>
</edge>
</graph>
<data key="d7">
<y:Resources/>
</data>
</graphml>

BIN
View File


+ 13
- 1
projects/triangle/triangle.lpi View File

@@ -33,7 +33,7 @@
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="8">
<Units Count="11">
<Unit0>
<Filename Value="triangle.lpr"/>
<IsPartOfProject Value="True"/>
@@ -69,6 +69,18 @@
<Filename Value="..\utils\uvkuDevice.pas"/>
<IsPartOfProject Value="True"/>
</Unit7>
<Unit8>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<IsPartOfProject Value="True"/>
</Unit8>
<Unit9>
<Filename Value="..\utils\uvkuPhysicalDeviceFactory.pas"/>
<IsPartOfProject Value="True"/>
</Unit9>
<Unit10>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<IsPartOfProject Value="True"/>
</Unit10>
</Units>
</ProjectOptions>
<CompilerOptions>


+ 2
- 1
projects/triangle/triangle.lpr View File

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

{$R *.res}



+ 153
- 80
projects/triangle/triangle.lps View File

@@ -4,14 +4,13 @@
<PathDelim Value="\"/>
<Version Value="9"/>
<BuildModes Active="Default"/>
<Units Count="13">
<Units Count="16">
<Unit0>
<Filename Value="triangle.lpr"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<CursorPos X="60" Y="10"/>
<UsageCount Value="34"/>
<Loaded Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos X="44" Y="22"/>
<UsageCount Value="40"/>
</Unit0>
<Unit1>
<Filename Value="uMainForm.pas"/>
@@ -19,63 +18,65 @@
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<TopLine Value="6"/>
<CursorPos X="44" Y="9"/>
<UsageCount Value="34"/>
<EditorIndex Value="3"/>
<TopLine Value="72"/>
<CursorPos X="41" Y="98"/>
<UsageCount Value="40"/>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
</Unit1>
<Unit2>
<Filename Value="..\Vulkan.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="7"/>
<CursorPos X="33" Y="1694"/>
<UsageCount Value="34"/>
<EditorIndex Value="2"/>
<WindowIndex Value="1"/>
<TopLine Value="1634"/>
<CursorPos X="27" Y="1645"/>
<UsageCount Value="40"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
<Filename Value="..\utils\uvkuInstance.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="4"/>
<TopLine Value="3"/>
<CursorPos X="44" Y="18"/>
<UsageCount Value="32"/>
<IsVisibleTab Value="True"/>
<WindowIndex Value="1"/>
<TopLine Value="42"/>
<CursorPos X="5" Y="57"/>
<UsageCount Value="38"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="..\utils\uvkuUtils.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="9"/>
<EditorIndex Value="-1"/>
<TopLine Value="28"/>
<CursorPos Y="40"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
<UsageCount Value="35"/>
</Unit4>
<Unit5>
<Filename Value="..\utils\uvkuInstanceFactory.pas"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/>
<TopLine Value="170"/>
<CursorPos Y="186"/>
<UsageCount Value="26"/>
<EditorIndex Value="1"/>
<WindowIndex Value="1"/>
<TopLine Value="123"/>
<CursorPos X="3" Y="126"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit5>
<Unit6>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="5"/>
<CursorPos X="32" Y="38"/>
<UsageCount Value="26"/>
<EditorIndex Value="4"/>
<TopLine Value="42"/>
<CursorPos X="14" Y="18"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit6>
<Unit7>
<Filename Value="..\..\data\Vulkan.tpl"/>
<EditorIndex Value="3"/>
<EditorIndex Value="-1"/>
<TopLine Value="44"/>
<CursorPos X="27" Y="22"/>
<UsageCount Value="15"/>
<Loaded Value="True"/>
<UsageCount Value="14"/>
<DefaultSyntaxHighlighter Value="None"/>
</Unit7>
<Unit8>
@@ -84,108 +85,180 @@
<EditorIndex Value="-1"/>
<TopLine Value="72"/>
<CursorPos X="14" Y="86"/>
<UsageCount Value="10"/>
<UsageCount Value="9"/>
</Unit8>
<Unit9>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\inc\objpash.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="213"/>
<CursorPos X="21" Y="224"/>
<UsageCount Value="10"/>
<UsageCount Value="9"/>
</Unit9>
<Unit10>
<Filename Value="C:\Zusatzprogramme\Lazarus\lcl\include\customform.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="138"/>
<CursorPos Y="154"/>
<UsageCount Value="10"/>
<UsageCount Value="9"/>
</Unit10>
<Unit11>
<Filename Value="C:\Zusatzprogramme\Lazarus\fpc\3.1.1\source\rtl\objpas\sysutils\sysstrh.inc"/>
<EditorIndex Value="8"/>
<EditorIndex Value="-1"/>
<TopLine Value="96"/>
<CursorPos X="10" Y="112"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
<UsageCount Value="10"/>
</Unit11>
<Unit12>
<Filename Value="..\utils\uvkuDevice.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="6"/>
<TopLine Value="8"/>
<CursorPos X="29" Y="31"/>
<UsageCount Value="22"/>
<IsVisibleTab Value="True"/>
<CursorPos X="35" Y="14"/>
<UsageCount Value="28"/>
<Loaded Value="True"/>
</Unit12>
<Unit13>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="1"/>
<TopLine Value="17"/>
<CursorPos X="38" Y="223"/>
<UsageCount Value="26"/>
<Loaded Value="True"/>
</Unit13>
<Unit14>
<Filename Value="..\utils\uvkuPhysicalDeviceFactory.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="-1"/>
<CursorPos Y="16"/>
<UsageCount Value="26"/>
</Unit14>
<Unit15>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="2"/>
<TopLine Value="73"/>
<CursorPos Y="100"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit15>
</Units>
<JumpHistory Count="14" HistoryIndex="13">
<JumpHistory Count="29" HistoryIndex="28">
<Position1>
<Filename Value="uMainForm.pas"/>
<Caret Line="83" Column="19" TopLine="64"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="94" TopLine="73"/>
</Position1>
<Position2>
<Filename Value="uMainForm.pas"/>
<Caret Line="84" Column="16" TopLine="64"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="95" TopLine="73"/>
</Position2>
<Position3>
<Filename Value="triangle.lpr"/>
<Caret Line="10" Column="40"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="96" TopLine="73"/>
</Position3>
<Position4>
<Filename Value="..\utils\uvkuPhysicalDevice.pas"/>
<Caret Line="136" TopLine="14"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="97" TopLine="73"/>
</Position4>
<Position5>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="18" Column="23"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="98" TopLine="73"/>
</Position5>
<Position6>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="31" Column="29" TopLine="8"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="99" TopLine="73"/>
</Position6>
<Position7>
<Filename Value="..\Vulkan.pas"/>
<Caret Line="1836" Column="25" TopLine="1817"/>
<Filename Value="..\utils\uvkuAllocationHandler.pas"/>
<Caret Line="100" TopLine="73"/>
</Position7>
<Position8>
<Filename Value="..\utils\uvkuInstance.pas"/>
<Caret Line="13" Column="27" TopLine="6"/>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="67" TopLine="52"/>
</Position8>
<Position9>
<Filename Value="..\utils\uvkuInstance.pas"/>
<Caret Line="29" Column="87" TopLine="17"/>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="72" TopLine="52"/>
</Position9>
<Position10>
<Filename Value="..\utils\uvkuInstance.pas"/>
<Caret Line="84" Column="29" TopLine="65"/>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="69" TopLine="52"/>
</Position10>
<Position11>
<Filename Value="uMainForm.pas"/>
<Caret Line="9" Column="56"/>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="70" TopLine="52"/>
</Position11>
<Position12>
<Filename Value="uMainForm.pas"/>
<Caret Line="73" Column="26" TopLine="56"/>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="71" TopLine="52"/>
</Position12>
<Position13>
<Filename Value="uMainForm.pas"/>
<Caret Line="25" Column="28" TopLine="10"/>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="47" TopLine="35"/>
</Position13>
<Position14>
<Filename Value="uMainForm.pas"/>
<Caret Line="9" Column="44" TopLine="6"/>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="48" TopLine="35"/>
</Position14>
<Position15>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="49" TopLine="35"/>
</Position15>
<Position16>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="51" TopLine="35"/>
</Position16>
<Position17>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="52" TopLine="35"/>
</Position17>
<Position18>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="58" Column="27" TopLine="35"/>
</Position18>
<Position19>
<Filename Value="..\utils\uvkuDevice.pas"/>
<Caret Line="72" TopLine="57"/>
</Position19>
<Position20>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<Caret Line="77" TopLine="55"/>
</Position20>
<Position21>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<Caret Line="150" TopLine="136"/>
</Position21>
<Position22>
<Filename Value="uMainForm.pas"/>
<Caret Line="91" TopLine="69"/>
</Position22>
<Position23>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<Caret Line="56" Column="48" TopLine="37"/>
</Position23>
<Position24>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<Caret Line="149" Column="47" TopLine="133"/>
</Position24>
<Position25>
<Filename Value="uMainForm.pas"/>
<Caret Line="92" Column="38" TopLine="77"/>
</Position25>
<Position26>
<Filename Value="uMainForm.pas"/>
<Caret Line="91" Column="25" TopLine="74"/>
</Position26>
<Position27>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<Caret Line="183" Column="31" TopLine="172"/>
</Position27>
<Position28>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<Caret Line="184" Column="66" TopLine="170"/>
</Position28>
<Position29>
<Filename Value="..\utils\uvkuDeviceFactory.pas"/>
<Caret Line="151" Column="32" TopLine="134"/>
</Position29>
</JumpHistory>
</ProjectSession>
<Debugging>
<BreakPoints Count="1">
<Item1>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="..\utils\uvkuInstanceFactory.pas"/>
<Line Value="186"/>
</Item1>
</BreakPoints>
</Debugging>
</CONFIG>

+ 32
- 3
projects/triangle/uMainForm.pas View File

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

uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
Vulkan, uvkuInstance, uvkuInstanceFactory, uvkuPhysicalDevice, uvkuUtils;
Vulkan, uvkuInstance, uvkuInstanceFactory, uvkuPhysicalDevice, uvkuUtils, uvkuAllocationHandler, uvkuDevice, uvkuDeviceFactory;

type
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -22,7 +22,9 @@ type
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
fAllocHandler: TCustomAllocHandler;
fInstance: TvkuInstance;
fDevice: TvkuDevice;
public
{ public declarations }
end;
@@ -64,22 +66,49 @@ end;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TMainForm.FormCreate(Sender: TObject);
var
i: Integer;
PhyDevices: TvkuPhysicalDeviceArr;
QueueFamProps: TVkQueueFamilyPropertiesArr;
iFactory: TvkuInstanceFactory;
dFactory: TvkuDeviceFactory;
qci: TvkuQueueCreateInfo;
begin
fAllocHandler := TCustomAllocHandler.Create;

WriteLn('create vulkan instance');
iFactory := TvkuInstanceFactory.Create;
try
fInstance := iFactory.CreateInstance(TCustomAllocHandler.Create, true);
fInstance := iFactory.CreateInstance(fAllocHandler, false);
finally
FreeAndNil(iFactory);
end;

PhyDevices := fInstance.GetPhysicalDevices;
if (Length(PhyDevices) <= 0) then
raise Exception.Create('unable to get physical device');

WriteLn('create vulkan device');
dFactory := TvkuDeviceFactory.Create;
try
SetLength(qci.Priorities, 1);
qci.Priorities[0] := 1.0;
qci.FamilyIndex := 0;
qci.Flags := 0;

dFactory.QueueCreateInfoCount := 1;
dFactory.QueueCreateInfo[0] := qci;

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

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

end.


+ 103
- 0
projects/utils/uvkuAllocationHandler.pas View File

@@ -0,0 +1,103 @@
unit uvkuAllocationHandler;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils,
Vulkan;

type
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuAllocationHandler = class(TObject)
protected
function AllocateMemory(const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid; virtual;
function ReallocateMemory(const aOriginal: PVkVoid; const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid; virtual;
procedure FreeMemory(const aMemory: PVkVoid); virtual;

procedure InternalAllocationNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
procedure InternalFreeNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
public
function GetAllocationCallbacks: TVkAllocationCallbacks;
end;

implementation

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function AllocateMemoryCallback(aUserData: PVkVoid; aSize: VkSize; aAlignment: VkSize; aScope: TVkSystemAllocationScope): PVkVoid; stdcall;
begin
result := TvkuAllocationHandler(aUserData).AllocateMemory(aSize, aAlignment, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ReallocateMemoryCallback(aUserData: PVkVoid; aOriginal: PVkVoid; aSize: VkSize;
aAlignment: VkSize; aScope: TVkSystemAllocationScope): PVkVoid; stdcall;
begin
result := TvkuAllocationHandler(aUserData).ReallocateMemory(aOriginal, aSize, aAlignment, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure FreeMemoryCallback(aUserData: PVkVoid; aMemory: PVkVoid); stdcall;
begin
TvkuAllocationHandler(aUserData).FreeMemory(aMemory);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure InternalAllocationCallback(aUserData: PVkVoid; aSize: VkSize; aType: TVkInternalAllocationType; aScope: TVkSystemAllocationScope); stdcall;
begin
TvkuAllocationHandler(aUserData).InternalAllocationNotification(aSize, aType, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure InternalFreeCallback(aUserData: PVkVoid; aSize: VkSize; aType: TVkInternalAllocationType; aScope: TVkSystemAllocationScope); stdcall;
begin
TvkuAllocationHandler(aUserData).InternalFreeNotification(aSize, aType, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuAllocationHandler//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuAllocationHandler.AllocateMemory(const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid;
begin
result := System.GetMemory(aSize);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuAllocationHandler.ReallocateMemory(const aOriginal: PVkVoid; const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid;
begin
result := System.ReAllocMemory(aOriginal, aSize);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuAllocationHandler.FreeMemory(const aMemory: PVkVoid);
begin
System.FreeMemory(aMemory);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuAllocationHandler.InternalAllocationNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
begin
// DUMMY
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuAllocationHandler.InternalFreeNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
begin
// DUMMY
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuAllocationHandler.GetAllocationCallbacks: TVkAllocationCallbacks;
begin
FillByte(result, SizeOf(result), 0);
result.pUserData := self;
result.pfnAllocation := @AllocateMemoryCallback;
result.pfnReallocation := @ReallocateMemoryCallback;
result.pfnFree := @FreeMemoryCallback;
result.pfnInternalAllocation := @InternalAllocationCallback;
result.pfnInternalFree := @InternalFreeCallback;
end;

end.


+ 52
- 5
projects/utils/uvkuDevice.pas View File

@@ -13,28 +13,75 @@ type
TvkuDevice = class(TObject)
private
fHandle: VkDevice;
fPhysicalDevice: VkPhysicalDevice;
fAllocCallbacks: PVkAllocationCallbacks;

procedure CreateHandle(
const aCreateInfo: PVkDeviceCreateInfo;
const aAllocCallbacks: PVkAllocationCallbacks);
public
property Handle: VkDevice read fHandle;
property Handle: VkDevice read fHandle;
property PhysicalDevice: VkPhysicalDevice read fPhysicalDevice;

constructor Create(const aPhysicalDevice: VkDevice);
constructor Create(
const aPhysicalDevice: VkPhysicalDevice;
const aCreateInfo: TVkDeviceCreateInfo);
constructor Create(
const aPhysicalDevice: VkPhysicalDevice;
const aCreateInfo: TVkDeviceCreateInfo;
const aAllocCallbacks: TVkAllocationCallbacks);
destructor Destroy; override;
end;

implementation

uses
uvkuUtils;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuDevice/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuDevice.Create(const aPhysicalDevice: VkDevice);
var
info: TVkDeviceCreateInfo;
procedure TvkuDevice.CreateHandle(const aCreateInfo: PVkDeviceCreateInfo; const aAllocCallbacks: PVkAllocationCallbacks);
var err: TVkResult;
begin
if Assigned(aAllocCallbacks) then begin
new(fAllocCallbacks);
fAllocCallbacks^ := aAllocCallbacks^;
end;
err := vkCreateDevice(fPhysicalDevice, aCreateInfo, fAllocCallbacks, @fHandle);
if (err < VK_SUCCESS) then
raise TvkuErrorException.Create('unable to create device', err);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuDevice.Create(const aPhysicalDevice: VkPhysicalDevice; const aCreateInfo: TVkDeviceCreateInfo);
begin
inherited Create;
fHandle := nil;
fPhysicalDevice := aPhysicalDevice;
CreateHandle(@aCreateInfo, nil);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuDevice.Create(const aPhysicalDevice: VkPhysicalDevice; const aCreateInfo: TVkDeviceCreateInfo; const aAllocCallbacks: TVkAllocationCallbacks);
begin
inherited Create;
fHandle := nil;
fPhysicalDevice := aPhysicalDevice;
CreateHandle(@aCreateInfo, @aAllocCallbacks);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
destructor TvkuDevice.Destroy;
begin
if Assigned(fHandle) then begin
vkDestroyDevice(fHandle, fAllocCallbacks);
fHandle := nil;
end;
if Assigned(fAllocCallbacks) then begin
Dispose(fAllocCallbacks);
fAllocCallbacks := nil;
end;
inherited Destroy;
end;



+ 242
- 0
projects/utils/uvkuDeviceFactory.pas View File

@@ -0,0 +1,242 @@
unit uvkuDeviceFactory;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils,
Vulkan, uvkuDevice, uvkuAllocationHandler;

type
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuQueuePriorityArr = array of VkFloat;
TvkuQueueCreateInfo = packed record
Flags: VkDeviceQueueCreateFlags;
FamilyIndex: VkUint32;
Priorities: TvkuQueuePriorityArr;
end;
TvkuQueueCreateInfoArr = array of TvkuQueueCreateInfo;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuDeviceEx = class(TvkuDevice)
private
fAllocHandler: TvkuAllocationHandler;
fOwnsHandler: Boolean;
public
constructor Create(
const aPhysicalDevice: VkPhysicalDevice;
const aCreateInfo: TVkDeviceCreateInfo);
constructor Create(
const aPhysicalDevice: VkPhysicalDevice;
const aCreateInfo: TVkDeviceCreateInfo;
const aAllocHandler: TvkuAllocationHandler;
const aOwnsHandler: Boolean);
destructor Destroy; override;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuDeviceFactory = class(TObject)
private
fFeatures: TVkPhysicalDeviceFeatures;
fFlags: VkDeviceCreateFlags;
fLayers: TStringList;
fExtensions: TStringList;
fQueueCreateInfos: TvkuQueueCreateInfoArr;

function GetLayers: TStrings;
function GetExtensions: TStrings;

function GetQueueCreateInfoCount: Integer;
function GetQueueCreateInfo(const aIndex: Integer): TvkuQueueCreateInfo;
function GetQueueCreateInfos: TvkuQueueCreateInfoArr;

procedure SetQueueCreateInfoCount(aValue: Integer);
procedure SetQueueCreateInfo(const aIndex: Integer; aValue: TvkuQueueCreateInfo);
procedure SetQueueCreateInfos(aValue: TvkuQueueCreateInfoArr);
public
property Flags: VkDeviceCreateFlags read fFlags write fFlags;
property EnabledLayers: TStrings read GetLayers;
property EnabledExtensions: TStrings read GetExtensions;
property EnabledFeatures: TVkPhysicalDeviceFeatures read fFeatures;

property QueueCreateInfos: TvkuQueueCreateInfoArr read GetQueueCreateInfos write SetQueueCreateInfos;
property QueueCreateInfoCount: Integer read GetQueueCreateInfoCount write SetQueueCreateInfoCount;
property QueueCreateInfo[const aIndex: Integer]: TvkuQueueCreateInfo read GetQueueCreateInfo write SetQueueCreateInfo;

function CreateDevice(
const aPhysicalDevice: VkPhysicalDevice): TvkuDevice;
function CreateDevice(
const aPhysicalDevice: VkPhysicalDevice;
const aAllocHandler: TvkuAllocationHandler;
const aOwnsHandler: Boolean): TvkuDevice;

constructor Create;
destructor Destroy; override;
end;

implementation

uses
uvkuUtils;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuDeviceEx///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuDeviceEx.Create(const aPhysicalDevice: VkPhysicalDevice; const aCreateInfo: TVkDeviceCreateInfo);
begin
inherited Create(aPhysicalDevice, aCreateInfo);
fAllocHandler := nil;
fOwnsHandler := false;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuDeviceEx.Create(const aPhysicalDevice: VkPhysicalDevice; const aCreateInfo: TVkDeviceCreateInfo;
const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean);
begin
fAllocHandler := aAllocHandler;
fOwnsHandler := aOwnsHandler;
if Assigned(fAllocHandler)
then inherited Create(aPhysicalDevice, aCreateInfo, fAllocHandler.GetAllocationCallbacks)
else inherited Create(aPhysicalDevice, aCreateInfo);
end;

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

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuDeviceFactory//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuDeviceFactory.GetLayers: TStrings;
begin
result := fLayers;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuDeviceFactory.GetExtensions: TStrings;
begin
result := fExtensions;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuDeviceFactory.GetQueueCreateInfoCount: Integer;
begin
result := Length(fQueueCreateInfos);
end;

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

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuDeviceFactory.GetQueueCreateInfos: TvkuQueueCreateInfoArr;
begin
result := fQueueCreateInfos;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuDeviceFactory.SetQueueCreateInfoCount(aValue: Integer);
begin
if (aValue < 0) then
aValue := 0;
SetLength(fQueueCreateInfos, aValue);
end;

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

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuDeviceFactory.SetQueueCreateInfos(aValue: TvkuQueueCreateInfoArr);
begin
fQueueCreateInfos := aValue;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuDeviceFactory.CreateDevice(const aPhysicalDevice: VkPhysicalDevice): TvkuDevice;
begin
result := CreateDevice(aPhysicalDevice, nil, false);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuDeviceFactory.CreateDevice(const aPhysicalDevice: VkPhysicalDevice; const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean): TvkuDevice;
var
CreateInfo: TVkDeviceCreateInfo;
QueueInfos: array of TVkDeviceQueueCreateInfo;
lay: array of PVkChar;
ext: array of PVkChar;
i: Integer;
prio: VkFloat;
err: TVkResult;
begin
if (Length(fQueueCreateInfos) <= 0) then
raise TvkuException.Create('no queue create infos assigned');

SetLength(lay, fLayers.Count);
for i := 0 to fLayers.Count-1 do
lay[i] := PVkChar(fLayers[i]);

SetLength(ext, fExtensions.Count);
for i := 0 to fExtensions.Count-1 do
ext[i] := PVkChar(fExtensions[i]);

SetLength(QueueInfos, Length(fQueueCreateInfos));
for i := 0 to high(fQueueCreateInfos) do begin
FillByte(QueueInfos[i], SizeOf(QueueInfos[0]), 0);
QueueInfos[i].sType := VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
QueueInfos[i].pNext := nil;
QueueInfos[i].flags := fQueueCreateInfos[i].Flags;
QueueInfos[i].queueFamilyIndex := fQueueCreateInfos[i].FamilyIndex;
QueueInfos[i].queueCount := Length(fQueueCreateInfos[i].Priorities);
if (QueueInfos[i].queueCount > 0)
then QueueInfos[i].pQueuePriorities := @fQueueCreateInfos[i].Priorities[0]
else QueueInfos[i].pQueuePriorities := nil;
end;

FillByte(CreateInfo, SizeOf(CreateInfo), 0);
CreateInfo.sType := VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
CreateInfo.pNext := nil;
CreateInfo.flags := fFlags;
CreateInfo.queueCreateInfoCount := Length(QueueInfos);
CreateInfo.pQueueCreateInfos := @QueueInfos[0];
CreateInfo.enabledLayerCount := Length(lay);
CreateInfo.ppEnabledLayerNames := @lay[0];
CreateInfo.enabledExtensionCount := Length(ext);
CreateInfo.ppEnabledExtensionNames := @ext[0];
CreateInfo.pEnabledFeatures := @fFeatures;

result := TvkuDeviceEx.Create(aPhysicalDevice, CreateInfo, aAllocHandler, aOwnsHandler);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuDeviceFactory.Create;
begin
inherited Create;
FillByte(fFeatures, SizeOf(fFeatures), 0);
fLayers := TStringList.Create;
fExtensions := TStringList.Create;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
destructor TvkuDeviceFactory.Destroy;
begin
FreeAndNil(fLayers);
FreeAndNil(fExtensions);
inherited Destroy;
end;

end.


+ 2
- 2
projects/utils/uvkuInstance.pas View File

@@ -21,7 +21,7 @@ type
function GetPhysicalDevice(const aIndex: Integer): VkPhysicalDevice;
procedure UpdatePhysicalDevices;
protected
procedure CreateHandle(aCreateInfo: PVkInstanceCreateInfo; aAllocCallbacks: PVkAllocationCallbacks);
procedure CreateHandle(const aCreateInfo: PVkInstanceCreateInfo; const aAllocCallbacks: PVkAllocationCallbacks);
constructor Create;
public
property Handle: VkInstance read fHandle;
@@ -85,7 +85,7 @@ begin
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuInstance.CreateHandle(aCreateInfo: PVkInstanceCreateInfo; aAllocCallbacks: PVkAllocationCallbacks);
procedure TvkuInstance.CreateHandle(const aCreateInfo: PVkInstanceCreateInfo; const aAllocCallbacks: PVkAllocationCallbacks);
var e: TVkResult;
begin
if Assigned(aAllocCallbacks) then begin


+ 17
- 98
projects/utils/uvkuInstanceFactory.pas View File

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

uses
Classes, SysUtils,
Vulkan, uvkuInstance;
Vulkan, uvkuInstance, uvkuAllocationHandler;

type
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -19,28 +19,20 @@ type
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuAllocationHandler = class(TObject)
protected
function AllocateMemory(const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid; virtual;
function ReallocateMemory(const aOriginal: PVkVoid; const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid; virtual;
procedure FreeMemory(const aMemory: PVkVoid); virtual;

procedure InternalAllocationNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
procedure InternalFreeNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
TvkuInstanceEx = class(TvkuInstance)
private
fAllocHandler: TvkuAllocationHandler;
fOwnsHandler: Boolean;
public
constructor Create(
const aCreateInfo: TVkInstanceCreateInfo;
const aAllocHandler: TvkuAllocationHandler;
const aOwnsHandler: Boolean);
destructor Destroy; override;
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuInstanceFactory = class(TObject)
private type
TvkuInstanceEx = class(TvkuInstance)
private
fAllocHandler: TvkuAllocationHandler;
fOwnsHandler: Boolean;
public
constructor Create(const aCreateInfo: TVkInstanceCreateInfo; const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean);
destructor Destroy; override;
end;

private
fFlags: VkInstanceCreateFlags;
fApplicationInfo: TvkuApplicationInfo;
@@ -95,92 +87,19 @@ begin
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuAllocationHandler//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuAllocationHandler.AllocateMemory(const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid;
begin
result := System.GetMemory(aSize);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuAllocationHandler.ReallocateMemory(const aOriginal: PVkVoid; const aSize: VkSize; const aAlignment: VkSize; const aScope: TVkSystemAllocationScope): PVkVoid;
begin
result := System.ReAllocMemory(aOriginal, aSize);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuAllocationHandler.FreeMemory(const aMemory: PVkVoid);
begin
System.FreeMemory(aMemory);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuAllocationHandler.InternalAllocationNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
begin
// DUMMY
end;

//TvkuInstanceEx/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure TvkuAllocationHandler.InternalFreeNotification(const aSize: VkSize; const aType: TVkInternalAllocationType; const aScope: TVkSystemAllocationScope);
begin
// DUMMY
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function AllocateMemoryCallback(aUserData: PVkVoid; aSize: VkSize; aAlignment: VkSize; aScope: TVkSystemAllocationScope): PVkVoid; stdcall;
begin
result := TvkuAllocationHandler(aUserData).AllocateMemory(aSize, aAlignment, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ReallocateMemoryCallback(aUserData: PVkVoid; aOriginal: PVkVoid; aSize: VkSize;
aAlignment: VkSize; aScope: TVkSystemAllocationScope): PVkVoid; stdcall;
begin
result := TvkuAllocationHandler(aUserData).ReallocateMemory(aOriginal, aSize, aAlignment, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure FreeMemoryCallback(aUserData: PVkVoid; aMemory: PVkVoid); stdcall;
begin
TvkuAllocationHandler(aUserData).FreeMemory(aMemory);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure InternalAllocationCallback(aUserData: PVkVoid; aSize: VkSize; aType: TVkInternalAllocationType; aScope: TVkSystemAllocationScope); stdcall;
begin
TvkuAllocationHandler(aUserData).InternalAllocationNotification(aSize, aType, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
procedure InternalFreeCallback(aUserData: PVkVoid; aSize: VkSize; aType: TVkInternalAllocationType; aScope: TVkSystemAllocationScope); stdcall;
begin
TvkuAllocationHandler(aUserData).InternalFreeNotification(aSize, aType, aScope);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuInstanceFactory.TvkuInstanceEx/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
constructor TvkuInstanceFactory.TvkuInstanceEx.Create(const aCreateInfo: TVkInstanceCreateInfo; const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean);
var
AllocCallbacks: TVkAllocationCallbacks;
constructor TvkuInstanceEx.Create(const aCreateInfo: TVkInstanceCreateInfo; const aAllocHandler: TvkuAllocationHandler; const aOwnsHandler: Boolean);
begin
fOwnsHandler := aOwnsHandler;
fAllocHandler := aAllocHandler;
if Assigned(fAllocHandler) then begin
FillByte(AllocCallbacks, SizeOf(AllocCallbacks), 0);
AllocCallbacks.pUserData := fAllocHandler;
AllocCallbacks.pfnAllocation := @AllocateMemoryCallback;
AllocCallbacks.pfnReallocation := @ReallocateMemoryCallback;
AllocCallbacks.pfnFree := @FreeMemoryCallback;
AllocCallbacks.pfnInternalAllocation := @InternalAllocationCallback;
AllocCallbacks.pfnInternalFree := @InternalFreeCallback;
inherited Create(aCreateInfo, AllocCallbacks);
end else
inherited Create(aCreateInfo);
if Assigned(fAllocHandler)
then inherited Create(aCreateInfo, fAllocHandler.GetAllocationCallbacks)
else inherited Create(aCreateInfo);
end;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
destructor TvkuInstanceFactory.TvkuInstanceEx.Destroy;
destructor TvkuInstanceEx.Destroy;
begin
inherited Destroy;
if fOwnsHandler then


+ 29
- 0
projects/utils/uvkuPhysicalDeviceFactory.pas View File

@@ -0,0 +1,29 @@
unit uvkuPhysicalDeviceFactory;

{$mode objfpc}{$H+}

interface

uses
Classes, SysUtils,
Vulkan, uvkuPhysicalDevice;

type
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TvkuPhysicalDeviceFactory = class(TObject)
public
function CreatePhysicalDevice(const aHandle: VkPhysicalDevice): TvkuPhysicalDevice;
end;

implementation

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//TvkuPhysicalDeviceFactory//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function TvkuPhysicalDeviceFactory.CreatePhysicalDevice(const aHandle: VkPhysicalDevice): TvkuPhysicalDevice;
begin
result := TvkuPhysicalDevice.Create(aHandle);
end;

end.


Loading…
Cancel
Save