mirror of https://github.com/PCSX2/pcsx2.git
GS: Make GL_NNN macros device independent
This commit is contained in:
parent
5976be55f4
commit
8e920d727f
|
@ -19,6 +19,7 @@
|
|||
#include "GS/Window/GSwxDialog.h"
|
||||
#endif
|
||||
#include "GS.h"
|
||||
#include "GSGL.h"
|
||||
#include "GSUtil.h"
|
||||
#include "GSExtra.h"
|
||||
#include "Renderers/SW/GSRendererSW.h"
|
||||
|
|
|
@ -15,32 +15,35 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Renderers/OpenGL/GLLoader.h"
|
||||
#include "GSExtra.h"
|
||||
#include "GS/Renderers/Common/GSDevice.h"
|
||||
#include "GS/GSExtra.h"
|
||||
|
||||
#if !defined(NDEBUG) || defined(_DEBUG) || defined(_DEVEL)
|
||||
#define ENABLE_OGL_DEBUG // Create a debug context and check opengl command status. Allow also to dump various textures/states.
|
||||
//#define ENABLE_OGL_DEBUG_FENCE
|
||||
//#define ENABLE_OGL_DEBUG_MEM_BW // compute the quantity of data transfered (debug purpose)
|
||||
//#define ENABLE_TRACE_REG // print GS reg write
|
||||
//#define ENABLE_EXTRA_LOG // print extra log
|
||||
#endif
|
||||
|
||||
// Note: GL messages are present in common code, so in all renderers.
|
||||
|
||||
#define GL_INSERT(type, code, sev, ...) \
|
||||
do \
|
||||
if (glDebugMessageInsert) glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, type, code, sev, -1, format(__VA_ARGS__).c_str()); \
|
||||
while(0);
|
||||
|
||||
#if defined(_DEBUG)
|
||||
#define GL_CACHE(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xFEAD, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__)
|
||||
#define GL_CACHE(...) g_gs_device->InsertDebugMessage(GSDevice::DebugMessageCategory::Cache, __VA_ARGS__)
|
||||
#else
|
||||
#define GL_CACHE(...) (void)(0);
|
||||
#define GL_CACHE(...) (void)(0)
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_TRACE_REG) && defined(_DEBUG)
|
||||
#define GL_REG(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xB0B0, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__)
|
||||
#define GL_REG(...) g_gs_device->InsertDebugMessage(GSDevice::DebugMessageCategory::Reg, __VA_ARGS__)
|
||||
#else
|
||||
#define GL_REG(...) (void)(0);
|
||||
#define GL_REG(...) (void)(0)
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_EXTRA_LOG) && defined(_DEBUG)
|
||||
#define GL_DBG(...) GL_INSERT(GL_DEBUG_TYPE_OTHER, 0xD0D0, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__)
|
||||
#define GL_DBG(...) g_gs_device->InsertDebugMessage(GSDevice::DebugMessageCategory::Debug, __VA_ARGS__)
|
||||
#else
|
||||
#define GL_DBG(...) (void)(0);
|
||||
#define GL_DBG(...) (void)(0)
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_OGL_DEBUG)
|
||||
|
@ -48,20 +51,19 @@
|
|||
{
|
||||
~GLAutoPop()
|
||||
{
|
||||
if (glPopDebugGroup)
|
||||
glPopDebugGroup();
|
||||
g_gs_device->PopDebugGroup();
|
||||
}
|
||||
};
|
||||
|
||||
#define GL_PUSH_(...) do if (glPushDebugGroup) glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0xBAD, -1, format(__VA_ARGS__).c_str()); while(0);
|
||||
#define GL_PUSH(...) do if (glPushDebugGroup) glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0xBAD, -1, format(__VA_ARGS__).c_str()); while(0); GLAutoPop gl_auto_pop;
|
||||
#define GL_POP() do if (glPopDebugGroup) glPopDebugGroup(); while(0);
|
||||
#define GL_INS(...) GL_INSERT(GL_DEBUG_TYPE_ERROR, 0xDEAD, GL_DEBUG_SEVERITY_MEDIUM, __VA_ARGS__)
|
||||
#define GL_PERF(...) GL_INSERT(GL_DEBUG_TYPE_PERFORMANCE, 0xFEE1, GL_DEBUG_SEVERITY_NOTIFICATION, __VA_ARGS__)
|
||||
#define GL_PUSH_(...) g_gs_device->PushDebugGroup(__VA_ARGS__)
|
||||
#define GL_PUSH(...) g_gs_device->PushDebugGroup(__VA_ARGS__); GLAutoPop gl_auto_pop;
|
||||
#define GL_POP() g_gs_device->PopDebugGroup()
|
||||
#define GL_INS(...) g_gs_device->InsertDebugMessage(GSDevice::DebugMessageCategory::Message, __VA_ARGS__)
|
||||
#define GL_PERF(...) g_gs_device->InsertDebugMessage(GSDevice::DebugMessageCategory::Performance, __VA_ARGS__)
|
||||
#else
|
||||
#define GL_PUSH_(...) (void)(0);
|
||||
#define GL_PUSH(...) (void)(0);
|
||||
#define GL_POP() (void)(0);
|
||||
#define GL_INS(...) (void)(0);
|
||||
#define GL_PERF(...) (void)(0);
|
||||
#define GL_PUSH_(...) (void)(0)
|
||||
#define GL_PUSH(...) (void)(0)
|
||||
#define GL_POP() (void)(0)
|
||||
#define GL_INS(...) (void)(0)
|
||||
#define GL_PERF(...) (void)(0)
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,7 @@ GSState::GSState()
|
|||
{
|
||||
// m_nativeres seems to be a hack. Unfortunately it impacts draw call number which make debug painful in the replayer.
|
||||
// Let's keep it disabled to ease debug.
|
||||
m_nativeres = theApp.GetConfigI("upscale_multiplier") == 1 || GLLoader::in_replayer;
|
||||
m_nativeres = theApp.GetConfigI("upscale_multiplier") == 1;
|
||||
m_mipmap = theApp.GetConfigI("mipmap");
|
||||
m_NTSC_Saturation = theApp.GetConfigB("NTSC_Saturation");
|
||||
if (theApp.GetConfigB("UserHacks"))
|
||||
|
|
|
@ -570,6 +570,15 @@ public:
|
|||
DontCare
|
||||
};
|
||||
|
||||
enum class DebugMessageCategory
|
||||
{
|
||||
Cache,
|
||||
Reg,
|
||||
Debug,
|
||||
Message,
|
||||
Performance
|
||||
};
|
||||
|
||||
virtual bool Create(HostDisplay* display);
|
||||
virtual void Destroy();
|
||||
|
||||
|
@ -588,6 +597,10 @@ public:
|
|||
virtual void ClearDepth(GSTexture* t) {}
|
||||
virtual void ClearStencil(GSTexture* t, u8 c) {}
|
||||
|
||||
virtual void PushDebugGroup(const char* fmt, ...) {}
|
||||
virtual void PopDebugGroup() {}
|
||||
virtual void InsertDebugMessage(DebugMessageCategory category, const char* fmt, ...) {}
|
||||
|
||||
GSTexture* CreateSparseRenderTarget(int w, int h, GSTexture::Format format, bool clear = true);
|
||||
GSTexture* CreateSparseDepthStencil(int w, int h, GSTexture::Format format, bool clear = true);
|
||||
GSTexture* CreateRenderTarget(int w, int h, GSTexture::Format format, bool clear = true);
|
||||
|
|
|
@ -100,7 +100,7 @@ void GSRendererNew::SetupIA(const float& sx, const float& sy)
|
|||
// the extra validation cost of the extra stage.
|
||||
//
|
||||
// Note: keep Geometry Shader in the replayer to ease debug.
|
||||
if (g_gs_device->Features().geometry_shader && !m_vt.m_accurate_stq && (m_vertex.next > 32 || GLLoader::in_replayer)) // <=> 16 sprites (based on Shadow Hearts)
|
||||
if (g_gs_device->Features().geometry_shader && !m_vt.m_accurate_stq && m_vertex.next > 32) // <=> 16 sprites (based on Shadow Hearts)
|
||||
{
|
||||
m_conf.gs.expand = true;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "GS/GSGL.h"
|
||||
#include "GS/Renderers/OpenGL/GLLoader.h"
|
||||
#include "GS/GSVector.h"
|
||||
|
||||
namespace GLState
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "GS/GSState.h"
|
||||
#include "GSDeviceOGL.h"
|
||||
#include "GLState.h"
|
||||
#include "GS/GSGL.h"
|
||||
#include "GS/GSUtil.h"
|
||||
#include "Host.h"
|
||||
#include "HostDisplay.h"
|
||||
|
@ -83,8 +84,6 @@ GSDeviceOGL::~GSDeviceOGL()
|
|||
}
|
||||
#endif
|
||||
|
||||
GL_PUSH("GSDeviceOGL destructor");
|
||||
|
||||
// Clean vertex buffer state
|
||||
if (m_vertex_array_object)
|
||||
glDeleteVertexArrays(1, &m_vertex_array_object);
|
||||
|
@ -2162,3 +2161,74 @@ u16 GSDeviceOGL::ConvertBlendEnum(u16 generic)
|
|||
default : ASSERT(0); return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void GSDeviceOGL::PushDebugGroup(const char* fmt, ...)
|
||||
{
|
||||
#ifdef ENABLE_OGL_DEBUG
|
||||
if (!glPushDebugGroup)
|
||||
return;
|
||||
|
||||
std::va_list ap;
|
||||
va_start(ap, fmt);
|
||||
const std::string buf(StringUtil::StdStringFromFormatV(fmt, ap));
|
||||
va_end(ap);
|
||||
if (!buf.empty())
|
||||
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0xBAD, -1, buf.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
void GSDeviceOGL::PopDebugGroup()
|
||||
{
|
||||
#ifdef ENABLE_OGL_DEBUG
|
||||
if (!glPopDebugGroup)
|
||||
return;
|
||||
|
||||
glPopDebugGroup();
|
||||
#endif
|
||||
}
|
||||
|
||||
void GSDeviceOGL::InsertDebugMessage(DebugMessageCategory category, const char* fmt, ...)
|
||||
{
|
||||
#ifdef ENABLE_OGL_DEBUG
|
||||
if (!glDebugMessageInsert)
|
||||
return;
|
||||
|
||||
GLenum type, id, severity;
|
||||
switch (category)
|
||||
{
|
||||
case GSDevice::DebugMessageCategory::Cache:
|
||||
type = GL_DEBUG_TYPE_OTHER;
|
||||
id = 0xFEAD;
|
||||
severity = GL_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
case GSDevice::DebugMessageCategory::Reg:
|
||||
type = GL_DEBUG_TYPE_OTHER;
|
||||
id = 0xB0B0;
|
||||
severity = GL_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
case GSDevice::DebugMessageCategory::Debug:
|
||||
type = GL_DEBUG_TYPE_OTHER;
|
||||
id = 0xD0D0;
|
||||
severity = GL_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
case GSDevice::DebugMessageCategory::Message:
|
||||
type = GL_DEBUG_TYPE_ERROR;
|
||||
id = 0xDEAD;
|
||||
severity = GL_DEBUG_SEVERITY_MEDIUM;
|
||||
break;
|
||||
case GSDevice::DebugMessageCategory::Performance:
|
||||
default:
|
||||
type = GL_DEBUG_TYPE_PERFORMANCE;
|
||||
id = 0xFEE1;
|
||||
severity = GL_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
}
|
||||
|
||||
std::va_list ap;
|
||||
va_start(ap, fmt);
|
||||
const std::string buf(StringUtil::StdStringFromFormatV(fmt, ap));
|
||||
va_end(ap);
|
||||
if (!buf.empty())
|
||||
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, type, id, severity, buf.size(), buf.c_str());
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "GSTextureOGL.h"
|
||||
#include "GSUniformBufferOGL.h"
|
||||
#include "GLState.h"
|
||||
#include "GLLoader.h"
|
||||
#include "GS/GS.h"
|
||||
|
||||
#ifdef ENABLE_OGL_DEBUG_MEM_BW
|
||||
|
@ -347,6 +348,10 @@ public:
|
|||
|
||||
void CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r) final;
|
||||
|
||||
void PushDebugGroup(const char* fmt, ...) final;
|
||||
void PopDebugGroup() final;
|
||||
void InsertDebugMessage(DebugMessageCategory category, const char* fmt, ...) final;
|
||||
|
||||
// BlitRect *does* mess with GL state, be sure to re-bind.
|
||||
void BlitRect(GSTexture* sTex, const GSVector4i& r, const GSVector2i& dsize, bool at_origin, bool linear);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "GLState.h"
|
||||
#include "GS/GSPerfMon.h"
|
||||
#include "GS/GSPng.h"
|
||||
#include "GS/GSGL.h"
|
||||
|
||||
#ifdef ENABLE_OGL_DEBUG_MEM_BW
|
||||
extern u64 g_real_texture_upload_byte;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "GS/Renderers/Common/GSTexture.h"
|
||||
#include "GS/GSGL.h"
|
||||
#include "GS/Renderers/OpenGL/GLLoader.h"
|
||||
#include "common/AlignedMalloc.h"
|
||||
|
||||
namespace PboPool
|
||||
|
|
|
@ -61,7 +61,7 @@ GSRendererSW::GSRendererSW(int threads)
|
|||
|
||||
// Reset handler with the auto flush hack enabled on the SW renderer.
|
||||
// Some games run better without the hack so rely on ini/gui option.
|
||||
if (!GLLoader::in_replayer && theApp.GetConfigB("autoflush_sw"))
|
||||
if (theApp.GetConfigB("autoflush_sw"))
|
||||
{
|
||||
m_userhacks_auto_flush = true;
|
||||
ResetHandlers();
|
||||
|
|
|
@ -31,12 +31,4 @@
|
|||
// Not yet used/experimental OpenGL extensions
|
||||
//#define GL_EXT_TEX_SUB_IMAGE
|
||||
|
||||
#if !defined(NDEBUG) || defined(_DEBUG) || defined(_DEVEL)
|
||||
#define ENABLE_OGL_DEBUG // Create a debug context and check opengl command status. Allow also to dump various textures/states.
|
||||
//#define ENABLE_OGL_DEBUG_FENCE
|
||||
//#define ENABLE_OGL_DEBUG_MEM_BW // compute the quantity of data transfered (debug purpose)
|
||||
//#define ENABLE_TRACE_REG // print GS reg write
|
||||
//#define ENABLE_EXTRA_LOG // print extra log
|
||||
#endif
|
||||
|
||||
//#define DISABLE_PERF_MON // Burn cycle for nothing in release mode
|
||||
|
|
Loading…
Reference in New Issue