Skip to content

Commit

Permalink
rend: force Native Depth Interpolation for AMD gpus
Browse files Browse the repository at this point in the history
  • Loading branch information
flyinghead committed Dec 28, 2023
1 parent 06529b6 commit 9f9b29b
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/emulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "hw/pvr/pvr.h"
#include "profiler/fc_profiler.h"
#include "oslib/storage.h"
#include "wsi/context.h"
#include <chrono>

settings_t settings;
Expand Down Expand Up @@ -327,6 +328,8 @@ static void loadSpecialSettings()
config::ForceFreePlay.override(false);
}
}
if (GraphicsContext::Instance()->isAMD())
config::NativeDepthInterpolation.override(true);
}

void dc_reset(bool hard)
Expand Down
5 changes: 5 additions & 0 deletions core/rend/dx11/dx11context.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class DX11Context : public GraphicsContext
bool isIntel() const {
return vendorId == VENDOR_INTEL;
}
bool isAMD() override {
return vendorId == VENDOR_ATI || vendorId == VENDOR_AMD;
}

void setFrameRendered() {
frameRendered = true;
Expand Down Expand Up @@ -97,6 +100,8 @@ class DX11Context : public GraphicsContext
pD3DCompile d3dcompiler = nullptr;

static constexpr UINT VENDOR_INTEL = 0x8086;
static constexpr UINT VENDOR_ATI = 0x1002;
static constexpr UINT VENDOR_AMD = 0x1022;
};
extern DX11Context theDX11Context;
#endif
5 changes: 5 additions & 0 deletions core/rend/dx11/dx11context_lr.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class DX11Context : public GraphicsContext
bool isIntel() const {
return vendorId == VENDOR_INTEL;
}
bool isAMD() override {
return vendorId == VENDOR_ATI || vendorId == VENDOR_AMD;
}

DX11Shaders& getShaders() {
return shaders;
Expand Down Expand Up @@ -90,6 +93,8 @@ class DX11Context : public GraphicsContext
bool supportedTexFormats[5] {}; // indexed by TextureType enum

static constexpr UINT VENDOR_INTEL = 0x8086;
static constexpr UINT VENDOR_ATI = 0x1002;
static constexpr UINT VENDOR_AMD = 0x1022;
};
extern DX11Context theDX11Context;
#endif
1 change: 1 addition & 0 deletions core/rend/dx9/dxcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ bool DXContext::init(bool keepCurrentWindow)
driverName = std::string(id.Description);
driverVersion = std::to_string(id.DriverVersion.HighPart >> 16) + "." + std::to_string((u16)id.DriverVersion.HighPart)
+ "." + std::to_string(id.DriverVersion.LowPart >> 16) + "." + std::to_string((u16)id.DriverVersion.LowPart);
amd = id.VendorId == 0x1002 || id.VendorId == 0x1022;
deviceReady = true;

return true;
Expand Down
4 changes: 4 additions & 0 deletions core/rend/dx9/dxcontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class DXContext : public GraphicsContext
std::string getDriverVersion() override {
return driverVersion;
}
bool isAMD() override {
return amd;
}
void setFrameRendered() {
frameRendered = true;
}
Expand All @@ -69,6 +72,7 @@ class DXContext : public GraphicsContext
bool frameRendered = false;
std::string driverName;
std::string driverVersion;
bool amd = false;
bool deviceReady = false;
};
extern DXContext theDXContext;
Expand Down
3 changes: 3 additions & 0 deletions core/rend/vulkan/vk_context_lr.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class VulkanContext : public GraphicsContext, public FlightManager
+ "." + std::to_string(VK_API_VERSION_MINOR(props.driverVersion))
+ "." + std::to_string(VK_API_VERSION_PATCH(props.driverVersion));
}
bool isAMD() override {
return vendorID == VENDOR_ATI || vendorID == VENDOR_AMD;
}
vk::Format GetDepthFormat() const { return depthFormat; }
static VulkanContext *Instance() { return contextInstance; }
bool SupportsSamplerAnisotropy() const { return samplerAnisotropy; }
Expand Down
3 changes: 3 additions & 0 deletions core/rend/vulkan/vulkan_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ class VulkanContext : public GraphicsContext, public FlightManager
std::string getDriverVersion() override {
return driverVersion;
}
bool isAMD() override {
return vendorID == VENDOR_ATI || vendorID == VENDOR_AMD;
}
vk::Format GetDepthFormat() const { return depthFormat; }
static VulkanContext *Instance() { return contextInstance; }
bool SupportsSamplerAnisotropy() const { return samplerAnisotropy; }
Expand Down
1 change: 1 addition & 0 deletions core/wsi/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class GraphicsContext
virtual void resize() {}
virtual std::string getDriverName() = 0;
virtual std::string getDriverVersion() = 0;
virtual bool isAMD() = 0;
virtual bool hasPerPixel() { return false; }

void setWindow(void *window, void *display = nullptr) {
Expand Down
10 changes: 10 additions & 0 deletions core/wsi/gl_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ void GLGraphicsContext::findGLVersion()
driverName = p != nullptr ? p : "unknown";
p = (const char *)glGetString(GL_VERSION);
driverVersion = p != nullptr ? p : "unknown";
p = (const char *)glGetString(GL_VENDOR);
std::string vendor = p != nullptr ? p : "";
if (vendor.substr(0, 4) == "ATI ")
amd = true;
else if (driverName.find(" ATI ") != std::string::npos
|| driverName.find(" AMD ") != std::string::npos)
// mesa
amd = true;
else
amd = false;
}

void GLGraphicsContext::postInit()
Expand Down
4 changes: 4 additions & 0 deletions core/wsi/gl_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class GLGraphicsContext : public GraphicsContext
std::string getDriverVersion() override {
return driverVersion;
}
bool isAMD() override {
return amd;
}
void resetUIDriver();

bool hasPerPixel() override
Expand All @@ -70,6 +73,7 @@ class GLGraphicsContext : public GraphicsContext
bool _isGLES = false;
std::string driverName;
std::string driverVersion;
bool amd = false;
};

#if defined(LIBRETRO)
Expand Down

0 comments on commit 9f9b29b

Please sign in to comment.