コード例 #1
0
        private void CreateInstance()
        {
            var enabledLayers = new List <string>();

            if (Instance.EnumerateLayerProperties().Any(x => x.LayerName == "VK_LAYER_LUNARG_standard_validation"))
            {
                enabledLayers.Add("VK_LAYER_LUNARG_standard_validation");
            }

            var glfwExtensions = Glfw3.glfwGetRequiredInstanceExtensions();

            this.instance = Instance.Create(new InstanceCreateInfo
            {
                ApplicationInfo = new ApplicationInfo
                {
                    ApplicationName    = "SharpVk Test Harness",
                    ApplicationVersion = Constants.SharpVkVersion,
                    EngineName         = "SharpVk",
                    EngineVersion      = Constants.SharpVkVersion,
                    ApiVersion         = Constants.ApiVersion10
                },
                EnabledExtensionNames = glfwExtensions.Concat(new[] { ExtDebugReport.ExtensionName }).ToArray(),
                EnabledLayerNames     = enabledLayers.ToArray()
            }, null);

            this.debugCallback = this.instance.CreateDebugReportCallback(new DebugReportCallbackCreateInfo
            {
                Flags       = DebugReportFlags.Error | DebugReportFlags.Warning | DebugReportFlags.PerformanceWarning,
                PfnCallback = DebugReportDelegate
            });
        }
コード例 #2
0
ファイル: Instance.cs プロジェクト: yongweisun/SharpVk
 /// <summary>
 /// Create a debug report callback object.
 /// </summary>
 public DebugReportCallback CreateDebugReportCallback(DebugReportCallbackCreateInfo createInfo)
 {
     unsafe
     {
         try
         {
             var commandDelegate        = this.commandCache.GetCommandDelegate <Interop.vkCreateDebugReportCallbackEXT>("vkCreateDebugReportCallbackEXT", "instance");
             DebugReportCallback result = default(DebugReportCallback);
             Result commandResult;
             Interop.DebugReportCallbackCreateInfo marshalledCreateInfo;
             createInfo.MarshalTo(&marshalledCreateInfo);
             Interop.AllocationCallbacks marshalledAllocator;
             this.allocator?.MarshalTo(&marshalledAllocator);
             Interop.DebugReportCallback marshalledCallback;
             commandResult = commandDelegate(this.handle, &marshalledCreateInfo, this.allocator == null ? null : &marshalledAllocator, &marshalledCallback);
             if (SharpVkException.IsError(commandResult))
             {
                 throw SharpVkException.Create(commandResult);
             }
             result = new DebugReportCallback(marshalledCallback, this, this.commandCache);
             return(result);
         }
         finally
         {
             Interop.HeapUtil.FreeLog();
         }
     }
 }
コード例 #3
0
        private void TearDown()
        {
            device.WaitIdle();

            this.renderFinishedSemaphore.Dispose();
            this.renderFinishedSemaphore = null;

            this.imageAvailableSemaphore.Dispose();
            this.imageAvailableSemaphore = null;

            this.descriptorPool.Dispose();
            this.descriptorPool = null;
            this.descriptorSet  = null;

            this.device.FreeMemory(this.uniformBufferMemory);
            this.uniformBufferMemory = null;

            this.uniformBuffer.Dispose();
            this.uniformBuffer = null;

            this.device.FreeMemory(this.uniformStagingBufferMemory);
            this.uniformStagingBufferMemory = null;

            this.uniformStagingBuffer.Dispose();
            this.uniformStagingBuffer = null;

            this.device.FreeMemory(this.indexBufferMemory);
            this.indexBufferMemory = null;

            this.indexBuffer.Dispose();
            this.indexBuffer = null;

            this.device.FreeMemory(this.vertexBufferMemory);
            this.vertexBufferMemory = null;

            this.vertexBuffer.Dispose();
            this.vertexBuffer = null;

            this.commandPool.Dispose();
            this.commandPool    = null;
            this.commandBuffers = null;
            this.transientCommandPool.Dispose();
            this.transientCommandPool = null;

            foreach (var frameBuffer in this.frameBuffers)
            {
                frameBuffer.Dispose();
            }
            this.frameBuffers = null;

            this.pipeline.Dispose();
            this.pipeline = null;

            this.pipelineLayout.Dispose();
            this.pipelineLayout = null;

            foreach (var imageView in this.swapChainImageViews)
            {
                imageView.Dispose();
            }
            this.swapChainImageViews = null;

            this.descriptorSetLayout.Dispose();
            this.descriptorSetLayout = null;

            this.renderPass.Dispose();
            this.renderPass = null;

            this.swapChain.Dispose();
            this.swapChain = null;

            this.device.Dispose();
            this.device = null;

            this.surface.Dispose();
            this.surface = null;

            this.debugCallback.Dispose();
            this.debugCallback = null;

            this.instance.Dispose();
            this.instance = null;
        }