Пример #1
0
        public void Render(RenderContext context, IPipeline pipeline, IViewport viewport, CommandList cl)
        {
            _buffer.Bind(cl, 0);

            if (pipeline.Type == PipelineType.TexturedModel)
            {
                _textureResource.BindTo(cl, 1);
                uint ci = 0;

                foreach (var bpi in _bodyPartIndices)
                {
                    const int model = 0;
                    for (var j = 0; j < bpi.Length; j++)
                    {
                        if (j == model)
                        {
                            cl.DrawIndexed(bpi[j], 1, ci, 0, 0);
                        }
                        ci += bpi[j];
                    }
                }
            }
            else if (pipeline.Type == PipelineType.WireframeModel)
            {
                cl.DrawIndexed(_numWireframeIndices, 1, _numTexturedIndices, 0, 0);
            }
        }
Пример #2
0
        private void DrawOffscreen()
        {
            _cl.SetFramebuffer(_offscreenFB);
            _cl.SetFullViewports();
            _cl.ClearColorTarget(0, RgbaFloat.Black);
            _cl.ClearDepthStencil(1f);

            _cl.SetPipeline(_offscreenPipeline);
            _cl.SetGraphicsResourceSet(0, _offscreenResourceSet);
            _cl.SetVertexBuffer(0, _dragonModel.VertexBuffer);
            _cl.SetIndexBuffer(_dragonModel.IndexBuffer, IndexFormat.UInt32);
            _cl.DrawIndexed(_dragonModel.IndexCount, 1, 0, 0, 0);
        }
        private unsafe void FlushVertexArray(VertexPosition3ColorTexture *vertexArray, int vertexIndex, Texture2D texture, View view, Sampler sampler, IntRect?scissorRect)
        {
            if (texture == null)
            {
                return;
            }

            var vrsd            = new ResourceSetDescription(viewResourceLayout, worldMatrixBuffer);
            var viewResourceSet = factory.CreateResourceSet(vrsd);

            var grsd = new ResourceSetDescription(graphicsResourceLayout, texture.TextureView, sampler ?? device.PointSampler);
            var graphicsResourceSet = factory.CreateResourceSet(grsd);

            //TODO: Depth buffer
            commandList.Begin();
            commandList.UpdateBuffer(vertexBuffer, 0, (IntPtr)vertexArray, (uint)vertexIndex * VERTEX_SIZE);
            commandList.SetFramebuffer(framebuffer);
            commandList.SetViewport(0, view.ScreenView);
            if (scissorRect.HasValue)
            {
                var sr = scissorRect.Value;
                commandList.SetScissorRect(0, (uint)sr.X, (uint)sr.Y, (uint)sr.Width, (uint)sr.Height);
            }
            commandList.SetPipeline(pipeline);
            commandList.SetGraphicsResourceSet(0, viewResourceSet);
            commandList.SetGraphicsResourceSet(1, graphicsResourceSet);
            commandList.SetIndexBuffer(indexBuffer, IndexFormat.UInt16);
            commandList.SetVertexBuffer(0, vertexBuffer);
            commandList.DrawIndexed((uint)(vertexIndex * 1.5));
            commandList.End();
            device.SubmitCommands(commandList);

            viewResourceSet.Dispose();
            graphicsResourceSet.Dispose();
        }
