DRW: Fix rasterizer discard messing with clear commands

Fixes T62179 Viewport Ghosting on rigs
This commit is contained in:
Clément Foucault 2019-03-05 16:42:18 +01:00
parent 4bc97db121
commit 81283b1c81
2 changed files with 11 additions and 8 deletions

View File

@ -306,6 +306,8 @@ typedef enum {
DRW_STATE_STENCIL_NEQUAL = (1 << 31),
} DRWState;
#define DRW_STATE_DEFAULT (DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL)
#define DRW_STATE_RASTERIZER_ENABLED (DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_STENCIL | \
DRW_STATE_WRITE_STENCIL_SHADOW_PASS | DRW_STATE_WRITE_STENCIL_SHADOW_FAIL)
typedef enum {
DRW_ATTR_INT,

View File

@ -97,15 +97,9 @@ void drw_state_set(DRWState state)
/* Raster Discard */
{
if (CHANGED_ANY(DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR |
DRW_STATE_WRITE_STENCIL |
DRW_STATE_WRITE_STENCIL_SHADOW_PASS |
DRW_STATE_WRITE_STENCIL_SHADOW_FAIL))
if (CHANGED_ANY(DRW_STATE_RASTERIZER_ENABLED))
{
if ((state & (DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR |
DRW_STATE_WRITE_STENCIL | DRW_STATE_WRITE_STENCIL_SHADOW_PASS |
DRW_STATE_WRITE_STENCIL_SHADOW_FAIL)) != 0)
{
if ((state & DRW_STATE_RASTERIZER_ENABLED) != 0) {
glDisable(GL_RASTERIZER_DISCARD);
}
else {
@ -1355,6 +1349,13 @@ static void drw_draw_pass_ex(DRWPass *pass, DRWShadingGroup *start_group, DRWSha
DST.shader = NULL;
}
/* HACK: Rasterized discard can affect clear commands which are not
* part of a DRWPass (as of now). So disable rasterized discard here
* if it has been enabled. */
if ((DST.state & DRW_STATE_RASTERIZER_ENABLED) == 0) {
drw_state_set((DST.state & ~DRW_STATE_RASTERIZER_ENABLED) | DRW_STATE_DEFAULT);
}
DRW_stats_query_end();
}