#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
{
ctx->tcs = (swr_tess_control_shader *)tcs;
ctx->dirty |= SWR_NEW_TCS;
+ ctx->dirty |= SWR_NEW_TS;
}
static void
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
}
}
+ // 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 |
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 |
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);
}
}