Merge pull request #3935 from stenzek/vulkan-pr

Vulkan Backend
This commit is contained in:
Mat M
2016-09-30 19:15:50 -04:00
committed by GitHub
95 changed files with 15395 additions and 165 deletions
@@ -14,6 +14,7 @@ import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.model.settings.BooleanSetting;
import org.dolphinemu.dolphinemu.model.settings.FloatSetting;
import org.dolphinemu.dolphinemu.model.settings.IntSetting;
import org.dolphinemu.dolphinemu.model.settings.StringSetting;
import org.dolphinemu.dolphinemu.model.settings.view.CheckBoxSetting;
import org.dolphinemu.dolphinemu.model.settings.view.SettingsItem;
import org.dolphinemu.dolphinemu.model.settings.view.SingleChoiceSetting;
@@ -207,7 +208,11 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
}
else
{
if (scSetting.getKey().equals(SettingsFile.KEY_XFB_METHOD))
if (scSetting.getKey().equals(SettingsFile.KEY_VIDEO_BACKEND_INDEX))
{
putVideoBackendSetting(which);
}
else if (scSetting.getKey().equals(SettingsFile.KEY_XFB_METHOD))
{
putXfbSetting(which);
}
@@ -318,6 +323,31 @@ public final class SettingsAdapter extends RecyclerView.Adapter<SettingViewHolde
return -1;
}
public void putVideoBackendSetting(int which)
{
StringSetting gfxBackend = null;
switch (which)
{
case 0:
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, SettingsFile.SECTION_CORE, "OGL");
break;
case 1:
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, SettingsFile.SECTION_CORE, "Vulkan");
break;
case 2:
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, SettingsFile.SECTION_CORE, "SW");
break;
case 3:
gfxBackend = new StringSetting(SettingsFile.KEY_VIDEO_BACKEND, SettingsFile.SECTION_CORE, "Null");
break;
}
mView.putSetting(gfxBackend);
}
public void putXfbSetting(int which)
{
BooleanSetting xfbEnable = null;
@@ -5,6 +5,7 @@ import org.dolphinemu.dolphinemu.model.settings.BooleanSetting;
import org.dolphinemu.dolphinemu.model.settings.IntSetting;
import org.dolphinemu.dolphinemu.model.settings.Setting;
import org.dolphinemu.dolphinemu.model.settings.SettingSection;
import org.dolphinemu.dolphinemu.model.settings.StringSetting;
import org.dolphinemu.dolphinemu.model.settings.view.CheckBoxSetting;
import org.dolphinemu.dolphinemu.model.settings.view.HeaderSetting;
import org.dolphinemu.dolphinemu.model.settings.view.SettingsItem;
@@ -137,6 +138,7 @@ public final class SettingsFragmentPresenter
Setting dualCore = null;
Setting overclockEnable = null;
Setting overclock = null;
IntSetting videoBackend = new IntSetting(SettingsFile.KEY_VIDEO_BACKEND_INDEX, SettingsFile.SECTION_CORE, getVideoBackendValue());
Setting continuousScan = null;
Setting wiimoteSpeaker = null;
@@ -162,6 +164,13 @@ public final class SettingsFragmentPresenter
sl.add(new CheckBoxSetting(SettingsFile.KEY_DUAL_CORE, SettingsFile.SECTION_CORE, R.string.dual_core, R.string.dual_core_descrip, true, dualCore));
sl.add(new CheckBoxSetting(SettingsFile.KEY_OVERCLOCK_ENABLE, SettingsFile.SECTION_CORE, R.string.overclock_enable, R.string.overclock_enable_description, false, overclockEnable));
sl.add(new SliderSetting(SettingsFile.KEY_OVERCLOCK_PERCENT, SettingsFile.SECTION_CORE, R.string.overclock_title, 0, 400, "%", 100, overclock));
// While it doesn't seem appropriate to store the video backend with the CPU settings, the video
// backend is stored in the main INI, which can't be changed by the graphics settings page, so
// we have to put it here.
sl.add(new SingleChoiceSetting(SettingsFile.KEY_VIDEO_BACKEND_INDEX, SettingsFile.SECTION_CORE, R.string.video_backend, R.string.video_backend_descrip,
R.array.videoBackendEntries, R.array.videoBackendValues, 0, videoBackend));
sl.add(new CheckBoxSetting(SettingsFile.KEY_WIIMOTE_SCAN, SettingsFile.SECTION_CORE, R.string.wiimote_scanning, R.string.wiimote_scanning_description, true, continuousScan));
sl.add(new CheckBoxSetting(SettingsFile.KEY_WIIMOTE_SPEAKER, SettingsFile.SECTION_CORE, R.string.wiimote_speaker, R.string.wiimote_speaker_description, true, wiimoteSpeaker));
}
@@ -291,6 +300,32 @@ public final class SettingsFragmentPresenter
sl.add(new CheckBoxSetting(SettingsFile.KEY_GCADAPTER_BONGOS + gcPadNumber, SettingsFile.SECTION_CORE, R.string.gc_adapter_bongos, R.string.gc_adapter_bongos_description, false, bongos));
}
private int getVideoBackendValue()
{
int videoBackendValue;
try
{
String videoBackend = ((StringSetting)mSettings.get(SettingsFile.SECTION_CORE).getSetting(SettingsFile.KEY_VIDEO_BACKEND)).getValue();
if (videoBackend.equals("OGL"))
videoBackendValue = 0;
else if (videoBackend.equals("Vulkan"))
videoBackendValue = 1;
else if (videoBackend.equals("Software"))
videoBackendValue = 2;
else if (videoBackend.equals("Null"))
videoBackendValue = 3;
else
videoBackendValue = 0;
}
catch (NullPointerException ex)
{
videoBackendValue = 0;
}
return videoBackendValue;
}
private int getXfbValue()
{
int xfbValue;
@@ -86,6 +86,7 @@ public final class SettingsFile
public static final String KEY_WIIMOTE_SPEAKER = "WiimoteEnableSpeaker";
// Internal only, not actually found in settings file.
public static final String KEY_VIDEO_BACKEND_INDEX = "VideoBackendIndex";
public static final String KEY_XFB_METHOD = "XFBMethod";
private SettingsFile()
@@ -12,6 +12,20 @@
<item>5</item>
</integer-array>
<!-- Video backend selection -->
<string-array name="videoBackendEntries" translatable="false">
<item>OpenGL</item>
<item>Vulkan</item>
<item>Software</item>
<item>Null</item>
</string-array>
<integer-array name="videoBackendValues" translatable="false">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</integer-array>
<!-- Wiimote extensions -->
<string-array name="wiimoteExtEntries" translatable="false">
<item>"None"</item>
@@ -263,7 +263,7 @@
<string name="opengl_es3">OpenGL ES</string>
<string name="opengl">OpenGL</string>
<string name="video_backend">Video Backend</string>
<string name="video_backend_desc">%s</string>
<string name="video_backend_descrip">Select the API used for graphics rendering.</string>
<string name="show_fps">Show FPS</string>
<string name="show_fps_descrip">Show the number of frames rendered per second as a measure of emulation speed.</string>
+5 -19
View File
@@ -747,35 +747,21 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceChang
if (surf == nullptr)
__android_log_print(ANDROID_LOG_ERROR, DOLPHIN_TAG, "Error: Surface is null.");
// If GLInterface isn't a thing yet then we don't need to let it know that the
// surface has changed
if (GLInterface)
{
GLInterface->UpdateHandle(surf);
Renderer::s_ChangedSurface.Reset();
Renderer::s_SurfaceNeedsChanged.Set();
Renderer::s_ChangedSurface.Wait();
}
if (g_renderer)
g_renderer->ChangeSurface(surf);
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestroyed(JNIEnv* env,
jobject obj)
{
if (g_renderer)
g_renderer->ChangeSurface(nullptr);
if (surf)
{
ANativeWindow_release(surf);
surf = nullptr;
}
// If GLInterface isn't a thing yet then we don't need to let it know that the
// surface has changed
if (GLInterface)
{
GLInterface->UpdateHandle(nullptr);
Renderer::s_ChangedSurface.Reset();
Renderer::s_SurfaceNeedsChanged.Set();
Renderer::s_ChangedSurface.Wait();
}
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RefreshWiimotes(JNIEnv* env,
jobject obj)
+1
View File
@@ -125,6 +125,7 @@
<ClInclude Include="Profiler.h" />
<ClInclude Include="ScopeGuard.h" />
<ClInclude Include="SDCardUtil.h" />
<ClInclude Include="Semaphore.h" />
<ClInclude Include="SettingsHandler.h" />
<ClInclude Include="StringUtil.h" />
<ClInclude Include="SymbolDB.h" />
@@ -225,6 +225,7 @@
<ClInclude Include="Assert.h" />
<ClInclude Include="NonCopyable.h" />
<ClInclude Include="Analytics.h" />
<ClInclude Include="Semaphore.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="BreakPoints.cpp" />
+50
View File
@@ -0,0 +1,50 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <Windows.h>
namespace Common
{
class Semaphore
{
public:
Semaphore(int initial_count, int maximum_count)
{
m_handle = CreateSemaphoreA(nullptr, initial_count, maximum_count, nullptr);
}
~Semaphore() { CloseHandle(m_handle); }
void Wait() { WaitForSingleObject(m_handle, INFINITE); }
void Post() { ReleaseSemaphore(m_handle, 1, nullptr); }
private:
HANDLE m_handle;
};
} // namespace Common
#else // _WIN32
#include <semaphore.h>
namespace Common
{
class Semaphore
{
public:
Semaphore(int initial_count, int maximum_count) { sem_init(&m_handle, 0, initial_count); }
~Semaphore() { sem_destroy(&m_handle); }
void Wait() { sem_wait(&m_handle); }
void Post() { sem_post(&m_handle); }
private:
sem_t m_handle;
};
} // namespace Common
#endif // _WIN32
+1
View File
@@ -233,6 +233,7 @@ set(LIBS
sfml-network
sfml-system
videonull
videovulkan
videoogl
videosoftware
z
@@ -207,6 +207,9 @@
<ProjectReference Include="..\VideoBackends\D3D12\D3D12.vcxproj">
<Project>{570215b7-e32f-4438-95ae-c8d955f9fca3}</Project>
</ProjectReference>
<ProjectReference Include="..\VideoBackends\Vulkan\Vulkan.vcxproj">
<Project>{29f29a19-f141-45ad-9679-5a2923b49da3}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
+3
View File
@@ -238,6 +238,9 @@
<ProjectReference Include="$(CoreDir)VideoBackends\Null\Null.vcxproj">
<Project>{53A5391B-737E-49A8-BC8F-312ADA00736F}</Project>
</ProjectReference>
<ProjectReference Include="$(CoreDir)VideoBackends\Vulkan\Vulkan.vcxproj">
<Project>{29F29A19-F141-45AD-9679-5A2923B49DA3}</Project>
</ProjectReference>
<ProjectReference Include="$(CoreDir)VideoCommon\VideoCommon.vcxproj">
<Project>{3de9ee35-3e91-4f27-a014-2866ad8c3fe3}</Project>
</ProjectReference>
+7
View File
@@ -77,6 +77,7 @@
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "VideoCommon/RenderBase.h"
#include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h"
@@ -907,6 +908,12 @@ void CFrame::OnRenderParentResize(wxSizeEvent& event)
}
m_LogWindow->Refresh();
m_LogWindow->Update();
// We call Renderer::ChangeSurface here to indicate the size has changed,
// but pass the same window handle. This is needed for the Vulkan backend,
// otherwise it cannot tell that the window has been resized on some drivers.
if (g_renderer)
g_renderer->ChangeSurface(GetRenderHandle());
}
event.Skip();
}
+16
View File
@@ -272,6 +272,12 @@ static wxString stereo_convergence_desc =
static wxString stereo_swap_desc =
wxTRANSLATE("Swaps the left and right eye. Mostly useful if you want to view side-by-side "
"cross-eyed.\n\nIf unsure, leave this unchecked.");
static wxString validation_layer_desc =
wxTRANSLATE("Enables validation of API calls made by the video backend, which may assist in "
"debugging graphical issues.\n\nIf unsure, leave this unchecked.");
static wxString backend_multithreading_desc =
wxTRANSLATE("Enables multi-threading in the video backend, which may result in performance "
"gains in some scenarios.\n\nIf unsure, leave this unchecked.");
#if !defined(__APPLE__)
// Search for available resolutions - TODO: Move to Common?
@@ -471,6 +477,13 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title)
CreateCheckBox(page_general, _("Render to Main Window"),
wxGetTranslation(render_to_main_win_desc),
SConfig::GetInstance().bRenderToMain));
if (vconfig.backend_info.bSupportsMultithreading)
{
szr_other->Add(CreateCheckBox(page_general, _("Enable Multi-threading"),
wxGetTranslation(backend_multithreading_desc),
vconfig.bBackendMultithreading));
}
}
wxStaticBoxSizer* const group_basic =
@@ -760,6 +773,9 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title)
wxGetTranslation(show_stats_desc), vconfig.bOverlayStats));
szr_debug->Add(CreateCheckBox(page_advanced, _("Texture Format Overlay"),
wxGetTranslation(texfmt_desc), vconfig.bTexFmtOverlayEnable));
szr_debug->Add(CreateCheckBox(page_advanced, _("Enable API Validation Layers"),
wxGetTranslation(validation_layer_desc),
vconfig.bEnableValidationLayer));
wxStaticBoxSizer* const group_debug =
new wxStaticBoxSizer(wxVERTICAL, page_advanced, _("Debugging"));
+1
View File
@@ -1,4 +1,5 @@
add_subdirectory(OGL)
add_subdirectory(Null)
add_subdirectory(Software)
add_subdirectory(Vulkan)
# TODO: Add other backends here!
+1 -1
View File
@@ -58,7 +58,7 @@ private:
u32 memory_stride, PEControl::PixelFormat srcFormat, const EFBRectangle& srcRect,
bool isIntensity, bool scaleByHalf) override;
void CompileShaders() override {}
bool CompileShaders() override { return true; }
void DeleteShaders() override {}
ID3D11Buffer* palette_buf;
ID3D11ShaderResourceView* palette_buf_srv;
+1
View File
@@ -73,6 +73,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsClipControl = true;
g_Config.backend_info.bSupportsDepthClamp = true;
g_Config.backend_info.bSupportsReversedDepthRange = false;
g_Config.backend_info.bSupportsMultithreading = false;
IDXGIFactory* factory;
IDXGIAdapter* ad;
@@ -65,7 +65,7 @@ private:
u32 memory_stride, PEControl::PixelFormat src_format, const EFBRectangle& src_rect,
bool is_intensity, bool scale_by_half) override;
void CompileShaders() override {}
bool CompileShaders() override { return true; }
void DeleteShaders() override {}
std::unique_ptr<D3DStreamBuffer> m_palette_stream_buffer;
+1
View File
@@ -76,6 +76,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsClipControl = true;
g_Config.backend_info.bSupportsDepthClamp = true;
g_Config.backend_info.bSupportsReversedDepthRange = false;
g_Config.backend_info.bSupportsMultithreading = false;
IDXGIFactory* factory;
IDXGIAdapter* ad;
+11 -1
View File
@@ -26,17 +26,27 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.api_type = APIType::Nothing;
g_Config.backend_info.bSupportsExclusiveFullscreen = true;
g_Config.backend_info.bSupportsDualSourceBlend = true;
g_Config.backend_info.bSupportsEarlyZ = true;
g_Config.backend_info.bSupportsPrimitiveRestart = true;
g_Config.backend_info.bSupportsOversizedViewports = true;
g_Config.backend_info.bSupportsGeometryShaders = true;
g_Config.backend_info.bSupports3DVision = false;
g_Config.backend_info.bSupportsEarlyZ = true;
g_Config.backend_info.bSupportsBindingLayout = true;
g_Config.backend_info.bSupportsBBox = true;
g_Config.backend_info.bSupportsGSInstancing = true;
g_Config.backend_info.bSupportsPostProcessing = false;
g_Config.backend_info.bSupportsPaletteConversion = true;
g_Config.backend_info.bSupportsClipControl = true;
g_Config.backend_info.bSupportsSSAA = true;
g_Config.backend_info.bSupportsDepthClamp = true;
g_Config.backend_info.bSupportsReversedDepthRange = true;
g_Config.backend_info.bSupportsMultithreading = false;
// aamodes: We only support 1 sample, so no MSAA
g_Config.backend_info.Adapters.clear();
g_Config.backend_info.AAModes = {1};
g_Config.backend_info.PPShaders.clear();
g_Config.backend_info.AnaglyphShaders.clear();
}
bool VideoBackend::Initialize(void* window_handle)

Some files were not shown because too many files have changed in this diff Show More