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 committed Jul 7, 2024
1 parent f73a82e commit 520adfa
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 @@ -282,6 +282,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 @@ -28,12 +28,26 @@ 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) {
int32_t minManagedSize = config.getOption<int32_t> ("d3d8.managedBufferPlacement", managedBufferPlacement);
managedBufferPlacement = config.getOption<bool> ("d3d8.managedBufferPlacement", true) ? minManagedSize : UINT32_MAX;
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 @@ -1111,6 +1111,12 @@ namespace dxvk {
{ R"(\\(nations|patriots)\.exe$)", {{
{ "d3d8.managedBufferPlacement", "False" },
}} },
/* 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 520adfa

Please sign in to comment.