Moving common GL code out of gpu/.

This commit is contained in:
Ben Vanik 2015-07-01 07:29:14 -07:00
parent 5231e2e721
commit 0ebee76bfe
26 changed files with 185 additions and 204 deletions

View File

@ -83,18 +83,13 @@
<ClCompile Include="src\xenia\cpu\xex_module.cc" />
<ClCompile Include="src\xenia\debug\debugger.cc" />
<ClCompile Include="src\xenia\emulator.cc" />
<ClCompile Include="src\xenia\gpu\gl4\blitter.cc" />
<ClCompile Include="src\xenia\gpu\gl4\circular_buffer.cc" />
<ClCompile Include="src\xenia\gpu\gl4\command_processor.cc" />
<ClCompile Include="src\xenia\gpu\gl4\draw_batcher.cc" />
<ClCompile Include="src\xenia\gpu\gl4\gl4_gpu_flags.cc" />
<ClCompile Include="src\xenia\gpu\gl4\gl4_graphics_system.cc" />
<ClCompile Include="src\xenia\gpu\gl4\gl4_profiler_display.cc" />
<ClCompile Include="src\xenia\gpu\gl4\gl4_shader.cc" />
<ClCompile Include="src\xenia\gpu\gl4\gl4_shader_translator.cc" />
<ClCompile Include="src\xenia\gpu\gl4\gl_context.cc" />
<ClCompile Include="src\xenia\gpu\gl4\texture_cache.cc" />
<ClCompile Include="src\xenia\gpu\gl4\wgl_control.cc" />
<ClCompile Include="src\xenia\gpu\gpu_flags.cc" />
<ClCompile Include="src\xenia\gpu\graphics_system.cc" />
<ClCompile Include="src\xenia\gpu\register_file.cc" />
@ -171,6 +166,11 @@
<ClCompile Include="src\xenia\memory.cc" />
<ClCompile Include="src\xenia\profiling.cc" />
<ClCompile Include="src\xenia\ui\control.cc" />
<ClCompile Include="src\xenia\ui\gl\blitter.cc" />
<ClCompile Include="src\xenia\ui\gl\circular_buffer.cc" />
<ClCompile Include="src\xenia\ui\gl\gl_context.cc" />
<ClCompile Include="src\xenia\ui\gl\gl_profiler_display.cc" />
<ClCompile Include="src\xenia\ui\gl\wgl_control.cc" />
<ClCompile Include="src\xenia\ui\main_window.cc" />
<ClCompile Include="src\xenia\ui\menu_item.cc" />
<ClCompile Include="src\xenia\ui\win32\win32_control.cc" />
@ -328,18 +328,13 @@
<ClInclude Include="src\xenia\debug\proto\modules_generated.h" />
<ClInclude Include="src\xenia\debug\proto\threads_generated.h" />
<ClInclude Include="src\xenia\emulator.h" />
<ClInclude Include="src\xenia\gpu\gl4\blitter.h" />
<ClInclude Include="src\xenia\gpu\gl4\circular_buffer.h" />
<ClInclude Include="src\xenia\gpu\gl4\command_processor.h" />
<ClInclude Include="src\xenia\gpu\gl4\draw_batcher.h" />
<ClInclude Include="src\xenia\gpu\gl4\gl4_gpu_flags.h" />
<ClInclude Include="src\xenia\gpu\gl4\gl4_graphics_system.h" />
<ClInclude Include="src\xenia\gpu\gl4\gl4_profiler_display.h" />
<ClInclude Include="src\xenia\gpu\gl4\gl4_shader.h" />
<ClInclude Include="src\xenia\gpu\gl4\gl4_shader_translator.h" />
<ClInclude Include="src\xenia\gpu\gl4\gl_context.h" />
<ClInclude Include="src\xenia\gpu\gl4\texture_cache.h" />
<ClInclude Include="src\xenia\gpu\gl4\wgl_control.h" />
<ClInclude Include="src\xenia\gpu\gpu_flags.h" />
<ClInclude Include="src\xenia\gpu\graphics_system.h" />
<ClInclude Include="src\xenia\gpu\register_file.h" />
@ -400,6 +395,11 @@
<ClInclude Include="src\xenia\profiling.h" />
<ClInclude Include="src\xenia\ui\control.h" />
<ClInclude Include="src\xenia\ui\file_picker.h" />
<ClInclude Include="src\xenia\ui\gl\blitter.h" />
<ClInclude Include="src\xenia\ui\gl\circular_buffer.h" />
<ClInclude Include="src\xenia\ui\gl\gl_context.h" />
<ClInclude Include="src\xenia\ui\gl\gl_profiler_display.h" />
<ClInclude Include="src\xenia\ui\gl\wgl_control.h" />
<ClInclude Include="src\xenia\ui\loop.h" />
<ClInclude Include="src\xenia\ui\main_window.h" />
<ClInclude Include="src\xenia\ui\menu_item.h" />

