コード例 #1
0
        public void InitializeRenderer(RendererWindow WindowHandle, IPreferredGraphicsDeviceFilter myPreferencesForDevice = null)
        {
            Gl.Enable(EnableCap.Multisample);
            byte[]  ShaderData = null;
            Program myProgram  = new Program(_VertexSourceGL, _FragmentSourceGL);

            int linked;

            Gl.GetProgram(ProgramName, ProgramProperty.LinkStatus, out linked);
            if (linked == 0)
            {
                throw new Exception("Damn");
            }
            if ((LocationMVP = Gl.GetUniformLocation(ProgramName, "uMVP")) < 0)
            {
                throw new InvalidOperationException("no uniform uMVP");
            }

            // Get attributes locations
            if ((LocationPosition = Gl.GetAttribLocation(ProgramName, "aPosition")) < 0)
            {
                throw new InvalidOperationException("no attribute aPosition");
            }
            if ((LocationColor = Gl.GetAttribLocation(ProgramName, "aColor")) < 0)
            {
                throw new InvalidOperationException("no attribute aColor");
            }
            this.WindowHandle = WindowHandle;
            _VertexArray      = new VertexArray(myProgram, _ArrayPosition, _ArrayColor);
            Gl.Viewport(0, 0, WindowHandle.Width, WindowHandle.Height);

            Gl.ClearColor(Color.AliceBlue.R, Color.AliceBlue.G, Color.AliceBlue.B, Color.AliceBlue.A);
        }
コード例 #2
0
 public VulkanSupportedDevices(VulkanInstance myWindow, SurfaceKHR mySurface, IPreferredGraphicsDeviceFilter CustomGraphicFilter = null, IPreferredComputeDeviceFilter CustomComputeFilter = null)
 {
     if (CustomGraphicFilter != null)
     {
         GraphicsDevicePreferences = CustomGraphicFilter;
     }
     if (CustomComputeFilter != null)
     {
         ComputeDevicePreferences = CustomComputeFilter;
     }
     foreach (var A in myWindow.EnumeratePhysicalDevices())
     {
         VulkanPhysicalDevice myPhysicalDevice = (VulkanPhysicalDevice)A;
         myDevices.Add(new Support(A, GraphicsDevicePreferences.Score(A, mySurface), ComputeDevicePreferences.Score(A)));
     }
 }
コード例 #3
0
        public VulkanInitializer(String WindowName, RendererWindow WindowHandle, GraphicsSettings mySettings, IPreferredGraphicsDeviceFilter myGraphicsDeviceFilter = null, IPreferredComputeDeviceFilter myComputeDeviceFilter = null)
        {
            var Window       = new VulkanInstance(WindowName, WindowHandle.WindowHandle);
            var Surface      = new SurfaceKHR(Window);
            var myDeviceList = new VulkanSupportedDevices(Window, Surface, myGraphicsDeviceFilter, myComputeDeviceFilter);

            var SelectedPhysicalGraphicsDevice = myDeviceList.GetBestGraphicsDevice();
            var SelectedLogicalGraphicsDevice  = new VulkanLogicalDevice(SelectedPhysicalGraphicsDevice);

            DescriptorSetPoolManager myDescriptorPoolGraphicsManager;
            DescriptorSetPoolManager myDescriptorPoolComputeManager;

            Renderer.Vulkan.Queue myGraphicsQueue = null;
            Renderer.Vulkan.Queue myComputeQueue  = null;

            var SelectedPhysicalComputeDevice = myDeviceList.GetNextComputeDevice();
            VulkanLogicalDevice SelectedLogicalComputeDevice;

            if (myDeviceList.Count == 1)
            {
                //Compute and Renderer will share a device.
                SelectedLogicalComputeDevice    = new VulkanLogicalDevice(SelectedPhysicalGraphicsDevice);
                myDescriptorPoolGraphicsManager = new DescriptorSetPoolManager(SelectedLogicalGraphicsDevice);
                myDescriptorPoolComputeManager  = myDescriptorPoolGraphicsManager;
                myGraphicsQueue = SelectedLogicalGraphicsDevice.QueueManager.GetQueue(QueueFlags.Graphics);
                myComputeQueue  = SelectedLogicalGraphicsDevice.QueueManager.GetQueue(QueueFlags.Compute);
            }
            else
            {
                //TODO: iterate through queue to find next best device for compute
                SelectedLogicalComputeDevice    = new VulkanLogicalDevice(SelectedPhysicalComputeDevice);
                myDescriptorPoolGraphicsManager = new DescriptorSetPoolManager(SelectedLogicalGraphicsDevice);
                myDescriptorPoolComputeManager  = new DescriptorSetPoolManager(SelectedLogicalComputeDevice);
                myGraphicsQueue = SelectedLogicalGraphicsDevice.QueueManager.GetQueue(QueueFlags.Graphics);
                myComputeQueue  = SelectedLogicalComputeDevice.QueueManager.GetQueue(QueueFlags.Compute);
            }


            myLightingManager = new LightingManager();

            var Renderer = new VulkanRenderer(myLightingManager, Surface, Window, SelectedLogicalGraphicsDevice, myDescriptorPoolGraphicsManager, SelectedPhysicalGraphicsDevice, myGraphicsQueue, mySettings);
            var Compute  = new VulkanCompute(SelectedLogicalComputeDevice, myDescriptorPoolComputeManager, SelectedPhysicalComputeDevice, myComputeQueue);

            RenderingManager = Renderer;
            //Make sure they know about eachother's fences so they don't draw or do compute shaders at the same time!
            Renderer.SetComputeFence(Compute.GetFinishedFence());//Semaphore or fence?
            Compute.SetRendererFence(Renderer.GetFinshedFence());
            ComputeManager = Compute;
        }
コード例 #4
0
 public void InitializeRenderer(RendererWindow WindowHandle, IPreferredGraphicsDeviceFilter myPreferencesForDevice = null, bool Deferred = true)
 {
     throw new NotImplementedException();
 }