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