diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2019-07-15 19:24:07 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2019-07-15 19:24:07 +0300 |
commit | 0a964a62b2088753e13f699e0a71703ad5932b9a (patch) | |
tree | f7a5976f0294520b18148937971afe6f00cdecbe /source/blender/gpu | |
parent | cf701b0d2a427164649c0ba48921e0b535f4601a (diff) | |
parent | 9cdd2df277b3b9b2949aee4f869b276f79ca17f4 (diff) |
Merge branch 'master' into sculpt-mode-features
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_state.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/GPU_vertex_format.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_buffers.c | 8 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 3 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_element.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 8 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_framebuffer.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_matrix.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_sample_query.c | 13 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_interface.c | 6 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_state.c | 14 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_texture.c | 7 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_vertex_format.c | 5 | ||||
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_gpencil_fill_frag.glsl | 20 | ||||
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 2 |
15 files changed, 63 insertions, 33 deletions
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h index 7b970786e5e..efea02eb5a4 100644 --- a/source/blender/gpu/GPU_state.h +++ b/source/blender/gpu/GPU_state.h @@ -59,4 +59,6 @@ void GPU_viewport_size_get_i(int coords[4]); void GPU_flush(void); void GPU_finish(void); +void GPU_logic_op_invert_set(bool enable); + #endif /* __GPU_STATE_H__ */ diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h index 43eec55bca2..68608a98a79 100644 --- a/source/blender/gpu/GPU_vertex_format.h +++ b/source/blender/gpu/GPU_vertex_format.h @@ -31,7 +31,7 @@ #include "BLI_assert.h" #define GPU_VERT_ATTR_MAX_LEN 16 -#define GPU_VERT_ATTR_MAX_NAMES 4 +#define GPU_VERT_ATTR_MAX_NAMES 5 #define GPU_VERT_ATTR_NAME_AVERAGE_LEN 11 #define GPU_VERT_ATTR_NAMES_BUF_LEN ((GPU_VERT_ATTR_NAME_AVERAGE_LEN + 1) * GPU_VERT_ATTR_MAX_LEN) diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 566a5ff3b16..a1c4ff8eceb 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -387,6 +387,7 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3], /* Fill the only the line buffer. */ GPUIndexBufBuilder elb_lines; GPU_indexbuf_init(&elb_lines, GPU_PRIM_LINES, tottri * 3, INT_MAX); + int vert_idx = 0; for (i = 0; i < face_indices_len; ++i) { const MLoopTri *lt = &looptri[face_indices[i]]; @@ -397,9 +398,10 @@ GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3], } /* TODO skip "non-real" edges. */ - GPU_indexbuf_add_line_verts(&elb_lines, i * 3 + 0, i * 3 + 1); - GPU_indexbuf_add_line_verts(&elb_lines, i * 3 + 1, i * 3 + 2); - GPU_indexbuf_add_line_verts(&elb_lines, i * 3 + 2, i * 3 + 0); + GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 0, vert_idx * 3 + 1); + GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 1, vert_idx * 3 + 2); + GPU_indexbuf_add_line_verts(&elb_lines, vert_idx * 3 + 2, vert_idx * 3 + 0); + vert_idx++; } buffers->index_lines_buf = GPU_indexbuf_build(&elb_lines); } diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index d1d5e1d89a2..be3655648f5 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -475,6 +475,9 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget ima->gpuflag &= ~IMA_GPU_REFRESH; } + /* Tag as in active use for garbage collector. */ + BKE_image_tag_time(ima); + /* Test if we already have a texture. */ GPUTexture **tex = gpu_get_image_gputexture(ima, textarget); if (*tex) { diff --git a/source/blender/gpu/intern/gpu_element.c b/source/blender/gpu/intern/gpu_element.c index 380de4c4e65..50e7df96503 100644 --- a/source/blender/gpu/intern/gpu_element.c +++ b/source/blender/gpu/intern/gpu_element.c @@ -204,7 +204,7 @@ static void squeeze_indices_short(GPUIndexBufBuilder *builder, * converting in place to avoid extra allocation */ GLushort *data = (GLushort *)builder->data; - if (max_index > 0xFFFF) { + if (max_index >= 0xFFFF) { elem->base_index = min_index; for (uint i = 0; i < index_len; ++i) { data[i] = (values[i] == RESTART_INDEX) ? 0xFFFF : (GLushort)(values[i] - min_index); diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 58efe3dc5c4..6e387799060 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -378,7 +378,13 @@ void gpu_extensions_init(void) GG.dfdyfactors[1] = 1.0; } - if (strstr(renderer, "HD Graphics 4000")) { + if (strstr(version, "Build 10.18.10.3574") || + strstr(version, "Build 10.18.10.4252") || + strstr(version, "Build 10.18.10.4358") || + strstr(version, "Build 10.18.10.5069") || + strstr(version, "Build 10.18.14.4264") || + strstr(version, "Build 10.18.14.4432") || + strstr(version, "Build 10.18.14.5067")) { GG.context_local_shaders_workaround = true; } } diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c index cd63355ff51..7d096058e4c 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.c +++ b/source/blender/gpu/intern/gpu_framebuffer.c @@ -837,7 +837,7 @@ static GPUFrameBuffer *gpu_offscreen_fb_get(GPUOffScreen *ofs) /* List is full, this should never happen or * it might just slow things down if it happens - * regulary. In this case we just empty the list + * regularly. In this case we just empty the list * and start over. This is most likely never going * to happen under normal usage. */ BLI_assert(0); diff --git a/source/blender/gpu/intern/gpu_matrix.c b/source/blender/gpu/intern/gpu_matrix.c index 858afdc534e..58ca800a92c 100644 --- a/source/blender/gpu/intern/gpu_matrix.c +++ b/source/blender/gpu/intern/gpu_matrix.c @@ -5,7 +5,7 @@ * 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 ipmlied warranty of + * 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. * diff --git a/source/blender/gpu/intern/gpu_select_sample_query.c b/source/blender/gpu/intern/gpu_select_sample_query.c index 56f9ef69221..beea25b4171 100644 --- a/source/blender/gpu/intern/gpu_select_sample_query.c +++ b/source/blender/gpu/intern/gpu_select_sample_query.c @@ -40,6 +40,8 @@ #include "PIL_time.h" +#include "BKE_global.h" + #include "gpu_select_private.h" /* Ad hoc number of queries to allocate to skip doing many glGenQueries */ @@ -173,15 +175,8 @@ uint gpu_select_query_end(void) for (i = 0; i < g_query_state.active_query; i++) { uint result = 0; - /* Wait until the result is available. */ - while (result == 0) { - glGetQueryObjectuiv(g_query_state.queries[i], GL_QUERY_RESULT_AVAILABLE, &result); - if (result == 0) { - /* (fclem) Not sure if this is better than calling - * glGetQueryObjectuiv() indefinitely. */ - PIL_sleep_ms(1); - } - } + /* We are not using GL_QUERY_RESULT_AVAILABLE and sleep to wait for results, + * because it causes lagging on Windows/NVIDIA, see T61474. */ glGetQueryObjectuiv(g_query_state.queries[i], GL_QUERY_RESULT, &result); if (result > 0) { if (g_query_state.mode != GPU_SELECT_NEAREST_SECOND_PASS) { diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c index e7483e45312..e34c6e23024 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -180,10 +180,10 @@ static const GPUShaderInput *add_uniform(GPUShaderInterface *shaderface, const c input->location = glGetUniformLocation(shaderface->program, name); - uint name_len = strlen(name); + const uint name_len = strlen(name); + /* Include NULL terminator. */ shaderface->name_buffer = MEM_reallocN(shaderface->name_buffer, - shaderface->name_buffer_offset + name_len + - 1); /* include NULL terminator */ + shaderface->name_buffer_offset + name_len + 1); char *name_buffer = shaderface->name_buffer + shaderface->name_buffer_offset; strcpy(name_buffer, name); diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c index 7a27fea2f0d..caf97a620ab 100644 --- a/source/blender/gpu/intern/gpu_state.c +++ b/source/blender/gpu/intern/gpu_state.c @@ -175,3 +175,17 @@ void GPU_finish(void) { glFinish(); } + +void GPU_logic_op_invert_set(bool enable) +{ + if (enable) { + glLogicOp(GL_INVERT); + glEnable(GL_COLOR_LOGIC_OP); + glDisable(GL_DITHER); + } + else { + glLogicOp(GL_COPY); + glDisable(GL_COLOR_LOGIC_OP); + glEnable(GL_DITHER); + } +} diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index 6a92832d1e5..dab17fcd72a 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -505,7 +505,8 @@ static float *GPU_texture_rescale_3d( static bool gpu_texture_check_capacity( GPUTexture *tex, GLenum proxy, GLenum internalformat, GLenum data_format, GLenum data_type) { - if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_WIN, GPU_DRIVER_ANY)) { + if (GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_WIN, GPU_DRIVER_ANY) || + GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OFFICIAL)) { /* Some AMD drivers have a faulty `GL_PROXY_TEXTURE_..` check. * (see T55888, T56185, T59351). * Checking with `GL_PROXY_TEXTURE_..` doesn't prevent `Out Of Memory` issue, @@ -1459,7 +1460,9 @@ void *GPU_texture_read(GPUTexture *tex, eGPUDataFormat gpu_data_format, int mipl break; } - void *buf = MEM_mallocN(buf_size, "GPU_texture_read"); + /* AMD Pro driver have a bug that write 8 bytes past buffer size + * if the texture is big. (see T66573) */ + void *buf = MEM_mallocN(buf_size + 8, "GPU_texture_read"); GLenum data_format = gpu_get_gl_dataformat(tex->format, &tex->format_flag); GLenum data_type = gpu_get_gl_datatype(gpu_data_format); diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c index 37e1f9cf9da..e745c525df6 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.c +++ b/source/blender/gpu/intern/gpu_vertex_format.c @@ -365,6 +365,11 @@ void GPU_vertformat_from_interface(GPUVertFormat *format, const GPUShaderInterfa input = next; next = input->next; + /* OpenGL attributes such as `gl_VertexID` have a location of -1. */ + if (input->location < 0) { + continue; + } + format->name_len++; /* multiname support */ format->attr_len++; diff --git a/source/blender/gpu/shaders/gpu_shader_gpencil_fill_frag.glsl b/source/blender/gpu/shaders/gpu_shader_gpencil_fill_frag.glsl index 946fc752e17..56c9a2bd339 100644 --- a/source/blender/gpu/shaders/gpu_shader_gpencil_fill_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_gpencil_fill_frag.glsl @@ -22,7 +22,7 @@ uniform sampler2D myTexture; #define SOLID 0 #define GRADIENT 1 #define RADIAL 2 -#define CHESS 3 +#define CHECKER 3 #define TEXTURE 4 in vec2 texCoord_interp; @@ -104,7 +104,7 @@ void main() vec2 rot_tex = (matrot_tex * (texCoord_interp - t_center)) + t_center + t_offset; vec4 tmp_color = texture2D(myTexture, rot_tex * t_scale); vec4 text_color = vec4(tmp_color[0], tmp_color[1], tmp_color[2], tmp_color[3] * t_opacity); - vec4 chesscolor; + vec4 checker_color; /* solid fill */ if (fill_type == SOLID) { @@ -144,32 +144,32 @@ void main() } set_color(color, color2, text_color, mix_factor, intensity, t_mix, t_flip, fragColor); } - /* chessboard */ - if (fill_type == CHESS) { + /* Checkerboard */ + if (fill_type == CHECKER) { vec2 pos = rot / g_boxsize; if ((fract(pos.x) < 0.5 && fract(pos.y) < 0.5) || (fract(pos.x) > 0.5 && fract(pos.y) > 0.5)) { if (t_flip == 0) { - chesscolor = color; + checker_color = color; } else { - chesscolor = color2; + checker_color = color2; } } else { if (t_flip == 0) { - chesscolor = color2; + checker_color = color2; } else { - chesscolor = color; + checker_color = color; } } /* mix with texture */ if (t_mix == 1) { - fragColor = mix(chesscolor, text_color, mix_factor); + fragColor = mix(checker_color, text_color, mix_factor); } else { - fragColor = chesscolor; + fragColor = checker_color; } } /* texture */ diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 1750e124c29..6149409774a 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2224,7 +2224,7 @@ void node_tex_coord_background(vec3 I, generated = coords; normal = -coords; uv = vec3(attr_uv.xy, 0.0); - object = coords; + object = (obmatinv * vec4(coords, 1.0)).xyz; camera = vec3(co.xy, -co.z); window = vec3(mtex_2d_mapping(I).xy * camerafac.xy + camerafac.zw, 0.0); |