diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-08-23 12:11:27 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-08-23 13:04:24 +0300 |
commit | f18e53745151eee946dcc01bc4b526994971daef (patch) | |
tree | 4694ed04ee9c9a4a509e6850ca1b65370c9a8444 /source/blender/gpu/intern | |
parent | 846cac94db56ec1a51dea9f9e6d3138840741952 (diff) |
Cleanup: GPU: Use explicit clear value in GPU_clear* commands
This replace `GPU_clear()` by `GPU_clear_color()` and `GPU_clear_depth()`.
Since we always set the clear value before clearing, it is unecessary
to track the clear color state.
Moreover, it makes it clearer what we clear the framebuffer to.
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_framebuffer.cc | 14 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_pick.c | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_sample_query.c | 2 |
3 files changed, 12 insertions, 8 deletions
diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc index 305113d909d..88013640bfc 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.cc +++ b/source/blender/gpu/intern/gpu_framebuffer.cc @@ -1117,18 +1117,22 @@ void GPU_offscreen_viewport_data_get(GPUOffScreen *ofs, void GPU_clear_color(float red, float green, float blue, float alpha) { + BLI_assert((GPU_write_mask_get() & GPU_WRITE_COLOR) != 0); + + GPU_context_active_get()->state_manager->apply_state(); + glClearColor(red, green, blue, alpha); + glClear(GL_COLOR_BUFFER_BIT); } void GPU_clear_depth(float depth) { - glClearDepth(depth); -} + BLI_assert((GPU_write_mask_get() & GPU_WRITE_DEPTH) != 0); -void GPU_clear(eGPUFrameBufferBits flags) -{ GPU_context_active_get()->state_manager->apply_state(); - glClear(convert_buffer_bits_to_gl(flags)); + + glClearDepth(depth); + glClear(GL_DEPTH_BUFFER_BIT); } void GPU_frontbuffer_read_pixels( diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index f7fd1faeb1e..5ee97134015 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -339,7 +339,7 @@ void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, c /* It's possible we don't want to clear depth buffer, * so existing elements are masked by current z-buffer. */ - GPU_clear(GPU_DEPTH_BIT); + GPU_clear_depth(1.0f); /* scratch buffer (read new values here) */ ps->gl.rect_depth_test = depth_buf_malloc(rect_len); @@ -519,7 +519,7 @@ bool gpu_select_pick_load_id(uint id, bool end) if (g_pick_state.mode == GPU_SELECT_PICK_ALL) { /* we want new depths every time */ - GPU_clear(GPU_DEPTH_BIT); + GPU_clear_depth(1.0f); } } } diff --git a/source/blender/gpu/intern/gpu_select_sample_query.c b/source/blender/gpu/intern/gpu_select_sample_query.c index 2ca5cf39a90..45d52b22664 100644 --- a/source/blender/gpu/intern/gpu_select_sample_query.c +++ b/source/blender/gpu/intern/gpu_select_sample_query.c @@ -122,7 +122,7 @@ void gpu_select_query_begin( else if (mode == GPU_SELECT_NEAREST_FIRST_PASS) { GPU_depth_test(GPU_DEPTH_LESS_EQUAL); GPU_depth_mask(true); - GPU_clear(GPU_DEPTH_BIT); + GPU_clear_depth(1.0f); } else if (mode == GPU_SELECT_NEAREST_SECOND_PASS) { GPU_depth_test(GPU_DEPTH_EQUAL); |