From c5862e0a06b75767fd863673c54aab54f27d1872 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Apr 2019 01:45:43 +1000 Subject: Cleanup: comments (long lines) in gpu --- source/blender/gpu/GPU_immediate.h | 7 ++++--- source/blender/gpu/GPU_matrix.h | 3 ++- source/blender/gpu/GPU_shader.h | 9 ++++++--- source/blender/gpu/GPU_vertex_format.h | 7 ++++--- source/blender/gpu/intern/gpu_attr_binding.c | 3 ++- source/blender/gpu/intern/gpu_batch.c | 3 ++- source/blender/gpu/intern/gpu_codegen.c | 3 ++- source/blender/gpu/intern/gpu_framebuffer.c | 3 ++- source/blender/gpu/intern/gpu_immediate.c | 4 +++- source/blender/gpu/intern/gpu_select.c | 6 ++++-- source/blender/gpu/intern/gpu_select_pick.c | 3 ++- source/blender/gpu/intern/gpu_shader.c | 11 ++++++----- source/blender/gpu/intern/gpu_texture.c | 7 ++++--- source/blender/gpu/intern/gpu_viewport.c | 3 ++- .../blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl | 6 ++++-- .../blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl | 10 ++++++---- .../shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl | 4 ++-- .../gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl | 3 ++- .../gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl | 7 ++++--- .../shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl | 4 ++-- source/blender/gpu/shaders/gpu_shader_material.glsl | 3 ++- 21 files changed, 67 insertions(+), 42 deletions(-) (limited to 'source/blender/gpu') diff --git a/source/blender/gpu/GPU_immediate.h b/source/blender/gpu/GPU_immediate.h index 30a6020f74a..a8e5e9d0e04 100644 --- a/source/blender/gpu/GPU_immediate.h +++ b/source/blender/gpu/GPU_immediate.h @@ -47,9 +47,10 @@ void immBegin(GPUPrimType, uint vertex_len); void immBeginAtMost(GPUPrimType, uint max_vertex_len); void immEnd(void); /* finishes and draws. */ -/* ImmBegin a batch, then use standard immFunctions as usual. */ -/* ImmEnd will finalize the batch instead of drawing. */ -/* Then you can draw it as many times as you like! Partially replaces the need for display lists. */ +/* immBegin a batch, then use standard immFunctions as usual. */ +/* immEnd will finalize the batch instead of drawing. */ +/* Then you can draw it as many times as you like! + * Partially replaces the need for display lists. */ GPUBatch *immBeginBatch(GPUPrimType, uint vertex_len); GPUBatch *immBeginBatchAtMost(GPUPrimType, uint vertex_len); diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h index 24a76c13e01..67fb2bb2bd4 100644 --- a/source/blender/gpu/GPU_matrix.h +++ b/source/blender/gpu/GPU_matrix.h @@ -123,7 +123,8 @@ const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3]; void GPU_matrix_bind(const struct GPUShaderInterface *); bool GPU_matrix_dirty_get(void); /* since last bind */ -/* Python API needs to be able to inspect the stack so errors raise exceptions instead of crashing. */ +/* Python API needs to be able to inspect the stack so errors raise exceptions + * instead of crashing. */ #ifdef USE_GPU_PY_MATRIX_API int GPU_matrix_stack_level_get_model_view(void); int GPU_matrix_stack_level_get_projection(void); diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index d7addeb87b4..d174aafacce 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -239,7 +239,8 @@ typedef enum eGPUBuiltinShader { */ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA, /** - * Draw round points with a constant size and an outline. Take a 2D position and a color for each vertex. + * Draw round points with a constant size and an outline. + * Take a 2D position and a color for each vertex. * * \param size: uniform float * \param outlineWidth: uniform float @@ -249,7 +250,8 @@ typedef enum eGPUBuiltinShader { */ GPU_SHADER_2D_POINT_UNIFORM_SIZE_VARYING_COLOR_OUTLINE_AA, /** - * Draw round points with a constant size and an outline. Take a 2D position and a color for each vertex. + * Draw round points with a constant size and an outline. + * Take a 2D position and a color for each vertex. * * \param size: in float * \param color: in vec4 @@ -302,7 +304,8 @@ typedef enum eGPUBuiltinShader { */ GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR, /** - * Draw round points with a constant size and an outline. Take a 3D position and a color for each vertex. + * Draw round points with a constant size and an outline. + * Take a 3D position and a color for each vertex. * * \param size: in float * \param color: in vec4 diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h index 021def5b265..7f1934431cf 100644 --- a/source/blender/gpu/GPU_vertex_format.h +++ b/source/blender/gpu/GPU_vertex_format.h @@ -91,12 +91,13 @@ void GPU_vertformat_alias_add(GPUVertFormat *, const char *alias); int GPU_vertformat_attr_id_get(const GPUVertFormat *, const char *name); /** - * This makes the "virtual" attributes with suffixes "0", "1", "2" to access triangle data in the vertex - * shader. + * This makes the "virtual" attributes with suffixes "0", "1", "2" + * to access triangle data in the vertex shader. * * IMPORTANT: * - Call this before creating the vertex buffer and after creating all attributes - * - Only first vertex out of 3 has the correct information. Use flat output with GL_FIRST_VERTEX_CONVENTION. + * - Only first vertex out of 3 has the correct information. + * Use flat output with #GL_FIRST_VERTEX_CONVENTION. */ void GPU_vertformat_triple_load(GPUVertFormat *format); diff --git a/source/blender/gpu/intern/gpu_attr_binding.c b/source/blender/gpu/intern/gpu_attr_binding.c index 6cd350df505..e280b77f661 100644 --- a/source/blender/gpu/intern/gpu_attr_binding.c +++ b/source/blender/gpu/intern/gpu_attr_binding.c @@ -73,7 +73,8 @@ void get_attr_locations(const GPUVertFormat *format, const GPUShaderInput *input = GPU_shaderinterface_attr(shaderface, a->name[n_idx]); #if TRUST_NO_ONE assert(input != NULL); - /* TODO: make this a recoverable runtime error? indicates mismatch between vertex format and program */ + /* TODO: make this a recoverable runtime error? + * indicates mismatch between vertex format and program. */ #endif write_attr_location(binding, a_idx, input->location); } diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 636a48c1623..4f5215ce9e6 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -420,7 +420,8 @@ static void batch_update_program_bindings(GPUBatch *batch, uint v_first) void GPU_batch_program_use_begin(GPUBatch *batch) { /* NOTE: use_program & done_using_program are fragile, depend on staying in sync with - * the GL context's active program. use_program doesn't mark other programs as "not used". */ + * the GL context's active program. + * use_program doesn't mark other programs as "not used". */ /* TODO: make not fragile (somehow) */ if (!batch->program_in_use) { diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 242544ec07f..43211fe0969 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -824,7 +824,8 @@ static char *code_generate_fragment(GPUMaterial *material, BLI_dynstr_append(ds, "}\n"); - /* XXX This cannot go into gpu_shader_material.glsl because main() would be parsed and generate error */ + /* XXX This cannot go into gpu_shader_material.glsl because main() + * would be parsed and generate error */ /* Old glsl mode compat. */ BLI_dynstr_append(ds, "#ifndef NODETREE_EXEC\n"); BLI_dynstr_append(ds, "out vec4 fragColor;\n"); diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index dbe1d2c8d69..a77f9ca5f11 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -717,7 +717,8 @@ void GPU_framebuffer_blit(GPUFrameBuffer *fb_read, /** * Use this if you need to custom downsample your texture and use the previous mip level as input. - * This function only takes care of the correct texture handling. It execute the callback for each texture level. + * This function only takes care of the correct texture handling. + * It execute the callback for each texture level. */ void GPU_framebuffer_recursive_downsample(GPUFrameBuffer *fb, int max_lvl, diff --git a/source/blender/gpu/intern/gpu_immediate.c b/source/blender/gpu/intern/gpu_immediate.c index 3c8b76dd36c..11c4cfba8df 100644 --- a/source/blender/gpu/intern/gpu_immediate.c +++ b/source/blender/gpu/intern/gpu_immediate.c @@ -634,7 +634,9 @@ static void immEndVertex(void) /* and move on to the next vertex */ if ((imm.unassigned_attr_bits >> a_idx) & 1) { const GPUVertAttr *a = &imm.vertex_format.attrs[a_idx]; - /* printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx); */ +#if 0 + printf("copying %s from vertex %u to %u\n", a->name, imm.vertex_idx - 1, imm.vertex_idx); +#endif GLubyte *data = imm.vertex_data + a->offset; memcpy(data, data - imm.vertex_format.stride, a->sz); diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c index 4cfedc0708b..4268af2198d 100644 --- a/source/blender/gpu/intern/gpu_select.c +++ b/source/blender/gpu/intern/gpu_select.c @@ -69,7 +69,8 @@ static GPUSelectState g_select_state = {0}; void GPU_select_begin(uint *buffer, uint bufsize, const rcti *input, char mode, int oldhits) { if (mode == GPU_SELECT_NEAREST_SECOND_PASS) { - /* In the case hits was '-1', don't start the second pass since it's not going to give useful results. + /* In the case hits was '-1', + * don't start the second pass since it's not going to give useful results. * As well as buffer overflow in 'gpu_select_query_load_id'. */ BLI_assert(oldhits != -1); } @@ -99,7 +100,8 @@ void GPU_select_begin(uint *buffer, uint bufsize, const rcti *input, char mode, } /** - * loads a new selection id and ends previous query, if any. In second pass of selection it also returns + * loads a new selection id and ends previous query, if any. + * In second pass of selection it also returns * if id has been hit on the first pass already. * Thus we can skip drawing un-hit objects. * diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index 253c8703234..6c3e05912b0 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -318,7 +318,8 @@ void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, c if (mode == GPU_SELECT_PICK_ALL) { /* Note that other depth settings (such as #GL_LEQUAL) work too, * since the depth is always cleared. - * Noting this for cases when depth picking is used where drawing calls change depth settings. */ + * Noting this for cases when depth picking is used where + * drawing calls change depth settings. */ glDepthFunc(GL_ALWAYS); } else { diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index dd8035e2618..5fe23824ce2 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -557,10 +557,10 @@ static const char *string_join_array_maybe_alloc(const char **str_arr, bool *r_i * Example: * \code{.c} * sh = GPU_shader_create_from_arrays({ - * .vert = (const char *[]){shader_lib_glsl, shader_vert_glsl, NULL}, - * .geom = (const char *[]){shader_geom_glsl, NULL}, - * .frag = (const char *[]){shader_frag_glsl, NULL}, - * .defs = (const char *[]){"#define DEFINE\n", test ? "#define OTHER_DEFINE\n" : "", NULL}, + * .vert = (const char *[]){shader_lib_glsl, shader_vert_glsl, NULL}, + * .geom = (const char *[]){shader_geom_glsl, NULL}, + * .frag = (const char *[]){shader_frag_glsl, NULL}, + * .defs = (const char *[]){"#define DEFINE\n", test ? "#define OTHER_DEFINE\n" : "", NULL}, * }); * \endcode */ @@ -1297,7 +1297,8 @@ GPUShader *GPU_shader_get_builtin_shader_with_config(eGPUBuiltinShader shader, } } else if (shader == GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR) { - /* Dashed need geometry shader, which are not supported by legacy OpenGL, fallback to solid lines. */ + /* Dashed need geometry shader, which are not supported by legacy OpenGL, + * fallback to solid lines. */ /* TODO: remove after switch to core profile (maybe) */ if (!GLEW_VERSION_3_2) { stages_legacy.vert = datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl; diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index afe5e381334..e1a4357467c 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -43,8 +43,8 @@ #include "gpu_context_private.h" static struct GPUTextureGlobal { - GPUTexture * - invalid_tex_1D; /* texture used in place of invalid textures (not loaded correctly, missing) */ + /** Texture used in place of invalid textures (not loaded correctly, missing). */ + GPUTexture *invalid_tex_1D; GPUTexture *invalid_tex_2D; GPUTexture *invalid_tex_3D; } GG = {NULL, NULL, NULL}; @@ -1598,7 +1598,8 @@ void GPU_texture_generate_mipmap(GPUTexture *tex) if (GPU_texture_depth(tex)) { /* Some drivers have bugs when using glGenerateMipmap with depth textures (see T56789). * In this case we just create a complete texture with mipmaps manually without downsampling. - * You must initialize the texture levels using other methods like GPU_framebuffer_recursive_downsample(). */ + * You must initialize the texture levels using other methods like + * GPU_framebuffer_recursive_downsample(). */ int levels = 1 + floor(log2(max_ii(tex->w, tex->h))); eGPUDataFormat data_format = gpu_get_data_format_from_tex_format(tex->format); for (int i = 1; i < levels; ++i) { diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c index 74c2959ee00..b57be9fdf37 100644 --- a/source/blender/gpu/intern/gpu_viewport.c +++ b/source/blender/gpu/intern/gpu_viewport.c @@ -265,7 +265,8 @@ void GPU_viewport_size_get(const GPUViewport *viewport, int size[2]) /** * Special case, this is needed for when we have a viewport without a frame-buffer output - * (occlusion queries for eg) but still need to set the size since it may be used for other calculations. + * (occlusion queries for eg) + * but still need to set the size since it may be used for other calculations. */ void GPU_viewport_size_set(GPUViewport *viewport, const int size[2]) { diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl index 185a4c8c59f..a29335046f2 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl @@ -1,6 +1,7 @@ /* - * Fragment Shader for dashed lines, with uniform multi-color(s), or any single-color, and any thickness. + * Fragment Shader for dashed lines, with uniform multi-color(s), + * or any single-color, and any thickness. * * Dashed is performed in screen space. */ @@ -10,7 +11,8 @@ uniform float dash_width; /* Simple mode, discarding non-dash parts (so no need for blending at all). */ uniform float dash_factor; /* if > 1.0, solid line. */ -/* More advanced mode, allowing for complex, multi-colored patterns. Enabled when colors_len > 0. */ +/* More advanced mode, allowing for complex, multi-colored patterns. + * Enabled when colors_len > 0. */ /* Note: max number of steps/colors in pattern is 32! */ uniform int colors_len; /* Enabled if > 0, 1 for solid line. */ uniform vec4 colors[32]; diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl index 11f67172e89..584a179a9ac 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_geom.glsl @@ -1,6 +1,7 @@ /* - * Geometry Shader for dashed lines, with uniform multi-color(s), or any single-color, and unary thickness. + * Geometry Shader for dashed lines, with uniform multi-color(s), + * or any single-color, and unary thickness. * * Dashed is performed in screen space. */ @@ -9,7 +10,8 @@ uniform mat4 ModelViewProjectionMatrix; uniform vec2 viewport_size; -/* Uniforms from fragment shader, used here to optimize out useless computation in case of solid line. */ +/* Uniforms from fragment shader, + * used here to optimize out useless computation in case of solid line. */ uniform float dash_factor; /* if > 1.0, solid line. */ uniform int colors_len; /* Enabled if > 0, 1 for solid line. */ @@ -58,6 +60,6 @@ void main() EndPrimitive(); - /* Note: we could also use similar approach as diag_stripes_frag, but this would give us dashed 'anchored' - * to the screen, and not to one end of the line... */ + /* Note: we could also use similar approach as diag_stripes_frag, + * but this would give us dashed 'anchored' to the screen, and not to one end of the line... */ } diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl index 933a0976c6e..8b5a5cd8c9a 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl @@ -1,7 +1,7 @@ /* - * Vertex Shader for dashed lines with 2D coordinates, with uniform multi-colors or uniform single-color, - * and unary thickness. + * Vertex Shader for dashed lines with 2D coordinates, + * with uniform multi-colors or uniform single-color, and unary thickness. * * Dashed is performed in screen space. */ diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl index 434917f8052..336f310837e 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_width_geom.glsl @@ -8,7 +8,8 @@ uniform vec2 viewport_size; /* Width of the generated 'line'. */ uniform float width; /* in pixels, screen space. */ -/* Uniforms from fragment shader, used here to optimize out useless computation in case of solid line. */ +/* Uniforms from fragment shader, + * used here to optimize out useless computation in case of solid line. */ uniform float dash_factor; /* if > 1.0, solid line. */ uniform int colors_len; /* Enabled if > 0, 1 for solid line. */ diff --git a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl index 9fe63c65054..28c91343771 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_legacy_vert.glsl @@ -1,7 +1,7 @@ /* - * Vertex Shader for dashed lines with 3D coordinates, with uniform multi-colors or uniform single-color, - * and unary thickness. + * Vertex Shader for dashed lines with 3D coordinates, + * with uniform multi-colors or uniform single-color, and unary thickness. * * Legacy version, without geometry shader support, always produce solid lines! */ @@ -19,7 +19,8 @@ void main() { gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); - /* Hack - prevent stupid GLSL compiler to optimize out unused viewport_size uniform, which gives crash! */ + /* Hack - prevent stupid GLSL compiler to optimize out unused viewport_size uniform, + * which gives crash! */ distance_along_line = viewport_size.x * 0.000001f - viewport_size.x * 0.0000009f; color_geom = color; diff --git a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl index 47ca09b5e72..7c317ecfb8c 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl @@ -1,7 +1,7 @@ /* - * Vertex Shader for dashed lines with 3D coordinates, with uniform multi-colors or uniform single-color, - * and unary thickness. + * Vertex Shader for dashed lines with 3D coordinates, + * with uniform multi-colors or uniform single-color, and unary thickness. * * Dashed is performed in screen space. */ diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 545629dbfa0..6ad93e88130 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -1190,7 +1190,8 @@ void convert_metallic_to_specular_tinted(vec3 basecol, vec3 principled_sheen(float NV, vec3 basecol_tint, float sheen_tint) { float f = 1.0 - NV; - /* Temporary fix for T59784. Normal map seems to contain NaNs for tangent space normal maps, therefore we need to clamp value. */ + /* Temporary fix for T59784. Normal map seems to contain NaNs for tangent space normal maps, + * therefore we need to clamp value. */ f = clamp(f, 0.0, 1.0); /* Empirical approximation (manual curve fitting). Can be refined. */ float sheen = f * f * f * 0.077 + f * 0.01 + 0.00026; -- cgit v1.2.3