diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index 7cbc094d7..0456e68bc 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -2061,12 +2061,7 @@ void BufferViewer::updatePreviewColumns() m_VSInPosition.offset = vbs[el.buffer].ByteOffset + el.offset + draw->vertexOffset * m_VSInPosition.stride; - m_VSInPosition.compCount = el.format.compCount; - m_VSInPosition.compByteWidth = el.format.compByteWidth; - m_VSInPosition.compType = el.format.compType; - m_VSInPosition.bgraOrder = el.format.bgraOrder; - m_VSInPosition.specialFormat = - el.format.special ? el.format.specialFormat : SpecialFormat::Unknown; + m_VSInPosition.fmt = el.format; } elIdx = m_ModelVSIn->secondaryColumn(); @@ -2080,12 +2075,7 @@ void BufferViewer::updatePreviewColumns() m_VSInSecondary.offset = vbs[el.buffer].ByteOffset + el.offset + draw->vertexOffset * m_VSInPosition.stride; - m_VSInSecondary.compCount = el.format.compCount; - m_VSInSecondary.compByteWidth = el.format.compByteWidth; - m_VSInSecondary.compType = el.format.compType; - m_VSInSecondary.bgraOrder = el.format.bgraOrder; - m_VSInSecondary.specialFormat = - el.format.special ? el.format.specialFormat : SpecialFormat::Unknown; + m_VSInSecondary.fmt = el.format; m_VSInSecondary.showAlpha = m_ModelVSIn->secondaryAlpha(); } } diff --git a/renderdoc/api/replay/control_types.h b/renderdoc/api/replay/control_types.h index e5b28558d..00cd68bb0 100644 --- a/renderdoc/api/replay/control_types.h +++ b/renderdoc/api/replay/control_types.h @@ -40,11 +40,6 @@ struct MeshFormat baseVertex = 0; offset = 0; stride = 0; - compCount = 0; - compByteWidth = 0; - compType = CompType::Typeless; - bgraOrder = false; - specialFormat = SpecialFormat::Unknown; showAlpha = false; topo = Topology::Unknown; numVerts = 0; @@ -68,18 +63,8 @@ struct MeshFormat DOCUMENT("The stride in bytes between the start of one vertex and the start of another."); uint32_t stride; - DOCUMENT("The number of components in each vertex."); - uint32_t compCount; - DOCUMENT("The width in bytes of each component."); - uint32_t compByteWidth; - DOCUMENT("The :class:`type ` of each component."); - CompType compType; - DOCUMENT("``True`` if the components are to be read in ``BGRA`` order."); - bool32 bgraOrder; - DOCUMENT( - "If the component is in a non-uniform format, contains the :class:`SpecialFormat` that " - "describes it."); - SpecialFormat specialFormat; + DOCUMENT("The :class:`ResourceFormat` describing this mesh component."); + ResourceFormat fmt; DOCUMENT( "The color to use for rendering the wireframe of this mesh element, as a " diff --git a/renderdoc/core/replay_proxy.cpp b/renderdoc/core/replay_proxy.cpp index d96d03e9a..acfbc0b76 100644 --- a/renderdoc/core/replay_proxy.cpp +++ b/renderdoc/core/replay_proxy.cpp @@ -1573,11 +1573,7 @@ void Serialiser::Serialise(const char *name, MeshFormat &el) Serialise("", el.buf); Serialise("", el.offset); Serialise("", el.stride); - Serialise("", el.compCount); - Serialise("", el.compByteWidth); - Serialise("", el.compType); - Serialise("", el.bgraOrder); - Serialise("", el.specialFormat); + Serialise("", el.fmt); Serialise("", el.meshColor); Serialise("", el.showAlpha); Serialise("", el.topo); @@ -1586,7 +1582,7 @@ void Serialiser::Serialise(const char *name, MeshFormat &el) Serialise("", el.nearPlane); Serialise("", el.farPlane); - SIZE_CHECK(104); + SIZE_CHECK(112); } template <> diff --git a/renderdoc/driver/d3d11/d3d11_analyse.cpp b/renderdoc/driver/d3d11/d3d11_analyse.cpp index 4f362f91f..0881c206c 100644 --- a/renderdoc/driver/d3d11/d3d11_analyse.cpp +++ b/renderdoc/driver/d3d11/d3d11_analyse.cpp @@ -2411,17 +2411,6 @@ uint32_t D3D11DebugManager::PickVertex(uint32_t eventID, const MeshDisplay &cfg, Matrix4f pickMVP = projMat.Mul(camMat); - ResourceFormat resFmt; - resFmt.compByteWidth = cfg.position.compByteWidth; - resFmt.compCount = cfg.position.compCount; - resFmt.compType = cfg.position.compType; - resFmt.special = false; - if(cfg.position.specialFormat != SpecialFormat::Unknown) - { - resFmt.special = true; - resFmt.specialFormat = cfg.position.specialFormat; - } - Matrix4f pickMVPProj; if(cfg.position.unproject) { diff --git a/renderdoc/driver/d3d11/d3d11_debug.cpp b/renderdoc/driver/d3d11/d3d11_debug.cpp index 6eb084744..6e6e3413e 100644 --- a/renderdoc/driver/d3d11/d3d11_debug.cpp +++ b/renderdoc/driver/d3d11/d3d11_debug.cpp @@ -3837,13 +3837,14 @@ MeshFormat D3D11DebugManager::GetPostVSBuffers(uint32_t eventID, uint32_t instID ret.offset = s.instStride * instID; ret.stride = s.vertStride; - ret.compCount = 4; - ret.compByteWidth = 4; - ret.compType = CompType::Float; - ret.specialFormat = SpecialFormat::Unknown; + ret.fmt.compCount = 4; + ret.fmt.compByteWidth = 4; + ret.fmt.compType = CompType::Float; + ret.fmt.special = false; + ret.fmt.specialFormat = SpecialFormat::Unknown; + ret.fmt.bgraOrder = false; ret.showAlpha = false; - ret.bgraOrder = false; ret.topo = MakePrimitiveTopology(s.topo); ret.numVerts = s.numVerts; @@ -4805,27 +4806,8 @@ void D3D11DebugManager::RenderMesh(uint32_t eventID, const vector &s // don't cull in wireframe mesh display 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 != SpecialFormat::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 != SpecialFormat::Unknown) - { - resFmt2.special = true; - resFmt2.specialFormat = cfg.second.specialFormat; - } + const ResourceFormat &resFmt = cfg.position.fmt; + const ResourceFormat &resFmt2 = cfg.second.fmt; if(m_PrevMeshFmt != resFmt || m_PrevMeshFmt2 != resFmt2) { @@ -4837,7 +4819,7 @@ void D3D11DebugManager::RenderMesh(uint32_t eventID, const vector &s layoutdesc[0].SemanticIndex = 0; layoutdesc[0].Format = DXGI_FORMAT_R8G8B8A8_UNORM; if(cfg.position.buf != ResourceId() && - (cfg.position.specialFormat != SpecialFormat::Unknown || cfg.position.compCount > 0)) + (resFmt.specialFormat != SpecialFormat::Unknown || resFmt.compCount > 0)) layoutdesc[0].Format = MakeDXGIFormat(resFmt); layoutdesc[0].AlignedByteOffset = 0; // offset will be handled by vertex buffer offset layoutdesc[0].InputSlot = 0; @@ -4848,7 +4830,7 @@ void D3D11DebugManager::RenderMesh(uint32_t eventID, const vector &s layoutdesc[1].SemanticIndex = 0; layoutdesc[1].Format = DXGI_FORMAT_R8G8B8A8_UNORM; if(cfg.second.buf != ResourceId() && - (cfg.second.specialFormat != SpecialFormat::Unknown || cfg.second.compCount > 0)) + (resFmt2.specialFormat != SpecialFormat::Unknown || resFmt2.compCount > 0)) layoutdesc[1].Format = MakeDXGIFormat(resFmt2); layoutdesc[1].AlignedByteOffset = 0; layoutdesc[1].InputSlot = 1; diff --git a/renderdoc/driver/d3d12/d3d12_debug.cpp b/renderdoc/driver/d3d12/d3d12_debug.cpp index 7f695e140..6c5d959ab 100644 --- a/renderdoc/driver/d3d12/d3d12_debug.cpp +++ b/renderdoc/driver/d3d12/d3d12_debug.cpp @@ -2483,17 +2483,6 @@ uint32_t D3D12DebugManager::PickVertex(uint32_t eventID, const MeshDisplay &cfg, Matrix4f pickMVP = projMat.Mul(camMat); - ResourceFormat resFmt; - resFmt.compByteWidth = cfg.position.compByteWidth; - resFmt.compCount = cfg.position.compCount; - resFmt.compType = cfg.position.compType; - resFmt.special = false; - if(cfg.position.specialFormat != SpecialFormat::Unknown) - { - resFmt.special = true; - resFmt.specialFormat = cfg.position.specialFormat; - } - Matrix4f pickMVPProj; if(cfg.position.unproject) { @@ -4990,13 +4979,14 @@ MeshFormat D3D12DebugManager::GetPostVSBuffers(uint32_t eventID, uint32_t instID ret.offset = s.instStride * instID; ret.stride = s.vertStride; - ret.compCount = 4; - ret.compByteWidth = 4; - ret.compType = CompType::Float; - ret.specialFormat = SpecialFormat::Unknown; + ret.fmt.compCount = 4; + ret.fmt.compByteWidth = 4; + ret.fmt.compType = CompType::Float; + ret.fmt.special = false; + ret.fmt.specialFormat = SpecialFormat::Unknown; + ret.fmt.bgraOrder = false; ret.showAlpha = false; - ret.bgraOrder = false; ret.topo = MakePrimitiveTopology(s.topo); ret.numVerts = s.numVerts; @@ -5277,23 +5267,9 @@ D3D12DebugManager::MeshDisplayPipelines D3D12DebugManager::CacheMeshDisplayPipel key |= uint64_t((uint32_t)primary.topo & 0x3f) << bit; bit += 6; - ResourceFormat fmt; - fmt.special = primary.specialFormat != SpecialFormat::Unknown; - fmt.specialFormat = primary.specialFormat; - fmt.compByteWidth = primary.compByteWidth; - fmt.compCount = primary.compCount; - fmt.compType = primary.compType; - - DXGI_FORMAT primaryFmt = MakeDXGIFormat(fmt); - - fmt.special = secondary.specialFormat != SpecialFormat::Unknown; - fmt.specialFormat = secondary.specialFormat; - fmt.compByteWidth = secondary.compByteWidth; - fmt.compCount = secondary.compCount; - fmt.compType = secondary.compType; - + DXGI_FORMAT primaryFmt = MakeDXGIFormat(primary.fmt); DXGI_FORMAT secondaryFmt = - secondary.buf == ResourceId() ? DXGI_FORMAT_UNKNOWN : MakeDXGIFormat(fmt); + secondary.buf == ResourceId() ? DXGI_FORMAT_UNKNOWN : MakeDXGIFormat(secondary.fmt); key |= uint64_t((uint32_t)primaryFmt & 0xff) << bit; bit += 8; @@ -5703,10 +5679,11 @@ void D3D12DebugManager::RenderMesh(uint32_t eventID, const vector &s helper.idxByteWidth = 2; helper.topo = Topology::LineList; - helper.specialFormat = SpecialFormat::Unknown; - helper.compByteWidth = 4; - helper.compCount = 4; - helper.compType = CompType::Float; + helper.fmt.special = false; + helper.fmt.specialFormat = SpecialFormat::Unknown; + helper.fmt.compByteWidth = 4; + helper.fmt.compCount = 4; + helper.fmt.compType = CompType::Float; helper.stride = sizeof(Vec4f); diff --git a/renderdoc/driver/gl/gl_debug.cpp b/renderdoc/driver/gl/gl_debug.cpp index 1c3d1fab1..7dfd21ea8 100644 --- a/renderdoc/driver/gl/gl_debug.cpp +++ b/renderdoc/driver/gl/gl_debug.cpp @@ -1188,17 +1188,6 @@ uint32_t GLReplay::PickVertex(uint32_t eventID, const MeshDisplay &cfg, uint32_t Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity(); Matrix4f pickMVP = projMat.Mul(camMat); - ResourceFormat resFmt; - resFmt.compByteWidth = cfg.position.compByteWidth; - resFmt.compCount = cfg.position.compCount; - resFmt.compType = cfg.position.compType; - resFmt.special = false; - if(cfg.position.specialFormat != SpecialFormat::Unknown) - { - resFmt.special = true; - resFmt.specialFormat = cfg.position.specialFormat; - } - Matrix4f pickMVPProj; if(cfg.position.unproject) { @@ -1213,7 +1202,6 @@ uint32_t GLReplay::PickVertex(uint32_t eventID, const MeshDisplay &cfg, uint32_t guessProj = Matrix4f::Orthographic(cfg.position.nearPlane, cfg.position.farPlane); pickMVPProj = projMat.Mul(camMat.Mul(guessProj.Inverse())); - ; } vec3 rayPos; @@ -1238,10 +1226,9 @@ uint32_t GLReplay::PickVertex(uint32_t eventID, const MeshDisplay &cfg, uint32_t vec3 testDir = (cameraToWorldFarPosition - cameraToWorldNearPosition); testDir.Normalise(); - /* Calculate the ray direction first in the regular way (above), so we can use the - the output for testing if the ray we are picking is negative or not. This is similar - to checking against the forward direction of the camera, but more robust - */ + // Calculate the ray direction first in the regular way (above), so we can use the + // the output for testing if the ray we are picking is negative or not. This is similar + // to checking against the forward direction of the camera, but more robust if(cfg.position.unproject) { Matrix4f inversePickMVPGuess = pickMVPProj.Inverse(); @@ -1282,32 +1269,32 @@ uint32_t GLReplay::PickVertex(uint32_t eventID, const MeshDisplay &cfg, uint32_t { cdata->meshMode = MESH_TRIANGLE_LIST; break; - }; + } case Topology::TriangleStrip: { cdata->meshMode = MESH_TRIANGLE_STRIP; break; - }; + } case Topology::TriangleFan: { cdata->meshMode = MESH_TRIANGLE_FAN; break; - }; + } case Topology::TriangleList_Adj: { cdata->meshMode = MESH_TRIANGLE_LIST_ADJ; break; - }; + } case Topology::TriangleStrip_Adj: { cdata->meshMode = MESH_TRIANGLE_STRIP_ADJ; break; - }; + } default: // points, lines, patchlists, unknown { cdata->meshMode = MESH_OTHER; isTriangleMesh = false; - }; + } } // line/point data @@ -2894,125 +2881,127 @@ ResourceId GLReplay::RenderOverlay(ResourceId texid, CompType typeHint, DebugOve for(uint32_t inst = 0; draw && inst < RDCMAX(1U, draw->numInstances); inst++) { - MeshFormat fmt = GetPostVSBuffers(events[i], inst, MeshDataStage::GSOut); - if(fmt.buf == ResourceId()) - fmt = GetPostVSBuffers(events[i], inst, MeshDataStage::VSOut); + MeshFormat postvs = GetPostVSBuffers(events[i], inst, MeshDataStage::GSOut); + if(postvs.buf == ResourceId()) + postvs = GetPostVSBuffers(events[i], inst, MeshDataStage::VSOut); - if(fmt.buf != ResourceId()) + if(postvs.buf != ResourceId()) { - GLenum topo = MakeGLPrimitiveTopology(fmt.topo); + GLenum topo = MakeGLPrimitiveTopology(postvs.topo); gl.glBindVertexArray(tempVAO); { - if(fmt.specialFormat != SpecialFormat::Unknown) + if(postvs.fmt.specialFormat != SpecialFormat::Unknown) { - if(fmt.specialFormat == SpecialFormat::R10G10B10A2) + if(postvs.fmt.specialFormat == SpecialFormat::R10G10B10A2) { - if(fmt.compType == CompType::UInt) + if(postvs.fmt.compType == CompType::UInt) gl.glVertexAttribIFormat(0, 4, eGL_UNSIGNED_INT_2_10_10_10_REV, 0); - if(fmt.compType == CompType::SInt) + if(postvs.fmt.compType == CompType::SInt) gl.glVertexAttribIFormat(0, 4, eGL_INT_2_10_10_10_REV, 0); } - else if(fmt.specialFormat == SpecialFormat::R11G11B10) + else if(postvs.fmt.specialFormat == SpecialFormat::R11G11B10) { gl.glVertexAttribFormat(0, 4, eGL_UNSIGNED_INT_10F_11F_11F_REV, GL_FALSE, 0); } else { - RDCWARN("Unsupported special vertex attribute format: %x", fmt.specialFormat); + RDCWARN("Unsupported special vertex attribute format: %x", + postvs.fmt.specialFormat); } } - else if(fmt.compType == CompType::Float || fmt.compType == CompType::UNorm || - fmt.compType == CompType::SNorm) + else if(postvs.fmt.compType == CompType::Float || + postvs.fmt.compType == CompType::UNorm || + postvs.fmt.compType == CompType::SNorm) { GLenum fmttype = eGL_UNSIGNED_INT; - if(fmt.compByteWidth == 4) + if(postvs.fmt.compByteWidth == 4) { - if(fmt.compType == CompType::Float) + if(postvs.fmt.compType == CompType::Float) fmttype = eGL_FLOAT; - else if(fmt.compType == CompType::UNorm) + else if(postvs.fmt.compType == CompType::UNorm) fmttype = eGL_UNSIGNED_INT; - else if(fmt.compType == CompType::SNorm) + else if(postvs.fmt.compType == CompType::SNorm) fmttype = eGL_INT; } - else if(fmt.compByteWidth == 2) + else if(postvs.fmt.compByteWidth == 2) { - if(fmt.compType == CompType::Float) + if(postvs.fmt.compType == CompType::Float) fmttype = eGL_HALF_FLOAT; - else if(fmt.compType == CompType::UNorm) + else if(postvs.fmt.compType == CompType::UNorm) fmttype = eGL_UNSIGNED_SHORT; - else if(fmt.compType == CompType::SNorm) + else if(postvs.fmt.compType == CompType::SNorm) fmttype = eGL_SHORT; } - else if(fmt.compByteWidth == 1) + else if(postvs.fmt.compByteWidth == 1) { - if(fmt.compType == CompType::UNorm) + if(postvs.fmt.compType == CompType::UNorm) fmttype = eGL_UNSIGNED_BYTE; - else if(fmt.compType == CompType::SNorm) + else if(postvs.fmt.compType == CompType::SNorm) fmttype = eGL_BYTE; } - gl.glVertexAttribFormat(0, fmt.compCount, fmttype, fmt.compType != CompType::Float, - 0); + gl.glVertexAttribFormat(0, postvs.fmt.compCount, fmttype, + postvs.fmt.compType != CompType::Float, 0); } - else if(fmt.compType == CompType::UInt || fmt.compType == CompType::SInt) + else if(postvs.fmt.compType == CompType::UInt || postvs.fmt.compType == CompType::SInt) { GLenum fmttype = eGL_UNSIGNED_INT; - if(fmt.compByteWidth == 4) + if(postvs.fmt.compByteWidth == 4) { - if(fmt.compType == CompType::UInt) + if(postvs.fmt.compType == CompType::UInt) fmttype = eGL_UNSIGNED_INT; - else if(fmt.compType == CompType::SInt) + else if(postvs.fmt.compType == CompType::SInt) fmttype = eGL_INT; } - else if(fmt.compByteWidth == 2) + else if(postvs.fmt.compByteWidth == 2) { - if(fmt.compType == CompType::UInt) + if(postvs.fmt.compType == CompType::UInt) fmttype = eGL_UNSIGNED_SHORT; - else if(fmt.compType == CompType::SInt) + else if(postvs.fmt.compType == CompType::SInt) fmttype = eGL_SHORT; } - else if(fmt.compByteWidth == 1) + else if(postvs.fmt.compByteWidth == 1) { - if(fmt.compType == CompType::UInt) + if(postvs.fmt.compType == CompType::UInt) fmttype = eGL_UNSIGNED_BYTE; - else if(fmt.compType == CompType::SInt) + else if(postvs.fmt.compType == CompType::SInt) fmttype = eGL_BYTE; } - gl.glVertexAttribIFormat(0, fmt.compCount, fmttype, 0); + gl.glVertexAttribIFormat(0, postvs.fmt.compCount, fmttype, 0); } - else if(fmt.compType == CompType::Double) + else if(postvs.fmt.compType == CompType::Double) { - gl.glVertexAttribLFormat(0, fmt.compCount, eGL_DOUBLE, 0); + gl.glVertexAttribLFormat(0, postvs.fmt.compCount, eGL_DOUBLE, 0); } - GLuint vb = m_pDriver->GetResourceManager()->GetCurrentResource(fmt.buf).name; - gl.glBindVertexBuffer(0, vb, (GLintptr)fmt.offset, fmt.stride); + GLuint vb = m_pDriver->GetResourceManager()->GetCurrentResource(postvs.buf).name; + gl.glBindVertexBuffer(0, vb, (GLintptr)postvs.offset, postvs.stride); } gl.glEnableVertexAttribArray(0); gl.glDisableVertexAttribArray(1); - if(fmt.idxbuf != ResourceId()) + if(postvs.idxbuf != ResourceId()) { GLenum idxtype = eGL_UNSIGNED_BYTE; - if(fmt.idxByteWidth == 2) + if(postvs.idxByteWidth == 2) idxtype = eGL_UNSIGNED_SHORT; - else if(fmt.idxByteWidth == 4) + else if(postvs.idxByteWidth == 4) idxtype = eGL_UNSIGNED_INT; - GLuint ib = m_pDriver->GetResourceManager()->GetCurrentResource(fmt.idxbuf).name; + GLuint ib = m_pDriver->GetResourceManager()->GetCurrentResource(postvs.idxbuf).name; gl.glBindBuffer(eGL_ELEMENT_ARRAY_BUFFER, ib); - gl.glDrawElementsBaseVertex(topo, fmt.numVerts, idxtype, - (const void *)uintptr_t(fmt.idxoffs), fmt.baseVertex); + gl.glDrawElementsBaseVertex(topo, postvs.numVerts, idxtype, + (const void *)uintptr_t(postvs.idxoffs), postvs.baseVertex); } else { - gl.glDrawArrays(topo, 0, fmt.numVerts); + gl.glDrawArrays(topo, 0, postvs.numVerts); } } } @@ -4694,13 +4683,14 @@ MeshFormat GLReplay::GetPostVSBuffers(uint32_t eventID, uint32_t instID, MeshDat ret.offset = s.instStride * instID; ret.stride = s.vertStride; - ret.compCount = 4; - ret.compByteWidth = 4; - ret.compType = CompType::Float; - ret.specialFormat = SpecialFormat::Unknown; + ret.fmt.compCount = 4; + ret.fmt.compByteWidth = 4; + ret.fmt.compType = CompType::Float; + ret.fmt.special = false; + ret.fmt.specialFormat = SpecialFormat::Unknown; + ret.fmt.bgraOrder = false; ret.showAlpha = false; - ret.bgraOrder = false; ret.topo = s.topo; ret.numVerts = s.numVerts; @@ -4740,7 +4730,7 @@ void GLReplay::RenderMesh(uint32_t eventID, const vector &secondaryD gl.glBindVertexArray(DebugData.meshVAO); - const MeshFormat *fmts[2] = {&cfg.position, &cfg.second}; + const MeshFormat *meshData[2] = {&cfg.position, &cfg.second}; GLenum topo = MakeGLPrimitiveTopology(cfg.position.topo); @@ -4832,96 +4822,97 @@ void GLReplay::RenderMesh(uint32_t eventID, const vector &secondaryD for(uint32_t i = 0; i < 2; i++) { - if(fmts[i]->buf == ResourceId()) + if(meshData[i]->buf == ResourceId()) continue; - if(fmts[i]->specialFormat != SpecialFormat::Unknown) + if(meshData[i]->fmt.specialFormat != SpecialFormat::Unknown) { - if(fmts[i]->specialFormat == SpecialFormat::R10G10B10A2) + if(meshData[i]->fmt.specialFormat == SpecialFormat::R10G10B10A2) { - if(fmts[i]->compType == CompType::UInt) + if(meshData[i]->fmt.compType == CompType::UInt) gl.glVertexAttribIFormat(i, 4, eGL_UNSIGNED_INT_2_10_10_10_REV, 0); - if(fmts[i]->compType == CompType::SInt) + if(meshData[i]->fmt.compType == CompType::SInt) gl.glVertexAttribIFormat(i, 4, eGL_INT_2_10_10_10_REV, 0); } - else if(fmts[i]->specialFormat == SpecialFormat::R11G11B10) + else if(meshData[i]->fmt.specialFormat == SpecialFormat::R11G11B10) { gl.glVertexAttribFormat(i, 4, eGL_UNSIGNED_INT_10F_11F_11F_REV, GL_FALSE, 0); } else { - RDCWARN("Unsupported special vertex attribute format: %x", fmts[i]->specialFormat); + RDCWARN("Unsupported special vertex attribute format: %x", meshData[i]->fmt.specialFormat); } } - else if(fmts[i]->compType == CompType::Float || fmts[i]->compType == CompType::UNorm || - fmts[i]->compType == CompType::SNorm) + else if(meshData[i]->fmt.compType == CompType::Float || + meshData[i]->fmt.compType == CompType::UNorm || + meshData[i]->fmt.compType == CompType::SNorm) { GLenum fmttype = eGL_UNSIGNED_INT; - if(fmts[i]->compByteWidth == 4) + if(meshData[i]->fmt.compByteWidth == 4) { - if(fmts[i]->compType == CompType::Float) + if(meshData[i]->fmt.compType == CompType::Float) fmttype = eGL_FLOAT; - else if(fmts[i]->compType == CompType::UNorm) + else if(meshData[i]->fmt.compType == CompType::UNorm) fmttype = eGL_UNSIGNED_INT; - else if(fmts[i]->compType == CompType::SNorm) + else if(meshData[i]->fmt.compType == CompType::SNorm) fmttype = eGL_INT; } - else if(fmts[i]->compByteWidth == 2) + else if(meshData[i]->fmt.compByteWidth == 2) { - if(fmts[i]->compType == CompType::Float) + if(meshData[i]->fmt.compType == CompType::Float) fmttype = eGL_HALF_FLOAT; - else if(fmts[i]->compType == CompType::UNorm) + else if(meshData[i]->fmt.compType == CompType::UNorm) fmttype = eGL_UNSIGNED_SHORT; - else if(fmts[i]->compType == CompType::SNorm) + else if(meshData[i]->fmt.compType == CompType::SNorm) fmttype = eGL_SHORT; } - else if(fmts[i]->compByteWidth == 1) + else if(meshData[i]->fmt.compByteWidth == 1) { - if(fmts[i]->compType == CompType::UNorm) + if(meshData[i]->fmt.compType == CompType::UNorm) fmttype = eGL_UNSIGNED_BYTE; - else if(fmts[i]->compType == CompType::SNorm) + else if(meshData[i]->fmt.compType == CompType::SNorm) fmttype = eGL_BYTE; } - gl.glVertexAttribFormat(i, fmts[i]->compCount, fmttype, fmts[i]->compType != CompType::Float, - 0); + gl.glVertexAttribFormat(i, meshData[i]->fmt.compCount, fmttype, + meshData[i]->fmt.compType != CompType::Float, 0); } - else if(fmts[i]->compType == CompType::UInt || fmts[i]->compType == CompType::SInt) + else if(meshData[i]->fmt.compType == CompType::UInt || meshData[i]->fmt.compType == CompType::SInt) { GLenum fmttype = eGL_UNSIGNED_INT; - if(fmts[i]->compByteWidth == 4) + if(meshData[i]->fmt.compByteWidth == 4) { - if(fmts[i]->compType == CompType::UInt) + if(meshData[i]->fmt.compType == CompType::UInt) fmttype = eGL_UNSIGNED_INT; - else if(fmts[i]->compType == CompType::SInt) + else if(meshData[i]->fmt.compType == CompType::SInt) fmttype = eGL_INT; } - else if(fmts[i]->compByteWidth == 2) + else if(meshData[i]->fmt.compByteWidth == 2) { - if(fmts[i]->compType == CompType::UInt) + if(meshData[i]->fmt.compType == CompType::UInt) fmttype = eGL_UNSIGNED_SHORT; - else if(fmts[i]->compType == CompType::SInt) + else if(meshData[i]->fmt.compType == CompType::SInt) fmttype = eGL_SHORT; } - else if(fmts[i]->compByteWidth == 1) + else if(meshData[i]->fmt.compByteWidth == 1) { - if(fmts[i]->compType == CompType::UInt) + if(meshData[i]->fmt.compType == CompType::UInt) fmttype = eGL_UNSIGNED_BYTE; - else if(fmts[i]->compType == CompType::SInt) + else if(meshData[i]->fmt.compType == CompType::SInt) fmttype = eGL_BYTE; } - gl.glVertexAttribIFormat(i, fmts[i]->compCount, fmttype, 0); + gl.glVertexAttribIFormat(i, meshData[i]->fmt.compCount, fmttype, 0); } - else if(fmts[i]->compType == CompType::Double) + else if(meshData[i]->fmt.compType == CompType::Double) { - gl.glVertexAttribLFormat(i, fmts[i]->compCount, eGL_DOUBLE, 0); + gl.glVertexAttribLFormat(i, meshData[i]->fmt.compCount, eGL_DOUBLE, 0); } - GLuint vb = m_pDriver->GetResourceManager()->GetCurrentResource(fmts[i]->buf).name; - gl.glBindVertexBuffer(i, vb, (GLintptr)fmts[i]->offset, fmts[i]->stride); + GLuint vb = m_pDriver->GetResourceManager()->GetCurrentResource(meshData[i]->buf).name; + gl.glBindVertexBuffer(i, vb, (GLintptr)meshData[i]->offset, meshData[i]->stride); } // enable position attribute diff --git a/renderdoc/driver/vulkan/vk_debug.cpp b/renderdoc/driver/vulkan/vk_debug.cpp index 3f87339be..5740e0118 100644 --- a/renderdoc/driver/vulkan/vk_debug.cpp +++ b/renderdoc/driver/vulkan/vk_debug.cpp @@ -3937,17 +3937,6 @@ uint32_t VulkanDebugManager::PickVertex(uint32_t eventID, const MeshDisplay &cfg Matrix4f camMat = cfg.cam ? ((Camera *)cfg.cam)->GetMatrix() : Matrix4f::Identity(); Matrix4f pickMVP = projMat.Mul(camMat); - ResourceFormat resFmt; - resFmt.compByteWidth = cfg.position.compByteWidth; - resFmt.compCount = cfg.position.compCount; - resFmt.compType = cfg.position.compType; - resFmt.special = false; - if(cfg.position.specialFormat != SpecialFormat::Unknown) - { - resFmt.special = true; - resFmt.specialFormat = cfg.position.specialFormat; - } - Matrix4f pickMVPProj; if(cfg.position.unproject) { @@ -6833,22 +6822,9 @@ MeshDisplayPipelines VulkanDebugManager::CacheMeshDisplayPipelines(const MeshFor key |= uint64_t((uint32_t)primary.topo & 0x3f) << bit; bit += 6; - ResourceFormat fmt; - fmt.special = primary.specialFormat != SpecialFormat::Unknown; - fmt.specialFormat = primary.specialFormat; - fmt.compByteWidth = primary.compByteWidth; - fmt.compCount = primary.compCount; - fmt.compType = primary.compType; - - VkFormat primaryFmt = MakeVkFormat(fmt); - - fmt.special = secondary.specialFormat != SpecialFormat::Unknown; - fmt.specialFormat = secondary.specialFormat; - fmt.compByteWidth = secondary.compByteWidth; - fmt.compCount = secondary.compCount; - fmt.compType = secondary.compType; - - VkFormat secondaryFmt = secondary.buf == ResourceId() ? VK_FORMAT_UNDEFINED : MakeVkFormat(fmt); + VkFormat primaryFmt = MakeVkFormat(primary.fmt); + VkFormat secondaryFmt = + secondary.buf == ResourceId() ? VK_FORMAT_UNDEFINED : MakeVkFormat(secondary.fmt); RDCCOMPILE_ASSERT(VK_FORMAT_RANGE_SIZE <= 255, "Mesh pipeline cache key needs an extra bit for format"); @@ -8722,13 +8698,14 @@ MeshFormat VulkanDebugManager::GetPostVSBuffers(uint32_t eventID, uint32_t instI ret.offset = s.instStride * instID; ret.stride = s.vertStride; - ret.compCount = 4; - ret.compByteWidth = 4; - ret.compType = CompType::Float; - ret.specialFormat = SpecialFormat::Unknown; + ret.fmt.compCount = 4; + ret.fmt.compByteWidth = 4; + ret.fmt.compType = CompType::Float; + ret.fmt.special = false; + ret.fmt.specialFormat = SpecialFormat::Unknown; + ret.fmt.bgraOrder = false; ret.showAlpha = false; - ret.bgraOrder = false; ret.topo = MakePrimitiveTopology(s.topo, 1); ret.numVerts = s.numVerts; diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index b0671cfbe..e8aa427f0 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -2009,10 +2009,11 @@ void VulkanReplay::RenderMesh(uint32_t eventID, const vector &second helper.idxByteWidth = 2; helper.topo = Topology::LineList; - helper.specialFormat = SpecialFormat::Unknown; - helper.compByteWidth = 4; - helper.compCount = 4; - helper.compType = CompType::Float; + helper.fmt.special = false; + helper.fmt.specialFormat = SpecialFormat::Unknown; + helper.fmt.compByteWidth = 4; + helper.fmt.compCount = 4; + helper.fmt.compType = CompType::Float; helper.stride = sizeof(Vec4f); diff --git a/renderdoc/replay/replay_driver.cpp b/renderdoc/replay/replay_driver.cpp index 5c97821d9..45adb9e53 100644 --- a/renderdoc/replay/replay_driver.cpp +++ b/renderdoc/replay/replay_driver.cpp @@ -110,12 +110,9 @@ FloatVector HighlightCache::InterpretVertex(byte *data, uint32_t vert, const Mes float *out = &ret.x; - ResourceFormat fmt; - fmt.compByteWidth = cfg.position.compByteWidth; - fmt.compCount = cfg.position.compCount; - fmt.compType = cfg.position.compType; + const ResourceFormat &fmt = cfg.position.fmt; - if(cfg.position.specialFormat == SpecialFormat::R10G10B10A2) + if(fmt.specialFormat == SpecialFormat::R10G10B10A2) { if(data + 4 >= end) { @@ -130,7 +127,7 @@ FloatVector HighlightCache::InterpretVertex(byte *data, uint32_t vert, const Mes ret.w = v.w; return ret; } - else if(cfg.position.specialFormat == SpecialFormat::R11G11B10) + else if(fmt.specialFormat == SpecialFormat::R11G11B10) { if(data + 4 >= end) { @@ -145,21 +142,21 @@ FloatVector HighlightCache::InterpretVertex(byte *data, uint32_t vert, const Mes return ret; } - if(data + cfg.position.compCount * cfg.position.compByteWidth > end) + if(data + fmt.compCount * fmt.compByteWidth > end) { valid = false; return ret; } - for(uint32_t i = 0; i < cfg.position.compCount; i++) + for(uint32_t i = 0; i < fmt.compCount; i++) { *out = ConvertComponent(fmt, data); - data += cfg.position.compByteWidth; + data += fmt.compByteWidth; out++; } - if(cfg.position.bgraOrder) + if(fmt.bgraOrder) { FloatVector reversed; reversed.x = ret.z;