diff --git a/libxenia.vcxproj b/libxenia.vcxproj
index b8a2b7761..9334245b9 100644
--- a/libxenia.vcxproj
+++ b/libxenia.vcxproj
@@ -83,18 +83,13 @@
-
-
-
-
-
@@ -171,6 +166,11 @@
+
+
+
+
+
@@ -328,18 +328,13 @@
-
-
-
-
-
@@ -400,6 +395,11 @@
+
+
+
+
+
diff --git a/libxenia.vcxproj.filters b/libxenia.vcxproj.filters
index 5c46cbe7e..70041c6f3 100644
--- a/libxenia.vcxproj.filters
+++ b/libxenia.vcxproj.filters
@@ -158,6 +158,9 @@
{82795389-e855-4cd6-a3b6-9580030cebf2}
+
+ {c38dacd1-1e4c-4cd1-847e-19b394e8313d}
+
@@ -364,33 +367,18 @@
src\xenia\gpu
-
- src\xenia\gpu\gl4
-
-
- src\xenia\gpu\gl4
-
src\xenia\gpu\gl4
src\xenia\gpu\gl4
-
- src\xenia\gpu\gl4
-
src\xenia\gpu\gl4
-
- src\xenia\gpu\gl4
-
src\xenia\gpu\gl4
-
- src\xenia\gpu\gl4
-
src\xenia\gpu\gl4
@@ -727,6 +715,21 @@
src\xenia\vfs
+
+ src\xenia\ui\gl
+
+
+ src\xenia\ui\gl
+
+
+ src\xenia\ui\gl
+
+
+ src\xenia\ui\gl
+
+
+ src\xenia\ui\gl
+
@@ -954,33 +957,18 @@
src\xenia\gpu
-
- src\xenia\gpu\gl4
-
-
- src\xenia\gpu\gl4
-
src\xenia\gpu\gl4
src\xenia\gpu\gl4
-
- src\xenia\gpu\gl4
-
src\xenia\gpu\gl4
-
- src\xenia\gpu\gl4
-
src\xenia\gpu\gl4
-
- src\xenia\gpu\gl4
-
src\xenia\gpu\gl4
@@ -1365,6 +1353,21 @@
src\xenia\cpu\backend\x64
+
+ src\xenia\ui\gl
+
+
+ src\xenia\ui\gl
+
+
+ src\xenia\ui\gl
+
+
+ src\xenia\ui\gl
+
+
+ src\xenia\ui\gl
+
diff --git a/src/xenia/gpu/gl4/command_processor.cc b/src/xenia/gpu/gl4/command_processor.cc
index c6177d18e..b6837549d 100644
--- a/src/xenia/gpu/gl4/command_processor.cc
+++ b/src/xenia/gpu/gl4/command_processor.cc
@@ -30,8 +30,6 @@ namespace gl4 {
using namespace xe::gpu::xenos;
-extern "C" GLEWContext* glewGetContext();
-
const GLuint kAnyTarget = UINT_MAX;
// All uncached vertex/index data goes here. If it fills up we need to sync
@@ -85,7 +83,8 @@ CommandProcessor::CommandProcessor(GL4GraphicsSystem* graphics_system)
CommandProcessor::~CommandProcessor() { CloseHandle(write_ptr_index_event_); }
-bool CommandProcessor::Initialize(std::unique_ptr context) {
+bool CommandProcessor::Initialize(
+ std::unique_ptr context) {
context_ = std::move(context);
worker_running_ = true;
diff --git a/src/xenia/gpu/gl4/command_processor.h b/src/xenia/gpu/gl4/command_processor.h
index 51ef477ee..d3fb6c1ad 100644
--- a/src/xenia/gpu/gl4/command_processor.h
+++ b/src/xenia/gpu/gl4/command_processor.h
@@ -18,9 +18,7 @@
#include
#include
-#include "xenia/gpu/gl4/circular_buffer.h"
#include "xenia/gpu/gl4/draw_batcher.h"
-#include "xenia/gpu/gl4/gl_context.h"
#include "xenia/gpu/gl4/gl4_shader.h"
#include "xenia/gpu/gl4/gl4_shader_translator.h"
#include "xenia/gpu/gl4/texture_cache.h"
@@ -29,6 +27,8 @@
#include "xenia/gpu/xenos.h"
#include "xenia/kernel/objects/xthread.h"
#include "xenia/memory.h"
+#include "xenia/ui/gl/circular_buffer.h"
+#include "xenia/ui/gl/gl_context.h"
namespace xe {
namespace kernel {
@@ -67,7 +67,7 @@ class CommandProcessor {
uint32_t counter() const { return counter_; }
void increment_counter() { counter_++; }
- bool Initialize(std::unique_ptr context);
+ bool Initialize(std::unique_ptr context);
void Shutdown();
void CallInThread(std::function fn);
@@ -238,7 +238,7 @@ class CommandProcessor {
std::atomic worker_running_;
kernel::object_ref worker_thread_;
- std::unique_ptr context_;
+ std::unique_ptr context_;
SwapHandler swap_handler_;
std::queue> pending_fns_;
@@ -292,7 +292,7 @@ class CommandProcessor {
TextureCache texture_cache_;
DrawBatcher draw_batcher_;
- CircularBuffer scratch_buffer_;
+ xe::ui::gl::CircularBuffer scratch_buffer_;
private:
bool SetShadowRegister(uint32_t& dest, uint32_t register_name);
diff --git a/src/xenia/gpu/gl4/draw_batcher.cc b/src/xenia/gpu/gl4/draw_batcher.cc
index 93e7693dc..1b546d80e 100644
--- a/src/xenia/gpu/gl4/draw_batcher.cc
+++ b/src/xenia/gpu/gl4/draw_batcher.cc
@@ -22,8 +22,6 @@ namespace gl4 {
using namespace xe::gpu::xenos;
-extern "C" GLEWContext* glewGetContext();
-
const size_t kCommandBufferCapacity = 16 * (1024 * 1024);
const size_t kCommandBufferAlignment = 4;
const size_t kStateBufferCapacity = 64 * (1024 * 1024);
diff --git a/src/xenia/gpu/gl4/draw_batcher.h b/src/xenia/gpu/gl4/draw_batcher.h
index 61328b3bf..1d7a19263 100644
--- a/src/xenia/gpu/gl4/draw_batcher.h
+++ b/src/xenia/gpu/gl4/draw_batcher.h
@@ -10,16 +10,18 @@
#ifndef XENIA_GPU_GL4_GL4_STATE_DATA_BUILDER_H_
#define XENIA_GPU_GL4_GL4_STATE_DATA_BUILDER_H_
-#include "xenia/gpu/gl4/circular_buffer.h"
-#include "xenia/gpu/gl4/gl_context.h"
#include "xenia/gpu/gl4/gl4_shader.h"
#include "xenia/gpu/register_file.h"
#include "xenia/gpu/xenos.h"
+#include "xenia/ui/gl/circular_buffer.h"
+#include "xenia/ui/gl/gl_context.h"
namespace xe {
namespace gpu {
namespace gl4 {
+using xe::ui::gl::CircularBuffer;
+
union float4 {
float v[4];
struct {
diff --git a/src/xenia/gpu/gl4/gl4_gpu_flags.cc b/src/xenia/gpu/gl4/gl4_gpu_flags.cc
index bcd06e698..02e3ed4cf 100644
--- a/src/xenia/gpu/gl4/gl4_gpu_flags.cc
+++ b/src/xenia/gpu/gl4/gl4_gpu_flags.cc
@@ -9,18 +9,6 @@
#include "xenia/gpu/gl4/gl4_gpu_flags.h"
-DEFINE_bool(thread_safe_gl, false,
- "Only allow one GL context to be active at a time.");
-
-DEFINE_bool(disable_gl_context_reset, false,
- "Do not aggressively reset the GL context (helps with capture "
- "programs such as OBS or FRAPS).");
-
-DEFINE_bool(gl_debug, false, "Enable OpenGL debug validation layer.");
-DEFINE_bool(gl_debug_output, false, "Dump ARB_debug_output to stderr.");
-DEFINE_bool(gl_debug_output_synchronous, true,
- "ARB_debug_output will synchronize to be thread safe.");
-
DEFINE_bool(vendor_gl_extensions, false,
"Enable vendor-specific (NV, AMD, etc) GL extensions.");
diff --git a/src/xenia/gpu/gl4/gl4_gpu_flags.h b/src/xenia/gpu/gl4/gl4_gpu_flags.h
index 4c44985cb..fbf043460 100644
--- a/src/xenia/gpu/gl4/gl4_gpu_flags.h
+++ b/src/xenia/gpu/gl4/gl4_gpu_flags.h
@@ -12,13 +12,6 @@
#include
-DECLARE_bool(thread_safe_gl);
-DECLARE_bool(disable_gl_context_reset);
-
-DECLARE_bool(gl_debug);
-DECLARE_bool(gl_debug_output);
-DECLARE_bool(gl_debug_output_synchronous);
-
DECLARE_bool(vendor_gl_extensions);
DECLARE_bool(disable_framebuffer_readback);
diff --git a/src/xenia/gpu/gl4/gl4_graphics_system.cc b/src/xenia/gpu/gl4/gl4_graphics_system.cc
index a8f0022d6..52641c9af 100644
--- a/src/xenia/gpu/gl4/gl4_graphics_system.cc
+++ b/src/xenia/gpu/gl4/gl4_graphics_system.cc
@@ -17,16 +17,14 @@
#include "xenia/cpu/processor.h"
#include "xenia/emulator.h"
#include "xenia/gpu/gl4/gl4_gpu_flags.h"
-#include "xenia/gpu/gl4/gl4_profiler_display.h"
#include "xenia/gpu/gpu_flags.h"
#include "xenia/gpu/tracing.h"
+#include "xenia/ui/gl/gl_profiler_display.h"
namespace xe {
namespace gpu {
namespace gl4 {
-extern "C" GLEWContext* glewGetContext();
-
void InitializeIfNeeded();
void CleanupOnShutdown();
@@ -65,12 +63,12 @@ X_STATUS GL4GraphicsSystem::Setup(cpu::Processor* processor,
// Create rendering control.
// This must happen on the UI thread.
xe::threading::Fence control_ready_fence;
- std::unique_ptr processor_context;
+ std::unique_ptr processor_context;
target_loop_->Post([&]() {
// 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.
- control_ = std::make_unique(target_loop_);
+ control_ = std::make_unique(target_loop_);
target_window_->AddChild(control_.get());
// Setup the GL context the command processor will do all its drawing in.
@@ -79,9 +77,9 @@ X_STATUS GL4GraphicsSystem::Setup(cpu::Processor* processor,
processor_context = control_->context()->CreateShared();
{
- GLContextLock context_lock(control_->context());
+ xe::ui::gl::GLContextLock context_lock(control_->context());
auto profiler_display =
- std::make_unique(control_.get());
+ std::make_unique(control_.get());
Profiler::set_display(std::move(profiler_display));
}
diff --git a/src/xenia/gpu/gl4/gl4_graphics_system.h b/src/xenia/gpu/gl4/gl4_graphics_system.h
index fd589620e..5baaa1f70 100644
--- a/src/xenia/gpu/gl4/gl4_graphics_system.h
+++ b/src/xenia/gpu/gl4/gl4_graphics_system.h
@@ -13,10 +13,10 @@
#include
#include "xenia/gpu/gl4/command_processor.h"
-#include "xenia/gpu/gl4/wgl_control.h"
#include "xenia/gpu/graphics_system.h"
#include "xenia/gpu/register_file.h"
#include "xenia/kernel/objects/xthread.h"
+#include "xenia/ui/gl/wgl_control.h"
namespace xe {
namespace gpu {
@@ -67,7 +67,7 @@ class GL4GraphicsSystem : public GraphicsSystem {
RegisterFile register_file_;
std::unique_ptr command_processor_;
- std::unique_ptr control_;
+ std::unique_ptr control_;
std::atomic worker_running_;
kernel::object_ref worker_thread_;
diff --git a/src/xenia/gpu/gl4/gl4_shader.cc b/src/xenia/gpu/gl4/gl4_shader.cc
index 6650f9501..f7dfa6b22 100644
--- a/src/xenia/gpu/gl4/gl4_shader.cc
+++ b/src/xenia/gpu/gl4/gl4_shader.cc
@@ -22,8 +22,6 @@ namespace gl4 {
using namespace xe::gpu::xenos;
-extern "C" GLEWContext* glewGetContext();
-
GL4Shader::GL4Shader(ShaderType shader_type, uint64_t data_hash,
const uint32_t* dword_ptr, uint32_t dword_count)
: Shader(shader_type, data_hash, dword_ptr, dword_count),
diff --git a/src/xenia/gpu/gl4/gl4_shader.h b/src/xenia/gpu/gl4/gl4_shader.h
index 7c68bd83a..9e9077395 100644
--- a/src/xenia/gpu/gl4/gl4_shader.h
+++ b/src/xenia/gpu/gl4/gl4_shader.h
@@ -12,8 +12,8 @@
#include
-#include "xenia/gpu/gl4/gl_context.h"
#include "xenia/gpu/shader.h"
+#include "xenia/ui/gl/gl_context.h"
namespace xe {
namespace gpu {
diff --git a/src/xenia/gpu/gl4/gl4_shader_translator.h b/src/xenia/gpu/gl4/gl4_shader_translator.h
index 5e0a8d490..9c997923a 100644
--- a/src/xenia/gpu/gl4/gl4_shader_translator.h
+++ b/src/xenia/gpu/gl4/gl4_shader_translator.h
@@ -13,10 +13,10 @@
#include
#include "xenia/base/string_buffer.h"
-#include "xenia/gpu/gl4/gl_context.h"
#include "xenia/gpu/gl4/gl4_shader.h"
#include "xenia/gpu/ucode.h"
#include "xenia/gpu/xenos.h"
+#include "xenia/ui/gl/gl_context.h"
namespace xe {
namespace gpu {
diff --git a/src/xenia/gpu/gl4/texture_cache.cc b/src/xenia/gpu/gl4/texture_cache.cc
index 3e8a2b20b..c3f076aca 100644
--- a/src/xenia/gpu/gl4/texture_cache.cc
+++ b/src/xenia/gpu/gl4/texture_cache.cc
@@ -24,9 +24,6 @@ namespace gl4 {
using namespace xe::gpu::xenos;
-extern "C" GLEWContext* glewGetContext();
-extern "C" WGLEWContext* wglewGetContext();
-
struct TextureConfig {
TextureFormat texture_format;
GLenum internal_format;
diff --git a/src/xenia/gpu/gl4/texture_cache.h b/src/xenia/gpu/gl4/texture_cache.h
index 5e78fee9e..15177a3be 100644
--- a/src/xenia/gpu/gl4/texture_cache.h
+++ b/src/xenia/gpu/gl4/texture_cache.h
@@ -15,17 +15,21 @@
#include
#include "xenia/base/mutex.h"
-#include "xenia/gpu/gl4/blitter.h"
-#include "xenia/gpu/gl4/circular_buffer.h"
-#include "xenia/gpu/gl4/gl_context.h"
#include "xenia/gpu/sampler_info.h"
#include "xenia/gpu/texture_info.h"
#include "xenia/memory.h"
+#include "xenia/ui/gl/blitter.h"
+#include "xenia/ui/gl/circular_buffer.h"
+#include "xenia/ui/gl/gl_context.h"
namespace xe {
namespace gpu {
namespace gl4 {
+using xe::ui::gl::Blitter;
+using xe::ui::gl::CircularBuffer;
+using xe::ui::gl::Rect2D;
+
class TextureCache {
public:
struct TextureEntry;
diff --git a/src/xenia/gpu/xe-gpu-trace-viewer.cc b/src/xenia/gpu/xe-gpu-trace-viewer.cc
index b71f56762..19569542b 100644
--- a/src/xenia/gpu/xe-gpu-trace-viewer.cc
+++ b/src/xenia/gpu/xe-gpu-trace-viewer.cc
@@ -18,12 +18,12 @@
#include "xenia/base/mapped_memory.h"
#include "xenia/base/math.h"
#include "xenia/emulator.h"
-#include "xenia/gpu/gl4/gl_context.h"
#include "xenia/gpu/graphics_system.h"
#include "xenia/gpu/register_file.h"
#include "xenia/gpu/tracing.h"
#include "xenia/gpu/xenos.h"
#include "xenia/profiling.h"
+#include "xenia/ui/gl/gl_context.h"
#include "xenia/ui/main_window.h"
// HACK: until we have another impl, we just use gl4 directly.
@@ -2317,9 +2317,6 @@ int trace_viewer_main(std::vector& args) {
// TODO(benvanik): move to another file.
-extern "C" GLEWContext* glewGetContext();
-extern "C" WGLEWContext* wglewGetContext();
-
static int shader_handle, vert_handle, frag_handle;
static int texture_location, proj_mtx_location;
static int position_location, uv_location, colour_location;
diff --git a/src/xenia/gpu/gl4/blitter.cc b/src/xenia/ui/gl/blitter.cc
similarity index 98%
rename from src/xenia/gpu/gl4/blitter.cc
rename to src/xenia/ui/gl/blitter.cc
index 722792942..6d12eac1a 100644
--- a/src/xenia/gpu/gl4/blitter.cc
+++ b/src/xenia/ui/gl/blitter.cc
@@ -7,19 +7,17 @@
******************************************************************************
*/
-#include "xenia/gpu/gl4/blitter.h"
+#include "xenia/ui/gl/blitter.h"
#include
#include "xenia/base/assert.h"
#include "xenia/base/math.h"
+#include "xenia/ui/gl/gl_context.h"
namespace xe {
-namespace gpu {
-namespace gl4 {
-
-extern "C" GLEWContext* glewGetContext();
-extern "C" WGLEWContext* wglewGetContext();
+namespace ui {
+namespace gl {
Blitter::Blitter()
: vertex_program_(0),
@@ -303,6 +301,6 @@ void Blitter::CopyDepthTexture(GLuint src_texture, Rect2D src_rect,
state.Restore();
}
-} // namespace gl4
-} // namespace gpu
+} // namespace gl
+} // namespace ui
} // namespace xe
diff --git a/src/xenia/gpu/gl4/blitter.h b/src/xenia/ui/gl/blitter.h
similarity index 91%
rename from src/xenia/gpu/gl4/blitter.h
rename to src/xenia/ui/gl/blitter.h
index b70c62e9c..c4eed6c73 100644
--- a/src/xenia/gpu/gl4/blitter.h
+++ b/src/xenia/ui/gl/blitter.h
@@ -7,8 +7,8 @@
******************************************************************************
*/
-#ifndef XENIA_GPU_GL4_BLITTER_H_
-#define XENIA_GPU_GL4_BLITTER_H_
+#ifndef XENIA_UI_GL_BLITTER_H_
+#define XENIA_UI_GL_BLITTER_H_
#include
@@ -16,8 +16,8 @@
#include "third_party/GL/wglew.h"
namespace xe {
-namespace gpu {
-namespace gl4 {
+namespace ui {
+namespace gl {
struct Rect2D {
int32_t x;
@@ -63,8 +63,8 @@ class Blitter {
GLuint scratch_framebuffer_;
};
-} // namespace gl4
-} // namespace gpu
+} // namespace gl
+} // namespace ui
} // namespace xe
-#endif // XENIA_GPU_GL4_BLITTER_H_
+#endif // XENIA_UI_GL_BLITTER_H_
diff --git a/src/xenia/gpu/gl4/circular_buffer.cc b/src/xenia/ui/gl/circular_buffer.cc
similarity index 95%
rename from src/xenia/gpu/gl4/circular_buffer.cc
rename to src/xenia/ui/gl/circular_buffer.cc
index 76195f15d..cba41af1c 100644
--- a/src/xenia/gpu/gl4/circular_buffer.cc
+++ b/src/xenia/ui/gl/circular_buffer.cc
@@ -7,19 +7,15 @@
******************************************************************************
*/
-#include "xenia/gpu/gl4/circular_buffer.h"
+#include "xenia/ui/gl/circular_buffer.h"
#include "xenia/base/assert.h"
#include "xenia/base/math.h"
#include "xenia/gpu/gl4/gl4_gpu_flags.h"
-#include "xenia/gpu/gpu_flags.h"
namespace xe {
-namespace gpu {
-namespace gl4 {
-
-extern "C" GLEWContext* glewGetContext();
-extern "C" WGLEWContext* wglewGetContext();
+namespace ui {
+namespace gl {
CircularBuffer::CircularBuffer(size_t capacity, size_t alignment)
: capacity_(capacity),
@@ -146,6 +142,6 @@ void CircularBuffer::WaitUntilClean() {
ClearCache();
}
-} // namespace gl4
-} // namespace gpu
+} // namespace gl
+} // namespace ui
} // namespace xe
diff --git a/src/xenia/gpu/gl4/circular_buffer.h b/src/xenia/ui/gl/circular_buffer.h
similarity index 87%
rename from src/xenia/gpu/gl4/circular_buffer.h
rename to src/xenia/ui/gl/circular_buffer.h
index da1ebd788..1cbc42c50 100644
--- a/src/xenia/gpu/gl4/circular_buffer.h
+++ b/src/xenia/ui/gl/circular_buffer.h
@@ -7,16 +7,16 @@
******************************************************************************
*/
-#ifndef XENIA_GPU_GL4_CIRCULAR_BUFFER_H_
-#define XENIA_GPU_GL4_CIRCULAR_BUFFER_H_
+#ifndef XENIA_UI_GL_CIRCULAR_BUFFER_H_
+#define XENIA_UI_GL_CIRCULAR_BUFFER_H_
#include
-#include "xenia/gpu/gl4/gl_context.h"
+#include "xenia/ui/gl/gl_context.h"
namespace xe {
-namespace gpu {
-namespace gl4 {
+namespace ui {
+namespace gl {
// TODO(benvanik): uh, make this circular.
// TODO(benvanik): fences to prevent this from ever flushing.
@@ -64,8 +64,8 @@ class CircularBuffer {
std::unordered_map allocation_cache_;
};
-} // namespace gl4
-} // namespace gpu
+} // namespace gl
+} // namespace ui
} // namespace xe
-#endif // XENIA_GPU_GL4_CIRCULAR_BUFFER_H_
+#endif // XENIA_UI_GL_CIRCULAR_BUFFER_H_
diff --git a/src/xenia/gpu/gl4/gl_context.cc b/src/xenia/ui/gl/gl_context.cc
similarity index 94%
rename from src/xenia/gpu/gl4/gl_context.cc
rename to src/xenia/ui/gl/gl_context.cc
index f6d43b748..fc7f3fdfc 100644
--- a/src/xenia/gpu/gl4/gl_context.cc
+++ b/src/xenia/ui/gl/gl_context.cc
@@ -7,7 +7,7 @@
******************************************************************************
*/
-#include "xenia/gpu/gl4/gl_context.h"
+#include "xenia/ui/gl/gl_context.h"
#include
#include
@@ -15,12 +15,23 @@
#include "xenia/base/assert.h"
#include "xenia/base/logging.h"
#include "xenia/base/math.h"
-#include "xenia/gpu/gl4/gl4_gpu_flags.h"
#include "xenia/profiling.h"
+DEFINE_bool(thread_safe_gl, false,
+ "Only allow one GL context to be active at a time.");
+
+DEFINE_bool(disable_gl_context_reset, false,
+ "Do not aggressively reset the GL context (helps with capture "
+ "programs such as OBS or FRAPS).");
+
+DEFINE_bool(gl_debug, false, "Enable OpenGL debug validation layer.");
+DEFINE_bool(gl_debug_output, false, "Dump ARB_debug_output to stderr.");
+DEFINE_bool(gl_debug_output_synchronous, true,
+ "ARB_debug_output will synchronize to be thread safe.");
+
namespace xe {
-namespace gpu {
-namespace gl4 {
+namespace ui {
+namespace gl {
static std::recursive_mutex global_gl_mutex_;
@@ -388,6 +399,6 @@ void GLContext::ClearCurrent() {
}
}
-} // namespace gl4
-} // namespace gpu
+} // namespace gl
+} // namespace ui
} // namespace xe
diff --git a/src/xenia/gpu/gl4/gl_context.h b/src/xenia/ui/gl/gl_context.h
similarity index 82%
rename from src/xenia/gpu/gl4/gl_context.h
rename to src/xenia/ui/gl/gl_context.h
index 114c5e9fc..64184a715 100644
--- a/src/xenia/gpu/gl4/gl_context.h
+++ b/src/xenia/ui/gl/gl_context.h
@@ -7,19 +7,25 @@
******************************************************************************
*/
-#ifndef XENIA_GPU_GL4_GL_CONTEXT_H_
-#define XENIA_GPU_GL4_GL_CONTEXT_H_
+#ifndef XENIA_UI_GL_GL_CONTEXT_H_
+#define XENIA_UI_GL_GL_CONTEXT_H_
+
+#include
#include
-#include "xenia/gpu/gl4/blitter.h"
-
#include "third_party/GL/glew.h"
#include "third_party/GL/wglew.h"
+#include "xenia/ui/gl/blitter.h"
+
+DECLARE_bool(thread_safe_gl);
+
+extern "C" GLEWContext* glewGetContext();
+extern "C" WGLEWContext* wglewGetContext();
namespace xe {
-namespace gpu {
-namespace gl4 {
+namespace ui {
+namespace gl {
class GLContext {
public:
@@ -67,8 +73,8 @@ struct GLContextLock {
GLContext* context_;
};
-} // namespace gl4
-} // namespace gpu
+} // namespace gl
+} // namespace ui
} // namespace xe
-#endif // XENIA_GPU_GL4_GL_CONTEXT_H_
+#endif // XENIA_UI_GL_GL_CONTEXT_H_
diff --git a/src/xenia/gpu/gl4/gl4_profiler_display.cc b/src/xenia/ui/gl/gl_profiler_display.cc
similarity index 94%
rename from src/xenia/gpu/gl4/gl4_profiler_display.cc
rename to src/xenia/ui/gl/gl_profiler_display.cc
index d38e75688..3ea38cdd0 100644
--- a/src/xenia/gpu/gl4/gl4_profiler_display.cc
+++ b/src/xenia/ui/gl/gl_profiler_display.cc
@@ -7,19 +7,16 @@
******************************************************************************
*/
-#include "xenia/gpu/gl4/gl4_profiler_display.h"
+#include "xenia/ui/gl/gl_profiler_display.h"
#include "third_party/microprofile/microprofileui.h"
#include "xenia/base/assert.h"
#include "xenia/base/math.h"
-#include "xenia/gpu/gpu_flags.h"
namespace xe {
-namespace gpu {
-namespace gl4 {
-
-extern "C" GLEWContext* glewGetContext();
+namespace ui {
+namespace gl {
#define MICROPROFILE_MAX_VERTICES (16 << 10)
#define MICROPROFILE_NUM_QUERIES (8 << 10)
@@ -135,7 +132,7 @@ const uint8_t profiler_font[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
-GL4ProfilerDisplay::GL4ProfilerDisplay(WGLControl* control)
+GLProfilerDisplay::GLProfilerDisplay(xe::ui::gl::WGLControl* control)
: control_(control),
program_(0),
vao_(0),
@@ -179,7 +176,7 @@ GL4ProfilerDisplay::GL4ProfilerDisplay(WGLControl* control)
});
}
-bool GL4ProfilerDisplay::SetupFont() {
+bool GLProfilerDisplay::SetupFont() {
// Setup font lookup table.
for (uint32_t i = 0; i < xe::countof(font_description_.char_offsets); ++i) {
font_description_.char_offsets[i] = 206;
@@ -234,14 +231,14 @@ bool GL4ProfilerDisplay::SetupFont() {
return true;
}
-bool GL4ProfilerDisplay::SetupState() {
+bool GLProfilerDisplay::SetupState() {
if (!vertex_buffer_.Initialize()) {
return false;
}
return true;
}
-bool GL4ProfilerDisplay::SetupShaders() {
+bool GLProfilerDisplay::SetupShaders() {
const std::string header =
"\n\
#version 450 \n\
@@ -331,7 +328,7 @@ void main() { \n\
return true;
}
-GL4ProfilerDisplay::~GL4ProfilerDisplay() {
+GLProfilerDisplay::~GLProfilerDisplay() {
vertex_buffer_.Shutdown();
glMakeTextureHandleNonResidentARB(font_handle_);
glDeleteTextures(1, &font_texture_);
@@ -339,11 +336,11 @@ GL4ProfilerDisplay::~GL4ProfilerDisplay() {
glDeleteProgram(program_);
}
-uint32_t GL4ProfilerDisplay::width() const { return control_->width(); }
+uint32_t GLProfilerDisplay::width() const { return control_->width(); }
-uint32_t GL4ProfilerDisplay::height() const { return control_->height(); }
+uint32_t GLProfilerDisplay::height() const { return control_->height(); }
-void GL4ProfilerDisplay::Begin() {
+void GLProfilerDisplay::Begin() {
glEnablei(GL_BLEND, 0);
glBlendFunci(0, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_DEPTH_TEST);
@@ -372,13 +369,13 @@ void GL4ProfilerDisplay::Begin() {
glBindVertexArray(vao_);
}
-void GL4ProfilerDisplay::End() {
+void GLProfilerDisplay::End() {
Flush();
glUseProgram(0);
glBindVertexArray(0);
}
-GL4ProfilerDisplay::Vertex* GL4ProfilerDisplay::BeginVertices(size_t count) {
+GLProfilerDisplay::Vertex* GLProfilerDisplay::BeginVertices(size_t count) {
if (draw_command_count_ + 1 > kMaxCommands) {
Flush();
}
@@ -390,7 +387,7 @@ GL4ProfilerDisplay::Vertex* GL4ProfilerDisplay::BeginVertices(size_t count) {
return reinterpret_cast(current_allocation_.host_ptr);
}
-void GL4ProfilerDisplay::EndVertices(GLenum prim_type) {
+void GLProfilerDisplay::EndVertices(GLenum prim_type) {
size_t vertex_count = current_allocation_.length / sizeof(Vertex);
if (draw_command_count_ &&
@@ -408,7 +405,7 @@ void GL4ProfilerDisplay::EndVertices(GLenum prim_type) {
vertex_buffer_.Commit(std::move(current_allocation_));
}
-void GL4ProfilerDisplay::Flush() {
+void GLProfilerDisplay::Flush() {
if (!draw_command_count_) {
return;
}
@@ -423,8 +420,8 @@ void GL4ProfilerDisplay::Flush() {
vertex_buffer_.WaitUntilClean();
}
-void GL4ProfilerDisplay::DrawBox(int x0, int y0, int x1, int y1, uint32_t color,
- BoxType type) {
+void GLProfilerDisplay::DrawBox(int x0, int y0, int x1, int y1, uint32_t color,
+ BoxType type) {
auto v = BeginVertices(6);
if (type == BoxType::kFlat) {
color =
@@ -489,8 +486,8 @@ void GL4ProfilerDisplay::DrawBox(int x0, int y0, int x1, int y1, uint32_t color,
EndVertices(GL_TRIANGLES);
}
-void GL4ProfilerDisplay::DrawLine2D(uint32_t count, float* vertices,
- uint32_t color) {
+void GLProfilerDisplay::DrawLine2D(uint32_t count, float* vertices,
+ uint32_t color) {
if (!count || !vertices) {
return;
}
@@ -513,8 +510,8 @@ void GL4ProfilerDisplay::DrawLine2D(uint32_t count, float* vertices,
EndVertices(GL_LINES);
}
-void GL4ProfilerDisplay::DrawText(int x, int y, uint32_t color,
- const char* text, size_t text_length) {
+void GLProfilerDisplay::DrawText(int x, int y, uint32_t color, const char* text,
+ size_t text_length) {
if (!text_length) {
return;
}
@@ -563,6 +560,6 @@ void GL4ProfilerDisplay::DrawText(int x, int y, uint32_t color,
EndVertices(GL_TRIANGLES);
}
-} // namespace gl4
-} // namespace gpu
+} // namespace gl
+} // namespace ui
} // namespace xe
diff --git a/src/xenia/gpu/gl4/gl4_profiler_display.h b/src/xenia/ui/gl/gl_profiler_display.h
similarity index 77%
rename from src/xenia/gpu/gl4/gl4_profiler_display.h
rename to src/xenia/ui/gl/gl_profiler_display.h
index 637c7f63c..ca029115b 100644
--- a/src/xenia/gpu/gl4/gl4_profiler_display.h
+++ b/src/xenia/ui/gl/gl_profiler_display.h
@@ -7,22 +7,22 @@
******************************************************************************
*/
-#ifndef XENIA_GPU_GL4_GL4_PROFILER_DISPLAY_H_
-#define XENIA_GPU_GL4_GL4_PROFILER_DISPLAY_H_
+#ifndef XENIA_UI_GL_GL_PROFILER_DISPLAY_H_
+#define XENIA_UI_GL_GL_PROFILER_DISPLAY_H_
-#include "xenia/gpu/gl4/circular_buffer.h"
-#include "xenia/gpu/gl4/gl_context.h"
-#include "xenia/gpu/gl4/wgl_control.h"
#include "xenia/profiling.h"
+#include "xenia/ui/gl/circular_buffer.h"
+#include "xenia/ui/gl/gl_context.h"
+#include "xenia/ui/gl/wgl_control.h"
namespace xe {
-namespace gpu {
-namespace gl4 {
+namespace ui {
+namespace gl {
-class GL4ProfilerDisplay : public ProfilerDisplay {
+class GLProfilerDisplay : public ProfilerDisplay {
public:
- GL4ProfilerDisplay(WGLControl* control);
- virtual ~GL4ProfilerDisplay();
+ GLProfilerDisplay(xe::ui::gl::WGLControl* control);
+ virtual ~GLProfilerDisplay();
uint32_t width() const override;
uint32_t height() const override;
@@ -54,7 +54,7 @@ class GL4ProfilerDisplay : public ProfilerDisplay {
void EndVertices(GLenum prim_type);
void Flush();
- WGLControl* control_;
+ xe::ui::gl::WGLControl* control_;
GLuint program_;
GLuint vao_;
GLuint font_texture_;
@@ -76,8 +76,8 @@ class GL4ProfilerDisplay : public ProfilerDisplay {
} font_description_;
};
-} // namespace gl4
-} // namespace gpu
+} // namespace gl
+} // namespace ui
} // namespace xe
-#endif // XENIA_GPU_GL4_GL4_PROFILER_DISPLAY_H_
+#endif // XENIA_UI_GL_GL_PROFILER_DISPLAY_H_
diff --git a/src/xenia/gpu/gl4/wgl_control.cc b/src/xenia/ui/gl/wgl_control.cc
similarity index 90%
rename from src/xenia/gpu/gl4/wgl_control.cc
rename to src/xenia/ui/gl/wgl_control.cc
index d7204abff..9c1e61733 100644
--- a/src/xenia/gpu/gl4/wgl_control.cc
+++ b/src/xenia/ui/gl/wgl_control.cc
@@ -7,21 +7,17 @@
******************************************************************************
*/
-#include "xenia/gpu/gl4/wgl_control.h"
+#include "xenia/ui/gl/wgl_control.h"
#include "xenia/base/assert.h"
#include "xenia/base/logging.h"
-#include "xenia/gpu/gl4/gl4_gpu_flags.h"
#include "xenia/profiling.h"
namespace xe {
-namespace gpu {
-namespace gl4 {
+namespace ui {
+namespace gl {
-extern "C" GLEWContext* glewGetContext();
-extern "C" WGLEWContext* wglewGetContext();
-
-WGLControl::WGLControl(xe::ui::Loop* loop)
+WGLControl::WGLControl(Loop* loop)
: xe::ui::win32::Win32Control(Flags::kFlagOwnPaint), loop_(loop) {}
WGLControl::~WGLControl() = default;
@@ -75,7 +71,7 @@ bool WGLControl::Create() {
return true;
}
-void WGLControl::OnLayout(xe::ui::UIEvent& e) { Control::ResizeToFill(); }
+void WGLControl::OnLayout(UIEvent& e) { Control::ResizeToFill(); }
LRESULT WGLControl::WndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam) {
@@ -94,7 +90,7 @@ LRESULT WGLControl::WndProc(HWND hWnd, UINT message, WPARAM wParam,
current_paint_callback_ = nullptr;
}
- xe::ui::UIEvent e(this);
+ UIEvent e(this);
OnPaint(e);
// TODO(benvanik): profiler present.
@@ -122,6 +118,6 @@ void WGLControl::SynchronousRepaint(std::function paint_callback) {
RDW_INTERNALPAINT | RDW_UPDATENOW | RDW_ALLCHILDREN);
}
-} // namespace gl4
-} // namespace gpu
+} // namespace gl
+} // namespace ui
} // namespace xe
diff --git a/src/xenia/gpu/gl4/wgl_control.h b/src/xenia/ui/gl/wgl_control.h
similarity index 76%
rename from src/xenia/gpu/gl4/wgl_control.h
rename to src/xenia/ui/gl/wgl_control.h
index a377866d3..322e85541 100644
--- a/src/xenia/gpu/gl4/wgl_control.h
+++ b/src/xenia/ui/gl/wgl_control.h
@@ -7,23 +7,23 @@
******************************************************************************
*/
-#ifndef XENIA_GPU_GL4_WGL_CONTROL_H_
-#define XENIA_GPU_GL4_WGL_CONTROL_H_
+#ifndef XENIA_UI_GL_WGL_CONTROL_H_
+#define XENIA_UI_GL_WGL_CONTROL_H_
#include
#include "xenia/base/threading.h"
-#include "xenia/gpu/gl4/gl_context.h"
+#include "xenia/ui/gl/gl_context.h"
#include "xenia/ui/loop.h"
#include "xenia/ui/win32/win32_control.h"
namespace xe {
-namespace gpu {
-namespace gl4 {
+namespace ui {
+namespace gl {
class WGLControl : public xe::ui::win32::Win32Control {
public:
- WGLControl(xe::ui::Loop* loop);
+ WGLControl(Loop* loop);
~WGLControl() override;
GLContext* context() { return &context_; }
@@ -33,19 +33,19 @@ class WGLControl : public xe::ui::win32::Win32Control {
protected:
bool Create() override;
- void OnLayout(xe::ui::UIEvent& e) override;
+ void OnLayout(UIEvent& e) override;
LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam) override;
private:
- xe::ui::Loop* loop_;
+ Loop* loop_;
GLContext context_;
std::function current_paint_callback_;
};
-} // namespace gl4
-} // namespace gpu
+} // namespace gl
+} // namespace ui
} // namespace xe
-#endif // XENIA_GPU_GL4_WGL_CONTROL_H_
+#endif // XENIA_UI_GL_WGL_CONTROL_H_