-
Notifications
You must be signed in to change notification settings - Fork 151
Remove d3dx8d dependency from MinGW builds #2176
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
base: main
Are you sure you want to change the base?
Conversation
…rs#2176) Create D3DXCompat.h with WWMath-based D3DX replacements (550 lines). Implement vector/matrix math functions using existing WWMath library. Add D3DXWrapper.h for conditional D3DX inclusion (45 lines). Functions implemented: - Math: D3DXVec4Dot, D3DXVec4Transform, D3DXVec3Transform, D3DXMatrixTranspose, D3DXMatrixMultiply, D3DXMatrixRotationZ (21 uses) - Utilities: D3DXGetErrorStringA, D3DXGetFVFVertexSize (6 uses) - Textures: D3DXCreateTexture, D3DXCreateCubeTexture, D3DXCreateVolumeTexture (6 uses) Functions stubbed for future implementation: - D3DXMatrixInverse: Awaiting Matrix4x4::Inverse() implementation - D3DXLoadSurfaceFromSurface, D3DXFilterTexture: Return errors to trigger fallback to existing game code This provides implementations for most D3DX8 functions used by the game.
…rs#2176) - Add no_d3dx_verify.cmake for post-build DLL import checking - Add MINGW_NO_D3DX option to cmake/mingw.cmake (default: OFF) - Conditional d3dx8d linking in main executables - Update CMake targets for selective D3DXWrapper inclusion - Add verification targets to g_generals and z_generals Build system changes: - cmake/mingw.cmake: NO_D3DX option, selective forced includes - cmake/dx8.cmake: Conditional d3dx8d removal from d3d8lib - cmake/no_d3dx_verify.cmake: Post-build objdump DLL verification - CMakeLists.txt: Include verification system - Target CMakeLists: Add conditional linking and forced includes Currently disabled (MINGW_NO_D3DX=OFF) to use d3dx8.dll until header conflicts are resolved. When enabled (ON), will verify no d3dx8 imports in built executables. Prepares build system for D3DX-free binaries in future releases. Files modified: - 11 CMakeLists.txt files across build system - 1 new cmake verification module (no_d3dx_verify.cmake)
…structure (TheSuperHackers#2176) Complete D3DX8 elimination for Zero Hour targets and enable the feature for both Generals and Zero Hour. This turns on the D3DX-free build by default, eliminating the d3dx8.dll dependency. Changes: - Add D3DXWrapper.h forced include to generalszh, worldbuilder_zh - Enable MINGW_NO_D3DX option by default (header conflicts resolved) - Add shader stub infrastructure (scripts/shaders/water_shader2.psh, water_shader3.psh) - Expand D3DXCompat.h with shader function stubs Build status: - generalsv.exe: 12M, NO d3dx8.dll dependency - generalszh.exe: 13M, NO d3dx8.dll dependency D3DX8 elimination complete for MinGW builds. D3DXAssembleShader implementation completed in next commit.
390987c to
cc3b83e
Compare
…eSuperHackers#2176) Replace D3DXAssembleShader with precompiled bytecode lookup for water shaders. This eliminates the shader compilation dependency. Implementation approach: - Extract 3 shader bytecodes from d3dx8.dll using Wine debugging - Match shader source strings to identify which shader to return - Create ID3DXBuffer wrapper class for bytecode storage Shaders implemented: 1. River water shader (scripts/shaders/water_shader1.psh - co-issued instructions, +mul opcode) 2. Environment mapping water (scripts/shaders/water_shader2.psh - texbem bump environment mapping) 3. Trapezoid water (scripts/shaders/water_shader3.psh - mad multiply-add) Total shader bytecode: ~450 bytes for all 3 shaders combined. This completes D3DX8 elimination for MinGW builds. All D3DX functions used by the game now have replacements or acceptable stubs.
TheSuperHackers#2176) Implement surface copying using D3D8's native IDirect3DDevice8::CopyRects instead of Wine/d3dx8.dll. This provides hardware-accelerated surface copying using Direct3D 8 API directly. Implementation: - Call pSrcSurface->GetDevice() to obtain D3D8 device - Use device->CopyRects() for hardware-accelerated copy - Same API as DX8Wrapper::_Copy_DX8_Rects (14 uses in codebase) - No Wine code needed - pure D3D8 API Why Direct D3D8 instead of Wine: - CopyRects is native D3D8 functionality (no d3dx8.dll required) - Avoids complex Wine texture locking/filtering code - Game already uses this API extensively via DX8Wrapper - Hardware-accelerated, same performance as existing code Function now fully implemented with working surface copy.
…Hackers#2176) Implement D3DXMatrixIdentity using WWMath and stub D3DXCreateFont for disabled Generals Tools build. 1. D3DXMatrixIdentity - Full Implementation - Maps to Matrix4x4::Make_Identity() from WWMath - Used in 8+ locations, including water rendering (W3DWater.cpp) - Critical for clipping matrix initialization 2. D3DXCreateFont - Stub for Disabled Tools - Only used in disabled Generals Tools (apt, w3dviewer) - Build preset RTS_BUILD_GENERALS_TOOLS=OFF by default - Returns D3DERR_NOTAVAILABLE to indicate unavailable functionality - Acceptable stub for out-of-scope build targets Alternative approaches evaluated: - Matrix4x4::Make_Identity() found in WWMath (used for implementation) - No existing game font system suitable for D3DXCreateFont - GDI CreateFont possible but unnecessary for disabled build D3DXMatrixIdentity completes matrix math coverage alongside existing D3DXMatrixMultiply, D3DXMatrixRotationZ, D3DXMatrixTranspose.
…ibility (TheSuperHackers#2176) Point to JohnsterID fork branches with MinGW export alias fixes. These are temporary workarounds until upstream repositories accept the fixes. Changes: - bink-sdk-stub: TheSuperHackers → JohnsterID/fix-mingw-export-aliases - miles-sdk-stub: TheSuperHackers → JohnsterID/fix-mingw-export-aliases Issue: MinGW-w64 requires proper __declspec(dllexport) for stub libraries. Upstream PRs pending to merge these fixes back to TheSuperHackers repos.
TheSuperHackers#2176) Implement surface copying using D3D8's native IDirect3DDevice8::CopyRects instead of Wine/d3dx8.dll. This provides hardware-accelerated surface copying using Direct3D 8 API directly. Implementation: - Call pSrcSurface->GetDevice() to obtain D3D8 device - Use device->CopyRects() for hardware-accelerated copy - Same API as DX8Wrapper::_Copy_DX8_Rects (14 uses in codebase) - No Wine code needed - pure D3D8 API Why Direct D3D8 instead of Wine: - CopyRects is native D3D8 functionality (no d3dx8.dll required) - Avoids complex Wine texture locking/filtering code - Game already uses this API extensively via DX8Wrapper - Hardware-accelerated, same performance as existing code Function now fully implemented with working surface copy.
cc3b83e to
0a7285f
Compare
…Hackers#2176) Implement D3DXMatrixIdentity using WWMath and stub D3DXCreateFont for disabled Generals Tools build. 1. D3DXMatrixIdentity - Full Implementation - Maps to Matrix4x4::Make_Identity() from WWMath - Used in 8+ locations, including water rendering (W3DWater.cpp) - Critical for clipping matrix initialization 2. D3DXCreateFont - Stub for Disabled Tools - Only used in disabled Generals Tools (apt, w3dviewer) - Build preset RTS_BUILD_GENERALS_TOOLS=OFF by default - Returns D3DERR_NOTAVAILABLE to indicate unavailable functionality - Acceptable stub for out-of-scope build targets Alternative approaches evaluated: - Matrix4x4::Make_Identity() found in WWMath (used for implementation) - No existing game font system suitable for D3DXCreateFont - GDI CreateFont possible but unnecessary for disabled build D3DXMatrixIdentity completes matrix math coverage alongside existing D3DXMatrixMultiply, D3DXMatrixRotationZ, D3DXMatrixTranspose.
|
I assume this is AI generated code? Drafts are typically not looked at. |
|
Yes with refactoring and runtime testing. I was going to switch to ready soon as I can't see anything else staring at it. It will help in the future anyway separate to Mingw-w64 with any eventual move to DX9 after VC6. I need to delete the temp commit as I had to use it for runtime testing. |
Greptile Overview
|
| Filename | Overview |
|---|---|
| Core/Libraries/Include/Lib/D3DXCompat.h | Comprehensive D3DX8 compatibility layer with WWMath integration, Direct3D 8 wrappers, and precompiled shader bytecode - all implementations verified correct |
| Core/Libraries/Include/Lib/D3DXWrapper.h | Clean conditional include wrapper that routes to D3DXCompat.h when NO_D3DX is defined, otherwise uses standard d3dx8.h |
| scripts/compile_shaders.py | Pixel Shader 1.1 assembler for water shaders - generates precompiled bytecode arrays embedded in D3DXCompat.h |
| cmake/dx8.cmake | Removes d3dx8d from d3d8lib link libraries when MINGW_NO_D3DX is enabled |
| cmake/mingw.cmake | Added MINGW_NO_D3DX option (default ON) that defines NO_D3DX and sets up D3DXWrapper.h for selective inclusion |
| cmake/no_d3dx_verify.cmake | Post-build verification using objdump to ensure executables have no d3dx8*.dll imports when NO_D3DX is enabled |
| Generals/Code/Main/CMakeLists.txt | Conditionally links d3dx8 only when NO_D3DX is disabled, adds verification for g_generals target |
| GeneralsMD/Code/Main/CMakeLists.txt | Conditionally links d3dx8 only when NO_D3DX is disabled, adds verification for z_generals target |
Sequence Diagram
sequenceDiagram
participant Game as Game Code
participant Wrapper as D3DXWrapper.h
participant Compat as D3DXCompat.h
participant WWMath as WWMath Library
participant D3D8 as Direct3D 8 API
participant Shader as Precompiled Shaders
Note over Game,Shader: MinGW Build with NO_D3DX enabled
Game->>Wrapper: #include D3DXWrapper.h
Wrapper->>Compat: #include D3DXCompat.h (when NO_D3DX)
Note over Compat: Defines include guards to block<br/>min-dx8-sdk D3DX headers
rect rgb(240, 248, 255)
Note over Game,WWMath: Math Operations (WWMath-based)
Game->>Compat: D3DXMatrixInverse()
Compat->>WWMath: Matrix4x4::Inverse()
WWMath-->>Compat: Inverse matrix
Compat-->>Game: D3DXMATRIX result
Game->>Compat: D3DXMatrixMultiply()
Compat->>WWMath: Matrix4x4::operator*
WWMath-->>Compat: Product matrix
Compat-->>Game: D3DXMATRIX result
Game->>Compat: D3DXVec4Transform()
Compat->>WWMath: Matrix4x4::Transform_Vector()
WWMath-->>Compat: Transformed vector
Compat-->>Game: D3DXVECTOR4 result
end
rect rgb(240, 255, 240)
Note over Game,D3D8: Texture Operations (Direct D3D8)
Game->>Compat: D3DXCreateTexture()
Compat->>D3D8: IDirect3DDevice8::CreateTexture()
D3D8-->>Compat: IDirect3DTexture8*
Compat-->>Game: Texture created
Game->>Compat: D3DXLoadSurfaceFromSurface()
Compat->>D3D8: GetDevice() + CopyRects()
D3D8-->>Compat: Hardware-accelerated copy
Compat-->>Game: Surface copied
end
rect rgb(255, 248, 240)
Note over Game,Shader: Shader Assembly (Precompiled)
Game->>Compat: D3DXAssembleShader(water_shader1)
Compat->>Shader: Identify by "+mul r0.a" signature
Shader-->>Compat: shader1_bytecode[]
Compat->>Compat: new D3DXShaderBuffer(bytecode)
Compat-->>Game: ID3DXBuffer* with bytecode
Game->>D3D8: CreatePixelShader(bytecode)
D3D8-->>Game: Pixel shader created
end
Note over Game,Shader: Result: No d3dx8.dll dependency<br/>All functions inline or direct D3D8 calls
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.
1 file reviewed, 1 comment
TheSuperHackers#2176) Implement surface copying using D3D8's native IDirect3DDevice8::CopyRects instead of Wine/d3dx8.dll. This provides hardware-accelerated surface copying using Direct3D 8 API directly. Implementation: - Call pSrcSurface->GetDevice() to obtain D3D8 device - Use device->CopyRects() for hardware-accelerated copy - Same API as DX8Wrapper::_Copy_DX8_Rects (14 uses in codebase) - No Wine code needed - pure D3D8 API Why Direct D3D8 instead of Wine: - CopyRects is native D3D8 functionality (no d3dx8.dll required) - Avoids complex Wine texture locking/filtering code - Game already uses this API extensively via DX8Wrapper - Hardware-accelerated, same performance as existing code Function now fully implemented with working surface copy.
…Hackers#2176) Implement D3DXMatrixIdentity using WWMath and stub D3DXCreateFont for disabled Generals Tools build. 1. D3DXMatrixIdentity - Full Implementation - Maps to Matrix4x4::Make_Identity() from WWMath - Used in 8+ locations, including water rendering (W3DWater.cpp) - Critical for clipping matrix initialization 2. D3DXCreateFont - Stub for Disabled Tools - Only used in disabled Generals Tools (apt, w3dviewer) - Build preset RTS_BUILD_GENERALS_TOOLS=OFF by default - Returns D3DERR_NOTAVAILABLE to indicate unavailable functionality - Acceptable stub for out-of-scope build targets Alternative approaches evaluated: - Matrix4x4::Make_Identity() found in WWMath (used for implementation) - No existing game font system suitable for D3DXCreateFont - GDI CreateFont possible but unnecessary for disabled build D3DXMatrixIdentity completes matrix math coverage alongside existing D3DXMatrixMultiply, D3DXMatrixRotationZ, D3DXMatrixTranspose.
0a7285f to
09e6ff3
Compare
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.
2 files reviewed, 2 comments
| /** | ||
| * D3DXCompat.h - D3DX8 compatibility layer using WWMath | ||
| * | ||
| * This header provides replacements for D3DX8 math functions using the existing | ||
| * WWMath library (Westwood Math). This eliminates the need for d3dx8.dll at runtime. | ||
| * | ||
| * Usage: Define NO_D3DX before including D3DX8 headers |
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.
Missing @file directive in Doxygen block
| /** | |
| * D3DXCompat.h - D3DX8 compatibility layer using WWMath | |
| * | |
| * This header provides replacements for D3DX8 math functions using the existing | |
| * WWMath library (Westwood Math). This eliminates the need for d3dx8.dll at runtime. | |
| * | |
| * Usage: Define NO_D3DX before including D3DX8 headers | |
| /** | |
| * @file D3DXCompat.h | |
| * @brief D3DX8 compatibility layer using WWMath | |
| * | |
| * This header provides replacements for D3DX8 math functions using the existing | |
| * WWMath library (Westwood Math). This eliminates the need for d3dx8.dll at runtime. | |
| * | |
| * Usage: Define NO_D3DX before including D3DX8 headers | |
| */ |
Context Used: Rule from dashboard - All source files (.h, .cpp, .inl) must have a standardized prologue consisting of: 1) GPL-3.0 licens... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/Libraries/Include/Lib/D3DXCompat.h
Line: 19:25
Comment:
Missing `@file` directive in Doxygen block
```suggestion
/**
* @file D3DXCompat.h
* @brief D3DX8 compatibility layer using WWMath
*
* This header provides replacements for D3DX8 math functions using the existing
* WWMath library (Westwood Math). This eliminates the need for d3dx8.dll at runtime.
*
* Usage: Define NO_D3DX before including D3DX8 headers
*/
```
**Context Used:** Rule from `dashboard` - All source files (.h, .cpp, .inl) must have a standardized prologue consisting of: 1) GPL-3.0 licens... ([source](https://app.greptile.com/review/custom-context?memory=c1850c23-ecc8-49a8-a6e9-ffb44120e6b3))
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| /** | ||
| * D3DXWrapper.h - Conditional D3DX8 include | ||
| * | ||
| * Include this file instead of <d3dx8.h> directly. | ||
| * When NO_D3DX is defined, uses compatibility layer. | ||
| * Otherwise, uses standard D3DX8 headers. | ||
| * | ||
| * NOTE: This header is safe to force-include globally. | ||
| * For C files, it does nothing when NO_D3DX is defined. | ||
| */ |
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.
Missing @file directive in Doxygen block
| /** | |
| * D3DXWrapper.h - Conditional D3DX8 include | |
| * | |
| * Include this file instead of <d3dx8.h> directly. | |
| * When NO_D3DX is defined, uses compatibility layer. | |
| * Otherwise, uses standard D3DX8 headers. | |
| * | |
| * NOTE: This header is safe to force-include globally. | |
| * For C files, it does nothing when NO_D3DX is defined. | |
| */ | |
| /** | |
| * @file D3DXWrapper.h | |
| * @brief Conditional D3DX8 include | |
| * | |
| * Include this file instead of <d3dx8.h> directly. | |
| * When NO_D3DX is defined, uses compatibility layer. | |
| * Otherwise, uses standard D3DX8 headers. | |
| * | |
| * NOTE: This header is safe to force-include globally. | |
| * For C files, it does nothing when NO_D3DX is defined. | |
| */ |
Context Used: Rule from dashboard - All source files (.h, .cpp, .inl) must have a standardized prologue consisting of: 1) GPL-3.0 licens... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/Libraries/Include/Lib/D3DXWrapper.h
Line: 19:28
Comment:
Missing `@file` directive in Doxygen block
```suggestion
/**
* @file D3DXWrapper.h
* @brief Conditional D3DX8 include
*
* Include this file instead of <d3dx8.h> directly.
* When NO_D3DX is defined, uses compatibility layer.
* Otherwise, uses standard D3DX8 headers.
*
* NOTE: This header is safe to force-include globally.
* For C files, it does nothing when NO_D3DX is defined.
*/
```
**Context Used:** Rule from `dashboard` - All source files (.h, .cpp, .inl) must have a standardized prologue consisting of: 1) GPL-3.0 licens... ([source](https://app.greptile.com/review/custom-context?memory=c1850c23-ecc8-49a8-a6e9-ffb44120e6b3))
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.…rs#2176) Create D3DXCompat.h with WWMath-based D3DX replacements (550 lines). Implement vector/matrix math functions using existing WWMath library. Add D3DXWrapper.h for conditional D3DX inclusion (45 lines). Functions implemented: - Math: D3DXVec4Dot, D3DXVec4Transform, D3DXVec3Transform, D3DXMatrixTranspose, D3DXMatrixMultiply, D3DXMatrixRotationZ (21 uses) - Utilities: D3DXGetErrorStringA, D3DXGetFVFVertexSize (6 uses) - Textures: D3DXCreateTexture, D3DXCreateCubeTexture, D3DXCreateVolumeTexture (6 uses) Functions stubbed for future implementation: - D3DXMatrixInverse: Awaiting Matrix4x4::Inverse() implementation - D3DXLoadSurfaceFromSurface, D3DXFilterTexture: Return errors to trigger fallback to existing game code This provides implementations for most D3DX8 functions used by the game.
…rs#2176) - Add no_d3dx_verify.cmake for post-build DLL import checking - Add MINGW_NO_D3DX option to cmake/mingw.cmake (default: OFF) - Conditional d3dx8d linking in main executables - Update CMake targets for selective D3DXWrapper inclusion - Add verification targets to g_generals and z_generals Build system changes: - cmake/mingw.cmake: NO_D3DX option, selective forced includes - cmake/dx8.cmake: Conditional d3dx8d removal from d3d8lib - cmake/no_d3dx_verify.cmake: Post-build objdump DLL verification - CMakeLists.txt: Include verification system - Target CMakeLists: Add conditional linking and forced includes Currently disabled (MINGW_NO_D3DX=OFF) to use d3dx8.dll until header conflicts are resolved. When enabled (ON), will verify no d3dx8 imports in built executables. Prepares build system for D3DX-free binaries in future releases. Files modified: - 11 CMakeLists.txt files across build system - 1 new cmake verification module (no_d3dx_verify.cmake)
…structure (TheSuperHackers#2176) Complete D3DX8 elimination for Zero Hour targets and enable the feature for both Generals and Zero Hour. This turns on the D3DX-free build by default, eliminating the d3dx8.dll dependency. Changes: - Add D3DXWrapper.h forced include to generalszh, worldbuilder_zh - Enable MINGW_NO_D3DX option by default (header conflicts resolved) - Add shader stub infrastructure (scripts/shaders/water_shader2.psh, water_shader3.psh) - Expand D3DXCompat.h with shader function stubs Build status: - generalsv.exe: 12M, NO d3dx8.dll dependency - generalszh.exe: 13M, NO d3dx8.dll dependency D3DX8 elimination complete for MinGW builds. D3DXAssembleShader implementation completed in next commit.
…eSuperHackers#2176) Replace D3DXAssembleShader with precompiled bytecode lookup for water shaders. This eliminates the shader compilation dependency. Implementation approach: - Extract 3 shader bytecodes from d3dx8.dll using Wine debugging - Match shader source strings to identify which shader to return - Create ID3DXBuffer wrapper class for bytecode storage Shaders implemented: 1. River water shader (scripts/shaders/water_shader1.psh - co-issued instructions, +mul opcode) 2. Environment mapping water (scripts/shaders/water_shader2.psh - texbem bump environment mapping) 3. Trapezoid water (scripts/shaders/water_shader3.psh - mad multiply-add) Total shader bytecode: ~450 bytes for all 3 shaders combined. This completes D3DX8 elimination for MinGW builds. All D3DX functions used by the game now have replacements or acceptable stubs.
TheSuperHackers#2176) Implement surface copying using D3D8's native IDirect3DDevice8::CopyRects instead of Wine/d3dx8.dll. This provides hardware-accelerated surface copying using Direct3D 8 API directly. Implementation: - Call pSrcSurface->GetDevice() to obtain D3D8 device - Use device->CopyRects() for hardware-accelerated copy - Same API as DX8Wrapper::_Copy_DX8_Rects (14 uses in codebase) - No Wine code needed - pure D3D8 API Why Direct D3D8 instead of Wine: - CopyRects is native D3D8 functionality (no d3dx8.dll required) - Avoids complex Wine texture locking/filtering code - Game already uses this API extensively via DX8Wrapper - Hardware-accelerated, same performance as existing code Function now fully implemented with working surface copy.
09e6ff3 to
a5121e0
Compare
…Hackers#2176) Implement D3DXMatrixIdentity using WWMath and stub D3DXCreateFont for disabled Generals Tools build. 1. D3DXMatrixIdentity - Full Implementation - Maps to Matrix4x4::Make_Identity() from WWMath - Used in 8+ locations, including water rendering (W3DWater.cpp) - Critical for clipping matrix initialization 2. D3DXCreateFont - Stub for Disabled Tools - Only used in disabled Generals Tools (apt, w3dviewer) - Build preset RTS_BUILD_GENERALS_TOOLS=OFF by default - Returns D3DERR_NOTAVAILABLE to indicate unavailable functionality - Acceptable stub for out-of-scope build targets Alternative approaches evaluated: - Matrix4x4::Make_Identity() found in WWMath (used for implementation) - No existing game font system suitable for D3DXCreateFont - GDI CreateFont possible but unnecessary for disabled build D3DXMatrixIdentity completes matrix math coverage alongside existing D3DXMatrixMultiply, D3DXMatrixRotationZ, D3DXMatrixTranspose.
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.
1 file reviewed, 1 comment
…structure (TheSuperHackers#2176) Complete D3DX8 elimination for Zero Hour targets and enable the feature for both Generals and Zero Hour. This turns on the D3DX-free build by default, eliminating the d3dx8.dll dependency. Changes: - Add D3DXWrapper.h forced include to generalszh, worldbuilder_zh - Enable MINGW_NO_D3DX option by default (header conflicts resolved) - Add shader stub infrastructure (scripts/shaders/water_shader2.psh, water_shader3.psh) - Expand D3DXCompat.h with shader function stubs Build status: - generalsv.exe: 12M, NO d3dx8.dll dependency - generalszh.exe: 13M, NO d3dx8.dll dependency D3DX8 elimination complete for MinGW builds. D3DXAssembleShader implementation completed in next commit.
…eSuperHackers#2176) Replace D3DXAssembleShader with precompiled bytecode lookup for water shaders. This eliminates the shader compilation dependency. Implementation approach: - Extract 3 shader bytecodes from d3dx8.dll using Wine debugging - Match shader source strings to identify which shader to return - Create ID3DXBuffer wrapper class for bytecode storage Shaders implemented: 1. River water shader (scripts/shaders/water_shader1.psh - co-issued instructions, +mul opcode) 2. Environment mapping water (scripts/shaders/water_shader2.psh - texbem bump environment mapping) 3. Trapezoid water (scripts/shaders/water_shader3.psh - mad multiply-add) Total shader bytecode: ~450 bytes for all 3 shaders combined. This completes D3DX8 elimination for MinGW builds. All D3DX functions used by the game now have replacements or acceptable stubs.
TheSuperHackers#2176) Implement surface copying using D3D8's native IDirect3DDevice8::CopyRects instead of Wine/d3dx8.dll. This provides hardware-accelerated surface copying using Direct3D 8 API directly. Implementation: - Call pSrcSurface->GetDevice() to obtain D3D8 device - Use device->CopyRects() for hardware-accelerated copy - Same API as DX8Wrapper::_Copy_DX8_Rects (14 uses in codebase) - No Wine code needed - pure D3D8 API Why Direct D3D8 instead of Wine: - CopyRects is native D3D8 functionality (no d3dx8.dll required) - Avoids complex Wine texture locking/filtering code - Game already uses this API extensively via DX8Wrapper - Hardware-accelerated, same performance as existing code Function now fully implemented with working surface copy.
…Hackers#2176) Implement D3DXMatrixIdentity using WWMath and stub D3DXCreateFont for disabled Generals Tools build. 1. D3DXMatrixIdentity - Full Implementation - Maps to Matrix4x4::Make_Identity() from WWMath - Used in 8+ locations, including water rendering (W3DWater.cpp) - Critical for clipping matrix initialization 2. D3DXCreateFont - Stub for Disabled Tools - Only used in disabled Generals Tools (apt, w3dviewer) - Build preset RTS_BUILD_GENERALS_TOOLS=OFF by default - Returns D3DERR_NOTAVAILABLE to indicate unavailable functionality - Acceptable stub for out-of-scope build targets Alternative approaches evaluated: - Matrix4x4::Make_Identity() found in WWMath (used for implementation) - No existing game font system suitable for D3DXCreateFont - GDI CreateFont possible but unnecessary for disabled build D3DXMatrixIdentity completes matrix math coverage alongside existing D3DXMatrixMultiply, D3DXMatrixRotationZ, D3DXMatrixTranspose.
a5121e0 to
dae47c4
Compare
Summary
Eliminates d3dx8d.dll dependency for MinGW-w64 (i686) builds by implementing a D3DX8 compatibility layer using existing WWMath libraries and Direct3D 8 native APIs.
Build Strategy: Merge with Rebase (preserves commit history)
What This Achieves
Removed d3dx8d dependency from MinGW build targets g_generals and z_generals
generalsv.exe: 12M, no d3dx8.dll dependencygeneralszh.exe: 13M, no d3dx8.dll dependencyProvides strategic foundation for DX9 migration
Zero runtime overhead
Function Replacement (D3DXCompat.h)
Link-Time (cmake/dx8.cmake)
Implementation Highlights
D3DX Function Coverage (19 used by game)
Fully Implemented (16):
Acceptable Stubs (3):
Shader Precompilation
Generated by
scripts/compile_shaders.pyfromscripts/shaders/*.psh:D3DXAssembleShader identifies shaders by signature strings and returns precompiled bytecode.
Build Verification
Environment:
Commands:
DLL Dependencies:
Known Limitations
1. WorldBuilder Not Supported
D3DXCreateFontis stubbed (4 call sites inwbview3d.cpp)RTS_BUILD_GENERALS_TOOLSdisabled)g_generals,z_generals)D3DXCreateFontalternative.### 2. Temporary Forked Dependencies (BLOCKER)- bink-sdk-stub:JohnsterID/bink-sdk-stub@fix-mingw-export-aliases- miles-sdk-stub:JohnsterID/miles-sdk-stub@fix-mingw-export-aliases- TODO: Remove commit before merge, only used for runtime testing