/// <summary> /// Initializes a new instance of the <see cref="GraphicsAdapter" /> class. /// </summary> /// <param name="physicalDevice">The default factory.</param> /// <param name="adapterOrdinal">The adapter ordinal.</param> internal GraphicsAdapter(PhysicalDevice defaultPhysicalDevice, int adapterOrdinal) { this.adapterOrdinal = adapterOrdinal; this.defaultPhysicalDevice = defaultPhysicalDevice; defaultPhysicalDevice.GetProperties(out properties); // TODO VULKAN //var displayProperties = physicalDevice.DisplayProperties; //outputs = new GraphicsOutput[displayProperties.Length]; //for (var i = 0; i < outputs.Length; i++) // outputs[i] = new GraphicsOutput(this, displayProperties[i], i).DisposeBy(this); outputs = new[] { new GraphicsOutput() }; }
internal static unsafe extern void vkGetPhysicalDeviceSparseImageFormatProperties(PhysicalDevice physicalDevice, Format format, ImageType type, SampleCountFlags samples, ImageUsageFlags usage, ImageTiling tiling, uint* propertyCount, SparseImageFormatProperties* properties);
internal static unsafe extern void vkGetPhysicalDeviceQueueFamilyProperties(PhysicalDevice physicalDevice, uint* queueFamilyPropertyCount, QueueFamilyProperties* queueFamilyProperties);
internal unsafe void EnumeratePhysicalDevices(ref uint physicalDeviceCount, PhysicalDevice* physicalDevices) { fixed (uint* __physicalDeviceCount__ = &physicalDeviceCount) { vkEnumeratePhysicalDevices(this, __physicalDeviceCount__, physicalDevices).CheckError(); } }
internal PhysicalDevice GetPhysicalDevice(bool enableValidation) { if (enableValidation) { if (debugPhysicalDevice == PhysicalDevice.Null) { debugPhysicalDevice = GraphicsAdapterFactory.GetInstance(true).NativeInstance.PhysicalDevices[adapterOrdinal]; } return debugPhysicalDevice; } else { return defaultPhysicalDevice; } }
internal static unsafe extern RawBool vkGetPhysicalDeviceXlibPresentationSupportKHR(PhysicalDevice physicalDevice, uint queueFamilyIndex, IntPtr dpy, uint visualId);
internal static unsafe extern RawBool vkGetPhysicalDeviceWin32PresentationSupportKHR(PhysicalDevice physicalDevice, uint queueFamilyIndex);
internal static unsafe extern Result vkGetPhysicalDeviceSurfacePresentModesKHR(PhysicalDevice physicalDevice, Surface surface, uint* presentModeCount, PresentMode* presentModes);
internal static unsafe extern Result vkGetDisplayPlaneSupportedDisplaysKHR(PhysicalDevice physicalDevice, uint planeIndex, uint* displayCount, Display* displays);
internal static unsafe extern Result vkGetDisplayPlaneCapabilitiesKHR(PhysicalDevice physicalDevice, DisplayMode mode, uint planeIndex, DisplayPlaneCapabilities* capabilities);
internal static unsafe extern Result vkEnumerateDeviceLayerProperties(PhysicalDevice physicalDevice, uint* propertyCount, LayerProperties* properties);
internal static unsafe extern Result vkEnumerateDeviceExtensionProperties(PhysicalDevice physicalDevice, byte* layerName, uint* propertyCount, ExtensionProperties* properties);
internal static unsafe extern Result vkCreateDisplayModeKHR(PhysicalDevice physicalDevice, Display display, DisplayModeCreateInfo* createInfo, AllocationCallbacks* allocator, DisplayMode* mode);
internal static unsafe extern Result vkCreateDevice(PhysicalDevice physicalDevice, DeviceCreateInfo* createInfo, AllocationCallbacks* allocator, Device* device);
internal static unsafe extern Result vkGetPhysicalDeviceSurfaceCapabilitiesKHR(PhysicalDevice physicalDevice, Surface surface, SurfaceCapabilities* surfaceCapabilities);
internal static unsafe extern Result vkGetPhysicalDeviceSurfaceFormatsKHR(PhysicalDevice physicalDevice, Surface surface, uint* surfaceFormatCount, SurfaceFormat* surfaceFormats);
internal static unsafe extern Result vkGetPhysicalDeviceDisplayPropertiesKHR(PhysicalDevice physicalDevice, uint* propertyCount, DisplayProperties* properties);
internal static unsafe extern Result vkGetPhysicalDeviceSurfaceSupportKHR(PhysicalDevice physicalDevice, uint queueFamilyIndex, Surface surface, RawBool* supported);
internal static unsafe extern void vkGetPhysicalDeviceFeatures(PhysicalDevice physicalDevice, PhysicalDeviceFeatures* features);
internal static unsafe extern RawBool vkGetPhysicalDeviceXcbPresentationSupportKHR(PhysicalDevice physicalDevice, uint queueFamilyIndex, IntPtr connection, uint visualid);
internal static unsafe extern void vkGetPhysicalDeviceFormatProperties(PhysicalDevice physicalDevice, Format format, FormatProperties* formatProperties);
protected virtual void CreateInstance() { var applicationInfo = new ApplicationInfo { StructureType = StructureType.ApplicationInfo, EngineVersion = 0, ApiVersion = Vulkan.ApiVersion }; var enabledLayerNames = new [] { Marshal.StringToHGlobalAnsi("VK_LAYER_LUNARG_standard_validation"), }; var enabledExtensionNames = new [] { Marshal.StringToHGlobalAnsi("VK_KHR_surface"), Marshal.StringToHGlobalAnsi("VK_KHR_win32_surface"), Marshal.StringToHGlobalAnsi("VK_EXT_debug_report"), }; try { fixed (void* enabledLayerNamesPointer = &enabledLayerNames[0]) fixed (void* enabledExtensionNamesPointer = &enabledExtensionNames[0]) { var instanceCreateInfo = new InstanceCreateInfo { StructureType = StructureType.InstanceCreateInfo, ApplicationInfo = new IntPtr(&applicationInfo), EnabledExtensionCount = (uint)enabledExtensionNames.Length, EnabledExtensionNames = new IntPtr(enabledExtensionNamesPointer), }; if (validate) { instanceCreateInfo.EnabledLayerCount = (uint)enabledLayerNames.Length; instanceCreateInfo.EnabledLayerNames = new IntPtr(enabledLayerNamesPointer); } instance = Vulkan.CreateInstance(ref instanceCreateInfo); } if (validate) { var createDebugReportCallbackName = Encoding.ASCII.GetBytes("vkCreateDebugReportCallbackEXT"); fixed (byte* createDebugReportCallbackNamePointer = &createDebugReportCallbackName[0]) { var createDebugReportCallback = Marshal.GetDelegateForFunctionPointer<CreateDebugReportCallbackDelegate>(instance.GetProcAddress(createDebugReportCallbackNamePointer)); debugReport = DebugReport; var createInfo = new DebugReportCallbackCreateInfo { StructureType = StructureType.DebugReportCallbackCreateInfo, Flags = (uint)(DebugReportFlags.Error | DebugReportFlags.Warning | DebugReportFlags.PerformanceWarning), Callback = Marshal.GetFunctionPointerForDelegate(debugReport) }; createDebugReportCallback(instance, ref createInfo, null, out debugReportCallback); } } } finally { foreach (var enabledExtensionName in enabledExtensionNames) Marshal.FreeHGlobal(enabledExtensionName); foreach (var enabledLayerName in enabledLayerNames) Marshal.FreeHGlobal(enabledLayerName); } physicalDevice = instance.PhysicalDevices[0]; var props = physicalDevice.QueueFamilyProperties; }
internal static unsafe extern Result vkGetPhysicalDeviceImageFormatProperties(PhysicalDevice physicalDevice, Format format, ImageType type, ImageTiling tiling, ImageUsageFlags usage, ImageCreateFlags flags, ImageFormatProperties* imageFormatProperties);
internal static unsafe extern void vkGetPhysicalDeviceProperties(PhysicalDevice physicalDevice, PhysicalDeviceProperties* properties);
internal static unsafe extern Result vkEnumeratePhysicalDevices(Instance instance, uint* physicalDeviceCount, PhysicalDevice* physicalDevices);