From f459c633803150129226f9ae12f84287d2a5be89 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 15 Jan 2015 23:37:17 +0000 Subject: [PATCH] Show restart index on GL pipe state, and handle it being disabled --- renderdoc/api/replay/gl_pipestate.h | 2 + renderdoc/driver/gl/gl_replay.cpp | 3 ++ renderdocui/Code/CommonPipelineState.cs | 41 +++++++++++++++++++ renderdocui/Interop/GLPipelineState.cs | 2 + renderdocui/Windows/BufferViewer.cs | 16 +++++--- .../GLPipelineStateViewer.Designer.cs | 20 +++++++-- .../PipelineState/GLPipelineStateViewer.cs | 12 ++++++ 7 files changed, 87 insertions(+), 9 deletions(-) diff --git a/renderdoc/api/replay/gl_pipestate.h b/renderdoc/api/replay/gl_pipestate.h index 3fd6d07f4..0f0f78675 100644 --- a/renderdoc/api/replay/gl_pipestate.h +++ b/renderdoc/api/replay/gl_pipestate.h @@ -54,6 +54,8 @@ struct GLPipelineState rdctype::array vbuffers; ResourceId ibuffer; + bool32 primitiveRestart; + uint32_t restartIndex; } m_VtxIn; struct ShaderStage diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 96f1dc114..4fe361e91 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -864,6 +864,9 @@ void GLReplay::SavePipelineState() gl.glGetIntegerv(eGL_ELEMENT_ARRAY_BUFFER_BINDING, (GLint*)&ibuffer); pipe.m_VtxIn.ibuffer = rm->GetOriginalID(rm->GetID(BufferRes(ctx, ibuffer))); + pipe.m_VtxIn.primitiveRestart = rs.Enabled[GLRenderState::eEnabled_PrimitiveRestart]; + pipe.m_VtxIn.restartIndex = rs.Enabled[GLRenderState::eEnabled_PrimitiveRestartFixedIndex] ? ~0U : rs.PrimitiveRestartIndex; + // Vertex buffers and attributes GLint numVBufferBindings = 16; gl.glGetIntegerv(eGL_MAX_VERTEX_ATTRIB_BINDINGS, &numVBufferBindings); diff --git a/renderdocui/Code/CommonPipelineState.cs b/renderdocui/Code/CommonPipelineState.cs index 0a5364564..ff19f84bd 100644 --- a/renderdocui/Code/CommonPipelineState.cs +++ b/renderdocui/Code/CommonPipelineState.cs @@ -248,6 +248,47 @@ namespace renderdocui.Code ByteOffset = 0; } + public bool IsStripRestartEnabled() + { + if (LogLoaded) + { + if (IsLogD3D11) + { + // D3D11 this is always enabled + return true; + } + else if (IsLogGL) + { + return m_GL.m_VtxIn.primitiveRestart; + } + } + + return false; + } + + public uint GetStripRestartIndex(uint indexByteWidth) + { + if (LogLoaded) + { + if (IsLogD3D11) + { + // D3D11 this is always '-1' in whichever size of index we're using + return indexByteWidth == 2 ? ushort.MaxValue : uint.MaxValue; + } + else if (IsLogGL) + { + uint maxval = uint.MaxValue; + if (indexByteWidth == 2) + maxval = ushort.MaxValue; + else if (indexByteWidth == 1) + maxval = 0xff; + return Math.Min(maxval, m_GL.m_VtxIn.restartIndex); + } + } + + return uint.MaxValue; + } + public struct VBuffer { public ResourceId Buffer; diff --git a/renderdocui/Interop/GLPipelineState.cs b/renderdocui/Interop/GLPipelineState.cs index 4595599f4..90ff8e29d 100644 --- a/renderdocui/Interop/GLPipelineState.cs +++ b/renderdocui/Interop/GLPipelineState.cs @@ -59,6 +59,8 @@ namespace renderdoc public VertexBuffer[] vbuffers; public ResourceId ibuffer; + public bool primitiveRestart; + public UInt32 restartIndex; }; [CustomMarshalAs(CustomUnmanagedType.CustomClass)] public VertexInputs m_VtxIn; diff --git a/renderdocui/Windows/BufferViewer.cs b/renderdocui/Windows/BufferViewer.cs index 5438f26ce..98f9fdb0f 100644 --- a/renderdocui/Windows/BufferViewer.cs +++ b/renderdocui/Windows/BufferViewer.cs @@ -76,6 +76,8 @@ namespace renderdocui.Windows public ResourceId IndexBuffer = ResourceId.Null; public uint IndexOffset = 0; + public bool IndexRestart = true; + public uint IndexRestartValue = uint.MaxValue; } // contains the raw bytes (and any state necessary from the drawcall itself) @@ -711,6 +713,8 @@ namespace renderdocui.Windows ret.IndexBuffer = ibuffer; ret.IndexOffset = ioffset; + ret.IndexRestart = m_Core.CurPipelineState.IsStripRestartEnabled(); + ret.IndexRestartValue = m_Core.CurPipelineState.GetStripRestartIndex(draw != null ? draw.indexByteWidth : 0); if (type != MeshDataStage.VSIn) { @@ -893,9 +897,9 @@ namespace renderdocui.Windows uint minIndex = ret.Indices.Length > 0 ? ret.Indices[0] : 0; foreach (var i in ret.Indices) { - if (input.Drawcall.indexByteWidth == 2 && i == UInt16.MaxValue) + if (input.Drawcall.indexByteWidth == 2 && i == input.IndexRestartValue && input.IndexRestart) continue; - if (input.Drawcall.indexByteWidth == 4 && i == UInt32.MaxValue) + if (input.Drawcall.indexByteWidth == 4 && i == input.IndexRestartValue && input.IndexRestart) continue; minIndex = Math.Min(minIndex, i); @@ -949,9 +953,9 @@ namespace renderdocui.Windows maxIndex = 0; foreach (var i in ret.Indices) { - if (input.Drawcall.indexByteWidth == 2 && i == UInt16.MaxValue) + if (input.Drawcall.indexByteWidth == 2 && i == input.IndexRestartValue && input.IndexRestart) continue; - if (input.Drawcall.indexByteWidth == 4 && i == UInt32.MaxValue) + if (input.Drawcall.indexByteWidth == 4 && i == input.IndexRestartValue && input.IndexRestart) continue; maxIndex = Math.Max(maxIndex, i); @@ -1576,9 +1580,9 @@ namespace renderdocui.Windows state.m_Data.Topology == PrimitiveTopology.TriangleStrip || state.m_Data.Topology == PrimitiveTopology.TriangleStrip_Adj; - if (state.m_Input.Drawcall.indexByteWidth == 2 && index == ushort.MaxValue && strip) + if (state.m_Input.Drawcall.indexByteWidth == 2 && index == state.m_Input.IndexRestartValue && state.m_Input.IndexRestart && strip) rowdata[1] = "-1"; - if (state.m_Input.Drawcall.indexByteWidth == 4 && index == uint.MaxValue && strip) + if (state.m_Input.Drawcall.indexByteWidth == 4 && index == state.m_Input.IndexRestartValue && state.m_Input.IndexRestart && strip) rowdata[1] = "-1"; x = 2; diff --git a/renderdocui/Windows/PipelineState/GLPipelineStateViewer.Designer.cs b/renderdocui/Windows/PipelineState/GLPipelineStateViewer.Designer.cs index 11aaac77b..fb92dc6ff 100644 --- a/renderdocui/Windows/PipelineState/GLPipelineStateViewer.Designer.cs +++ b/renderdocui/Windows/PipelineState/GLPipelineStateViewer.Designer.cs @@ -287,6 +287,7 @@ this.tableLayoutPanel13 = new System.Windows.Forms.TableLayoutPanel(); this.topologyDiagram = new System.Windows.Forms.PictureBox(); this.topology = new System.Windows.Forms.Label(); + this.restartIndex = new System.Windows.Forms.Label(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.iabuffers = new TreelistView.TreeListView(); this.inputLayouts = new TreelistView.TreeListView(); @@ -787,12 +788,14 @@ this.tableLayoutPanel13.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel13.Controls.Add(this.topologyDiagram, 0, 1); this.tableLayoutPanel13.Controls.Add(this.topology, 0, 0); + this.tableLayoutPanel13.Controls.Add(this.restartIndex, 0, 2); this.tableLayoutPanel13.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel13.Location = new System.Drawing.Point(3, 16); this.tableLayoutPanel13.Name = "tableLayoutPanel13"; - this.tableLayoutPanel13.RowCount = 2; + this.tableLayoutPanel13.RowCount = 3; this.tableLayoutPanel13.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel13.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayoutPanel13.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tableLayoutPanel13.Size = new System.Drawing.Size(336, 278); this.tableLayoutPanel13.TabIndex = 2; // @@ -802,7 +805,7 @@ this.topologyDiagram.Image = global::renderdocui.Properties.Resources.topo_trilist; this.topologyDiagram.Location = new System.Drawing.Point(3, 26); this.topologyDiagram.Name = "topologyDiagram"; - this.topologyDiagram.Size = new System.Drawing.Size(330, 249); + this.topologyDiagram.Size = new System.Drawing.Size(330, 226); this.topologyDiagram.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage; this.topologyDiagram.TabIndex = 1; this.topologyDiagram.TabStop = false; @@ -821,6 +824,16 @@ this.topology.Text = "Triangle List"; this.topology.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // restartIndex + // + this.restartIndex.AutoSize = true; + this.restartIndex.Font = new System.Drawing.Font("Tahoma", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.restartIndex.Location = new System.Drawing.Point(3, 255); + this.restartIndex.Name = "restartIndex"; + this.restartIndex.Size = new System.Drawing.Size(214, 23); + this.restartIndex.TabIndex = 2; + this.restartIndex.Text = "Restart Idx: 0xFFFFFFFF"; + // // groupBox4 // this.groupBox4.Controls.Add(this.iabuffers); @@ -2405,7 +2418,7 @@ this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 687F)); + this.tableLayoutPanel8.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 688F)); this.tableLayoutPanel8.Controls.Add(this.frontCCW, 5, 0); this.tableLayoutPanel8.Controls.Add(this.cullMode, 3, 0); this.tableLayoutPanel8.Controls.Add(label1, 0, 1); @@ -4553,5 +4566,6 @@ private System.Windows.Forms.PictureBox psShaderEdit; private System.Windows.Forms.PictureBox csShaderEdit; private System.Windows.Forms.PictureBox meshView; + private System.Windows.Forms.Label restartIndex; } } \ No newline at end of file diff --git a/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs b/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs index 9e7b29f9f..3f841fb84 100644 --- a/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs +++ b/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs @@ -403,6 +403,18 @@ namespace renderdocui.Windows.PipelineState bool ibufferUsed = draw != null && (draw.flags & DrawcallFlags.UseIBuffer) != 0; + if (ibufferUsed) + { + if(state.m_VtxIn.primitiveRestart) + restartIndex.Text = String.Format("Restart Idx: 0x{0:X8}", state.m_VtxIn.restartIndex); + else + restartIndex.Text = "Restart Idx: Disabled"; + } + else + { + restartIndex.Text = ""; + } + if (state.m_VtxIn.ibuffer != null) { if (ibufferUsed || showDisabled.Checked)