public void SetBufferData(BufferHandle buffer, int offset, ReadOnlySpan <byte> data)
 {
     BufferManager.SetData(buffer, offset, data, _pipeline.CurrentCommandBuffer, _pipeline.EndRenderPass);
 }
 public ReadOnlySpan <byte> GetBufferData(BufferHandle buffer, int offset, int size)
 {
     return(BufferManager.GetData(buffer, offset, size));
 }
 public BufferHandle CreateBuffer(int size)
 {
     return(BufferManager.CreateWithHandle(this, size));
 }
 public void DeleteBuffer(BufferHandle buffer)
 {
     BufferManager.Delete(buffer);
 }
        private void SetupContext(GraphicsDebugLevel logLevel, string[] requiredExtensions)
        {
            var api = Vk.GetApi();

            Api = api;

            _instance = VulkanInitialization.CreateInstance(api, logLevel, requiredExtensions, out ExtDebugReport debugReport, out _debugReportCallback);

            DebugReportApi = debugReport;

            if (api.TryGetInstanceExtension(_instance, out KhrSurface surfaceApi))
            {
                SurfaceApi = surfaceApi;
            }

            _surface        = GetSurface(_instance, api);
            _physicalDevice = VulkanInitialization.FindSuitablePhysicalDevice(api, _instance, _surface);

            FormatCapabilities = new FormatCapabilities(api, _physicalDevice);

            var queueFamilyIndex    = VulkanInitialization.FindSuitableQueueFamily(api, _physicalDevice, _surface, out uint maxQueueCount);
            var supportedExtensions = VulkanInitialization.GetSupportedExtensions(api, _physicalDevice);

            _device = VulkanInitialization.CreateDevice(api, _physicalDevice, queueFamilyIndex, supportedExtensions, maxQueueCount);

            Capabilities = new HardwareCapabilities(
                supportedExtensions.Contains(ExtConditionalRendering.ExtensionName),
                supportedExtensions.Contains(ExtExtendedDynamicState.ExtensionName));

            SupportsIndexTypeUint8    = supportedExtensions.Contains("VK_EXT_index_type_uint8");
            SupportsCustomBorderColor = supportedExtensions.Contains("VK_EXT_custom_border_color");

            if (api.TryGetDeviceExtension(_instance, _device, out KhrSwapchain swapchainApi))
            {
                SwapchainApi = swapchainApi;
            }

            if (api.TryGetDeviceExtension(_instance, _device, out ExtConditionalRendering conditionalRenderingApi))
            {
                ConditionalRenderingApi = conditionalRenderingApi;
            }

            if (api.TryGetDeviceExtension(_instance, _device, out ExtExtendedDynamicState extendedDynamicStateApi))
            {
                ExtendedDynamicStateApi = extendedDynamicStateApi;
            }

            if (api.TryGetDeviceExtension(_instance, _device, out ExtTransformFeedback transformFeedbackApi))
            {
                TransformFeedbackApi = transformFeedbackApi;
            }

            api.GetDeviceQueue(_device, queueFamilyIndex, 0, out var queue);
            Queue = queue;

            if (maxQueueCount >= 2)
            {
                api.GetDeviceQueue(_device, queueFamilyIndex, 1, out var backgroundQueue);
                BackgroundQueue     = backgroundQueue;
                BackgroundQueueLock = new object();
            }

            Api.GetPhysicalDeviceProperties(_physicalDevice, out var properties);

            MemoryAllocator = new MemoryAllocator(api, _device, properties.Limits.MaxMemoryAllocationCount);

            CommandBufferPool = VulkanInitialization.CreateCommandBufferPool(api, _device, queue, queueFamilyIndex);

            DescriptorSetManager = new DescriptorSetManager(_device);

            PipelineLayoutCache = new PipelineLayoutCache();

            BufferManager = new BufferManager(this, _physicalDevice, _device);

            _syncManager = new SyncManager(this, _device);
            _pipeline    = new PipelineFull(this, _device);

            Blit = new TextureBlit(this, _device);

            _counters = new Counters(this, _device, _pipeline);

            _window = new Window(this, _surface, _physicalDevice, _device);
        }