Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
perf(ww3d2): make the shared dynamic buffers full size once
Olcay Seygan63279e42b6f1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1e25e323e..3a08ff5c4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -21,6 +21,7 @@ found and fixed — EA's own, not port damage.**- A screen full of fire and smoke is cheaper to draw. Thirty Inferno Cannons shelling twenty Crusaders used to send the graphics card 459 separate batches of see-through effects a frame, mostly the same texture again and again, and the game looked up the same seven card settings from scratch for every one of them. Matching effects go out together now, and settings that have not changed are not looked up again: 177 batches, and the same battle went from 11.6ms a frame to 8.6ms. It is at 6.7ms now, since the game stopped preparing everything it draws a second time for a copy of the picture nobody sees. Nothing on screen changes, the effects are drawn in exactly the order they were.- The same battle with the particle limit turned up costs 7.6ms a frame where it cost 9.1ms, and the old renderer went from 9.3ms to 6.3ms. Both were keeping a count of every kind of draw the game makes, and both did it by writing out and reading back a description of each one, on every draw, for a report no player ever opens. They glance at one draw in sixteen now. The new renderer also stopped re-sending the graphics card settings it had just sent.- Raise the particle limit as far as you like and every puff gets drawn. Past about sixteen thousand smoke and fire sprites on screen the game quietly stopped drawing the rest: a test with 68,000 of them showed barely a fifth. A test with 101,000 now draws all of them at 8.3ms a frame, and in 1,200 frames not one fell below 60 a second. The first version that drew them all took 22.4ms; the rest came from sorting and copying them far less and from sharing the work across every core of the processor.+- Big fights no longer drag the picture down into the twenties. Every moving tank and soldier, and every puff of smoke, goes to the graphics card through one shared scratch area, and it was so small that a big fight on Bombardment Beach filled it about fifty times a frame. Each refill made the processor wait for the card, 8 to 12ms of every frame, while the card sat two thirds idle. The area is made full size once now and refills about seven times a frame, in 0.02ms. The same 16,000-frame battle, fast-forwarded, finishes in 226 seconds where it took between 263 and 325, and the seconds that fell under 50 frames a second went from 125 or more to 4.- Every animation runs on a clock instead of counting frames.- A scroll that starts after the camera has stood still no longer lurches. The first frame of the move was timed from the last time the camera moved, so after a few seconds of looking at one spot it was worth three frames of scrolling at once. The clock runs while the camera is still now, and the first frame moves one frame's worth.- Briefing and cutscene subtitles hold long enough to read again.diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8indexbuffer.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8indexbuffer.cppindex 245649cc7..db2565f14 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8indexbuffer.cpp+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8indexbuffer.cpp@@ -46,7 +46,9 @@#include "thread.h"#include "wwmemlog.h"-#define DEFAULT_IB_SIZE 5000+// Made full size once, for the reason DEFAULT_VB_SIZE in dx8vertexbuffer.cpp gives: each time the+// buffer fills, the next lock is a DISCARD the Direct3D 11 driver has to rename.+#define DEFAULT_IB_SIZE 65535static bool _DynamicSortingIndexArrayInUse=false;static SortingIndexBufferClass* _DynamicSortingIndexArray;diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8vertexbuffer.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8vertexbuffer.cppindex 9901c01db..d674fccc0 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8vertexbuffer.cpp+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8vertexbuffer.cpp@@ -48,7 +48,13 @@#include "wwmemlog.h"#include "d3dx9runtime.h"-#define DEFAULT_VB_SIZE 5000+// The shared dynamic buffer is made at the most a 16 bit vertex count can name, once. Every time+// it fills, the next lock is a DISCARD, and on the Direct3D 11 frame each DISCARD is a buffer the+// driver has to rename. At EA's 5000 it filled about 50 times a frame in a big fight on Bombardment+// Beach (skinned units and the sorted particles all come through it) and Map spent 8 to 12 ms of+// the scene waiting for a free copy while the GPU sat about a third busy. At 65535 it is about 7+// DISCARDs a frame and 0.02 ms. It also never has to grow, so it is never released mid-match.+#define DEFAULT_VB_SIZE 65535static bool _DynamicSortingVertexArrayInUse=false;//static VertexFormatXYZNDUV2* _DynamicSortingVertexArray=NULL;