public void Render() { if (DualityApp.GraphicsBackend == null) { return; } // Prepare forwarding the collected data and parameters to the graphics backend this.UploadVertexData(); this.AggregateBatches(); this.UpdateBuiltinShaderParameters(); bool overlayMode = (this.projection == ProjectionMode.Screen); this.renderOptions.ClearFlags = this.clearFlags; this.renderOptions.ClearColor = this.clearColor; this.renderOptions.ClearDepth = this.clearDepth; this.renderOptions.Viewport = this.viewportRect; this.renderOptions.ViewMatrix = this.matView; this.renderOptions.ProjectionMatrix = this.matProjection; this.renderOptions.DepthTest = !overlayMode; this.renderOptions.DepthWrite = !overlayMode; this.renderOptions.Target = this.renderTarget.IsAvailable ? this.renderTarget.Res.Native : null; this.renderOptions.ShaderParameters = this.shaderParameters; this.renderStats.Reset(); // Invoke graphics backend functionality to do the rendering DualityApp.GraphicsBackend.BeginRendering(this, this.renderOptions, this.renderStats); { //Profile.TimeProcessDrawcalls.BeginMeasure(); // Sorted as needed by batch optimizer DualityApp.GraphicsBackend.Render(this.batchBufferSolid); // Z-Sorted, back to Front DualityApp.GraphicsBackend.Render(this.batchBufferBlended); //Profile.TimeProcessDrawcalls.EndMeasure(); } DualityApp.GraphicsBackend.EndRendering(); //Profile.StatNumDrawcalls.Add(this.renderStats.DrawCalls); // Reset all temp materials and return them to the pool for (int i = 0; i < this.tempMaterialIndex; i++) { this.tempMaterialPool[i].Technique = DrawTechnique.Mask; this.tempMaterialPool[i].Reset(); } this.tempMaterialIndex = 0; // Clear all working buffers for vertex and drawcall processing this.drawBuffer.Clear(); this.sortBufferSolid.Clear(); this.sortBufferBlended.Clear(); this.sortBufferTemp.Clear(); this.batchBufferSolid.Clear(); this.batchBufferBlended.Clear(); this.drawVertices.Clear(); this.batchIndexPool.Reset(); }
/// <summary> /// Initializes this <see cref="BatchInfo"/> instance to match the specified /// target instance exactly, e.g. use the same <see cref="Technique"/> and /// specify the same shader parameter values. /// </summary> public void InitFrom(BatchInfo source) { this.Reset(); this.technique = source.technique; if (source.parameters != null) { if (this.parameters == null) { this.parameters = new ShaderParameterCollection(source.parameters); } else { source.parameters.CopyTo(this.parameters); } } }
/// <summary> /// Creates a new, empty BatchInfo. /// </summary> public BatchInfo() { this.parameters = new ShaderParameterCollection(); }
/// <summary> /// Assigns all shader variables in batch. /// </summary> /// <param name="variables"></param> /// <seealso cref="ShaderParameterCollection.CopyTo"/> public void SetVariables(ShaderParameterCollection variables) { variables.CopyTo(this.parameters); }