diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/gpu/CMakeLists.txt | 4 | ||||
-rw-r--r-- | source/blender/gpu/GPU_debug.h | 78 | ||||
-rw-r--r-- | source/blender/gpu/GPU_draw.h | 4 | ||||
-rw-r--r-- | source/blender/gpu/GPU_extensions.h | 1 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.c | 3 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_debug.c | 748 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 392 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 84 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_init_exit.c | 5 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_private.h (renamed from source/blender/gpu/intern/gpu_extensions_private.h) | 23 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 9 |
11 files changed, 892 insertions, 459 deletions
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 12b7f864469..b5d9028a8ae 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -55,6 +55,7 @@ set(SRC intern/gpu_simple_shader.c intern/gpu_select.c intern/gpu_compositing.c + intern/gpu_debug.c shaders/gpu_shader_fx_lib.glsl shaders/gpu_shader_fx_ssao_frag.glsl @@ -73,6 +74,7 @@ set(SRC GPU_buffers.h GPU_draw.h + GPU_debug.h GPU_extensions.h GPU_glew.h GPU_init_exit.h @@ -81,7 +83,7 @@ set(SRC GPU_select.h GPU_compositing.h intern/gpu_codegen.h - intern/gpu_extensions_private.h + intern/gpu_private.h ) data_to_c_simple(shaders/gpu_shader_material.glsl SRC) diff --git a/source/blender/gpu/GPU_debug.h b/source/blender/gpu/GPU_debug.h new file mode 100644 index 00000000000..02c5df013af --- /dev/null +++ b/source/blender/gpu/GPU_debug.h @@ -0,0 +1,78 @@ +/* + * ***** 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) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Jason Wilkins. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file source/blender/gpu/GPU_debug.h + * \ingroup gpu + */ + +#ifndef __GPU_DEBUG_H__ +#define __GPU_DEBUG_H__ + +#include "GPU_glew.h" + +#include "BLI_utildefines.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* prints something if debug mode is active only */ +void GPU_print_error_debug(const char *str); + +/* replacement for gluErrorString */ +const char *gpuErrorString(GLenum err); + +/* prints current OpenGL state */ +void GPU_state_print(void); + +void gpu_assert_no_gl_errors(const char *file, int line, const char *str); + +# define GPU_ASSERT_NO_GL_ERRORS(str) gpu_assert_no_gl_errors(__FILE__, __LINE__, (str)) + +# define GPU_CHECK_ERRORS_AROUND(glProcCall) \ + ( \ + GPU_ASSERT_NO_GL_ERRORS("Pre: " #glProcCall), \ + (glProcCall), \ + GPU_ASSERT_NO_GL_ERRORS("Post: " #glProcCall) \ + ) + + +#ifdef WITH_GPU_DEBUG +/* inserts a debug marker message for the debug context messaging system */ +void gpu_string_marker (size_t size, const char *str); + +# define GPU_STRING_MARKER(size, str) gpu_string_marker((size), (str)) +#else /* WITH_GPU_DEBUG */ +# define GPU_STRING_MARKER(len, str) ((void)(size),(void)(str)) +#endif /* WITH_GPU_DEBUG */ + +#ifdef __cplusplus +} +#endif + + +#endif /* __GPU_DEBUG_H__ */
\ No newline at end of file diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 3ddec157c49..4329127407f 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -57,10 +57,6 @@ struct SmokeModifierData; void GPU_state_init(void); -/* Debugging */ - -void GPU_state_print(void); - /* Material drawing * - first the state is initialized by a particular object and * it's materials diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index 739d45663f8..186db85d31a 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -55,7 +55,6 @@ typedef struct GPUShader GPUShader; /* GPU extensions support */ void GPU_extensions_disable(void); -int GPU_print_error(const char *str); int GPU_glsl_support(void); int GPU_non_power_of_two_support(void); diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 9e4d0d5f823..47d2ac2d2e5 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -31,8 +31,6 @@ * Convert material node-trees to GLSL. */ -#include "GPU_glew.h" - #include "MEM_guardedalloc.h" #include "DNA_customdata_types.h" @@ -44,6 +42,7 @@ #include "BLI_dynstr.h" #include "BLI_ghash.h" +#include "GPU_glew.h" #include "GPU_material.h" #include "GPU_extensions.h" diff --git a/source/blender/gpu/intern/gpu_debug.c b/source/blender/gpu/intern/gpu_debug.c new file mode 100644 index 00000000000..fb772748989 --- /dev/null +++ b/source/blender/gpu/intern/gpu_debug.c @@ -0,0 +1,748 @@ +/* + * ***** 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) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Brecht Van Lommel, Jason Wilkins. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file source/blender/gpu/GPU_debug.h + * \ingroup gpu + */ + +#include "BLI_sys_types.h" + +#include "BKE_global.h" + +#include "GPU_glew.h" +#include "GPU_debug.h" +#include "intern/gpu_private.h" + +#include <stdio.h> +#include <string.h> + +#define CASE_CODE_RETURN_STR(code) case code: return #code; + +static const char* gpu_gl_error_symbol(GLenum err) +{ + switch(err) { + CASE_CODE_RETURN_STR(GL_NO_ERROR) + CASE_CODE_RETURN_STR(GL_INVALID_ENUM) + CASE_CODE_RETURN_STR(GL_INVALID_VALUE) + CASE_CODE_RETURN_STR(GL_INVALID_OPERATION) + CASE_CODE_RETURN_STR(GL_STACK_OVERFLOW) + CASE_CODE_RETURN_STR(GL_STACK_UNDERFLOW) + CASE_CODE_RETURN_STR(GL_OUT_OF_MEMORY) + +#if GL_ARB_imaging + CASE_CODE_RETURN_STR(GL_TABLE_TOO_LARGE) +#endif + +#if defined(WITH_GLU) + CASE_CODE_RETURN_STR(GLU_INVALID_ENUM) + CASE_CODE_RETURN_STR(GLU_INVALID_VALUE) + CASE_CODE_RETURN_STR(GLU_OUT_OF_MEMORY) +#endif + + default: + return "<unknown error>"; + } +} + +#undef CASE_CODE_RETURN_STR + + +static bool gpu_report_gl_errors(const char *file, int line, const char *str) +{ + GLenum gl_error = glGetError(); + + if (gl_error == GL_NO_ERROR) { + return true; + } + else { + /* glGetError should have cleared the error flag, so if we get the + same flag twice that means glGetError itself probably triggered + the error. This happens on Windows if the GL context is invalid. + */ + { + GLenum new_error = glGetError(); + if (gl_error == new_error) { + fprintf(stderr, "GL: Possible context invalidation issue\n"); + return false; + } + } + + fprintf( + stderr, + "%s(%d): ``%s'' -> GL Error (0x%04X - %s): %s\n", + file, + line, + str, + gl_error, + gpu_gl_error_symbol(gl_error), + gpuErrorString(gl_error)); + + return false; + } +} + + +const char* gpuErrorString(GLenum err) +{ + switch(err) { + case GL_NO_ERROR: + return "No Error"; + + case GL_INVALID_ENUM: + return "Invalid Enumeration"; + + case GL_INVALID_VALUE: + return "Invalid Value"; + + case GL_INVALID_OPERATION: + return "Invalid Operation"; + + case GL_STACK_OVERFLOW: + return "Stack Overflow"; + + case GL_STACK_UNDERFLOW: + return "Stack Underflow"; + + case GL_OUT_OF_MEMORY: + return "Out of Memory"; + +#if GL_ARB_imaging + case GL_TABLE_TOO_LARGE: + return "Table Too Large"; +#endif + +#if defined(WITH_GLU) + case GLU_INVALID_ENUM: + return "Invalid Enum (GLU)"; + + case GLU_INVALID_VALUE: + return "Invalid Value (GLU)"; + + case GLU_OUT_OF_MEMORY: + return "Out of Memory (GLU)"; +#endif + + default: + return "<unknown error>"; + } +} + + +#ifdef WITH_GPU_DEBUG + +/* Debug callbacks need the same calling convention as OpenGL functions. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define APIENTRY __stdcall +#else +# define APIENTRY +#endif + + +static void APIENTRY gpu_debug_proc(GLenum UNUSED(source), GLenum UNUSED(type), GLuint UNUSED(id), + GLenum UNUSED(severity), GLsizei UNUSED(length), + const GLchar *message, GLvoid *UNUSED(userParm)) +{ + fprintf(stderr, "GL: %s\n", message); +} + + +#ifndef GLEW_ES_ONLY +static void APIENTRY gpu_debug_proc_amd(GLuint UNUSED(id), GLenum UNUSED(category), + GLenum UNUSED(severity), GLsizei UNUSED(length), + const GLchar *message, GLvoid *UNUSED(userParm)) +{ + fprintf(stderr, "GL: %s\n", message); +} +#endif + + +#undef APIENTRY + +void gpu_debug_init(void) +{ + const char success[] = "Successfully hooked OpenGL debug callback."; + +#if !defined(WITH_GLEW_ES) && !defined(GLEW_ES_ONLY) + if (GLEW_VERSION_4_3) { + glDebugMessageCallback(gpu_debug_proc, mxGetCurrentContext()); + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE); + GPU_STRING_MARKER(sizeof(success), success); + return; + } +#endif + + if (GLEW_KHR_debug) { +#ifndef GLEW_NO_ES + if (MX_profile_es20) + { + glDebugMessageCallbackKHR(gpu_debug_proc, mxGetCurrentContext()); + glDebugMessageControlKHR(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE); + GPU_STRING_MARKER(sizeof(success), success); + } + else +#endif + { +#ifndef GLEW_ES_ONLY + glDebugMessageCallback(gpu_debug_proc, mxGetCurrentContext()); + glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE); + GPU_STRING_MARKER(sizeof(success), success); +#endif + } + + return; + } + +#ifndef GLEW_ES_ONLY + if (GLEW_ARB_debug_output) { + glDebugMessageCallbackARB(gpu_debug_proc, mxGetCurrentContext()); + glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE); + GPU_STRING_MARKER(sizeof(success), success); + + return; + } + + if (GLEW_AMD_debug_output) { + glDebugMessageCallbackAMD(gpu_debug_proc_amd, mxGetCurrentContext()); + glDebugMessageEnableAMD(GL_DONT_CARE, GL_DONT_CARE, 0, NULL, GL_TRUE); + GPU_STRING_MARKER(sizeof(success), success); + + return; + } +#endif + + fprintf(stderr, "Failed to hook OpenGL debug callback.\n"); + + return; +} + + +void gpu_debug_exit(void) +{ +#ifndef WITH_GLEW_ES +#ifndef GLEW_ES_ONLY + if (GLEW_VERSION_4_3) { + glDebugMessageCallback(NULL, NULL); + + return; + } +#endif +#endif + + if (GLEW_KHR_debug) { +#ifndef GLEW_NO_ES + if (MX_profile_es20) + { + glDebugMessageCallbackKHR(NULL, NULL); + } + else +#endif + { +#ifndef GLEW_ES_ONLY + glDebugMessageCallback(NULL, NULL); +#endif + } + + return; + } + +#ifndef GLEW_ES_ONLY + if (GLEW_ARB_debug_output) { + glDebugMessageCallbackARB(NULL, NULL); + + return; + } + + if (GLEW_AMD_debug_output) { + glDebugMessageCallbackAMD(NULL, NULL); + + return; + } +#endif + + return; +} + +void gpu_string_marker(size_t length, const char *buf) +{ +#ifndef WITH_GLEW_ES +#ifndef GLEW_ES_ONLY + if (GLEW_VERSION_4_3) { + glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0, GL_DEBUG_SEVERITY_NOTIFICATION, length, buf); + + return; + } +#endif +#endif + + if (GLEW_KHR_debug) { +#ifndef GLEW_NO_ES + if (MX_profile_es20) + { + glDebugMessageInsertKHR(GL_DEBUG_SOURCE_APPLICATION_KHR, GL_DEBUG_TYPE_MARKER_KHR, 0, GL_DEBUG_SEVERITY_NOTIFICATION_KHR, length, buf); + } + else +#endif + { +#ifndef GLEW_ES_ONLY + glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0, GL_DEBUG_SEVERITY_NOTIFICATION, length, buf); +#endif + } + + return; + } + +#ifndef GLEW_ES_ONLY + if (GLEW_ARB_debug_output) { + glDebugMessageInsertARB(GL_DEBUG_SOURCE_APPLICATION_ARB, GL_DEBUG_TYPE_OTHER_ARB, 0, GL_DEBUG_SEVERITY_LOW_ARB, length, buf); + + return; + } + + if (GLEW_AMD_debug_output) { + glDebugMessageInsertAMD(GL_DEBUG_CATEGORY_APPLICATION_AMD, GL_DEBUG_SEVERITY_LOW_AMD, 0, length, buf); + + return; + } + + if (GLEW_GREMEDY_string_marker) { + glStringMarkerGREMEDY(length, buf); + + return; + } +#endif + + return; +} + +#endif /* WITH_GPU_DEBUG */ + +void GPU_print_error_debug(const char *str) +{ + if (G.debug & G_DEBUG) + fprintf(stderr, "GPU: %s\n", str); +} + + +void gpu_assert_no_gl_errors(const char* file, int line, const char* str) +{ + if (G.debug) { + GLboolean gl_ok = gpu_report_gl_errors(file, line, str); + + BLI_assert(gl_ok); + } +} + + +static void gpu_state_print_fl_ex(const char *name, GLenum type) +{ + const unsigned char err_mark[4] = {0xff, 0xff, 0xff, 0xff}; + + float value[32]; + int a; + + memset(value, 0xff, sizeof(value)); + glGetFloatv(type, value); + + if (glGetError() == GL_NO_ERROR) { + printf("%s: ", name); + for (a = 0; a < 32; a++) { + if (memcmp(&value[a], err_mark, sizeof(value[a])) == 0) { + break; + } + printf("%.2f ", value[a]); + } + printf("\n"); + } +} + +#define gpu_state_print_fl(val) gpu_state_print_fl_ex(#val, val) + +void GPU_state_print(void) +{ + GPU_ASSERT_NO_GL_ERRORS("GPU_state_print"); /* clear any errors */ + + gpu_state_print_fl(GL_ACCUM_ALPHA_BITS); + gpu_state_print_fl(GL_ACCUM_BLUE_BITS); + gpu_state_print_fl(GL_ACCUM_CLEAR_VALUE); + gpu_state_print_fl(GL_ACCUM_GREEN_BITS); + gpu_state_print_fl(GL_ACCUM_RED_BITS); + gpu_state_print_fl(GL_ACTIVE_TEXTURE); + gpu_state_print_fl(GL_ALIASED_LINE_WIDTH_RANGE); + gpu_state_print_fl(GL_ALIASED_POINT_SIZE_RANGE); + gpu_state_print_fl(GL_ALPHA_BIAS); + gpu_state_print_fl(GL_ALPHA_BITS); + gpu_state_print_fl(GL_ALPHA_SCALE); + gpu_state_print_fl(GL_ALPHA_TEST); + gpu_state_print_fl(GL_ALPHA_TEST_FUNC); + gpu_state_print_fl(GL_ALPHA_TEST_REF); + gpu_state_print_fl(GL_ARRAY_BUFFER_BINDING); + gpu_state_print_fl(GL_ATTRIB_STACK_DEPTH); + gpu_state_print_fl(GL_AUTO_NORMAL); + gpu_state_print_fl(GL_AUX_BUFFERS); + gpu_state_print_fl(GL_BLEND); + gpu_state_print_fl(GL_BLEND_COLOR); + gpu_state_print_fl(GL_BLEND_DST_ALPHA); + gpu_state_print_fl(GL_BLEND_DST_RGB); + gpu_state_print_fl(GL_BLEND_EQUATION_ALPHA); + gpu_state_print_fl(GL_BLEND_EQUATION_RGB); + gpu_state_print_fl(GL_BLEND_SRC_ALPHA); + gpu_state_print_fl(GL_BLEND_SRC_RGB); + gpu_state_print_fl(GL_BLUE_BIAS); + gpu_state_print_fl(GL_BLUE_BITS); + gpu_state_print_fl(GL_BLUE_SCALE); + gpu_state_print_fl(GL_CLIENT_ACTIVE_TEXTURE); + gpu_state_print_fl(GL_CLIENT_ATTRIB_STACK_DEPTH); + gpu_state_print_fl(GL_CLIP_PLANE0); + gpu_state_print_fl(GL_COLOR_ARRAY); + gpu_state_print_fl(GL_COLOR_ARRAY_BUFFER_BINDING); + gpu_state_print_fl(GL_COLOR_ARRAY_SIZE); + gpu_state_print_fl(GL_COLOR_ARRAY_STRIDE); + gpu_state_print_fl(GL_COLOR_ARRAY_TYPE); + gpu_state_print_fl(GL_COLOR_CLEAR_VALUE); + gpu_state_print_fl(GL_COLOR_LOGIC_OP); + gpu_state_print_fl(GL_COLOR_MATERIAL); + gpu_state_print_fl(GL_COLOR_MATERIAL_FACE); + gpu_state_print_fl(GL_COLOR_MATERIAL_PARAMETER); + gpu_state_print_fl(GL_COLOR_MATRIX); + gpu_state_print_fl(GL_COLOR_MATRIX_STACK_DEPTH); + gpu_state_print_fl(GL_COLOR_SUM); + gpu_state_print_fl(GL_COLOR_TABLE); + gpu_state_print_fl(GL_COLOR_WRITEMASK); + gpu_state_print_fl(GL_COMPRESSED_TEXTURE_FORMATS); + gpu_state_print_fl(GL_CONVOLUTION_1D); + gpu_state_print_fl(GL_CONVOLUTION_2D); + gpu_state_print_fl(GL_CULL_FACE); + gpu_state_print_fl(GL_CULL_FACE_MODE); + gpu_state_print_fl(GL_CURRENT_COLOR); + gpu_state_print_fl(GL_CURRENT_FOG_COORD); + gpu_state_print_fl(GL_CURRENT_INDEX); + gpu_state_print_fl(GL_CURRENT_NORMAL); + gpu_state_print_fl(GL_CURRENT_PROGRAM); + gpu_state_print_fl(GL_CURRENT_RASTER_COLOR); + gpu_state_print_fl(GL_CURRENT_RASTER_DISTANCE); + gpu_state_print_fl(GL_CURRENT_RASTER_INDEX); + gpu_state_print_fl(GL_CURRENT_RASTER_POSITION); + gpu_state_print_fl(GL_CURRENT_RASTER_POSITION_VALID); + gpu_state_print_fl(GL_CURRENT_RASTER_SECONDARY_COLOR); + gpu_state_print_fl(GL_CURRENT_RASTER_TEXTURE_COORDS); + gpu_state_print_fl(GL_CURRENT_SECONDARY_COLOR); + gpu_state_print_fl(GL_CURRENT_TEXTURE_COORDS); + gpu_state_print_fl(GL_DEPTH_BIAS); + gpu_state_print_fl(GL_DEPTH_BITS); + gpu_state_print_fl(GL_DEPTH_CLEAR_VALUE); + gpu_state_print_fl(GL_DEPTH_FUNC); + gpu_state_print_fl(GL_DEPTH_RANGE); + gpu_state_print_fl(GL_DEPTH_SCALE); + gpu_state_print_fl(GL_DEPTH_TEST); + gpu_state_print_fl(GL_DEPTH_WRITEMASK); + gpu_state_print_fl(GL_DITHER); + gpu_state_print_fl(GL_DOUBLEBUFFER); + gpu_state_print_fl(GL_DRAW_BUFFER); + gpu_state_print_fl(GL_DRAW_BUFFER0); + gpu_state_print_fl(GL_EDGE_FLAG); + gpu_state_print_fl(GL_EDGE_FLAG_ARRAY); + gpu_state_print_fl(GL_EDGE_FLAG_ARRAY_BUFFER_BINDING); + gpu_state_print_fl(GL_EDGE_FLAG_ARRAY_STRIDE); + gpu_state_print_fl(GL_ELEMENT_ARRAY_BUFFER_BINDING); + gpu_state_print_fl(GL_FEEDBACK_BUFFER_SIZE); + gpu_state_print_fl(GL_FEEDBACK_BUFFER_TYPE); + gpu_state_print_fl(GL_FOG); + gpu_state_print_fl(GL_FOG_COLOR); + gpu_state_print_fl(GL_FOG_COORD_ARRAY); + gpu_state_print_fl(GL_FOG_COORD_ARRAY_BUFFER_BINDING); + gpu_state_print_fl(GL_FOG_COORD_ARRAY_STRIDE); + gpu_state_print_fl(GL_FOG_COORD_ARRAY_TYPE); + gpu_state_print_fl(GL_FOG_COORD_SRC); + gpu_state_print_fl(GL_FOG_DENSITY); + gpu_state_print_fl(GL_FOG_END); + gpu_state_print_fl(GL_FOG_HINT); + gpu_state_print_fl(GL_FOG_INDEX); + gpu_state_print_fl(GL_FOG_MODE); + gpu_state_print_fl(GL_FOG_START); + gpu_state_print_fl(GL_FRAGMENT_PROGRAM_ARB); + gpu_state_print_fl(GL_FRAGMENT_SHADER_DERIVATIVE_HINT); + gpu_state_print_fl(GL_FRONT_FACE); + gpu_state_print_fl(GL_GENERATE_MIPMAP_HINT); + gpu_state_print_fl(GL_GREEN_BIAS); + gpu_state_print_fl(GL_GREEN_BITS); + gpu_state_print_fl(GL_GREEN_SCALE); + gpu_state_print_fl(GL_HISTOGRAM); + gpu_state_print_fl(GL_INDEX_ARRAY); + gpu_state_print_fl(GL_INDEX_ARRAY_BUFFER_BINDING); + gpu_state_print_fl(GL_INDEX_ARRAY_STRIDE); + gpu_state_print_fl(GL_INDEX_ARRAY_TYPE); + gpu_state_print_fl(GL_INDEX_BITS); + gpu_state_print_fl(GL_INDEX_CLEAR_VALUE); + gpu_state_print_fl(GL_INDEX_LOGIC_OP); + gpu_state_print_fl(GL_INDEX_MODE); + gpu_state_print_fl(GL_INDEX_OFFSET); + gpu_state_print_fl(GL_INDEX_SHIFT); + gpu_state_print_fl(GL_INDEX_WRITEMASK); + gpu_state_print_fl(GL_LIGHT0); + gpu_state_print_fl(GL_LIGHT1); + gpu_state_print_fl(GL_LIGHT2); + gpu_state_print_fl(GL_LIGHT3); + gpu_state_print_fl(GL_LIGHT4); + gpu_state_print_fl(GL_LIGHT5); + gpu_state_print_fl(GL_LIGHT6); + gpu_state_print_fl(GL_LIGHT7); + gpu_state_print_fl(GL_LIGHTING); + gpu_state_print_fl(GL_LIGHT_MODEL_AMBIENT); + gpu_state_print_fl(GL_LIGHT_MODEL_COLOR_CONTROL); + gpu_state_print_fl(GL_LIGHT_MODEL_LOCAL_VIEWER); + gpu_state_print_fl(GL_LIGHT_MODEL_TWO_SIDE); + gpu_state_print_fl(GL_LINE_SMOOTH); + gpu_state_print_fl(GL_LINE_SMOOTH_HINT); + gpu_state_print_fl(GL_LINE_STIPPLE); + gpu_state_print_fl(GL_LINE_STIPPLE_PATTERN); + gpu_state_print_fl(GL_LINE_STIPPLE_REPEAT); + gpu_state_print_fl(GL_LINE_WIDTH); + gpu_state_print_fl(GL_LINE_WIDTH_GRANULARITY); + gpu_state_print_fl(GL_LINE_WIDTH_RANGE); + gpu_state_print_fl(GL_LIST_BASE); + gpu_state_print_fl(GL_LIST_INDEX); + gpu_state_print_fl(GL_LIST_MODE); + gpu_state_print_fl(GL_LOGIC_OP); + gpu_state_print_fl(GL_LOGIC_OP_MODE); + gpu_state_print_fl(GL_MAP1_COLOR_4); + gpu_state_print_fl(GL_MAP1_GRID_DOMAIN); + gpu_state_print_fl(GL_MAP1_GRID_SEGMENTS); + gpu_state_print_fl(GL_MAP1_INDEX); + gpu_state_print_fl(GL_MAP1_NORMAL); + gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_1); + gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_2); + gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_3); + gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_4); + gpu_state_print_fl(GL_MAP1_VERTEX_3); + gpu_state_print_fl(GL_MAP1_VERTEX_4); + gpu_state_print_fl(GL_MAP2_COLOR_4); + gpu_state_print_fl(GL_MAP2_GRID_DOMAIN); + gpu_state_print_fl(GL_MAP2_GRID_SEGMENTS); + gpu_state_print_fl(GL_MAP2_INDEX); + gpu_state_print_fl(GL_MAP2_NORMAL); + gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_1); + gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_2); + gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_3); + gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_4); + gpu_state_print_fl(GL_MAP2_VERTEX_3); + gpu_state_print_fl(GL_MAP2_VERTEX_4); + gpu_state_print_fl(GL_MAP_COLOR); + gpu_state_print_fl(GL_MAP_STENCIL); + gpu_state_print_fl(GL_MATRIX_MODE); + gpu_state_print_fl(GL_MAX_3D_TEXTURE_SIZE); + gpu_state_print_fl(GL_MAX_ATTRIB_STACK_DEPTH); + gpu_state_print_fl(GL_MAX_CLIENT_ATTRIB_STACK_DEPTH); + gpu_state_print_fl(GL_MAX_CLIP_PLANES); + gpu_state_print_fl(GL_MAX_COLOR_MATRIX_STACK_DEPTH); + gpu_state_print_fl(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS); + gpu_state_print_fl(GL_MAX_CUBE_MAP_TEXTURE_SIZE); + gpu_state_print_fl(GL_MAX_DRAW_BUFFERS); + gpu_state_print_fl(GL_MAX_ELEMENTS_INDICES); + gpu_state_print_fl(GL_MAX_ELEMENTS_VERTICES); + gpu_state_print_fl(GL_MAX_EVAL_ORDER); + gpu_state_print_fl(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS); + gpu_state_print_fl(GL_MAX_LIGHTS); + gpu_state_print_fl(GL_MAX_LIST_NESTING); + gpu_state_print_fl(GL_MAX_MODELVIEW_STACK_DEPTH); + gpu_state_print_fl(GL_MAX_NAME_STACK_DEPTH); + gpu_state_print_fl(GL_MAX_PIXEL_MAP_TABLE); + gpu_state_print_fl(GL_MAX_PROJECTION_STACK_DEPTH); + gpu_state_print_fl(GL_MAX_TEXTURE_COORDS); + gpu_state_print_fl(GL_MAX_TEXTURE_IMAGE_UNITS); + gpu_state_print_fl(GL_MAX_TEXTURE_LOD_BIAS); + gpu_state_print_fl(GL_MAX_TEXTURE_SIZE); + gpu_state_print_fl(GL_MAX_TEXTURE_STACK_DEPTH); + gpu_state_print_fl(GL_MAX_TEXTURE_UNITS); + gpu_state_print_fl(GL_MAX_VARYING_FLOATS); + gpu_state_print_fl(GL_MAX_VERTEX_ATTRIBS); + gpu_state_print_fl(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS); + gpu_state_print_fl(GL_MAX_VERTEX_UNIFORM_COMPONENTS); + gpu_state_print_fl(GL_MAX_VIEWPORT_DIMS); + gpu_state_print_fl(GL_MINMAX); + gpu_state_print_fl(GL_MODELVIEW_MATRIX); + gpu_state_print_fl(GL_MODELVIEW_STACK_DEPTH); + gpu_state_print_fl(GL_MULTISAMPLE); + gpu_state_print_fl(GL_MULTISAMPLE_ARB); + gpu_state_print_fl(GL_NAME_STACK_DEPTH); + gpu_state_print_fl(GL_NORMALIZE); + gpu_state_print_fl(GL_NORMAL_ARRAY); + gpu_state_print_fl(GL_NORMAL_ARRAY_BUFFER_BINDING); + gpu_state_print_fl(GL_NORMAL_ARRAY_STRIDE); + gpu_state_print_fl(GL_NORMAL_ARRAY_TYPE); + gpu_state_print_fl(GL_NUM_COMPRESSED_TEXTURE_FORMATS); + gpu_state_print_fl(GL_PACK_ALIGNMENT); + gpu_state_print_fl(GL_PACK_IMAGE_HEIGHT); + gpu_state_print_fl(GL_PACK_LSB_FIRST); + gpu_state_print_fl(GL_PACK_ROW_LENGTH); + gpu_state_print_fl(GL_PACK_SKIP_IMAGES); + gpu_state_print_fl(GL_PACK_SKIP_PIXELS); + gpu_state_print_fl(GL_PACK_SKIP_ROWS); + gpu_state_print_fl(GL_PACK_SWAP_BYTES); + gpu_state_print_fl(GL_PERSPECTIVE_CORRECTION_HINT); + gpu_state_print_fl(GL_PIXEL_MAP_A_TO_A_SIZE); + gpu_state_print_fl(GL_PIXEL_MAP_B_TO_B_SIZE); + gpu_state_print_fl(GL_PIXEL_MAP_G_TO_G_SIZE); + gpu_state_print_fl(GL_PIXEL_MAP_I_TO_A_SIZE); + gpu_state_print_fl(GL_PIXEL_MAP_I_TO_B_SIZE); + gpu_state_print_fl(GL_PIXEL_MAP_I_TO_G_SIZE); + gpu_state_print_fl(GL_PIXEL_MAP_I_TO_I_SIZE); + gpu_state_print_fl(GL_PIXEL_MAP_I_TO_R_SIZE); + gpu_state_print_fl(GL_PIXEL_MAP_R_TO_R_SIZE); + gpu_state_print_fl(GL_PIXEL_MAP_S_TO_S_SIZE); + gpu_state_print_fl(GL_PIXEL_PACK_BUFFER_BINDING); + gpu_state_print_fl(GL_PIXEL_UNPACK_BUFFER_BINDING); + gpu_state_print_fl(GL_POINT_DISTANCE_ATTENUATION); + gpu_state_print_fl(GL_POINT_FADE_THRESHOLD_SIZE); + gpu_state_print_fl(GL_POINT_SIZE); + gpu_state_print_fl(GL_POINT_SIZE_GRANULARITY); + gpu_state_print_fl(GL_POINT_SIZE_MAX); + gpu_state_print_fl(GL_POINT_SIZE_MIN); + gpu_state_print_fl(GL_POINT_SIZE_RANGE); + gpu_state_print_fl(GL_POINT_SMOOTH); + gpu_state_print_fl(GL_POINT_SMOOTH_HINT); + gpu_state_print_fl(GL_POINT_SPRITE); + gpu_state_print_fl(GL_POLYGON_MODE); + gpu_state_print_fl(GL_POLYGON_OFFSET_FACTOR); + gpu_state_print_fl(GL_POLYGON_OFFSET_FILL); + gpu_state_print_fl(GL_POLYGON_OFFSET_LINE); + gpu_state_print_fl(GL_POLYGON_OFFSET_POINT); + gpu_state_print_fl(GL_POLYGON_OFFSET_UNITS); + gpu_state_print_fl(GL_POLYGON_SMOOTH); + gpu_state_print_fl(GL_POLYGON_SMOOTH_HINT); + gpu_state_print_fl(GL_POLYGON_STIPPLE); + gpu_state_print_fl(GL_POST_COLOR_MATRIX_ALPHA_BIAS); + gpu_state_print_fl(GL_POST_COLOR_MATRIX_ALPHA_SCALE); + gpu_state_print_fl(GL_POST_COLOR_MATRIX_BLUE_BIAS); + gpu_state_print_fl(GL_POST_COLOR_MATRIX_BLUE_SCALE); + gpu_state_print_fl(GL_POST_COLOR_MATRIX_COLOR_TABLE); + gpu_state_print_fl(GL_POST_COLOR_MATRIX_GREEN_BIAS); + gpu_state_print_fl(GL_POST_COLOR_MATRIX_GREEN_SCALE); + gpu_state_print_fl(GL_POST_COLOR_MATRIX_RED_BIAS); + gpu_state_print_fl(GL_POST_COLOR_MATRIX_RED_SCALE); + gpu_state_print_fl(GL_POST_CONVOLUTION_ALPHA_BIAS); + gpu_state_print_fl(GL_POST_CONVOLUTION_ALPHA_SCALE); + gpu_state_print_fl(GL_POST_CONVOLUTION_BLUE_BIAS); + gpu_state_print_fl(GL_POST_CONVOLUTION_BLUE_SCALE); + gpu_state_print_fl(GL_POST_CONVOLUTION_COLOR_TABLE); + gpu_state_print_fl(GL_POST_CONVOLUTION_GREEN_BIAS); + gpu_state_print_fl(GL_POST_CONVOLUTION_GREEN_SCALE); + gpu_state_print_fl(GL_POST_CONVOLUTION_RED_BIAS); + gpu_state_print_fl(GL_POST_CONVOLUTION_RED_SCALE); + gpu_state_print_fl(GL_PROJECTION_MATRIX); + gpu_state_print_fl(GL_PROJECTION_STACK_DEPTH); + gpu_state_print_fl(GL_READ_BUFFER); + gpu_state_print_fl(GL_RED_BIAS); + gpu_state_print_fl(GL_RED_BITS); + gpu_state_print_fl(GL_RED_SCALE); + gpu_state_print_fl(GL_RENDER_MODE); + gpu_state_print_fl(GL_RESCALE_NORMAL); + gpu_state_print_fl(GL_RGBA_MODE); + gpu_state_print_fl(GL_SAMPLES); + gpu_state_print_fl(GL_SAMPLE_BUFFERS); + gpu_state_print_fl(GL_SAMPLE_COVERAGE_INVERT); + gpu_state_print_fl(GL_SAMPLE_COVERAGE_VALUE); + gpu_state_print_fl(GL_SCISSOR_BOX); + gpu_state_print_fl(GL_SCISSOR_TEST); + gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY); + gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING); + gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_SIZE); + gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_STRIDE); + gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_TYPE); + gpu_state_print_fl(GL_SELECTION_BUFFER_SIZE); + gpu_state_print_fl(GL_SEPARABLE_2D); + gpu_state_print_fl(GL_SHADE_MODEL); + gpu_state_print_fl(GL_SMOOTH_LINE_WIDTH_GRANULARITY); + gpu_state_print_fl(GL_SMOOTH_LINE_WIDTH_RANGE); + gpu_state_print_fl(GL_SMOOTH_POINT_SIZE_GRANULARITY); + gpu_state_print_fl(GL_SMOOTH_POINT_SIZE_RANGE); + gpu_state_print_fl(GL_STENCIL_BACK_FAIL); + gpu_state_print_fl(GL_STENCIL_BACK_FUNC); + gpu_state_print_fl(GL_STENCIL_BACK_PASS_DEPTH_FAIL); + gpu_state_print_fl(GL_STENCIL_BACK_PASS_DEPTH_PASS); + gpu_state_print_fl(GL_STENCIL_BACK_REF); + gpu_state_print_fl(GL_STENCIL_BACK_VALUE_MASK); + gpu_state_print_fl(GL_STENCIL_BACK_WRITEMASK); + gpu_state_print_fl(GL_STENCIL_BITS); + gpu_state_print_fl(GL_STENCIL_CLEAR_VALUE); + gpu_state_print_fl(GL_STENCIL_FAIL); + gpu_state_print_fl(GL_STENCIL_FUNC); + gpu_state_print_fl(GL_STENCIL_PASS_DEPTH_FAIL); + gpu_state_print_fl(GL_STENCIL_PASS_DEPTH_PASS); + gpu_state_print_fl(GL_STENCIL_REF); + gpu_state_print_fl(GL_STENCIL_TEST); + gpu_state_print_fl(GL_STENCIL_VALUE_MASK); + gpu_state_print_fl(GL_STENCIL_WRITEMASK); + gpu_state_print_fl(GL_STEREO); + gpu_state_print_fl(GL_SUBPIXEL_BITS); + gpu_state_print_fl(GL_TEXTURE_1D); + gpu_state_print_fl(GL_TEXTURE_2D); + gpu_state_print_fl(GL_TEXTURE_3D); + gpu_state_print_fl(GL_TEXTURE_BINDING_1D); + gpu_state_print_fl(GL_TEXTURE_BINDING_2D); + gpu_state_print_fl(GL_TEXTURE_BINDING_3D); + gpu_state_print_fl(GL_TEXTURE_BINDING_CUBE_MAP); + gpu_state_print_fl(GL_TEXTURE_COMPRESSION_HINT); + gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY); + gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING); + gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_SIZE); + gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_STRIDE); + gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_TYPE); + gpu_state_print_fl(GL_TEXTURE_CUBE_MAP); + gpu_state_print_fl(GL_TEXTURE_CUBE_MAP_ARB); + gpu_state_print_fl(GL_TEXTURE_GEN_Q); + gpu_state_print_fl(GL_TEXTURE_GEN_R); + gpu_state_print_fl(GL_TEXTURE_GEN_S); + gpu_state_print_fl(GL_TEXTURE_GEN_T); + gpu_state_print_fl(GL_TEXTURE_MATRIX); + gpu_state_print_fl(GL_TEXTURE_STACK_DEPTH); + gpu_state_print_fl(GL_TRANSPOSE_COLOR_MATRIX); + gpu_state_print_fl(GL_TRANSPOSE_MODELVIEW_MATRIX); + gpu_state_print_fl(GL_TRANSPOSE_PROJECTION_MATRIX); + gpu_state_print_fl(GL_TRANSPOSE_TEXTURE_MATRIX); + gpu_state_print_fl(GL_UNPACK_ALIGNMENT); + gpu_state_print_fl(GL_UNPACK_IMAGE_HEIGHT); + gpu_state_print_fl(GL_UNPACK_LSB_FIRST); + gpu_state_print_fl(GL_UNPACK_ROW_LENGTH); + gpu_state_print_fl(GL_UNPACK_SKIP_IMAGES); + gpu_state_print_fl(GL_UNPACK_SKIP_PIXELS); + gpu_state_print_fl(GL_UNPACK_SKIP_ROWS); + gpu_state_print_fl(GL_UNPACK_SWAP_BYTES); + gpu_state_print_fl(GL_VERTEX_ARRAY); + gpu_state_print_fl(GL_VERTEX_ARRAY_BUFFER_BINDING); + gpu_state_print_fl(GL_VERTEX_ARRAY_SIZE); + gpu_state_print_fl(GL_VERTEX_ARRAY_STRIDE); + gpu_state_print_fl(GL_VERTEX_ARRAY_TYPE); + gpu_state_print_fl(GL_VERTEX_PROGRAM_POINT_SIZE); + gpu_state_print_fl(GL_VERTEX_PROGRAM_TWO_SIDE); + gpu_state_print_fl(GL_VIEWPORT); + gpu_state_print_fl(GL_ZOOM_X); + gpu_state_print_fl(GL_ZOOM_Y); +} + +#undef gpu_state_print_fl diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index 4a93fbac48e..7c047d9229b 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -39,6 +39,7 @@ #include <string.h> #include "GPU_glew.h" +#include "GPU_debug.h" #include "BLI_blenlib.h" #include "BLI_linklist.h" @@ -796,12 +797,12 @@ bool GPU_upload_dxt_texture(ImBuf *ibuf) } if (format == 0) { - printf("Unable to find a suitable DXT compression, falling back to uncompressed\n"); + fprintf(stderr, "Unable to find a suitable DXT compression, falling back to uncompressed\n"); return false; } if (!is_power_of_2_resolution(width, height)) { - printf("Unable to load non-power-of-two DXT image resolution, falling back to uncompressed\n"); + fprintf(stderr, "Unable to load non-power-of-two DXT image resolution, falling back to uncompressed\n"); return false; } @@ -2013,390 +2014,3 @@ void GPU_state_init(void) gpu_multisample(false); } -#ifdef DEBUG -/* debugging aid */ -static void gpu_state_print_fl_ex(const char *name, GLenum type) -{ - const unsigned char err_mark[4] = {0xff, 0xff, 0xff, 0xff}; - - float value[32]; - int a; - - memset(value, 0xff, sizeof(value)); - glGetFloatv(type, value); - - printf("%s: ", name); - for (a = 0; a < 32; a++) { - if (memcmp(&value[a], err_mark, sizeof(value[a])) == 0) { - break; - } - printf("%.2f ", value[a]); - } - printf("\n"); -} - -#define gpu_state_print_fl(val) gpu_state_print_fl_ex(#val, val) - -void GPU_state_print(void) -{ - gpu_state_print_fl(GL_ACCUM_ALPHA_BITS); - gpu_state_print_fl(GL_ACCUM_BLUE_BITS); - gpu_state_print_fl(GL_ACCUM_CLEAR_VALUE); - gpu_state_print_fl(GL_ACCUM_GREEN_BITS); - gpu_state_print_fl(GL_ACCUM_RED_BITS); - gpu_state_print_fl(GL_ACTIVE_TEXTURE); - gpu_state_print_fl(GL_ALIASED_LINE_WIDTH_RANGE); - gpu_state_print_fl(GL_ALIASED_POINT_SIZE_RANGE); - gpu_state_print_fl(GL_ALPHA_BIAS); - gpu_state_print_fl(GL_ALPHA_BITS); - gpu_state_print_fl(GL_ALPHA_SCALE); - gpu_state_print_fl(GL_ALPHA_TEST); - gpu_state_print_fl(GL_ALPHA_TEST_FUNC); - gpu_state_print_fl(GL_ALPHA_TEST_REF); - gpu_state_print_fl(GL_ARRAY_BUFFER_BINDING); - gpu_state_print_fl(GL_ATTRIB_STACK_DEPTH); - gpu_state_print_fl(GL_AUTO_NORMAL); - gpu_state_print_fl(GL_AUX_BUFFERS); - gpu_state_print_fl(GL_BLEND); - gpu_state_print_fl(GL_BLEND_COLOR); - gpu_state_print_fl(GL_BLEND_DST_ALPHA); - gpu_state_print_fl(GL_BLEND_DST_RGB); - gpu_state_print_fl(GL_BLEND_EQUATION_ALPHA); - gpu_state_print_fl(GL_BLEND_EQUATION_RGB); - gpu_state_print_fl(GL_BLEND_SRC_ALPHA); - gpu_state_print_fl(GL_BLEND_SRC_RGB); - gpu_state_print_fl(GL_BLUE_BIAS); - gpu_state_print_fl(GL_BLUE_BITS); - gpu_state_print_fl(GL_BLUE_SCALE); - gpu_state_print_fl(GL_CLIENT_ACTIVE_TEXTURE); - gpu_state_print_fl(GL_CLIENT_ATTRIB_STACK_DEPTH); - gpu_state_print_fl(GL_CLIP_PLANE0); - gpu_state_print_fl(GL_COLOR_ARRAY); - gpu_state_print_fl(GL_COLOR_ARRAY_BUFFER_BINDING); - gpu_state_print_fl(GL_COLOR_ARRAY_SIZE); - gpu_state_print_fl(GL_COLOR_ARRAY_STRIDE); - gpu_state_print_fl(GL_COLOR_ARRAY_TYPE); - gpu_state_print_fl(GL_COLOR_CLEAR_VALUE); - gpu_state_print_fl(GL_COLOR_LOGIC_OP); - gpu_state_print_fl(GL_COLOR_MATERIAL); - gpu_state_print_fl(GL_COLOR_MATERIAL_FACE); - gpu_state_print_fl(GL_COLOR_MATERIAL_PARAMETER); - gpu_state_print_fl(GL_COLOR_MATRIX); - gpu_state_print_fl(GL_COLOR_MATRIX_STACK_DEPTH); - gpu_state_print_fl(GL_COLOR_SUM); - gpu_state_print_fl(GL_COLOR_TABLE); - gpu_state_print_fl(GL_COLOR_WRITEMASK); - gpu_state_print_fl(GL_COMPRESSED_TEXTURE_FORMATS); - gpu_state_print_fl(GL_CONVOLUTION_1D); - gpu_state_print_fl(GL_CONVOLUTION_2D); - gpu_state_print_fl(GL_CULL_FACE); - gpu_state_print_fl(GL_CULL_FACE_MODE); - gpu_state_print_fl(GL_CURRENT_COLOR); - gpu_state_print_fl(GL_CURRENT_FOG_COORD); - gpu_state_print_fl(GL_CURRENT_INDEX); - gpu_state_print_fl(GL_CURRENT_NORMAL); - gpu_state_print_fl(GL_CURRENT_PROGRAM); - gpu_state_print_fl(GL_CURRENT_RASTER_COLOR); - gpu_state_print_fl(GL_CURRENT_RASTER_DISTANCE); - gpu_state_print_fl(GL_CURRENT_RASTER_INDEX); - gpu_state_print_fl(GL_CURRENT_RASTER_POSITION); - gpu_state_print_fl(GL_CURRENT_RASTER_POSITION_VALID); - gpu_state_print_fl(GL_CURRENT_RASTER_SECONDARY_COLOR); - gpu_state_print_fl(GL_CURRENT_RASTER_TEXTURE_COORDS); - gpu_state_print_fl(GL_CURRENT_SECONDARY_COLOR); - gpu_state_print_fl(GL_CURRENT_TEXTURE_COORDS); - gpu_state_print_fl(GL_DEPTH_BIAS); - gpu_state_print_fl(GL_DEPTH_BITS); - gpu_state_print_fl(GL_DEPTH_CLEAR_VALUE); - gpu_state_print_fl(GL_DEPTH_FUNC); - gpu_state_print_fl(GL_DEPTH_RANGE); - gpu_state_print_fl(GL_DEPTH_SCALE); - gpu_state_print_fl(GL_DEPTH_TEST); - gpu_state_print_fl(GL_DEPTH_WRITEMASK); - gpu_state_print_fl(GL_DITHER); - gpu_state_print_fl(GL_DOUBLEBUFFER); - gpu_state_print_fl(GL_DRAW_BUFFER); - gpu_state_print_fl(GL_DRAW_BUFFER0); - gpu_state_print_fl(GL_EDGE_FLAG); - gpu_state_print_fl(GL_EDGE_FLAG_ARRAY); - gpu_state_print_fl(GL_EDGE_FLAG_ARRAY_BUFFER_BINDING); - gpu_state_print_fl(GL_EDGE_FLAG_ARRAY_STRIDE); - gpu_state_print_fl(GL_ELEMENT_ARRAY_BUFFER_BINDING); - gpu_state_print_fl(GL_FEEDBACK_BUFFER_SIZE); - gpu_state_print_fl(GL_FEEDBACK_BUFFER_TYPE); - gpu_state_print_fl(GL_FOG); - gpu_state_print_fl(GL_FOG_COLOR); - gpu_state_print_fl(GL_FOG_COORD_ARRAY); - gpu_state_print_fl(GL_FOG_COORD_ARRAY_BUFFER_BINDING); - gpu_state_print_fl(GL_FOG_COORD_ARRAY_STRIDE); - gpu_state_print_fl(GL_FOG_COORD_ARRAY_TYPE); - gpu_state_print_fl(GL_FOG_COORD_SRC); - gpu_state_print_fl(GL_FOG_DENSITY); - gpu_state_print_fl(GL_FOG_END); - gpu_state_print_fl(GL_FOG_HINT); - gpu_state_print_fl(GL_FOG_INDEX); - gpu_state_print_fl(GL_FOG_MODE); - gpu_state_print_fl(GL_FOG_START); - gpu_state_print_fl(GL_FRAGMENT_PROGRAM_ARB); - gpu_state_print_fl(GL_FRAGMENT_SHADER_DERIVATIVE_HINT); - gpu_state_print_fl(GL_FRONT_FACE); - gpu_state_print_fl(GL_GENERATE_MIPMAP_HINT); - gpu_state_print_fl(GL_GREEN_BIAS); - gpu_state_print_fl(GL_GREEN_BITS); - gpu_state_print_fl(GL_GREEN_SCALE); - gpu_state_print_fl(GL_HISTOGRAM); - gpu_state_print_fl(GL_INDEX_ARRAY); - gpu_state_print_fl(GL_INDEX_ARRAY_BUFFER_BINDING); - gpu_state_print_fl(GL_INDEX_ARRAY_STRIDE); - gpu_state_print_fl(GL_INDEX_ARRAY_TYPE); - gpu_state_print_fl(GL_INDEX_BITS); - gpu_state_print_fl(GL_INDEX_CLEAR_VALUE); - gpu_state_print_fl(GL_INDEX_LOGIC_OP); - gpu_state_print_fl(GL_INDEX_MODE); - gpu_state_print_fl(GL_INDEX_OFFSET); - gpu_state_print_fl(GL_INDEX_SHIFT); - gpu_state_print_fl(GL_INDEX_WRITEMASK); - gpu_state_print_fl(GL_LIGHT0); - gpu_state_print_fl(GL_LIGHT1); - gpu_state_print_fl(GL_LIGHT2); - gpu_state_print_fl(GL_LIGHT3); - gpu_state_print_fl(GL_LIGHT4); - gpu_state_print_fl(GL_LIGHT5); - gpu_state_print_fl(GL_LIGHT6); - gpu_state_print_fl(GL_LIGHT7); - gpu_state_print_fl(GL_LIGHTING); - gpu_state_print_fl(GL_LIGHT_MODEL_AMBIENT); - gpu_state_print_fl(GL_LIGHT_MODEL_COLOR_CONTROL); - gpu_state_print_fl(GL_LIGHT_MODEL_LOCAL_VIEWER); - gpu_state_print_fl(GL_LIGHT_MODEL_TWO_SIDE); - gpu_state_print_fl(GL_LINE_SMOOTH); - gpu_state_print_fl(GL_LINE_SMOOTH_HINT); - gpu_state_print_fl(GL_LINE_STIPPLE); - gpu_state_print_fl(GL_LINE_STIPPLE_PATTERN); - gpu_state_print_fl(GL_LINE_STIPPLE_REPEAT); - gpu_state_print_fl(GL_LINE_WIDTH); - gpu_state_print_fl(GL_LINE_WIDTH_GRANULARITY); - gpu_state_print_fl(GL_LINE_WIDTH_RANGE); - gpu_state_print_fl(GL_LIST_BASE); - gpu_state_print_fl(GL_LIST_INDEX); - gpu_state_print_fl(GL_LIST_MODE); - gpu_state_print_fl(GL_LOGIC_OP); - gpu_state_print_fl(GL_LOGIC_OP_MODE); - gpu_state_print_fl(GL_MAP1_COLOR_4); - gpu_state_print_fl(GL_MAP1_GRID_DOMAIN); - gpu_state_print_fl(GL_MAP1_GRID_SEGMENTS); - gpu_state_print_fl(GL_MAP1_INDEX); - gpu_state_print_fl(GL_MAP1_NORMAL); - gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_1); - gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_2); - gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_3); - gpu_state_print_fl(GL_MAP1_TEXTURE_COORD_4); - gpu_state_print_fl(GL_MAP1_VERTEX_3); - gpu_state_print_fl(GL_MAP1_VERTEX_4); - gpu_state_print_fl(GL_MAP2_COLOR_4); - gpu_state_print_fl(GL_MAP2_GRID_DOMAIN); - gpu_state_print_fl(GL_MAP2_GRID_SEGMENTS); - gpu_state_print_fl(GL_MAP2_INDEX); - gpu_state_print_fl(GL_MAP2_NORMAL); - gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_1); - gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_2); - gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_3); - gpu_state_print_fl(GL_MAP2_TEXTURE_COORD_4); - gpu_state_print_fl(GL_MAP2_VERTEX_3); - gpu_state_print_fl(GL_MAP2_VERTEX_4); - gpu_state_print_fl(GL_MAP_COLOR); - gpu_state_print_fl(GL_MAP_STENCIL); - gpu_state_print_fl(GL_MATRIX_MODE); - gpu_state_print_fl(GL_MAX_3D_TEXTURE_SIZE); - gpu_state_print_fl(GL_MAX_ATTRIB_STACK_DEPTH); - gpu_state_print_fl(GL_MAX_CLIENT_ATTRIB_STACK_DEPTH); - gpu_state_print_fl(GL_MAX_CLIP_PLANES); - gpu_state_print_fl(GL_MAX_COLOR_MATRIX_STACK_DEPTH); - gpu_state_print_fl(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS); - gpu_state_print_fl(GL_MAX_CUBE_MAP_TEXTURE_SIZE); - gpu_state_print_fl(GL_MAX_DRAW_BUFFERS); - gpu_state_print_fl(GL_MAX_ELEMENTS_INDICES); - gpu_state_print_fl(GL_MAX_ELEMENTS_VERTICES); - gpu_state_print_fl(GL_MAX_EVAL_ORDER); - gpu_state_print_fl(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS); - gpu_state_print_fl(GL_MAX_LIGHTS); - gpu_state_print_fl(GL_MAX_LIST_NESTING); - gpu_state_print_fl(GL_MAX_MODELVIEW_STACK_DEPTH); - gpu_state_print_fl(GL_MAX_NAME_STACK_DEPTH); - gpu_state_print_fl(GL_MAX_PIXEL_MAP_TABLE); - gpu_state_print_fl(GL_MAX_PROJECTION_STACK_DEPTH); - gpu_state_print_fl(GL_MAX_TEXTURE_COORDS); - gpu_state_print_fl(GL_MAX_TEXTURE_IMAGE_UNITS); - gpu_state_print_fl(GL_MAX_TEXTURE_LOD_BIAS); - gpu_state_print_fl(GL_MAX_TEXTURE_SIZE); - gpu_state_print_fl(GL_MAX_TEXTURE_STACK_DEPTH); - gpu_state_print_fl(GL_MAX_TEXTURE_UNITS); - gpu_state_print_fl(GL_MAX_VARYING_FLOATS); - gpu_state_print_fl(GL_MAX_VERTEX_ATTRIBS); - gpu_state_print_fl(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS); - gpu_state_print_fl(GL_MAX_VERTEX_UNIFORM_COMPONENTS); - gpu_state_print_fl(GL_MAX_VIEWPORT_DIMS); - gpu_state_print_fl(GL_MINMAX); - gpu_state_print_fl(GL_MODELVIEW_MATRIX); - gpu_state_print_fl(GL_MODELVIEW_STACK_DEPTH); - gpu_state_print_fl(GL_MULTISAMPLE); - gpu_state_print_fl(GL_MULTISAMPLE_ARB); - gpu_state_print_fl(GL_NAME_STACK_DEPTH); - gpu_state_print_fl(GL_NORMALIZE); - gpu_state_print_fl(GL_NORMAL_ARRAY); - gpu_state_print_fl(GL_NORMAL_ARRAY_BUFFER_BINDING); - gpu_state_print_fl(GL_NORMAL_ARRAY_STRIDE); - gpu_state_print_fl(GL_NORMAL_ARRAY_TYPE); - gpu_state_print_fl(GL_NUM_COMPRESSED_TEXTURE_FORMATS); - gpu_state_print_fl(GL_PACK_ALIGNMENT); - gpu_state_print_fl(GL_PACK_IMAGE_HEIGHT); - gpu_state_print_fl(GL_PACK_LSB_FIRST); - gpu_state_print_fl(GL_PACK_ROW_LENGTH); - gpu_state_print_fl(GL_PACK_SKIP_IMAGES); - gpu_state_print_fl(GL_PACK_SKIP_PIXELS); - gpu_state_print_fl(GL_PACK_SKIP_ROWS); - gpu_state_print_fl(GL_PACK_SWAP_BYTES); - gpu_state_print_fl(GL_PERSPECTIVE_CORRECTION_HINT); - gpu_state_print_fl(GL_PIXEL_MAP_A_TO_A_SIZE); - gpu_state_print_fl(GL_PIXEL_MAP_B_TO_B_SIZE); - gpu_state_print_fl(GL_PIXEL_MAP_G_TO_G_SIZE); - gpu_state_print_fl(GL_PIXEL_MAP_I_TO_A_SIZE); - gpu_state_print_fl(GL_PIXEL_MAP_I_TO_B_SIZE); - gpu_state_print_fl(GL_PIXEL_MAP_I_TO_G_SIZE); - gpu_state_print_fl(GL_PIXEL_MAP_I_TO_I_SIZE); - gpu_state_print_fl(GL_PIXEL_MAP_I_TO_R_SIZE); - gpu_state_print_fl(GL_PIXEL_MAP_R_TO_R_SIZE); - gpu_state_print_fl(GL_PIXEL_MAP_S_TO_S_SIZE); - gpu_state_print_fl(GL_PIXEL_PACK_BUFFER_BINDING); - gpu_state_print_fl(GL_PIXEL_UNPACK_BUFFER_BINDING); - gpu_state_print_fl(GL_POINT_DISTANCE_ATTENUATION); - gpu_state_print_fl(GL_POINT_FADE_THRESHOLD_SIZE); - gpu_state_print_fl(GL_POINT_SIZE); - gpu_state_print_fl(GL_POINT_SIZE_GRANULARITY); - gpu_state_print_fl(GL_POINT_SIZE_MAX); - gpu_state_print_fl(GL_POINT_SIZE_MIN); - gpu_state_print_fl(GL_POINT_SIZE_RANGE); - gpu_state_print_fl(GL_POINT_SMOOTH); - gpu_state_print_fl(GL_POINT_SMOOTH_HINT); - gpu_state_print_fl(GL_POINT_SPRITE); - gpu_state_print_fl(GL_POLYGON_MODE); - gpu_state_print_fl(GL_POLYGON_OFFSET_FACTOR); - gpu_state_print_fl(GL_POLYGON_OFFSET_FILL); - gpu_state_print_fl(GL_POLYGON_OFFSET_LINE); - gpu_state_print_fl(GL_POLYGON_OFFSET_POINT); - gpu_state_print_fl(GL_POLYGON_OFFSET_UNITS); - gpu_state_print_fl(GL_POLYGON_SMOOTH); - gpu_state_print_fl(GL_POLYGON_SMOOTH_HINT); - gpu_state_print_fl(GL_POLYGON_STIPPLE); - gpu_state_print_fl(GL_POST_COLOR_MATRIX_ALPHA_BIAS); - gpu_state_print_fl(GL_POST_COLOR_MATRIX_ALPHA_SCALE); - gpu_state_print_fl(GL_POST_COLOR_MATRIX_BLUE_BIAS); - gpu_state_print_fl(GL_POST_COLOR_MATRIX_BLUE_SCALE); - gpu_state_print_fl(GL_POST_COLOR_MATRIX_COLOR_TABLE); - gpu_state_print_fl(GL_POST_COLOR_MATRIX_GREEN_BIAS); - gpu_state_print_fl(GL_POST_COLOR_MATRIX_GREEN_SCALE); - gpu_state_print_fl(GL_POST_COLOR_MATRIX_RED_BIAS); - gpu_state_print_fl(GL_POST_COLOR_MATRIX_RED_SCALE); - gpu_state_print_fl(GL_POST_CONVOLUTION_ALPHA_BIAS); - gpu_state_print_fl(GL_POST_CONVOLUTION_ALPHA_SCALE); - gpu_state_print_fl(GL_POST_CONVOLUTION_BLUE_BIAS); - gpu_state_print_fl(GL_POST_CONVOLUTION_BLUE_SCALE); - gpu_state_print_fl(GL_POST_CONVOLUTION_COLOR_TABLE); - gpu_state_print_fl(GL_POST_CONVOLUTION_GREEN_BIAS); - gpu_state_print_fl(GL_POST_CONVOLUTION_GREEN_SCALE); - gpu_state_print_fl(GL_POST_CONVOLUTION_RED_BIAS); - gpu_state_print_fl(GL_POST_CONVOLUTION_RED_SCALE); - gpu_state_print_fl(GL_PROJECTION_MATRIX); - gpu_state_print_fl(GL_PROJECTION_STACK_DEPTH); - gpu_state_print_fl(GL_READ_BUFFER); - gpu_state_print_fl(GL_RED_BIAS); - gpu_state_print_fl(GL_RED_BITS); - gpu_state_print_fl(GL_RED_SCALE); - gpu_state_print_fl(GL_RENDER_MODE); - gpu_state_print_fl(GL_RESCALE_NORMAL); - gpu_state_print_fl(GL_RGBA_MODE); - gpu_state_print_fl(GL_SAMPLES); - gpu_state_print_fl(GL_SAMPLE_BUFFERS); - gpu_state_print_fl(GL_SAMPLE_COVERAGE_INVERT); - gpu_state_print_fl(GL_SAMPLE_COVERAGE_VALUE); - gpu_state_print_fl(GL_SCISSOR_BOX); - gpu_state_print_fl(GL_SCISSOR_TEST); - gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY); - gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING); - gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_SIZE); - gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_STRIDE); - gpu_state_print_fl(GL_SECONDARY_COLOR_ARRAY_TYPE); - gpu_state_print_fl(GL_SELECTION_BUFFER_SIZE); - gpu_state_print_fl(GL_SEPARABLE_2D); - gpu_state_print_fl(GL_SHADE_MODEL); - gpu_state_print_fl(GL_SMOOTH_LINE_WIDTH_GRANULARITY); - gpu_state_print_fl(GL_SMOOTH_LINE_WIDTH_RANGE); - gpu_state_print_fl(GL_SMOOTH_POINT_SIZE_GRANULARITY); - gpu_state_print_fl(GL_SMOOTH_POINT_SIZE_RANGE); - gpu_state_print_fl(GL_STENCIL_BACK_FAIL); - gpu_state_print_fl(GL_STENCIL_BACK_FUNC); - gpu_state_print_fl(GL_STENCIL_BACK_PASS_DEPTH_FAIL); - gpu_state_print_fl(GL_STENCIL_BACK_PASS_DEPTH_PASS); - gpu_state_print_fl(GL_STENCIL_BACK_REF); - gpu_state_print_fl(GL_STENCIL_BACK_VALUE_MASK); - gpu_state_print_fl(GL_STENCIL_BACK_WRITEMASK); - gpu_state_print_fl(GL_STENCIL_BITS); - gpu_state_print_fl(GL_STENCIL_CLEAR_VALUE); - gpu_state_print_fl(GL_STENCIL_FAIL); - gpu_state_print_fl(GL_STENCIL_FUNC); - gpu_state_print_fl(GL_STENCIL_PASS_DEPTH_FAIL); - gpu_state_print_fl(GL_STENCIL_PASS_DEPTH_PASS); - gpu_state_print_fl(GL_STENCIL_REF); - gpu_state_print_fl(GL_STENCIL_TEST); - gpu_state_print_fl(GL_STENCIL_VALUE_MASK); - gpu_state_print_fl(GL_STENCIL_WRITEMASK); - gpu_state_print_fl(GL_STEREO); - gpu_state_print_fl(GL_SUBPIXEL_BITS); - gpu_state_print_fl(GL_TEXTURE_1D); - gpu_state_print_fl(GL_TEXTURE_2D); - gpu_state_print_fl(GL_TEXTURE_3D); - gpu_state_print_fl(GL_TEXTURE_BINDING_1D); - gpu_state_print_fl(GL_TEXTURE_BINDING_2D); - gpu_state_print_fl(GL_TEXTURE_BINDING_3D); - gpu_state_print_fl(GL_TEXTURE_BINDING_CUBE_MAP); - gpu_state_print_fl(GL_TEXTURE_COMPRESSION_HINT); - gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY); - gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING); - gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_SIZE); - gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_STRIDE); - gpu_state_print_fl(GL_TEXTURE_COORD_ARRAY_TYPE); - gpu_state_print_fl(GL_TEXTURE_CUBE_MAP); - gpu_state_print_fl(GL_TEXTURE_CUBE_MAP_ARB); - gpu_state_print_fl(GL_TEXTURE_GEN_Q); - gpu_state_print_fl(GL_TEXTURE_GEN_R); - gpu_state_print_fl(GL_TEXTURE_GEN_S); - gpu_state_print_fl(GL_TEXTURE_GEN_T); - gpu_state_print_fl(GL_TEXTURE_MATRIX); - gpu_state_print_fl(GL_TEXTURE_STACK_DEPTH); - gpu_state_print_fl(GL_TRANSPOSE_COLOR_MATRIX); - gpu_state_print_fl(GL_TRANSPOSE_MODELVIEW_MATRIX); - gpu_state_print_fl(GL_TRANSPOSE_PROJECTION_MATRIX); - gpu_state_print_fl(GL_TRANSPOSE_TEXTURE_MATRIX); - gpu_state_print_fl(GL_UNPACK_ALIGNMENT); - gpu_state_print_fl(GL_UNPACK_IMAGE_HEIGHT); - gpu_state_print_fl(GL_UNPACK_LSB_FIRST); - gpu_state_print_fl(GL_UNPACK_ROW_LENGTH); - gpu_state_print_fl(GL_UNPACK_SKIP_IMAGES); - gpu_state_print_fl(GL_UNPACK_SKIP_PIXELS); - gpu_state_print_fl(GL_UNPACK_SKIP_ROWS); - gpu_state_print_fl(GL_UNPACK_SWAP_BYTES); - gpu_state_print_fl(GL_VERTEX_ARRAY); - gpu_state_print_fl(GL_VERTEX_ARRAY_BUFFER_BINDING); - gpu_state_print_fl(GL_VERTEX_ARRAY_SIZE); - gpu_state_print_fl(GL_VERTEX_ARRAY_STRIDE); - gpu_state_print_fl(GL_VERTEX_ARRAY_TYPE); - gpu_state_print_fl(GL_VERTEX_PROGRAM_POINT_SIZE); - gpu_state_print_fl(GL_VERTEX_PROGRAM_TWO_SIDE); - gpu_state_print_fl(GL_VIEWPORT); - gpu_state_print_fl(GL_ZOOM_X); - gpu_state_print_fl(GL_ZOOM_Y); -} - -#undef gpu_state_print_fl - -#endif diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 1d081875c9b..c7e89e50b7e 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -33,8 +33,6 @@ */ -#include "GPU_glew.h" - #include "DNA_image_types.h" #include "MEM_guardedalloc.h" @@ -45,12 +43,14 @@ #include "BKE_global.h" +#include "GPU_glew.h" +#include "GPU_debug.h" #include "GPU_draw.h" #include "GPU_extensions.h" #include "GPU_compositing.h" #include "GPU_simple_shader.h" -#include "intern/gpu_extensions_private.h" +#include "intern/gpu_private.h" #include <stdlib.h> #include <stdio.h> @@ -273,20 +273,6 @@ int GPU_color_depth(void) return GG.colordepth; } -int GPU_print_error(const char *str) -{ - GLenum errCode; - - if ((G.debug & G_DEBUG)) { - if ((errCode = glGetError()) != GL_NO_ERROR) { - fprintf(stderr, "%s opengl error: %s\n", str, gluErrorString(errCode)); - return 1; - } - } - - return 0; -} - static void GPU_print_framebuffer_error(GLenum status, char err_out[256]) { const char *err= "unknown"; @@ -552,7 +538,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, float * tex->number = 0; glBindTexture(tex->target, tex->bindcode); - GPU_print_error("3D glBindTexture"); + GPU_ASSERT_NO_GL_ERRORS("3D glBindTexture"); type = GL_FLOAT; if (channels == 4) { @@ -569,7 +555,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, float * glTexImage3D(tex->target, 0, internalformat, tex->w, tex->h, tex->depth, 0, format, type, NULL); - GPU_print_error("3D glTexImage3D"); + GPU_ASSERT_NO_GL_ERRORS("3D glTexImage3D"); if (fpixels) { if (!GPU_non_power_of_two_support() && (w != tex->w || h != tex->h || depth != tex->depth)) { @@ -580,19 +566,19 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, float * } glTexSubImage3D(tex->target, 0, 0, 0, 0, w, h, depth, format, type, fpixels); - GPU_print_error("3D glTexSubImage3D"); + GPU_ASSERT_NO_GL_ERRORS("3D glTexSubImage3D"); } glTexParameterfv(GL_TEXTURE_3D, GL_TEXTURE_BORDER_COLOR, vfBorderColor); - GPU_print_error("3D GL_TEXTURE_BORDER_COLOR"); + GPU_ASSERT_NO_GL_ERRORS("3D GL_TEXTURE_BORDER_COLOR"); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - GPU_print_error("3D GL_LINEAR"); + GPU_ASSERT_NO_GL_ERRORS("3D GL_LINEAR"); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - GPU_print_error("3D GL_CLAMP_TO_BORDER"); + GPU_ASSERT_NO_GL_ERRORS("3D GL_CLAMP_TO_BORDER"); if (pixels) MEM_freeN(pixels); @@ -629,7 +615,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, bool is_data, ima->gputexture= tex; if (!glIsTexture(tex->bindcode)) { - GPU_print_error("Blender Texture Not Loaded"); + GPU_ASSERT_NO_GL_ERRORS("Blender Texture Not Loaded"); } else { glBindTexture(GL_TEXTURE_2D, tex->bindcode); @@ -676,7 +662,7 @@ GPUTexture *GPU_texture_from_preview(PreviewImage *prv, int mipmap) prv->gputexture[0]= tex; if (!glIsTexture(tex->bindcode)) { - GPU_print_error("Blender Texture Not Loaded"); + GPU_ASSERT_NO_GL_ERRORS("Blender Texture Not Loaded"); } else { glBindTexture(GL_TEXTURE_2D, tex->bindcode); @@ -813,7 +799,7 @@ void GPU_texture_bind(GPUTexture *tex, int number) GLenum arbnumber; if (number >= GG.maxtextures) { - GPU_print_error("Not enough texture slots."); + fprintf(stderr, "Not enough texture slots."); return; } @@ -826,7 +812,7 @@ void GPU_texture_bind(GPUTexture *tex, int number) if (number < 0) return; - GPU_print_error("Pre Texture Bind"); + GPU_ASSERT_NO_GL_ERRORS("Pre Texture Bind"); arbnumber = (GLenum)((GLuint)GL_TEXTURE0_ARB + number); if (number != 0) glActiveTextureARB(arbnumber); @@ -840,7 +826,7 @@ void GPU_texture_bind(GPUTexture *tex, int number) tex->number = number; - GPU_print_error("Post Texture Bind"); + GPU_ASSERT_NO_GL_ERRORS("Post Texture Bind"); } void GPU_texture_unbind(GPUTexture *tex) @@ -848,14 +834,14 @@ void GPU_texture_unbind(GPUTexture *tex) GLenum arbnumber; if (tex->number >= GG.maxtextures) { - GPU_print_error("Not enough texture slots."); + fprintf(stderr, "Not enough texture slots."); return; } if (tex->number == -1) return; - GPU_print_error("Pre Texture Unbind"); + GPU_ASSERT_NO_GL_ERRORS("Pre Texture Unbind"); arbnumber = (GLenum)((GLuint)GL_TEXTURE0_ARB + tex->number); if (tex->number != 0) glActiveTextureARB(arbnumber); @@ -865,7 +851,7 @@ void GPU_texture_unbind(GPUTexture *tex) tex->number = -1; - GPU_print_error("Post Texture Unbind"); + GPU_ASSERT_NO_GL_ERRORS("Post Texture Unbind"); } void GPU_depth_texture_mode(GPUTexture *tex, bool compare, bool use_filter) @@ -873,19 +859,19 @@ void GPU_depth_texture_mode(GPUTexture *tex, bool compare, bool use_filter) GLenum arbnumber; if (tex->number >= GG.maxtextures) { - GPU_print_error("Not enough texture slots."); + fprintf(stderr, "Not enough texture slots."); return; } if (!tex->depth) { - GPU_print_error("Not a depth texture."); + fprintf(stderr, "Not a depth texture."); return; } if (tex->number == -1) return; - GPU_print_error("Pre Texture Unbind"); + GPU_ASSERT_NO_GL_ERRORS("Pre Texture Unbind"); arbnumber = (GLenum)((GLuint)GL_TEXTURE0_ARB + tex->number); if (tex->number != 0) glActiveTextureARB(arbnumber); @@ -904,7 +890,7 @@ void GPU_depth_texture_mode(GPUTexture *tex, bool compare, bool use_filter) } if (tex->number != 0) glActiveTextureARB(GL_TEXTURE0_ARB); - GPU_print_error("Post Texture Unbind"); + GPU_ASSERT_NO_GL_ERRORS("Post Texture Unbind"); } void GPU_texture_free(GPUTexture *tex) @@ -1606,16 +1592,16 @@ GPUShader *GPU_shader_create_lib(const char *code) void GPU_shader_bind(GPUShader *shader) { - GPU_print_error("Pre Shader Bind"); + GPU_ASSERT_NO_GL_ERRORS("Pre Shader Bind"); glUseProgramObjectARB(shader->object); - GPU_print_error("Post Shader Bind"); + GPU_ASSERT_NO_GL_ERRORS("Post Shader Bind"); } void GPU_shader_unbind(void) { - GPU_print_error("Pre Shader Unbind"); + GPU_ASSERT_NO_GL_ERRORS("Pre Shader Unbind"); glUseProgramObjectARB(0); - GPU_print_error("Post Shader Unbind"); + GPU_ASSERT_NO_GL_ERRORS("Post Shader Unbind"); } void GPU_shader_free(GPUShader *shader) @@ -1641,7 +1627,7 @@ void GPU_shader_uniform_vector(GPUShader *UNUSED(shader), int location, int leng if (location == -1) return; - GPU_print_error("Pre Uniform Vector"); + GPU_ASSERT_NO_GL_ERRORS("Pre Uniform Vector"); if (length == 1) glUniform1fvARB(location, arraysize, value); else if (length == 2) glUniform2fvARB(location, arraysize, value); @@ -1650,7 +1636,7 @@ void GPU_shader_uniform_vector(GPUShader *UNUSED(shader), int location, int leng else if (length == 9) glUniformMatrix3fvARB(location, arraysize, 0, value); else if (length == 16) glUniformMatrix4fvARB(location, arraysize, 0, value); - GPU_print_error("Post Uniform Vector"); + GPU_ASSERT_NO_GL_ERRORS("Post Uniform Vector"); } void GPU_shader_uniform_int(GPUShader *UNUSED(shader), int location, int value) @@ -1658,9 +1644,7 @@ void GPU_shader_uniform_int(GPUShader *UNUSED(shader), int location, int value) if (location == -1) return; - GPU_print_error("Pre Uniform Int"); - glUniform1iARB(location, value); - GPU_print_error("Post Uniform Int"); + GPU_CHECK_ERRORS_AROUND(glUniform1iARB(location, value)); } void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUTexture *tex) @@ -1668,7 +1652,7 @@ void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUText GLenum arbnumber; if (tex->number >= GG.maxtextures) { - GPU_print_error("Not enough texture slots."); + fprintf(stderr, "Not enough texture slots."); return; } @@ -1678,7 +1662,7 @@ void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUText if (location == -1) return; - GPU_print_error("Pre Uniform Texture"); + GPU_ASSERT_NO_GL_ERRORS("Pre Uniform Texture"); arbnumber = (GLenum)((GLuint)GL_TEXTURE0_ARB + tex->number); @@ -1691,18 +1675,14 @@ void GPU_shader_uniform_texture(GPUShader *UNUSED(shader), int location, GPUText glEnable(tex->target); if (tex->number != 0) glActiveTextureARB(GL_TEXTURE0_ARB); - GPU_print_error("Post Uniform Texture"); + GPU_ASSERT_NO_GL_ERRORS("Post Uniform Texture"); } int GPU_shader_get_attribute(GPUShader *shader, const char *name) { int index; - GPU_print_error("Pre Get Attribute"); - - index = glGetAttribLocationARB(shader->object, name); - - GPU_print_error("Post Get Attribute"); + GPU_CHECK_ERRORS_AROUND(index = glGetAttribLocationARB(shader->object, name)); return index; } diff --git a/source/blender/gpu/intern/gpu_init_exit.c b/source/blender/gpu/intern/gpu_init_exit.c index fd99595b6a4..a93c1a21130 100644 --- a/source/blender/gpu/intern/gpu_init_exit.c +++ b/source/blender/gpu/intern/gpu_init_exit.c @@ -33,7 +33,7 @@ #include "GPU_init_exit.h" /* interface */ #include "intern/gpu_codegen.h" -#include "intern/gpu_extensions_private.h" +#include "intern/gpu_private.h" /** * although the order of initialization and shutdown should not matter @@ -53,12 +53,15 @@ void GPU_init(void) gpu_extensions_init(); /* must come first */ gpu_codegen_init(); + + GPU_DEBUG_INIT(); } void GPU_exit(void) { + GPU_DEBUG_EXIT(); gpu_codegen_exit(); gpu_extensions_exit(); /* must come last */ diff --git a/source/blender/gpu/intern/gpu_extensions_private.h b/source/blender/gpu/intern/gpu_private.h index a4124b8fa3d..11bc2bd3119 100644 --- a/source/blender/gpu/intern/gpu_extensions_private.h +++ b/source/blender/gpu/intern/gpu_private.h @@ -22,11 +22,28 @@ * \ingroup gpu */ -#ifndef __GPU_EXTENSIONS_PRIVATE_H__ -#define __GPU_EXTENSIONS_PRIVATE_H__ +#ifndef __GPU_PRIVATE_H__ +#define __GPU_PRIVATE_H__ /* call this before running any of the functions below */ void gpu_extensions_init(void); void gpu_extensions_exit(void); -#endif /* __GPU_EXTENSIONS_PRIVATE_H__ */ + +/* gpu_debug.c */ +#ifdef WITH_GPU_DEBUG + +void gpu_debug_init(void); +void gpu_debug_exit(void); + +# define GPU_DEBUG_INIT() gpu_debug_init() +# define GPU_DEBUG_EXIT() gpu_debug_exit() + +#else + +# define GPU_DEBUG_INIT() ((void)0) +# define GPU_DEBUG_EXIT() ((void)0) + +#endif + +#endif /* __GPU_PRIVATE_H__ */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 4b8af999205..8ddc5d77a42 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -71,6 +71,8 @@ #include "BIF_gl.h" +#include "GPU_debug.h" + #include "UI_interface.h" #include "PIL_time.h" @@ -2417,12 +2419,7 @@ void wm_event_do_handlers(bContext *C) /* update key configuration after handling events */ WM_keyconfig_update(wm); - if (G.debug) { - GLenum error = glGetError(); - if (error != GL_NO_ERROR) { - printf("GL error: %s\n", gluErrorString(error)); - } - } + GPU_ASSERT_NO_GL_ERRORS("wm_event_do_handlers"); } /* ********** filesector handling ************ */ |