diff options
author | Jan Zielinski <[email protected]> | 2020-01-28 12:09:11 +0100 |
---|---|---|
committer | Jan Zielinski <[email protected]> | 2020-01-28 13:55:47 +0100 |
commit | ab7ac1ffda0f2d58a4b646a1a26aeffb8a8ec41c (patch) | |
tree | 339da09cbd69e1add76bbf30655172ab6deba4ca /src/gallium/drivers | |
parent | fe5267d32233192b57969a19d5733e874e63bb15 (diff) |
gallium/swr: fix tessellation state save/restore
Tessellation state should be saved with TCS/TES state
when binding new state and restored if old state
is set again.
Reviewed-by: Krzysztof Raszkowski <[email protected]>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3596>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3596>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/swr/swr_context.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_state.cpp | 30 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_state.h | 1 |
3 files changed, 27 insertions, 9 deletions
diff --git a/src/gallium/drivers/swr/swr_context.h b/src/gallium/drivers/swr/swr_context.h index 0fafe1449e7..9a19720478a 100644 --- a/src/gallium/drivers/swr/swr_context.h +++ b/src/gallium/drivers/swr/swr_context.h @@ -56,8 +56,9 @@ #define SWR_BLOCK_CLIENT_DRAW ( 1 << 18) // Indicates client draw will block #define SWR_NEW_TCS (1 << 19) #define SWR_NEW_TES (1 << 20) -#define SWR_NEW_TCSCONSTANTS (1 << 21) -#define SWR_NEW_TESCONSTANTS (1 << 22) +#define SWR_NEW_TS (1 << 21) +#define SWR_NEW_TCSCONSTANTS (1 << 22) +#define SWR_NEW_TESCONSTANTS (1 << 23) namespace std { diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index ea6d09ffb5f..34e36a8025a 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -485,6 +485,7 @@ swr_bind_tcs_state(struct pipe_context *pipe, void *tcs) ctx->tcs = (swr_tess_control_shader *)tcs; ctx->dirty |= SWR_NEW_TCS; + ctx->dirty |= SWR_NEW_TS; } static void @@ -519,8 +520,15 @@ swr_bind_tes_state(struct pipe_context *pipe, void *tes) if (ctx->tes == tes) return; + // Save current tessellator state first + if (ctx->tes != nullptr) { + ctx->tes->ts_state = ctx->tsState; + } + ctx->tes = (swr_tess_evaluation_shader *)tes; + ctx->dirty |= SWR_NEW_TES; + ctx->dirty |= SWR_NEW_TS; } static void @@ -1544,6 +1552,19 @@ swr_update_derived(struct pipe_context *pipe, } } + // We may need to restore tessellation state + // This restored state may be however overwritten + // during shader compilation + if (ctx->dirty & SWR_NEW_TS) { + if (ctx->tes != nullptr) { + ctx->tsState = ctx->tes->ts_state; + ctx->api.pfnSwrSetTsState(ctx->swrContext, &ctx->tsState); + } else { + SWR_TS_STATE state = { 0 }; + ctx->api.pfnSwrSetTsState(ctx->swrContext, &state); + } + } + // Tessellation Evaluation Shader // Compile TES first, because TCS is optional if (ctx->dirty & (SWR_NEW_GS | @@ -1582,16 +1603,13 @@ swr_update_derived(struct pipe_context *pipe, ctx->swrDC.texturesTES); } + // Update tessellation state in case it's been updated ctx->api.pfnSwrSetTsState(ctx->swrContext, &ctx->tsState); - } else { - SWR_TS_STATE state = { 0 }; - ctx->api.pfnSwrSetTsState(ctx->swrContext, &state); ctx->api.pfnSwrSetDsFunc(ctx->swrContext, NULL); } } - /* Tessellation Control Shader */ if (ctx->dirty & (SWR_NEW_GS | SWR_NEW_VS | @@ -1631,11 +1649,9 @@ swr_update_derived(struct pipe_context *pipe, ctx->swrDC.texturesTCS); } + // Update tessellation state in case it's been updated ctx->api.pfnSwrSetTsState(ctx->swrContext, &ctx->tsState); - } else { - SWR_TS_STATE state = { 0 }; - ctx->api.pfnSwrSetTsState(ctx->swrContext, &state); ctx->api.pfnSwrSetHsFunc(ctx->swrContext, NULL); } } diff --git a/src/gallium/drivers/swr/swr_state.h b/src/gallium/drivers/swr/swr_state.h index 09463241b96..128b85a892b 100644 --- a/src/gallium/drivers/swr/swr_state.h +++ b/src/gallium/drivers/swr/swr_state.h @@ -92,6 +92,7 @@ struct swr_tess_control_shader { struct swr_tess_evaluation_shader { struct pipe_shader_state pipe; struct lp_tgsi_info info; + SWR_TS_STATE ts_state; std::unordered_map<swr_jit_tes_key, std::unique_ptr<VariantTES>> map; }; |