Added "-debugrenderdevice" command line argument to write a logfile for the render device

This commit is contained in:
biwa 2022-08-18 10:18:16 +02:00
parent 91010eb92f
commit d597c11e1f
8 changed files with 30 additions and 21 deletions

View file

@ -231,6 +231,7 @@ namespace CodeImp.DoomBuilder
private static bool delaymainwindow; private static bool delaymainwindow;
private static bool nosettings; private static bool nosettings;
private static bool portablemode; //mxd private static bool portablemode; //mxd
private static bool debugrenderdevice;
//misc //misc
private static readonly Random random = new Random(); //mxd private static readonly Random random = new Random(); //mxd
@ -275,6 +276,7 @@ namespace CodeImp.DoomBuilder
public static DataLocationList AutoLoadResources { get { return new DataLocationList(autoloadresources); } } public static DataLocationList AutoLoadResources { get { return new DataLocationList(autoloadresources); } }
public static bool DelayMainWindow { get { return delaymainwindow; } } public static bool DelayMainWindow { get { return delaymainwindow; } }
public static bool NoSettings { get { return nosettings; } } public static bool NoSettings { get { return nosettings; } }
public static bool DebugRenderDevice { get { return debugrenderdevice; } }
public static EditingManager Editing { get { return editing; } } public static EditingManager Editing { get { return editing; } }
public static ErrorLogger ErrorLogger { get { return errorlogger; } } public static ErrorLogger ErrorLogger { get { return errorlogger; } }
public static string CommitHash { get { return commithash; } } //mxd public static string CommitHash { get { return commithash; } } //mxd
@ -956,6 +958,10 @@ namespace CodeImp.DoomBuilder
if(!string.IsNullOrEmpty(dl.location)) if(!string.IsNullOrEmpty(dl.location))
autoloadresources.Add(dl); autoloadresources.Add(dl);
} }
else if (string.Compare(curarg, "-DEBUGRENDERDEVICE", true) == 0)
{
debugrenderdevice = true;
}
// Every other arg // Every other arg
else else
{ {

View file

@ -134,7 +134,7 @@ namespace CodeImp.DoomBuilder.Rendering
display = (IntPtr)xplatui.GetField("DisplayHandle", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); display = (IntPtr)xplatui.GetField("DisplayHandle", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
} }
Handle = RenderDevice_New(display, RenderTarget.Handle); Handle = RenderDevice_New(display, RenderTarget.Handle, General.DebugRenderDevice);
if (Handle == IntPtr.Zero) if (Handle == IntPtr.Zero)
{ {
StringBuilder sb = new StringBuilder(4096); StringBuilder sb = new StringBuilder(4096);
@ -571,7 +571,7 @@ namespace CodeImp.DoomBuilder.Rendering
IntPtr Handle; IntPtr Handle;
[DllImport("BuilderNative", CallingConvention = CallingConvention.Cdecl)] [DllImport("BuilderNative", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr RenderDevice_New(IntPtr display, IntPtr window); static extern IntPtr RenderDevice_New(IntPtr display, IntPtr window, bool debug);
[DllImport("BuilderNative", CallingConvention = CallingConvention.Cdecl)] [DllImport("BuilderNative", CallingConvention = CallingConvention.Cdecl)]
static extern void RenderDevice_Delete(IntPtr handle); static extern void RenderDevice_Delete(IntPtr handle);

View file

@ -66,9 +66,9 @@ Backend* Backend::Get()
extern "C" extern "C"
{ {
RenderDevice* RenderDevice_New(void* disp, void* window) RenderDevice* RenderDevice_New(void* disp, void* window, bool debug)
{ {
return Backend::Get()->NewRenderDevice(disp, window); return Backend::Get()->NewRenderDevice(disp, window, debug);
} }
void RenderDevice_Delete(RenderDevice* device) void RenderDevice_Delete(RenderDevice* device)

View file

@ -133,7 +133,7 @@ public:
static Backend* Get(); static Backend* Get();
virtual RenderDevice* NewRenderDevice(void* disp, void* window) = 0; virtual RenderDevice* NewRenderDevice(void* disp, void* window, bool debug) = 0;
virtual void DeleteRenderDevice(RenderDevice* device) = 0; virtual void DeleteRenderDevice(RenderDevice* device) = 0;
virtual VertexBuffer* NewVertexBuffer() = 0; virtual VertexBuffer* NewVertexBuffer() = 0;

View file

@ -26,9 +26,9 @@
#include "GLIndexBuffer.h" #include "GLIndexBuffer.h"
#include "GLTexture.h" #include "GLTexture.h"
RenderDevice* GLBackend::NewRenderDevice(void* disp, void* window) RenderDevice* GLBackend::NewRenderDevice(void* disp, void* window, bool debug)
{ {
GLRenderDevice* device = new GLRenderDevice(disp, window); GLRenderDevice* device = new GLRenderDevice(disp, window, debug);
if (!device->Context) if (!device->Context)
{ {
delete device; delete device;

View file

@ -26,7 +26,7 @@
class GLBackend : public Backend class GLBackend : public Backend
{ {
public: public:
RenderDevice* NewRenderDevice(void* disp, void* window) override; RenderDevice* NewRenderDevice(void* disp, void* window, bool debug) override;
void DeleteRenderDevice(RenderDevice* device) override; void DeleteRenderDevice(RenderDevice* device) override;
VertexBuffer* NewVertexBuffer() override; VertexBuffer* NewVertexBuffer() override;

View file

@ -44,14 +44,16 @@ static const char* GLLogCheckNull(const GLubyte* str)
return str ? (const char*)str : "null"; return str ? (const char*)str : "null";
} }
GLRenderDevice::GLRenderDevice(void* disp, void* window) GLRenderDevice::GLRenderDevice(void* disp, void* window, bool debug)
{ {
Context = IOpenGLContext::Create(disp, window); Context = IOpenGLContext::Create(disp, window);
if (Context) if (Context)
{ {
Context->MakeCurrent(); Context->MakeCurrent();
#ifdef _DEBUG //#ifdef _DEBUG
if (debug)
{
FILE* f = fopen("OpenGLDebug.log", "wb"); FILE* f = fopen("OpenGLDebug.log", "wb");
if (f) if (f)
{ {
@ -64,7 +66,8 @@ GLRenderDevice::GLRenderDevice(void* disp, void* window)
glEnable(GL_DEBUG_OUTPUT); glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(&GLLogCallback, nullptr); glDebugMessageCallback(&GLLogCallback, nullptr);
} }
#endif }
//#endif
glGenVertexArrays(1, &mStreamVAO); glGenVertexArrays(1, &mStreamVAO);
glGenBuffers(1, &mStreamVertexBuffer); glGenBuffers(1, &mStreamVertexBuffer);

View file

@ -35,7 +35,7 @@ class GLTexture;
class GLRenderDevice : public RenderDevice class GLRenderDevice : public RenderDevice
{ {
public: public:
GLRenderDevice(void* disp, void* window); GLRenderDevice(void* disp, void* window, bool debug);
~GLRenderDevice(); ~GLRenderDevice();
void DeclareUniform(UniformName name, const char* glslname, UniformType type) override; void DeclareUniform(UniformName name, const char* glslname, UniformType type) override;