public ConstantBufferPreviewer(Core c, ShaderStageType stage, UInt32 slot, UInt32 idx) { InitializeComponent(); if (SystemInformation.HighContrast) toolStrip1.Renderer = new ToolStripSystemRenderer(); m_Core = c; Stage = stage; Slot = slot; ArrayIdx = idx; shader = m_Core.CurPipelineState.GetShader(stage); entryPoint = m_Core.CurPipelineState.GetShaderEntryPoint(stage); UpdateLabels(); ulong offs = 0; ulong size = 0; m_Core.CurPipelineState.GetConstantBuffer(Stage, Slot, ArrayIdx, out cbuffer, out offs, out size); m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { SetVariables(r.GetCBufferVariableContents(shader, entryPoint, Slot, cbuffer, offs)); }); m_Core.AddLogViewer(this); }
public BufferFormatSpecifier(BufferViewer viewer, ResourceId buff, string format) { InitializeComponent(); // WHY THE HELL do you require \r\n in text boxes? formatText.Text = format.Replace("\r\n", "\n").Replace("\n", Environment.NewLine); m_Viewer = viewer; m_Buffer = buff; }
public ConstantBufferPreviewer(Core c, ShaderStageType stage, UInt32 slot, UInt32 idx) { InitializeComponent(); if (SystemInformation.HighContrast) toolStrip1.Renderer = new ToolStripSystemRenderer(); m_Core = c; Stage = stage; Slot = slot; ArrayIdx = idx; shader = m_Core.CurPipelineState.GetShader(stage); entryPoint = m_Core.CurPipelineState.GetShaderEntryPoint(stage); UpdateLabels(); }
public ConstantBufferPreviewer(Core c, ShaderStageType stage, UInt32 slot) { InitializeComponent(); m_Core = c; Stage = stage; Slot = slot; shader = m_Core.CurPipelineState.GetShader(stage); UpdateLabels(); uint offs = 0; m_Core.CurPipelineState.GetConstantBuffer(Stage, Slot, out cbuffer, out offs); m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { SetVariables(r.GetCBufferVariableContents(shader, Slot, cbuffer, offs)); }); m_Core.AddLogViewer(this); }
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 GetIBuffer(out ResourceId buf, out uint ByteOffset, out ResourceFormat IndexFormat) { if (LogLoaded) { if (IsLogD3D11) { buf = m_D3D11.m_IA.ibuffer.Buffer; ByteOffset = m_D3D11.m_IA.ibuffer.Offset; IndexFormat = m_D3D11.m_IA.ibuffer.Format; return; } else if (IsLogGL) { buf = m_GL.m_VtxIn.ibuffer.Buffer; ByteOffset = m_GL.m_VtxIn.ibuffer.Offset; IndexFormat = m_GL.m_VtxIn.ibuffer.Format; return; } } buf = ResourceId.Null; ByteOffset = 0; IndexFormat = new ResourceFormat(FormatComponentType.UInt, 1, 2); }
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 PixelModification[] PixelHistory(ResourceId target, UInt32 x, UInt32 y, UInt32 slice, UInt32 mip, UInt32 sampleIdx) { IntPtr mem = CustomMarshal.Alloc(typeof(templated_array)); bool success = ReplayRenderer_PixelHistory(m_Real, target, x, y, slice, mip, sampleIdx, mem); PixelModification[] ret = null; if (success) ret = (PixelModification[])CustomMarshal.GetTemplatedArray(mem, typeof(PixelModification), true); CustomMarshal.Free(mem); return ret; }
private void InitResourcePreview(ResourcePreview prev, ResourceId id, FormatComponentType typeHint, bool force, Following follow, string bindName, string slotName) { if (id != ResourceId.Null || force) { FetchTexture tex = null; foreach (var t in m_Core.CurTextures) if (t.ID == id) tex = t; FetchBuffer buf = null; foreach (var b in m_Core.CurBuffers) if (b.ID == id) buf = b; if (tex != null) { string fullname = bindName; if (tex.customName) { if (fullname.Length > 0) fullname += " = "; fullname += tex.name; } if (fullname.Length == 0) fullname = tex.name; prev.Init(fullname, tex.width, tex.height, tex.depth, tex.mips); IntPtr handle = prev.ThumbnailHandle; m_Core.Renderer.BeginInvoke((ReplayRenderer rep) => { m_Output.AddThumbnail(handle, id, typeHint); }); } else if (buf != null) { string fullname = bindName; if (buf.customName) { if (fullname.Length > 0) fullname += " = "; fullname += buf.name; } if (fullname.Length == 0) fullname = buf.name; prev.Init(fullname, buf.length, 0, 0, 1); IntPtr handle = prev.ThumbnailHandle; m_Core.Renderer.BeginInvoke((ReplayRenderer rep) => { m_Output.AddThumbnail(handle, ResourceId.Null, FormatComponentType.None); }); } else { prev.Init(); IntPtr handle = prev.ThumbnailHandle; m_Core.Renderer.BeginInvoke((ReplayRenderer rep) => { m_Output.AddThumbnail(handle, ResourceId.Null, FormatComponentType.None); }); } prev.Tag = follow; prev.SlotName = slotName; prev.Visible = true; prev.Selected = (m_Following == follow); } else if (m_Following == follow) { FetchTexture tex = null; if(id != ResourceId.Null) foreach (var t in m_Core.CurTextures) if (t.ID == id) tex = t; IntPtr handle = prev.ThumbnailHandle; if (id == ResourceId.Null || tex == null) prev.Init(); else prev.Init("Unused", tex.width, tex.height, tex.depth, tex.mips); prev.Selected = true; m_Core.Renderer.BeginInvoke((ReplayRenderer rep) => { m_Output.AddThumbnail(handle, ResourceId.Null, FormatComponentType.None); }); } else { prev.Init(); prev.Visible = false; } }
// setting a context filter allows replaying of deferred events. You can set the deferred // events to replay in a context, after replaying up to a given event on the main thread public void SetContextFilter(ILogViewerForm exclude, UInt32 frameID, UInt32 eventID, ResourceId ctx, UInt32 firstDeferred, UInt32 lastDeferred) { m_FrameID = frameID; m_EventID = eventID; m_DeferredEvent = lastDeferred; m_Renderer.Invoke((ReplayRenderer r) => { r.SetContextFilter(ctx, firstDeferred, lastDeferred); }); m_Renderer.Invoke((ReplayRenderer r) => { r.SetFrameEvent(m_FrameID, m_EventID); m_D3D11PipelineState = r.GetD3D11PipelineState(); m_GLPipelineState = r.GetGLPipelineState(); m_PipelineState.SetStates(m_APIProperties, m_D3D11PipelineState, m_GLPipelineState); }); foreach (var logviewer in m_LogViewers) { if (logviewer == exclude) continue; Control c = (Control)logviewer; if (c.InvokeRequired) c.BeginInvoke(new Action(() => logviewer.OnEventSelected(frameID, eventID))); else logviewer.OnEventSelected(frameID, eventID); } }
public void ViewRawBuffer(bool isBuffer, ResourceId id) { ViewRawBuffer(isBuffer, id, ""); }
private static extern bool ReplayRenderer_GetCBufferVariableContents(IntPtr real, ResourceId shader, IntPtr entryPoint, UInt32 cbufslot, ResourceId buffer, UInt64 offs, IntPtr outvars);
private static extern bool ReplayRenderer_GetUsage(IntPtr real, ResourceId id, IntPtr outusage);
private static extern bool ReplayRenderer_PixelHistory(IntPtr real, ResourceId target, UInt32 x, UInt32 y, UInt32 slice, UInt32 mip, UInt32 sampleIdx, IntPtr history);
private static extern bool ReplayRenderer_FreeTargetResource(IntPtr real, ResourceId id);
private static extern bool ReplayRenderer_RemoveReplacement(IntPtr real, ResourceId id);
private static extern bool ReplayRenderer_ReplaceResource(IntPtr real, ResourceId from, ResourceId to);
private static extern void ReplayRenderer_BuildTargetShader(IntPtr real, IntPtr entry, IntPtr source, UInt32 compileFlags, ShaderStageType type, ref ResourceId shaderID, IntPtr errorMem);
public void ViewRawBuffer(ResourceId buff) { ViewRawBuffer(buff, ""); }
private void OpenResourceContextMenu(ResourceId id, bool thumbStripMenu, Control c, Point p) { var menuItems = new List<ToolStripItem>(); int i = 0; for (i = 0; i < rightclickMenu.Items.Count; i++) { menuItems.Add(rightclickMenu.Items[i]); if (rightclickMenu.Items[i] == usedStartLabel) break; menuItems[i].Visible = thumbStripMenu; } if (id != ResourceId.Null) { usedSep.Visible = true; usedStartLabel.Visible = true; openNewTab.Visible = true; openNewTab.Tag = id; m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { EventUsage[] usage = r.GetUsage(id); this.BeginInvoke(new Action(() => { uint start = 0; uint end = 0; ResourceUsage us = ResourceUsage.IndexBuffer; foreach (var u in usage) { if (start == 0) { start = end = u.eventID; us = u.usage; continue; } var curDraw = m_Core.GetDrawcall(m_Core.CurFrame, u.eventID); if (u.usage != us || curDraw.previous == null || curDraw.previous.eventID != end) { AddResourceUsageEntry(menuItems, start, end, us); start = end = u.eventID; us = u.usage; } end = u.eventID; } if (start != 0) AddResourceUsageEntry(menuItems, start, end, us); rightclickMenu.Items.Clear(); rightclickMenu.Items.AddRange(menuItems.ToArray()); rightclickMenu.Show(c, p); })); }); } else { usedSep.Visible = false; usedStartLabel.Visible = false; openNewTab.Visible = false; rightclickMenu.Show(c, p); } }
private static extern bool ReplayRenderer_GetMinMax(IntPtr real, ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, IntPtr outminval, IntPtr outmaxval);
public FetchBuffer GetBuffer(ResourceId id) { if (id == ResourceId.Null) return null; for (int b = 0; b < m_Buffers.Length; b++) if (m_Buffers[b].ID == id) return m_Buffers[b]; return null; }
private static extern bool ReplayRenderer_GetHistogram(IntPtr real, ResourceId tex, UInt32 sliceFace, UInt32 mip, UInt32 sample, float minval, float maxval, bool[] channels, IntPtr outhistogram);
public void OnEventSelected(UInt32 frameID, UInt32 eventID) { uint offs = 0; m_Core.CurPipelineState.GetConstantBuffer(Stage, Slot, out cbuffer, out offs); shader = m_Core.CurPipelineState.GetShader(Stage); var reflection = m_Core.CurPipelineState.GetShaderReflection(Stage); UpdateLabels(); if (reflection == null || reflection.ConstantBlocks.Length <= Slot) { SetVariables(null); return; } m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { SetVariables(r.GetCBufferVariableContents(shader, Slot, cbuffer, offs)); }); }
private static extern bool ReplayRenderer_GetBufferData(IntPtr real, ResourceId buff, UInt64 offset, UInt64 len, IntPtr outdata);
private static extern bool ReplayRenderer_FreeCustomShader(IntPtr real, ResourceId id);
private static extern bool ReplayRenderer_GetTextureData(IntPtr real, ResourceId tex, UInt32 arrayIdx, UInt32 mip, IntPtr outdata);
public BufferResTag(bool rw, UInt32 b, ResourceId id, ulong offs, ulong sz) { rwRes = rw; bindPoint = b; ID = id; offset = offs; size = sz; }
public bool SetContextFilter(ResourceId id, UInt32 firstDefEv, UInt32 lastDefEv) { return(ReplayRenderer_SetContextFilter(m_Real, id, firstDefEv, lastDefEv)); }
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 bool FreeCustomShader(ResourceId id) { return(ReplayRenderer_FreeCustomShader(m_Real, id)); }
public ResourceId[] GetOutputTargets() { if (LogLoaded) { if (IsLogD3D11) { ResourceId[] ret = new ResourceId[m_D3D11.m_OM.RenderTargets.Length]; for (int i = 0; i < m_D3D11.m_OM.RenderTargets.Length; i++) { ret[i] = m_D3D11.m_OM.RenderTargets[i].Resource; if (ret[i] == ResourceId.Null && i > m_D3D11.m_OM.UAVStartSlot) ret[i] = m_D3D11.m_OM.UAVs[i - m_D3D11.m_OM.UAVStartSlot].Resource; } return ret; } else if (IsLogGL) { return m_GL.m_FB.Color; } } return null; }
public bool ReplaceResource(ResourceId from, ResourceId to) { return(ReplayRenderer_ReplaceResource(m_Real, from, to)); }
// used for the mesh view, to get the format of the mesh input from whichever stage that // we're looking at private Input GetCurrentMeshInput(FetchDrawcall draw, MeshDataStage type) { if (!MeshView) return null; FormatElement[] f = null; Input ret = new Input(); ret.Drawcall = draw; ret.Topology = m_Core.CurPipelineState.DrawTopology; if (type != MeshDataStage.VSIn) { ShaderReflection details = null; if (type == MeshDataStage.VSOut) details = m_Core.CurPipelineState.GetShaderReflection(ShaderStageType.Vertex); else if (type == MeshDataStage.GSOut) { details = m_Core.CurPipelineState.GetShaderReflection(ShaderStageType.Geometry); if (details == null) details = m_Core.CurPipelineState.GetShaderReflection(ShaderStageType.Domain); } if (details == null) return null; f = new FormatElement[details.OutputSig.Length]; uint offset = 0; for (int i = 0; i < details.OutputSig.Length; i++) { var sig = details.OutputSig[i]; f[i] = new FormatElement(); f[i].buffer = 0; f[i].name = details.OutputSig[i].varName != "" ? details.OutputSig[i].varName : details.OutputSig[i].semanticIdxName; f[i].format.compByteWidth = sizeof(float); f[i].format.compCount = sig.compCount; f[i].format.compType = sig.compType; f[i].format.special = false; f[i].format.rawType = 0; f[i].offset = offset; f[i].perinstance = false; f[i].rowmajor = false; f[i].matrixdim = 1; offset += details.OutputSig[i].compCount * sizeof(float); } ret.BufferFormats = f; ret.Strides = new uint[] { offset }; ret.Offsets = new uint[] { 0 }; ret.Buffers = null; ret.IndexBuffer = ResourceId.Null; return ret; } CommonPipelineState.VBuffer[] vbs = m_Core.CurPipelineState.GetVBuffers(); ResourceId[] bs = new ResourceId[vbs.Length]; uint[] s = new uint[vbs.Length]; uint[] o = new uint[vbs.Length]; for (int i = 0; i < vbs.Length; i++) { bs[i] = vbs[i].Buffer; s[i] = vbs[i].ByteStride; o[i] = vbs[i].ByteOffset; } { var vinputs = m_Core.CurPipelineState.GetVertexInputs(); f = new FormatElement[vinputs.Length]; int i = 0; foreach (var a in vinputs) { f[i] = new FormatElement(a.Name, a.VertexBuffer, a.RelativeByteOffset, a.PerInstance, false, // row major matrix 1, // matrix dimension a.Format); i++; } } ResourceId ibuffer = ResourceId.Null; uint ioffset = 0; ResourceFormat ifmt = null; m_Core.CurPipelineState.GetIBuffer(out ibuffer, out ioffset, out ifmt); if (draw != null && (draw.flags & DrawcallFlags.UseIBuffer) == 0) { ibuffer = ResourceId.Null; ioffset = 0; } ret.BufferFormats = f; ret.Strides = s; ret.Offsets = o; ret.Buffers = bs; ret.IndexFormat = new FormatElement("", 0, 0, false, false, 1, ifmt); ret.IndexBuffer = ibuffer; ret.IndexOffset = ioffset; return ret; }
public bool RemoveReplacement(ResourceId id) { return(ReplayRenderer_RemoveReplacement(m_Real, id)); }
public void ViewRawBuffer(ResourceId buff, string formatString) { if (m_Core.CurBuffers == null) return; m_FormatText = formatString; Text = "Buffer Contents"; foreach (var b in m_Core.CurBuffers) { if (b.ID == buff) { Text = b.name + " - Contents"; break; } } var elems = new List<FormatElement>(); var formatReader = new StringReader(formatString); // regex doesn't account for trailing or preceeding whitespace, or comments var regExpr = @"^(row_major\s+)?" + // row_major matrix @"(" + @"uintten|unormten" + @"|unormh|unormb" + @"|snormh|snormb" + @"|bool|byte|ubyte|short|ushort|int|uint|half|float|double" + // basic types last since they're most the most common match @")" + @"([1-9])?" + // might be a vector @"(x[1-9])?" + // or a matrix @"(\s+[A-Za-z_][A-Za-z0-9_]*)?" + // get identifier name @"(\[[0-9]+\])?" + // optional array dimension @"(\s*:\s*[A-Za-z_][A-Za-z0-9_]*)?" + // optional semantic @"$"; Regex regParser = new Regex(regExpr, RegexOptions.Compiled); bool success = true; string errors = ""; Input input = new Input(); input.Strides = new uint[] { 0 }; var text = formatReader.ReadToEnd(); text = text.Replace("{", "").Replace("}", ""); Regex c_comments = new Regex(@"/\*[^*]*\*+(?:[^*/][^*]*\*+)*/", RegexOptions.Compiled); text = c_comments.Replace(text, ""); Regex cpp_comments = new Regex(@"//.*", RegexOptions.Compiled); text = cpp_comments.Replace(text, ""); // get each line and parse it to determine the format the user wanted foreach (var l in text.Split(';')) { var line = l; line = line.Trim(); if (line == "") continue; var match = regParser.Match(line); if (!match.Success) { errors = "Couldn't parse line:\n" + line; success = false; break; } var basetype = match.Groups[2].Value; bool row_major = match.Groups[1].Success; var vectorDim = match.Groups[3].Success ? match.Groups[3].Value : "1"; var matrixDim = match.Groups[4].Success ? match.Groups[4].Value.Substring(1) : "1"; var name = match.Groups[5].Success ? match.Groups[5].Value.Trim() : "data"; var arrayDim = match.Groups[6].Success ? match.Groups[6].Value.Trim() : "[1]"; arrayDim = arrayDim.Substring(1, arrayDim.Length - 2); if(match.Groups[4].Success) { var a = vectorDim; vectorDim = matrixDim; matrixDim = a; } ResourceFormat fmt = new ResourceFormat(FormatComponentType.None, 0, 0); FormatComponentType type = FormatComponentType.Float; uint count = 0; uint arrayCount = 1; uint matrixCount = 0; uint width = 0; // calculate format { if (!uint.TryParse(vectorDim, out count)) { errors = "Invalid vector dimension on line:\n" + line; success = false; break; } if (!uint.TryParse(arrayDim, out arrayCount)) { arrayCount = 1; } arrayCount = Math.Max(0, arrayCount); if (!uint.TryParse(matrixDim, out matrixCount)) { errors = "Invalid matrix second dimension on line:\n" + line; success = false; break; } if (basetype == "bool") { type = FormatComponentType.UInt; width = 4; } else if (basetype == "byte") { type = FormatComponentType.SInt; width = 1; } else if (basetype == "ubyte") { type = FormatComponentType.UInt; width = 1; } else if (basetype == "short") { type = FormatComponentType.SInt; width = 2; } else if (basetype == "ushort") { type = FormatComponentType.UInt; width = 2; } else if (basetype == "int") { type = FormatComponentType.SInt; width = 4; } else if (basetype == "uint") { type = FormatComponentType.UInt; width = 4; } else if (basetype == "half") { type = FormatComponentType.Float; width = 2; } else if (basetype == "float") { type = FormatComponentType.Float; width = 4; } else if (basetype == "double") { type = FormatComponentType.Float; width = 8; } else if (basetype == "unormh") { type = FormatComponentType.UNorm; width = 2; } else if (basetype == "unormb") { type = FormatComponentType.UNorm; width = 1; } else if (basetype == "snormh") { type = FormatComponentType.SNorm; width = 2; } else if (basetype == "snormb") { type = FormatComponentType.SNorm; width = 1; } else if (basetype == "uintten") { fmt = new ResourceFormat(FormatComponentType.UInt, 4 * count, 1); fmt.special = true; fmt.specialFormat = SpecialFormat.R10G10B10A2; } else if (basetype == "unormten") { fmt = new ResourceFormat(FormatComponentType.UNorm, 4 * count, 1); fmt.special = true; fmt.specialFormat = SpecialFormat.R10G10B10A2; } else { errors = "Unrecognised basic type on line:\n" + line; success = false; break; } } if(fmt.compType == FormatComponentType.None) fmt = new ResourceFormat(type, count * arrayCount, width); FormatElement elem = new FormatElement(name, 0, input.Strides[0], false, row_major, matrixCount, fmt); elems.Add(elem); input.Strides[0] += elem.ByteSize; } if (!success || elems.Count == 0) { elems.Clear(); var fmt = new ResourceFormat(FormatComponentType.UInt, 4, 4); elems.Add(new FormatElement("data", 0, input.Strides[0], false, false, 1, fmt)); input.Strides[0] = elems.Last().ByteSize; } input.Buffers = new ResourceId[] { buff }; input.Offsets = new uint[] { 0 }; input.IndexBuffer = ResourceId.Null; input.BufferFormats = elems.ToArray(); input.IndexOffset = 0; m_VSIn.m_Input = input; ShowFormatSpecifier(); m_FormatSpecifier.SetErrors(errors); ClearStoredData(); m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { var contents = RT_FetchBufferContents(MeshDataStage.VSIn, r, input); this.BeginInvoke(new Action(() => { UI_SetRowsData(MeshDataStage.VSIn, contents); UI_SetColumns(MeshDataStage.VSIn, input.BufferFormats); })); }); }
public bool FreeTargetResource(ResourceId id) { return(ReplayRenderer_FreeTargetResource(m_Real, id)); }
// used for the mesh view, to get the format of the mesh input from whichever stage that // we're looking at private Input GetCurrentMeshInput(FetchDrawcall draw, MeshDataStage type) { if (!MeshView) return null; Input ret = new Input(); ret.Drawcall = draw; ret.Topology = draw.topology; ResourceId ibuffer = ResourceId.Null; ulong ioffset = 0; m_Core.CurPipelineState.GetIBuffer(out ibuffer, out ioffset); if (draw != null && (draw.flags & DrawcallFlags.UseIBuffer) == 0) { ibuffer = ResourceId.Null; ioffset = 0; } 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) { ShaderReflection details = null; if (type == MeshDataStage.VSOut) details = m_Core.CurPipelineState.GetShaderReflection(ShaderStageType.Vertex); else if (type == MeshDataStage.GSOut) { details = m_Core.CurPipelineState.GetShaderReflection(ShaderStageType.Geometry); if (details == null) details = m_Core.CurPipelineState.GetShaderReflection(ShaderStageType.Domain); } if (details == null) return null; List<FormatElement> f = new List<FormatElement>(); int posidx = -1; for (int i = 0; i < details.OutputSig.Length; i++) { var sig = details.OutputSig[i]; f.Add(new FormatElement()); f[i].buffer = 0; f[i].name = details.OutputSig[i].varName.Length > 0 ? details.OutputSig[i].varName : details.OutputSig[i].semanticIdxName; f[i].format.compByteWidth = sizeof(float); f[i].format.compCount = sig.compCount; f[i].format.compType = sig.compType; f[i].format.special = false; f[i].format.rawType = 0; f[i].perinstance = false; f[i].instancerate = 1; f[i].rowmajor = false; f[i].matrixdim = 1; f[i].systemValue = sig.systemValue; if(f[i].systemValue == SystemAttribute.Position) posidx = i; } // shift position attribute up to first, keeping order otherwise // the same if (posidx > 0) { FormatElement pos = f[posidx]; f.RemoveAt(posidx); f.Insert(0, pos); } uint offset = 0; for (int i = 0; i < details.OutputSig.Length; i++) { uint numComps = f[i].format.compCount; uint elemSize = f[i].format.compType == FormatComponentType.Double ? 8U : 4U; if (m_Core.CurPipelineState.HasAlignedPostVSData) { if (numComps == 2) offset = offset.AlignUp(2U * elemSize); else if (numComps > 2) offset = offset.AlignUp(4U * elemSize); } f[i].offset = offset; offset += numComps * elemSize; } ret.BufferFormats = f.ToArray(); ret.Strides = new uint[] { offset }; ret.Offsets = new ulong[] { 0 }; ret.Buffers = null; return ret; } BoundVBuffer[] vbs = m_Core.CurPipelineState.GetVBuffers(); ResourceId[] bs = new ResourceId[vbs.Length]; uint[] s = new uint[vbs.Length]; ulong[] o = new ulong[vbs.Length]; for (int i = 0; i < vbs.Length; i++) { bs[i] = vbs[i].Buffer; s[i] = vbs[i].ByteStride; o[i] = vbs[i].ByteOffset; } { FormatElement[] f = null; var vinputs = m_Core.CurPipelineState.GetVertexInputs(); f = new FormatElement[vinputs.Length]; ret.GenericValues = new object[vinputs.Length][]; int numinputs = vinputs.Length; int i = 0; foreach (var a in vinputs) { if (!a.Used) { numinputs--; Array.Resize(ref f, numinputs); Array.Resize(ref ret.GenericValues, numinputs); continue; } f[i] = new FormatElement(a.Name, a.VertexBuffer, a.RelativeByteOffset, a.PerInstance, a.InstanceRate, false, // row major matrix 1, // matrix dimension a.Format, false); ret.GenericValues[i] = a.GenericValue; i++; } ret.BufferFormats = f; ret.Strides = s; ret.Offsets = o; ret.Buffers = bs; } return ret; }
public ShaderVariable[] GetCBufferVariableContents(ResourceId shader, string entryPoint, UInt32 cbufslot, ResourceId buffer, UInt64 offs) { IntPtr mem = CustomMarshal.Alloc(typeof(templated_array)); IntPtr entry_mem = CustomMarshal.MakeUTF8String(entryPoint); bool success = ReplayRenderer_GetCBufferVariableContents(m_Real, shader, entry_mem, cbufslot, buffer, offs, mem); ShaderVariable[] ret = null; if (success) { ret = (ShaderVariable[])CustomMarshal.GetTemplatedArray(mem, typeof(ShaderVariable), true); } CustomMarshal.Free(entry_mem); CustomMarshal.Free(mem); return(ret); }
public void ViewRawBuffer(bool isBuffer, ResourceId id, string formatString) { if (m_Core.CurBuffers == null) return; m_FormatText = formatString; UInt64 len = 0; Text = "Buffer Contents"; foreach (var b in m_Core.CurBuffers) { if (b.ID == id) { Text = b.name + " - Contents"; len = b.byteSize; break; } } Input input = new Input(); string errors = ""; FormatElement[] elems = FormatElement.ParseFormatString(formatString, len, true, out errors); input.Strides = new uint[] { elems.Last().offset + elems.Last().ByteSize }; input.Buffers = new ResourceId[] { isBuffer ? id : ResourceId.Null, isBuffer ? ResourceId.Null : id }; input.Offsets = new ulong[] { 0 }; input.IndexBuffer = ResourceId.Null; input.BufferFormats = elems; input.IndexOffset = 0; largeBufferWarning.Visible = false; byteOffset.Enabled = false; m_VSIn.m_Input = input; ShowFormatSpecifier(); m_FormatSpecifier.SetErrors(errors); ClearStoredData(); uint byteoffset = ByteOffset; m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { if (IsDisposed) return; var contents = RT_FetchBufferContents(MeshDataStage.VSIn, r, input, byteoffset); this.BeginInvoke(new Action(() => { if (IsDisposed) return; UI_SetRowsData(MeshDataStage.VSIn, contents, 0); UI_SetColumns(MeshDataStage.VSIn, input.BufferFormats); })); }); }
private static extern bool ReplayOutput_AddThumbnail(IntPtr real, IntPtr wnd, ResourceId texID);
public FetchTexture GetTexture(ResourceId id) { if (id == ResourceId.Null) return null; for (int t = 0; t < m_Textures.Length; t++) if (m_Textures[t].ID == id) return m_Textures[t]; return null; }
public bool AddThumbnail(IntPtr wnd, ResourceId texID) { return(ReplayOutput_AddThumbnail(m_Real, wnd, texID)); }
public GoIconClickEventArgs(ResourceId i) { id = i; }
public void ViewTexture(ResourceId ID, bool focus) { if (this.InvokeRequired) { this.BeginInvoke(new Action(() => { this.ViewTexture(ID, focus); })); return; } TextureViewer_Load(null, null); if (lockedTabs.ContainsKey(ID)) { if (!lockedTabs[ID].IsDisposed && !lockedTabs[ID].IsHidden) { if (focus) Show(); lockedTabs[ID].Show(); m_Core.Renderer.BeginInvoke(RT_UpdateAndDisplay); return; } lockedTabs.Remove(ID); } for (int i = 0; i < m_Core.CurTextures.Length; i++) { if (m_Core.CurTextures[i].ID == ID) { FetchTexture current = m_Core.CurTextures[i]; var newPanel = Helpers.WrapDockContent(dockPanel, renderToolstripContainer, current.name); newPanel.DockState = DockState.Document; newPanel.AllowEndUserDocking = false; newPanel.Icon = Icon.FromHandle(global::renderdocui.Properties.Resources.page_white_link.GetHicon()); newPanel.Tag = current; newPanel.DockHandler.TabPageContextMenuStrip = tabContextMenu; newPanel.FormClosing += new FormClosingEventHandler(PreviewPanel_FormClosing); newPanel.Show(m_PreviewPanel.Pane, null); newPanel.Show(); if (focus) Show(); lockedTabs.Add(ID, newPanel); m_Core.Renderer.BeginInvoke(RT_UpdateAndDisplay); return; } } for (int i = 0; i < m_Core.CurBuffers.Length; i++) { if (m_Core.CurBuffers[i].ID == ID) { var viewer = new BufferViewer(m_Core, false); viewer.ViewRawBuffer(true, 0, ulong.MaxValue, ID); viewer.Show(DockPanel); return; } } }
public void HighlightResource(ResourceId id, string name, EventUsage[] usage) { m_HighlightResource = id; m_HighlightName = name; m_HighlightUsage = usage; panel.Invalidate(); }
private static extern bool ReplayOutput_PickPixel(IntPtr real, ResourceId texID, bool customShader, UInt32 x, UInt32 y, UInt32 sliceFace, UInt32 mip, UInt32 sample, IntPtr outval);
private void OpenResourceContextMenu(ResourceId id, bool thumbStripMenu, Control c, Point p) { var menuItems = new List<ToolStripItem>(); int i = 0; for (i = 0; i < rightclickMenu.Items.Count; i++) { menuItems.Add(rightclickMenu.Items[i]); if (rightclickMenu.Items[i] == usedStartLabel) break; menuItems[i].Visible = thumbStripMenu; } if (m_Core.CurPipelineState.SupportsBarriers) { imageInLayoutMenuItem.Visible = true; imageInLayoutMenuItem.Text = "Image is in layout " + m_Core.CurPipelineState.GetImageLayout(id); } else { imageInLayoutMenuItem.Visible = false; } if (id != ResourceId.Null) { usedSep.Visible = true; usedStartLabel.Visible = true; openNewTab.Visible = true; openNewTab.Tag = id; m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { EventUsage[] usage = r.GetUsage(id); this.BeginInvoke(new Action(() => { uint start = 0; uint end = 0; ResourceUsage us = ResourceUsage.IndexBuffer; foreach (var u in usage) { if (start == 0) { start = end = u.eventID; us = u.usage; continue; } var curDraw = m_Core.GetDrawcall(u.eventID); bool distinct = false; // if the usage is different from the last, add a new entry, // or if the previous draw link is broken. if (u.usage != us || curDraw == null || curDraw.previous == null) { distinct = true; } else { // otherwise search back through real draws, to see if the // last event was where we were - otherwise it's a new // distinct set of drawcalls and should have a separate // entry in the context menu FetchDrawcall prev = curDraw.previous; while(prev != null && prev.eventID > end) { if((prev.flags & (DrawcallFlags.Dispatch|DrawcallFlags.Drawcall|DrawcallFlags.CmdList)) == 0) { prev = prev.previous; } else { distinct = true; break; } if(prev == null) distinct = true; } } if(distinct) { AddResourceUsageEntry(menuItems, start, end, us); start = end = u.eventID; us = u.usage; } end = u.eventID; } if (start != 0) AddResourceUsageEntry(menuItems, start, end, us); rightclickMenu.Items.Clear(); rightclickMenu.Items.AddRange(menuItems.ToArray()); rightclickMenu.Show(c, p); })); }); } else { usedSep.Visible = false; usedStartLabel.Visible = false; openNewTab.Visible = false; rightclickMenu.Show(c, p); } }
private static extern bool ReplayRenderer_SetContextFilter(IntPtr real, ResourceId id, UInt32 firstDefEv, UInt32 lastDefEv);
public IABufferTag(ResourceId i, ulong offs) { id = i; offset = offs; }
public EventUsage[] GetUsage(ResourceId id) { IntPtr mem = CustomMarshal.Alloc(typeof(templated_array)); bool success = ReplayRenderer_GetUsage(m_Real, id, mem); EventUsage[] ret = null; if (success) ret = (EventUsage[])CustomMarshal.GetTemplatedArray(mem, typeof(EventUsage), true); CustomMarshal.Free(mem); return ret; }
public void OnLogfileClosed() { m_Root = null; m_HighlightResource = ResourceId.Null; m_HighlightUsage = null; panel.Invalidate(); UpdateScrollbar(1.0f, 0.0f); }
private static extern void ReplayOutput_GetCustomShaderTexID(IntPtr real, ref ResourceId texid);