Skip to content
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

Fix crash for DOF blur at default DOF resolution #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions RenderstateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,26 @@

RSManager RSManager::instance;

static const char *PIXEL_SHADER_DUMP_DIR = "dsfix/pixelshader_dump";
static const char *PIXEL_SHADER_OVERRIDE_DIR = "dsfix/pixelshader_override";
static const char *VERTEX_SHADER_DUMP_DIR = "dsfix/vertexshader_dump";
static const char *VERTEX_SHADER_OVERRIDE_DIR = "dsfix/vertexshader_override";
namespace {
const char *PIXEL_SHADER_DUMP_DIR = "dsfix/pixelshader_dump";
const char *PIXEL_SHADER_OVERRIDE_DIR = "dsfix/pixelshader_override";
const char *VERTEX_SHADER_DUMP_DIR = "dsfix/vertexshader_dump";
const char *VERTEX_SHADER_OVERRIDE_DIR = "dsfix/vertexshader_override";

unsigned getDOFResolution() {
unsigned setting = Settings::get().getDOFOverrideResolution();
if (setting == 0) {
return 360;
} else {
return setting;
}
}
}

void RSManager::initResources() {
SDLOG(0, "RenderstateManager resource initialization started\n");
unsigned rw = Settings::get().getRenderWidth(), rh = Settings::get().getRenderHeight();
unsigned dofRes = Settings::get().getDOFOverrideResolution();
unsigned dofRes = getDOFResolution();
if(Settings::get().getAAQuality()) {
if(Settings::get().getAAType() == "SMAA") {
smaa = new SMAA(d3ddev, rw, rh, (SMAA::Preset)(Settings::get().getAAQuality()-1));
Expand Down Expand Up @@ -581,7 +592,7 @@ void RSManager::reloadScao() {

void RSManager::reloadGauss() {
SAFEDELETE(gauss);
gauss = new GAUSS(d3ddev, Settings::get().getDOFOverrideResolution()*16/9, Settings::get().getDOFOverrideResolution());
gauss = new GAUSS(d3ddev, getDOFResolution()*16/9, getDOFResolution());
SDLOG(0, "Reloaded GAUSS\n");
}

Expand Down Expand Up @@ -754,7 +765,7 @@ bool RSManager::isTextureText(IDirect3DBaseTexture9* t) {
}

unsigned RSManager::isDof(unsigned width, unsigned height) {
unsigned topWidth = Settings::get().getDOFOverrideResolution()*16/9, topHeight = Settings::get().getDOFOverrideResolution();
unsigned topWidth = getDOFResolution()*16/9, topHeight = getDOFResolution();
if(width == topWidth && height == topHeight) return 1;
if(width == topWidth/2 && height == topHeight/2) return 2;
return 0;
Expand Down