Skip to content

Commit

Permalink
More cleaning on dx12 to eliminate unnused code.
Browse files Browse the repository at this point in the history
Added new options, more aspect ratio modes and Disable filtering to allow correct output  with scaling shaders.
  • Loading branch information
Tinob committed Feb 23, 2016
1 parent fd51451 commit 4822c37
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 61 deletions.
4 changes: 3 additions & 1 deletion Source/Core/DolphinWX/VideoConfigDiag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ static wxString phong_lighting_desc = _("Use Phong specular model when pixel lig
static wxString hacked_buffer_upload_desc = _("Uses unsafe operations to speed up vertex streaming in OpenGL. There are no known problems on supported GPUs, but it will cause severe stability and graphical issues otherwise.\n\nIf unsure, leave this unchecked.");
static wxString fast_depth_calc_desc = _("Use a less accurate algorithm to calculate depth values.\nCauses issues in a few games but might give a decent speedup.\n\nIf unsure, leave this checked.");
static wxString force_filtering_desc = _("Force texture filtering even if the emulated game explicitly disabled it.\nImproves texture quality slightly but causes glitches in some games.\n\nIf unsure, leave this unchecked.");
static wxString disable_filtering_desc = _("Disable texture filtering even if the emulated game explicitly enable it.\n\nIf unsure, leave this unchecked.");
static wxString Use_Scaling_filter_desc = _("Use filtering when efb scaled size is larger than the target resolution.");
static wxString borderless_fullscreen_desc = _("Implement fullscreen mode with a borderless window spanning the whole screen instead of using exclusive mode.\nAllows for faster transitions between fullscreen and windowed mode, but increases input latency, makes movement less smooth and slightly decreases performance.\nExclusive mode is required to support Nvidia 3D Vision in the Direct3D backend.\n\nIf unsure, leave this unchecked.");
static wxString internal_res_desc = _("Specifies the resolution used to render at. A high resolution greatly improves visual quality, but also greatly increases GPU load and can cause issues in certain games.\n\"Multiple of 640x528\" will result in a size slightly larger than \"Window Size\" but yield fewer issues. Generally speaking, the lower the internal resolution is, the better your performance will be. Auto (Window Size), 1.5x, and 2.5x may cause issues in some games.\n\nIf unsure, select Native.");
Expand Down Expand Up @@ -322,7 +323,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con

// aspect-ratio
{
const wxString ar_choices[] = { _("Auto"), _("Force 16:9"), _("Force 4:3"), _("Stretch to Window") };
const wxString ar_choices[] = { _("Auto"), _("Force Analog 16:9"), _("Force Analog 4:3"), _("Stretch to Window"), _("Force 4:3"), _("Force 16:9"), _("Force 16:10") };

szr_display->Add(new wxStaticText(page_general, wxID_ANY, _("Aspect Ratio:")), 1, wxALIGN_CENTER_VERTICAL, 0);
wxChoice* const choice_aspect = CreateChoice(page_general, vconfig.iAspectRatio, (ar_desc),
Expand Down Expand Up @@ -423,6 +424,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
szr_enh->Add(CreateCheckBox(page_enh, _("Use Scaling Filter"), (Use_Scaling_filter_desc), vconfig.bUseScalingFilter));
}
szr_enh->Add(CreateCheckBox(page_enh, _("Force Texture Filtering"), (force_filtering_desc), vconfig.bForceFiltering));
szr_enh->Add(CreateCheckBox(page_enh, _("Disable Texture Filtering"), (disable_filtering_desc), vconfig.bDisableTextureFiltering));

szr_enh->Add(CreateCheckBox(page_enh, _("Widescreen Hack"), (ws_hack_desc), vconfig.bWidescreenHack));
szr_enh->Add(CreateCheckBox(page_enh, _("Disable Fog"), (disable_fog_desc), vconfig.bDisableFog));
Expand Down
6 changes: 2 additions & 4 deletions Source/Core/VideoBackends/D3D12/D3DUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ extern StateCache gx_state_cache;

namespace D3D
{
inline unsigned int AlignValue(unsigned int value, unsigned int alignment)
{
return (value + (alignment - 1)) & ~(alignment - 1);
}
#define AlignValue(value, alignment) (((value) + ((alignment) - 1)) & ~((alignment) - 1))

void ResourceBarrier(ID3D12GraphicsCommandList* command_list, ID3D12Resource* resource, D3D12_RESOURCE_STATES state_before, D3D12_RESOURCE_STATES state_after, UINT subresource);

// Font creation flags
Expand Down
39 changes: 18 additions & 21 deletions Source/Core/VideoBackends/D3D12/FramebufferManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void FramebufferManager::InitializeEFBCache(const D3D12_CLEAR_VALUE& color_clear
D3D::SetDebugObjectName12(m_efb.color_cache_tex->GetTex(), "EFB color cache texture");

// AccessEFB - Sysmem buffer used to retrieve the pixel data from color_tex
tex_desc = CD3DX12_RESOURCE_DESC::Buffer(D3D::AlignValue(EFB_WIDTH * sizeof(int), D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) * EFB_HEIGHT);
tex_desc = CD3DX12_RESOURCE_DESC::Buffer(EFB_CACHE_PITCH * EFB_HEIGHT);
hr = D3D::device12->CreateCommittedResource(&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_READBACK), D3D12_HEAP_FLAG_NONE, &tex_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&m_efb.color_cache_buf));
CHECK(hr == S_OK, "create EFB color cache buffer (hr=%#x)", hr);

Expand All @@ -93,7 +93,7 @@ void FramebufferManager::InitializeEFBCache(const D3D12_CLEAR_VALUE& color_clear
D3D::SetDebugObjectName12(m_efb.depth_cache_tex->GetTex(), "EFB depth cache texture (used in Renderer::AccessEFB)");

// AccessEFB - Sysmem buffer used to retrieve the pixel data from depth_read_texture
tex_desc = CD3DX12_RESOURCE_DESC::Buffer(D3D::AlignValue(EFB_WIDTH * sizeof(float), D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) * EFB_HEIGHT);
tex_desc = CD3DX12_RESOURCE_DESC::Buffer(EFB_CACHE_PITCH * EFB_HEIGHT);
hr = D3D::device12->CreateCommittedResource(&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_READBACK), D3D12_HEAP_FLAG_NONE, &tex_desc, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&m_efb.depth_cache_buf));
CHECK(hr == S_OK, "create EFB depth cache buffer (hr=%#x)", hr);
D3D::SetDebugObjectName12(m_efb.depth_cache_buf, "EFB depth cache buffer");
Expand Down Expand Up @@ -291,8 +291,7 @@ u32 FramebufferManager::GetEFBCachedColor(u32 x, u32 y)
if (!m_efb.color_cache_data)
PopulateEFBColorCache();

u32 row_offset = y * D3D::AlignValue(EFB_WIDTH * sizeof(int), D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
const u32* row = reinterpret_cast<const u32*>(m_efb.color_cache_data + row_offset);
const u32* row = reinterpret_cast<const u32*>(m_efb.color_cache_data + y * EFB_CACHE_PITCH);
return row[x];
}

Expand All @@ -301,8 +300,8 @@ float FramebufferManager::GetEFBCachedDepth(u32 x, u32 y)
if (!m_efb.depth_cache_data)
PopulateEFBDepthCache();

u32 row_offset = y * D3D::AlignValue(EFB_WIDTH * sizeof(float), D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
const float* row = reinterpret_cast<const float*>(m_efb.depth_cache_data + row_offset);
u32 row_offset = y * EFB_CACHE_PITCH;
const float* row = reinterpret_cast<const float*>(m_efb.depth_cache_data + y * EFB_CACHE_PITCH);
return row[x];
}

Expand All @@ -311,8 +310,7 @@ void FramebufferManager::SetEFBCachedColor(u32 x, u32 y, u32 value)
if (!m_efb.color_cache_data)
return;

u32 row_offset = y * D3D::AlignValue(EFB_WIDTH * sizeof(int), D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
u32* row = reinterpret_cast<u32*>(m_efb.color_cache_data + row_offset);
u32* row = reinterpret_cast<u32*>(m_efb.color_cache_data + y * EFB_CACHE_PITCH);
row[x] = value;
}

Expand All @@ -321,8 +319,7 @@ void FramebufferManager::SetEFBCachedDepth(u32 x, u32 y, float value)
if (!m_efb.depth_cache_data)
return;

u32 row_offset = y * D3D::AlignValue(EFB_WIDTH * sizeof(float), D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
float* row = reinterpret_cast<float*>(m_efb.depth_cache_data + row_offset);
float* row = reinterpret_cast<float*>(m_efb.depth_cache_data + y * EFB_CACHE_PITCH);
row[x] = value;
}

Expand Down Expand Up @@ -370,7 +367,7 @@ void FramebufferManager::PopulateEFBColorCache()
dst_location.PlacedFootprint.Footprint.Width = EFB_WIDTH;
dst_location.PlacedFootprint.Footprint.Height = EFB_HEIGHT;
dst_location.PlacedFootprint.Footprint.Depth = 1;
dst_location.PlacedFootprint.Footprint.RowPitch = D3D::AlignValue(EFB_WIDTH * sizeof(int), D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
dst_location.PlacedFootprint.Footprint.RowPitch = EFB_CACHE_PITCH;

D3D12_TEXTURE_COPY_LOCATION src_location = {};
src_location.pResource = src_texture->GetTex();
Expand All @@ -381,13 +378,14 @@ void FramebufferManager::PopulateEFBColorCache()
D3D::current_command_list->CopyTextureRegion(&dst_location, 0, 0, 0, &src_location, &src_box);
// Need to wait for the CPU to complete the copy (and all prior operations) before we can read it on the CPU.
D3D::command_list_mgr->ExecuteQueuedWork(true);

// Restores proper viewport/scissor settings.
m_efb.color_tex->TransitionToResourceState(D3D::current_command_list, D3D12_RESOURCE_STATE_RENDER_TARGET);
m_efb.depth_tex->TransitionToResourceState(D3D::current_command_list, D3D12_RESOURCE_STATE_DEPTH_WRITE);
D3D::current_command_list->OMSetRenderTargets(1, &m_efb.color_tex->GetRTV(), FALSE, &m_efb.depth_tex->GetDSV());
g_renderer->RestoreAPIState();
void* data = nullptr;
HRESULT hr = m_efb.color_cache_buf->Map(0, nullptr, &data);
m_efb.color_cache_data = reinterpret_cast<u8*>(data);

HRESULT hr = m_efb.color_cache_buf->Map(0, nullptr, reinterpret_cast<void**>(&m_efb.color_cache_data));
CHECK(SUCCEEDED(hr), "failed to map efb peek color cache texture (hr=%08X)", hr);
}

Expand Down Expand Up @@ -443,7 +441,7 @@ void FramebufferManager::PopulateEFBDepthCache()
dst_location.PlacedFootprint.Footprint.Width = EFB_WIDTH;
dst_location.PlacedFootprint.Footprint.Height = EFB_HEIGHT;
dst_location.PlacedFootprint.Footprint.Depth = 1;
dst_location.PlacedFootprint.Footprint.RowPitch = D3D::AlignValue(EFB_WIDTH * sizeof(float), D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
dst_location.PlacedFootprint.Footprint.RowPitch = EFB_CACHE_PITCH;

D3D12_TEXTURE_COPY_LOCATION src_location = {};
src_location.pResource = src_texture->GetTex();
Expand All @@ -453,17 +451,16 @@ void FramebufferManager::PopulateEFBDepthCache()
src_texture->TransitionToResourceState(D3D::current_command_list, D3D12_RESOURCE_STATE_COPY_SOURCE);
D3D::current_command_list->CopyTextureRegion(&dst_location, 0, 0, 0, &src_location, &src_box);


// Restores proper viewport/scissor settings.
g_renderer->RestoreAPIState();
// Need to wait for the CPU to complete the copy (and all prior operations) before we can read it on the CPU.
D3D::command_list_mgr->ExecuteQueuedWork(true);

// Restores proper viewport/scissor settings.
m_efb.color_tex->TransitionToResourceState(D3D::current_command_list, D3D12_RESOURCE_STATE_RENDER_TARGET);
m_efb.depth_tex->TransitionToResourceState(D3D::current_command_list, D3D12_RESOURCE_STATE_DEPTH_WRITE);
D3D::current_command_list->OMSetRenderTargets(1, &m_efb.color_tex->GetRTV(), FALSE, &m_efb.depth_tex->GetDSV());
void* data = nullptr;
HRESULT hr = m_efb.depth_cache_buf->Map(0, nullptr, &data);
m_efb.depth_cache_data = reinterpret_cast<u8*>(data);
g_renderer->RestoreAPIState();

HRESULT hr = m_efb.depth_cache_buf->Map(0, nullptr, reinterpret_cast<void**>(&m_efb.depth_cache_data));
CHECK(SUCCEEDED(hr), "failed to map efb peek color cache texture (hr=%08X)", hr);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/D3D12/FramebufferManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include "d3d11.h"

#include "VideoBackends/D3D12/D3DUtil.h"
#include "VideoBackends/D3D12/D3DTexture.h"
#include "VideoCommon/FramebufferManagerBase.h"

Expand Down Expand Up @@ -109,7 +109,7 @@ class FramebufferManager final : public FramebufferManagerBase

int slices{};
} m_efb;

static constexpr size_t EFB_CACHE_PITCH = AlignValue(EFB_WIDTH * sizeof(int), D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
static unsigned int m_target_width;
static unsigned int m_target_height;
};
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/D3D12/PSTextureEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void PSTextureEncoder::Init()
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_READBACK),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Buffer(
D3D::AlignValue(static_cast<unsigned int>(out_tex_desc.Width) * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) *
AlignValue(static_cast<unsigned int>(out_tex_desc.Width) * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) *
out_tex_desc.Height
),
D3D12_RESOURCE_STATE_COPY_DEST,
Expand Down Expand Up @@ -209,7 +209,7 @@ void PSTextureEncoder::Encode(u8* dst, u32 format, u32 native_width, u32 bytes_p
dst_location.PlacedFootprint.Footprint.Width = EFB_WIDTH * 4;
dst_location.PlacedFootprint.Footprint.Height = EFB_HEIGHT / 4;
dst_location.PlacedFootprint.Footprint.Depth = 1;
dst_location.PlacedFootprint.Footprint.RowPitch = D3D::AlignValue(dst_location.PlacedFootprint.Footprint.Width * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
dst_location.PlacedFootprint.Footprint.RowPitch = AlignValue(dst_location.PlacedFootprint.Footprint.Width * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);

D3D12_TEXTURE_COPY_LOCATION src_location = {};
src_location.pResource = m_out;
Expand Down
35 changes: 8 additions & 27 deletions Source/Core/VideoBackends/D3D12/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ static bool s_last_xfb_mode = false;

static Television s_television;

static ID3D12Resource* s_access_efb_constant_buffer = nullptr;

enum CLEAR_BLEND_DESC
{
CLEAR_BLEND_DESC_ALL_CHANNELS_ENABLED = 0,
Expand Down Expand Up @@ -109,25 +107,6 @@ static void SetupDeviceObjects()

g_framebuffer_manager = std::make_unique<FramebufferManager>();

float colmat[20] = { 0.0f };
colmat[0] = colmat[5] = colmat[10] = 1.0f;

CheckHR(
D3D::device12->CreateCommittedResource(
&CD3DX12_HEAP_PROPERTIES(D3D12_HEAP_TYPE_UPLOAD),
D3D12_HEAP_FLAG_NONE,
&CD3DX12_RESOURCE_DESC::Buffer(sizeof(colmat)),
D3D12_RESOURCE_STATE_GENERIC_READ,
nullptr,
IID_PPV_ARGS(&s_access_efb_constant_buffer)
)
);

// Copy inital data to access_efb_cbuf12.
void* access_efb_constant_buffer_data = nullptr;
CheckHR(s_access_efb_constant_buffer->Map(0, nullptr, &access_efb_constant_buffer_data));
memcpy(access_efb_constant_buffer_data, colmat, sizeof(colmat));

D3D12_DEPTH_STENCIL_DESC depth_desc;
depth_desc.DepthEnable = FALSE;
depth_desc.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ZERO;
Expand Down Expand Up @@ -196,9 +175,6 @@ static void TeardownDeviceObjects()
s_screenshot_texture = nullptr;
}

D3D::command_list_mgr->DestroyResourceAfterCurrentCommandListExecuted(s_access_efb_constant_buffer);
s_access_efb_constant_buffer = nullptr;

s_television.Shutdown();

gx_state_cache.Clear();
Expand All @@ -210,7 +186,7 @@ void CreateScreenshotTexture()
// This texture is released to be recreated when the window is resized in Renderer::SwapImpl.

const unsigned int screenshot_buffer_size =
D3D::AlignValue(D3D::GetBackBufferWidth() * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) *
AlignValue(D3D::GetBackBufferWidth() * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT) *
D3D::GetBackBufferHeight();

CheckHR(
Expand Down Expand Up @@ -712,7 +688,7 @@ bool Renderer::SaveScreenshot(const std::string& filename, const TargetRectangle
dst_location.PlacedFootprint.Footprint.Width = D3D::GetBackBufferWidth();
dst_location.PlacedFootprint.Footprint.Height = D3D::GetBackBufferHeight();
dst_location.PlacedFootprint.Footprint.Depth = 1;
dst_location.PlacedFootprint.Footprint.RowPitch = D3D::AlignValue(dst_location.PlacedFootprint.Footprint.Width * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
dst_location.PlacedFootprint.Footprint.RowPitch = AlignValue(dst_location.PlacedFootprint.Footprint.Width * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);

D3D12_TEXTURE_COPY_LOCATION src_location = {};
src_location.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
Expand Down Expand Up @@ -897,7 +873,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
dst_location.PlacedFootprint.Footprint.Width = GetTargetRectangle().GetWidth();
dst_location.PlacedFootprint.Footprint.Height = GetTargetRectangle().GetHeight();
dst_location.PlacedFootprint.Footprint.Depth = 1;
dst_location.PlacedFootprint.Footprint.RowPitch = D3D::AlignValue(dst_location.PlacedFootprint.Footprint.Width * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
dst_location.PlacedFootprint.Footprint.RowPitch = AlignValue(dst_location.PlacedFootprint.Footprint.Width * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);

D3D12_TEXTURE_COPY_LOCATION src_location = {};
src_location.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
Expand Down Expand Up @@ -1325,6 +1301,11 @@ void Renderer::SetSamplerState(int stage, int tex_index, bool custom_tex)
gx_state.sampler[stage].min_filter = 6; // 4 (linear mip) | 2 (linear min)
gx_state.sampler[stage].mag_filter = 1; // linear mag
}
else if (g_ActiveConfig.bDisableTextureFiltering)
{
gx_state.sampler[stage].min_filter = 0;
gx_state.sampler[stage].mag_filter = 0;
}
else
{
gx_state.sampler[stage].min_filter = static_cast<u32>(tm0.min_filter);
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/VideoBackends/D3D12/TextureCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ bool TextureCache::TCacheEntry::Save(const std::string& filename, unsigned int l

D3D12_RESOURCE_DESC texture_desc = m_texture->GetTex()->GetDesc();

const unsigned int required_readback_buffer_size = D3D::AlignValue(static_cast<unsigned int>(texture_desc.Width) * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
const unsigned int required_readback_buffer_size = AlignValue(static_cast<unsigned int>(texture_desc.Width) * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);

if (s_texture_cache_entry_readback_buffer_size < required_readback_buffer_size)
{
Expand Down Expand Up @@ -169,7 +169,7 @@ bool TextureCache::TCacheEntry::Save(const std::string& filename, unsigned int l
dst_location.PlacedFootprint.Footprint.Format = texture_desc.Format;
dst_location.PlacedFootprint.Footprint.Width = static_cast<UINT>(texture_desc.Width);
dst_location.PlacedFootprint.Footprint.Height = texture_desc.Height;
dst_location.PlacedFootprint.Footprint.RowPitch = D3D::AlignValue(dst_location.PlacedFootprint.Footprint.Width * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
dst_location.PlacedFootprint.Footprint.RowPitch = AlignValue(dst_location.PlacedFootprint.Footprint.Width * 4, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);

D3D12_TEXTURE_COPY_LOCATION src_location = CD3DX12_TEXTURE_COPY_LOCATION(m_texture->GetTex(), 0);

Expand Down
5 changes: 3 additions & 2 deletions Source/Core/VideoBackends/DX11/PostProcessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ static const char* s_shader_common = R"(
struct VS_INPUT
{
float4 position : POSITION;
float4 texCoord : TEXCOORD0;
float3 texCoord : TEXCOORD0;
float3 texCoord1 : TEXCOORD1;
};
struct VS_OUTPUT
Expand All @@ -57,7 +58,7 @@ static const char* s_vertex_shader = R"(
void main(in VS_INPUT input, out VS_OUTPUT output)
{
output.position = input.position;
output.srcTexCoord = input.texCoord;
output.srcTexCoord = input.texCoord.xy;
output.dstTexCoord = float2(input.position.x * 0.5f + 0.5f, 1.0f - (input.position.y * 0.5f + 0.5f));
output.layer = input.texCoord.z;
}
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/VideoBackends/DX11/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,11 @@ void Renderer::SetSamplerState(int stage, int texindex, bool custom_tex)
gx_state.sampler[stage].min_filter = 6; // 4 (linear mip) | 2 (linear min)
gx_state.sampler[stage].mag_filter = 1; // linear mag
}
else if (g_ActiveConfig.bDisableTextureFiltering)
{
gx_state.sampler[stage].min_filter = 0;
gx_state.sampler[stage].mag_filter = 0;
}
else
{
gx_state.sampler[stage].min_filter = (u32)tm0.min_filter;
Expand Down
4 changes: 4 additions & 0 deletions Source/Core/VideoBackends/DX9/Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,10 @@ void Renderer::SetSamplerState(int stage, int texindex, bool custom_tex)
{
min = mag = mip = D3DTEXF_LINEAR;
}
else if (g_ActiveConfig.bDisableTextureFiltering)
{
min = mag = mip = D3DTEXF_NONE;
}
else
{
min = (tm0.min_filter & 4) ? D3DTEXF_LINEAR : D3DTEXF_POINT;
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/VideoBackends/OGL/SamplerCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ void SamplerCache::SetSamplerState(int stage, const TexMode0& tm0, const TexMode
params.tm0.min_filter |= 0x4;
params.tm0.mag_filter |= 0x1;
}
else if (g_ActiveConfig.bDisableTextureFiltering)
{
params.tm0.min_filter = 0;
params.tm0.mag_filter = 0;
}

// custom textures may have higher resolution, so disable the max_lod
if (custom_tex)
Expand Down
12 changes: 12 additions & 0 deletions Source/Core/VideoCommon/RenderBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,18 @@ void Renderer::UpdateDrawRectangle(int backbuffer_width, int backbuffer_height)
{
Ratio = (WinWidth / WinHeight) / AspectToWidescreen(VideoInterface::GetAspectRatio());
}
else if (g_ActiveConfig.iAspectRatio == ASPECT_4_3)
{
Ratio = (WinWidth / WinHeight) / (4.0f / 3.0f);
}
else if (g_ActiveConfig.iAspectRatio == ASPECT_16_9)
{
Ratio = (WinWidth / WinHeight) / (16.0f / 9.0f);
}
else if (g_ActiveConfig.iAspectRatio == ASPECT_16_10)
{
Ratio = (WinWidth / WinHeight) / (16.0f / 10.0f);
}
else
{
Ratio = (WinWidth / WinHeight) / VideoInterface::GetAspectRatio();
Expand Down
Loading

0 comments on commit 4822c37

Please sign in to comment.