@@ -80,6 +80,9 @@ void W3DSmudgeManager::ReleaseResources(void)
80
80
// Make sure (SMUDGE_DRAW_SIZE * 12) < 65535 because that's the max index buffer size.
81
81
#define SMUDGE_DRAW_SIZE 500 // draw at most 50 smudges per call. Tweak value to improve CPU/GPU parallelism.
82
82
83
+ static_assert (SMUDGE_DRAW_SIZE * 12 < 65535 , " Must not exceed the max index buffer size" );
84
+
85
+
83
86
void W3DSmudgeManager::ReAcquireResources (void )
84
87
{
85
88
ReleaseResources ();
@@ -467,12 +470,12 @@ void W3DSmudgeManager::render(RenderInfoClass &rinfo)
467
470
VertexMaterialClass *vmat=VertexMaterialClass::Get_Preset (VertexMaterialClass::PRELIT_DIFFUSE);
468
471
DX8Wrapper::Set_Material (vmat);
469
472
REF_PTR_RELEASE (vmat);
470
- DX8Wrapper::Apply_Render_State_Changes ();
471
473
472
474
// Disable reading texture alpha since it's undefined.
473
475
// DX8Wrapper::Set_DX8_Texture_Stage_State(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1);
474
476
DX8Wrapper::Set_DX8_Texture_Stage_State (0 ,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2);
475
477
478
+ Int smudgesBatchCount=0 ;
476
479
Int smudgesRemaining=count;
477
480
set=m_usedSmudgeSetList.Head (); // first smudge set that needs rendering.
478
481
Smudge *remainingSmudgeStart=set->getUsedSmudgeList ().Head (); // first smudge that needs rendering.
@@ -502,7 +505,8 @@ void W3DSmudgeManager::render(RenderInfoClass &rinfo)
502
505
503
506
// Check if we exceeded maximum number of smudges allowed per draw call.
504
507
if (smudgesInRenderBatch >= count)
505
- { remainingSmudgeStart = smudge;
508
+ {
509
+ remainingSmudgeStart = smudge;
506
510
goto flushSmudges;
507
511
}
508
512
@@ -535,9 +539,10 @@ void W3DSmudgeManager::render(RenderInfoClass &rinfo)
535
539
if (set) // start next batch at beginning of set.
536
540
remainingSmudgeStart = set->getUsedSmudgeList ().Head ();
537
541
}
538
- flushSmudges:
539
- DX8Wrapper::Set_Vertex_Buffer (vb_access);
540
542
}
543
+ flushSmudges:
544
+ ++smudgesBatchCount;
545
+ DX8Wrapper::Set_Vertex_Buffer (vb_access);
541
546
542
547
DX8Wrapper::Draw_Triangles ( 0 ,smudgesInRenderBatch*4 , 0 , smudgesInRenderBatch*5 );
543
548
@@ -553,6 +558,15 @@ void W3DSmudgeManager::render(RenderInfoClass &rinfo)
553
558
smudgesRemaining -= smudgesInRenderBatch;
554
559
}
555
560
561
+ // TheSuperHackers @bugfix xezon 15/06/2025 Draw a dummy point with the last vertex buffer
562
+ // to force the GPU to flush all current pipeline state and commit the previous draw call.
563
+ // This is required for some AMD models and drivers that refuse to flush a single draw call
564
+ // for the smudges. This draw call is invisible and harmless.
565
+ if (smudgesBatchCount == 1 )
566
+ {
567
+ DX8Wrapper::_Get_D3D_Device8 ()->DrawPrimitive (D3DPT_POINTLIST, 0 , 1 );
568
+ }
569
+
556
570
DX8Wrapper::Set_DX8_Texture_Stage_State (0 ,D3DTSS_COLOROP,D3DTOP_MODULATE);
557
571
DX8Wrapper::Set_DX8_Texture_Stage_State (0 ,D3DTSS_ALPHAOP,D3DTOP_MODULATE);
558
572
0 commit comments