mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-10-07 19:03:29 +00:00
glcore context switching
This commit is contained in:
parent
350cb11f9a
commit
b41d20dd82
@ -3,6 +3,7 @@ set(LIBRETRO_SRCS
|
||||
libretro.cpp
|
||||
LibretroGraphicsContext.cpp
|
||||
LibretroGLContext.cpp
|
||||
LibretroGLCoreContext.cpp
|
||||
LibretroVulkanContext.cpp
|
||||
libretro_vulkan.cpp)
|
||||
|
||||
|
@ -9,8 +9,6 @@ public:
|
||||
LibretroGLContext()
|
||||
#ifdef USING_GLES2
|
||||
: LibretroHWRenderContext(RETRO_HW_CONTEXT_OPENGLES2)
|
||||
#elif defined(HAVE_OPENGL_CORE)
|
||||
: LibretroHWRenderContext(RETRO_HW_CONTEXT_OPENGL_CORE, 3, 1)
|
||||
#else
|
||||
: LibretroHWRenderContext(RETRO_HW_CONTEXT_OPENGL)
|
||||
#endif
|
||||
|
36
libretro/LibretroGLCoreContext.cpp
Normal file
36
libretro/LibretroGLCoreContext.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
#include "Common/Log.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/ConfigValues.h"
|
||||
#include "Core/System.h"
|
||||
#include "gfx_es2/gpu_features.h"
|
||||
|
||||
#include "libretro/LibretroGLCoreContext.h"
|
||||
|
||||
bool LibretroGLCoreContext::Init() {
|
||||
if (!LibretroHWRenderContext::Init(true))
|
||||
return false;
|
||||
|
||||
g_Config.iGPUBackend = (int)GPUBackend::OPENGL;
|
||||
return true;
|
||||
}
|
||||
|
||||
void LibretroGLCoreContext::CreateDrawContext() {
|
||||
if (!glewInitDone) {
|
||||
#if !defined(IOS) && !defined(USING_GLES2)
|
||||
if (glewInit() != GLEW_OK) {
|
||||
ERROR_LOG(G3D, "glewInit() failed.\n");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
glewInitDone = true;
|
||||
CheckGLExtensions();
|
||||
}
|
||||
draw_ = Draw::T3DCreateGLContext();
|
||||
renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
}
|
||||
|
||||
void LibretroGLCoreContext::DestroyDrawContext() {
|
||||
LibretroHWRenderContext::DestroyDrawContext();
|
||||
renderManager_ = nullptr;
|
||||
}
|
37
libretro/LibretroGLCoreContext.h
Normal file
37
libretro/LibretroGLCoreContext.h
Normal file
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "gfx/gl_common.h"
|
||||
#include "libretro/LibretroGraphicsContext.h"
|
||||
#include "thin3d/GLRenderManager.h"
|
||||
|
||||
class LibretroGLCoreContext : public LibretroHWRenderContext {
|
||||
public:
|
||||
LibretroGLCoreContext()
|
||||
: LibretroHWRenderContext(RETRO_HW_CONTEXT_OPENGL_CORE, 3, 1)
|
||||
{
|
||||
hw_render_.bottom_left_origin = true;
|
||||
}
|
||||
|
||||
bool Init() override;
|
||||
void CreateDrawContext() override;
|
||||
void DestroyDrawContext() override;
|
||||
void SetRenderTarget() override {
|
||||
extern GLuint g_defaultFBO;
|
||||
g_defaultFBO = hw_render_.get_current_framebuffer();
|
||||
}
|
||||
|
||||
void ThreadStart() override { renderManager_->ThreadStart(draw_); }
|
||||
bool ThreadFrame() override { return renderManager_->ThreadFrame(); }
|
||||
void ThreadEnd() override { renderManager_->ThreadEnd(); }
|
||||
void StopThread() override {
|
||||
renderManager_->WaitUntilQueueIdle();
|
||||
renderManager_->StopThread();
|
||||
}
|
||||
|
||||
GPUCore GetGPUCore() override { return GPUCORE_GLES; }
|
||||
const char *Ident() override { return "OpenGL Core"; }
|
||||
|
||||
private:
|
||||
GLRenderManager *renderManager_ = nullptr;
|
||||
bool glewInitDone = false;
|
||||
};
|
@ -1,6 +1,7 @@
|
||||
|
||||
#include "libretro/LibretroGraphicsContext.h"
|
||||
#include "libretro/LibretroGLContext.h"
|
||||
#include "libretro/LibretroGLCoreContext.h"
|
||||
#include "libretro/libretro.h"
|
||||
#include "libretro/LibretroVulkanContext.h"
|
||||
#ifdef _WIN32
|
||||
@ -88,34 +89,55 @@ void LibretroGraphicsContext::LostBackbuffer() { draw_->HandleEvent(Draw::Event:
|
||||
LibretroGraphicsContext *LibretroGraphicsContext::CreateGraphicsContext() {
|
||||
LibretroGraphicsContext *ctx;
|
||||
|
||||
ctx = new LibretroGLContext();
|
||||
retro_hw_context_type preferred;
|
||||
if (!Libretro::environ_cb(RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER, &preferred))
|
||||
preferred = RETRO_HW_CONTEXT_DUMMY;
|
||||
|
||||
if (ctx->Init()) {
|
||||
return ctx;
|
||||
#ifndef USING_GLES2
|
||||
if (preferred == RETRO_HW_CONTEXT_DUMMY || preferred == RETRO_HW_CONTEXT_OPENGL_CORE) {
|
||||
ctx = new LibretroGLCoreContext();
|
||||
|
||||
if (ctx->Init()) {
|
||||
return ctx;
|
||||
}
|
||||
delete ctx;
|
||||
}
|
||||
delete ctx;
|
||||
#endif
|
||||
|
||||
ctx = new LibretroVulkanContext();
|
||||
if (preferred == RETRO_HW_CONTEXT_DUMMY || preferred == RETRO_HW_CONTEXT_OPENGL) {
|
||||
ctx = new LibretroGLContext();
|
||||
|
||||
if (ctx->Init()) {
|
||||
return ctx;
|
||||
if (ctx->Init()) {
|
||||
return ctx;
|
||||
}
|
||||
delete ctx;
|
||||
}
|
||||
|
||||
if (preferred == RETRO_HW_CONTEXT_DUMMY || preferred == RETRO_HW_CONTEXT_VULKAN) {
|
||||
ctx = new LibretroVulkanContext();
|
||||
|
||||
if (ctx->Init()) {
|
||||
return ctx;
|
||||
}
|
||||
delete ctx;
|
||||
}
|
||||
delete ctx;
|
||||
|
||||
#ifdef _WIN32
|
||||
ctx = new LibretroD3D11Context();
|
||||
if (preferred == RETRO_HW_CONTEXT_DUMMY || preferred == RETRO_HW_CONTEXT_DIRECT3D) {
|
||||
ctx = new LibretroD3D11Context();
|
||||
|
||||
if (ctx->Init()) {
|
||||
return ctx;
|
||||
if (ctx->Init()) {
|
||||
return ctx;
|
||||
}
|
||||
delete ctx;
|
||||
|
||||
ctx = new LibretroD3D9Context();
|
||||
|
||||
if (ctx->Init()) {
|
||||
return ctx;
|
||||
}
|
||||
delete ctx;
|
||||
}
|
||||
delete ctx;
|
||||
|
||||
ctx = new LibretroD3D9Context();
|
||||
|
||||
if (ctx->Init()) {
|
||||
return ctx;
|
||||
}
|
||||
delete ctx;
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
|
@ -696,7 +696,8 @@ endif
|
||||
SOURCES_CXX += \
|
||||
$(LIBRETRODIR)/libretro.cpp \
|
||||
$(LIBRETRODIR)/LibretroGraphicsContext.cpp \
|
||||
$(LIBRETRODIR)/LibretroGLContext.cpp
|
||||
$(LIBRETRODIR)/LibretroGLContext.cpp \
|
||||
$(LIBRETRODIR)/LibretroGLCoreContext.cpp
|
||||
|
||||
ifneq ($(STATIC_LINKING), 1)
|
||||
SOURCES_C += \
|
||||
|
Loading…
Reference in New Issue
Block a user