Skip to content

Commit

Permalink
Add AdapterConfig.Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
FaberSanZ committed Nov 23, 2021
1 parent 0177342 commit f835c29
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 50 deletions.
4 changes: 2 additions & 2 deletions Src/Samples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class Program
{
static void Main(string[] args)
{
using var App = new ClearScreen.ClearScreenExample();
//using var App = new Triangle.TriangleExample();
//using var App = new ClearScreen.ClearScreenExample();
using var App = new Triangle.TriangleExample();
//using var App = new Transformations.TransformationsExample();
//using var App = new PushConstant.PushConstantExample();
//using var App = new LoadGLTF.LoadGLTFExample();
Expand Down
2 changes: 1 addition & 1 deletion Src/Samples/Samples/Bindless/Bindless.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override void Initialize()
AdapterConfig = new()
{
SwapChain = true,
VulkanDebug = false,
Debug = false,
Bindless = true,
//SingleQueue
};
Expand Down
7 changes: 1 addition & 6 deletions Src/Samples/Samples/ClearScreen/ClearScreenExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,13 @@ public ClearScreenExample() : base()
AdapterConfig = new()
{
SwapChain = true,
VulkanDebug = true,
//VultaikDebug = true,
Debug = true,
Fullscreen = false,
Bindless = false,
BindMemory2 = false,
ConditionalRendering = false,
ConservativeRasterization = false,
CopyCommands2 = false,
Multiview = false,
RayTracing = false,
ShadingRate = false,
SingleQueue = false,
};
}

Expand Down
28 changes: 14 additions & 14 deletions Src/Vultaik/Adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ internal void supports_extensions()
.Select(_ => Interop.String.FromPointer(_.extensionName));


if (AdapterConfig.VulkanDebug && instance_extensions_names.Contains("VK_EXT_debug_utils"));
if (AdapterConfig.Debug && instance_extensions_names.Contains("VK_EXT_debug_utils"));
{
InstanceExtensionsNames.Add("VK_EXT_debug_utils");
SupportsDebugUtils = true;
Expand Down Expand Up @@ -351,7 +351,7 @@ internal void CreateInstance(string[] extensions)

ReadOnlySpan<VkLayerProperties> availableLayers = vkEnumerateInstanceLayerProperties();

if (AdapterConfig.VulkanDebug)
if (AdapterConfig.Debug)
foreach (var layer in availableLayers)
if ("VK_LAYER_KHRONOS_validation" == layer.GetLayerName())
requested_validation_layers.Add("VK_LAYER_KHRONOS_validation");
Expand Down Expand Up @@ -408,19 +408,19 @@ private static uint DebugMessengerCallback(VkDebugUtilsMessageSeverityFlagsEXT m
uint[] ignored_ids = new[]
{
0xc05b3a9du,
//0x2864340eu,
//0xbfcfaec2u,
//0x96f03c1cu,
//0x8189c842u,
//0x3d492883u,
//0x1608dec0u,
0x2864340eu,
0xbfcfaec2u,
0x96f03c1cu,
0x8189c842u,
0x3d492883u,
0x1608dec0u,

0x9b4c6071u, // TODO: VkDebugUtilsObjectNameInfoEXT
//0x90ef715du, // TODO: UNASSIGNED-CoreValidation-DrawState-InvalidImageAspect
//0xf27b16au, // TODO: VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: when using a Depth or Stencil format
//0x34f84ef4u, // TODO: vkCmdBeginRenderPass-initialLayout: If any of the initialLayout or finalLayout member of the VkAttachmentDescription
//0x4d08326du, // TODO: vkEndCommandBuffer-commandBuffer
//0xc7aabc16u, // TODO: VkPresentInfoKHR-pImageIndices
0x90ef715du, // TODO: UNASSIGNED-CoreValidation-DrawState-InvalidImageAspect
0xf27b16au, // TODO: VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: when using a Depth or Stencil format
0x34f84ef4u, // TODO: vkCmdBeginRenderPass-initialLayout: If any of the initialLayout or finalLayout member of the VkAttachmentDescription
0x4d08326du, // TODO: vkEndCommandBuffer-commandBuffer
0xc7aabc16u, // TODO: VkPresentInfoKHR-pImageIndices
};

for (int i = 0; i < ignored_ids.Length; i++)
Expand Down Expand Up @@ -587,7 +587,7 @@ public void Dispose()

private void vultaik_debug()
{
if (AdapterConfig.VultaikDebug)
if (AdapterConfig.Debug)
{
ConsoleLog.Info("Adapter", $"Handle = 0x{handle.Handle.ToString("X")}");
ConsoleLog.Info("Adapter", $"DepthFormat = {DepthFormat}");
Expand Down
14 changes: 1 addition & 13 deletions Src/Vultaik/AdapterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,24 @@ namespace Vultaik
{
public class AdapterConfig
{
public bool VulkanDebug { get; set; }
public bool Debug { get; set; }

public bool ValidationGpuAssisted { get; set; }

public bool VultaikDebug { get; set; } // TODO: Implement VultaikDebug

public bool Fullscreen { get; set; } // TODO: Implement Fullscreen

public bool RayTracing { get; set; } // TODO: Implement RayTracing

public bool ConservativeRasterization { get; set; } // TODO: Implement ConservativeRasterization

public bool CopyCommands2 { get; set; } // TODO: Implement CopyCommands2

public bool BindMemory2 { get; set; } // TODO: Implement BindMemory2

public bool Multiview { get; set; } // TODO: Implement Multiview

public bool ConditionalRendering { get; set; } // TODO: Implement ConditionalRendering

public bool ShadingRate { get; set; } // TODO: Implement ShadingRate

public bool Bindless { get; set; }

public bool SingleQueue { get; set; } // TODO: Implement SingleQueue

public bool SwapChain { get; set; }

public bool SamplerAnisotropy { get; set; } // TODO: Implement SamplerAnisotropy

public bool Arithmetic16BitStorage { get; set; }

public bool IntegratedGpu { get; set; }
Expand Down
18 changes: 9 additions & 9 deletions Src/Vultaik/Graphics/GraphicsPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ private void SetupDescriptorSetLayout()
ShaderResource[] resources = Resources.Where(x => x.resource_type != SPIRVCross.spvc_resource_type.PushConstant).ToArray();

VkDescriptorSetLayoutBinding* layoutBinding = stackalloc VkDescriptorSetLayoutBinding[resources.Length];
bool is_array = resources.Where(x => x.is_array).Any();

bool is_array = resources.Where(x => x.is_array).Any();
bool is_bindless = NativeDevice.supports_descriptor_indexing();

for (int i = 0; i < resources.Length; i++)
Expand Down Expand Up @@ -190,11 +190,11 @@ private void CreateGraphicsPipeline(GraphicsPipelineDescription description)
{

List<ShaderBytecode> shaders = description.Shaders;
VkPipelineShaderStageCreateInfo* shaderStageCreateInfos = stackalloc VkPipelineShaderStageCreateInfo[shaders.Count];
VkPipelineShaderStageCreateInfo* shader_stage_infos = stackalloc VkPipelineShaderStageCreateInfo[shaders.Count];

for (int i = 0; i < shaders.Count; i++)
{
shaderStageCreateInfos[i] = new VkPipelineShaderStageCreateInfo
shader_stage_infos[i] = new VkPipelineShaderStageCreateInfo
{
sType = VkStructureType.PipelineShaderStageCreateInfo,
pNext = null,
Expand Down Expand Up @@ -238,7 +238,7 @@ private void CreateGraphicsPipeline(GraphicsPipelineDescription description)



VkPipelineVertexInputStateCreateInfo vertexInputStateCreate_info = new VkPipelineVertexInputStateCreateInfo()
VkPipelineVertexInputStateCreateInfo vertex_input_state_info = new VkPipelineVertexInputStateCreateInfo()
{
sType = VkStructureType.PipelineVertexInputStateCreateInfo,
pNext = null,
Expand Down Expand Up @@ -376,8 +376,8 @@ private void CreateGraphicsPipeline(GraphicsPipelineDescription description)
sType = VkStructureType.GraphicsPipelineCreateInfo,
pNext = null,
stageCount = (uint)shaders.Count,
pStages = shaderStageCreateInfos,
pVertexInputState = &vertexInputStateCreate_info,
pStages = shader_stage_infos,
pVertexInputState = &vertex_input_state_info,
pInputAssemblyState = &input_ass_state_info,
pRasterizationState = &rasterizer_state_info,
pMultisampleState = &multisampleState_info,
Expand All @@ -388,7 +388,7 @@ private void CreateGraphicsPipeline(GraphicsPipelineDescription description)
pDepthStencilState = &depthStencilState,
pDynamicState = &dynamicState,
//flags = VkPipelineCreateFlags.None
pViewportState = &vkPipelineViewportStateCreateInfo
pViewportState = &vkPipelineViewportStateCreateInfo,
};


Expand All @@ -400,9 +400,9 @@ private void CreateGraphicsPipeline(GraphicsPipelineDescription description)

for (int i = 0; i < shaders.Count; i++)
{
if (shaderStageCreateInfos[i].module != VkShaderModule.Null)
if (shader_stage_infos[i].module != VkShaderModule.Null)
{
vkDestroyShaderModule(NativeDevice.handle, shaderStageCreateInfos[i].module, null);
vkDestroyShaderModule(NativeDevice.handle, shader_stage_infos[i].module, null);
//shaderStageCreateInfos[i] = *(VkPipelineShaderStageCreateInfo*)null;
}
}
Expand Down
5 changes: 1 addition & 4 deletions Src/Vultaik/MappedResource.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright (c) 2019-2020 Faber Leonardo. All Rights Reserved. https://github.com/FaberSanZ
// Copyright (c) 2019-2021 Faber Leonardo. All Rights Reserved. https://github.com/FaberSanZ
// This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)

/*=============================================================================
MappedResource.cs
=============================================================================*/

using System;
using System.Collections.Generic;
Expand Down
2 changes: 1 addition & 1 deletion Src/Vultaik/SwapChain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public unsafe class SwapChain : GraphicsResource, IDisposable
internal VkImage[] images;
internal VkImageView[] swapChain_image_views;

internal bool vultaik_debug => AdapterConfig.VultaikDebug;
internal bool vultaik_debug => AdapterConfig.Debug;


public SwapChain(Device device, SwapchainDescription description) : base(device)
Expand Down

0 comments on commit f835c29

Please sign in to comment.