Skip to content

Commit

Permalink
Merge pull request #1618 from vlj/gl
Browse files Browse the repository at this point in the history
gl: Enable core context and debug output.
  • Loading branch information
vlj committed Mar 27, 2016
2 parents 35570a5 + 855d693 commit 27a8c07
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ endif()
set(PNG_SHARED OFF CACHE BOOL "Build shared lib." FORCE)
set(PNG_TESTS OFF CACHE BOOL "Build tests." FORCE)

add_definitions(-DCMAKE_BUILD)

add_subdirectory( asmjit )
add_subdirectory( 3rdparty/libpng )
# TODO: do real installation, including copying directory structure
Expand Down
22 changes: 4 additions & 18 deletions rpcs3/Emu/RSX/GL/GLGSRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void GLGSRender::begin()
__glcheck glDepthRange((f32&)rsx::method_registers[NV4097_SET_CLIP_MIN], (f32&)rsx::method_registers[NV4097_SET_CLIP_MAX]);
__glcheck enable(rsx::method_registers[NV4097_SET_DITHER_ENABLE], GL_DITHER);

if (__glcheck enable(rsx::method_registers[NV4097_SET_ALPHA_TEST_ENABLE], GL_ALPHA_TEST))
if (!!rsx::method_registers[NV4097_SET_ALPHA_TEST_ENABLE])
{
//TODO: NV4097_SET_ALPHA_REF must be converted to f32
//glcheck(glAlphaFunc(rsx::method_registers[NV4097_SET_ALPHA_FUNC], rsx::method_registers[NV4097_SET_ALPHA_REF]));
Expand Down Expand Up @@ -205,7 +205,7 @@ void GLGSRender::begin()
__glcheck enable(blend_mrt & 8, GL_BLEND, GL_COLOR_ATTACHMENT3);
}

if (__glcheck enable(rsx::method_registers[NV4097_SET_LOGIC_OP_ENABLE], GL_LOGIC_OP))
if (__glcheck enable(rsx::method_registers[NV4097_SET_LOGIC_OP_ENABLE], GL_COLOR_LOGIC_OP))
{
__glcheck glLogicOp(rsx::method_registers[NV4097_SET_LOGIC_OP]);
}
Expand Down Expand Up @@ -261,14 +261,6 @@ void GLGSRender::begin()

__glcheck enable(rsx::method_registers[NV4097_SET_POLY_OFFSET_FILL_ENABLE], GL_POLYGON_OFFSET_FILL);

if (__glcheck enable(rsx::method_registers[NV4097_SET_POLYGON_STIPPLE], GL_POLYGON_STIPPLE))
{
__glcheck glPolygonStipple((GLubyte*)(rsx::method_registers + NV4097_SET_POLYGON_STIPPLE_PATTERN));
}

__glcheck glPolygonMode(GL_FRONT, rsx::method_registers[NV4097_SET_FRONT_POLYGON_MODE]);
__glcheck glPolygonMode(GL_BACK, rsx::method_registers[NV4097_SET_BACK_POLYGON_MODE]);

if (__glcheck enable(rsx::method_registers[NV4097_SET_CULL_FACE_ENABLE], GL_CULL_FACE))
{
__glcheck glCullFace(rsx::method_registers[NV4097_SET_CULL_FACE]);
Expand All @@ -288,14 +280,6 @@ void GLGSRender::begin()
{
__glcheck glPrimitiveRestartIndex(rsx::method_registers[NV4097_SET_RESTART_INDEX]);
}

if (__glcheck enable(rsx::method_registers[NV4097_SET_LINE_STIPPLE], GL_LINE_STIPPLE))
{
u32 line_stipple_pattern = rsx::method_registers[NV4097_SET_LINE_STIPPLE_PATTERN];
u16 factor = line_stipple_pattern;
u16 pattern = line_stipple_pattern >> 16;
__glcheck glLineStipple(factor, pattern);
}
}

