Skip to content

Commit

Permalink
[d3d9] Clamp MipmapLodBias between 0, 15 (+ nan check with fclamp)
Browse files Browse the repository at this point in the history
  • Loading branch information
misyltoad committed Apr 20, 2019
1 parent b8b4d6b commit bd8264e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/d3d9/d3d9_sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "../dxvk/dxvk_hash.h"

#include "../util/util_math.h"

namespace dxvk {

struct D3D9SamplerKey {
Expand Down Expand Up @@ -38,8 +40,14 @@ namespace dxvk {

key.MaxAnisotropy = std::clamp<DWORD>(key.MaxAnisotropy, 0, 16);

if (key.MipFilter == D3DTEXF_NONE)
if (key.MipFilter == D3DTEXF_NONE) {
// May as well try and keep slots down.
key.MipmapLodBias = 0;
}
else {
// Clamp between 0.0f and 15.0f, matching limits of d3d9.
key.MipmapLodBias = fclamp(key.MipmapLodBias, 0.0f, 15.0f);
}

if ( key.AddressU != D3DTADDRESS_BORDER
&& key.AddressV != D3DTADDRESS_BORDER
Expand Down

0 comments on commit bd8264e

Please sign in to comment.