View File

@ -158,6 +158,9 @@
<Filter Include="src\xenia\vfs\devices">
<UniqueIdentifier>{82795389-e855-4cd6-a3b6-9580030cebf2}</UniqueIdentifier>
</Filter>
<Filter Include="src\xenia\ui\gl">
<UniqueIdentifier>{c38dacd1-1e4c-4cd1-847e-19b394e8313d}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\xenia\emulator.cc">
@ -364,33 +367,18 @@
<ClCompile Include="src\xenia\gpu\ucode_disassembler.cc">
<Filter>src\xenia\gpu</Filter>
</ClCompile>
<ClCompile Include="src\xenia\gpu\gl4\blitter.cc">
<Filter>src\xenia\gpu\gl4</Filter>
</ClCompile>
<ClCompile Include="src\xenia\gpu\gl4\circular_buffer.cc">
<Filter>src\xenia\gpu\gl4</Filter>
</ClCompile>
<ClCompile Include="src\xenia\gpu\gl4\command_processor.cc">
<Filter>src\xenia\gpu\gl4</Filter>
</ClCompile>
<ClCompile Include="src\xenia\gpu\gl4\draw_batcher.cc">
<Filter>src\xenia\gpu\gl4</Filter>
</ClCompile>
<ClCompile Include="src\xenia\gpu\gl4\gl_context.cc">
<Filter>src\xenia\gpu\gl4</Filter>
</ClCompile>
<ClCompile Include="src\xenia\gpu\gl4\texture_cache.cc">
<Filter>src\xenia\gpu\gl4</Filter>
</ClCompile>
<ClCompile Include="src\xenia\gpu\gl4\wgl_control.cc">
<Filter>src\xenia\gpu\gl4</Filter>
</ClCompile>
<ClCompile Include="src\xenia\gpu\gl4\gl4_graphics_system.cc">
<Filter>src\xenia\gpu\gl4</Filter>
</ClCompile>
<ClCompile Include="src\xenia\gpu\gl4\gl4_profiler_display.cc">
<Filter>src\xenia\gpu\gl4</Filter>
</ClCompile>
<ClCompile Include="src\xenia\gpu\gl4\gl4_shader.cc">
<Filter>src\xenia\gpu\gl4</Filter>
</ClCompile>
@ -727,6 +715,21 @@
<ClCompile Include="src\xenia\vfs\virtual_file_system.cc">
<Filter>src\xenia\vfs</Filter>
</ClCompile>
<ClCompile Include="src\xenia\ui\gl\blitter.cc">
<Filter>src\xenia\ui\gl</Filter>
</ClCompile>
<ClCompile Include="src\xenia\ui\gl\gl_context.cc">
<Filter>src\xenia\ui\gl</Filter>
</ClCompile>
<ClCompile Include="src\xenia\ui\gl\wgl_control.cc">
<Filter>src\xenia\ui\gl</Filter>
</ClCompile>
<ClCompile Include="src\xenia\ui\gl\gl_profiler_display.cc">
<Filter>src\xenia\ui\gl</Filter>
</ClCompile>
<ClCompile Include="src\xenia\ui\gl\circular_buffer.cc">
<Filter>src\xenia\ui\gl</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\xenia\emulator.h">
@ -954,33 +957,18 @@
<ClInclude Include="src\xenia\gpu\xenos.h">
<Filter>src\xenia\gpu</Filter>
</ClInclude>
<ClInclude Include="src\xenia\gpu\gl4\blitter.h">
<Filter>src\xenia\gpu\gl4</Filter>
</ClInclude>
<ClInclude Include="src\xenia\gpu\gl4\circular_buffer.h">
<Filter>src\xenia\gpu\gl4</Filter>
</ClInclude>
<ClInclude Include="src\xenia\gpu\gl4\command_processor.h">
<Filter>src\xenia\gpu\gl4</Filter>
</ClInclude>
<ClInclude Include="src\xenia\gpu\gl4\draw_batcher.h">
<Filter>src\xenia\gpu\gl4</Filter>
</ClInclude>
<ClInclude Include="src\xenia\gpu\gl4\gl_context.h">
<Filter>src\xenia\gpu\gl4</Filter>
</ClInclude>
<ClInclude Include="src\xenia\gpu\gl4\texture_cache.h">
<Filter>src\xenia\gpu\gl4</Filter>
</ClInclude>
<ClInclude Include="src\xenia\gpu\gl4\wgl_control.h">
<Filter>src\xenia\gpu\gl4</Filter>
</ClInclude>
<ClInclude Include="src\xenia\gpu\gl4\gl4_graphics_system.h">
<Filter>src\xenia\gpu\gl4</Filter>
</ClInclude>
<ClInclude Include="src\xenia\gpu\gl4\gl4_profiler_display.h">
<Filter>src\xenia\gpu\gl4</Filter>
</ClInclude>
<ClInclude Include="src\xenia\gpu\gl4\gl4_shader.h">
<Filter>src\xenia\gpu\gl4</Filter>
</ClInclude>
@ -1365,6 +1353,21 @@
<ClInclude Include="src\xenia\cpu\backend\x64\x64_stack_layout.h">
<Filter>src\xenia\cpu\backend\x64</Filter>
</ClInclude>
<ClInclude Include="src\xenia\ui\gl\blitter.h">
<Filter>src\xenia\ui\gl</Filter>
</ClInclude>
<ClInclude Include="src\xenia\ui\gl\gl_context.h">
<Filter>src\xenia\ui\gl</Filter>
</ClInclude>
<ClInclude Include="src\xenia\ui\gl\wgl_control.h">
<Filter>src\xenia\ui\gl</Filter>
</ClInclude>
<ClInclude Include="src\xenia\ui\gl\gl_profiler_display.h">
<Filter>src\xenia\ui\gl</Filter>
</ClInclude>
<ClInclude Include="src\xenia\ui\gl\circular_buffer.h">
<Filter>src\xenia\ui\gl</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="src\xenia\cpu\hir\opcodes.inl">

