From b8593ec00f912e922736a4d19fe29cc4bf8cb295 Mon Sep 17 00:00:00 2001 From: Duc Le Date: Wed, 8 Jul 2015 13:47:53 +0000 Subject: [PATCH] add toggle for bilinear filter --- DXSpriteBatch.cpp | 13 +++++++++---- DXSpriteBatch.h | 4 ++-- EmulatorRenderer.cpp | 2 +- EmulatorSettings.h | 2 +- ExportPage.xaml.cpp | 2 +- NavMenuListView.cpp | 2 +- SettingsPage.xaml | 29 ++++++++++++++++++++--------- SettingsPage.xaml.cpp | 11 +++++++++++ SettingsPage.xaml.h | 1 + VBA10.vcxproj | 41 +++++++++++++++++++++++++++-------------- 10 files changed, 74 insertions(+), 33 deletions(-) diff --git a/DXSpriteBatch.cpp b/DXSpriteBatch.cpp index 985c93d..1a5dc80 100644 --- a/DXSpriteBatch.cpp +++ b/DXSpriteBatch.cpp @@ -23,7 +23,7 @@ namespace Engine #define DEFAULT_DEPTH 1.0f - DXSpriteBatch::DXSpriteBatch(ID3D11Device1 *device, ID3D11DeviceContext1 *context, float width, float height) + DXSpriteBatch::DXSpriteBatch(ID3D11Device1 *device, ID3D11DeviceContext1 *context, bool useFilter, float width, float height) : device(device), context(context), batchedSprites(0), beginCalled(false), customPS(nullptr) @@ -31,7 +31,7 @@ namespace Engine this->queuedSprites.reserve(MAX_BATCH_SIZE); this->LoadShaders(); this->InitializeBuffers(); - this->CreateStates(); + this->CreateStates(useFilter); this->UpdateProjectionMatrix(width, height); } @@ -152,7 +152,7 @@ namespace Engine this->onResizeBuffer = tmpOnResizeBuffer; } - void DXSpriteBatch::CreateStates(void) + void DXSpriteBatch::CreateStates(bool useFilter) { // Blend state D3D11_BLEND_DESC blendDesc; @@ -217,7 +217,12 @@ namespace Engine D3D11_SAMPLER_DESC samplerDesc; ZeroMemory(&samplerDesc, sizeof(D3D11_SAMPLER_DESC)); - samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; //D3D11_FILTER_ANISOTROPIC; //D3D11_FILTER_MIN_MAG_MIP_POINT; //D3D11_FILTER_MIN_MAG_MIP_LINEAR + if (useFilter) + samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + else + samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; + + //D3D11_FILTER_ANISOTROPIC; //D3D11_FILTER_MIN_MAG_MIP_POINT; //D3D11_FILTER_MIN_MAG_MIP_LINEAR samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; diff --git a/DXSpriteBatch.h b/DXSpriteBatch.h index e1ee4ff..e6b94cf 100644 --- a/DXSpriteBatch.h +++ b/DXSpriteBatch.h @@ -70,12 +70,12 @@ namespace Engine void LoadShaders(void); void UpdateProjectionMatrix(float width, float height); void InitializeBuffers(void); - void CreateStates(void); + void CreateStates(bool useFilter); void FlushBatch(void); void RenderBatch(UINT start, UINT end, SpriteInfo &spriteInfo); void QueueSprite(SpriteInfo &info); public: - DXSpriteBatch(ID3D11Device1 *device, ID3D11DeviceContext1 *context, float width, float height); + DXSpriteBatch(ID3D11Device1 *device, ID3D11DeviceContext1 *context, bool useFilter, float width, float height); ~DXSpriteBatch(void); void OnResize(float width, float height); diff --git a/EmulatorRenderer.cpp b/EmulatorRenderer.cpp index 8113a83..ada9b4a 100644 --- a/EmulatorRenderer.cpp +++ b/EmulatorRenderer.cpp @@ -261,7 +261,7 @@ namespace VBA10 //resize buffers take the render width and height, regardless of orientation if(!this->dxSpriteBatch) { - this->dxSpriteBatch = new DXSpriteBatch(m_deviceResources->GetD3DDevice(), m_deviceResources->GetD3DDeviceContext(), this->renderwidth, this->renderheight); + this->dxSpriteBatch = new DXSpriteBatch(m_deviceResources->GetD3DDevice(), m_deviceResources->GetD3DDeviceContext(), App::Settings->LinearFilterEnabled, this->renderwidth, this->renderheight); }else { this->dxSpriteBatch->OnResize(this->renderwidth, this->renderheight); diff --git a/EmulatorSettings.h b/EmulatorSettings.h index 5952964..d92ce4f 100644 --- a/EmulatorSettings.h +++ b/EmulatorSettings.h @@ -20,7 +20,7 @@ namespace VBA10 FiveToFour, }; - ref class EmulatorSettings sealed + ref class EmulatorSettings sealed { public: EmulatorSettings(); diff --git a/ExportPage.xaml.cpp b/ExportPage.xaml.cpp index 0a66c56..139bbb8 100644 --- a/ExportPage.xaml.cpp +++ b/ExportPage.xaml.cpp @@ -2,7 +2,7 @@ // ExportPage.xaml.cpp // Implementation of the ExportPage class // - +#include "pch.h" #include "ExportPage.xaml.h" using namespace VBA10; diff --git a/NavMenuListView.cpp b/NavMenuListView.cpp index 66508cf..91e0dd5 100644 --- a/NavMenuListView.cpp +++ b/NavMenuListView.cpp @@ -1,4 +1,4 @@ -#include "pch.h" + #include "NavMenuListView.h" using namespace Platform; diff --git a/SettingsPage.xaml b/SettingsPage.xaml index 119f900..577ba6a 100644 --- a/SettingsPage.xaml +++ b/SettingsPage.xaml @@ -186,15 +186,7 @@ MaxWidth="440"> - - 30 Hz - 60 Hz (default) - 120 Hz - + @@ -226,6 +218,16 @@ 6 + + 30 Hz + 60 Hz (default) + 120 Hz + + 1:1 + + + + + + diff --git a/SettingsPage.xaml.cpp b/SettingsPage.xaml.cpp index eabe077..5c514ec 100644 --- a/SettingsPage.xaml.cpp +++ b/SettingsPage.xaml.cpp @@ -3,6 +3,7 @@ // Implementation of the SettingsPage class // +#include "pch.h" #include "SettingsPage.xaml.h" #include "EmulatorSettings.h" #include @@ -73,6 +74,7 @@ SettingsPage::SettingsPage() this->aspectComboBox->SelectedIndex = 4; break; } + this->linearFilterToggle->IsOn = App::Settings->LinearFilterEnabled; //general this->loadConfirmationToggle->IsOn = IsLoadConfirmationDisabled(); @@ -365,3 +367,12 @@ void SettingsPage::soundSyncToggle_Toggled_1(Platform::Object^ sender, Windows:: } + + +void SettingsPage::linearFilterToggle_Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + if (initdone) + { + App::Settings->LinearFilterEnabled = this->linearFilterToggle->IsOn; + } +} diff --git a/SettingsPage.xaml.h b/SettingsPage.xaml.h index 3df3e1b..fc8570a 100644 --- a/SettingsPage.xaml.h +++ b/SettingsPage.xaml.h @@ -58,5 +58,6 @@ namespace VBA10 void loadConfirmationToggle_Toggled_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void soundToggle_Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void soundSyncToggle_Toggled_1(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void linearFilterToggle_Toggled(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); }; } diff --git a/VBA10.vcxproj b/VBA10.vcxproj index b407c5c..23ba582 100644 --- a/VBA10.vcxproj +++ b/VBA10.vcxproj @@ -389,12 +389,12 @@ ExportPage.xaml - NotUsing - NotUsing - NotUsing - NotUsing - NotUsing - NotUsing + Use + Use + Use + Use + Use + Use HelpPage.xaml @@ -407,7 +407,7 @@ App.xaml - NotUsing + Use NotUsing @@ -508,9 +508,22 @@ NotUsing NotUsing - + + NotUsing + NotUsing + NotUsing + NotUsing + NotUsing + NotUsing + PageHeader.xaml + Use + Use + Use + Use + Use + Use NotUsing @@ -548,12 +561,12 @@ SettingsPage.xaml - NotUsing - NotUsing - NotUsing - NotUsing - NotUsing - NotUsing + Use + Use + Use + Use + Use + Use NotUsing