template<typename T, int count>
Expand Down Expand Up @@ -779,6 +763,8 @@ void GLGSRender::on_init_thread()
GSRender::on_init_thread();

gl::init();
if (rpcs3::config.rsx.d3d12.debug_output.value())
gl::enable_debugging();
LOG_NOTICE(RSX, "%s", (const char*)glGetString(GL_VERSION));
LOG_NOTICE(RSX, "%s", (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION));
LOG_NOTICE(RSX, "%s", (const char*)glGetString(GL_VENDOR));
Expand Down
4 changes: 1 addition & 3 deletions rpcs3/Emu/RSX/GL/GLProcTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ OPENGL_PROC(PFNGLTEXTUREBUFFERRANGEEXTPROC, TextureBufferRangeEXT);
OPENGL_PROC(PFNGLCOPYIMAGESUBDATAPROC, CopyImageSubData);

//KHR_debug
OPENGL_PROC(PFNGLDEBUGMESSAGECONTROLARBPROC, DebugMessageControlARB);
OPENGL_PROC(PFNGLDEBUGMESSAGEINSERTARBPROC, DebugMessageInsertARB);
OPENGL_PROC(PFNGLDEBUGMESSAGECALLBACKARBPROC, DebugMessageCallbackARB);
OPENGL_PROC(PFNGLDEBUGMESSAGECALLBACKPROC, DebugMessageCallback);

OPENGL_PROC(PFNGLTEXSTORAGE2DPROC, TexStorage2D);
//...
Expand Down
25 changes: 25 additions & 0 deletions rpcs3/Emu/RSX/GL/gl_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ namespace gl
throw new EXCEPTION("unknow primitive type");
}

#ifdef WIN32
void APIENTRY dbgFunc(GLenum source, GLenum type, GLuint id,
GLenum severity, GLsizei lenght, const GLchar* message,
const void* userParam)
{
switch (type)
{
case GL_DEBUG_TYPE_ERROR:
LOG_ERROR(RSX, "%s", message);
return;
default:
LOG_WARNING(RSX, "%s", message);
return;
}
}
#endif

void enable_debugging()
{
#ifdef WIN32
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageCallback(static_cast<GLDEBUGPROC>(dbgFunc), nullptr);
#endif
}

void fbo::create()
{
glGenFramebuffers(1, &m_id);
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/RSX/GL/gl_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ namespace gl
#define __glcheck
#endif

void enable_debugging();

class exception : public std::exception
{
protected:
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/GL/rsx_gl_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ namespace rsx

glTexParameteri(m_target, GL_TEXTURE_COMPARE_FUNC, gl_tex_zfunc[tex.zfunc()]);

glTexEnvi(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, (GLint)tex.bias());
// TODO: Handle texture bias
glTexParameteri(m_target, GL_TEXTURE_MIN_LOD, (tex.min_lod() >> 8));
glTexParameteri(m_target, GL_TEXTURE_MAX_LOD, (tex.max_lod() >> 8));

Expand Down
10 changes: 10 additions & 0 deletions rpcs3/Gui/GLGSFrame.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "stdafx.h"
#include "stdafx_gui.h"
#include "GLGSFrame.h"
#include "config.h"
#include <wx/version.h>

GLGSFrame::GLGSFrame() : GSFrame("OpenGL")
{
Expand All @@ -9,6 +11,14 @@ GLGSFrame::GLGSFrame() : GSFrame("OpenGL")
WX_GL_RGBA,
WX_GL_DEPTH_SIZE, 16,
WX_GL_DOUBLEBUFFER,
#if wxCHECK_VERSION(3, 1, 0)
WX_GL_MAJOR_VERSION, 3,
WX_GL_MINOR_VERSION, 3,
WX_GL_CORE_PROFILE,
#if !defined(CMAKE_BUILD)
rpcs3::config.rsx.d3d12.debug_output.value() ? WX_GL_DEBUG : 0,
#endif
#endif
0
};

Expand Down

0 comments on commit 27a8c07

Please sign in to comment.