Ejemplo n.º 1
0
        public void BindSparse()
        {
            var bindSparseInfo = new BindSparseInfo(null, null, null, null, null);

            GraphicsQueue.BindSparse(bindSparseInfo);
            GraphicsQueue.BindSparse(new[] { bindSparseInfo });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Block until this device has idled on all queues
        /// </summary>
        public void Idle()
        {
            var graphics = GraphicsQueue.GetSynchronizerForIdle();
            var compute  = ComputeQueue.GetSynchronizerForIdle();
            var copy     = CopyQueue.GetSynchronizerForIdle();

            if (DeviceLevel >= SupportedDevice.Device1)
            {
                var fences      = stackalloc ID3D12Fence *[3];
                var fenceValues = stackalloc ulong[3];

                graphics.GetFenceAndMarker(out fences[0], out fenceValues[0]);
                compute.GetFenceAndMarker(out fences[1], out fenceValues[1]);
                copy.GetFenceAndMarker(out fences[2], out fenceValues[2]);

                ThrowIfFailed(As <ID3D12Device1>()->SetEventOnMultipleFenceCompletion(
                                  fences,
                                  fenceValues,
                                  3,
                                  D3D12_MULTIPLE_FENCE_WAIT_FLAGS.D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL,
                                  default
                                  ));
            }
            else
            {
                BetterDeviceNeeded();
            }
        }
 /// <summary>
 /// Create a GPU-accelerated compositor
 /// </summary>
 /// <param name="width">Composite width</param>
 /// <param name="height">Composite height</param>
 public RenderCompositor(int width, int height)
 {
     // Create the material
     material = new Material(Shader.Find("Hidden/RenderCompositor"));
     // Create the graphic command queue
     commandQueue = new GraphicsQueue();
     // Create the layers collection
     layers = new Layers();
     // Create the composite // Antialiasing please ;)
     composite = RenderTexture.GetTemporary(width, height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Default, 8);
     // Clear it
     commandQueue.Enqueue(() => {
         Graphics.SetRenderTarget(composite);
         GL.Clear(true, true, Color.black);
     });
 }
Ejemplo n.º 4
0
        public void EndRender()
        {
            Profiler.BeginSample("Present");

            Swapchain.QueuePresent(GraphicsQueue, (uint)renderFrame.imageIndex, renderFrame.renderSemaphore);

            GraphicsQueue.Submit(null, renderFrame.presentFence);

            GraphicsQueue.WaitIdle();

            foreach (var action in renderFrame.postActions)
            {
                action.Invoke();
            }

            Profiler.EndSample();
        }
Ejemplo n.º 5
0
        public void GetResults()
        {
            using (var cmdPool = Device.CreateCommandPool(new CommandPoolCreateInfo(GraphicsQueue.FamilyIndex)))
                using (var cmdBuffer = cmdPool.AllocateBuffers(new CommandBufferAllocateInfo(CommandBufferLevel.Primary, 1))[0])
                    using (var queryPool = Device.CreateQueryPool(new QueryPoolCreateInfo(QueryType.Occlusion, 1)))
                    {
                        cmdBuffer.Begin();
                        cmdBuffer.CmdBeginQuery(queryPool, 0);
                        cmdBuffer.CmdEndQuery(queryPool, 0);
                        cmdBuffer.End();

                        GraphicsQueue.Submit(new SubmitInfo(commandBuffers: new[] { cmdBuffer }));
                        Device.WaitIdle();

                        const int size    = 1024;
                        byte *    pointer = stackalloc byte[size];
                        queryPool.GetResults(0, 1, size, new IntPtr(pointer), size);
                    }
        }
Ejemplo n.º 6
0
 public void Submit()
 {
     GraphicsQueue.Submit(null, 0, null, null);
     GraphicsQueue.Submit(new SubmitInfo());
     GraphicsQueue.Submit(new[] { new SubmitInfo() });
 }
Ejemplo n.º 7
0
 public void WaitIdle()
 {
     GraphicsQueue.WaitIdle();
 }
        public void RenderEnd()
        {
            GeometryPass.ExecutePass(GBufferPrimaryCommandBuffer);
            foreach (SubPass A in mySubpasses)
            {
                A.ExecutePass(GBufferPrimaryCommandBuffer);
            }
            GBufferPrimaryCommandBuffer.CmdEndRenderPass();
            GBufferPrimaryCommandBuffer.End();


            var submitInfo = new SubmitInfo //TODO: Move to Graphics queue
            {
                WaitSemaphores     = new Semaphore[] { mySwapchain.SwapchainDrawCompleteSemaphore },
                WaitDstStageMask   = new PipelineStageFlags[] { PipelineStageFlags.AllGraphics },
                CommandBufferCount = (uint)1,
                CommandBuffers     = new CommandBuffer[] { GBufferPrimaryCommandBuffer },
                SignalSemaphores   = new Semaphore[] { OffscreenRenderFinishedSemaphore } //TODO: create this semaphore
            };

            GraphicsQueue.Submit(submitInfo);



            /* Draws the G-buffer to the screen quad*/



            RendererFinalCompositionBuffer.CmdDebugMarkerBeginEXT(EndOFDeferred);
            RendererFinalCompositionBuffer.CmdBeginRenderPass(this.activeSwapChain, SubpassContents.Inline);
            RendererFinalCompositionBuffer.CmdBindPipeline(PipelineBindPoint.Graphics, this.DeferredRendererOutputPipe);
            RendererFinalCompositionBuffer.CmdBindDescriptorSets(PipelineBindPoint.Graphics, this.DeferredRendererOutputPipeLayout, 0, myDeferredRendererDescriptorSet.myDSet, null);
            RendererFinalCompositionBuffer.CmdBindIndexBuffer(this.myScreenQuadIndexBuffer, this.myScreenQuadIndexBuffer.SizeOfBuffer, IndexType.Uint32);
            RendererFinalCompositionBuffer.CmdBindVertexBuffer(0, this.myScreenQuadVertexBuffer, this.myScreenQuadIndexBuffer.SizeOfBuffer);
            RendererFinalCompositionBuffer.CmdDrawIndexed(this.myScreenQuadIndexBuffer.Count, 1, 0, 0, 0);
            RendererFinalCompositionBuffer.CmdEndRenderPass();
            RendererFinalCompositionBuffer.CmdDebugMarkerEndEXT();
            RendererFinalCompositionBuffer.End();


            var submitInfo1 = new SubmitInfo //TODO: Move to Graphics queue
            {
                WaitSemaphores     = new Semaphore[] { OffscreenRenderFinishedSemaphore },
                WaitDstStageMask   = new PipelineStageFlags[] { PipelineStageFlags.AllGraphics },
                CommandBufferCount = (uint)1,
                CommandBuffers     = new CommandBuffer[] { RendererFinalCompositionBuffer },
            };

            GraphicsQueue.Submit(submitInfo1, DrawingFence);

            submitInfo.Dispose();
            submitInfo1.Dispose();//TODO: Verify this is a good thing or not.
            //TODO: RenderTarget Processing.
            try
            {
                GraphicsQueue.PresentKHR(mySwapchain.SwapChainPresentInfo);
            }
            catch (VULKAN_ERROR_OUT_OF_DATE_KHR E)
            {
                RebuildSwapChain();
            }
            catch (VULKAN_ERROR_SUBOPTIMAL_KHR E)
            {
                RebuildSwapChain();
            }
            mySwapchain.SwapBuffer();
        }