Cleanup: GPU: Move depth/color masks functions to GPU_state
This commit is contained in:
parent
436d38bb54
commit
5099cbeec9
@ -98,12 +98,7 @@ void drw_state_set(DRWState state)
|
||||
{
|
||||
int test;
|
||||
if ((test = CHANGED_TO(DRW_STATE_WRITE_DEPTH))) {
|
||||
if (test == 1) {
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
else {
|
||||
glDepthMask(GL_FALSE);
|
||||
}
|
||||
GPU_depth_mask(test == 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,10 +137,10 @@ void drw_state_set(DRWState state)
|
||||
int test;
|
||||
if ((test = CHANGED_TO(DRW_STATE_WRITE_COLOR))) {
|
||||
if (test == 1) {
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
GPU_color_mask(true, true, true, true);
|
||||
}
|
||||
else {
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
GPU_color_mask(false, false, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,9 +103,9 @@ void DRW_draw_cursor(void)
|
||||
Scene *scene = draw_ctx->scene;
|
||||
ViewLayer *view_layer = draw_ctx->view_layer;
|
||||
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDepthMask(GL_FALSE);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
GPU_color_mask(true, true, true, true);
|
||||
GPU_depth_mask(false);
|
||||
GPU_depth_test(false);
|
||||
|
||||
if (is_cursor_visible(draw_ctx, scene, view_layer)) {
|
||||
int co[2];
|
||||
@ -217,5 +217,5 @@ void DRW_draw_gizmo_2d(void)
|
||||
|
||||
WM_gizmomap_draw(region->gizmo_map, draw_ctx->evil_C, WM_GIZMOMAP_DRAWSTEP_2D);
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
GPU_depth_mask(true);
|
||||
}
|
||||
|
@ -555,11 +555,8 @@ static void annotation_draw_strokes(const bGPDframe *gpf,
|
||||
/* check which stroke-drawer to use */
|
||||
if (dflag & GP_DRAWDATA_ONLY3D) {
|
||||
const int no_xray = (dflag & GP_DRAWDATA_NO_XRAY);
|
||||
int mask_orig = 0;
|
||||
|
||||
if (no_xray) {
|
||||
glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
|
||||
glDepthMask(0);
|
||||
GPU_depth_test(true);
|
||||
|
||||
/* first arg is normally rv3d->dist, but this isn't
|
||||
@ -578,7 +575,6 @@ static void annotation_draw_strokes(const bGPDframe *gpf,
|
||||
}
|
||||
|
||||
if (no_xray) {
|
||||
glDepthMask(mask_orig);
|
||||
GPU_depth_test(false);
|
||||
|
||||
bglPolygonOffset(0.0, 0.0);
|
||||
@ -743,12 +739,18 @@ static void annotation_draw_data(
|
||||
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
||||
GPU_blend(true);
|
||||
|
||||
/* Do not write to depth (avoid self-occlusion). */
|
||||
bool prev_depth_mask = GPU_depth_mask_get();
|
||||
GPU_depth_mask(false);
|
||||
|
||||
/* draw! */
|
||||
annotation_draw_data_layers(gpd, offsx, offsy, winx, winy, cfra, dflag);
|
||||
|
||||
/* turn off alpha blending, then smooth lines */
|
||||
GPU_blend(false); // alpha blending
|
||||
GPU_line_smooth(false); // smooth lines
|
||||
|
||||
GPU_depth_mask(prev_depth_mask);
|
||||
}
|
||||
|
||||
/* if we have strokes for scenes (3d view)/clips (movie clip editor)
|
||||
|
@ -306,6 +306,10 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw)
|
||||
|
||||
GPU_program_point_size(true);
|
||||
|
||||
/* Do not write to depth (avoid self-occlusion). */
|
||||
bool prev_depth_mask = GPU_depth_mask_get();
|
||||
GPU_depth_mask(false);
|
||||
|
||||
bGPDstroke *gps_init = (tgpw->gps) ? tgpw->gps : tgpw->t_gpf->strokes.first;
|
||||
|
||||
for (bGPDstroke *gps = gps_init; gps; gps = gps->next) {
|
||||
@ -343,11 +347,8 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw)
|
||||
/* check which stroke-drawer to use */
|
||||
if (tgpw->dflag & GP_DRAWDATA_ONLY3D) {
|
||||
const int no_xray = (tgpw->dflag & GP_DRAWDATA_NO_XRAY);
|
||||
int mask_orig = 0;
|
||||
|
||||
if (no_xray) {
|
||||
glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
|
||||
glDepthMask(0);
|
||||
GPU_depth_test(true);
|
||||
|
||||
/* first arg is normally rv3d->dist, but this isn't
|
||||
@ -393,7 +394,6 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw)
|
||||
}
|
||||
}
|
||||
if (no_xray) {
|
||||
glDepthMask(mask_orig);
|
||||
GPU_depth_test(false);
|
||||
|
||||
bglPolygonOffset(0.0, 0.0);
|
||||
@ -405,6 +405,7 @@ static void gpencil_draw_strokes(tGPDdraw *tgpw)
|
||||
}
|
||||
}
|
||||
|
||||
GPU_depth_mask(prev_depth_mask);
|
||||
GPU_program_point_size(false);
|
||||
}
|
||||
|
||||
|
@ -638,8 +638,8 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
|
||||
if (load_tex(brush, vc, zoom, col, primary)) {
|
||||
GPU_blend(true);
|
||||
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDepthMask(GL_FALSE);
|
||||
GPU_color_mask(true, true, true, true);
|
||||
GPU_depth_mask(false);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
|
||||
if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) {
|
||||
@ -758,8 +758,8 @@ static bool paint_draw_cursor_overlay(
|
||||
float center[2];
|
||||
GPU_blend(true);
|
||||
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDepthMask(GL_FALSE);
|
||||
GPU_color_mask(true, true, true, true);
|
||||
GPU_depth_mask(false);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
|
||||
if (ups->draw_anchored) {
|
||||
|
@ -1085,7 +1085,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d)
|
||||
GPU_blend(true);
|
||||
GPU_blend_set_func_separate(
|
||||
GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
|
||||
glDepthMask(GL_FALSE); /* don't overwrite zbuf */
|
||||
GPU_depth_mask(false); /* don't overwrite zbuf */
|
||||
|
||||
GPUVertFormat *format = immVertexFormat();
|
||||
uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
|
||||
@ -1175,7 +1175,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d)
|
||||
immUnbindProgram();
|
||||
|
||||
GPU_blend(false);
|
||||
glDepthMask(GL_TRUE);
|
||||
GPU_depth_mask(true);
|
||||
}
|
||||
#endif /* WITH_INPUT_NDOF */
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
* \{ */
|
||||
|
||||
|
@ -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();
|
||||
|
@ -548,7 +548,7 @@ static void gizmo_draw_select_3d_loop(const bContext *C,
|
||||
/* pass */
|
||||
}
|
||||
else {
|
||||
glDepthMask(!is_depth_skip);
|
||||
GPU_depth_mask(!is_depth_skip);
|
||||
is_depth_skip_prev = is_depth_skip;
|
||||
}
|
||||
|
||||
@ -565,7 +565,7 @@ static void gizmo_draw_select_3d_loop(const bContext *C,
|
||||
GPU_depth_test(false);
|
||||
}
|
||||
if (is_depth_skip_prev) {
|
||||
glDepthMask(true);
|
||||
GPU_depth_mask(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user