From 5177b3b12198830eed5be41901ba0371377e484b Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 13 May 2022 23:07:59 +0200 Subject: [PATCH] r_showSurfaceInfo works --- neo/renderer/ImmediateMode.cpp | 35 ++++++++++-------------- neo/renderer/NVRHI/RenderDebug_NVRHI.cpp | 5 ++-- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/neo/renderer/ImmediateMode.cpp b/neo/renderer/ImmediateMode.cpp index a9d7fa6a..cbf955b4 100644 --- a/neo/renderer/ImmediateMode.cpp +++ b/neo/renderer/ImmediateMode.cpp @@ -138,13 +138,6 @@ void fhImmediateMode::End() commandList->writeBuffer( indexBuffer, lineIndices, drawVertsUsed * sizeof( triIndex_t ) ); commandList->setPermanentBufferState( indexBuffer, nvrhi::ResourceStates::IndexBuffer ); - GFXenum mode = currentMode; - - if( mode == GFX_QUADS || mode == GFX_POLYGON || mode == GFX_QUAD_STRIP ) //quads and polygons are replaced by triangles in GLSL mode - { - mode = GFX_TRIANGLES; - } - renderProgManager.CommitConstantBuffer( commandList ); int bindingLayoutType = renderProgManager.BindingLayoutType(); @@ -157,7 +150,6 @@ void fhImmediateMode::End() if( !tr.backend.currentBindingSets[i] || *tr.backend.currentBindingSets[i]->getDesc() != tr.backend.pendingBindingSetDescs[bindingLayoutType][i] ) { tr.backend.currentBindingSets[i] = tr.backend.bindingCache.GetOrCreateBindingSet( tr.backend.pendingBindingSetDescs[bindingLayoutType][i], ( *layouts )[i] ); - //changeState = true; } } @@ -167,7 +159,6 @@ void fhImmediateMode::End() PipelineKey key{ stateBits, program, tr.backend.depthBias, tr.backend.slopeScaleBias, tr.backend.currentFrameBuffer }; auto pipeline = tr.backend.pipelineCache.GetOrCreatePipeline( key ); - //if( changeState ) { nvrhi::GraphicsState state; @@ -188,24 +179,13 @@ void fhImmediateMode::End() tr.backend.currentViewport.zmin, tr.backend.currentViewport.zmax }; state.viewport.addViewport( viewport ); - -#if 0 - if( !context.scissor.IsEmpty() ) - { - state.viewport.addScissorRect( nvrhi::Rect( context.scissor.x1, context.scissor.x2, context.scissor.y1, context.scissor.y2 ) ); - } - else -#endif - { - state.viewport.addScissorRect( nvrhi::Rect( viewport ) ); - } + state.viewport.addScissorRect( nvrhi::Rect( viewport ) ); commandList->setGraphicsState( state ); } nvrhi::DrawArguments args; args.vertexCount = drawVertsUsed; - //commandList->draw( args ); commandList->drawIndexed( args ); // RB: added stats @@ -298,6 +278,19 @@ void fhImmediateMode::Vertex3f( float x, float y, float z ) drawVertsUsed += 2; } + /* + if( ( currentMode == GFX_LINES ) && + drawVertsUsed >= 2 && + drawVertsUsed + 1 < c_drawVertsCapacity ) + { + // duplicate the last one if new line starts + if( drawVertsUsed % 2 == 0 ) + { + drawVerts[drawVertsUsed] = drawVerts[drawVertsUsed -1]; + drawVertsUsed += 1; + } + } + */ idDrawVert& vertex = drawVerts[drawVertsUsed++]; vertex.xyz.Set( x, y, z ); diff --git a/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp b/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp index 1ae34309..bd6deaae 100644 --- a/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp +++ b/neo/renderer/NVRHI/RenderDebug_NVRHI.cpp @@ -681,9 +681,9 @@ void idRenderBackend::DBG_ShowSurfaceInfo( drawSurf_t** drawSurfs, int numDrawSu // R_AxisToModelMatrix( mt.entity->axis, mt.entity->origin, matrix ); tr.primaryWorld->DrawText( surfModelName, surfPoint + tr.primaryView->renderView.viewaxis[2] * 12, - 0.35f, colorRed, tr.primaryView->renderView.viewaxis ); + 0.35f, colorYellow, tr.primaryView->renderView.viewaxis ); tr.primaryWorld->DrawText( surfMatName, surfPoint, - 0.35f, colorBlue, tr.primaryView->renderView.viewaxis ); + 0.35f, colorCyan, tr.primaryView->renderView.viewaxis ); } /* @@ -1830,6 +1830,7 @@ static void RB_DrawText( const char* text, const idVec3& origin, float scale, co im.Vertex3fv( p1.ToFloatPtr() ); im.Vertex3fv( p2.ToFloatPtr() ); + im.Vertex3fv( p2.ToFloatPtr() ); // RB: just build a triangle of this line } org -= viewAxis[1] * ( spacing * scale ); }