Пример #4
0
        public void Render(CommandList cl, IDistortionStageModel stage, GpuSurface target, ICameraModel2D camera)
        {
            cl.SetPipeline(_pipeline);
            cl.SetFramebuffer(target.Framebuffer);
            cl.ClearColorTarget(0, RgbaFloat.Clear);                          // HERE DIFFERENT TO STANDARD DRAW ONLY (FUTURE PULL OUT TO BASE?)
            cl.SetVertexBuffer(0, stage.Buffers.VertexBuffer);
            cl.SetIndexBuffer(stage.Buffers.IndexBuffer, IndexFormat.UInt32); //Extract format and type
            cl.SetGraphicsResourceSet(0, camera.ResourceSet);

            var batcher = stage.Batcher;

            for (var b = 0; b < batcher.NumberOfBatches; b++)
            {
                var batch = batcher.Pool[b];

                ResourceSet t0;
                if (batch.Texture0 == 0UL)
                {
                    t0 = _surfaceManager.SingleWhitePixel.ResourceSet_TexWrap;
                }
                else
                {
                    var retrieved = _surfaceManager.RetrieveSurface(batch.Texture0, new GpuSurfaceType[] { GpuSurfaceType.SwapChainOutput, GpuSurfaceType.Internal });

                    if (retrieved == target)
                    {
                        _frameworkMessenger.Report("Warning: A distortion stage is attempting to draw a surface onto itself. Aborting");
                        return;
                    }

                    t0 = retrieved == null ? _surfaceManager.SingleWhitePixel.ResourceSet_TexWrap :
                         batch.TextureMode0 == TextureCoordinateMode.Mirror ?
                         retrieved.ResourceSet_TexMirror : retrieved.ResourceSet_TexWrap;
                }
                cl.SetGraphicsResourceSet(1, t0);

                ResourceSet t1;
                if (batch.Texture1 == 0UL)
                {
                    t1 = _surfaceManager.SingleWhitePixel.ResourceSet_TexWrap;
                }
                else
                {
                    var retrieved = _surfaceManager.RetrieveSurface(batch.Texture1, new GpuSurfaceType[] { GpuSurfaceType.SwapChainOutput, GpuSurfaceType.Internal });

                    if (retrieved == target)
                    {
                        _frameworkMessenger.Report("Warning: A distortion stage is attempting to draw a surface onto itself. Aborting");
                        return;
                    }

                    t1 = retrieved == null ? _surfaceManager.SingleWhitePixel.ResourceSet_TexWrap :
                         batch.TextureMode1 == TextureCoordinateMode.Mirror ?
                         retrieved.ResourceSet_TexMirror : retrieved.ResourceSet_TexWrap;
                }
                cl.SetGraphicsResourceSet(2, t1);

                cl.DrawIndexed((uint)batch.NumIndices, 1, (uint)batch.StartIndex, 0, 0);
            }
        }
Пример #5
0
 public void Render(GraphicsDevice gd, CommandList cl)
 {
     cl.SetPipeline(_pipeline);
     cl.SetVertexBuffer(0, _vb);
     cl.SetIndexBuffer(_ib, IndexFormat.UInt16);
     cl.DrawIndexed(6, 1, 0, 0, 0);
 }
            public void Render(GraphicsDevice device, CommandList commandList, long elapsed)
            {
                commandList.Begin();

                commandList.SetPipeline(Pipeline);
                commandList.SetGraphicsResourceSet(0, ResourceSet);
                commandList.SetFramebuffer(FrameBuffer);

                // commandList.SetFullScissorRects();
                // commandList.SetFullViewports();

                commandList.ClearColorTarget(0, RgbaFloat.CornflowerBlue);

                commandList.SetVertexBuffer(0, VertexBuffer);
                commandList.SetIndexBuffer(IndexBuffer, IndexFormat.UInt16);

                commandList.DrawIndexed(
                    indexCount: 6,
                    instanceCount: 1,
                    indexStart: 0,
                    vertexOffset: 0,
                    instanceStart: 0);
                commandList.End();

                device.SubmitCommands(commandList);
            }
Пример #7
0
        private void RenderShader()
        {
            commandList.Begin();

            commandList.SetFramebuffer(swapchain.Framebuffer);
            commandList.ClearColorTarget(0, RgbaFloat.Black);

            if (isInitialized)
            {
                commandList.UpdateBuffer(runtimeDataBuffer, 0, runtimeData);
                commandList.SetPipeline(pipeline);
                commandList.SetGraphicsResourceSet(0, resourceSet);
                commandList.SetVertexBuffer(0, vertexBuffer);
                commandList.SetIndexBuffer(indexBuffer, IndexFormat.UInt32);

                commandList.DrawIndexed(
                    indexCount: 6,
                    instanceCount: 1,
                    indexStart: 0,
                    vertexOffset: 0,
                    instanceStart: 0);
            }
            commandList.End();

            graphicsDevice.SubmitCommands(commandList);
        }
