Skip to content

Commit

Permalink
add toggle for bilinear filter
Browse files Browse the repository at this point in the history
  • Loading branch information
duchuule committed Jul 8, 2015
1 parent b55fb4e commit b8593ec
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 33 deletions.
13 changes: 9 additions & 4 deletions DXSpriteBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ 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)
{
this->queuedSprites.reserve(MAX_BATCH_SIZE);
this->LoadShaders();
this->InitializeBuffers();
this->CreateStates();
this->CreateStates(useFilter);

this->UpdateProjectionMatrix(width, height);
}
Expand Down Expand Up @@ -152,7 +152,7 @@ namespace Engine
this->onResizeBuffer = tmpOnResizeBuffer;
}

void DXSpriteBatch::CreateStates(void)
void DXSpriteBatch::CreateStates(bool useFilter)
{
// Blend state
D3D11_BLEND_DESC blendDesc;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions DXSpriteBatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion EmulatorRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion EmulatorSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace VBA10
FiveToFour,
};

ref class EmulatorSettings sealed
ref class EmulatorSettings sealed
{
public:
EmulatorSettings();
Expand Down
2 changes: 1 addition & 1 deletion ExportPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// ExportPage.xaml.cpp
// Implementation of the ExportPage class
//

#include "pch.h"
#include "ExportPage.xaml.h"

using namespace VBA10;
Expand Down
2 changes: 1 addition & 1 deletion NavMenuListView.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "pch.h"

#include "NavMenuListView.h"

using namespace Platform;
Expand Down
29 changes: 20 additions & 9 deletions SettingsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,7 @@
MaxWidth="440">
<!--<ToggleSwitch Toggled="hzToggle_Toggled" Header="30 Hz mode for displays with 30 Hz" Name="hzToggle" IsOn="True" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>-->

<ComboBox Name="monitorComboBox" HorizontalAlignment="Stretch"
VerticalAlignment="Top"
SelectedIndex="1"
SelectionChanged="monitorComboBox_SelectionChanged_1"
Header="Display Type">
<ComboBoxItem>30 Hz</ComboBoxItem>
<ComboBoxItem>60 Hz (default)</ComboBoxItem>
<ComboBoxItem>120 Hz</ComboBoxItem>
</ComboBox>


<!--<ToggleSwitch Toggled="fpsToggle_Toggled" Header="Show Frames per Second" x:Name="fpsToggle" IsOn="True" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>-->

Expand Down Expand Up @@ -226,6 +218,16 @@
<ComboBoxItem>6</ComboBoxItem>
</ComboBox>

<ComboBox Name="monitorComboBox" HorizontalAlignment="Stretch"
VerticalAlignment="Top"
SelectedIndex="1"
SelectionChanged="monitorComboBox_SelectionChanged_1"
Header="Display Type">
<ComboBoxItem>30 Hz</ComboBoxItem>
<ComboBoxItem>60 Hz (default)</ComboBoxItem>
<ComboBoxItem>120 Hz</ComboBoxItem>
</ComboBox>

<ComboBox Name="aspectComboBox"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
Expand All @@ -240,11 +242,20 @@
<ComboBoxItem>1:1</ComboBoxItem>
</ComboBox>

<ToggleSwitch Header="Use bilinear filter (app restart required)"
Name="linearFilterToggle"
IsOn="True" Toggled="linearFilterToggle_Toggled"
/>



<ToggleSwitch Header="Show FPS"
Name="fpsToggle"
IsOn="True"
Toggled="fpsToggle_Toggled"/>



</StackPanel>
</ScrollViewer>
</PivotItem>
Expand Down
11 changes: 11 additions & 0 deletions SettingsPage.xaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Implementation of the SettingsPage class
//

#include "pch.h"
#include "SettingsPage.xaml.h"
#include "EmulatorSettings.h"
#include <string>
Expand Down Expand Up @@ -73,6 +74,7 @@ SettingsPage::SettingsPage()
this->aspectComboBox->SelectedIndex = 4;
break;
}
this->linearFilterToggle->IsOn = App::Settings->LinearFilterEnabled;

//general
this->loadConfirmationToggle->IsOn = IsLoadConfirmationDisabled();
Expand Down Expand Up @@ -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;
}
}
1 change: 1 addition & 0 deletions SettingsPage.xaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
41 changes: 27 additions & 14 deletions VBA10.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,12 @@
</ClCompile>
<ClCompile Include="ExportPage.xaml.cpp">
<DependentUpon>ExportPage.xaml</DependentUpon>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
</ClCompile>
<ClCompile Include="HelpPage.xaml.cpp">
<DependentUpon>HelpPage.xaml</DependentUpon>
Expand All @@ -407,7 +407,7 @@
</ClCompile>
<ClCompile Include="App.xaml.cpp">
<DependentUpon>App.xaml</DependentUpon>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
</ClCompile>
<ClCompile Include="CheatData.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
Expand Down Expand Up @@ -508,9 +508,22 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="NavMenuListView.cpp" />
<ClCompile Include="NavMenuListView.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="PageHeader.xaml.cpp">
<DependentUpon>PageHeader.xaml</DependentUpon>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Point.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
Expand Down Expand Up @@ -548,12 +561,12 @@
</ClCompile>
<ClCompile Include="SettingsPage.xaml.cpp">
<DependentUpon>SettingsPage.xaml</DependentUpon>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Use</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Use</PrecompiledHeader>
</ClCompile>
<ClCompile Include="stringhelper.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
Expand Down

0 comments on commit b8593ec

Please sign in to comment.