forked from electronicarts/CnC_Generals_Zero_Hour
-
Notifications
You must be signed in to change notification settings - Fork 81
[ZH] Fix the bugged Heat Haze (Smudge) effect of the USA Microwave Tank #1073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
xezon
wants to merge
1
commit into
TheSuperHackers:main
Choose a base branch
from
xezon:xezon/fix-smudge-effect
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+18
−4
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,9 @@ void W3DSmudgeManager::ReleaseResources(void) | |
//Make sure (SMUDGE_DRAW_SIZE * 12) < 65535 because that's the max index buffer size. | ||
#define SMUDGE_DRAW_SIZE 500 //draw at most 50 smudges per call. Tweak value to improve CPU/GPU parallelism. | ||
|
||
static_assert(SMUDGE_DRAW_SIZE * 12 < 65535, "Must not exceed the max index buffer size"); | ||
|
||
|
||
void W3DSmudgeManager::ReAcquireResources(void) | ||
{ | ||
ReleaseResources(); | ||
|
@@ -467,12 +470,12 @@ void W3DSmudgeManager::render(RenderInfoClass &rinfo) | |
VertexMaterialClass *vmat=VertexMaterialClass::Get_Preset(VertexMaterialClass::PRELIT_DIFFUSE); | ||
DX8Wrapper::Set_Material(vmat); | ||
REF_PTR_RELEASE(vmat); | ||
DX8Wrapper::Apply_Render_State_Changes(); | ||
|
||
//Disable reading texture alpha since it's undefined. | ||
//DX8Wrapper::Set_DX8_Texture_Stage_State(0,D3DTSS_COLOROP,D3DTOP_SELECTARG1); | ||
DX8Wrapper::Set_DX8_Texture_Stage_State(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG2); | ||
|
||
Int smudgesBatchCount=0; | ||
Int smudgesRemaining=count; | ||
set=m_usedSmudgeSetList.Head(); //first smudge set that needs rendering. | ||
Smudge *remainingSmudgeStart=set->getUsedSmudgeList().Head(); //first smudge that needs rendering. | ||
|
@@ -502,7 +505,8 @@ void W3DSmudgeManager::render(RenderInfoClass &rinfo) | |
|
||
//Check if we exceeded maximum number of smudges allowed per draw call. | ||
if (smudgesInRenderBatch >= count) | ||
{ remainingSmudgeStart = smudge; | ||
{ | ||
remainingSmudgeStart = smudge; | ||
goto flushSmudges; | ||
} | ||
|
||
|
@@ -535,9 +539,10 @@ void W3DSmudgeManager::render(RenderInfoClass &rinfo) | |
if (set) //start next batch at beginning of set. | ||
remainingSmudgeStart = set->getUsedSmudgeList().Head(); | ||
} | ||
flushSmudges: | ||
DX8Wrapper::Set_Vertex_Buffer(vb_access); | ||
} | ||
flushSmudges: | ||
++smudgesBatchCount; | ||
DX8Wrapper::Set_Vertex_Buffer(vb_access); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I moved this call outside the above scope, because that was within the lock of the vertex buffer, which did not appear to cause issues but is technically not right. |
||
|
||
DX8Wrapper::Draw_Triangles( 0,smudgesInRenderBatch*4, 0, smudgesInRenderBatch*5); | ||
|
||
|
@@ -553,6 +558,15 @@ void W3DSmudgeManager::render(RenderInfoClass &rinfo) | |
smudgesRemaining -= smudgesInRenderBatch; | ||
} | ||
|
||
// TheSuperHackers @bugfix xezon 15/06/2025 Draw a dummy point with the last vertex buffer | ||
// to force the GPU to flush all current pipeline state and commit the previous draw call. | ||
// This is required for some AMD models and drivers that refuse to flush a single draw call | ||
// for the smudges. This draw call is invisible and harmless. | ||
if (smudgesBatchCount == 1) | ||
{ | ||
DX8Wrapper::_Get_D3D_Device8()->DrawPrimitive(D3DPT_POINTLIST, 0, 1); | ||
} | ||
|
||
DX8Wrapper::Set_DX8_Texture_Stage_State(0,D3DTSS_COLOROP,D3DTOP_MODULATE); | ||
DX8Wrapper::Set_DX8_Texture_Stage_State(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE); | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this call, because
DX8Wrapper::Draw_Triangles
will call this as well and therefore it is redundant.