Пример #8
0
        protected void Draw(float deltaSeconds)
        {
            _ticks += deltaSeconds * 1000f;
            _cl.Begin();

            //_cl.UpdateBuffer(_projectionBuffer, 0, Matrix4x4.CreatePerspectiveFieldOfView(
            //  1.0f,
///                (float)Window.Width / Window.Height,
            //0.5f,
            //100f));

            _cl.UpdateBuffer(_viewBuffer, 0, Matrix4x4.CreateLookAt(Vector3.UnitZ * 2.5f, Vector3.Zero, Vector3.UnitY));

            Matrix4x4 rotation =
                Matrix4x4.CreateFromAxisAngle(Vector3.UnitY, (_ticks / 1000f))
                * Matrix4x4.CreateFromAxisAngle(Vector3.UnitX, (_ticks / 3000f));

            _cl.UpdateBuffer(_worldBuffer, 0, ref rotation);

            //_cl.SetFramebuffer(MainSwapchain.Framebuffer);
            _cl.ClearColorTarget(0, RgbaFloat.Black);
            _cl.ClearDepthStencil(1f);
            _cl.SetPipeline(_pipeline);
            _cl.SetVertexBuffer(0, _vertexBuffer);
            _cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16);
            _cl.SetGraphicsResourceSet(0, _projViewSet);
            _cl.SetGraphicsResourceSet(1, _worldTextureSet);
            _cl.DrawIndexed(36, 1, 0, 0, 0);

            _cl.End();
            //VeldridGL.graphicsDevice.SubmitCommands(_cl);
            //VeldridGL.graphicsDevice.SwapBuffers(MainSwapchain);
            //VeldridGL.graphicsDevice.WaitForIdle();
        }
Пример #9
0
        private static void Draw()
        {
            ticks = ticks + 0.0001f;
            _commandList.Begin();

            _commandList.UpdateBuffer(_projectionBuffer, 0, Matrix4x4.CreatePerspectiveFieldOfView(
                                          1.0f,
                                          (float)Width / Height,
                                          0.5f,
                                          100f
                                          ));

            _commandList.UpdateBuffer(_viewBuffer, 0, Matrix4x4.CreateLookAt(Vector3.UnitZ * 2.5f, Vector3.Zero, Vector3.UnitY));

            Matrix4x4 rotation = Matrix4x4.CreateFromAxisAngle(Vector3.UnitY, ticks) * Matrix4x4.CreateFromAxisAngle(Vector3.UnitX, ticks);

            _commandList.UpdateBuffer(_worldBuffer, 0, ref rotation);

            _commandList.SetFramebuffer(_graphicsDevice.MainSwapchain.Framebuffer);
            _commandList.ClearColorTarget(0, RgbaFloat.Red);
            _commandList.ClearDepthStencil(1f);
            _commandList.SetPipeline(_pipeline);
            _commandList.SetVertexBuffer(0, _vertexBuffer);
            _commandList.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16);
            _commandList.SetGraphicsResourceSet(0, _projViewSet);
            _commandList.SetGraphicsResourceSet(1, _worldTextureSet);
            _commandList.DrawIndexed(36, 1, 0, 0, 0);

            _commandList.End();
            _graphicsDevice.SubmitCommands(_commandList);
            _graphicsDevice.SwapBuffers(_graphicsDevice.MainSwapchain);
            _graphicsDevice.WaitForIdle();
        }
Пример #10
0
        private static void Draw()
        {
            // Begin() must be called before commands can be issued.
            _commandList.Begin();

            // We want to render directly to the output window.
            _commandList.SetFramebuffer(_graphicsDevice.SwapchainFramebuffer);
            _commandList.ClearColorTarget(0, RgbaFloat.Black);

            // Set all relevant state to draw our quad.
            _commandList.SetVertexBuffer(0, _vertexBuffer);
            _commandList.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16);
            _commandList.SetPipeline(_pipeline);
            // Issue a Draw command for a single instance with 4 indices.
            _commandList.DrawIndexed(
                indexCount: 4,
                instanceCount: 1,
                indexStart: 0,
                vertexOffset: 0,
                instanceStart: 0);

            // End() must be called before commands can be submitted for execution.
            _commandList.End();
            _graphicsDevice.SubmitCommands(_commandList);

            // Once commands have been submitted, the rendered image can be presented to the application window.
            _graphicsDevice.SwapBuffers();
        }
