Skip to content

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.

2.6 KB
Raw Blame
/*
**	Command & Conquer Generals Zero Hour(tm)
**	Copyright 2025 Electronic Arts Inc.
**
**	This program is free software: you can redistribute it and/or modify
**	it under the terms of the GNU General Public License as published by
**	the Free Software Foundation, either version 3 of the License, or
**	(at your option) any later version.
**
**	This program is distributed in the hope that it will be useful,
**	but WITHOUT ANY WARRANTY; without even the implied warranty of
**	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**	GNU General Public License for more details.
**
**	You should have received a copy of the GNU General Public License
**	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
// Modified 2026 by İlyas Akın for the macOS/Linux port; see NOTICE.md and the git history.

/*
** The fixed-function inventory.
**
** Replacing fixed-function multitexture with HLSL is most of the Direct3D 11 backend, and the first thing
** that has to be known is how many different things the pipeline is actually asked to compute.  The
** bit layout in shader.h can express tens of thousands of combinations; what the game sets during a
** match is a far smaller set, and it is the smaller set that has to be written as shaders.
**
** This reads the configuration back off the device at every draw, so it sees what a call site set
** directly as well as what went through DX8Wrapper, and counts each distinct combination once.
** Started with -ffprobe and dumped to Run/ffprobe.txt at shutdown.
*/

#ifndef FFPROBE_H
#define FFPROBE_H

#include <d3d9.h>

// Off until W3DDisplay turns it on, which the game always does.  Reading forty states back per
// draw call is not free.
void FixedFunctionProbe_Enable(bool enabled);
bool FixedFunctionProbe_Is_Enabled();

// Off until W3DDisplay turns it on, which the game always does.  Replaces the texture stage
// combiners on the Direct3D 9 device with a generated pixel shader for every draw the generator
// will take.
void CombinerShaders_Enable(bool enabled);
bool CombinerShaders_Are_Enabled();

// Counts one draw and says whether it is one of the draws the probe reads, one in sixteen.  Asked
// before Record so that a caller owing the device state sends it only for those.
bool FixedFunctionProbe_Samples_Draw();

// One sampled draw's worth: reads the stage combiners and the pixel-affecting render states off the
// device and counts the combination.
void FixedFunctionProbe_Record(IDirect3DDevice9 * device);

// Writes the inventory, most used first, and forgets it.  Does nothing when nothing was recorded.
void FixedFunctionProbe_Dump(const char * path);

#endif