diff options
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/intern/gpu_select.c | 44 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_pick.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_create_info.cc | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_create_info.hh | 5 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_backend.cc | 2 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_shader.cc | 5 |
6 files changed, 44 insertions, 16 deletions
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c index aadb52fb49c..958aab65b57 100644 --- a/source/blender/gpu/intern/gpu_select.c +++ b/source/blender/gpu/intern/gpu_select.c @@ -61,6 +61,15 @@ typedef struct GPUSelectState { char algorithm; /* allow GPU_select_begin/end without drawing */ bool use_cache; + /** + * Signifies that #GPU_select_cache_begin has been called, + * future calls to #GPU_select_begin should initialize the cache. + * + * \note #GPU_select_cache_begin could perform initialization but doesn't as it's inconvenient + * for callers making the cache begin/end calls outside lower level selection logic + * where the `mode` to pass to #GPU_select_begin yet isn't known. + */ + bool use_cache_needs_init; } GPUSelectState; static GPUSelectState g_select_state = {0}; @@ -90,9 +99,26 @@ void GPU_select_begin(uint *buffer, uint bufsize, const rcti *input, char mode, g_select_state.algorithm = ALGO_GL_QUERY; } + /* This function is called when cache has already been initialized, + * so only manipulate cache values when cache is pending. */ + if (g_select_state.use_cache_needs_init) { + g_select_state.use_cache_needs_init = false; + + switch (g_select_state.algorithm) { + case ALGO_GL_QUERY: { + g_select_state.use_cache = false; + break; + } + default: { + g_select_state.use_cache = true; + gpu_select_pick_cache_begin(); + break; + } + } + } + switch (g_select_state.algorithm) { case ALGO_GL_QUERY: { - g_select_state.use_cache = false; gpu_select_query_begin((uint(*)[4])buffer, bufsize / 4, input, mode, oldhits); break; } @@ -154,12 +180,13 @@ uint GPU_select_end(void) void GPU_select_cache_begin(void) { - /* validate on GPU_select_begin, clear if not supported */ - BLI_assert(g_select_state.use_cache == false); - g_select_state.use_cache = true; - if (g_select_state.algorithm == ALGO_GL_PICK) { - gpu_select_pick_cache_begin(); - } + BLI_assert(g_select_state.select_is_active == false); + /* Ensure #GPU_select_cache_end is always called. */ + BLI_assert(g_select_state.use_cache_needs_init == false); + + /* Signal that cache should be used, instead of calling the algorithms cache-begin function. + * This is more convenient as the exact method of selection may not be known by the caller. */ + g_select_state.use_cache_needs_init = true; } void GPU_select_cache_load_id(void) @@ -173,9 +200,12 @@ void GPU_select_cache_load_id(void) void GPU_select_cache_end(void) { if (g_select_state.algorithm == ALGO_GL_PICK) { + BLI_assert(g_select_state.use_cache == true); gpu_select_pick_cache_end(); } g_select_state.use_cache = false; + /* Paranoid assignment, should already be false. */ + g_select_state.use_cache_needs_init = false; } bool GPU_select_is_cached(void) diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index 737e4c6e874..ddd3dfc6879 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -673,7 +673,7 @@ uint gpu_select_pick_end(void) #endif /* first 3 are dummy values */ g_pick_state.buffer[hits][0] = 1; - g_pick_state.buffer[hits][1] = 0x0; /* depth_data[i].depth; */ /* unused */ + g_pick_state.buffer[hits][1] = depth_data[i].depth; g_pick_state.buffer[hits][2] = 0x0; /* z-far is currently never used. */ g_pick_state.buffer[hits][3] = depth_data[i].id; hits++; diff --git a/source/blender/gpu/intern/gpu_shader_create_info.cc b/source/blender/gpu/intern/gpu_shader_create_info.cc index e245d9b5269..f7622751726 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.cc +++ b/source/blender/gpu/intern/gpu_shader_create_info.cc @@ -112,7 +112,7 @@ void ShaderCreateInfo::finalize() void ShaderCreateInfo::validate(const ShaderCreateInfo &other_info) { { - /* Check same bindpoints usage in OGL. */ + /* Check same bind-points usage in OGL. */ Set<int> images, samplers, ubos, ssbos; auto register_resource = [&](const Resource &res) -> bool { diff --git a/source/blender/gpu/intern/gpu_shader_create_info.hh b/source/blender/gpu/intern/gpu_shader_create_info.hh index 391752a31a8..6236e92a226 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.hh +++ b/source/blender/gpu/intern/gpu_shader_create_info.hh @@ -63,7 +63,10 @@ enum class Type { }; enum class BuiltinBits { - /** Allow getting barycentic coordinates inside the fragment shader. NOTE: emulated on OpenGL. */ + /** + * Allow getting barycentric coordinates inside the fragment shader. + * \note Emulated on OpenGL. + */ BARYCENTRIC_COORD = (1 << 0), FRAG_COORD = (1 << 2), FRONT_FACING = (1 << 4), diff --git a/source/blender/gpu/opengl/gl_backend.cc b/source/blender/gpu/opengl/gl_backend.cc index c32123bc15e..92d180f1140 100644 --- a/source/blender/gpu/opengl/gl_backend.cc +++ b/source/blender/gpu/opengl/gl_backend.cc @@ -423,7 +423,7 @@ static void detect_workarounds() /* Buggy interface query functions cause crashes when handling SSBOs (T93680) */ if (GPU_type_matches(GPU_DEVICE_INTEL, GPU_OS_ANY, GPU_DRIVER_ANY) && - (strstr(renderer, "HD Graphics 4400")|| strstr(renderer, "HD Graphics 4600"))) { + (strstr(renderer, "HD Graphics 4400") || strstr(renderer, "HD Graphics 4600"))) { GCaps.shader_storage_buffer_objects_support = false; } } // namespace blender::gpu diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc index 0d4f1d15f39..1e6e2475665 100644 --- a/source/blender/gpu/opengl/gl_shader.cc +++ b/source/blender/gpu/opengl/gl_shader.cc @@ -601,11 +601,6 @@ static char *glsl_patch_default_get() STR_CONCAT(patch, slen, "#extension GL_ARB_shading_language_420pack: enable\n"); } - if (!GLContext::shader_draw_parameters_support) { - /* Fallback: Emulate base instance using a uniform. */ - STR_CONCAT(patch, slen, "uniform int gpu_BaseInstance;\n"); - } - /* Fallbacks. */ if (!GLContext::shader_draw_parameters_support) { STR_CONCAT(patch, slen, "uniform int gpu_BaseInstance;\n"); |