Пример #11
0
        public void Draw(CommandList cmdList, Camera cam)
        {
            cmdList.SetVertexBuffer(0, m_vertexBuffer);
            cmdList.SetIndexBuffer(m_indexBuffer, IndexFormat.UInt32);
            cmdList.SetPipeline(m_pipelineState);

            SN.Matrix4x4 transform = WorldMatrix;

            for (int i = 0; i < m_meshesToDraw.Count; i++)
            {
                MeshDrawCall   drawParams = m_meshesToDraw[i];
                MeshPart       partData   = m_meshesData[drawParams.MeshPartIndex];
                SimpleMaterial material   = m_materials[partData.MaterialIndex];

                SN.Matrix4x4 w   = drawParams.World * transform;
                SN.Matrix4x4 wvp = w * cam.ViewProjection;

                cmdList.UpdateBuffer(m_wvpParam, 0, ref wvp);
                cmdList.UpdateBuffer(m_worldParam, 0, ref w);
                cmdList.UpdateBuffer(m_lightPosParam, 0, LightPosition);
                cmdList.UpdateBuffer(m_camPosParam, 0, cam.Position);

                cmdList.SetGraphicsResourceSet(0, m_worldLightCBSet);
                cmdList.SetGraphicsResourceSet(1, material.ColorAndTexture);

                cmdList.DrawIndexed((uint)partData.IndexCount, 1, (uint)partData.IndexOffset, 0, 0);
            }
        }
Пример #12
0
        private static void Draw()
        {
            _commandList.Begin();

            _commandList.SetFramebuffer(_graphicsDevice.SwapchainFramebuffer);

            _commandList.ClearColorTarget(0, RgbaFloat.CornflowerBlue);

            _commandList.SetVertexBuffer(0, _vertexBuffer);
            _commandList.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16);

            _commandList.SetPipeline(_pipeline);

            var redValue = Math.Sin((double)_stopWatch.ElapsedMilliseconds / 1000) / 2.0f + 0.5f;

            _shaderResourceManager.UpdateShaderResourceBuffer(_commandList, "MyColorBlock", new MyColorBlock {
                Color = new RgbaFloat((float)redValue, 0f, 0f, 1.0f)
            });

            _commandList.DrawIndexed(indexCount: 4, instanceCount: 1, indexStart: 0, vertexOffset: 0, instanceStart: 0);

            _commandList.End();

            _graphicsDevice.SubmitCommands(_commandList);
            _graphicsDevice.SwapBuffers();
        }
Пример #13
0
        /// <summary>
        /// Render Commands for Mesh of Type:
        /// <see cref="Henzai.Geometry.VertexPositionColor"/>
        /// Also used in ShadowMap PrePass
        ///</summary>
        private static void GenerateCommandsForMesh_Inline <T>(
            CommandList commandList,
            ModelRuntimeDescriptor <T> modelState,
            int meshIndex,
            SceneRuntimeDescriptor sceneRuntimeDescriptor,
            ResourceSet[] effectResourceSets,
            Mesh <T> mesh,
            uint modelInstanceCount) where T : struct, VertexLocateable
        {
            var effectIndex = 1;

            var vertexBuffer = modelState.VertexBuffers[meshIndex];
            var indexBuffer  = modelState.IndexBuffers[meshIndex];

            var cameraProjViewBuffer = sceneRuntimeDescriptor.CameraProjViewBuffer;
            var cameraResourceSet    = sceneRuntimeDescriptor.CameraResourceSet;

            commandList.SetVertexBuffer(0, vertexBuffer);
            commandList.SetIndexBuffer(indexBuffer, IndexFormat.UInt16);
            commandList.UpdateBuffer(cameraProjViewBuffer, 128, mesh.World);
            commandList.SetGraphicsResourceSet(0, cameraResourceSet);
            for (int i = 0; i < effectResourceSets.Length; i++)
            {
                var resourceSet      = effectResourceSets[i];
                var resourceSetIndex = effectIndex + i;
                commandList.SetGraphicsResourceSet((uint)resourceSetIndex, resourceSet);
            }
            commandList.DrawIndexed(
                indexCount: mesh.Indices.Length.ToUnsigned(),
                instanceCount: modelInstanceCount,
                indexStart: 0,
                vertexOffset: 0,
                instanceStart: 0
                );
        }
