diff --git a/renderdoc/api/replay/control_types.h b/renderdoc/api/replay/control_types.h index fc423fef6..f2513da70 100644 --- a/renderdoc/api/replay/control_types.h +++ b/renderdoc/api/replay/control_types.h @@ -29,6 +29,18 @@ struct OutputConfig OutputType m_Type; }; +struct MeshFormat +{ + ResourceId buf; + uint32_t offset; + uint32_t stride; + uint32_t compCount; + uint32_t compByteWidth; + FormatComponentType compType; + SpecialFormat specialFormat; + bool showAlpha; +}; + struct MeshDisplay { MeshDataStage type; @@ -43,13 +55,8 @@ struct MeshDisplay bool32 thisDrawOnly; uint32_t highlightVert; - ResourceId positionBuf; - uint32_t positionOffset; - uint32_t positionStride; - uint32_t positionCompCount; - uint32_t positionCompByteWidth; - FormatComponentType positionCompType; - SpecialFormat positionFormat; + MeshFormat position; + MeshFormat second; FloatVector prevMeshColour; FloatVector currentMeshColour; diff --git a/renderdoc/api/replay/data_types.h b/renderdoc/api/replay/data_types.h index 8b0f37531..b4a4f1dd2 100644 --- a/renderdoc/api/replay/data_types.h +++ b/renderdoc/api/replay/data_types.h @@ -46,6 +46,22 @@ struct ResourceFormat srgbCorrected = false; } + bool operator ==(const ResourceFormat &r) const + { + if(special || r.special) + return special == r.special && specialFormat == r.specialFormat; + + return compCount == r.compCount && + compByteWidth == r.compByteWidth && + compType == r.compType && + srgbCorrected == r.srgbCorrected; + } + + bool operator !=(const ResourceFormat &r) const + { + return !(*this == r); + } + uint32_t rawType; // indicates it's not a type represented with the members below diff --git a/renderdoc/api/replay/replay_enums.h b/renderdoc/api/replay/replay_enums.h index 7fc9871bc..a68412a38 100644 --- a/renderdoc/api/replay/replay_enums.h +++ b/renderdoc/api/replay/replay_enums.h @@ -338,8 +338,7 @@ enum SolidShadeMode eShade_None = 0, eShade_Solid, eShade_Lit, - eShade_Tex, - eShade_VertCol, + eShade_Secondary, }; enum TriangleFillMode diff --git a/renderdoc/data/hlsl/debugcbuffers.h b/renderdoc/data/hlsl/debugcbuffers.h index c1e0af1f4..b522a2b5a 100644 --- a/renderdoc/data/hlsl/debugcbuffers.h +++ b/renderdoc/data/hlsl/debugcbuffers.h @@ -127,10 +127,10 @@ cbuffer HistogramCBufferData REG(b0) #define RESTYPE_CUBE 0x8 #define RESTYPE_TEX2D_MS 0x9 -#define MESHDISPLAY_SOLID 0x1 -#define MESHDISPLAY_FACELIT 0x2 -#define MESHDISPLAY_TEXCOORD 0x3 -#define MESHDISPLAY_COLOR 0x4 +#define MESHDISPLAY_SOLID 0x1 +#define MESHDISPLAY_FACELIT 0x2 +#define MESHDISPLAY_SECONDARY 0x3 +#define MESHDISPLAY_SECONDARY_ALPHA 0x4 #define TEXDISPLAY_TYPEMASK 0xF #define TEXDISPLAY_NANS 0x0100 diff --git a/renderdoc/data/hlsl/debugdisplay.hlsl b/renderdoc/data/hlsl/debugdisplay.hlsl index 03bb5a0bc..11d3ce9a4 100644 --- a/renderdoc/data/hlsl/debugdisplay.hlsl +++ b/renderdoc/data/hlsl/debugdisplay.hlsl @@ -183,14 +183,19 @@ struct wireframeV2F { float4 pos : SV_Position; float3 norm : Normal; - float3 color : COLOR; - float2 tex : TEXCOORD0; + float4 secondary : Secondary; }; -wireframeV2F RENDERDOC_WireframeHomogVS(float4 pos : POSITION, uint vid : SV_VertexID) +struct meshA2V +{ + float4 pos : pos; + float4 secondary : sec; +}; + +wireframeV2F RENDERDOC_WireframeHomogVS(meshA2V IN, uint vid : SV_VertexID) { wireframeV2F OUT = (wireframeV2F)0; - OUT.pos = mul(pos, ModelViewProj); + OUT.pos = mul(IN.pos, ModelViewProj); float2 psprite[4] = { @@ -201,25 +206,18 @@ wireframeV2F RENDERDOC_WireframeHomogVS(float4 pos : POSITION, uint vid : SV_Ver }; OUT.pos.xy += SpriteSize.xy*0.01f*psprite[vid%4]*OUT.pos.w; + OUT.secondary = IN.secondary; return OUT; } -struct meshA2V -{ - float3 pos : pos; - float2 tex : tex; - float3 color : col; -}; - wireframeV2F RENDERDOC_MeshVS(meshA2V IN, uint vid : SV_VertexID) { wireframeV2F OUT = (wireframeV2F)0; - OUT.pos = mul(float4(IN.pos, 1), ModelViewProj); + OUT.pos = mul(float4(IN.pos.xyz, 1), ModelViewProj); OUT.norm = float3(0, 0, 1); - OUT.color = IN.color; - OUT.tex = IN.tex; + OUT.secondary = IN.secondary; return OUT; } @@ -237,8 +235,7 @@ void RENDERDOC_MeshGS(triangle wireframeV2F input[3], inout TriangleStream= end) { @@ -4415,7 +4436,7 @@ FloatVector D3D11DebugManager::InterpretVertex(byte *data, uint32_t vert, MeshDi ret.w = v.w; return ret; } - else if(cfg.positionFormat == eSpecial_R11G11B10) + else if(cfg.position.specialFormat == eSpecial_R11G11B10) { if(data+4 >= end) { @@ -4429,7 +4450,7 @@ FloatVector D3D11DebugManager::InterpretVertex(byte *data, uint32_t vert, MeshDi ret.z = v.z; return ret; } - else if(cfg.positionFormat == eSpecial_B8G8R8A8) + else if(cfg.position.specialFormat == eSpecial_B8G8R8A8) { if(data+4 >= end) { @@ -4442,21 +4463,21 @@ FloatVector D3D11DebugManager::InterpretVertex(byte *data, uint32_t vert, MeshDi fmt.compType = eCompType_UNorm; } - if(data + cfg.positionCompCount*cfg.positionCompByteWidth >= end) + if(data + cfg.position.compCount*cfg.position.compByteWidth >= end) { valid = false; return ret; } - for(uint32_t i=0; i < cfg.positionCompCount; i++) + for(uint32_t i=0; i < cfg.position.compCount; i++) { *out = ConvertComponent(fmt, data); - data += cfg.positionCompByteWidth; + data += cfg.position.compByteWidth; out++; } - if(cfg.positionFormat == eSpecial_B8G8R8A8) + if(cfg.position.specialFormat == eSpecial_B8G8R8A8) { FloatVector reversed; reversed.x = ret.x; @@ -4541,6 +4562,81 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve */ m_pImmediateContext->RSSetState(m_WireframeHelpersRS); + ResourceFormat resFmt; + resFmt.compByteWidth = cfg.position.compByteWidth; + resFmt.compCount = cfg.position.compCount; + resFmt.compType = cfg.position.compType; + resFmt.special = false; + if(cfg.position.specialFormat != eSpecial_Unknown) + { + resFmt.special = true; + resFmt.specialFormat = cfg.position.specialFormat; + } + + ResourceFormat resFmt2; + resFmt2.compByteWidth = cfg.second.compByteWidth; + resFmt2.compCount = cfg.second.compCount; + resFmt2.compType = cfg.second.compType; + resFmt2.special = false; + if(cfg.second.specialFormat != eSpecial_Unknown) + { + resFmt2.special = true; + resFmt2.specialFormat = cfg.second.specialFormat; + } + + if(m_PrevMeshFmt != resFmt || m_PrevMeshFmt2 != resFmt2) + { + SAFE_RELEASE(m_MeshDisplayLayout); + SAFE_RELEASE(m_PostMeshDisplayLayout); + + D3D11_INPUT_ELEMENT_DESC layoutdesc[2]; + + layoutdesc[0].SemanticName = "pos"; + layoutdesc[0].SemanticIndex = 0; + layoutdesc[0].Format = DXGI_FORMAT_R8G8B8A8_UNORM; + if(cfg.position.buf != ResourceId() && + (cfg.position.specialFormat != eSpecial_Unknown || cfg.position.compCount > 0) + ) + layoutdesc[0].Format = MakeDXGIFormat(resFmt); + layoutdesc[0].AlignedByteOffset = 0; // offset will be handled by vertex buffer offset + layoutdesc[0].InputSlot = 0; + layoutdesc[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; + layoutdesc[0].InstanceDataStepRate = 0; + + layoutdesc[1].SemanticName = "sec"; + layoutdesc[1].SemanticIndex = 0; + layoutdesc[1].Format = DXGI_FORMAT_R8G8B8A8_UNORM; + if(cfg.second.buf != ResourceId() && + (cfg.second.specialFormat != eSpecial_Unknown || cfg.second.compCount > 0) + ) + layoutdesc[1].Format = MakeDXGIFormat(resFmt2); + layoutdesc[1].AlignedByteOffset = 0; + layoutdesc[1].InputSlot = 1; + layoutdesc[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA; + layoutdesc[1].InstanceDataStepRate = 0; + + HRESULT hr = m_pDevice->CreateInputLayout(layoutdesc, 2, m_DebugRender.MeshVSBytecode, m_DebugRender.MeshVSBytelen, &m_MeshDisplayLayout); + + if(FAILED(hr)) + { + RDCERR("Failed to create m_MeshDisplayLayout %08x", hr); + m_MeshDisplayLayout = NULL; + } + + layoutdesc[0].Format = DXGI_FORMAT_R32G32B32A32_FLOAT; + + hr = m_pDevice->CreateInputLayout(layoutdesc, 2, m_DebugRender.MeshHomogVSBytecode, m_DebugRender.MeshHomogVSBytelen, &m_PostMeshDisplayLayout); + + if(FAILED(hr)) + { + RDCERR("Failed to create m_PostMeshDisplayLayout %08x", hr); + m_PostMeshDisplayLayout = NULL; + } + } + + m_PrevMeshFmt = resFmt; + m_PrevMeshFmt2 = resFmt2; + if((cfg.type != eMeshDataStage_VSIn && pipeState.m_HS.Shader == ResourceId()) || (cfg.type == eMeshDataStage_GSOut && pipeState.m_HS.Shader != ResourceId())) { @@ -4582,16 +4678,17 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve m_pImmediateContext->VSSetShader(m_DebugRender.WireframeHomogVS, NULL, 0); m_pImmediateContext->PSSetConstantBuffers(0, 1, &m_DebugRender.GenericPSCBuffer); - m_pImmediateContext->PSSetShader(m_DebugRender.WireframePS, NULL, 0); + m_pImmediateContext->PSSetShader(m_DebugRender.MeshPS, NULL, 0); { - m_pImmediateContext->IASetInputLayout(m_DebugRender.GenericHomogLayout); - if(events.size() > 1) { + pixelData.OutputDisplayFormat = MESHDISPLAY_SOLID; pixelData.WireframeColour = Vec3f(cfg.prevMeshColour.x, cfg.prevMeshColour.y, cfg.prevMeshColour.z); FillCBuffer(m_DebugRender.GenericPSCBuffer, (float *)&pixelData, sizeof(DebugPixelCBufferData)); } + + m_pImmediateContext->IASetInputLayout(m_DebugRender.GenericHomogLayout); for(size_t i=0; i < events.size()-1; i++) { @@ -4624,8 +4721,13 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve } } - pixelData.WireframeColour = Vec3f(cfg.currentMeshColour.x, cfg.currentMeshColour.y, cfg.currentMeshColour.z); - FillCBuffer(m_DebugRender.GenericPSCBuffer, (float *)&pixelData, sizeof(DebugPixelCBufferData)); + m_pImmediateContext->IASetInputLayout(m_PostMeshDisplayLayout); + + if(m_PostMeshDisplayLayout == NULL) + { + RDCWARN("Couldn't get a mesh display layout"); + return; + } PostVSData data = GetPostVSBuffers(frameID, events.back()); const PostVSData::StageData &stage = data.GetStage(cfg.type); @@ -4638,18 +4740,71 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve ID3D11Buffer *buf = UNWRAP(WrappedID3D11Buffer, stage.buf); m_pImmediateContext->IASetVertexBuffers(0, 1, &buf, (UINT *)&stage.vertStride, (UINT *)&stage.posOffset); + + UINT offset = cfg.second.offset; + m_pImmediateContext->IASetVertexBuffers(1, 1, &buf, (UINT *)&stage.vertStride, &offset); + if(stage.useIndices) { buf = UNWRAP(WrappedID3D11Buffer, stage.idxBuf); m_pImmediateContext->IASetIndexBuffer(buf, stage.idxFmt, 0); - - m_pImmediateContext->DrawIndexed(stage.numVerts, 0, 0); } - else + + // draw solid shaded mode + if(cfg.solidShadeMode != eShade_None) { - m_pImmediateContext->Draw(stage.numVerts, 0); + m_pImmediateContext->RSSetState(m_DebugRender.RastState); + + pixelData.OutputDisplayFormat = (int)cfg.solidShadeMode; + if(cfg.solidShadeMode == eShade_Secondary && cfg.second.showAlpha) + pixelData.OutputDisplayFormat = MESHDISPLAY_SECONDARY_ALPHA; + pixelData.WireframeColour = Vec3f(0.8f, 0.8f, 0.0f); + FillCBuffer(m_DebugRender.GenericPSCBuffer, (float *)&pixelData, sizeof(DebugPixelCBufferData)); + + if(cfg.solidShadeMode == eShade_Lit) + { + DebugGeometryCBuffer geomData; + + geomData.InvProj = projMat.Inverse(); + + FillCBuffer(m_DebugRender.GenericGSCBuffer, (float *)&geomData, sizeof(DebugGeometryCBuffer)); + m_pImmediateContext->GSSetConstantBuffers(0, 1, &m_DebugRender.GenericGSCBuffer); + + m_pImmediateContext->GSSetShader(m_DebugRender.MeshGS, NULL, 0); + } + + if(stage.useIndices) + m_pImmediateContext->DrawIndexed(stage.numVerts, 0, 0); + else + m_pImmediateContext->Draw(stage.numVerts, 0); + + if(cfg.solidShadeMode == eShade_Lit) + m_pImmediateContext->GSSetShader(NULL, NULL, 0); + } + + // draw wireframe mode + if(cfg.solidShadeMode == eShade_None || cfg.wireframeDraw) + { + m_pImmediateContext->RSSetState(m_WireframeHelpersRS); + + m_pImmediateContext->OMSetDepthStencilState(m_DebugRender.LEqualDepthState, 0); + + pixelData.OutputDisplayFormat = MESHDISPLAY_SOLID; + if(cfg.solidShadeMode == eShade_None) + pixelData.WireframeColour = Vec3f(cfg.currentMeshColour.x, cfg.currentMeshColour.y, cfg.currentMeshColour.z); + else + pixelData.WireframeColour = Vec3f(0.0f, 0.0f, 0.0f); + FillCBuffer(m_DebugRender.GenericPSCBuffer, (float *)&pixelData, sizeof(DebugPixelCBufferData)); + + if(stage.useIndices) + m_pImmediateContext->DrawIndexed(stage.numVerts, 0, 0); + else + m_pImmediateContext->Draw(stage.numVerts, 0); } } + + if(cfg.solidShadeMode == eShade_Lit) + m_pImmediateContext->GSSetShader(NULL, NULL, 0); } } else @@ -4658,141 +4813,29 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve m_pImmediateContext->VSSetConstantBuffers(0, 1, &m_DebugRender.GenericVSCBuffer); m_pImmediateContext->VSSetShader(m_DebugRender.MeshVS, NULL, 0); m_pImmediateContext->PSSetShader(m_DebugRender.MeshPS, NULL, 0); - - if(m_PrevMeshInputLayout != curRS->IA.Layout) - { - SAFE_RELEASE(m_MeshDisplayLayout); - - m_PrevMeshInputLayout = curRS->IA.Layout; - - const vector curLayout = m_WrappedDevice->GetLayoutDesc(curRS->IA.Layout); - - vector layoutdesc; - - byte elems = 0; - - int buffers[3] = {0,0,0}; - - for(size_t i=0; i < curLayout.size(); i++) - { - const D3D11_INPUT_ELEMENT_DESC &layout = curLayout[i]; - - if((!_stricmp(layout.SemanticName, "POSITION") || - !_stricmp(layout.SemanticName, "POS") || - !_stricmp(layout.SemanticName, "SV_Position")) && - layout.SemanticIndex == 0) // need to get name from input config - { - D3D11_INPUT_ELEMENT_DESC el = layout; - el.SemanticName = "pos"; // these are the known values since they match WireframeVS - el.SemanticIndex = 0; - - layoutdesc.push_back(el); - - buffers[0] = layout.InputSlot; - - elems |= 0x1; - } - else if(!_stricmp(layout.SemanticName, "TEXCOORD") && layout.SemanticIndex == 0) - { - D3D11_INPUT_ELEMENT_DESC el = layout; - el.SemanticName = "tex"; // these are the known values since they match WireframeVS - el.SemanticIndex = 0; - - layoutdesc.push_back(el); - - buffers[1] = layout.InputSlot; - - elems |= 0x2; - } - else if(!_stricmp(layout.SemanticName, "COLOR") && layout.SemanticIndex == 0) - { - D3D11_INPUT_ELEMENT_DESC el = layout; - el.SemanticName = "col"; // these are the known values since they match WireframeVS - el.SemanticIndex = 0; - - layoutdesc.push_back(el); - - buffers[2] = layout.InputSlot; - - elems |= 0x4; - } - } - - for(m_MeshDisplayNULLVB = 0; m_MeshDisplayNULLVB < 4; m_MeshDisplayNULLVB++) - { - bool used = false; - - for(int i=0; i < 3; i++) - { - if(elems & (1<CreateInputLayout(&layoutdesc[0], 3, m_DebugRender.MeshVSBytecode, m_DebugRender.MeshVSBytelen, &m_MeshDisplayLayout); - - if(FAILED(hr)) - { - RDCERR("Failed to create rendermesh input layout %08x", hr); - return; - } - } - + if(m_MeshDisplayLayout == NULL) { RDCWARN("Couldn't get a mesh display layout"); return; } + ID3D11Buffer *vbs[2] = { NULL, NULL }; + UINT str[] = { cfg.position.stride, cfg.second.stride }; + UINT offs[] = { cfg.position.offset, cfg.second.offset }; + + auto it = WrappedID3D11Buffer::m_BufferList.find(cfg.position.buf); + + if(it != WrappedID3D11Buffer::m_BufferList.end()) + vbs[0] = UNWRAP(WrappedID3D11Buffer, it->second.m_Buffer); + + it = WrappedID3D11Buffer::m_BufferList.find(cfg.second.buf); + + if(it != WrappedID3D11Buffer::m_BufferList.end()) + vbs[1] = UNWRAP(WrappedID3D11Buffer, it->second.m_Buffer); + + m_pImmediateContext->IASetVertexBuffers(0, 2, vbs, str, offs); m_pImmediateContext->IASetInputLayout(m_MeshDisplayLayout); - ID3D11Buffer *vb = NULL; - UINT dummy = 4; - m_pImmediateContext->IASetVertexBuffers(m_MeshDisplayNULLVB, 1, &vb, &dummy, &dummy); // draw solid shaded mode if(cfg.solidShadeMode != eShade_None && pipeState.m_IA.Topology < eTopology_PatchList_1CPs) @@ -4800,6 +4843,8 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve m_pImmediateContext->RSSetState(m_DebugRender.RastState); pixelData.OutputDisplayFormat = (int)cfg.solidShadeMode; + if(cfg.solidShadeMode == eShade_Secondary && cfg.second.showAlpha) + pixelData.OutputDisplayFormat = MESHDISPLAY_SECONDARY_ALPHA; pixelData.WireframeColour = Vec3f(0.8f, 0.8f, 0.0f); FillCBuffer(m_DebugRender.GenericPSCBuffer, (float *)&pixelData, sizeof(DebugPixelCBufferData)); @@ -4842,7 +4887,7 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve m_WrappedDevice->ReplayLog(frameID, 0, events[0], eReplay_OnlyDraw); } } - + m_pImmediateContext->RSSetState(m_WireframeHelpersRS); // set up state for drawing helpers @@ -4895,10 +4940,10 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve if(cfg.type == eMeshDataStage_VSOut && pipeState.m_HS.Shader != ResourceId()) stage = eMeshDataStage_VSIn; - if(m_HighlightCache.EID != events.back() || m_HighlightCache.buf != cfg.positionBuf || stage != m_HighlightCache.stage) + if(m_HighlightCache.EID != events.back() || m_HighlightCache.buf != cfg.position.buf || stage != m_HighlightCache.stage) { m_HighlightCache.EID = events.back(); - m_HighlightCache.buf = cfg.positionBuf; + m_HighlightCache.buf = cfg.position.buf; m_HighlightCache.stage = stage; ID3D11Buffer *idxBuf = curRS->IA.IndexBuffer; @@ -4909,7 +4954,7 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve if(cfg.type == eMeshDataStage_VSIn) { - m_HighlightCache.data = GetBufferData(cfg.positionBuf, 0, 0); + m_HighlightCache.data = GetBufferData(cfg.position.buf, 0, 0); m_HighlightCache.topo = curRS->IA.Topo; idxOffs += drawcall->indexOffset*bytesize; } @@ -4959,8 +5004,8 @@ void D3D11DebugManager::RenderMesh(uint32_t frameID, const vector &eve byte *data = &m_HighlightCache.data[0]; // buffer start byte *dataEnd = data + m_HighlightCache.data.size(); - data += cfg.positionOffset; // to start of position data - data += drawcall->vertexOffset*cfg.positionStride; // to first vertex + data += cfg.position.offset; // to start of position data + data += drawcall->vertexOffset*cfg.position.stride; // to first vertex /////////////////////////////////////////////////////////////// // vectors to be set from buffers, depending on topology diff --git a/renderdoc/driver/d3d11/d3d11_debug.h b/renderdoc/driver/d3d11/d3d11_debug.h index 44d56c574..e74bfafee 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.h +++ b/renderdoc/driver/d3d11/d3d11_debug.h @@ -321,12 +321,13 @@ class D3D11DebugManager ID3D11RasterizerState *m_WireframeHelpersRS, *m_WireframeHelpersCullCCWRS, *m_WireframeHelpersCullCWRS; ID3D11RasterizerState *m_SolidHelpersRS; - // this gets updated to pull the elements we want out of the buffers + // these gets updated to pull the elements selected out of the buffers ID3D11InputLayout *m_MeshDisplayLayout; - int m_MeshDisplayNULLVB; + ID3D11InputLayout *m_PostMeshDisplayLayout; - // whenever this changes (just a dumb pointer, not ref-owned) - ID3D11InputLayout *m_PrevMeshInputLayout; + // whenever these change + ResourceFormat m_PrevMeshFmt; + ResourceFormat m_PrevMeshFmt2; ID3D11Buffer *m_AxisHelper; ID3D11Buffer *m_FrustumHelper; @@ -459,6 +460,7 @@ class D3D11DebugManager SAFE_RELEASE(histogramUAV); SAFE_DELETE_ARRAY(MeshVSBytecode); + SAFE_DELETE_ARRAY(MeshHomogVSBytecode); SAFE_RELEASE(PickPixelRT); SAFE_RELEASE(PickPixelStageTex); @@ -506,6 +508,9 @@ class D3D11DebugManager byte *MeshVSBytecode; uint32_t MeshVSBytelen; + byte *MeshHomogVSBytecode; + uint32_t MeshHomogVSBytelen; + int publicCBufIdx; ID3D11RenderTargetView *PickPixelRT; diff --git a/renderdoc/replay/replay_output.cpp b/renderdoc/replay/replay_output.cpp index 8b2bbbe6f..dceeef661 100644 --- a/renderdoc/replay/replay_output.cpp +++ b/renderdoc/replay/replay_output.cpp @@ -565,7 +565,8 @@ void ReplayOutput::DisplayMesh() m_pDevice->ClearOutputWindowDepth(m_MainOutput.outputID, 1.0f, 0); MeshDisplay mesh = m_RenderData.meshDisplay; - mesh.positionBuf = m_pDevice->GetLiveID(mesh.positionBuf); + mesh.position.buf = m_pDevice->GetLiveID(mesh.position.buf); + mesh.second.buf = m_pDevice->GetLiveID(mesh.second.buf); m_pDevice->RenderMesh(m_FrameID, events, mesh); } diff --git a/renderdocui/Code/FormatElement.cs b/renderdocui/Code/FormatElement.cs index c4b3a15b3..119de780f 100644 --- a/renderdocui/Code/FormatElement.cs +++ b/renderdocui/Code/FormatElement.cs @@ -58,6 +58,41 @@ namespace renderdocui.Code hex = h; } + public override bool Equals(Object obj) + { + return obj is FormatElement && this == (FormatElement)obj; + } + public override int GetHashCode() + { + int hash = name.GetHashCode() * 17; + hash = hash * 17 + buffer.GetHashCode(); + hash = hash * 17 + offset.GetHashCode(); + hash = hash * 17 + format.GetHashCode(); + hash = hash * 17 + perinstance.GetHashCode(); + hash = hash * 17 + rowmajor.GetHashCode(); + hash = hash * 17 + matrixdim.GetHashCode(); + hash = hash * 17 + hex.GetHashCode(); + return hash; + } + public static bool operator ==(FormatElement x, FormatElement y) + { + if ((object)x == null) return false; + if ((object)y == null) return false; + + return x.name == y.name && + x.buffer == y.buffer && + x.offset == y.offset && + x.format == y.format && + x.perinstance == y.perinstance && + x.rowmajor == y.rowmajor && + x.matrixdim == y.matrixdim && + x.hex == y.hex; + } + public static bool operator !=(FormatElement x, FormatElement y) + { + return !(x == y); + } + public uint ByteSize { get diff --git a/renderdocui/Interop/Enums.cs b/renderdocui/Interop/Enums.cs index db10b7eb3..2e514250e 100644 --- a/renderdocui/Interop/Enums.cs +++ b/renderdocui/Interop/Enums.cs @@ -343,8 +343,7 @@ namespace renderdoc None = 0, Solid, Lit, - Tex, - VertCol, + Secondary, }; public enum TriangleFillMode diff --git a/renderdocui/Interop/FetchInfo.cs b/renderdocui/Interop/FetchInfo.cs index 1182b17b6..642c0a53a 100644 --- a/renderdocui/Interop/FetchInfo.cs +++ b/renderdocui/Interop/FetchInfo.cs @@ -132,11 +132,22 @@ namespace renderdoc } public override int GetHashCode() { - return rawType.GetHashCode(); + int hash = specialFormat.GetHashCode() * 17; + hash = hash * 17 + compCount.GetHashCode(); + hash = hash * 17 + compByteWidth.GetHashCode(); + hash = hash * 17 + compType.GetHashCode(); + hash = hash * 17 + srgbCorrected.GetHashCode(); + return hash; } public static bool operator ==(ResourceFormat x, ResourceFormat y) { - return x.rawType == y.rawType; + if (x.special || y.special) + return x.special == y.special && x.specialFormat == y.specialFormat; + + return x.compCount == y.compCount && + x.compByteWidth == y.compByteWidth && + x.compType == y.compType && + x.srgbCorrected == y.srgbCorrected; } public static bool operator !=(ResourceFormat x, ResourceFormat y) { @@ -341,6 +352,19 @@ namespace renderdoc public DebugMessage[] debugMessages; }; + [StructLayout(LayoutKind.Sequential)] + public struct MeshFormat + { + public ResourceId buf; + public UInt32 offset; + public UInt32 stride; + public UInt32 compCount; + public UInt32 compByteWidth; + public FormatComponentType compType; + public SpecialFormat specialFormat; + public bool showAlpha; + }; + [StructLayout(LayoutKind.Sequential)] public class MeshDisplay { @@ -357,13 +381,8 @@ namespace renderdoc public bool thisDrawOnly = true; public UInt32 highlightVert; - public ResourceId positionBuf; - public UInt32 positionOffset; - public UInt32 positionStride; - public UInt32 positionCompCount; - public UInt32 positionCompByteWidth; - public FormatComponentType positionCompType; - public SpecialFormat positionFormat; + public MeshFormat position; + public MeshFormat secondary; public FloatVector prevMeshColour = new FloatVector(); public FloatVector currentMeshColour = new FloatVector(); diff --git a/renderdocui/Windows/BufferViewer.Designer.cs b/renderdocui/Windows/BufferViewer.Designer.cs index 1b8074800..32b6e60c0 100644 --- a/renderdocui/Windows/BufferViewer.Designer.cs +++ b/renderdocui/Windows/BufferViewer.Designer.cs @@ -35,21 +35,21 @@ System.Windows.Forms.Label label3; System.Windows.Forms.Label label5; System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BufferViewer)); - WeifenLuo.WinFormsUI.Docking.DockPanelSkin dockPanelSkin3 = new WeifenLuo.WinFormsUI.Docking.DockPanelSkin(); - WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin autoHideStripSkin3 = new WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin(); - WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient7 = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient(); - WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient15 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); - WeifenLuo.WinFormsUI.Docking.DockPaneStripSkin dockPaneStripSkin3 = new WeifenLuo.WinFormsUI.Docking.DockPaneStripSkin(); - WeifenLuo.WinFormsUI.Docking.DockPaneStripGradient dockPaneStripGradient3 = new WeifenLuo.WinFormsUI.Docking.DockPaneStripGradient(); - WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient16 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); - WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient8 = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient(); - WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient17 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); - WeifenLuo.WinFormsUI.Docking.DockPaneStripToolWindowGradient dockPaneStripToolWindowGradient3 = new WeifenLuo.WinFormsUI.Docking.DockPaneStripToolWindowGradient(); - WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient18 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); - WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient19 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); - WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient9 = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient(); - WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient20 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); - WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient21 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); + WeifenLuo.WinFormsUI.Docking.DockPanelSkin dockPanelSkin1 = new WeifenLuo.WinFormsUI.Docking.DockPanelSkin(); + WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin autoHideStripSkin1 = new WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin(); + WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient1 = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient(); + WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient1 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); + WeifenLuo.WinFormsUI.Docking.DockPaneStripSkin dockPaneStripSkin1 = new WeifenLuo.WinFormsUI.Docking.DockPaneStripSkin(); + WeifenLuo.WinFormsUI.Docking.DockPaneStripGradient dockPaneStripGradient1 = new WeifenLuo.WinFormsUI.Docking.DockPaneStripGradient(); + WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient2 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); + WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient2 = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient(); + WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient3 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); + WeifenLuo.WinFormsUI.Docking.DockPaneStripToolWindowGradient dockPaneStripToolWindowGradient1 = new WeifenLuo.WinFormsUI.Docking.DockPaneStripToolWindowGradient(); + WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient4 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); + WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient5 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); + WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient3 = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient(); + WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient6 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); + WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient7 = new WeifenLuo.WinFormsUI.Docking.TabGradient(); this.previewTable = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); this.render = new renderdocui.Controls.NoScrollPanel(); @@ -114,6 +114,12 @@ this.instLabel = new System.Windows.Forms.ToolStripLabel(); this.instanceIdxToolitem = new System.Windows.Forms.ToolStripTextBox(); this.gsOutBufferView = new System.Windows.Forms.DataGridView(); + this.columnContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); + this.resetSelectedColumnsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); + this.selectColumnAsPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.selectColumnAsSecondaryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.selectAlphaAsSecondaryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); label7 = new System.Windows.Forms.Label(); label6 = new System.Windows.Forms.Label(); label1 = new System.Windows.Forms.Label(); @@ -134,6 +140,7 @@ this.flowLayoutPanel2.SuspendLayout(); this.toolStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.gsOutBufferView)).BeginInit(); + this.columnContextMenu.SuspendLayout(); this.SuspendLayout(); // // label7 @@ -469,8 +476,7 @@ "None", "Solid Colour", "Flat Shaded", - "TEXCOORD0", - "COLOR0"}); + "Secondary"}); this.solidShading.Name = "solidShading"; this.solidShading.Size = new System.Drawing.Size(121, 25); this.solidShading.SelectedIndexChanged += new System.EventHandler(this.solidShading_SelectedIndexChanged); @@ -573,7 +579,7 @@ this.previewTab.SelectedIndex = 0; this.previewTab.Size = new System.Drawing.Size(559, 313); this.previewTab.TabIndex = 1; - this.previewTab.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged); + this.previewTab.SelectedIndexChanged += new System.EventHandler(this.meshStageDraw_SelectedIndexChanged); // // tabPage1 // @@ -624,13 +630,14 @@ this.vsInBufferView.Size = new System.Drawing.Size(246, 85); this.vsInBufferView.TabIndex = 10; this.vsInBufferView.VirtualMode = true; + this.vsInBufferView.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.bufferView_MouseClick); this.vsInBufferView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.bufferView_CellValueNeeded); + this.vsInBufferView.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.bufferView_ColumnHeaderMouseClick); this.vsInBufferView.Scroll += new System.Windows.Forms.ScrollEventHandler(this.bufferView_Scroll); this.vsInBufferView.SelectionChanged += new System.EventHandler(this.bufferView_SelectionChanged); this.vsInBufferView.Paint += new System.Windows.Forms.PaintEventHandler(this.bufferView_Paint); this.vsInBufferView.Enter += new System.EventHandler(this.bufferView_EnterLeave); this.vsInBufferView.Leave += new System.EventHandler(this.bufferView_EnterLeave); - this.vsInBufferView.MouseClick += new System.Windows.Forms.MouseEventHandler(this.bufferView_MouseClick); // // csvSaveDialog // @@ -662,13 +669,14 @@ this.vsOutBufferView.Size = new System.Drawing.Size(206, 85); this.vsOutBufferView.TabIndex = 11; this.vsOutBufferView.VirtualMode = true; + this.vsOutBufferView.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.bufferView_MouseClick); this.vsOutBufferView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.bufferView_CellValueNeeded); + this.vsOutBufferView.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.bufferView_ColumnHeaderMouseClick); this.vsOutBufferView.Scroll += new System.Windows.Forms.ScrollEventHandler(this.bufferView_Scroll); this.vsOutBufferView.SelectionChanged += new System.EventHandler(this.bufferView_SelectionChanged); this.vsOutBufferView.Paint += new System.Windows.Forms.PaintEventHandler(this.bufferView_Paint); this.vsOutBufferView.Enter += new System.EventHandler(this.bufferView_EnterLeave); this.vsOutBufferView.Leave += new System.EventHandler(this.bufferView_EnterLeave); - this.vsOutBufferView.MouseClick += new System.Windows.Forms.MouseEventHandler(this.bufferView_MouseClick); // // dockPanel // @@ -680,52 +688,52 @@ this.dockPanel.Location = new System.Drawing.Point(3, 34); this.dockPanel.Name = "dockPanel"; this.dockPanel.Size = new System.Drawing.Size(834, 462); - dockPanelGradient7.EndColor = System.Drawing.SystemColors.ControlLight; - dockPanelGradient7.StartColor = System.Drawing.SystemColors.ControlLight; - autoHideStripSkin3.DockStripGradient = dockPanelGradient7; - tabGradient15.EndColor = System.Drawing.SystemColors.Control; - tabGradient15.StartColor = System.Drawing.SystemColors.Control; - tabGradient15.TextColor = System.Drawing.SystemColors.ControlDarkDark; - autoHideStripSkin3.TabGradient = tabGradient15; - autoHideStripSkin3.TextFont = new System.Drawing.Font("Tahoma", 8.25F); - dockPanelSkin3.AutoHideStripSkin = autoHideStripSkin3; - tabGradient16.EndColor = System.Drawing.SystemColors.ControlLightLight; - tabGradient16.StartColor = System.Drawing.SystemColors.ControlLightLight; - tabGradient16.TextColor = System.Drawing.SystemColors.ControlText; - dockPaneStripGradient3.ActiveTabGradient = tabGradient16; - dockPanelGradient8.EndColor = System.Drawing.SystemColors.Control; - dockPanelGradient8.StartColor = System.Drawing.SystemColors.Control; - dockPaneStripGradient3.DockStripGradient = dockPanelGradient8; - tabGradient17.EndColor = System.Drawing.SystemColors.ControlLight; - tabGradient17.StartColor = System.Drawing.SystemColors.ControlLight; - tabGradient17.TextColor = System.Drawing.SystemColors.ControlText; - dockPaneStripGradient3.InactiveTabGradient = tabGradient17; - dockPaneStripSkin3.DocumentGradient = dockPaneStripGradient3; - dockPaneStripSkin3.TextFont = new System.Drawing.Font("Tahoma", 8.25F); - tabGradient18.EndColor = System.Drawing.SystemColors.ActiveCaption; - tabGradient18.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical; - tabGradient18.StartColor = System.Drawing.SystemColors.GradientActiveCaption; - tabGradient18.TextColor = System.Drawing.SystemColors.ActiveCaptionText; - dockPaneStripToolWindowGradient3.ActiveCaptionGradient = tabGradient18; - tabGradient19.EndColor = System.Drawing.SystemColors.Control; - tabGradient19.StartColor = System.Drawing.SystemColors.Control; - tabGradient19.TextColor = System.Drawing.SystemColors.ControlText; - dockPaneStripToolWindowGradient3.ActiveTabGradient = tabGradient19; - dockPanelGradient9.EndColor = System.Drawing.SystemColors.ControlLight; - dockPanelGradient9.StartColor = System.Drawing.SystemColors.ControlLight; - dockPaneStripToolWindowGradient3.DockStripGradient = dockPanelGradient9; - tabGradient20.EndColor = System.Drawing.SystemColors.InactiveCaption; - tabGradient20.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical; - tabGradient20.StartColor = System.Drawing.SystemColors.GradientInactiveCaption; - tabGradient20.TextColor = System.Drawing.SystemColors.InactiveCaptionText; - dockPaneStripToolWindowGradient3.InactiveCaptionGradient = tabGradient20; - tabGradient21.EndColor = System.Drawing.Color.Transparent; - tabGradient21.StartColor = System.Drawing.Color.Transparent; - tabGradient21.TextColor = System.Drawing.SystemColors.ControlDarkDark; - dockPaneStripToolWindowGradient3.InactiveTabGradient = tabGradient21; - dockPaneStripSkin3.ToolWindowGradient = dockPaneStripToolWindowGradient3; - dockPanelSkin3.DockPaneStripSkin = dockPaneStripSkin3; - this.dockPanel.Skin = dockPanelSkin3; + dockPanelGradient1.EndColor = System.Drawing.SystemColors.ControlLight; + dockPanelGradient1.StartColor = System.Drawing.SystemColors.ControlLight; + autoHideStripSkin1.DockStripGradient = dockPanelGradient1; + tabGradient1.EndColor = System.Drawing.SystemColors.Control; + tabGradient1.StartColor = System.Drawing.SystemColors.Control; + tabGradient1.TextColor = System.Drawing.SystemColors.ControlDarkDark; + autoHideStripSkin1.TabGradient = tabGradient1; + autoHideStripSkin1.TextFont = new System.Drawing.Font("Tahoma", 8.25F); + dockPanelSkin1.AutoHideStripSkin = autoHideStripSkin1; + tabGradient2.EndColor = System.Drawing.SystemColors.ControlLightLight; + tabGradient2.StartColor = System.Drawing.SystemColors.ControlLightLight; + tabGradient2.TextColor = System.Drawing.SystemColors.ControlText; + dockPaneStripGradient1.ActiveTabGradient = tabGradient2; + dockPanelGradient2.EndColor = System.Drawing.SystemColors.Control; + dockPanelGradient2.StartColor = System.Drawing.SystemColors.Control; + dockPaneStripGradient1.DockStripGradient = dockPanelGradient2; + tabGradient3.EndColor = System.Drawing.SystemColors.ControlLight; + tabGradient3.StartColor = System.Drawing.SystemColors.ControlLight; + tabGradient3.TextColor = System.Drawing.SystemColors.ControlText; + dockPaneStripGradient1.InactiveTabGradient = tabGradient3; + dockPaneStripSkin1.DocumentGradient = dockPaneStripGradient1; + dockPaneStripSkin1.TextFont = new System.Drawing.Font("Tahoma", 8.25F); + tabGradient4.EndColor = System.Drawing.SystemColors.ActiveCaption; + tabGradient4.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical; + tabGradient4.StartColor = System.Drawing.SystemColors.GradientActiveCaption; + tabGradient4.TextColor = System.Drawing.SystemColors.ActiveCaptionText; + dockPaneStripToolWindowGradient1.ActiveCaptionGradient = tabGradient4; + tabGradient5.EndColor = System.Drawing.SystemColors.Control; + tabGradient5.StartColor = System.Drawing.SystemColors.Control; + tabGradient5.TextColor = System.Drawing.SystemColors.ControlText; + dockPaneStripToolWindowGradient1.ActiveTabGradient = tabGradient5; + dockPanelGradient3.EndColor = System.Drawing.SystemColors.ControlLight; + dockPanelGradient3.StartColor = System.Drawing.SystemColors.ControlLight; + dockPaneStripToolWindowGradient1.DockStripGradient = dockPanelGradient3; + tabGradient6.EndColor = System.Drawing.SystemColors.InactiveCaption; + tabGradient6.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical; + tabGradient6.StartColor = System.Drawing.SystemColors.GradientInactiveCaption; + tabGradient6.TextColor = System.Drawing.SystemColors.InactiveCaptionText; + dockPaneStripToolWindowGradient1.InactiveCaptionGradient = tabGradient6; + tabGradient7.EndColor = System.Drawing.Color.Transparent; + tabGradient7.StartColor = System.Drawing.Color.Transparent; + tabGradient7.TextColor = System.Drawing.SystemColors.ControlDarkDark; + dockPaneStripToolWindowGradient1.InactiveTabGradient = tabGradient7; + dockPaneStripSkin1.ToolWindowGradient = dockPaneStripToolWindowGradient1; + dockPanelSkin1.DockPaneStripSkin = dockPaneStripSkin1; + this.dockPanel.Skin = dockPanelSkin1; this.dockPanel.TabIndex = 12; // // tableLayoutPanel1 @@ -749,7 +757,7 @@ this.flowLayoutPanel2.Controls.Add(this.toolStrip1); this.flowLayoutPanel2.Location = new System.Drawing.Point(3, 3); this.flowLayoutPanel2.Name = "flowLayoutPanel2"; - this.flowLayoutPanel2.Size = new System.Drawing.Size(759, 25); + this.flowLayoutPanel2.Size = new System.Drawing.Size(728, 25); this.flowLayoutPanel2.TabIndex = 0; // // toolStrip1 @@ -774,7 +782,7 @@ this.instanceIdxToolitem}); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(759, 25); + this.toolStrip1.Size = new System.Drawing.Size(728, 25); this.toolStrip1.TabIndex = 0; this.toolStrip1.Text = "toolStrip1"; // @@ -929,13 +937,58 @@ this.gsOutBufferView.Size = new System.Drawing.Size(206, 85); this.gsOutBufferView.TabIndex = 14; this.gsOutBufferView.VirtualMode = true; + this.gsOutBufferView.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.bufferView_MouseClick); this.gsOutBufferView.CellValueNeeded += new System.Windows.Forms.DataGridViewCellValueEventHandler(this.bufferView_CellValueNeeded); + this.gsOutBufferView.ColumnHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.bufferView_ColumnHeaderMouseClick); this.gsOutBufferView.Scroll += new System.Windows.Forms.ScrollEventHandler(this.bufferView_Scroll); this.gsOutBufferView.SelectionChanged += new System.EventHandler(this.bufferView_SelectionChanged); this.gsOutBufferView.Paint += new System.Windows.Forms.PaintEventHandler(this.bufferView_Paint); this.gsOutBufferView.Enter += new System.EventHandler(this.bufferView_EnterLeave); this.gsOutBufferView.Leave += new System.EventHandler(this.bufferView_EnterLeave); - this.gsOutBufferView.MouseClick += new System.Windows.Forms.MouseEventHandler(this.bufferView_MouseClick); + // + // columnContextMenu + // + this.columnContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.resetSelectedColumnsToolStripMenuItem, + this.toolStripSeparator5, + this.selectColumnAsPositionToolStripMenuItem, + this.selectColumnAsSecondaryToolStripMenuItem, + this.selectAlphaAsSecondaryToolStripMenuItem}); + this.columnContextMenu.Name = "columnContextMenu"; + this.columnContextMenu.Size = new System.Drawing.Size(202, 98); + // + // resetSelectedColumnsToolStripMenuItem + // + this.resetSelectedColumnsToolStripMenuItem.Name = "resetSelectedColumnsToolStripMenuItem"; + this.resetSelectedColumnsToolStripMenuItem.Size = new System.Drawing.Size(201, 22); + this.resetSelectedColumnsToolStripMenuItem.Text = "Reset Selected Columns"; + this.resetSelectedColumnsToolStripMenuItem.Click += new System.EventHandler(this.resetSelectedColumnsToolStripMenuItem_Click); + // + // toolStripSeparator5 + // + this.toolStripSeparator5.Name = "toolStripSeparator5"; + this.toolStripSeparator5.Size = new System.Drawing.Size(198, 6); + // + // selectColumnAsPositionToolStripMenuItem + // + this.selectColumnAsPositionToolStripMenuItem.Name = "selectColumnAsPositionToolStripMenuItem"; + this.selectColumnAsPositionToolStripMenuItem.Size = new System.Drawing.Size(201, 22); + this.selectColumnAsPositionToolStripMenuItem.Text = "Select as Position"; + this.selectColumnAsPositionToolStripMenuItem.Click += new System.EventHandler(this.selectColumnAsPositionToolStripMenuItem_Click); + // + // selectColumnAsSecondaryToolStripMenuItem + // + this.selectColumnAsSecondaryToolStripMenuItem.Name = "selectColumnAsSecondaryToolStripMenuItem"; + this.selectColumnAsSecondaryToolStripMenuItem.Size = new System.Drawing.Size(201, 22); + this.selectColumnAsSecondaryToolStripMenuItem.Text = "Select as Secondary"; + this.selectColumnAsSecondaryToolStripMenuItem.Click += new System.EventHandler(this.selectColumnAsSecondaryToolStripMenuItem_Click); + // + // selectAlphaAsSecondaryToolStripMenuItem + // + this.selectAlphaAsSecondaryToolStripMenuItem.Name = "selectAlphaAsSecondaryToolStripMenuItem"; + this.selectAlphaAsSecondaryToolStripMenuItem.Size = new System.Drawing.Size(201, 22); + this.selectAlphaAsSecondaryToolStripMenuItem.Text = "Select Alpha as Secondary"; + this.selectAlphaAsSecondaryToolStripMenuItem.Click += new System.EventHandler(this.selectAlphaAsSecondaryToolStripMenuItem_Click); // // BufferViewer // @@ -973,6 +1026,7 @@ this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.gsOutBufferView)).EndInit(); + this.columnContextMenu.ResumeLayout(false); this.ResumeLayout(false); } @@ -1043,6 +1097,12 @@ private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.DataGridView gsOutBufferView; private System.Windows.Forms.ToolStripButton highlightVerts; + private System.Windows.Forms.ContextMenuStrip columnContextMenu; + private System.Windows.Forms.ToolStripMenuItem resetSelectedColumnsToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; + private System.Windows.Forms.ToolStripMenuItem selectColumnAsPositionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem selectColumnAsSecondaryToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem selectAlphaAsSecondaryToolStripMenuItem; } } \ No newline at end of file diff --git a/renderdocui/Windows/BufferViewer.cs b/renderdocui/Windows/BufferViewer.cs index 2dbd32c4d..99a74be21 100644 --- a/renderdocui/Windows/BufferViewer.cs +++ b/renderdocui/Windows/BufferViewer.cs @@ -95,8 +95,15 @@ namespace renderdocui.Windows // visible data in the UI. private class UIState { + public UIState(MeshDataStage stage) + { + m_Stage = stage; + } + public Input m_Input = null; + public MeshDataStage m_Stage = MeshDataStage.VSIn; + public Dataset m_Data = null; public Stream[] m_Stream = null; public BinaryReader[] m_Reader = null; @@ -135,9 +142,9 @@ namespace renderdocui.Windows } // one UI state for each stage - private UIState m_VSIn = new UIState(); - private UIState m_VSOut = new UIState(); - private UIState m_GSOut = new UIState(); + private UIState m_VSIn = new UIState(MeshDataStage.VSIn); + private UIState m_VSOut = new UIState(MeshDataStage.VSOut); + private UIState m_GSOut = new UIState(MeshDataStage.GSOut); // this points to the 'highlighted'/current UI state. private UIState m_ContextUIState = null; @@ -444,8 +451,6 @@ namespace renderdocui.Windows var contentsVSOut = RT_FetchBufferContents(MeshDataStage.VSOut, r, m_VSOut.m_Input); var contentsGSOut = RT_FetchBufferContents(MeshDataStage.GSOut, r, m_GSOut.m_Input); - UpdateMeshPositionBuffer(); - if (curReq != m_ReqID) return; @@ -454,20 +459,21 @@ namespace renderdocui.Windows if (curReq != m_ReqID) return; - UI_SetColumns(MeshDataStage.VSIn, m_VSIn.m_Input.BufferFormats); + UI_AutoFetchRenderComponents(MeshDataStage.VSIn, true); + UI_AutoFetchRenderComponents(MeshDataStage.VSOut, true); + UI_AutoFetchRenderComponents(MeshDataStage.GSOut, true); + UI_AutoFetchRenderComponents(MeshDataStage.VSIn, false); + UI_AutoFetchRenderComponents(MeshDataStage.VSOut, false); + UI_AutoFetchRenderComponents(MeshDataStage.GSOut, false); + UI_UpdateMeshRenderComponents(); + + UI_SetAllColumns(); + UI_SetRowsData(MeshDataStage.VSIn, contentsVSIn); - if (m_VSOut.m_Input != null) - { - UI_SetColumns(MeshDataStage.VSOut, m_VSOut.m_Input.BufferFormats); UI_SetRowsData(MeshDataStage.VSOut, contentsVSOut); - } - if (m_GSOut.m_Input != null) - { - UI_SetColumns(MeshDataStage.GSOut, m_GSOut.m_Input.BufferFormats); UI_SetRowsData(MeshDataStage.GSOut, contentsGSOut); - } })); }); } @@ -514,18 +520,34 @@ namespace renderdocui.Windows if (MeshView) { + MeshDataStage[] stages = new MeshDataStage[] { MeshDataStage.VSIn, MeshDataStage.VSOut, MeshDataStage.GSOut }; + + FormatElement[] prevPos = new FormatElement[3]; + FormatElement[] prevSecond = new FormatElement[3]; + + for (int i = 0; i < 3; i++) + { + prevPos[i] = GetPosHighlightFormatElement(stages[i]); + prevSecond[i] = GetSecondHighlightFormatElement(stages[i]); + } + m_VSIn.m_Input = GetCurrentMeshInput(draw, MeshDataStage.VSIn); m_VSOut.m_Input = GetCurrentMeshInput(draw, MeshDataStage.VSOut); m_GSOut.m_Input = GetCurrentMeshInput(draw, MeshDataStage.GSOut); + + for(int i=0; i < 3; i++) + { + FormatElement curPos = GetPosHighlightFormatElement(stages[i]); + FormatElement curSecond = GetSecondHighlightFormatElement(stages[i]); + if (prevPos[i] != curPos) UI_AutoFetchRenderComponents(stages[i], true); + if (prevSecond[i] != curSecond) UI_AutoFetchRenderComponents(stages[i], false); + } } var contentsVSIn = RT_FetchBufferContents(MeshDataStage.VSIn, r, m_VSIn.m_Input); var contentsVSOut = RT_FetchBufferContents(MeshDataStage.VSOut, r, m_VSOut.m_Input); var contentsGSOut = RT_FetchBufferContents(MeshDataStage.GSOut, r, m_GSOut.m_Input); - if (MeshView) - UpdateMeshPositionBuffer(); - if (curReq != m_ReqID) return; @@ -534,32 +556,24 @@ namespace renderdocui.Windows if (curReq != m_ReqID) return; + if (MeshView) + UI_UpdateMeshRenderComponents(); + m_VSIn.AbortThread(); m_VSOut.AbortThread(); m_GSOut.AbortThread(); + UI_SetAllColumns(); + if (m_VSIn.m_Input != null) - { - UI_SetColumns(MeshDataStage.VSIn, m_VSIn.m_Input.BufferFormats); UI_SetRowsData(MeshDataStage.VSIn, contentsVSIn); - } - if (m_VSOut.m_Input != null) - { - UI_SetColumns(MeshDataStage.VSOut, m_VSOut.m_Input.BufferFormats); UI_SetRowsData(MeshDataStage.VSOut, contentsVSOut); - } - if (m_GSOut.m_Input != null) - { - UI_SetColumns(MeshDataStage.GSOut, m_GSOut.m_Input.BufferFormats); UI_SetRowsData(MeshDataStage.GSOut, contentsGSOut); - } - })); - RT_UpdateRenderOutput(r); - if (m_Output != null) - m_Output.Display(); + render.Invalidate(); + })); }); } @@ -1022,6 +1036,49 @@ namespace renderdocui.Windows } } + private void UI_UpdateMeshColumns(MeshDataStage type, FormatElement[] el) + { + bool active = (type == m_MeshDisplay.type); + bool input = (type == MeshDataStage.VSIn); + var bufView = GetUIState(type).m_GridView; + + if (bufView.ColumnCount == 0) + return; + + int colidx = 2; // skip VTX and IDX columns + Color defaultCol = bufView.Columns[0].DefaultCellStyle.BackColor; + + for (int e = 0; e < el.Length; e++) + { + for (int i = 0; i < el[e].format.compCount; i++) + { + if (colidx >= bufView.ColumnCount) + return; + + DataGridViewColumn col = bufView.Columns[colidx]; + colidx++; + + if (e == CurPosElement && active) + { + if (i != 3 || !input) + col.DefaultCellStyle.BackColor = Color.SkyBlue; + else + col.DefaultCellStyle.BackColor = Color.LightCyan; + } + else if (e == CurSecondElement && active && m_MeshDisplay.solidShadeMode == SolidShadeMode.Secondary) + { + if ((m_MeshDisplay.secondary.showAlpha && i == 3) || + (!m_MeshDisplay.secondary.showAlpha && i != 3)) + col.DefaultCellStyle.BackColor = Color.LightGreen; + else + col.DefaultCellStyle.BackColor = Color.FromArgb(200, 238, 200); + } + else + col.DefaultCellStyle.BackColor = defaultCol; + } + } + } + private void UI_SetMeshColumns(MeshDataStage type, FormatElement[] el) { var bufView = GetUIState(type).m_GridView; @@ -1066,13 +1123,14 @@ namespace renderdocui.Windows col.ReadOnly = true; col.SortMode = DataGridViewColumnSortMode.Programmatic; col.DefaultCellStyle.Padding = new Padding(0, 2, 0, 2); - bufView.Columns.Add(col); } if (e < el.Length-1) bufView.Columns[bufView.Columns.Count - 1].DividerWidth = 10; } + + UI_UpdateMeshColumns(type, el); } private void UI_SetRawColumns(FormatElement[] el) @@ -1123,6 +1181,26 @@ namespace renderdocui.Windows UI_SetRawColumns(el); } + private void UI_SetAllColumns() + { + if (m_VSIn.m_Input != null) + UI_SetColumns(MeshDataStage.VSIn, m_VSIn.m_Input.BufferFormats); + if (m_VSOut.m_Input != null) + UI_SetColumns(MeshDataStage.VSOut, m_VSOut.m_Input.BufferFormats); + if (m_GSOut.m_Input != null) + UI_SetColumns(MeshDataStage.GSOut, m_GSOut.m_Input.BufferFormats); + } + + private void UI_UpdateAllColumns() + { + if (m_VSIn.m_Input != null) + UI_UpdateMeshColumns(MeshDataStage.VSIn, m_VSIn.m_Input.BufferFormats); + if (m_VSOut.m_Input != null) + UI_UpdateMeshColumns(MeshDataStage.VSOut, m_VSOut.m_Input.BufferFormats); + if (m_GSOut.m_Input != null) + UI_UpdateMeshColumns(MeshDataStage.GSOut, m_GSOut.m_Input.BufferFormats); + } + #endregion #region Setting Row Data @@ -1690,7 +1768,6 @@ namespace renderdocui.Windows } m_CurrentCamera.Apply(); - m_Core.Renderer.BeginInvoke(RT_UpdateRenderOutput); render.Invalidate(); } @@ -1721,7 +1798,6 @@ namespace renderdocui.Windows camSpeed.Value = Helpers.Clamp((decimal)(diag.Length() / 200.0f), camSpeed.Minimum, camSpeed.Maximum); m_CurrentCamera.Apply(); - m_Core.Renderer.BeginInvoke(RT_UpdateRenderOutput); render.Invalidate(); } @@ -1734,7 +1810,6 @@ namespace renderdocui.Windows if (m_CurrentCamera.Dirty) { m_CurrentCamera.Apply(); - m_Core.Renderer.BeginInvoke(RT_UpdateRenderOutput); render.Invalidate(); } } @@ -1800,7 +1875,6 @@ namespace renderdocui.Windows UpdateHighlightVerts(GetUIState(m_MeshDisplay.type)); m_CurrentCamera.Apply(); - m_Core.Renderer.BeginInvoke(RT_UpdateRenderOutput); render.Invalidate(); } @@ -1841,7 +1915,7 @@ namespace renderdocui.Windows return; } - m_Core.Renderer.Invoke((ReplayRenderer r) => { if (m_Output != null) m_Output.Display(); }); + m_Core.Renderer.Invoke((ReplayRenderer r) => { RT_UpdateRenderOutput(r); if (m_Output != null) m_Output.Display(); }); } private void BufferViewer_Load(object sender, EventArgs e) @@ -1935,18 +2009,25 @@ namespace renderdocui.Windows } } - private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) + private void meshStageDraw_SelectedIndexChanged(object sender, EventArgs e) { - previewTable.Parent = previewTab.SelectedTab; + if (previewTab.SelectedIndex == 0) + m_MeshDisplay.type = MeshDataStage.VSIn; + else if (previewTab.SelectedIndex == 1) + m_MeshDisplay.type = MeshDataStage.VSOut; + else if (previewTab.SelectedIndex == 2) + m_MeshDisplay.type = MeshDataStage.GSOut; + + drawRange.Enabled = (m_MeshDisplay.type != MeshDataStage.VSIn); + + UI_UpdateMeshRenderComponents(); if (previewTab.SelectedIndex == 0) { - m_MeshDisplay.type = MeshDataStage.VSIn; controlType.SelectedIndex = 0; } else if (previewTab.SelectedIndex == 1) { - m_MeshDisplay.type = MeshDataStage.VSOut; if (m_Core.CurPipelineState.IsTessellationEnabled) controlType.SelectedIndex = 0; else @@ -1954,52 +2035,188 @@ namespace renderdocui.Windows } else if (previewTab.SelectedIndex == 2) { - m_MeshDisplay.type = MeshDataStage.GSOut; controlType.SelectedIndex = 1; } - UpdateMeshPositionBuffer(); - enableCameraControls(); controlType_SelectedIndexChanged(sender, e); + + previewTable.Parent = previewTab.SelectedTab; } - private void UpdateMeshPositionBuffer() + private int[] m_PosElement = new int[] { -1, -1, -1, -1 }; + private int[] m_SecondElement = new int[] { -1, -1, -1, -1 }; + private bool[] m_SecondShowAlpha = new bool[] { false, false, false, false }; + + private int CurPosElement { get { return m_PosElement[(int)m_MeshDisplay.type]; } } + private int CurSecondElement { get { return m_SecondElement[(int)m_MeshDisplay.type]; } } + private bool CurSecondShowAlpha { get { return m_SecondShowAlpha[(int)m_MeshDisplay.type]; } } + + private FormatElement GetPosHighlightFormatElement(MeshDataStage stage) { var ui = GetUIState(m_MeshDisplay.type); - FormatElement pos = null; + int idx = m_PosElement[(int)stage]; - if (ui.m_Input != null && ui.m_Input.BufferFormats != null) + if (ui.m_Input == null || ui.m_Input.BufferFormats == null || + idx == -1 || idx >= ui.m_Input.BufferFormats.Length) + return null; + + return ui.m_Input.BufferFormats[idx]; + } + + private FormatElement GetSecondHighlightFormatElement(MeshDataStage stage) + { + var ui = GetUIState(m_MeshDisplay.type); + + int idx = m_SecondElement[(int)stage]; + + if (ui.m_Input == null || ui.m_Input.BufferFormats == null || + idx == -1 || idx >= ui.m_Input.BufferFormats.Length) + return null; + + return ui.m_Input.BufferFormats[idx]; + } + + private void UI_AutoFetchRenderComponents(MeshDataStage stage, bool pos) + { + var ui = GetUIState(stage); + + if (pos) { - foreach (var el in ui.m_Input.BufferFormats) + int posEl = -1; + + if (ui.m_Input != null && ui.m_Input.BufferFormats != null) { // prioritise SV_Position over general POSITION - if (el.name.ToUpperInvariant() == "SV_POSITION") - pos = el; - if (el.name.ToUpperInvariant() == "POSITION" && pos == null) - pos = el; - } - } + for (int i = 0; i < ui.m_Input.BufferFormats.Length; i++) + { + FormatElement el = ui.m_Input.BufferFormats[i]; - if (pos == null) - { - m_MeshDisplay.positionBuf = ResourceId.Null; + if (el.name.ToUpperInvariant() == "SV_POSITION") + { + posEl = i; + break; + } + } + for (int i = 0; posEl == -1 && i < ui.m_Input.BufferFormats.Length; i++) + { + FormatElement el = ui.m_Input.BufferFormats[i]; + + if (el.name.ToUpperInvariant() == "POSITION" || + el.name.ToUpperInvariant() == "POSITION0" || + el.name.ToUpperInvariant() == "POS" || + el.name.ToUpperInvariant() == "POS0") + { + posEl = i; + break; + } + } + } + + m_PosElement[(int)stage] = posEl; } else { - m_MeshDisplay.positionBuf = m_VSIn.m_Input.Buffers[pos.buffer]; - m_MeshDisplay.positionOffset = pos.offset + ui.m_Input.Offsets[pos.buffer]; - m_MeshDisplay.positionStride = ui.m_Input.Strides[pos.buffer]; + int secondEl = -1; - m_MeshDisplay.positionCompByteWidth = pos.format.compByteWidth; - m_MeshDisplay.positionCompCount = pos.format.compCount; - m_MeshDisplay.positionCompType = pos.format.compType; - m_MeshDisplay.positionFormat = pos.format.special ? pos.format.specialFormat : SpecialFormat.Unknown; + if (ui.m_Input != null && ui.m_Input.BufferFormats != null) + { + // prioritise TEXCOORD over general COLOR + for (int i = 0; i < ui.m_Input.BufferFormats.Length; i++) + { + FormatElement el = ui.m_Input.BufferFormats[i]; + + if (el.name.ToUpperInvariant() == "TEXCOORD" || + el.name.ToUpperInvariant() == "TEXCOORD0" || + el.name.ToUpperInvariant() == "TEX" || + el.name.ToUpperInvariant() == "TEX0" || + el.name.ToUpperInvariant() == "UV" || + el.name.ToUpperInvariant() == "UV0") + { + secondEl = i; + break; + } + } + for (int i = 0; secondEl == -1 && i < ui.m_Input.BufferFormats.Length; i++) + { + FormatElement el = ui.m_Input.BufferFormats[i]; + + if (el.name.ToUpperInvariant() == "COLOR" || + el.name.ToUpperInvariant() == "COLOR0" || + el.name.ToUpperInvariant() == "COL" || + el.name.ToUpperInvariant() == "COL0") + { + secondEl = i; + break; + } + } + } + + m_SecondElement[(int)stage] = secondEl; } } + private void UI_UpdateMeshRenderComponents() + { + var ui = GetUIState(m_MeshDisplay.type); + + if (ui.m_Input == null || ui.m_Input.BufferFormats == null || + CurPosElement == -1 || CurPosElement >= ui.m_Input.BufferFormats.Length) + { + m_MeshDisplay.position.buf = ResourceId.Null; + m_MeshDisplay.position.offset = 0; + m_MeshDisplay.position.stride = 0; + m_MeshDisplay.position.compByteWidth = 0; + m_MeshDisplay.position.compCount = 0; + m_MeshDisplay.position.compType = FormatComponentType.None; + m_MeshDisplay.position.specialFormat = SpecialFormat.Unknown; + m_MeshDisplay.position.showAlpha = false; + } + else + { + FormatElement pos = ui.m_Input.BufferFormats[CurPosElement]; + + m_MeshDisplay.position.buf = m_VSIn.m_Input.Buffers[pos.buffer]; + m_MeshDisplay.position.offset = pos.offset + ui.m_Input.Offsets[pos.buffer]; + m_MeshDisplay.position.stride = ui.m_Input.Strides[pos.buffer]; + m_MeshDisplay.position.compByteWidth = pos.format.compByteWidth; + m_MeshDisplay.position.compCount = pos.format.compCount; + m_MeshDisplay.position.compType = pos.format.compType; + m_MeshDisplay.position.specialFormat = pos.format.special ? pos.format.specialFormat : SpecialFormat.Unknown; + m_MeshDisplay.position.showAlpha = false; + } + + if (ui.m_Input == null || ui.m_Input.BufferFormats == null || + CurSecondElement == -1 || CurSecondElement >= ui.m_Input.BufferFormats.Length) + { + m_MeshDisplay.secondary.buf = ResourceId.Null; + m_MeshDisplay.secondary.offset = 0; + m_MeshDisplay.secondary.stride = 0; + m_MeshDisplay.secondary.compByteWidth = 0; + m_MeshDisplay.secondary.compCount = 0; + m_MeshDisplay.secondary.compType = FormatComponentType.None; + m_MeshDisplay.secondary.specialFormat = SpecialFormat.Unknown; + m_MeshDisplay.secondary.showAlpha = false; + } + else + { + FormatElement tex = ui.m_Input.BufferFormats[CurSecondElement]; + + m_MeshDisplay.secondary.buf = m_VSIn.m_Input.Buffers[tex.buffer]; + m_MeshDisplay.secondary.offset = tex.offset + ui.m_Input.Offsets[tex.buffer]; + m_MeshDisplay.secondary.stride = ui.m_Input.Strides[tex.buffer]; + m_MeshDisplay.secondary.compByteWidth = tex.format.compByteWidth; + m_MeshDisplay.secondary.compCount = tex.format.compCount; + m_MeshDisplay.secondary.compType = tex.format.compType; + m_MeshDisplay.secondary.specialFormat = tex.format.special ? tex.format.specialFormat : SpecialFormat.Unknown; + m_MeshDisplay.secondary.showAlpha = CurSecondShowAlpha; + } + + UI_UpdateAllColumns(); + } + private void camGuess_PropChanged() { m_MeshDisplay.ortho = matrixType.SelectedIndex == 1; @@ -2049,10 +2266,7 @@ namespace renderdocui.Windows farGuess.Text = far > -float.MaxValue ? far.ToString("G") : ""; - - - - m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { RT_UpdateRenderOutput(r); if (m_Output != null) m_Output.Display(); }); + render.Invalidate(); } private void camGuess_KeyPress(object sender, KeyPressEventArgs e) @@ -2073,26 +2287,32 @@ namespace renderdocui.Windows { m_MeshDisplay.thisDrawOnly = (drawRange.SelectedIndex == 0); - m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { RT_UpdateRenderOutput(r); if (m_Output != null) m_Output.Display(); }); + render.Invalidate(); } private void solidShading_SelectedIndexChanged(object sender, EventArgs e) { m_MeshDisplay.solidShadeMode = (SolidShadeMode)solidShading.SelectedIndex; - wireframeDraw.Enabled = (solidShading.SelectedIndex != 0); - if (solidShading.SelectedIndex == 0 && !wireframeDraw.Checked) wireframeDraw.Checked = true; - m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { RT_UpdateRenderOutput(r); if (m_Output != null) m_Output.Display(); }); + UI_UpdateAllColumns(); + + render.Invalidate(); } private void wireframeDraw_CheckedChanged(object sender, EventArgs e) { + if (solidShading.SelectedIndex == 0 && !wireframeDraw.Checked) + { + wireframeDraw.Checked = true; + return; + } + m_MeshDisplay.wireframeDraw = wireframeDraw.Checked; - m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { RT_UpdateRenderOutput(r); if (m_Output != null) m_Output.Display(); }); + render.Invalidate(); } private void instanceIdx_KeyDown(object sender, KeyEventArgs e) @@ -2124,9 +2344,79 @@ namespace renderdocui.Windows } } - private void bufferView_MouseClick(object sender, MouseEventArgs e) + private int m_ContextColumn = 0; + + private void resetSelectedColumnsToolStripMenuItem_Click(object sender, EventArgs e) { - if (m_Core.LogLoaded) + UI_AutoFetchRenderComponents(m_ContextUIState.m_Stage, true); + UI_AutoFetchRenderComponents(m_ContextUIState.m_Stage, false); + } + + private void selectColumnAsPositionToolStripMenuItem_Click(object sender, EventArgs e) + { + m_PosElement[(int)m_ContextUIState.m_Stage] = m_ContextColumn; + + UI_UpdateMeshRenderComponents(); + render.Invalidate(); + } + + private void selectColumnAsSecondaryToolStripMenuItem_Click(object sender, EventArgs e) + { + m_SecondElement[(int)m_ContextUIState.m_Stage] = m_ContextColumn; + m_SecondShowAlpha[(int)m_ContextUIState.m_Stage] = false; + + UI_UpdateMeshRenderComponents(); + render.Invalidate(); + } + + private void selectAlphaAsSecondaryToolStripMenuItem_Click(object sender, EventArgs e) + { + m_SecondElement[(int)m_ContextUIState.m_Stage] = m_ContextColumn; + m_SecondShowAlpha[(int)m_ContextUIState.m_Stage] = true; + + UI_UpdateMeshRenderComponents(); + render.Invalidate(); + } + + private void bufferView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) + { + if (m_Core.LogLoaded && MeshView) + { + m_ContextUIState = GetUIState(sender); + bool input = (m_ContextUIState == m_VSIn); + + if (e.Button == MouseButtons.Right && + m_ContextUIState.m_Input != null && + m_ContextUIState.m_Input.BufferFormats != null) + { + selectColumnAsPositionToolStripMenuItem.Visible = input; + selectAlphaAsSecondaryToolStripMenuItem.Visible = true; + + m_ContextColumn = 0; + int colidx = 2; // skip VTX and IDX columns + + for (int el = 0; el < m_ContextUIState.m_Input.BufferFormats.Length; el++) + { + for (int i = 0; i < m_ContextUIState.m_Input.BufferFormats[el].format.compCount; i++) + { + if (colidx == e.ColumnIndex) + { + m_ContextColumn = el; + selectAlphaAsSecondaryToolStripMenuItem.Visible = (m_ContextUIState.m_Input.BufferFormats[el].format.compCount >= 4); + } + + colidx++; + } + } + + columnContextMenu.Show(Cursor.Position); + } + } + } + + private void bufferView_MouseClick(object sender, DataGridViewCellMouseEventArgs e) + { + if (m_Core.LogLoaded && e.RowIndex >= 0) { m_ContextUIState = GetUIState(sender); @@ -2140,7 +2430,7 @@ namespace renderdocui.Windows vsInBufferView.SelectedRows.Count == 1; setInstanceToolStripMenuItem.Enabled = (m_Core.CurDrawcall != null && m_Core.CurDrawcall.numInstances > 1); - rightclickMenu.Show(((DataGridView)sender).PointToScreen(e.Location)); + rightclickMenu.Show(Cursor.Position); } } } @@ -2380,7 +2670,7 @@ namespace renderdocui.Windows private void ClearHighlightVerts() { m_MeshDisplay.highlightVert = ~0U; - m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { RT_UpdateRenderOutput(r); if (m_Output != null) m_Output.Display(); }); + render.Invalidate(); } private void UpdateHighlightVerts(UIState ui) @@ -2394,7 +2684,7 @@ namespace renderdocui.Windows else m_MeshDisplay.highlightVert = ~0U; - m_Core.Renderer.BeginInvoke((ReplayRenderer r) => { RT_UpdateRenderOutput(r); if (m_Output != null) m_Output.Display(); }); + render.Invalidate(); } #endregion diff --git a/renderdocui/Windows/BufferViewer.resx b/renderdocui/Windows/BufferViewer.resx index c85a4c3b7..c565da466 100644 --- a/renderdocui/Windows/BufferViewer.resx +++ b/renderdocui/Windows/BufferViewer.resx @@ -135,9 +135,6 @@ 486, 17 - - 486, 17 - @@ -166,4 +163,7 @@ 387, 17 + + 585, 17 + \ No newline at end of file