Store index format and topology in drawcall, to accommodate GL

* D3D11 just latches the state from the input assembler state into the
  drawcall when it's being added. GL stores the state per-draw.
This commit is contained in:
baldurk
2015-01-15 17:17:12 +00:00
parent b9f1b9820f
commit f013f6fd29
19 changed files with 190 additions and 262 deletions
+1 -4
View File
@@ -30,7 +30,7 @@ struct D3D11PipelineState
struct InputAssembler
{
InputAssembler() : Bytecode(NULL), Topology(eTopology_Unknown) {}
InputAssembler() : Bytecode(NULL) {}
struct LayoutInput
{
@@ -60,11 +60,8 @@ struct D3D11PipelineState
{
IndexBuffer() : Buffer(), Offset(0) {}
ResourceId Buffer;
ResourceFormat Format;
uint32_t Offset;
} ibuffer;
PrimitiveTopology Topology;
} m_IA;
struct ShaderStage
+5
View File
@@ -166,6 +166,8 @@ struct FetchDrawcall
indexOffset = 0;
vertexOffset = 0;
instanceOffset = 0;
topology = eTopology_Unknown;
indexByteWidth = 0;
flags = 0;
context = ResourceId();
duration = -1.0f;
@@ -187,6 +189,9 @@ struct FetchDrawcall
uint32_t indexOffset;
uint32_t vertexOffset;
uint32_t instanceOffset;
uint32_t indexByteWidth;
PrimitiveTopology topology;
ResourceId context;
+2 -10
View File
@@ -30,7 +30,7 @@ struct GLPipelineState
struct VertexInput
{
VertexInput() : Topology(eTopology_Unknown) {}
VertexInput() {}
struct VertexAttribute
{
@@ -53,15 +53,7 @@ struct GLPipelineState
};
rdctype::array<VertexBuffer> vbuffers;
struct IndexBuffer
{
IndexBuffer() : Buffer(), Offset(0) {}
ResourceId Buffer;
ResourceFormat Format;
uint32_t Offset;
} ibuffer;
PrimitiveTopology Topology;
ResourceId ibuffer;
} m_VtxIn;
struct ShaderStage
+3 -11
View File
@@ -107,10 +107,8 @@ void Serialiser::Serialise(const char *name, D3D11PipelineState::InputAssembler:
template<>
void Serialiser::Serialise(const char *name, D3D11PipelineState::InputAssembler &el)
{
Serialise("", el.Topology);
Serialise("", el.ibuffer.Buffer);
Serialise("", el.ibuffer.Offset);
Serialise("", el.ibuffer.Format);
Serialise("", el.vbuffers);
Serialise("", el.layouts);
@@ -290,21 +288,12 @@ void Serialiser::Serialise(const char *name, GLPipelineState::VertexInput::Verte
Serialise("", el.Stride);
}
template<>
void Serialiser::Serialise(const char *name, GLPipelineState::VertexInput::IndexBuffer &el)
{
Serialise("", el.Buffer);
Serialise("", el.Offset);
Serialise("", el.Format);
}
template<>
void Serialiser::Serialise(const char *name, GLPipelineState::VertexInput &el)
{
Serialise("", el.attributes);
Serialise("", el.ibuffer);
Serialise("", el.vbuffers);
Serialise("", el.Topology);
}
template<>
@@ -507,6 +496,9 @@ void Serialiser::Serialise(const char *name, FetchDrawcall &el)
Serialise("", el.vertexOffset);
Serialise("", el.instanceOffset);
Serialise("", el.indexByteWidth);
Serialise("", el.topology);
Serialise("", el.context);
Serialise("", el.duration);
+8
View File
@@ -1062,6 +1062,14 @@ void WrappedID3D11DeviceContext::AddDrawcall(FetchDrawcall d, bool hasEvents)
draw.eventID = m_CurEventID;
draw.drawcallID = m_CurDrawcallID;
draw.indexByteWidth = 0;
if(m_CurrentPipelineState->IA.IndexFormat == DXGI_FORMAT_R16_UINT)
draw.indexByteWidth = 2;
if(m_CurrentPipelineState->IA.IndexFormat == DXGI_FORMAT_R32_UINT)
draw.indexByteWidth = 4;
draw.topology = MakePrimitiveTopology(m_CurrentPipelineState->IA.Topo);
for(int i=0; i < D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT; i++)
{
draw.outputs[i] = ResourceId();
-3
View File
@@ -416,8 +416,6 @@ D3D11PipelineState D3D11Replay::MakePipelineState()
/////////////////////////////////////////////////
// Input Assembler
/////////////////////////////////////////////////
ret.m_IA.Topology = MakePrimitiveTopology(rs->IA.Topo);
D3D11ResourceManager *rm = m_pDevice->GetResourceManager();
@@ -458,7 +456,6 @@ D3D11PipelineState D3D11Replay::MakePipelineState()
}
ret.m_IA.ibuffer.Buffer = rm->GetOriginalID(GetIDForResource(rs->IA.IndexBuffer));
ret.m_IA.ibuffer.Format = MakeResourceFormat(rs->IA.IndexFormat);
ret.m_IA.ibuffer.Offset = rs->IA.IndexOffset;
/////////////////////////////////////////////////
+25
View File
@@ -593,6 +593,31 @@ ResourceFormat MakeResourceFormat(WrappedOpenGL &gl, GLenum target, GLenum fmt)
return ret;
}
PrimitiveTopology MakePrimitiveTopology(const GLHookSet &gl, GLenum Topo)
{
switch(Topo)
{
default: return eTopology_Unknown;
case eGL_POINTS: return eTopology_PointList;
case eGL_LINE_STRIP: return eTopology_LineStrip;
case eGL_LINE_LOOP: return eTopology_LineLoop;
case eGL_LINES: return eTopology_LineList;
case eGL_LINE_STRIP_ADJACENCY: return eTopology_LineStrip_Adj;
case eGL_LINES_ADJACENCY: return eTopology_LineList_Adj;
case eGL_TRIANGLE_STRIP: return eTopology_TriangleStrip;
case eGL_TRIANGLE_FAN: return eTopology_TriangleFan;
case eGL_TRIANGLES: return eTopology_TriangleList;
case eGL_TRIANGLE_STRIP_ADJACENCY: return eTopology_TriangleStrip_Adj;
case eGL_TRIANGLES_ADJACENCY: return eTopology_TriangleList_Adj;
case eGL_PATCHES:
{
GLint patchCount = 3;
gl.glGetIntegerv(eGL_PATCH_VERTICES, &patchCount);
return PrimitiveTopology(eTopology_PatchList_1CPs+patchCount);
}
}
}
template<const bool CopyUniforms, const bool SerialiseUniforms>
static void ForAllProgramUniforms(const GLHookSet &gl, Serialiser *ser, GLuint progSrc, GLuint progDst, map<GLint, GLint> *locTranslate, bool writing)
{
+1
View File
@@ -86,6 +86,7 @@ GLenum ShaderEnum(size_t idx);
ResourceFormat MakeResourceFormat(WrappedOpenGL &gl, GLenum target, GLenum fmt);
GLenum MakeGLFormat(WrappedOpenGL &gl, GLenum target, ResourceFormat fmt);
PrimitiveTopology MakePrimitiveTopology(const GLHookSet &gl, GLenum Topo);
GLuint GetBoundVertexBuffer(const GLHookSet &gl, GLuint idx);
-4
View File
@@ -674,10 +674,6 @@ WrappedOpenGL::WrappedOpenGL(const char *logfile, const GLHookSet &funcs)
m_ActiveConditional = false;
m_ActiveFeedback = false;
m_LastIndexSize = eGL_NONE;
m_LastIndexOffset = 0;
m_LastDrawMode = eGL_NONE;
m_DisplayListRecord = NULL;
#if defined(RELEASE)
-4
View File
@@ -166,10 +166,6 @@ class WrappedOpenGL
list<DrawcallTreeNode *> m_DrawcallStack;
GLenum m_LastIndexSize;
GLuint m_LastIndexOffset;
GLenum m_LastDrawMode;
// buffer used
vector<byte> m_ScratchBuf;
+1 -73
View File
@@ -837,35 +837,11 @@ void GLReplay::SavePipelineState()
// Index buffer
pipe.m_VtxIn.ibuffer.Offset = m_pDriver->m_LastIndexOffset;
pipe.m_VtxIn.ibuffer.Format = ResourceFormat();
pipe.m_VtxIn.ibuffer.Format.special = false;
pipe.m_VtxIn.ibuffer.Format.compCount = 1;
pipe.m_VtxIn.ibuffer.Format.compType = eCompType_UInt;
switch(m_pDriver->m_LastIndexSize)
{
default:
break;
case eGL_UNSIGNED_BYTE:
pipe.m_VtxIn.ibuffer.Format.compByteWidth = 1;
pipe.m_VtxIn.ibuffer.Format.strname = "GL_UNSIGNED_BYTE";
break;
case eGL_UNSIGNED_SHORT:
pipe.m_VtxIn.ibuffer.Format.compByteWidth = 2;
pipe.m_VtxIn.ibuffer.Format.strname = "GL_UNSIGNED_SHORT";
break;
case eGL_UNSIGNED_INT:
pipe.m_VtxIn.ibuffer.Format.compByteWidth = 4;
pipe.m_VtxIn.ibuffer.Format.strname = "GL_UNSIGNED_INT";
break;
}
void *ctx = m_ReplayCtx.ctx;
GLuint ibuffer = 0;
gl.glGetIntegerv(eGL_ELEMENT_ARRAY_BUFFER_BINDING, (GLint*)&ibuffer);
pipe.m_VtxIn.ibuffer.Buffer = rm->GetOriginalID(rm->GetID(BufferRes(ctx, ibuffer)));
pipe.m_VtxIn.ibuffer = rm->GetOriginalID(rm->GetID(BufferRes(ctx, ibuffer)));
// Vertex buffers and attributes
GLint numVBufferBindings = 16;
@@ -1012,54 +988,6 @@ void GLReplay::SavePipelineState()
pipe.m_VtxIn.attributes[i].Format = fmt;
}
switch(m_pDriver->m_LastDrawMode)
{
default:
pipe.m_VtxIn.Topology = eTopology_Unknown;
break;
case eGL_POINTS:
pipe.m_VtxIn.Topology = eTopology_PointList;
break;
case eGL_LINE_STRIP:
pipe.m_VtxIn.Topology = eTopology_LineStrip;
break;
case eGL_LINE_LOOP:
pipe.m_VtxIn.Topology = eTopology_LineLoop;
break;
case eGL_LINES:
pipe.m_VtxIn.Topology = eTopology_LineList;
break;
case eGL_LINE_STRIP_ADJACENCY:
pipe.m_VtxIn.Topology = eTopology_LineStrip_Adj;
break;
case eGL_LINES_ADJACENCY:
pipe.m_VtxIn.Topology = eTopology_LineList_Adj;
break;
case eGL_TRIANGLE_STRIP:
pipe.m_VtxIn.Topology = eTopology_TriangleStrip;
break;
case eGL_TRIANGLE_FAN:
pipe.m_VtxIn.Topology = eTopology_TriangleFan;
break;
case eGL_TRIANGLES:
pipe.m_VtxIn.Topology = eTopology_TriangleList;
break;
case eGL_TRIANGLE_STRIP_ADJACENCY:
pipe.m_VtxIn.Topology = eTopology_TriangleStrip_Adj;
break;
case eGL_TRIANGLES_ADJACENCY:
pipe.m_VtxIn.Topology = eTopology_TriangleList_Adj;
break;
case eGL_PATCHES:
{
GLint patchCount = 3;
gl.glGetIntegerv(eGL_PATCH_VERTICES, &patchCount);
pipe.m_VtxIn.Topology = PrimitiveTopology(eTopology_PatchList_1CPs+patchCount);
break;
}
}
// Shader stages & Textures
GLint numTexUnits = 8;
+95 -75
View File
@@ -275,12 +275,12 @@ bool WrappedOpenGL::Serialise_glDrawTransformFeedback(GLenum mode, GLuint id)
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
return true;
}
@@ -329,12 +329,12 @@ bool WrappedOpenGL::Serialise_glDrawTransformFeedbackInstanced(GLenum mode, GLui
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
return true;
}
@@ -383,12 +383,12 @@ bool WrappedOpenGL::Serialise_glDrawTransformFeedbackStream(GLenum mode, GLuint
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
return true;
}
@@ -438,12 +438,12 @@ bool WrappedOpenGL::Serialise_glDrawTransformFeedbackStreamInstanced(GLenum mode
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
return true;
}
@@ -494,11 +494,11 @@ bool WrappedOpenGL::Serialise_glDrawArrays(GLenum mode, GLint first, GLsizei cou
draw.flags |= eDraw_Drawcall;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
return true;
}
@@ -550,12 +550,12 @@ bool WrappedOpenGL::Serialise_glDrawArraysIndirect(GLenum mode, const void *indi
draw.instanceOffset = params.baseInstance;
draw.flags |= eDraw_Drawcall|eDraw_Instanced|eDraw_Indirect;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
return true;
}
@@ -606,12 +606,12 @@ bool WrappedOpenGL::Serialise_glDrawArraysInstanced(GLenum mode, GLint first, GL
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall|eDraw_Instanced;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
return true;
}
@@ -664,12 +664,12 @@ bool WrappedOpenGL::Serialise_glDrawArraysInstancedBaseInstance(GLenum mode, GLi
draw.instanceOffset = BaseInstance;
draw.flags |= eDraw_Drawcall|eDraw_Instanced;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
return true;
}
@@ -725,14 +725,13 @@ bool WrappedOpenGL::Serialise_glDrawElements(GLenum mode, GLsizei count, GLenum
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
m_LastIndexSize = Type;
m_LastIndexOffset = (GLuint)IdxOffset;
return true;
}
@@ -787,18 +786,18 @@ bool WrappedOpenGL::Serialise_glDrawElementsIndirect(GLenum mode, GLenum type, c
draw.name = name;
draw.numIndices = params.count;
draw.numInstances = params.instanceCount;
draw.indexOffset = params.firstIndex*IdxSize;
draw.indexOffset = params.firstIndex;
draw.vertexOffset = params.baseVertex;
draw.instanceOffset = params.baseInstance;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer|eDraw_Instanced|eDraw_Indirect;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
m_LastIndexSize = Type;
return true;
}
@@ -856,14 +855,13 @@ bool WrappedOpenGL::Serialise_glDrawRangeElements(GLenum mode, GLuint start, GLu
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
m_LastIndexSize = Type;
m_LastIndexOffset = (GLuint)IdxOffset;
return true;
}
@@ -923,14 +921,13 @@ bool WrappedOpenGL::Serialise_glDrawRangeElementsBaseVertex(GLenum mode, GLuint
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
m_LastIndexSize = Type;
m_LastIndexOffset = (GLuint)IdxOffset;
return true;
}
@@ -988,14 +985,13 @@ bool WrappedOpenGL::Serialise_glDrawElementsBaseVertex(GLenum mode, GLsizei coun
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
m_LastIndexSize = Type;
m_LastIndexOffset = (GLuint)IdxOffset;
return true;
}
@@ -1053,14 +1049,13 @@ bool WrappedOpenGL::Serialise_glDrawElementsInstanced(GLenum mode, GLsizei count
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
m_LastIndexSize = Type;
m_LastIndexOffset = (GLuint)IdxOffset;
return true;
}
@@ -1120,14 +1115,13 @@ bool WrappedOpenGL::Serialise_glDrawElementsInstancedBaseInstance(GLenum mode, G
draw.instanceOffset = BaseInstance;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
m_LastIndexSize = Type;
m_LastIndexOffset = (GLuint)IdxOffset;
return true;
}
@@ -1187,14 +1181,13 @@ bool WrappedOpenGL::Serialise_glDrawElementsInstancedBaseVertex(GLenum mode, GLs
draw.instanceOffset = 0;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
m_LastIndexSize = Type;
m_LastIndexOffset = (GLuint)IdxOffset;
return true;
}
@@ -1256,14 +1249,13 @@ bool WrappedOpenGL::Serialise_glDrawElementsInstancedBaseVertexBaseInstance(GLen
draw.instanceOffset = BaseInstance;
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddDrawcall(draw, true);
}
m_LastDrawMode = Mode;
m_LastIndexSize = Type;
m_LastIndexOffset = (GLuint)IdxOffset;
return true;
}
@@ -1346,6 +1338,8 @@ bool WrappedOpenGL::Serialise_glMultiDrawArrays(GLenum mode, const GLint *first,
draw.name = name;
draw.flags |= eDraw_MultiDraw;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddDrawcall(draw, false);
m_DrawcallStack.push_back(&m_DrawcallStack.back()->children.back());
@@ -1363,6 +1357,8 @@ bool WrappedOpenGL::Serialise_glMultiDrawArrays(GLenum mode, const GLint *first,
ToStr::Get(draw.vertexOffset) + ")";
draw.flags |= eDraw_Drawcall;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddEvent(MULTI_DRAWARRAYS, desc);
AddDrawcall(draw, true);
@@ -1377,8 +1373,6 @@ bool WrappedOpenGL::Serialise_glMultiDrawArrays(GLenum mode, const GLint *first,
m_CurEventID += Count+1;
}
m_LastDrawMode = Mode;
SAFE_DELETE_ARRAY(firstArray);
SAFE_DELETE_ARRAY(countArray);
@@ -1487,6 +1481,8 @@ bool WrappedOpenGL::Serialise_glMultiDrawElements(GLenum mode, const GLsizei *co
draw.name = name;
draw.flags |= eDraw_MultiDraw;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddDrawcall(draw, false);
@@ -1506,6 +1502,8 @@ bool WrappedOpenGL::Serialise_glMultiDrawElements(GLenum mode, const GLsizei *co
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddEvent(MULTI_DRAWELEMENTS, desc);
AddDrawcall(draw, true);
@@ -1519,8 +1517,6 @@ bool WrappedOpenGL::Serialise_glMultiDrawElements(GLenum mode, const GLsizei *co
m_CurEventID += Count+1;
}
m_LastDrawMode = Mode;
SAFE_DELETE_ARRAY(countArray);
SAFE_DELETE_ARRAY(idxOffsArray);
@@ -1626,10 +1622,18 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsBaseVertex(GLenum mode, const G
ToStr::Get(Type) + "," +
ToStr::Get(Count) + ")";
uint32_t IdxSize =
Type == eGL_UNSIGNED_BYTE ? 1
: Type == eGL_UNSIGNED_SHORT ? 2
: /*Type == eGL_UNSIGNED_INT*/ 4;
FetchDrawcall draw;
draw.name = name;
draw.flags |= eDraw_MultiDraw;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddDrawcall(draw, false);
@@ -1651,6 +1655,9 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsBaseVertex(GLenum mode, const G
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddEvent(MULTI_DRAWELEMENTSBASEVERTEX, desc);
AddDrawcall(draw, true);
@@ -1663,9 +1670,6 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsBaseVertex(GLenum mode, const G
{
m_CurEventID += Count+1;
}
m_LastIndexSize = Type;
m_LastDrawMode = Mode;
SAFE_DELETE_ARRAY(countArray);
SAFE_DELETE_ARRAY(baseArray);
@@ -1764,6 +1768,8 @@ bool WrappedOpenGL::Serialise_glMultiDrawArraysIndirect(GLenum mode, const void
draw.flags |= eDraw_MultiDraw;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddDrawcall(draw, false);
m_DrawcallStack.push_back(&m_DrawcallStack.back()->children.back());
@@ -1796,6 +1802,8 @@ bool WrappedOpenGL::Serialise_glMultiDrawArraysIndirect(GLenum mode, const void
ToStr::Get(draw.instanceOffset) + ">)";
draw.flags |= eDraw_Drawcall|eDraw_Instanced|eDraw_Indirect;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddEvent(MULTI_DRAWARRAYS_INDIRECT, desc);
AddDrawcall(draw, true);
@@ -1810,8 +1818,6 @@ bool WrappedOpenGL::Serialise_glMultiDrawArraysIndirect(GLenum mode, const void
m_CurEventID += Count+1;
}
m_LastDrawMode = Mode;
return true;
}
@@ -1893,8 +1899,6 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirect(GLenum mode, GLenum ty
m_Real.glDrawElementsInstancedBaseVertexBaseInstance(Mode, params.count, Type, (const void *)ptrdiff_t(params.firstIndex*IdxSize),
params.instanceCount, params.baseVertex, params.baseInstance);
m_LastIndexOffset = (GLuint)(params.firstIndex*IdxSize);
}
}
@@ -1909,10 +1913,18 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirect(GLenum mode, GLenum ty
ToStr::Get(Type) + "," +
ToStr::Get(Count) + ")";
uint32_t IdxSize =
Type == eGL_UNSIGNED_BYTE ? 1
: Type == eGL_UNSIGNED_SHORT ? 2
: /*Type == eGL_UNSIGNED_INT*/ 4;
FetchDrawcall draw;
draw.name = name;
draw.flags |= eDraw_MultiDraw;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddDrawcall(draw, false);
@@ -1936,7 +1948,7 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirect(GLenum mode, GLenum ty
FetchDrawcall draw;
draw.numIndices = params.count;
draw.numInstances = params.instanceCount;
draw.indexOffset = params.firstIndex*IdxSize;
draw.indexOffset = params.firstIndex;
draw.vertexOffset = params.baseVertex;
draw.instanceOffset = params.baseInstance;
@@ -1947,6 +1959,9 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirect(GLenum mode, GLenum ty
ToStr::Get(draw.instanceOffset) + ">)";
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer|eDraw_Instanced|eDraw_Indirect;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddEvent(MULTI_DRAWELEMENTS_INDIRECT, desc);
AddDrawcall(draw, true);
@@ -1961,9 +1976,6 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirect(GLenum mode, GLenum ty
m_CurEventID += Count+1;
}
m_LastIndexSize = Type;
m_LastDrawMode = Mode;
return true;
}
@@ -2068,6 +2080,8 @@ bool WrappedOpenGL::Serialise_glMultiDrawArraysIndirectCountARB(GLenum mode, GLi
draw.flags |= eDraw_MultiDraw;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddDrawcall(draw, false);
m_DrawcallStack.push_back(&m_DrawcallStack.back()->children.back());
@@ -2100,6 +2114,8 @@ bool WrappedOpenGL::Serialise_glMultiDrawArraysIndirectCountARB(GLenum mode, GLi
ToStr::Get(draw.instanceOffset) + ">)";
draw.flags |= eDraw_Drawcall|eDraw_Instanced|eDraw_Indirect;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
AddEvent(MULTI_DRAWARRAYS_INDIRECT, desc);
AddDrawcall(draw, true);
@@ -2114,8 +2130,6 @@ bool WrappedOpenGL::Serialise_glMultiDrawArraysIndirectCountARB(GLenum mode, GLi
m_CurEventID += realdrawcount+1;
}
m_LastDrawMode = Mode;
return true;
}
@@ -2208,8 +2222,6 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirectCountARB(GLenum mode, G
m_Real.glDrawElementsInstancedBaseVertexBaseInstance(Mode, params.count, Type, (const void *)ptrdiff_t(params.firstIndex*IdxSize),
params.instanceCount, params.baseVertex, params.baseInstance);
m_LastIndexOffset = (GLuint)(params.firstIndex*IdxSize);
}
}
@@ -2225,10 +2237,18 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirectCountARB(GLenum mode, G
ToStr::Get(realdrawcount) + ">, " +
ToStr::Get(MaxCount) + ")";
uint32_t IdxSize =
Type == eGL_UNSIGNED_BYTE ? 1
: Type == eGL_UNSIGNED_SHORT ? 2
: /*Type == eGL_UNSIGNED_INT*/ 4;
FetchDrawcall draw;
draw.name = name;
draw.flags |= eDraw_MultiDraw;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddDrawcall(draw, false);
@@ -2252,7 +2272,7 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirectCountARB(GLenum mode, G
FetchDrawcall draw;
draw.numIndices = params.count;
draw.numInstances = params.instanceCount;
draw.indexOffset = params.firstIndex*IdxSize;
draw.indexOffset = params.firstIndex;
draw.vertexOffset = params.baseVertex;
draw.instanceOffset = params.baseInstance;
@@ -2263,6 +2283,9 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirectCountARB(GLenum mode, G
ToStr::Get(draw.instanceOffset) + ")";
draw.flags |= eDraw_Drawcall|eDraw_UseIBuffer|eDraw_Instanced|eDraw_Indirect;
draw.topology = MakePrimitiveTopology(m_Real, Mode);
draw.indexByteWidth = IdxSize;
AddEvent(MULTI_DRAWELEMENTS_INDIRECT, desc);
AddDrawcall(draw, true);
@@ -2277,9 +2300,6 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirectCountARB(GLenum mode, G
m_CurEventID += realdrawcount+1;
}
m_LastIndexSize = Type;
m_LastDrawMode = Mode;
return true;
}
+3 -23
View File
@@ -90,23 +90,6 @@ namespace renderdocui.Code
}
}
public PrimitiveTopology DrawTopology
{
get
{
if (LogLoaded)
{
if (IsLogD3D11)
return m_D3D11.m_IA.Topology;
if (IsLogGL)
return m_GL.m_VtxIn.Topology;
}
return PrimitiveTopology.Unknown;
}
}
// there's a lot of redundancy in these functions
public ShaderBindpointMapping GetBindpointMapping(ShaderStageType stage)
@@ -241,7 +224,7 @@ namespace renderdocui.Code
return "";
}
public void GetIBuffer(out ResourceId buf, out uint ByteOffset, out ResourceFormat IndexFormat)
public void GetIBuffer(out ResourceId buf, out uint ByteOffset)
{
if (LogLoaded)
{
@@ -249,15 +232,13 @@ namespace renderdocui.Code
{
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;
buf = m_GL.m_VtxIn.ibuffer;
ByteOffset = 0; // GL only has per-draw index offset
return;
}
@@ -265,7 +246,6 @@ namespace renderdocui.Code
buf = ResourceId.Null;
ByteOffset = 0;
IndexFormat = new ResourceFormat(FormatComponentType.UInt, 1, 2);
}
public struct VBuffer
@@ -77,14 +77,10 @@ namespace renderdoc
public class IndexBuffer
{
public ResourceId Buffer;
[CustomMarshalAs(CustomUnmanagedType.CustomClass)]
public ResourceFormat Format;
public UInt32 Offset;
};
[CustomMarshalAs(CustomUnmanagedType.CustomClass)]
public IndexBuffer ibuffer;
public PrimitiveTopology Topology;
};
[CustomMarshalAs(CustomUnmanagedType.CustomClass)]
public InputAssembler m_IA;
+3
View File
@@ -329,6 +329,9 @@ namespace renderdoc
public UInt32 vertexOffset;
public UInt32 instanceOffset;
public UInt32 indexByteWidth;
public PrimitiveTopology topology;
public ResourceId context;
public double duration;
+1 -12
View File
@@ -57,18 +57,7 @@ namespace renderdoc
[CustomMarshalAs(CustomUnmanagedType.TemplatedArray)]
public VertexBuffer[] vbuffers;
[StructLayout(LayoutKind.Sequential)]
public class IndexBuffer
{
public ResourceId Buffer;
[CustomMarshalAs(CustomUnmanagedType.CustomClass)]
public ResourceFormat Format;
public UInt32 Offset;
};
[CustomMarshalAs(CustomUnmanagedType.CustomClass)]
public IndexBuffer ibuffer;
public PrimitiveTopology Topology;
public ResourceId ibuffer;
};
[CustomMarshalAs(CustomUnmanagedType.CustomClass)]
public VertexInputs m_VtxIn;
+19 -22
View File
@@ -74,7 +74,6 @@ namespace renderdocui.Windows
public FetchDrawcall Drawcall = null;
public FormatElement IndexFormat = new FormatElement();
public ResourceId IndexBuffer = ResourceId.Null;
public uint IndexOffset = 0;
}
@@ -697,13 +696,12 @@ namespace renderdocui.Windows
FormatElement[] f = null;
Input ret = new Input();
ret.Drawcall = draw;
ret.Topology = m_Core.CurPipelineState.DrawTopology;
ret.Topology = draw.topology;
ResourceId ibuffer = ResourceId.Null;
uint ioffset = 0;
ResourceFormat ifmt = null;
m_Core.CurPipelineState.GetIBuffer(out ibuffer, out ioffset, out ifmt);
m_Core.CurPipelineState.GetIBuffer(out ibuffer, out ioffset);
if (draw != null && (draw.flags & DrawcallFlags.UseIBuffer) == 0)
{
@@ -711,7 +709,6 @@ namespace renderdocui.Windows
ioffset = 0;
}
ret.IndexFormat = new FormatElement("", 0, 0, false, false, 1, ifmt, false);
ret.IndexBuffer = ibuffer;
ret.IndexOffset = ioffset;
@@ -872,12 +869,12 @@ namespace renderdocui.Windows
ret.IndexCount = input.Drawcall.numIndices;
byte[] rawidxs = r.GetBufferData(input.IndexBuffer,
input.IndexOffset + input.Drawcall.indexOffset * input.IndexFormat.format.compByteWidth,
ret.IndexCount * input.IndexFormat.format.compByteWidth);
input.IndexOffset + input.Drawcall.indexOffset * input.Drawcall.indexByteWidth,
ret.IndexCount * input.Drawcall.indexByteWidth);
ret.Indices = new uint[rawidxs.Length / input.IndexFormat.format.compByteWidth];
ret.Indices = new uint[rawidxs.Length / input.Drawcall.indexByteWidth];
if (input.IndexFormat.format.compByteWidth == 2)
if (input.Drawcall.indexByteWidth == 2)
{
ushort[] tmp = new ushort[rawidxs.Length / 2];
@@ -888,7 +885,7 @@ namespace renderdocui.Windows
ret.Indices[i] = tmp[i];
}
}
else if (input.IndexFormat.format.compByteWidth == 4)
else if (input.Drawcall.indexByteWidth == 4)
{
Buffer.BlockCopy(rawidxs, 0, ret.Indices, 0, rawidxs.Length);
}
@@ -896,9 +893,9 @@ namespace renderdocui.Windows
uint minIndex = ret.Indices.Length > 0 ? ret.Indices[0] : 0;
foreach (var i in ret.Indices)
{
if (input.IndexFormat.format.compByteWidth == 2 && i == UInt16.MaxValue)
if (input.Drawcall.indexByteWidth == 2 && i == UInt16.MaxValue)
continue;
if (input.IndexFormat.format.compByteWidth == 4 && i == UInt32.MaxValue)
if (input.Drawcall.indexByteWidth == 4 && i == UInt32.MaxValue)
continue;
minIndex = Math.Min(minIndex, i);
@@ -921,18 +918,18 @@ namespace renderdocui.Windows
input.IndexBuffer != ResourceId.Null)
{
byte[] rawidxs = r.GetBufferData(input.IndexBuffer,
input.IndexOffset + input.Drawcall.indexOffset * input.IndexFormat.format.compByteWidth,
ret.IndexCount * input.IndexFormat.format.compByteWidth);
input.IndexOffset + input.Drawcall.indexOffset * input.Drawcall.indexByteWidth,
ret.IndexCount * input.Drawcall.indexByteWidth);
if (input.IndexFormat.format.compByteWidth == 0)
if (input.Drawcall.indexByteWidth == 0)
{
ret.Indices = new uint[0];
}
else
{
ret.Indices = new uint[rawidxs.Length / input.IndexFormat.format.compByteWidth];
ret.Indices = new uint[rawidxs.Length / input.Drawcall.indexByteWidth];
if (input.IndexFormat.format.compByteWidth == 2)
if (input.Drawcall.indexByteWidth == 2)
{
ushort[] tmp = new ushort[rawidxs.Length / 2];
@@ -943,7 +940,7 @@ namespace renderdocui.Windows
ret.Indices[i] = tmp[i];
}
}
else if (input.IndexFormat.format.compByteWidth == 4)
else if (input.Drawcall.indexByteWidth == 4)
{
Buffer.BlockCopy(rawidxs, 0, ret.Indices, 0, rawidxs.Length);
}
@@ -952,9 +949,9 @@ namespace renderdocui.Windows
maxIndex = 0;
foreach (var i in ret.Indices)
{
if(input.IndexFormat.format.compByteWidth == 2 && i == UInt16.MaxValue)
if (input.Drawcall.indexByteWidth == 2 && i == UInt16.MaxValue)
continue;
if (input.IndexFormat.format.compByteWidth == 4 && i == UInt32.MaxValue)
if (input.Drawcall.indexByteWidth == 4 && i == UInt32.MaxValue)
continue;
maxIndex = Math.Max(maxIndex, i);
@@ -1579,9 +1576,9 @@ namespace renderdocui.Windows
state.m_Data.Topology == PrimitiveTopology.TriangleStrip ||
state.m_Data.Topology == PrimitiveTopology.TriangleStrip_Adj;
if (state.m_Input.IndexFormat.ByteSize == 2 && index == ushort.MaxValue && strip)
if (state.m_Input.Drawcall.indexByteWidth == 2 && index == ushort.MaxValue && strip)
rowdata[1] = "-1";
if (state.m_Input.IndexFormat.ByteSize == 4 && index == uint.MaxValue && strip)
if (state.m_Input.Drawcall.indexByteWidth == 4 && index == uint.MaxValue && strip)
rowdata[1] = "-1";
x = 2;
@@ -639,15 +639,15 @@ namespace renderdocui.Windows.PipelineState
inputLayouts.NodesSelection.Clear();
inputLayouts.EndUpdate();
topology.Text = state.m_IA.Topology.ToString();
if (state.m_IA.Topology > PrimitiveTopology.PatchList)
topology.Text = draw.topology.ToString();
if (draw.topology > PrimitiveTopology.PatchList)
{
int numCPs = (int)state.m_IA.Topology - (int)PrimitiveTopology.PatchList + 1;
int numCPs = (int)draw.topology - (int)PrimitiveTopology.PatchList + 1;
topology.Text = string.Format("PatchList ({0} Control Points)", numCPs);
}
switch (state.m_IA.Topology)
switch (draw.topology)
{
case PrimitiveTopology.PointList:
topologyDiagram.Image = global::renderdocui.Properties.Resources.topo_pointlist;
@@ -708,7 +708,7 @@ namespace renderdocui.Windows.PipelineState
}
}
var node = iabuffers.Nodes.Add(new object[] { "Index", name, state.m_IA.ibuffer.Format.compByteWidth, state.m_IA.ibuffer.Offset, length });
var node = iabuffers.Nodes.Add(new object[] { "Index", name, draw.indexByteWidth, state.m_IA.ibuffer.Offset, length });
node.Image = global::renderdocui.Properties.Resources.action;
node.HoverImage = global::renderdocui.Properties.Resources.action_hover;
@@ -2505,14 +2505,20 @@ namespace renderdocui.Windows.PipelineState
}
}
string ifmt = "UNKNOWN";
if (m_Core.CurDrawcall.indexByteWidth == 2)
ifmt = "R16_UINT";
if (m_Core.CurDrawcall.indexByteWidth == 4)
ifmt = "R32_UINT";
ExportHTMLTable(writer, new string[] { "Buffer", "Format", "Offset", "Byte Length" },
new object[] { name, ia.ibuffer.Format.ToString(), ia.ibuffer.Offset.ToString(), length.ToString() });
new object[] { name, ifmt, ia.ibuffer.Offset.ToString(), length.ToString() });
}
writer.WriteStartElement("p");
writer.WriteEndElement();
ExportHTMLTable(writer, new string[] { "Primitive Topology" }, new object[] { ia.Topology.Str() });
ExportHTMLTable(writer, new string[] { "Primitive Topology" }, new object[] { m_Core.CurDrawcall.topology.Str() });
}
private void ExportHTML(XmlTextWriter writer, D3D11PipelineState.ShaderStage sh)
@@ -322,15 +322,15 @@ namespace renderdocui.Windows.PipelineState
inputLayouts.NodesSelection.Clear();
inputLayouts.EndUpdate();
topology.Text = state.m_VtxIn.Topology.ToString();
if (state.m_VtxIn.Topology > PrimitiveTopology.PatchList)
topology.Text = draw.topology.ToString();
if (draw.topology > PrimitiveTopology.PatchList)
{
int numCPs = (int)state.m_VtxIn.Topology - (int)PrimitiveTopology.PatchList + 1;
int numCPs = (int)draw.topology - (int)PrimitiveTopology.PatchList + 1;
topology.Text = string.Format("PatchList ({0} Control Points)", numCPs);
}
switch (state.m_VtxIn.Topology)
switch (draw.topology)
{
case PrimitiveTopology.PointList:
topologyDiagram.Image = global::renderdocui.Properties.Resources.topo_pointlist;
@@ -373,7 +373,7 @@ namespace renderdocui.Windows.PipelineState
{
if (ibufferUsed || showDisabled.Checked)
{
string ptr = "Buffer " + state.m_VtxIn.ibuffer.Buffer.ToString();
string ptr = "Buffer " + state.m_VtxIn.ibuffer.ToString();
string name = ptr;
UInt32 length = 1;
@@ -384,23 +384,23 @@ namespace renderdocui.Windows.PipelineState
for (int t = 0; t < bufs.Length; t++)
{
if (bufs[t].ID == state.m_VtxIn.ibuffer.Buffer)
if (bufs[t].ID == state.m_VtxIn.ibuffer)
{
name = bufs[t].name;
length = bufs[t].length;
}
}
var node = iabuffers.Nodes.Add(new object[] { "Index", name, state.m_VtxIn.ibuffer.Format.compByteWidth, state.m_VtxIn.ibuffer.Offset, length });
var node = iabuffers.Nodes.Add(new object[] { "Index", name, draw.indexByteWidth, 0, length });
node.Image = global::renderdocui.Properties.Resources.action;
node.HoverImage = global::renderdocui.Properties.Resources.action_hover;
node.Tag = state.m_VtxIn.ibuffer.Buffer;
node.Tag = state.m_VtxIn.ibuffer;
if (!ibufferUsed)
InactiveRow(node);
if (state.m_VtxIn.ibuffer.Buffer == ResourceId.Null)
if (state.m_VtxIn.ibuffer == ResourceId.Null)
EmptyRow(node);
}
}
@@ -413,7 +413,7 @@ namespace renderdocui.Windows.PipelineState
node.Image = global::renderdocui.Properties.Resources.action;
node.HoverImage = global::renderdocui.Properties.Resources.action_hover;
node.Tag = state.m_VtxIn.ibuffer.Buffer;
node.Tag = state.m_VtxIn.ibuffer;
EmptyRow(node);