From 2d3e8315938a42f2003ddf9170ee7becf8eed6c1 Mon Sep 17 00:00:00 2001 From: Rich Geldreich Date: Fri, 21 Mar 2014 17:39:32 -0700 Subject: [PATCH] - Adding "-msaa X" command line option to voglreplay tool. We don't fully support MSAA default framebuffers yet, but this is a start until we do. --- src/voglbench/voglbench.cpp | 3 ++- src/voglcommon/vogl_replay_window.cpp | 38 ++++++++++++++++----------- src/voglcommon/vogl_replay_window.h | 2 +- src/voglreplay/vogl_replay_tool.cpp | 7 ++--- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/voglbench/voglbench.cpp b/src/voglbench/voglbench.cpp index a7fdad1..92971af 100644 --- a/src/voglbench/voglbench.cpp +++ b/src/voglbench/voglbench.cpp @@ -70,6 +70,7 @@ static command_line_param_desc g_command_line_param_descs[] = { { "width", 1, false, "Replay: Set initial window width (default is 1024)" }, { "height", 1, false, "Replay: Set initial window height (default is 768)" }, + { "msaa", 1, false, "Replay: Set initial window multisamples (default is 0)" }, { "lock_window_dimensions", 0, false, "Replay: Don't automatically change window's dimensions during replay" }, { "endless", 0, false, "Replay: Loop replay endlessly instead of exiting" }, { "force_debug_context", 0, false, "Replay: Force GL debug contexts" }, @@ -397,7 +398,7 @@ static bool tool_replay_mode() // TODO: This will create a window with default attributes, which seems fine for the majority of traces. // Unfortunately, some GL call streams *don't* want an alpha channel, or depth, or stencil etc. in the default framebuffer so this may become a problem. // Also, this design only supports a single window, which is going to be a problem with multiple window traces. - if (!window.open(g_command_line_params.get_value_as_int("width", 0, 1024, 1, 65535), g_command_line_params.get_value_as_int("height", 0, 768, 1, 65535))) + if (!window.open(g_command_line_params.get_value_as_int("width", 0, 1024, 1, 65535), g_command_line_params.get_value_as_int("height", 0, 768, 1, 65535), g_command_line_params.get_value_as_int("msaa", 0, 0, 0, 65535))) { vogl_error_printf("%s: Failed initializing replay window\n", VOGL_FUNCTION_NAME); return false; diff --git a/src/voglcommon/vogl_replay_window.cpp b/src/voglcommon/vogl_replay_window.cpp index 8ad3ecd..46b7140 100644 --- a/src/voglcommon/vogl_replay_window.cpp +++ b/src/voglcommon/vogl_replay_window.cpp @@ -44,7 +44,7 @@ vogl_replay_window::~vogl_replay_window() close(); } -bool vogl_replay_window::open(int width, int height) +bool vogl_replay_window::open(int width, int height, int samples) { VOGL_FUNC_TRACER @@ -54,20 +54,28 @@ bool vogl_replay_window::open(int width, int height) return false; // TODO: These attribs (especially the sizes) should be passed in by the caller! - static int fbAttribs[] = - { - GLX_RENDER_TYPE, GLX_RGBA_BIT, - GLX_X_RENDERABLE, True, - GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, - GLX_DOUBLEBUFFER, True, - GLX_RED_SIZE, 8, - GLX_BLUE_SIZE, 8, - GLX_GREEN_SIZE, 8, - GLX_ALPHA_SIZE, 8, - GLX_DEPTH_SIZE, 24, - GLX_STENCIL_SIZE, 8, - 0 - }; + int fbAttribs[64]; + + int *pAttribs = fbAttribs; + + *pAttribs++ = GLX_RENDER_TYPE; *pAttribs++ = GLX_RGBA_BIT; + *pAttribs++ = GLX_X_RENDERABLE; *pAttribs++ = True; + *pAttribs++ = GLX_DRAWABLE_TYPE; *pAttribs++ = GLX_WINDOW_BIT; + *pAttribs++ = GLX_DOUBLEBUFFER; *pAttribs++ = True; + *pAttribs++ = GLX_RED_SIZE; *pAttribs++ = 8; + *pAttribs++ = GLX_BLUE_SIZE; *pAttribs++ = 8; + *pAttribs++ = GLX_GREEN_SIZE; *pAttribs++ = 8; + *pAttribs++ = GLX_ALPHA_SIZE; *pAttribs++ = 8; + *pAttribs++ = GLX_DEPTH_SIZE; *pAttribs++ = 24; + *pAttribs++ = GLX_STENCIL_SIZE; *pAttribs++ = 8; + + if (samples > 1) + { + *pAttribs++ = GLX_SAMPLE_BUFFERS; *pAttribs++ = 1; + *pAttribs++ = GLX_SAMPLES; *pAttribs++ = samples; + } + + *pAttribs++ = 0; // Tell X we are going to use the display m_dpy = XOpenDisplay(NULL); diff --git a/src/voglcommon/vogl_replay_window.h b/src/voglcommon/vogl_replay_window.h index 0d9586b..48c31c7 100644 --- a/src/voglcommon/vogl_replay_window.h +++ b/src/voglcommon/vogl_replay_window.h @@ -44,7 +44,7 @@ public: return (m_width > 0) && (m_dpy != NULL); } - bool open(int width, int height); + bool open(int width, int height, int samples = 1); void set_title(const char *pTitle); diff --git a/src/voglreplay/vogl_replay_tool.cpp b/src/voglreplay/vogl_replay_tool.cpp index 40e23a4..3a2d0f6 100644 --- a/src/voglreplay/vogl_replay_tool.cpp +++ b/src/voglreplay/vogl_replay_tool.cpp @@ -78,8 +78,9 @@ static command_line_param_desc g_command_line_param_descs[] = { "compare_hash_files", 0, false, "Compare two files containing CRC's or per-component sums (presumably written using dump_backbuffer_hashes)" }, // replay specific - { "width", 1, false, "Replay: Set initial window width (default is 1024)" }, - { "height", 1, false, "Replay: Set initial window height (default is 768)" }, + { "width", 1, false, "Replay: Set replay window's initial width (default is 1024)" }, + { "height", 1, false, "Replay: Set replay window's initial height (default is 768)" }, + { "msaa", 1, false, "Replay: Set replay window's multisamples (default is 0)." }, { "lock_window_dimensions", 0, false, "Replay: Don't automatically change window's dimensions during replay" }, { "trim_file", 1, false, "Replay: Create a trimmed trace file during replay, must also specify -trim_frame" }, { "trim_frame", 1, false, "Replay: Frame index to begin trim, 0=beginning of trace, 1=first API call after first swap, etc." }, @@ -661,7 +662,7 @@ static bool tool_replay_mode() // TODO: This will create a window with default attributes, which seems fine for the majority of traces. // Unfortunately, some GL call streams *don't* want an alpha channel, or depth, or stencil etc. in the default framebuffer so this may become a problem. // Also, this design only supports a single window, which is going to be a problem with multiple window traces. - if (!window.open(g_command_line_params.get_value_as_int("width", 0, 1024, 1, 65535), g_command_line_params.get_value_as_int("height", 0, 768, 1, 65535))) + if (!window.open(g_command_line_params.get_value_as_int("width", 0, 1024, 1, 65535), g_command_line_params.get_value_as_int("height", 0, 768, 1, 65535), g_command_line_params.get_value_as_int("msaa", 0, 0, 0, 65535))) { vogl_error_printf("%s: Failed initializing replay window\n", VOGL_FUNCTION_NAME); return false; -- 2.43.0