Пример #1
0
        internal PhysicalDevice GetPhysicalDevice(bool enableValidation)
        {
            if (enableValidation)
            {
                if (debugPhysicalDevice == PhysicalDevice.Null)
                {
                    debugPhysicalDevice = GraphicsAdapterFactory.GetInstance(true).NativeInstance.PhysicalDevices[adapterOrdinal];
                }

                return(debugPhysicalDevice);
            }
            else
            {
                return(defaultPhysicalDevice);
            }
        }
Пример #2
0
        private unsafe void CreateSurface()
        {
            // Check for Window Handle parameter
            if (Description.DeviceWindowHandle == null)
            {
                throw new ArgumentException("DeviceWindowHandle cannot be null");
            }
            // Create surface
#if SILICONSTUDIO_PLATFORM_WINDOWS
            var controlHandle = Description.DeviceWindowHandle.Handle;
            if (controlHandle == IntPtr.Zero)
            {
                throw new NotSupportedException($"Form of type [{Description.DeviceWindowHandle.GetType().Name}] is not supported. Only System.Windows.Control are supported");
            }

            var surfaceCreateInfo = new Win32SurfaceCreateInfo
            {
                StructureType = StructureType.Win32SurfaceCreateInfo,
#if !SILICONSTUDIO_RUNTIME_CORECLR
                InstanceHandle = Process.GetCurrentProcess().Handle,
#else
                // To implement for CoreCLR, currently passing a NULL pointer seems to work
                InstanceHandle = IntPtr.Zero,
#endif
                WindowHandle = controlHandle,
            };
            surface = GraphicsDevice.NativeInstance.CreateWin32Surface(surfaceCreateInfo);
#elif SILICONSTUDIO_PLATFORM_ANDROID
            throw new NotImplementedException();
#elif SILICONSTUDIO_PLATFORM_LINUX
#if SILICONSTUDIO_XENKO_UI_SDL
            var control = Description.DeviceWindowHandle.NativeWindow as SDL.Window;
            if (control == null)
            {
                throw new NotSupportedException("Non SDL Window used in SDL setup.");
            }

            if (GraphicsAdapterFactory.GetInstance(GraphicsDevice.IsDebugMode).HasXlibSurfaceSupport)
            {
                var createInfo = new XlibSurfaceCreateInfo
                {
                    StructureType = StructureType.XlibSurfaceCreateInfo,
                    Window        = checked ((uint)control.Handle), // On Linux, a Window identifier is 32-bit
                    Dpy           = control.Display,
                };
                surface = GraphicsDevice.NativeInstance.CreateXlibSurface(ref createInfo);
            }
            else
            {
                var createInfo = new XcbSurfaceCreateInfo()
                {
                    StructureType = StructureType.XcbSurfaceCreateInfo,
                    Window        = checked ((uint)control.Handle), // On Linux, a Window identifier is 32-bit
                    Connection    = control.XcbConnection,
                };
                surface = GraphicsDevice.NativeInstance.CreateXcbSurface(ref createInfo);
            }
#else
            throw new NotSupportedException("Only SDL is supported for the time being on Linux");
#endif
#else
            throw new NotSupportedException();
#endif
        }