/// destroyed on Dispose.
/// </summary>
public ShaderInfo (VkShaderStageFlags stageFlags, VkShaderModule module, SpecializationInfo specializationInfo = null, string entryPoint = "main") {
- EntryPoint = new FixedUtf8String (entryPoint);
-
info.stage = stageFlags;
- info.pName = EntryPoint;
+ info.pName = entryPoint;
info.module = module;
- info.pSpecializationInfo = (specializationInfo == null) ? IntPtr.Zero : specializationInfo.InfosPtr;
+ if (specializationInfo != null)
+ info.pSpecializationInfo = specializationInfo.infos;
}
#region IDisposable Support
protected virtual void Dispose (bool disposing) {
if (!disposedValue) {
- if (disposing)
+ if (disposing)
EntryPoint.Dispose ();
else
System.Diagnostics.Debug.WriteLine ("VKE ShaderInfo disposed by finalizer");
IntPtr pData;
VkSpecializationMapEntry[] entries;
- VkSpecializationInfo infos;
+ public VkSpecializationInfo infos;
- public IntPtr InfosPtr { get; private set; }
#region CTOR
public SpecializationInfo (params SpecializationConstant[] constants) {
}
infos = new VkSpecializationInfo {
- mapEntryCount = (uint)constants.Length,
- pMapEntries = entries.Pin (),
+ pMapEntries = entries,
pData = pData,
dataSize = (UIntPtr)totSize
};
- InfosPtr = infos.Pin ();
}
#endregion
public void Dispose () {
- infos.Unpin ();
+ infos.Dispose();
Marshal.FreeHGlobal (pData);
entries.Unpin ();
}
inheri.queryFlags = queryFlags;
inheri.pipelineStatistics = statFlags;
VkCommandBufferBeginInfo cmdBufInfo = new VkCommandBufferBeginInfo (usage);
- cmdBufInfo.pInheritanceInfo = inheri.Pin ();
+ cmdBufInfo.pInheritanceInfo = inheri;
Utils.CheckResult (vkBeginCommandBuffer (handle, ref cmdBufInfo));
- inheri.Unpin ();
+ cmdBufInfo.Dispose();
}
}
public class PrimaryCommandBuffer : CommandBuffer {
/// <param name="fence">Fence.</param>
public void Submit (VkQueue queue, VkSemaphore wait = default, VkSemaphore signal = default, Fence fence = null) {
VkSubmitInfo submit_info = VkSubmitInfo.New ();
+ submit_info.pWaitDstStageMask = VkPipelineStageFlags.ColorAttachmentOutput;
+ if (signal != VkSemaphore.Null)
+ submit_info.pSignalSemaphores = signal;
+ if (wait != VkSemaphore.Null)
+ submit_info.pWaitSemaphores = wait;
+ submit_info.pCommandBuffers = handle;
- IntPtr dstStageMask = Marshal.AllocHGlobal (sizeof (uint));
- Marshal.WriteInt32 (dstStageMask, (int)VkPipelineStageFlags.ColorAttachmentOutput);
-
- using (PinnedObjects pctx = new PinnedObjects ()) {
- submit_info.pWaitDstStageMask = dstStageMask;
- if (signal != VkSemaphore.Null) {
- submit_info.signalSemaphoreCount = 1;
- submit_info.pSignalSemaphores = signal.Pin (pctx);
- }
- if (wait != VkSemaphore.Null) {
- submit_info.waitSemaphoreCount = 1;
- submit_info.pWaitSemaphores = wait.Pin (pctx);
- }
-
- submit_info.commandBufferCount = 1;
- submit_info.pCommandBuffers = handle.Pin (pctx);
-
- Utils.CheckResult (vkQueueSubmit (queue, 1, ref submit_info, fence));
- }
- Marshal.FreeHGlobal (dstStageMask);
+ Utils.CheckResult (vkQueueSubmit (queue, 1, ref submit_info, fence));
+ submit_info.Dispose();
}
/// <summary>
/// Put the command buffer in the recording state.
/// </summary>
/// <param name="device">the logical device that create the pool.</param>
/// <param name="maxSets">maximum number of descriptor sets that can be allocated from the pool</param>
- public DescriptorPool (Device device, uint maxSets = 1) : base (device) {
+ public DescriptorPool (Device device, uint maxSets = 1) : base (device) {
MaxSets = maxSets;
}
/// <summary>
PoolSizes.AddRange (poolSizes);
- Activate ();
+ Activate ();
}
#endregion
public sealed override void Activate () {
- if (state != ActivableState.Activated) {
+ if (state != ActivableState.Activated) {
VkDescriptorPoolCreateInfo info = VkDescriptorPoolCreateInfo.New();
- info.poolSizeCount = (uint)PoolSizes.Count;
- info.pPoolSizes = PoolSizes.Pin ();
+ info.pPoolSizes = PoolSizes;
info.maxSets = MaxSets;
Utils.CheckResult (vkCreateDescriptorPool (Dev.Handle, ref info, IntPtr.Zero, out handle));
- PoolSizes.Unpin ();
+ info.Dispose();
}
base.Activate ();
}
public void Allocate (DescriptorSet descriptorSet) {
VkDescriptorSetAllocateInfo allocInfo = VkDescriptorSetAllocateInfo.New();
allocInfo.descriptorPool = handle;
- allocInfo.descriptorSetCount = (uint)descriptorSet.descriptorSetLayouts.Count;
- allocInfo.pSetLayouts = descriptorSet.descriptorSetLayouts.Pin();
+ allocInfo.pSetLayouts = descriptorSet.descriptorSetLayouts;
Utils.CheckResult (vkAllocateDescriptorSets (Dev.Handle, ref allocInfo, out descriptorSet.handle));
- descriptorSet.descriptorSetLayouts.Unpin ();
+ allocInfo.Dispose();
}
public void FreeDescriptorSet (params DescriptorSet[] descriptorSets) {
if (descriptorSets.Length == 1) {
descPtrArray.Add (descriptors[i].Pin (pinCtx));
i++;
}
- pDescriptors = descPtrArray.Pin (pinCtx);
} else {
pDescriptors = descriptors[i].Pin (pinCtx);
i++;
}
- if (descriptors[firstDescriptor] is VkDescriptorBufferInfo)
+ /*if (descriptors[firstDescriptor] is VkDescriptorBufferInfo)
wds.pBufferInfo = pDescriptors;
else if (descriptors[firstDescriptor] is VkDescriptorImageInfo)
- wds.pImageInfo = pDescriptors;
+ wds.pImageInfo = pDescriptors;*/
WriteDescriptorSets[wdsPtr] = wds;
wdsPtr++;
pDescriptors = descriptors[i].Pin (pinCtx);
i++;
}
+ /*
if (descriptors[firstDescriptor] is VkDescriptorBufferInfo)
wds.pBufferInfo = pDescriptors;
else if (descriptors[firstDescriptor] is VkDescriptorImageInfo)
- wds.pImageInfo = pDescriptors;
+ wds.pImageInfo = pDescriptors;*/
WriteDescriptorSets[wdsPtr] = wds;
wdsPtr++;
wds.descriptorCount = binding.descriptorCount;
wds.dstBinding = binding.binding;
wds.dstSet = destSet.handle;
- wds.pBufferInfo = descriptor.Pin ();
+ wds.pBufferInfo = descriptor;
WriteDescriptorSets.Add (wds);
}
wds.descriptorCount = binding.descriptorCount;
wds.dstBinding = binding.binding;
wds.dstSet = destSet.handle;
- wds.pImageInfo = descriptor.Pin ();
+ wds.pImageInfo = descriptor;
WriteDescriptorSets.Add (wds);
}
}
VkDeviceCreateInfo deviceCreateInfo = VkDeviceCreateInfo.New ();
- deviceCreateInfo.queueCreateInfoCount = (uint)qInfos.Count;
- deviceCreateInfo.pQueueCreateInfos = qInfos.Pin ();
- deviceCreateInfo.pEnabledFeatures = enabledFeatures.Pin ();
+ deviceCreateInfo.pQueueCreateInfos = qInfos;
+ deviceCreateInfo.pEnabledFeatures = enabledFeatures;
if (deviceExtensions.Count > 0) {
deviceCreateInfo.enabledExtensionCount = (uint)deviceExtensions.Count;
}
Utils.CheckResult (vkCreateDevice (phy.Handle, ref deviceCreateInfo, IntPtr.Zero, out dev));
- qInfos.Unpin ();
- enabledFeatures.Unpin ();
+
+ deviceCreateInfo.Dispose();
+
foreach (List<float> fa in prioritiesLists)
fa.Unpin ();
public sealed override void Activate () {
if (state != ActivableState.Activated) {
VkImageView[] views = attachments.Select (a => a.Descriptor.imageView).ToArray ();
- createInfo.attachmentCount = (uint)views.Length;
- createInfo.pAttachments = views.Pin ();
+ createInfo.pAttachments = views;
if (PNext != null)
createInfo.pNext = PNext.GetPointer();
Utils.CheckResult (vkCreateFramebuffer (renderPass.Dev.Handle, ref createInfo, IntPtr.Zero, out handle));
- views.Unpin ();
+ createInfo.Dispose();
+
if (PNext != null)
PNext.ReleasePointer ();
colorBlendInfo.logicOpEnable = cfg.ColorBlendLogicOpEnable;
colorBlendInfo.logicOp = cfg.ColorBlendLogicOp;
colorBlendInfo.blendConstants = cfg.ColorBlendConstants;
- colorBlendInfo.attachmentCount = (uint)cfg.blendAttachments.Count;
- colorBlendInfo.pAttachments = cfg.blendAttachments.Pin (pctx);
+ colorBlendInfo.pAttachments = cfg.blendAttachments;
VkPipelineDynamicStateCreateInfo dynStatesInfo = VkPipelineDynamicStateCreateInfo.New ();
- dynStatesInfo.dynamicStateCount = (uint)cfg.dynamicStates.Count;
- dynStatesInfo.pDynamicStates = cfg.dynamicStates.Cast<int> ().ToArray ().Pin (pctx);
+ dynStatesInfo.pDynamicStates = cfg.dynamicStates;
VkPipelineVertexInputStateCreateInfo vertInputInfo = VkPipelineVertexInputStateCreateInfo.New ();
- vertInputInfo.vertexBindingDescriptionCount = (uint)cfg.vertexBindings.Count;
- vertInputInfo.pVertexBindingDescriptions = cfg.vertexBindings.Pin (pctx);
- vertInputInfo.vertexAttributeDescriptionCount = (uint)cfg.vertexAttributes.Count;
- vertInputInfo.pVertexAttributeDescriptions = cfg.vertexAttributes.Pin (pctx);
+ vertInputInfo.pVertexBindingDescriptions = cfg.vertexBindings;
+ vertInputInfo.pVertexAttributeDescriptions = cfg.vertexAttributes;
VkPipelineViewportStateCreateInfo viewportState = VkPipelineViewportStateCreateInfo.New ();
if (cfg.Viewports.Count > 0) {
- viewportState.viewportCount = (uint)cfg.Viewports.Count;
- viewportState.pViewports = cfg.Viewports.Pin (pctx);
+ viewportState.pViewports = cfg.Viewports;
} else
viewportState.viewportCount = 1;
if (cfg.Scissors.Count > 0) {
- viewportState.scissorCount = (uint)cfg.Scissors.Count;
- viewportState.pScissors = cfg.Scissors.Pin (pctx);
+ viewportState.pScissors = cfg.Scissors;
} else
viewportState.scissorCount = 1;
VkGraphicsPipelineCreateInfo info = VkGraphicsPipelineCreateInfo.New ();
info.renderPass = RenderPass.handle;
info.layout = Layout.handle;
- info.pVertexInputState = vertInputInfo.Pin (pctx);
- info.pInputAssemblyState = cfg.inputAssemblyState.Pin (pctx);
- info.pRasterizationState = cfg.rasterizationState.Pin (pctx);
- info.pColorBlendState = colorBlendInfo.Pin (pctx);
- info.pMultisampleState = cfg.multisampleState.Pin (pctx);
- info.pViewportState = viewportState.Pin (pctx);
- info.pDepthStencilState = cfg.depthStencilState.Pin (pctx);
- info.pDynamicState = dynStatesInfo.Pin (pctx);
- info.stageCount = (uint)cfg.Shaders.Count;
- info.pStages = shaderStages.Pin (pctx);
+ info.pVertexInputState = vertInputInfo;
+ info.pInputAssemblyState = cfg.inputAssemblyState;
+ info.pRasterizationState = cfg.rasterizationState;
+ info.pColorBlendState = colorBlendInfo;
+ info.pMultisampleState = cfg.multisampleState;
+ info.pViewportState = viewportState;
+ info.pDepthStencilState = cfg.depthStencilState;
+ info.pDynamicState = dynStatesInfo;
+ info.pStages = shaderStages;
info.subpass = cfg.SubpassIndex;
if (enableTesselation) {
VkPipelineTessellationStateCreateInfo tessellationInfo = VkPipelineTessellationStateCreateInfo.New();
tessellationInfo.patchControlPoints = cfg.TessellationPatchControlPoints;
- info.pTessellationState = tessellationInfo.Pin (pctx);
+ info.pTessellationState = tessellationInfo;
}
Utils.CheckResult (vkCreateGraphicsPipelines (Dev.Handle, Cache == null ? VkPipelineCache.Null : Cache.handle, 1, ref info, IntPtr.Zero, out handle));
+
+ info.Dispose ();
}
}
base.Activate ();
public VkPipelineBindPoint bindPoint = VkPipelineBindPoint.Graphics;
public VkPipelineInputAssemblyStateCreateInfo inputAssemblyState = VkPipelineInputAssemblyStateCreateInfo.New ();
public VkPipelineRasterizationStateCreateInfo rasterizationState = VkPipelineRasterizationStateCreateInfo.New ();
- public IList<VkViewport> Viewports = new List<VkViewport> ();
- public IList<VkRect2D> Scissors = new List<VkRect2D> ();
+ public List<VkViewport> Viewports = new List<VkViewport> ();
+ public List<VkRect2D> Scissors = new List<VkRect2D> ();
public VkPipelineDepthStencilStateCreateInfo depthStencilState = VkPipelineDepthStencilStateCreateInfo.New ();
public VkPipelineMultisampleStateCreateInfo multisampleState = VkPipelineMultisampleStateCreateInfo.New ();
- public IList<VkPipelineColorBlendAttachmentState> blendAttachments = new List<VkPipelineColorBlendAttachmentState> ();
- public IList<VkDynamicState> dynamicStates = new List<VkDynamicState> ();
- public IList<VkVertexInputBindingDescription> vertexBindings = new List<VkVertexInputBindingDescription> ();
- public IList<VkVertexInputAttributeDescription> vertexAttributes = new List<VkVertexInputAttributeDescription> ();
+ public List<VkPipelineColorBlendAttachmentState> blendAttachments = new List<VkPipelineColorBlendAttachmentState> ();
+ public List<VkDynamicState> dynamicStates = new List<VkDynamicState> ();
+ public List<VkVertexInputBindingDescription> vertexBindings = new List<VkVertexInputBindingDescription> ();
+ public List<VkVertexInputAttributeDescription> vertexAttributes = new List<VkVertexInputAttributeDescription> ();
/// <summary>
/// List of ShaderInfo's used to in this pipeline configuration. Those shaders have to be Disposed
/// after pipeline creation from this configuration. The 'DisposeShaders' helper method with clear the list.
/// To replace a single shader between two use of this configuration object to create two different pipelines, use
/// the 'ReplaceShader' helper method to automatically dispose the replace shader.
/// </summary>
- public IList<ShaderInfo> Shaders = new List<ShaderInfo> ();
+ public List<ShaderInfo> Shaders = new List<ShaderInfo> ();
public VkBool32 ColorBlendLogicOpEnable = false;
public VkLogicOp ColorBlendLogicOp;
public Vector4 ColorBlendConstants;
};
VkInstanceCreateInfo instanceCreateInfo = VkInstanceCreateInfo.New ();
- instanceCreateInfo.pApplicationInfo = appInfo.Pin (pctx);
+ instanceCreateInfo.pApplicationInfo = appInfo;
if (instanceExtensions.Count > 0) {
instanceCreateInfo.enabledExtensionCount = (uint)instanceExtensions.Count;
#region CTORS
public PipelineLayout (Device device) : base (device) { }
- public PipelineLayout (Device device, VkPushConstantRange pushConstantRange, params DescriptorSetLayout[] descriptorSetLayouts)
+ public PipelineLayout (Device device, VkPushConstantRange pushConstantRange, params DescriptorSetLayout[] descriptorSetLayouts)
: this (device, descriptorSetLayouts) {
PushConstantRanges.Add (pushConstantRange);
}
}
public PipelineLayout (Device device, params DescriptorSetLayout[] descriptorSetLayouts)
:this (device) {
-
+
if (descriptorSetLayouts.Length > 0)
DescriptorSetLayouts.AddRange (descriptorSetLayouts);
}
#endregion
- public void AddPushConstants (params VkPushConstantRange[] pushConstantRanges) {
+ public void AddPushConstants (params VkPushConstantRange[] pushConstantRanges) {
foreach (VkPushConstantRange pcr in pushConstantRanges)
PushConstantRanges.Add (pcr);
}
public override void Activate () {
if (state != ActivableState.Activated) {
- foreach (DescriptorSetLayout dsl in DescriptorSetLayouts)
+ foreach (DescriptorSetLayout dsl in DescriptorSetLayouts)
dsl.Activate ();
VkPipelineLayoutCreateInfo info = VkPipelineLayoutCreateInfo.New();
VkDescriptorSetLayout[] dsls = DescriptorSetLayouts.Select (dsl => dsl.handle).ToArray ();
if (dsls.Length > 0) {
- info.setLayoutCount = (uint)dsls.Length;
- info.pSetLayouts = dsls.Pin ();
+ info.pSetLayouts = dsls;
}
if (PushConstantRanges.Count > 0) {
- info.pushConstantRangeCount = (uint)PushConstantRanges.Count;
- info.pPushConstantRanges = PushConstantRanges.Pin();
+ info.pPushConstantRanges = PushConstantRanges;
}
Utils.CheckResult (vkCreatePipelineLayout (Dev.Handle, ref info, IntPtr.Zero, out handle));
- if (dsls.Length > 0)
- dsls.Unpin ();
- if (PushConstantRanges.Count > 0)
- PushConstantRanges.Unpin ();
+ info.Dispose();
+
}
base.Activate ();
}
protected override void Dispose (bool disposing) {
if (state == ActivableState.Activated) {
if (disposing) {
- foreach (DescriptorSetLayout dsl in DescriptorSetLayouts)
- dsl.Dispose ();
+ foreach (DescriptorSetLayout dsl in DescriptorSetLayouts)
+ dsl.Dispose ();
} else
System.Diagnostics.Debug.WriteLine ("VKE Activable PipelineLayout disposed by finalizer");
namespace vke {
- public class PresentQueue : Queue {
- public readonly VkSurfaceKHR Surface;
-
- public PresentQueue (Device _dev, VkQueueFlags requestedFlags, VkSurfaceKHR _surface, float _priority = 0.0f) {
- dev = _dev;
- priority = _priority;
- Surface = _surface;
-
- qFamIndex = searchQFamily (requestedFlags);
- dev.queues.Add (this);
- }
-
- uint searchQFamily (VkQueueFlags requestedFlags) {
- //search for dedicated Q
- for (uint i = 0; i < dev.phy.QueueFamilies.Length; i++) {
- if (dev.phy.QueueFamilies[i].queueFlags == requestedFlags && dev.phy.GetPresentIsSupported (i, Surface))
- return i;
- }
- //search Q having flags
- for (uint i = 0; i < dev.phy.QueueFamilies.Length; i++) {
- if ((dev.phy.QueueFamilies[i].queueFlags & requestedFlags) == requestedFlags && dev.phy.GetPresentIsSupported (i, Surface))
- return i;
- }
-
- throw new Exception (string.Format ("No Queue with flags {0} found", requestedFlags));
- }
-
- public void Present (VkPresentInfoKHR present) {
- Utils.CheckResult (vkQueuePresentKHR (handle, ref present));
- }
- public void Present (SwapChain swapChain, VkSemaphore wait) {
- VkPresentInfoKHR present = VkPresentInfoKHR.New();
-
- uint idx = swapChain.currentImageIndex;
- VkSwapchainKHR sc = swapChain.Handle;
- present.swapchainCount = 1;
- present.pSwapchains = sc.Pin();
- present.waitSemaphoreCount = 1;
- present.pWaitSemaphores = wait.Pin();
- present.pImageIndices = idx.Pin();
-
- vkQueuePresentKHR (handle, ref present);
-
- sc.Unpin ();
- wait.Unpin ();
- idx.Unpin ();
- }
- }
-
- public class Queue {
-
- protected VkQueue handle;
- internal Device dev;
+ public class PresentQueue : Queue {
+ public readonly VkSurfaceKHR Surface;
+
+ public PresentQueue (Device _dev, VkQueueFlags requestedFlags, VkSurfaceKHR _surface, float _priority = 0.0f) {
+ dev = _dev;
+ priority = _priority;
+ Surface = _surface;
+
+ qFamIndex = searchQFamily (requestedFlags);
+ dev.queues.Add (this);
+ }
+
+ uint searchQFamily (VkQueueFlags requestedFlags) {
+ //search for dedicated Q
+ for (uint i = 0; i < dev.phy.QueueFamilies.Length; i++) {
+ if (dev.phy.QueueFamilies[i].queueFlags == requestedFlags && dev.phy.GetPresentIsSupported (i, Surface))
+ return i;
+ }
+ //search Q having flags
+ for (uint i = 0; i < dev.phy.QueueFamilies.Length; i++) {
+ if ((dev.phy.QueueFamilies[i].queueFlags & requestedFlags) == requestedFlags && dev.phy.GetPresentIsSupported (i, Surface))
+ return i;
+ }
+
+ throw new Exception (string.Format ("No Queue with flags {0} found", requestedFlags));
+ }
+
+ public void Present (VkPresentInfoKHR present) {
+ Utils.CheckResult (vkQueuePresentKHR (handle, ref present));
+ }
+ public void Present (SwapChain swapChain, VkSemaphore wait) {
+ VkPresentInfoKHR present = VkPresentInfoKHR.New();
+
+ uint idx = swapChain.currentImageIndex;
+ VkSwapchainKHR sc = swapChain.Handle;
+ present.pSwapchains = sc;
+ present.pWaitSemaphores = wait;
+
+ vkQueuePresentKHR (handle, ref present);
+
+ present.Dispose();
+ }
+ }
+
+ public class Queue {
+
+ protected VkQueue handle;
+ internal Device dev;
public Device Dev => dev;
- VkQueueFlags flags => dev.phy.QueueFamilies[qFamIndex].queueFlags;
- public uint qFamIndex;
- public uint index;//index in queue family
- public float priority;
- public VkQueue Handle => handle;
-
- protected Queue () { }
- public Queue (Device _dev, VkQueueFlags requestedFlags, float _priority = 0.0f) {
- dev = _dev;
- priority = _priority;
-
- qFamIndex = searchQFamily (requestedFlags);
- dev.queues.Add (this);
- }
- public CommandPool CreateCommandPool (VkCommandPoolCreateFlags flags = 0)
- => new CommandPool (dev, qFamIndex, flags);
+ VkQueueFlags flags => dev.phy.QueueFamilies[qFamIndex].queueFlags;
+ public uint qFamIndex;
+ public uint index;//index in queue family
+ public float priority;
+ public VkQueue Handle => handle;
+
+ protected Queue () { }
+ public Queue (Device _dev, VkQueueFlags requestedFlags, float _priority = 0.0f) {
+ dev = _dev;
+ priority = _priority;
+
+ qFamIndex = searchQFamily (requestedFlags);
+ dev.queues.Add (this);
+ }
+ public CommandPool CreateCommandPool (VkCommandPoolCreateFlags flags = 0)
+ => new CommandPool (dev, qFamIndex, flags);
/// <summary>
/// End command recording, submit, and wait queue idle
/// </summary>
if (freeCommandBuffer)
cmd.Free ();
}
- public void Submit (PrimaryCommandBuffer cmd, VkSemaphore wait = default, VkSemaphore signal = default, Fence fence = null) {
- cmd.Submit (handle, wait, signal, fence);
- }
- public void WaitIdle () {
- Utils.CheckResult (vkQueueWaitIdle (handle));
- }
-
- uint searchQFamily (VkQueueFlags requestedFlags) {
- //search for dedicated Q
- for (uint i = 0; i < dev.phy.QueueFamilies.Length; i++) {
- if (dev.phy.QueueFamilies[i].queueFlags == requestedFlags)
- return i;
- }
- //search Q having flags
- for (uint i = 0; i < dev.phy.QueueFamilies.Length; i++) {
- if ((dev.phy.QueueFamilies[i].queueFlags & requestedFlags) == requestedFlags)
- return i;
- }
-
- throw new Exception (string.Format ("No Queue with flags {0} found", requestedFlags));
- }
-
- internal void updateHandle () {
- vkGetDeviceQueue (Dev.Handle, qFamIndex, index, out handle);
- }
- }
+ public void Submit (PrimaryCommandBuffer cmd, VkSemaphore wait = default, VkSemaphore signal = default, Fence fence = null) {
+ cmd.Submit (handle, wait, signal, fence);
+ }
+ public void WaitIdle () {
+ Utils.CheckResult (vkQueueWaitIdle (handle));
+ }
+
+ uint searchQFamily (VkQueueFlags requestedFlags) {
+ //search for dedicated Q
+ for (uint i = 0; i < dev.phy.QueueFamilies.Length; i++) {
+ if (dev.phy.QueueFamilies[i].queueFlags == requestedFlags)
+ return i;
+ }
+ //search Q having flags
+ for (uint i = 0; i < dev.phy.QueueFamilies.Length; i++) {
+ if ((dev.phy.QueueFamilies[i].queueFlags & requestedFlags) == requestedFlags)
+ return i;
+ }
+
+ throw new Exception (string.Format ("No Queue with flags {0} found", requestedFlags));
+ }
+
+ internal void updateHandle () {
+ vkGetDeviceQueue (Dev.Handle, qFamIndex, index, out handle);
+ }
+ }
}
spDescs.Add (sp.SubpassDescription);
VkRenderPassCreateInfo renderPassInfo = VkRenderPassCreateInfo.New();
- renderPassInfo.attachmentCount = (uint)attachments.Count;
- renderPassInfo.pAttachments = attachments.Pin ();
- renderPassInfo.subpassCount = (uint)spDescs.Count;
- renderPassInfo.pSubpasses = spDescs.Pin ();
- renderPassInfo.dependencyCount = (uint)dependencies.Count;
- renderPassInfo.pDependencies = dependencies.Pin ();
+ renderPassInfo.pAttachments = attachments;
+ renderPassInfo.pSubpasses = spDescs;
+ renderPassInfo.pDependencies = dependencies;
if (PNext != null)
renderPassInfo.pNext = PNext.GetPointer ();
if (PNext != null)
PNext.ReleasePointer ();
- attachments.Unpin ();
- spDescs.Unpin ();
- dependencies.Unpin ();
+
+ renderPassInfo.Dispose ();
}
base.Activate ();
}
info.renderPass = handle;
info.renderArea.extent.width = width;
info.renderArea.extent.height = height;
- info.clearValueCount = (uint)ClearValues.Count;
- info.pClearValues = ClearValues.Pin ();
+ info.pClearValues = ClearValues;
info.framebuffer = frameBuffer.handle;
vkCmdBeginRenderPass (cmd.Handle, ref info, contents);
public SubPass () {
}
public SubPass (params VkImageLayout[] layouts) {
- for (uint i = 0; i < layouts.Length; i++)
+ for (uint i = 0; i < layouts.Length; i++)
AddColorReference (i, layouts[i]);
}
VkSubpassDescription subpassDescription = new VkSubpassDescription ();
subpassDescription.pipelineBindPoint = VkPipelineBindPoint.Graphics;
if (colorRefs.Count > 0) {
- subpassDescription.colorAttachmentCount = (uint)colorRefs.Count;
- subpassDescription.pColorAttachments = colorRefs.Pin(); ;
+ subpassDescription.pColorAttachments = colorRefs;
}
if (inputRefs.Count > 0) {
- subpassDescription.inputAttachmentCount = (uint)inputRefs.Count;
- subpassDescription.pInputAttachments = inputRefs.Pin (); ;
+ subpassDescription.pInputAttachments = inputRefs; ;
}
if (preservedRefs.Count > 0) {
- subpassDescription.preserveAttachmentCount = (uint)preservedRefs.Count;
subpassDescription.pPreserveAttachments = preservedRefs.Pin (); ;
}
if (resolveRefs.Count > 0)
- subpassDescription.pResolveAttachments = resolveRefs.Pin ();
+ subpassDescription.pResolveAttachments = resolveRefs;
if (DepthReference.HasValue)
- subpassDescription.pDepthStencilAttachment = DepthReference.Value.Pin();
+ subpassDescription.pDepthStencilAttachment = DepthReference.Value;
return subpassDescription;
- }
+ }
}
internal void UnpinLists () {
- if (colorRefs.Count > 0)
- colorRefs.Unpin ();
- if (inputRefs.Count > 0)
+ if (colorRefs.Count > 0)
+ colorRefs.Unpin ();
+ if (inputRefs.Count > 0)
inputRefs.Unpin ();
- if (preservedRefs.Count > 0)
+ if (preservedRefs.Count > 0)
preservedRefs.Unpin ();
if (resolveRefs.Count > 0)
resolveRefs.Unpin ();
<ItemGroup>
<PackageReference Include="SpirVTasks" Version="$(SpirVTasksPackageVersion)" />
- <PackageReference Include="Vulkan" Version="0.3.0-beta" />
+ <PackageReference Include="Vulkan" Version="0.4.0-beta" />
<PackageReference Include="shaderc.net" Version="0.1.0" />
<PackageReference Include="glfw-sharp" Version="0.2.14" />
</ItemGroup>