Пример #14
0
        public void Render(CommandList cl, ITextArray textArray)
        {
            cl.SetVertexBuffer(0, _vertexBuffer);
            cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16);
            cl.SetPipeline(_pipeline);
            cl.SetGraphicsResourceSet(0, _projectionTextureResourceSet);

            // draw characters
            for (uint row = 0; row < textArray.Height; ++row)
            {
                for (uint col = 0; col < textArray.Width; ++col)
                {
                    var c = textArray[col, row];
                    if (c == null || c.Char <= ' ')
                    {
                        continue;
                    }

                    cl.UpdateBuffer(_worldBuffer, 0,
                                    Matrix4x4.CreateTranslation(
                                        col, row, 0));

                    cl.UpdateBuffer(_colorBuffer, 0, c.ForeColor);

                    cl.DrawIndexed(
                        indexCount: 4,
                        instanceCount: 1,
                        indexStart: 0,
                        vertexOffset: c.Char * 4,
                        instanceStart: 0);
                }
            }
        }
Пример #15
0
        private void Draw()
        {
            int ticks = Environment.TickCount;

            _cl.Begin();

            _cl.UpdateBuffer(_projectionBuffer, 0, Matrix4x4.CreatePerspectiveFieldOfView(
                                 1.0f,
                                 (float)_window.Width / _window.Height,
                                 0.5f,
                                 100f));

            _cl.UpdateBuffer(_viewBuffer, 0, Matrix4x4.CreateLookAt(Vector3.UnitZ * 2.5f, Vector3.Zero, Vector3.UnitY));

            Matrix4x4 rotation =
                Matrix4x4.CreateFromAxisAngle(Vector3.UnitY, (ticks / 1000f))
                * Matrix4x4.CreateFromAxisAngle(Vector3.UnitX, (ticks / 3000f));

            _cl.UpdateBuffer(_worldBuffer, 0, ref rotation);

            _cl.SetFramebuffer(_gd.SwapchainFramebuffer);
            _cl.SetFullViewports();
            _cl.ClearColorTarget(0, RgbaFloat.Black);
            _cl.ClearDepthTarget(1f);
            _cl.SetPipeline(_pipeline);
            _cl.SetVertexBuffer(0, _vertexBuffer);
            _cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16);
            _cl.SetGraphicsResourceSet(0, _projViewSet);
            _cl.SetGraphicsResourceSet(1, _worldTextureSet);
            _cl.DrawIndexed(36, 1, 0, 0, 0);

            _cl.End();
            _gd.ExecuteCommands(_cl);
            _gd.SwapBuffers();
        }
Пример #16
0
        private void HandleRender(CommandList cl)
        {
            locationBuffer.Update(cl);
            camera.Update(cl);
            gridRenderer.Render(cl);
            if (geometryBuffers == null)
            {
                return;
            }

            geometryBuffers.SetBuffers(cl);
            foreach (var(subMesh, index) in geometryBuffers.SubMeshes.Indexed())
            {
                (materials[index] as IMaterial).Apply(cl);
                cl.DrawIndexed(
                    indexStart: (uint)subMesh.IndexOffset,
                    indexCount: (uint)subMesh.IndexCount,
                    instanceCount: 1,
                    vertexOffset: 0,
                    instanceStart: 0);
            }

            skeletonRenderer?.Render(cl);
            planeRenderer.Render(cl);
            triangleRenderer.Render(cl);
        }
