Moving graphics context creation around to hide actual creation.
Makes it easier to support APIs that don't have a concept of sharing.
This commit is contained in:
@@ -18,27 +18,23 @@
|
||||
#include "xenia/gpu/gl4/gl4_command_processor.h"
|
||||
#include "xenia/gpu/gl4/gl4_gpu_flags.h"
|
||||
#include "xenia/gpu/gpu_flags.h"
|
||||
#include "xenia/ui/gl/gl_provider.h"
|
||||
#include "xenia/ui/window.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
namespace gl4 {
|
||||
|
||||
std::unique_ptr<ui::GraphicsContext> GL4GraphicsSystem::CreateContext(
|
||||
ui::Window* target_window) {
|
||||
// Setup the GL control that actually does the drawing.
|
||||
// We run here in the loop and only touch it (and its context) on this
|
||||
// thread. That means some sync-fu when we want to swap.
|
||||
return xe::ui::gl::GLContext::Create(target_window);
|
||||
}
|
||||
|
||||
GL4GraphicsSystem::GL4GraphicsSystem() : GraphicsSystem() {}
|
||||
GL4GraphicsSystem::GL4GraphicsSystem() = default;
|
||||
|
||||
GL4GraphicsSystem::~GL4GraphicsSystem() = default;
|
||||
|
||||
X_STATUS GL4GraphicsSystem::Setup(cpu::Processor* processor,
|
||||
kernel::KernelState* kernel_state,
|
||||
ui::Window* target_window) {
|
||||
// Must create the provider so we can create contexts.
|
||||
provider_ = xe::ui::gl::GLProvider::Create(target_window);
|
||||
|
||||
auto result = GraphicsSystem::Setup(processor, kernel_state, target_window);
|
||||
if (result) {
|
||||
return result;
|
||||
|
||||
@@ -24,9 +24,6 @@ class GL4GraphicsSystem : public GraphicsSystem {
|
||||
GL4GraphicsSystem();
|
||||
~GL4GraphicsSystem() override;
|
||||
|
||||
std::unique_ptr<ui::GraphicsContext> CreateContext(
|
||||
ui::Window* target_window) override;
|
||||
|
||||
X_STATUS Setup(cpu::Processor* processor, kernel::KernelState* kernel_state,
|
||||
ui::Window* target_window) override;
|
||||
void Shutdown() override;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "xenia/base/threading.h"
|
||||
#include "xenia/gpu/command_processor.h"
|
||||
#include "xenia/gpu/gpu_flags.h"
|
||||
#include "xenia/ui/graphics_provider.h"
|
||||
#include "xenia/ui/loop.h"
|
||||
|
||||
namespace xe {
|
||||
@@ -33,14 +34,18 @@ X_STATUS GraphicsSystem::Setup(cpu::Processor* processor,
|
||||
kernel_state_ = kernel_state;
|
||||
target_window_ = target_window;
|
||||
|
||||
// Initialize rendering context.
|
||||
// Initialize display and rendering context.
|
||||
// This must happen on the UI thread.
|
||||
std::unique_ptr<xe::ui::GraphicsContext> processor_context;
|
||||
target_window_->loop()->PostSynchronous([&]() {
|
||||
// Create the context used for presentation.
|
||||
assert_null(target_window->context());
|
||||
target_window_->set_context(provider_->CreateContext(target_window_));
|
||||
|
||||
// Setup the GL context the command processor will do all its drawing in.
|
||||
// It's shared with the display context so that we can resolve framebuffers
|
||||
// from it.
|
||||
processor_context = target_window->context()->CreateShared();
|
||||
processor_context = provider()->CreateOffscreenContext();
|
||||
processor_context->ClearCurrent();
|
||||
});
|
||||
if (!processor_context) {
|
||||
|
||||
@@ -34,12 +34,10 @@ class GraphicsSystem {
|
||||
public:
|
||||
virtual ~GraphicsSystem();
|
||||
|
||||
virtual std::unique_ptr<ui::GraphicsContext> CreateContext(
|
||||
ui::Window* target_window) = 0;
|
||||
|
||||
Memory* memory() const { return memory_; }
|
||||
cpu::Processor* processor() const { return processor_; }
|
||||
kernel::KernelState* kernel_state() const { return kernel_state_; }
|
||||
ui::GraphicsProvider* provider() const { return provider_.get(); }
|
||||
|
||||
virtual X_STATUS Setup(cpu::Processor* processor,
|
||||
kernel::KernelState* kernel_state,
|
||||
@@ -82,6 +80,7 @@ class GraphicsSystem {
|
||||
cpu::Processor* processor_ = nullptr;
|
||||
kernel::KernelState* kernel_state_ = nullptr;
|
||||
ui::Window* target_window_ = nullptr;
|
||||
std::unique_ptr<ui::GraphicsProvider> provider_;
|
||||
|
||||
uint32_t interrupt_callback_ = 0;
|
||||
uint32_t interrupt_callback_data_ = 0;
|
||||
|
||||
Reference in New Issue
Block a user