Fix T67951: Bone selection is broken on some Intel GPUs

The problem is that the `glDrawArraysInstancedBaseInstance` is ignoring the last parameter.
The solution is to indicate that `GLEW_ARB_base_instance` is not supported in these cases.

Reviewers: fclem, brecht, jbakker

Reviewed By: fclem, brecht

Differential Revision: https://developer.blender.org/D5383
This commit is contained in:
Germano Cavalcante 2019-07-31 16:35:06 -03:00
parent ea3690e329
commit d8fb63661b
Notes: blender-bot 2023-02-14 09:09:43 +01:00
Referenced by issue #67951, you cannot select bones individually
Referenced by issue #67645, Crash - Changing between Texture Paint and Edit
3 changed files with 17 additions and 3 deletions

View File

@ -43,6 +43,7 @@ int GPU_max_ubo_binds(void);
int GPU_max_ubo_size(void);
float GPU_max_line_width(void);
void GPU_get_dfdy_factors(float fac[2]);
bool GPU_arb_base_instance_is_supported(void);
bool GPU_mip_render_workaround(void);
bool GPU_depth_blitting_workaround(void);
bool GPU_unused_fb_slot_workaround(void);

View File

@ -28,6 +28,7 @@
#include "GPU_batch.h"
#include "GPU_batch_presets.h"
#include "GPU_extensions.h"
#include "GPU_matrix.h"
#include "GPU_shader.h"
@ -599,7 +600,7 @@ void GPU_batch_draw_advanced(GPUBatch *batch, int v_first, int v_count, int i_fi
i_count = (batch->inst) ? batch->inst->vertex_len : 1;
}
if (!GLEW_ARB_base_instance) {
if (!GPU_arb_base_instance_is_supported()) {
if (i_first > 0 && i_count > 0) {
/* If using offset drawing with instancing, we must
* use the default VAO and redo bindings. */
@ -624,7 +625,7 @@ void GPU_batch_draw_advanced(GPUBatch *batch, int v_first, int v_count, int i_fi
#endif
void *v_first_ofs = elem_offset(el, v_first);
if (GLEW_ARB_base_instance) {
if (GPU_arb_base_instance_is_supported()) {
glDrawElementsInstancedBaseVertexBaseInstance(
batch->gl_prim_type, v_count, index_type, v_first_ofs, i_count, base_index, i_first);
}
@ -637,7 +638,7 @@ void GPU_batch_draw_advanced(GPUBatch *batch, int v_first, int v_count, int i_fi
#ifdef __APPLE__
glDisable(GL_PRIMITIVE_RESTART);
#endif
if (GLEW_ARB_base_instance) {
if (GPU_arb_base_instance_is_supported()) {
glDrawArraysInstancedBaseInstance(batch->gl_prim_type, v_first, v_count, i_count, i_first);
}
else {

View File

@ -77,6 +77,9 @@ static struct GPUGlobal {
* number is factor on screen and second is off-screen */
float dfdyfactors[2];
float max_anisotropy;
/* Some Intel drivers have limited support for `GLEW_ARB_base_instance` so in
* these cases it is best to indicate that it is not supported. See T67951 */
bool glew_arb_base_instance_is_supported;
/* Some Intel drivers have issues with using mips as framebuffer targets if
* GL_TEXTURE_MAX_LEVEL is higher than the target mip.
* We need a workaround in this cases. */
@ -197,6 +200,11 @@ void GPU_get_dfdy_factors(float fac[2])
copy_v2_v2(fac, GG.dfdyfactors);
}
bool GPU_arb_base_instance_is_supported(void)
{
return GG.glew_arb_base_instance_is_supported;
}
bool GPU_mip_render_workaround(void)
{
return GG.mip_render_workaround;
@ -343,6 +351,7 @@ void gpu_extensions_init(void)
GG.os = GPU_OS_UNIX;
#endif
GG.glew_arb_base_instance_is_supported = GLEW_ARB_base_instance;
gpu_detect_mip_render_workaround();
if (G.debug & G_DEBUG_GPU_FORCE_WORKAROUNDS) {
@ -383,6 +392,9 @@ void gpu_extensions_init(void)
strstr(version, "Build 10.18.10.4653") || 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")) {
/* Maybe not all of these drivers have problems with `GLEW_ARB_base_instance`.
* But it's hard to test each case. */
GG.glew_arb_base_instance_is_supported = false;
GG.context_local_shaders_workaround = true;
}
}