forked from bartvdbraak/blender
Merge branch 'master' into blender2.8
This commit is contained in:
commit
36e7de9eb3
@ -127,15 +127,16 @@ enum {
|
||||
G_DEBUG_DEPSGRAPH_TAG = (1 << 10), /* depsgraph tagging messages */
|
||||
G_DEBUG_DEPSGRAPH_TIME = (1 << 11), /* depsgraph timing statistics and messages */
|
||||
G_DEBUG_DEPSGRAPH_NO_THREADS = (1 << 12), /* single threaded depsgraph */
|
||||
G_DEBUG_DEPSGRAPH_PRETTY = (1 << 13), /* use pretty colors in depsgraph messages */
|
||||
G_DEBUG_DEPSGRAPH = (G_DEBUG_DEPSGRAPH_BUILD |
|
||||
G_DEBUG_DEPSGRAPH_EVAL |
|
||||
G_DEBUG_DEPSGRAPH_TAG |
|
||||
G_DEBUG_DEPSGRAPH_TIME),
|
||||
G_DEBUG_SIMDATA = (1 << 13), /* sim debug data display */
|
||||
G_DEBUG_GPU_MEM = (1 << 14), /* gpu memory in status bar */
|
||||
G_DEBUG_GPU = (1 << 15), /* gpu debug */
|
||||
G_DEBUG_IO = (1 << 13), /* IO Debugging (for Collada, ...)*/
|
||||
G_DEBUG_GPU_SHADERS = (1 << 16), /* GLSL shaders */
|
||||
G_DEBUG_SIMDATA = (1 << 14), /* sim debug data display */
|
||||
G_DEBUG_GPU_MEM = (1 << 15), /* gpu memory in status bar */
|
||||
G_DEBUG_GPU = (1 << 16), /* gpu debug */
|
||||
G_DEBUG_IO = (1 << 17), /* IO Debugging (for Collada, ...)*/
|
||||
G_DEBUG_GPU_SHADERS = (1 << 18), /* GLSL shaders */
|
||||
};
|
||||
|
||||
#define G_DEBUG_ALL (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM | G_DEBUG_JOBS | \
|
||||
|
42
source/blender/blenlib/BLI_console.h
Normal file
42
source/blender/blenlib/BLI_console.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2018 Blender Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Contributor(s): Srrgey Sharybin.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef __BLI_CONSOLE_H__
|
||||
#define __BLI_CONSOLE_H__
|
||||
|
||||
/** \file BLI_console.h
|
||||
* \ingroup bli
|
||||
* \brief Set of utility functions and constants to work with consoles.
|
||||
*/
|
||||
|
||||
/* Format string where one could BLI_snprintf() R, G and B values
|
||||
* and get proper marker to start colored output in the console.
|
||||
*/
|
||||
#define TRUECOLOR_ANSI_COLOR_FORMAT "\x1b[38;2;%d;%d;%dm"
|
||||
|
||||
/* Marker which indicates that colored output is finished. */
|
||||
#define TRUECOLOR_ANSI_COLOR_FINISH "\x1b[0m"
|
||||
|
||||
#endif /* __BLI_CONSOLE_H__ */
|
@ -68,4 +68,16 @@ BLI_INLINE float BLI_hash_int_01(unsigned int k)
|
||||
return (float)BLI_hash_int(k) * (1.0f / (float)0xFFFFFFFF);
|
||||
}
|
||||
|
||||
BLI_INLINE void BLI_hash_pointer_to_color(const void *ptr, int *r, int *g, int *b)
|
||||
{
|
||||
size_t val = (size_t)ptr;
|
||||
const size_t hash_a = BLI_hash_int(val & 0x0000ffff);
|
||||
const size_t hash_b = BLI_hash_int((val & 0xffff0000) >> 32);
|
||||
const size_t hash =
|
||||
hash_a ^ (hash_b + 0x9e3779b9 + (hash_a << 6) + (hash_a >> 2));
|
||||
*r = (hash & 0xff0000) >> 16;
|
||||
*g = (hash & 0x00ff00) >> 8;
|
||||
*b = hash & 0x0000ff;
|
||||
}
|
||||
|
||||
#endif // __BLI_HASH_H__
|
||||
|
@ -139,6 +139,7 @@ set(SRC
|
||||
BLI_compiler_attrs.h
|
||||
BLI_compiler_compat.h
|
||||
BLI_compiler_typecheck.h
|
||||
BLI_console.h
|
||||
BLI_convexhull_2d.h
|
||||
BLI_dial_2d.h
|
||||
BLI_dlrbTree.h
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_console.h"
|
||||
#include "BLI_hash.h"
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_listbase.h"
|
||||
|
||||
@ -526,6 +528,31 @@ void deg_editors_scene_update(const DEGEditorUpdateContext *update_ctx,
|
||||
}
|
||||
}
|
||||
|
||||
bool deg_terminal_do_color(void)
|
||||
{
|
||||
return (G.debug & G_DEBUG_DEPSGRAPH_PRETTY) != 0;
|
||||
}
|
||||
|
||||
string deg_color_for_pointer(const void *pointer)
|
||||
{
|
||||
if (!deg_terminal_do_color()) {
|
||||
return "";
|
||||
}
|
||||
int r, g, b;
|
||||
BLI_hash_pointer_to_color(pointer, &r, &g, &b);
|
||||
char buffer[64];
|
||||
BLI_snprintf(buffer, sizeof(buffer), TRUECOLOR_ANSI_COLOR_FORMAT, r, g, b);
|
||||
return string(buffer);
|
||||
}
|
||||
|
||||
string deg_color_end(void)
|
||||
{
|
||||
if (!deg_terminal_do_color()) {
|
||||
return "";
|
||||
}
|
||||
return string(TRUECOLOR_ANSI_COLOR_FINISH);
|
||||
}
|
||||
|
||||
} // namespace DEG
|
||||
|
||||
/* **************** */
|
||||
@ -554,6 +581,8 @@ void DEG_editors_set_update_cb(DEG_EditorUpdateIDCb id_func,
|
||||
DEG::deg_editor_update_scene_cb = scene_func;
|
||||
}
|
||||
|
||||
/* Evaluation and debug */
|
||||
|
||||
void DEG_debug_print_eval(const char *function_name,
|
||||
const char *object_name,
|
||||
const void *object_address)
|
||||
@ -561,7 +590,12 @@ void DEG_debug_print_eval(const char *function_name,
|
||||
if ((G.debug & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
|
||||
return;
|
||||
}
|
||||
printf("%s on %s (%p)\n", function_name, object_name, object_address);
|
||||
printf("%s on %s %s(%p)%s\n",
|
||||
function_name,
|
||||
object_name,
|
||||
DEG::deg_color_for_pointer(object_address).c_str(),
|
||||
object_address,
|
||||
DEG::deg_color_end().c_str());
|
||||
}
|
||||
|
||||
void DEG_debug_print_eval_subdata(const char *function_name,
|
||||
@ -574,11 +608,17 @@ void DEG_debug_print_eval_subdata(const char *function_name,
|
||||
if ((G.debug & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
|
||||
return;
|
||||
}
|
||||
printf("%s on %s (%p) %s %s (%p)\n",
|
||||
printf("%s on %s %s(%p)%s %s %s %s(%p)%s\n",
|
||||
function_name,
|
||||
object_name, object_address,
|
||||
object_name,
|
||||
DEG::deg_color_for_pointer(object_address).c_str(),
|
||||
object_address,
|
||||
DEG::deg_color_end().c_str(),
|
||||
subdata_comment,
|
||||
subdata_name, subdata_address);
|
||||
subdata_name,
|
||||
DEG::deg_color_for_pointer(subdata_address).c_str(),
|
||||
subdata_address,
|
||||
DEG::deg_color_end().c_str());
|
||||
}
|
||||
|
||||
void DEG_debug_print_eval_subdata_index(const char *function_name,
|
||||
@ -592,11 +632,18 @@ void DEG_debug_print_eval_subdata_index(const char *function_name,
|
||||
if ((G.debug & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
|
||||
return;
|
||||
}
|
||||
printf("%s on %s (%p) %s %s[%d] (%p)\n",
|
||||
printf("%s on %s %s(%p)^%s %s %s[%d] %s(%p)%s\n",
|
||||
function_name,
|
||||
object_name, object_address,
|
||||
object_name,
|
||||
DEG::deg_color_for_pointer(object_address).c_str(),
|
||||
object_address,
|
||||
DEG::deg_color_end().c_str(),
|
||||
subdata_comment,
|
||||
subdata_name, subdata_index, subdata_address);
|
||||
subdata_name,
|
||||
subdata_index,
|
||||
DEG::deg_color_for_pointer(subdata_address).c_str(),
|
||||
subdata_address,
|
||||
DEG::deg_color_end().c_str());
|
||||
}
|
||||
|
||||
void DEG_debug_print_eval_time(const char *function_name,
|
||||
@ -607,6 +654,11 @@ void DEG_debug_print_eval_time(const char *function_name,
|
||||
if ((G.debug & G_DEBUG_DEPSGRAPH_EVAL) == 0) {
|
||||
return;
|
||||
}
|
||||
printf("%s on %s (%p) at time %f\n",
|
||||
function_name, object_name, object_address, time);
|
||||
printf("%s on %s %s(%p)%s at time %f\n",
|
||||
function_name,
|
||||
object_name,
|
||||
DEG::deg_color_for_pointer(object_address).c_str(),
|
||||
object_address,
|
||||
DEG::deg_color_end().c_str(),
|
||||
time);
|
||||
}
|
||||
|
@ -125,4 +125,8 @@ void deg_editors_scene_update(const DEGEditorUpdateContext *update_ctx,
|
||||
fflush(stderr); \
|
||||
} while (0)
|
||||
|
||||
bool deg_terminal_do_color(void);
|
||||
string deg_color_for_pointer(const void *pointer);
|
||||
string deg_color_end(void);
|
||||
|
||||
} // namespace DEG
|
||||
|
@ -361,6 +361,7 @@ static PyGetSetDef bpy_app_getsets[] = {
|
||||
{(char *)"debug_depsgraph_eval", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_DEPSGRAPH_EVAL},
|
||||
{(char *)"debug_depsgraph_tag", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_DEPSGRAPH_TAG},
|
||||
{(char *)"debug_depsgraph_time", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_DEPSGRAPH_TIME},
|
||||
{(char *)"debug_depsgraph_pretty", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_DEPSGRAPH_PRETTY},
|
||||
{(char *)"debug_simdata", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_SIMDATA},
|
||||
{(char *)"debug_gpumem", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_GPU_MEM},
|
||||
|
||||
|
@ -759,6 +759,8 @@ static const char arg_handle_debug_mode_generic_set_doc_depsgraph_eval[] =
|
||||
"\n\tEnable debug messages from dependency graph related on evaluation.";
|
||||
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_no_threads[] =
|
||||
"\n\tSwitch dependency graph to a single threaded evaluation.";
|
||||
static const char arg_handle_debug_mode_generic_set_doc_depsgraph_pretty[] =
|
||||
"\n\tEnable colors for dependency graph debug messages.";
|
||||
static const char arg_handle_debug_mode_generic_set_doc_gpumem[] =
|
||||
"\n\tEnable GPU memory stats in status bar.";
|
||||
|
||||
@ -1854,6 +1856,8 @@ void main_args_setup(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
|
||||
CB_EX(arg_handle_debug_mode_generic_set, depsgraph_time), (void *)G_DEBUG_DEPSGRAPH_TIME);
|
||||
BLI_argsAdd(ba, 1, NULL, "--debug-depsgraph-no-threads",
|
||||
CB_EX(arg_handle_debug_mode_generic_set, depsgraph_no_threads), (void *)G_DEBUG_DEPSGRAPH_NO_THREADS);
|
||||
BLI_argsAdd(ba, 1, NULL, "--debug-depsgraph-pretty",
|
||||
CB_EX(arg_handle_debug_mode_generic_set, depsgraph_pretty), (void *)G_DEBUG_DEPSGRAPH_PRETTY);
|
||||
BLI_argsAdd(ba, 1, NULL, "--debug-gpumem",
|
||||
CB_EX(arg_handle_debug_mode_generic_set, gpumem), (void *)G_DEBUG_GPU_MEM);
|
||||
BLI_argsAdd(ba, 1, NULL, "--debug-gpu-shaders",
|
||||
|
Loading…
Reference in New Issue
Block a user