Пример #17
0
        protected override void Draw(float deltaSeconds)
        {
            _cl.Begin();
            _ticks += deltaSeconds * 1000f;
            Vector4 shifts = new Vector4(
                _window.Width * MathF.Cos(_ticks / 500f),   // Red shift
                _window.Height * MathF.Sin(_ticks / 1250f), // Green shift
                MathF.Sin(_ticks / 1000f),                  // Blue shift
                0);                                         // Padding

            _cl.UpdateBuffer(_shiftBuffer, 0, ref shifts);

            _cl.SetPipeline(_computePipeline);
            _cl.SetComputeResourceSet(0, _computeResourceSet);
            _cl.Dispatch((uint)_window.Width, (uint)_window.Height, 1);

            _cl.SetFramebuffer(_gd.SwapchainFramebuffer);
            _cl.SetFullViewports();
            _cl.SetFullScissorRects();
            _cl.ClearColorTarget(0, RgbaFloat.Black);
            _cl.SetPipeline(_graphicsPipeline);
            _cl.SetVertexBuffer(0, _vertexBuffer);
            _cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16);
            _cl.SetGraphicsResourceSet(0, _graphicsResourceSet);
            _cl.DrawIndexed(6, 1, 0, 0, 0);

            _cl.End();
            _gd.SubmitCommands(_cl);
            _gd.SwapBuffers();
        }
Пример #18
0
 public override void Render(GraphicsDevice gd, CommandList cl, SceneContext sc, RenderPasses renderPass)
 {
     cl.SetVertexBuffer(0, _vb);
     cl.SetIndexBuffer(_ib, IndexFormat.UInt16);
     cl.SetPipeline(renderPass == RenderPasses.ReflectionMap ? _reflectionPipeline : _pipeline);
     cl.SetGraphicsResourceSet(0, _resourceSet);
     cl.DrawIndexed((uint)s_indices.Length, 1, 0, 0, 0);
 }
Пример #19
0
        public override void Render(CommandList commandList)
        {
            commandList.SetVertexBuffer(0, _vertexBuffer);

            commandList.SetIndexBuffer(_indexBuffer, IndexFormat.UInt16);

            commandList.DrawIndexed(_numIndices, 1, 0, 0, 0);
        }
Пример #20
0
 protected override void Draw(IPipeline pipeline, IViewport viewport, CommandList cl)
 {
     foreach (var ti in _textureIndices)
     {
         ti.Texture.BindTo(cl, 1);
         cl.DrawIndexed((uint)ti.Count, 1, (uint)ti.Offset, 0, 0);
     }
 }
Пример #21
0
 private void DrawMesh()
 {
     _cl.SetPipeline(_pipeline);
     _cl.SetGraphicsResourceSet(0, _rs);
     _cl.SetVertexBuffer(0, _vertexBuffer);
     _cl.SetIndexBuffer(_indexBuffer, IndexFormat.UInt32);
     _cl.DrawIndexed(_indexCount);
 }
Пример #22
0
 public void Render(GraphicsDevice gd, CommandList cl, GraphicsSystem sc, RenderPasses renderPass)
 {
     cl.SetPipeline(_pipeline);
     cl.SetGraphicsResourceSet(0, sc.MainSceneViewResourceSet);
     cl.SetVertexBuffer(0, _vb);
     cl.SetIndexBuffer(_ib, IndexFormat.UInt16);
     cl.DrawIndexed(6, 1, 0, 0, 0);
 }
Пример #23
0
 public void Render(GraphicsDevice gd, CommandList cl, SceneContext sc, RenderPasses renderPass, IRenderable r)
 {
     cl.SetPipeline(_pipeline);
     cl.SetGraphicsResourceSet(0, sc.DuplicatorTargetSet0);
     cl.SetVertexBuffer(0, _vb);
     cl.SetIndexBuffer(_ib, IndexFormat.UInt16);
     cl.DrawIndexed(6, 1, 0, 0, 0);
 }
Пример #24
0
 public void Render(GraphicsDevice gd, CommandList cl, GraphicsSystem sc, RenderPasses renderPass)
 {
     cl.SetPipeline(_pipeline);
     cl.SetGraphicsResourceSet(0, UseTintedTexture ? sc.DuplicatorTargetSet1 : sc.DuplicatorTargetSet0);
     cl.SetVertexBuffer(0, _vb);
     cl.SetIndexBuffer(_ib, IndexFormat.UInt16);
     cl.DrawIndexed(6, 1, 0, 0, 0);
 }
