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

View file

@ -134,7 +134,7 @@ namespace CodeImp.DoomBuilder.Rendering
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)
{
StringBuilder sb = new StringBuilder(4096);
@ -571,7 +571,7 @@ namespace CodeImp.DoomBuilder.Rendering
IntPtr Handle;
[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)]
static extern void RenderDevice_Delete(IntPtr handle);

View file

@ -66,9 +66,9 @@ Backend* Backend::Get()
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)

View file

@ -133,7 +133,7 @@ public:
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 VertexBuffer* NewVertexBuffer() = 0;

View file

@ -26,9 +26,9 @@
#include "GLIndexBuffer.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)
{
delete device;

View file

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

View file

@ -44,27 +44,30 @@ static const char* GLLogCheckNull(const GLubyte* str)
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);
if (Context)
{
Context->MakeCurrent();
#ifdef _DEBUG
FILE* f = fopen("OpenGLDebug.log", "wb");
if (f)
//#ifdef _DEBUG
if (debug)
{
fprintf(f, "GL_VENDOR = %s\r\n", GLLogCheckNull(glGetString(GL_VENDOR)));
fprintf(f, "GL_RENDERER = %s\r\n", GLLogCheckNull(glGetString(GL_RENDERER)));
fprintf(f, "GL_VERSION = %s\r\n", GLLogCheckNull(glGetString(GL_VERSION)));
fprintf(f, "GL_SHADING_LANGUAGE_VERSION = %s\r\n", GLLogCheckNull(glGetString(GL_SHADING_LANGUAGE_VERSION)));
fclose(f);
FILE* f = fopen("OpenGLDebug.log", "wb");
if (f)
{
fprintf(f, "GL_VENDOR = %s\r\n", GLLogCheckNull(glGetString(GL_VENDOR)));
fprintf(f, "GL_RENDERER = %s\r\n", GLLogCheckNull(glGetString(GL_RENDERER)));
fprintf(f, "GL_VERSION = %s\r\n", GLLogCheckNull(glGetString(GL_VERSION)));
fprintf(f, "GL_SHADING_LANGUAGE_VERSION = %s\r\n", GLLogCheckNull(glGetString(GL_SHADING_LANGUAGE_VERSION)));
fclose(f);
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(&GLLogCallback, nullptr);
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(&GLLogCallback, nullptr);
}
}
#endif
//#endif
glGenVertexArrays(1, &mStreamVAO);
glGenBuffers(1, &mStreamVertexBuffer);

View file

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