Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-04-16 23:53:44 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-04-16 23:53:44 +0300
commitf92e92b1c041582f5d31620f734951daeee3d552 (patch)
tree2f44aac606268ab1d7543b62279a310838ee34c6 /source
parentaf1c220d892160c3a133b0379b123c672a770b73 (diff)
Object Mode: Outlines: Use textureGather extension if available.
This has very little impact (only had 12.5% perf improvment on Nvidia for this specific pass). But it's an improvement nontheless!
Diffstat (limited to 'source')
-rw-r--r--source/blender/draw/modes/object_mode.c2
-rw-r--r--source/blender/draw/modes/shaders/object_outline_detect_frag.glsl29
2 files changed, 17 insertions, 14 deletions
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 0d9e46d1268..4bdd1444898 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -346,7 +346,7 @@ static void OBJECT_engine_init(void *vedata)
datatoc_common_fullscreen_vert_glsl, NULL,
datatoc_object_outline_detect_frag_glsl,
datatoc_common_globals_lib_glsl,
- NULL);
+ "#extension GL_ARB_texture_gather : enable\n");
e_data.outline_fade_sh = DRW_shader_create_fullscreen(datatoc_object_outline_expand_frag_glsl, NULL);
diff --git a/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl b/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
index 6b0f66d7c94..a7e68485b86 100644
--- a/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
+++ b/source/blender/draw/modes/shaders/object_outline_detect_frag.glsl
@@ -34,25 +34,28 @@ vec4 convert_id_to_color(int id)
}
}
-const ivec2 ofs[4] = ivec2[4](
- ivec2( 1, 0), ivec2( 0, 1),
- ivec2(-1, 0), ivec2( 0, -1)
-);
-
void main()
{
ivec2 texel = ivec2(gl_FragCoord.xy);
- vec2 uv = gl_FragCoord.xy / vec2(textureSize(outlineId, 0).xy);
+#ifdef GL_ARB_texture_gather
+ vec2 texel_size = 1.0 / vec2(textureSize(outlineId, 0).xy);
+ vec2 uv1 = gl_FragCoord.xy * texel_size - texel_size;
+ vec2 uv2 = gl_FragCoord.xy * texel_size;
+
+ /* Samples order is CW starting from top left. */
+ uvec4 tmp1 = textureGather(outlineId, uv1);
+ uvec4 tmp2 = textureGather(outlineId, uv2);
+
+ uint ref_id = tmp1.y;
+ uvec4 id = uvec4(tmp1.xz, tmp2.xz);
+#else
uvec4 id;
uint ref_id = texelFetch(outlineId, texel, 0).r;
-#if 0 /* commented out until being tested */
- id = textureGatherOffsets(outlineId, uv, ofs);
-#else
- id.x = texelFetchOffset(outlineId, texel, 0, ofs[0]).r;
- id.y = texelFetchOffset(outlineId, texel, 0, ofs[1]).r;
- id.z = texelFetchOffset(outlineId, texel, 0, ofs[2]).r;
- id.w = texelFetchOffset(outlineId, texel, 0, ofs[3]).r;
+ id.x = texelFetchOffset(outlineId, texel, 0, ivec2( 1, 0)).r;
+ id.y = texelFetchOffset(outlineId, texel, 0, ivec2( 0, 1)).r;
+ id.z = texelFetchOffset(outlineId, texel, 0, ivec2(-1, 0)).r;
+ id.w = texelFetchOffset(outlineId, texel, 0, ivec2( 0, -1)).r;
#endif
float ref_depth = texelFetch(outlineDepth, texel, 0).r;