Further work on SPU implementation

This commit is contained in:
Connor McLaughlin
2019-10-11 02:20:21 +10:00
parent bc51cc6d7d
commit f852b8dd90
9 changed files with 710 additions and 20 deletions

View File

@ -91,7 +91,7 @@ int main(int argc, char* argv[])
// const LOGLEVEL level = LOGLEVEL_DEV;
// const LOGLEVEL level = LOGLEVEL_PROFILE;
// g_pLog->SetConsoleOutputParams(true, nullptr, level);
g_pLog->SetConsoleOutputParams(true, "Pad SPU", level);
g_pLog->SetConsoleOutputParams(true, "Pad", level);
g_pLog->SetFilterLevel(level);
#else
g_pLog->SetConsoleOutputParams(true, nullptr, LOGLEVEL_DEBUG);

View File

@ -5,8 +5,10 @@
#include "core/digital_controller.h"
#include "core/gpu.h"
#include "core/memory_card.h"
#include "core/spu.h"
#include "core/system.h"
#include "icon.h"
#include "sdl_audio_stream.h"
#include <cinttypes>
#include <glad.h>
#include <imgui.h>
@ -173,11 +175,26 @@ void main()
return true;
}
bool SDLInterface::CreateAudioStream()
{
m_audio_stream = std::make_unique<SDLAudioStream>();
if (!m_audio_stream->Reconfigure(44100, 2))
{
Panic("Failed to open audio stream");
return false;
}
return true;
}
std::unique_ptr<SDLInterface> SDLInterface::Create()
{
std::unique_ptr<SDLInterface> intf = std::make_unique<SDLInterface>();
if (!intf->CreateSDLWindow() || !intf->CreateGLContext() || !intf->CreateImGuiContext() || !intf->CreateGLResources())
if (!intf->CreateSDLWindow() || !intf->CreateGLContext() || !intf->CreateImGuiContext() ||
!intf->CreateGLResources() || !intf->CreateAudioStream())
{
return nullptr;
}
return intf;
}
@ -312,15 +329,15 @@ bool SDLInterface::HandleSDLEvent(const SDL_Event* event)
break;
case SDL_SCANCODE_TAB:
{
// Window framebuffer has to be bound to call SetSwapInterval.
GLint current_fbo = 0;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &current_fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
SDL_GL_SetSwapInterval(pressed ? 0 : 1);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, current_fbo);
}
break;
{
// Window framebuffer has to be bound to call SetSwapInterval.
GLint current_fbo = 0;
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &current_fbo);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
SDL_GL_SetSwapInterval(pressed ? 0 : 1);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, current_fbo);
}
break;
default:
break;
@ -476,6 +493,8 @@ void SDLInterface::DrawImGui()
if (m_show_gpu_statistics)
m_system->GetGPU()->DrawStatistics();
m_system->GetSPU()->DrawDebugWindow();
DrawOSDMessages();
ImGui::Render();
@ -569,6 +588,13 @@ void SDLInterface::DrawMainMenuBar()
ImGui::EndMenu();
}
if (ImGui::BeginMenu("SPU"))
{
m_system->GetSPU()->DrawDebugMenu();
ImGui::EndMenu();
}
ImGui::EndMenu();
}
@ -689,6 +715,8 @@ void SDLInterface::ConnectDevices()
void SDLInterface::Run()
{
m_audio_stream->PauseOutput(false);
while (m_running)
{
for (;;)

View File

@ -13,6 +13,7 @@
class System;
class DigitalController;
class MemoryCard;
class AudioStream;
class SDLInterface : public HostInterface
{
@ -47,6 +48,7 @@ private:
bool CreateGLContext();
bool CreateImGuiContext();
bool CreateGLResources();
bool CreateAudioStream();
// We only pass mouse input through if it's grabbed
bool IsWindowFullscreen() const;