Skip to content

Commit

Permalink
[d3d8] Add a workaround for LotR: Fellowship of the Ring
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall authored and AlpyneDreams committed Jul 7, 2024
1 parent 58e986b commit cb2a2b5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/d3d8/d3d8_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ namespace dxvk {
IDirect3DTexture8** ppTexture) {
InitReturnPtr(ppTexture);

// Nvidia & Intel workaround for The Lord of the Rings: The Fellowship of the Ring
if (m_d3d8Options.placeP8InScratch && Format == D3DFMT_P8)
Pool = D3DPOOL_SCRATCH;

Com<d3d9::IDirect3DTexture9> pTex9 = nullptr;
HRESULT res = GetD3D9()->CreateTexture(
Width,
Expand Down
16 changes: 15 additions & 1 deletion src/d3d8/d3d8_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,24 @@ namespace dxvk {
/// May hurt performance outside of specifc games that benefit from it.
bool batching = false;

/// The Lord of the Rings: The Fellowship of the Ring tries to create a P8 texture
/// in D3DPOOL_MANAGED on Nvidia and Intel, which fails, but has a separate code
/// path for ATI/AMD that creates it in D3DPOOL_SCRATCH instead, which works.
///
/// The internal logic determining this path doesn't seem to be d3d-related, but
/// the game works universally if we mimic its own ATI/AMD workaround during P8
/// texture creation.
///
/// Early Nvidia GPUs, such as the GeForce 4 generation cards, included and exposed
/// P8 texture support. However, it was no longer advertised with cards in the FX series
/// and above. Most likely ATI/AMD drivers never supported P8 in the first place.
bool placeP8InScratch = false;

D3D8Options() {}
D3D8Options(const Config& config) {
auto forceVsDeclStr = config.getOption<std::string>("d3d8.forceVsDecl", "");
auto forceVsDeclStr = config.getOption<std::string>("d3d8.forceVsDecl", "");
batching = config.getOption<bool> ("d3d8.batching", batching);
placeP8InScratch = config.getOption<bool> ("d3d8.placeP8InScratch", placeP8InScratch);

parseVsDecl(forceVsDeclStr);
}
Expand Down
6 changes: 6 additions & 0 deletions src/util/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,12 @@ namespace dxvk {
{ R"(\\X2\.exe$)", {{
{ "d3d9.cachedDynamicBuffers", "True" },
}} },
/* The Lord of the Rings: *
* The Fellowship of the Ring */
{ R"(\\Fellowship\.exe$)", {{
{ "d3d9.maxFrameRate", "60" },
{ "d3d8.placeP8InScratch", "True" },
}} },
}};


Expand Down

0 comments on commit cb2a2b5

Please sign in to comment.