Пример #25
0
 public override void Render(GraphicsDevice gd, CommandList cl, SceneContext sc, RenderPasses renderPass)
 {
     cl.SetPipeline(_pipeline);
     cl.SetGraphicsResourceSet(0, _resourceSet);
     cl.SetVertexBuffer(0, _vb);
     cl.SetIndexBuffer(_ib, IndexFormat.UInt16);
     cl.DrawIndexed(6, 1, 0, 0, 0);
 }
Пример #26
0
        private int DoRenderPass(
            RenderContext context,
            CommandList commandList,
            RenderBucket bucket,
            BoundingFrustum cameraFrustum,
            ResourceSet cloudResourceSet)
        {
            // TODO: Make culling batch size configurable at runtime
            bucket.RenderItems.CullAndSort(cameraFrustum, ParallelCullingBatchSize);

            if (bucket.RenderItems.CulledItemIndices.Count == 0)
            {
                return(0);
            }

            Matrix4x4?lastWorld           = null;
            int?      lastRenderItemIndex = null;

            foreach (var i in bucket.RenderItems.CulledItemIndices)
            {
                ref var renderItem = ref bucket.RenderItems[i];

                if (lastRenderItemIndex == null || bucket.RenderItems[lastRenderItemIndex.Value].Pipeline != renderItem.Pipeline)
                {
                    commandList.InsertDebugMarker("Setting pipeline");
                    commandList.SetPipeline(renderItem.Pipeline);
                    SetGlobalResources(commandList, renderItem.ShaderSet.GlobalResourceSetIndices, cloudResourceSet);
                }

                if (renderItem.ShaderSet.GlobalResourceSetIndices.RenderItemConstants != null)
                {
                    if (lastWorld == null || lastWorld.Value != renderItem.World)
                    {
                        _renderItemConstantsBufferVS.Value.World = renderItem.World;
                        _renderItemConstantsBufferVS.Update(commandList);

                        lastWorld = renderItem.World;
                    }

                    if (renderItem.RenderItemConstantsPS != null)
                    {
                        _renderItemConstantsBufferPS.Value = renderItem.RenderItemConstantsPS.Value;
                        _renderItemConstantsBufferPS.Update(commandList);
                    }
                }

                renderItem.BeforeRenderCallback.Invoke(commandList, context);

                commandList.SetIndexBuffer(renderItem.IndexBuffer, IndexFormat.UInt16);
                commandList.DrawIndexed(
                    renderItem.IndexCount,
                    1,
                    renderItem.StartIndex,
                    0,
                    0);

                lastRenderItemIndex = i;
            }
Пример #27
0
 public void Draw(CommandList commandList)
 {
     commandList.SetPipeline(this.pipeline);
     commandList.SetVertexBuffer(0, this.vertexBuffer);
     commandList.SetIndexBuffer(this.indexBuffer, IndexFormat.UInt16);
     commandList.SetGraphicsResourceSet(0, this.projectionSet);
     commandList.SetGraphicsResourceSet(1, this.textureSet);
     commandList.DrawIndexed(6, 1, 0, 0, 0);
 }
Пример #28
0
 private void RenderShadowMap(CommandList cl, GraphicsSystem sc, int shadowMapIndex)
 {
     cl.SetVertexBuffer(0, _vb);
     cl.SetIndexBuffer(_ib, IndexFormat.UInt16);
     cl.SetPipeline(_shadowMapPipeline);
     cl.SetGraphicsResourceSet(0, _shadowMapResourceSets[shadowMapIndex * 2]);
     cl.SetGraphicsResourceSet(1, _shadowMapResourceSets[shadowMapIndex * 2 + 1]);
     cl.DrawIndexed((uint)_indexCount, 1, 0, 0, 0);
 }
Пример #29
0
 public override void Draw(CommandList commandList)
 {
     commandList.DrawIndexed(
         indexCount:    _indexCount,
         instanceCount: _instanceCount,
         indexStart:    _indexStart,
         vertexOffset:  _vertexOffset,
         instanceStart: _instanceStart);
 }
Пример #30
0
 public void DrawIndexed(CommandList cmdList, int startIndex, int indexCount)
 {
     cmdList.DrawIndexed(
         indexCount: (uint)indexCount,
         instanceCount: 1,
         indexStart: (uint)startIndex,
         vertexOffset: 0,
         instanceStart: 0);
 }