public ResourceId[] GetResources(ShaderStageType stage) { if (LogLoaded) { if (IsLogD3D11) { D3D11PipelineState.ShaderStage s = null; switch (stage) { case ShaderStageType.Vertex: s = m_D3D11.m_VS; break; case ShaderStageType.Domain: s = m_D3D11.m_DS; break; case ShaderStageType.Hull: s = m_D3D11.m_HS; break; case ShaderStageType.Geometry: s = m_D3D11.m_GS; break; case ShaderStageType.Pixel: s = m_D3D11.m_PS; break; case ShaderStageType.Compute: s = m_D3D11.m_CS; break; } ResourceId[] ret = new ResourceId[s.SRVs.Length]; for (int i = 0; i < s.SRVs.Length; i++) { ret[i] = s.SRVs[i].Resource; } return(ret); } else if (IsLogGL) { ResourceId[] ret = new ResourceId[m_GL.Textures.Length]; for (int i = 0; i < m_GL.Textures.Length; i++) { ret[i] = m_GL.Textures[i].Resource; } return(ret); } } return(null); }
public void GetConstantBuffer(ShaderStageType stage, uint BindPoint, out ResourceId buf, out uint ByteOffset) { if (LogLoaded) { if (IsLogD3D11) { D3D11PipelineState.ShaderStage s = null; switch (stage) { case ShaderStageType.Vertex: s = m_D3D11.m_VS; break; case ShaderStageType.Domain: s = m_D3D11.m_DS; break; case ShaderStageType.Hull: s = m_D3D11.m_HS; break; case ShaderStageType.Geometry: s = m_D3D11.m_GS; break; case ShaderStageType.Pixel: s = m_D3D11.m_PS; break; case ShaderStageType.Compute: s = m_D3D11.m_CS; break; } buf = s.ConstantBuffers[BindPoint].Buffer; ByteOffset = s.ConstantBuffers[BindPoint].VecOffset * 4 * sizeof(float); return; } else if (IsLogGL) { buf = ResourceId.Null; ByteOffset = 0; return; } } buf = ResourceId.Null; ByteOffset = 0; }
public void GetConstantBuffer(ShaderStageType stage, uint BufIdx, uint ArrayIdx, out ResourceId buf, out ulong ByteOffset, out ulong ByteSize) { if (LogLoaded) { if (IsLogD3D11) { D3D11PipelineState.ShaderStage s = null; switch (stage) { case ShaderStageType.Vertex: s = m_D3D11.m_VS; break; case ShaderStageType.Domain: s = m_D3D11.m_DS; break; case ShaderStageType.Hull: s = m_D3D11.m_HS; break; case ShaderStageType.Geometry: s = m_D3D11.m_GS; break; case ShaderStageType.Pixel: s = m_D3D11.m_PS; break; case ShaderStageType.Compute: s = m_D3D11.m_CS; break; } if (BufIdx < s.ConstantBuffers.Length) { buf = s.ConstantBuffers[BufIdx].Buffer; ByteOffset = (ulong)(s.ConstantBuffers[BufIdx].VecOffset * 4 * sizeof(float)); ByteSize = (ulong)(s.ConstantBuffers[BufIdx].VecCount * 4 * sizeof(float)); return; } } else if (IsLogGL) { GLPipelineState.ShaderStage s = null; switch (stage) { case ShaderStageType.Vertex: s = m_GL.m_VS; break; case ShaderStageType.Tess_Control: s = m_GL.m_TCS; break; case ShaderStageType.Tess_Eval: s = m_GL.m_TES; break; case ShaderStageType.Geometry: s = m_GL.m_GS; break; case ShaderStageType.Fragment: s = m_GL.m_FS; break; case ShaderStageType.Compute: s = m_GL.m_CS; break; } if (s.ShaderDetails != null && BufIdx < s.ShaderDetails.ConstantBlocks.Length) { if (s.ShaderDetails.ConstantBlocks[BufIdx].bindPoint >= 0) { int uboIdx = s.BindpointMapping.ConstantBlocks[s.ShaderDetails.ConstantBlocks[BufIdx].bindPoint].bind; if (uboIdx >= 0 && uboIdx < m_GL.UniformBuffers.Length) { var b = m_GL.UniformBuffers[uboIdx]; buf = b.Resource; ByteOffset = b.Offset; ByteSize = b.Size; return; } } } } else if (IsLogVK) { VulkanPipelineState.Pipeline pipe = m_Vulkan.graphics; if (stage == ShaderStageType.Compute) { pipe = m_Vulkan.compute; } VulkanPipelineState.ShaderStage s = null; switch (stage) { case ShaderStageType.Vertex: s = m_Vulkan.VS; break; case ShaderStageType.Tess_Control: s = m_Vulkan.TCS; break; case ShaderStageType.Tess_Eval: s = m_Vulkan.TES; break; case ShaderStageType.Geometry: s = m_Vulkan.GS; break; case ShaderStageType.Fragment: s = m_Vulkan.FS; break; case ShaderStageType.Compute: s = m_Vulkan.CS; break; } if (s.ShaderDetails != null && BufIdx < s.ShaderDetails.ConstantBlocks.Length) { var bind = s.BindpointMapping.ConstantBlocks[s.ShaderDetails.ConstantBlocks[BufIdx].bindPoint]; if (s.ShaderDetails.ConstantBlocks[BufIdx].bufferBacked == false) { // dummy values, it would be nice to fetch these properly buf = ResourceId.Null; ByteOffset = 0; ByteSize = 1024; return; } var descriptorBind = pipe.DescSets[bind.bindset].bindings[bind.bind].binds[ArrayIdx]; buf = descriptorBind.res; ByteOffset = descriptorBind.offset; ByteSize = descriptorBind.size; return; } } } buf = ResourceId.Null; ByteOffset = 0; ByteSize = 0; }
public Dictionary <BindpointMap, BoundResource[]> GetReadOnlyResources(ShaderStageType stage) { var ret = new Dictionary <BindpointMap, BoundResource[]>(); if (LogLoaded) { if (IsLogD3D11) { D3D11PipelineState.ShaderStage s = null; switch (stage) { case ShaderStageType.Vertex: s = m_D3D11.m_VS; break; case ShaderStageType.Domain: s = m_D3D11.m_DS; break; case ShaderStageType.Hull: s = m_D3D11.m_HS; break; case ShaderStageType.Geometry: s = m_D3D11.m_GS; break; case ShaderStageType.Pixel: s = m_D3D11.m_PS; break; case ShaderStageType.Compute: s = m_D3D11.m_CS; break; } for (int i = 0; i < s.SRVs.Length; i++) { var key = new BindpointMap(0, i); var val = new BoundResource(); val.Id = s.SRVs[i].Resource; val.HighestMip = (int)s.SRVs[i].HighestMip; val.FirstSlice = (int)s.SRVs[i].FirstArraySlice; ret.Add(key, new BoundResource[] { val }); } return(ret); } else if (IsLogGL) { for (int i = 0; i < m_GL.Textures.Length; i++) { var key = new BindpointMap(0, i); var val = new BoundResource(); val.Id = m_GL.Textures[i].Resource; val.HighestMip = (int)m_GL.Textures[i].HighestMip; val.FirstSlice = (int)m_GL.Textures[i].FirstSlice; ret.Add(key, new BoundResource[] { val }); } return(ret); } else if (IsLogVK) { VulkanPipelineState.Pipeline.DescriptorSet[] descsets = m_Vulkan.graphics.DescSets; if (stage == ShaderStageType.Compute) { descsets = m_Vulkan.compute.DescSets; } ShaderStageBits mask = (ShaderStageBits)(1 << (int)stage); for (int set = 0; set < m_Vulkan.graphics.DescSets.Length; set++) { var descset = m_Vulkan.graphics.DescSets[set]; for (int slot = 0; slot < descset.bindings.Length; slot++) { var bind = descset.bindings[slot]; if ((bind.type == ShaderBindType.ImageSampler || bind.type == ShaderBindType.InputAttachment || bind.type == ShaderBindType.ReadOnlyImage || bind.type == ShaderBindType.ReadOnlyTBuffer ) && (bind.stageFlags & mask) == mask) { var key = new BindpointMap(set, slot); var val = new BoundResource[bind.descriptorCount]; for (UInt32 i = 0; i < bind.descriptorCount; i++) { val[i] = new BoundResource(); val[i].Id = bind.binds[i].res; val[i].HighestMip = (int)bind.binds[i].baseMip; val[i].FirstSlice = (int)bind.binds[i].baseLayer; } ret.Add(key, val); } } } return(ret); } } return(ret); }
public void GetConstantBuffer(ShaderStageType stage, uint BufIdx, out ResourceId buf, out uint ByteOffset, out uint ByteSize) { if (LogLoaded) { if (IsLogD3D11) { D3D11PipelineState.ShaderStage s = null; switch (stage) { case ShaderStageType.Vertex: s = m_D3D11.m_VS; break; case ShaderStageType.Domain: s = m_D3D11.m_DS; break; case ShaderStageType.Hull: s = m_D3D11.m_HS; break; case ShaderStageType.Geometry: s = m_D3D11.m_GS; break; case ShaderStageType.Pixel: s = m_D3D11.m_PS; break; case ShaderStageType.Compute: s = m_D3D11.m_CS; break; } if (BufIdx < s.ConstantBuffers.Length) { buf = s.ConstantBuffers[BufIdx].Buffer; ByteOffset = s.ConstantBuffers[BufIdx].VecOffset * 4 * sizeof(float); ByteSize = s.ConstantBuffers[BufIdx].VecCount * 4 * sizeof(float); return; } } else if (IsLogGL) { GLPipelineState.ShaderStage s = null; switch (stage) { case ShaderStageType.Vertex: s = m_GL.m_VS; break; case ShaderStageType.Tess_Control: s = m_GL.m_TCS; break; case ShaderStageType.Tess_Eval: s = m_GL.m_TES; break; case ShaderStageType.Geometry: s = m_GL.m_GS; break; case ShaderStageType.Fragment: s = m_GL.m_FS; break; case ShaderStageType.Compute: s = m_GL.m_CS; break; } if (s.ShaderDetails != null && BufIdx < s.ShaderDetails.ConstantBlocks.Length) { if (s.ShaderDetails.ConstantBlocks[BufIdx].bindPoint >= 0) { int uboIdx = s.BindpointMapping.ConstantBlocks[s.ShaderDetails.ConstantBlocks[BufIdx].bindPoint].bind; if (uboIdx >= 0 && uboIdx < m_GL.UniformBuffers.Length) { var b = m_GL.UniformBuffers[uboIdx]; buf = b.Resource; ByteOffset = (uint)b.Offset; ByteSize = (uint)b.Size; return; } } } } } buf = ResourceId.Null; ByteOffset = 0; ByteSize = 0; }
public ShaderViewer(Core core, ShaderReflection shader, ShaderStageType stage, ShaderDebugTrace trace) { InitializeComponent(); Icon = global::renderdocui.Properties.Resources.icon; this.SuspendLayout(); mainLayout.Dock = DockStyle.Fill; m_Core = core; m_ShaderDetails = shader; m_Trace = trace; m_Stage = null; switch (stage) { case ShaderStageType.Vertex: m_Stage = m_Core.CurD3D11PipelineState.m_VS; break; case ShaderStageType.Domain: m_Stage = m_Core.CurD3D11PipelineState.m_DS; break; case ShaderStageType.Hull: m_Stage = m_Core.CurD3D11PipelineState.m_HS; break; case ShaderStageType.Geometry: m_Stage = m_Core.CurD3D11PipelineState.m_GS; break; case ShaderStageType.Pixel: m_Stage = m_Core.CurD3D11PipelineState.m_PS; break; case ShaderStageType.Compute: m_Stage = m_Core.CurD3D11PipelineState.m_CS; break; } var disasm = shader.Disassembly; if (m_Core.Config.ShaderViewer_FriendlyNaming) { for (int i = 0; i < m_ShaderDetails.ConstantBlocks.Length; i++) { var stem = string.Format("cb{0}", i); var cbuf = m_ShaderDetails.ConstantBlocks[i]; if (cbuf.variables.Length == 0) { continue; } disasm = FriendlyName(disasm, stem, cbuf.variables); } foreach (var r in m_ShaderDetails.Resources) { if (r.IsSRV) { var needle = string.Format(", t{0}([^0-9])", r.bindPoint); var replacement = string.Format(", {0}$1", r.name); Regex rgx = new Regex(needle); disasm = rgx.Replace(disasm, replacement); } if (r.IsSampler) { var needle = string.Format(", s{0}([^0-9])", r.bindPoint); var replacement = string.Format(", {0}$1", r.name); Regex rgx = new Regex(needle); disasm = rgx.Replace(disasm, replacement); } if (r.IsUAV) { var needle = string.Format(", u{0}([^0-9])", r.bindPoint); var replacement = string.Format(", {0}$1", r.name); Regex rgx = new Regex(needle); disasm = rgx.Replace(disasm, replacement); } } } { m_DisassemblyView = MakeEditor("scintillaDisassem", disasm, false); m_DisassemblyView.IsReadOnly = true; m_DisassemblyView.TabIndex = 0; m_DisassemblyView.KeyDown += new KeyEventHandler(m_DisassemblyView_KeyDown); m_DisassemblyView.Markers[CURRENT_MARKER].BackColor = System.Drawing.Color.LightCoral; m_DisassemblyView.Markers[CURRENT_MARKER].Symbol = ScintillaNET.MarkerSymbol.Background; m_DisassemblyView.Markers[CURRENT_MARKER + 1].BackColor = System.Drawing.Color.LightCoral; m_DisassemblyView.Markers[CURRENT_MARKER + 1].Symbol = ScintillaNET.MarkerSymbol.ShortArrow; CurrentLineMarkers.Add(CURRENT_MARKER); CurrentLineMarkers.Add(CURRENT_MARKER + 1); m_DisassemblyView.Markers[FINISHED_MARKER].BackColor = System.Drawing.Color.LightSlateGray; m_DisassemblyView.Markers[FINISHED_MARKER].Symbol = ScintillaNET.MarkerSymbol.Background; m_DisassemblyView.Markers[FINISHED_MARKER + 1].BackColor = System.Drawing.Color.LightSlateGray; m_DisassemblyView.Markers[FINISHED_MARKER + 1].Symbol = ScintillaNET.MarkerSymbol.RoundRectangle; FinishedMarkers.Add(FINISHED_MARKER); FinishedMarkers.Add(FINISHED_MARKER + 1); m_DisassemblyView.Markers[BREAKPOINT_MARKER].BackColor = System.Drawing.Color.Red; m_DisassemblyView.Markers[BREAKPOINT_MARKER].Symbol = ScintillaNET.MarkerSymbol.Background; m_DisassemblyView.Markers[BREAKPOINT_MARKER + 1].BackColor = System.Drawing.Color.Red; m_DisassemblyView.Markers[BREAKPOINT_MARKER + 1].Symbol = ScintillaNET.MarkerSymbol.Circle; BreakpointMarkers.Add(BREAKPOINT_MARKER); BreakpointMarkers.Add(BREAKPOINT_MARKER + 1); m_Scintillas.Add(m_DisassemblyView); var w = Helpers.WrapDockContent(dockPanel, m_DisassemblyView, "Disassembly"); w.DockState = DockState.Document; w.Show(); w.CloseButton = false; w.CloseButtonVisible = false; } if (shader.DebugInfo.entryFunc != "" && shader.DebugInfo.files.Length > 0) { Text = shader.DebugInfo.entryFunc + "()"; DockContent sel = null; foreach (var f in shader.DebugInfo.files) { var name = Path.GetFileName(f.filename); ScintillaNET.Scintilla scintilla1 = MakeEditor("scintilla" + name, f.filetext, true); scintilla1.IsReadOnly = true; scintilla1.Tag = name; var w = Helpers.WrapDockContent(dockPanel, scintilla1, name); w.CloseButton = false; w.CloseButtonVisible = false; w.Show(dockPanel); m_Scintillas.Add(scintilla1); if (f.filetext.Contains(shader.DebugInfo.entryFunc)) { sel = w; } } if (trace != null || sel == null) { sel = (DockContent)m_DisassemblyView.Parent; } sel.Show(); } ShowConstants(); ShowVariables(); ShowWatch(); ShowErrors(); editStrip.Visible = false; m_ErrorsDock.Hide(); if (trace == null) { debuggingStrip.Visible = false; m_ConstantsDock.Hide(); m_VariablesDock.Hide(); m_WatchDock.Hide(); var insig = Helpers.WrapDockContent(dockPanel, inSigBox); insig.CloseButton = insig.CloseButtonVisible = false; var outsig = Helpers.WrapDockContent(dockPanel, outSigBox); outsig.CloseButton = outsig.CloseButtonVisible = false; insig.Show(dockPanel, DockState.DockBottom); outsig.Show(insig.Pane, DockAlignment.Right, 0.5); foreach (var s in m_ShaderDetails.InputSig) { string name = s.varName == "" ? s.semanticName : String.Format("{0} ({1})", s.varName, s.semanticName); var node = inSig.Nodes.Add(new object[] { name, s.semanticIndex, s.regIndex, s.TypeString, s.systemValue.ToString(), SigParameter.GetComponentString(s.regChannelMask), SigParameter.GetComponentString(s.channelUsedMask) }); } bool multipleStreams = false; for (int i = 0; i < m_ShaderDetails.OutputSig.Length; i++) { if (m_ShaderDetails.OutputSig[i].stream > 0) { multipleStreams = true; break; } } foreach (var s in m_ShaderDetails.OutputSig) { string name = s.varName == "" ? s.semanticName : String.Format("{0} ({1})", s.varName, s.semanticName); if (multipleStreams) { name = String.Format("Stream {0} : {1}", s.stream, name); } var node = outSig.Nodes.Add(new object[] { name, s.semanticIndex, s.regIndex, s.TypeString, s.systemValue.ToString(), SigParameter.GetComponentString(s.regChannelMask), SigParameter.GetComponentString(s.channelUsedMask) }); } } else { inSigBox.Visible = false; outSigBox.Visible = false; m_DisassemblyView.Margins.Margin1.Width = 20; m_DisassemblyView.Margins.Margin2.Width = 0; m_DisassemblyView.Margins.Margin3.Width = 20; m_DisassemblyView.Margins.Margin3.IsMarkerMargin = true; m_DisassemblyView.Margins.Margin3.IsFoldMargin = false; m_DisassemblyView.Margins.Margin3.Type = ScintillaNET.MarginType.Symbol; m_DisassemblyView.Margins.Margin1.Mask = (int)m_DisassemblyView.Markers[BREAKPOINT_MARKER + 1].Mask; m_DisassemblyView.Margins.Margin3.Mask &= ~((int)m_DisassemblyView.Markers[BREAKPOINT_MARKER + 1].Mask); m_DisassemblyView.KeyDown += new KeyEventHandler(scintilla1_DebuggingKeyDown); watchRegs.Items.Add(new ListViewItem(new string[] { "", "", "" })); } CurrentStep = 0; this.ResumeLayout(false); }