Files
Xenia-Canary/src/xenia/gpu/graphics_system.h
Ben Vanik 6c95ca1cdb Moving graphics context creation around to hide actual creation.
Makes it easier to support APIs that don't have a concept of sharing.
2015-11-10 17:38:57 -08:00

99 lines
3.0 KiB
C++

/**
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2013 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
#ifndef XENIA_GPU_GRAPHICS_SYSTEM_H_
#define XENIA_GPU_GRAPHICS_SYSTEM_H_
#include <atomic>
#include <memory>
#include <thread>
#include "xenia/cpu/processor.h"
#include "xenia/gpu/register_file.h"
#include "xenia/kernel/xthread.h"
#include "xenia/memory.h"
#include "xenia/ui/window.h"
#include "xenia/xbox.h"
namespace xe {
class Emulator;
} // namespace xe
namespace xe {
namespace gpu {
class CommandProcessor;
class GraphicsSystem {
public:
virtual ~GraphicsSystem();
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,
ui::Window* target_window);
virtual void Shutdown();
RegisterFile* register_file() { return &register_file_; }
CommandProcessor* command_processor() const {
return command_processor_.get();
}
void InitializeRingBuffer(uint32_t ptr, uint32_t page_count);
void EnableReadPointerWriteBack(uint32_t ptr, uint32_t block_size);
void SetInterruptCallback(uint32_t callback, uint32_t user_data);
void DispatchInterruptCallback(uint32_t source, uint32_t cpu);
virtual void ClearCaches();
void RequestFrameTrace();
void BeginTracing();
void EndTracing();
protected:
GraphicsSystem();
virtual std::unique_ptr<CommandProcessor> CreateCommandProcessor() = 0;
static uint32_t ReadRegisterThunk(void* ppc_context, GraphicsSystem* gs,
uint32_t addr);
static void WriteRegisterThunk(void* ppc_context, GraphicsSystem* gs,
uint32_t addr, uint32_t value);
uint32_t ReadRegister(uint32_t addr);
void WriteRegister(uint32_t addr, uint32_t value);
void MarkVblank();
virtual void Swap(xe::ui::UIEvent* e) = 0;
Memory* memory_ = nullptr;
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;
std::atomic<bool> vsync_worker_running_;
kernel::object_ref<kernel::XHostThread> vsync_worker_thread_;
RegisterFile register_file_;
std::unique_ptr<CommandProcessor> command_processor_;
};
} // namespace gpu
} // namespace xe
#endif // XENIA_GPU_GRAPHICS_SYSTEM_H_