diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-07-16 05:16:10 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-07-16 19:01:44 +0300 |
commit | 5099cbeec9c481600e359e95a806a3393ba4ab0d (patch) | |
tree | aa20597f4760b5f1b77356e30e90ce6a5c914874 /source/blender/gpu | |
parent | 436d38bb548d904200337d58720552b6f78555cb (diff) |
Cleanup: GPU: Move depth/color masks functions to GPU_state
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_state.h | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_pick.c | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select_sample_query.c | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_state.c | 22 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_viewport.c | 8 |
5 files changed, 34 insertions, 8 deletions
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h index 6c0c4897fef..bdff3e66217 100644 --- a/source/blender/gpu/GPU_state.h +++ b/source/blender/gpu/GPU_state.h @@ -65,6 +65,10 @@ void GPU_scissor_get_f(float coords[4]); void GPU_scissor_get_i(int coords[4]); void GPU_viewport_size_get_f(float coords[4]); void GPU_viewport_size_get_i(int coords[4]); +void GPU_color_mask(bool r, bool g, bool b, bool a); +void GPU_depth_mask(bool depth); +bool GPU_depth_mask_get(void); +void GPU_stencil_mask(uint stencil); void GPU_flush(void); void GPU_finish(void); diff --git a/source/blender/gpu/intern/gpu_select_pick.c b/source/blender/gpu/intern/gpu_select_pick.c index 4b38cd333a1..3e5fc1ab19e 100644 --- a/source/blender/gpu/intern/gpu_select_pick.c +++ b/source/blender/gpu/intern/gpu_select_pick.c @@ -310,7 +310,7 @@ void gpu_select_pick_begin(uint (*buffer)[4], uint bufsize, const rcti *input, c gpuPushAttr(GPU_DEPTH_BUFFER_BIT | GPU_VIEWPORT_BIT); /* disable writing to the framebuffer */ - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + GPU_color_mask(false, false, false, false); glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); @@ -539,7 +539,7 @@ uint gpu_select_pick_end(void) gpu_select_pick_load_id(ps->gl.prev_id, true); } gpuPopAttr(); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + GPU_color_mask(true, true, true, true); } /* assign but never free directly since it may be in cache */ diff --git a/source/blender/gpu/intern/gpu_select_sample_query.c b/source/blender/gpu/intern/gpu_select_sample_query.c index c82d1e17c66..b20b6cac36b 100644 --- a/source/blender/gpu/intern/gpu_select_sample_query.c +++ b/source/blender/gpu/intern/gpu_select_sample_query.c @@ -88,7 +88,7 @@ void gpu_select_query_begin( gpuPushAttr(GPU_DEPTH_BUFFER_BIT | GPU_VIEWPORT_BIT | GPU_SCISSOR_BIT); /* disable writing to the framebuffer */ - glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + GPU_color_mask(false, false, false, false); /* In order to save some fill rate we minimize the viewport using rect. * We need to get the region of the viewport so that our geometry doesn't @@ -206,7 +206,7 @@ uint gpu_select_query_end(void) MEM_freeN(g_query_state.queries); MEM_freeN(g_query_state.id); gpuPopAttr(); - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + GPU_color_mask(true, true, true, true); return hits; } diff --git a/source/blender/gpu/intern/gpu_state.c b/source/blender/gpu/intern/gpu_state.c index 65acd5a7771..636a5e2c31d 100644 --- a/source/blender/gpu/intern/gpu_state.c +++ b/source/blender/gpu/intern/gpu_state.c @@ -192,6 +192,28 @@ void GPU_logic_op_xor_set(bool enable) } } +void GPU_color_mask(bool r, bool g, bool b, bool a) +{ + glColorMask(r, g, b, a); +} + +void GPU_depth_mask(bool depth) +{ + glDepthMask(depth); +} + +bool GPU_depth_mask_get(void) +{ + GLint mask; + glGetIntegerv(GL_DEPTH_WRITEMASK, &mask); + return mask == GL_TRUE; +} + +void GPU_stencil_mask(uint stencil) +{ + glStencilMask(stencil); +} + /** \name GPU Push/Pop State * \{ */ diff --git a/source/blender/gpu/intern/gpu_viewport.c b/source/blender/gpu/intern/gpu_viewport.c index 753da8544ea..4d31366f53f 100644 --- a/source/blender/gpu/intern/gpu_viewport.c +++ b/source/blender/gpu/intern/gpu_viewport.c @@ -630,13 +630,13 @@ void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo if (settings == S3D_DISPLAY_ANAGLYPH) { switch (stereo_format->anaglyph_type) { case S3D_ANAGLYPH_REDCYAN: - glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE); + GPU_color_mask(false, true, true, true); break; case S3D_ANAGLYPH_GREENMAGENTA: - glColorMask(GL_TRUE, GL_FALSE, GL_TRUE, GL_TRUE); + GPU_color_mask(true, false, true, true); break; case S3D_ANAGLYPH_YELLOWBLUE: - glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE); + GPU_color_mask(false, false, true, true); break; } } @@ -666,7 +666,7 @@ void GPU_viewport_stereo_composite(GPUViewport *viewport, Stereo3dFormat *stereo GPU_matrix_pop(); if (settings == S3D_DISPLAY_ANAGLYPH) { - glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + GPU_color_mask(true, true, true, true); } GPU_framebuffer_restore(); |