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
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-11-02 16:58:49 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-02 17:45:13 +0300
commit721a19d2b8a7784c48c753d57dfbf984524a54de (patch)
tree0be919eabfa00b65ad70a5bdea11d9676e31c9cb /source/blender/gpu
parent00ef0a4d8efc783e93d2e524d3a9d59a0230704f (diff)
GPU: Add safety check for max line width
On some platform does not support line width > 1.0 and can even throw and error. Better check an at least display something rather than no lines at all.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_extensions.h1
-rw-r--r--source/blender/gpu/intern/gpu_extensions.c8
-rw-r--r--source/blender/gpu/intern/gpu_state.c9
3 files changed, 17 insertions, 1 deletions
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h
index 805023e31df..07d8a5f8c8b 100644
--- a/source/blender/gpu/GPU_extensions.h
+++ b/source/blender/gpu/GPU_extensions.h
@@ -49,6 +49,7 @@ int GPU_max_color_texture_samples(void);
int GPU_max_cube_map_size(void);
int GPU_max_ubo_binds(void);
int GPU_max_ubo_size(void);
+float GPU_max_line_width(void);
int GPU_color_depth(void);
void GPU_get_dfdy_factors(float fac[2]);
bool GPU_mip_render_workaround(void);
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c
index 36e69f96b78..2237a6ea49c 100644
--- a/source/blender/gpu/intern/gpu_extensions.c
+++ b/source/blender/gpu/intern/gpu_extensions.c
@@ -80,6 +80,7 @@ static struct GPUGlobal {
GPUDeviceType device;
GPUOSType os;
GPUDriverType driver;
+ float line_width_range[2];
/* workaround for different calculation of dfdy factors on GPUs. Some GPUs/drivers
* calculate dfdy in shader differently when drawing to an offscreen buffer. First
* number is factor on screen and second is off-screen */
@@ -190,6 +191,11 @@ int GPU_max_ubo_size(void)
return GG.maxubosize;
}
+float GPU_max_line_width(void)
+{
+ return GG.line_width_range[1];
+}
+
void GPU_get_dfdy_factors(float fac[2])
{
copy_v2_v2(fac, GG.dfdyfactors);
@@ -230,6 +236,8 @@ void gpu_extensions_init(void)
glGetIntegerv(GL_MAX_FRAGMENT_UNIFORM_BLOCKS, &GG.maxubobinds);
glGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &GG.maxubosize);
+ glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE, GG.line_width_range);
+
#ifndef NDEBUG
GLint ret;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c
index 0f07b2debc3..afc8570356b 100644
--- a/source/blender/gpu/intern/gpu_state.c
+++ b/source/blender/gpu/intern/gpu_state.c
@@ -29,6 +29,7 @@
#include "GPU_glew.h"
#include "GPU_state.h"
+#include "GPU_extensions.h"
static GLenum gpu_get_gl_blendfunction(GPUBlendFunction blend)
{
@@ -118,7 +119,13 @@ void GPU_line_stipple(bool enable)
void GPU_line_width(float width)
{
- glLineWidth(width * U.pixelsize);
+ float max_size = GPU_max_line_width();
+ float final_size = width * U.pixelsize;
+ /* Fix opengl errors on certain platform / drivers. */
+ if (max_size < final_size) {
+ final_size = max_size;
+ }
+ glLineWidth(final_size);
}
void GPU_point_size(float size)