View File

@ -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<GLContext> context) {
bool CommandProcessor::Initialize(
std::unique_ptr<xe::ui::gl::GLContext> context) {
context_ = std::move(context);
worker_running_ = true;

View File

@ -18,9 +18,7 @@
#include <unordered_map>
#include <vector>
#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<GLContext> context);
bool Initialize(std::unique_ptr<xe::ui::gl::GLContext> context);
void Shutdown();
void CallInThread(std::function<void()> fn);
@ -238,7 +238,7 @@ class CommandProcessor {
std::atomic<bool> worker_running_;
kernel::object_ref<kernel::XHostThread> worker_thread_;
std::unique_ptr<GLContext> context_;
std::unique_ptr<xe::ui::gl::GLContext> context_;
SwapHandler swap_handler_;
std::queue<std::function<void()>> 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);

View File

@ -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);

View File

@ -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 {

View File

@ -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.");

View File

@ -12,13 +12,6 @@
#include <gflags/gflags.h>
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);

View File

@ -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<GLContext> processor_context;
std::unique_ptr<xe::ui::gl::GLContext> 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<WGLControl>(target_loop_);
control_ = std::make_unique<xe::ui::gl::WGLControl>(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<GL4ProfilerDisplay>(control_.get());
std::make_unique<xe::ui::gl::GLProfilerDisplay>(control_.get());
Profiler::set_display(std::move(profiler_display));
}

View File

@ -13,10 +13,10 @@
#include <memory>
#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<CommandProcessor> command_processor_;
std::unique_ptr<WGLControl> control_;
std::unique_ptr<xe::ui::gl::WGLControl> control_;
std::atomic<bool> worker_running_;
kernel::object_ref<kernel::XHostThread> worker_thread_;

View File

@ -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),

View File

@ -12,8 +12,8 @@
#include <string>
#include "xenia/gpu/gl4/gl_context.h"
#include "xenia/gpu/shader.h"
#include "xenia/ui/gl/gl_context.h"
namespace xe {
namespace gpu {

View File

@ -13,10 +13,10 @@
#include <string>
#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 {

View File

@ -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;

View File

@ -15,17 +15,21 @@
#include <vector>
#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;

View File

@ -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<std::wstring>& 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;

View File

@ -7,19 +7,17 @@
******************************************************************************
*/
#include "xenia/gpu/gl4/blitter.h"
#include "xenia/ui/gl/blitter.h"
#include <string>
#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

View File

@ -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 <memory>
@ -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_

View File

@ -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

View File

@ -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 <unordered_map>
#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<uint64_t, uintptr_t> 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_

View File

@ -7,7 +7,7 @@
******************************************************************************
*/
#include "xenia/gpu/gl4/gl_context.h"
#include "xenia/ui/gl/gl_context.h"
#include <mutex>
#include <string>
@ -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

View File

@ -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 <gflags/gflags.h>
#include <memory>
#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_

View File

@ -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<Vertex*>(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,7 +420,7 @@ void GL4ProfilerDisplay::Flush() {
vertex_buffer_.WaitUntilClean();
}
void GL4ProfilerDisplay::DrawBox(int x0, int y0, int x1, int y1, uint32_t color,
void GLProfilerDisplay::DrawBox(int x0, int y0, int x1, int y1, uint32_t color,
BoxType type) {
auto v = BeginVertices(6);
if (type == BoxType::kFlat) {
@ -489,7 +486,7 @@ 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,
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

View File

@ -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_

View File

@ -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<void()> paint_callback) {
RDW_INTERNALPAINT | RDW_UPDATENOW | RDW_ALLCHILDREN);
}
} // namespace gl4
} // namespace gpu
} // namespace gl
} // namespace ui
} // namespace xe

View File

@ -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 <functional>
#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<void()> 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_