Remove structure size and redundant 32-bit length field from FetchBuffer

This commit is contained in:
baldurk
2016-07-10 15:31:20 +03:00
parent b9600e6f28
commit 4268d8f58f
13 changed files with 65 additions and 76 deletions
+1 -3
View File
@@ -81,10 +81,8 @@ struct FetchBuffer
ResourceId ID;
rdctype::str name;
bool32 customName;
uint32_t length;
uint32_t structureSize;
uint32_t creationFlags;
uint64_t byteSize;
uint64_t length;
};
struct FetchTexture
+2 -4
View File
@@ -1046,12 +1046,10 @@ void Serialiser::Serialise(const char *name, FetchBuffer &el)
Serialise("", el.ID);
Serialise("", el.name);
Serialise("", el.customName);
Serialise("", el.length);
Serialise("", el.structureSize);
Serialise("", el.creationFlags);
Serialise("", el.byteSize);
Serialise("", el.length);
SIZE_CHECK(FetchBuffer, 48);
SIZE_CHECK(FetchBuffer, 40);
}
template <>
+2 -13
View File
@@ -391,11 +391,7 @@ FetchBuffer D3D11Replay::GetBuffer(ResourceId id)
it->second.m_Buffer->GetDesc(&desc);
ret.name = str;
ret.length = it->second.length;
ret.structureSize = 0;
if(desc.MiscFlags & D3D11_RESOURCE_MISC_BUFFER_STRUCTURED)
ret.structureSize = desc.StructureByteStride;
ret.byteSize = desc.ByteWidth;
ret.length = desc.ByteWidth;
ret.creationFlags = 0;
if(desc.BindFlags & D3D11_BIND_VERTEX_BUFFER)
@@ -1839,19 +1835,12 @@ ResourceId D3D11Replay::CreateProxyBuffer(const FetchBuffer &templateBuf)
ID3D11Buffer *throwaway = NULL;
D3D11_BUFFER_DESC desc;
desc.ByteWidth = (UINT)templateBuf.byteSize;
desc.ByteWidth = (UINT)templateBuf.length;
desc.CPUAccessFlags = 0;
desc.MiscFlags = 0;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
if(templateBuf.structureSize > 0)
{
desc.MiscFlags |= D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.StructureByteStride = templateBuf.structureSize;
}
if(templateBuf.creationFlags & eBufferCreate_Indirect)
{
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
+3 -5
View File
@@ -740,8 +740,6 @@ FetchBuffer GLReplay::GetBuffer(ResourceId id)
gl.glBindBuffer(res.curType, res.resource.name);
}
ret.structureSize = 0;
ret.creationFlags = 0;
switch(res.curType)
{
@@ -779,12 +777,12 @@ FetchBuffer GLReplay::GetBuffer(ResourceId id)
gl.glGetBufferParameteriv(res.curType, eGL_BUFFER_SIZE, &size);
}
ret.byteSize = ret.length = (uint32_t)size;
ret.length = size;
if(res.size == 0)
{
RDCWARN("BufferData::size didn't get filled out, setting at last minute");
res.size = ret.byteSize;
res.size = ret.length;
}
string str = "";
@@ -2991,7 +2989,7 @@ ResourceId GLReplay::CreateProxyBuffer(const FetchBuffer &templateBuf)
GLuint buf = 0;
gl.glGenBuffers(1, &buf);
gl.glBindBuffer(target, buf);
gl.glNamedBufferStorageEXT(buf, (GLsizeiptr)templateBuf.byteSize, NULL,
gl.glNamedBufferStorageEXT(buf, (GLsizeiptr)templateBuf.length, NULL,
GL_DYNAMIC_STORAGE_BIT | GL_MAP_READ_BIT);
if(templateBuf.customName)
+1 -3
View File
@@ -858,9 +858,7 @@ FetchBuffer VulkanReplay::GetBuffer(ResourceId id)
FetchBuffer ret;
ret.ID = m_pDriver->GetResourceManager()->GetOriginalID(id);
ret.byteSize = bufinfo.size;
ret.structureSize = 0;
ret.length = (uint32_t)ret.byteSize;
ret.length = bufinfo.size;
ret.creationFlags = 0;
+3 -2
View File
@@ -41,7 +41,8 @@ namespace renderdocui.Controls
public partial class ResourcePreview : UserControl
{
private string m_Name;
private UInt32 m_Width, m_Height, m_Depth, m_NumMips;
private UInt64 m_Width;
private UInt32 m_Height, m_Depth, m_NumMips;
private Core m_Core;
private ReplayOutput m_Output;
private IntPtr m_Handle;
@@ -83,7 +84,7 @@ namespace renderdocui.Controls
thumbnail.Painting = true;
}
public void Init(string Name, UInt32 Width, UInt32 Height, UInt32 Depth, UInt32 NumMips)
public void Init(string Name, UInt64 Width, UInt32 Height, UInt32 Depth, UInt32 NumMips)
{
m_Name = Name;
m_Width = Width;
+1 -3
View File
@@ -243,10 +243,8 @@ namespace renderdoc
[CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)]
public string name;
public bool customName;
public UInt32 length;
public UInt32 structureSize;
public BufferCreationFlags creationFlags;
public UInt64 byteSize;
public UInt64 length;
};
[StructLayout(LayoutKind.Sequential)]
+1 -1
View File
@@ -787,7 +787,7 @@ namespace renderdocui.Windows
if (b.ID == id)
{
Text = b.name + " - Contents";
len = b.byteSize;
len = b.length;
break;
}
}
@@ -265,7 +265,7 @@ namespace renderdocui.Windows.PipelineState
private bool HasImportantViewParams(D3D11PipelineState.ShaderStage.ResourceView view, FetchBuffer buf)
{
if (view.FirstElement > 0 || view.NumElements*view.ElementSize < buf.byteSize)
if (view.FirstElement > 0 || view.NumElements*view.ElementSize < buf.length)
return true;
return false;
@@ -345,7 +345,8 @@ namespace renderdocui.Windows.PipelineState
if (shaderInput != null && shaderInput.name.Length > 0)
slotname += ": " + shaderInput.name;
UInt32 w = 1, h = 1, d = 1;
UInt64 w = 1;
UInt32 h = 1, d = 1;
UInt32 a = 1;
string format = "Unknown";
string name = "Shader Resource " + r.Resource.ToString();
@@ -407,9 +408,9 @@ namespace renderdocui.Windows.PipelineState
typename = "Buffer";
// for structured buffers, display how many 'elements' there are in the buffer
if (bufs[t].structureSize > 0)
if (r.ElementSize > 0)
{
typename = "StructuredBuffer[" + (bufs[t].length / bufs[t].structureSize) + "]";
typename = "StructuredBuffer[" + (bufs[t].length / r.ElementSize) + "]";
}
else if (r.Flags.HasFlag(D3D11BufferViewFlags.Raw))
{
@@ -591,7 +592,7 @@ namespace renderdocui.Windows.PipelineState
)
{
string name = "Constant Buffer " + b.Buffer.ToString();
UInt32 length = 1;
UInt64 length = 1;
int numvars = shaderCBuf != null ? shaderCBuf.variables.Length : 0;
UInt32 byteSize = shaderCBuf != null ? shaderCBuf.byteSize : 0;
@@ -927,7 +928,7 @@ namespace renderdocui.Windows.PipelineState
{
string ptr = "Buffer " + state.m_IA.ibuffer.Buffer.ToString();
string name = ptr;
UInt32 length = 1;
UInt64 length = 1;
if (!ibufferUsed)
{
@@ -990,7 +991,7 @@ namespace renderdocui.Windows.PipelineState
)
{
string name = "Buffer " + v.Buffer.ToString();
UInt32 length = 1;
UInt64 length = 1;
for (int t = 0; t < bufs.Length; t++)
{
@@ -1072,7 +1073,8 @@ namespace renderdocui.Windows.PipelineState
if (shaderInput != null && shaderInput.name.Length > 0)
slotname += ": " + shaderInput.name;
UInt32 w = 1, h = 1, d = 1;
UInt64 w = 1;
UInt32 h = 1, d = 1;
UInt32 a = 1;
string format = "Unknown";
string name = "UAV " + r.Resource.ToString();
@@ -1131,9 +1133,9 @@ namespace renderdocui.Windows.PipelineState
name = bufs[t].name;
typename = "Buffer";
if (bufs[t].structureSize > 0)
if (r.ElementSize > 0)
{
typename = "RWStructuredBuffer[" + (bufs[t].length / bufs[t].structureSize) + "]";
typename = "RWStructuredBuffer[" + (bufs[t].length / r.ElementSize) + "]";
}
else if (r.Flags.HasFlag(D3D11BufferViewFlags.Raw))
{
@@ -1212,7 +1214,7 @@ namespace renderdocui.Windows.PipelineState
)
{
string name = "Buffer " + s.Buffer.ToString();
uint length = 0;
UInt64 length = 0;
if (!filledSlot)
{
@@ -1444,7 +1446,8 @@ namespace renderdocui.Windows.PipelineState
(showDisabled.Checked && !usedSlot && filledSlot) // it's bound, but not referenced, and we have "show disabled"
)
{
UInt32 w = 1, h = 1, d = 1;
UInt64 w = 1;
UInt32 h = 1, d = 1;
UInt32 a = 1;
string format = "Unknown";
string name = "UAV " + r.Resource.ToString();
@@ -1503,9 +1506,9 @@ namespace renderdocui.Windows.PipelineState
name = bufs[t].name;
typename = "Buffer";
if (bufs[t].structureSize > 0)
if (r.ElementSize > 0)
{
typename = "RWStructuredBuffer[" + (bufs[t].length / bufs[t].structureSize) + "]";
typename = "RWStructuredBuffer[" + (bufs[t].length / r.ElementSize) + "]";
}
else if (r.Flags.HasFlag(D3D11BufferViewFlags.Raw))
{
@@ -1834,8 +1837,8 @@ namespace renderdocui.Windows.PipelineState
buf.view.FirstElement * buf.view.ElementSize,
(buf.view.FirstElement + buf.view.NumElements) * buf.view.ElementSize,
buf.view.NumElements,
buf.buf.byteSize,
buf.buf.byteSize / buf.view.ElementSize);
buf.buf.length,
buf.buf.length / buf.view.ElementSize);
}
toolTip.Show(text.TrimEnd(), view, e.Location.X + Cursor.Size.Width, y);
@@ -2896,7 +2899,9 @@ namespace renderdocui.Windows.PipelineState
string name = "Empty";
string typename = "Unknown";
string format = "Unknown";
uint w = 0, h = 0, d = 0, a = 0;
UInt64 w = 1;
UInt32 h = 1, d = 1;
UInt32 a = 0;
string viewFormat = view.Format.ToString();
@@ -2934,9 +2939,9 @@ namespace renderdocui.Windows.PipelineState
typename = "Buffer";
// for structured buffers, display how many 'elements' there are in the buffer
if (bufs[t].structureSize > 0)
if (view.ElementSize > 0)
{
typename = (rw ? "RWStructuredBuffer" : "StructuredBuffer") + "[" + (bufs[t].length / bufs[t].structureSize) + "]";
typename = (rw ? "RWStructuredBuffer" : "StructuredBuffer") + "[" + (bufs[t].length / view.ElementSize) + "]";
}
else if (view.Flags.HasFlag(D3D11BufferViewFlags.Raw))
{
@@ -3033,7 +3038,7 @@ namespace renderdocui.Windows.PipelineState
foreach (var vb in ia.vbuffers)
{
string name = "Buffer " + vb.Buffer.ToString();
UInt32 length = 0;
UInt64 length = 0;
if (vb.Buffer == ResourceId.Null)
{
@@ -3065,7 +3070,7 @@ namespace renderdocui.Windows.PipelineState
writer.WriteEndElement();
string name = "Buffer " + ia.ibuffer.Buffer.ToString();
UInt32 length = 0;
UInt64 length = 0;
if (ia.ibuffer.Buffer == ResourceId.Null)
{
@@ -3259,7 +3264,7 @@ namespace renderdocui.Windows.PipelineState
shaderCBuf = sh.ShaderDetails.ConstantBlocks[i];
string name = "Constant Buffer " + sh.ConstantBuffers[i].Buffer.ToString();
UInt32 length = 1;
UInt64 length = 1;
int numvars = shaderCBuf != null ? shaderCBuf.variables.Length : 0;
UInt32 byteSize = shaderCBuf != null ? shaderCBuf.byteSize : 0;
@@ -3321,7 +3326,7 @@ namespace renderdocui.Windows.PipelineState
foreach (var o in so.Outputs)
{
string name = "Buffer " + o.Buffer.ToString();
UInt32 length = 0;
UInt64 length = 0;
if (o.Buffer == ResourceId.Null)
{
@@ -994,7 +994,7 @@ namespace renderdocui.Windows.PipelineState
{
string ptr = "Buffer " + state.m_VtxIn.ibuffer.ToString();
string name = ptr;
UInt32 length = 1;
UInt64 length = 1;
if (!ibufferUsed)
{
@@ -1057,7 +1057,7 @@ namespace renderdocui.Windows.PipelineState
)
{
string name = "Buffer " + v.Buffer.ToString();
UInt32 length = 1;
UInt64 length = 1;
if (!filledSlot)
{
@@ -2327,7 +2327,7 @@ namespace renderdocui.Windows.PipelineState
foreach (var vb in vtx.vbuffers)
{
string name = "Buffer " + vb.Buffer.ToString();
UInt32 length = 0;
UInt64 length = 0;
if (vb.Buffer == ResourceId.Null)
{
@@ -2359,7 +2359,7 @@ namespace renderdocui.Windows.PipelineState
writer.WriteEndElement();
string name = "Buffer " + vtx.ibuffer.ToString();
UInt32 length = 0;
UInt64 length = 0;
if (vtx.ibuffer == ResourceId.Null)
{
@@ -2937,7 +2937,7 @@ namespace renderdocui.Windows.PipelineState
for(int i=0; i < xfb.BufferBinding.Length; i++)
{
string name = "Buffer " + xfb.BufferBinding[i].ToString();
UInt32 length = 0;
UInt64 length = 0;
if (xfb.BufferBinding[i] == ResourceId.Null)
{
@@ -277,7 +277,7 @@ namespace renderdocui.Windows.PipelineState
private bool HasImportantViewParams(VulkanPipelineState.Pipeline.DescriptorSet.DescriptorBinding.BindingElement view, FetchBuffer buf)
{
if (view.offset > 0 || view.size < buf.byteSize)
if (view.offset > 0 || view.size < buf.length)
return true;
return false;
@@ -566,8 +566,8 @@ namespace renderdocui.Windows.PipelineState
{
if (bufs[t].ID == descriptorBind.res)
{
len = bufs[t].byteSize;
w = bufs[t].length;
len = bufs[t].length;
w = 0;
h = 0;
d = 0;
a = 0;
@@ -1303,7 +1303,7 @@ namespace renderdocui.Windows.PipelineState
{
string ptr = "Buffer " + state.IA.ibuffer.buf.ToString();
string name = ptr;
UInt32 length = 1;
UInt64 length = 1;
if (!ibufferUsed)
{
@@ -1376,7 +1376,7 @@ namespace renderdocui.Windows.PipelineState
{
string name = "No Buffer";
string rate = "-";
UInt32 length = 1;
UInt64 length = 1;
UInt64 offset = 0;
UInt32 stride = 0;
@@ -1879,7 +1879,7 @@ namespace renderdocui.Windows.PipelineState
{
text += String.Format("The view covers bytes {0}-{1}.\nThe buffer is {3} bytes in length.",
buf.offset, buf.size,
m_Core.GetBuffer(buf.ID).byteSize);
m_Core.GetBuffer(buf.ID).length);
}
toolTip.Show(text.TrimEnd(), treeview, e.Location.X + Cursor.Size.Width, y);
@@ -2544,7 +2544,7 @@ namespace renderdocui.Windows.PipelineState
if (ib != null)
{
name = ib.name;
length = ib.byteSize;
length = ib.length;
}
string ifmt = "UNKNOWN";
@@ -2616,7 +2616,7 @@ namespace renderdocui.Windows.PipelineState
if(buf != null)
{
name = buf.name;
length = buf.byteSize;
length = buf.length;
}
}
@@ -2777,7 +2777,9 @@ namespace renderdocui.Windows.PipelineState
if (name == "")
name = "Resource " + descriptorBind.res.ToString();
uint w = 0, h = 0, d = 0, arr = 0;
UInt64 w = 1;
UInt32 h = 1, d = 1;
UInt32 arr = 0;
string format = "Unknown";
string viewParams = "";
@@ -2893,7 +2895,9 @@ namespace renderdocui.Windows.PipelineState
if (name == "")
name = "Resource " + descriptorBind.res.ToString();
uint w = 0, h = 0, d = 0, arr = 0;
UInt64 w = 1;
UInt32 h = 1, d = 1;
UInt32 arr = 0;
string format = "Unknown";
string viewParams = "";
+3 -3
View File
@@ -686,12 +686,12 @@ namespace renderdocui.Windows
ulong BufBytes = 0;
foreach (var b in m_Core.CurBuffers)
{
BufBytes += b.byteSize;
BufBytes += b.length;
if ((b.creationFlags & BufferCreationFlags.IB) != 0)
IBBytes += b.byteSize;
IBBytes += b.length;
if ((b.creationFlags & BufferCreationFlags.VB) != 0)
VBBytes += b.byteSize;
VBBytes += b.length;
}
ulong RTBytes = 0;
+1 -1
View File
@@ -1195,7 +1195,7 @@ namespace renderdocui.Windows
if (fullname.Length == 0)
fullname = buf.name;
prev.Init(fullname, buf.length, 0, 0, Math.Max(1, buf.structureSize));
prev.Init(fullname, buf.length, 0, 0, 1);
IntPtr handle = prev.ThumbnailHandle;
m_Core.Renderer.BeginInvoke((ReplayRenderer rep) =>
{