예제 #1
0
        internal GraphicsDevice(Core core, bool validation)
        {
            if (!Glfw.VulkanSupported())
            {
                throw new PlatformNotSupportedException("The Vulkan runtime is not available on this platform");
            }
            Core = core;

            // Create the instance and select the device to use
            InitializeVulkanInstance(validation, out VkInstanceInfo, out VkDebugUtils, out VkDeviceInfo, out Features);
            VkInstance       = VkInstanceInfo.Instance;
            VkPhysicalDevice = VkDeviceInfo.PhysicalDevice;
            LINFO($"Selected device '{VkDeviceInfo.DeviceName}'");

            // Create the device and queue objects
            CreateVulkanDevice(VkDeviceInfo, Features, out VkDevice, out var graphicsQueue, out var graphicsQueueIndex);
            GraphicsQueue = new(this, graphicsQueue, graphicsQueueIndex);
            LINFO("Created Vulkan device instance");
            Limits = new(VkDeviceInfo);

            // Create the memory manager
            Memory = new(this);

            // Create the global binding table for the device
            BindingTable = new(this);

            // Prepare resources
            SamplerPool.Initialize(this);
            Resources = new(this);
        }
예제 #2
0
        private void dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                if (disposing)
                {
                    VkDevice.DeviceWaitIdle();

                    Resources.UnregisterThread();
                    Resources.Dispose();
                    SamplerPool.Terminate();

                    BindingTable.Dispose();

                    Memory.Dispose();

                    GraphicsQueue.Dispose();

                    VkDevice.DestroyDevice(null);
                    LINFO("Destroyed Vulkan device");
                    VkDebugUtils?.DestroyDebugUtilsMessengerEXT(null);
                    VkInstance.DestroyInstance(null);
                    LINFO("Destroyed Vulkan instance");
                }
            }
            IsDisposed = true;
        }