d3d12: Initial plumbing for tesselation
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Reviewed-by: Bill Kristiansen <billkris@microsoft.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14399>
This commit is contained in:
@@ -545,6 +545,8 @@ util_blit_save_state(struct d3d12_context *ctx)
|
||||
util_blitter_save_fragment_shader(ctx->blitter, ctx->gfx_stages[PIPE_SHADER_FRAGMENT]);
|
||||
util_blitter_save_vertex_shader(ctx->blitter, ctx->gfx_stages[PIPE_SHADER_VERTEX]);
|
||||
util_blitter_save_geometry_shader(ctx->blitter, ctx->gfx_stages[PIPE_SHADER_GEOMETRY]);
|
||||
util_blitter_save_tessctrl_shader(ctx->blitter, ctx->gfx_stages[PIPE_SHADER_TESS_CTRL]);
|
||||
util_blitter_save_tesseval_shader(ctx->blitter, ctx->gfx_stages[PIPE_SHADER_TESS_EVAL]);
|
||||
|
||||
util_blitter_save_framebuffer(ctx->blitter, &ctx->fb);
|
||||
util_blitter_save_viewport(ctx->blitter, ctx->viewport_states);
|
||||
|
||||
@@ -993,8 +993,6 @@ select_shader_variant(struct d3d12_selection_context *sel_ctx, d3d12_shader_sele
|
||||
static d3d12_shader_selector *
|
||||
get_prev_shader(struct d3d12_context *ctx, pipe_shader_type current)
|
||||
{
|
||||
/* No TESS_CTRL or TESS_EVAL yet */
|
||||
|
||||
switch (current) {
|
||||
case PIPE_SHADER_VERTEX:
|
||||
return NULL;
|
||||
@@ -1003,6 +1001,14 @@ get_prev_shader(struct d3d12_context *ctx, pipe_shader_type current)
|
||||
return ctx->gfx_stages[PIPE_SHADER_GEOMETRY];
|
||||
FALLTHROUGH;
|
||||
case PIPE_SHADER_GEOMETRY:
|
||||
if (ctx->gfx_stages[PIPE_SHADER_TESS_EVAL])
|
||||
return ctx->gfx_stages[PIPE_SHADER_TESS_EVAL];
|
||||
FALLTHROUGH;
|
||||
case PIPE_SHADER_TESS_EVAL:
|
||||
if (ctx->gfx_stages[PIPE_SHADER_TESS_CTRL])
|
||||
return ctx->gfx_stages[PIPE_SHADER_TESS_CTRL];
|
||||
FALLTHROUGH;
|
||||
case PIPE_SHADER_TESS_CTRL:
|
||||
return ctx->gfx_stages[PIPE_SHADER_VERTEX];
|
||||
default:
|
||||
unreachable("shader type not supported");
|
||||
@@ -1012,10 +1018,16 @@ get_prev_shader(struct d3d12_context *ctx, pipe_shader_type current)
|
||||
static d3d12_shader_selector *
|
||||
get_next_shader(struct d3d12_context *ctx, pipe_shader_type current)
|
||||
{
|
||||
/* No TESS_CTRL or TESS_EVAL yet */
|
||||
|
||||
switch (current) {
|
||||
case PIPE_SHADER_VERTEX:
|
||||
if (ctx->gfx_stages[PIPE_SHADER_TESS_CTRL])
|
||||
return ctx->gfx_stages[PIPE_SHADER_TESS_CTRL];
|
||||
FALLTHROUGH;
|
||||
case PIPE_SHADER_TESS_CTRL:
|
||||
if (ctx->gfx_stages[PIPE_SHADER_TESS_EVAL])
|
||||
return ctx->gfx_stages[PIPE_SHADER_TESS_EVAL];
|
||||
FALLTHROUGH;
|
||||
case PIPE_SHADER_TESS_EVAL:
|
||||
if (ctx->gfx_stages[PIPE_SHADER_GEOMETRY])
|
||||
return ctx->gfx_stages[PIPE_SHADER_GEOMETRY];
|
||||
FALLTHROUGH;
|
||||
@@ -1218,7 +1230,13 @@ d3d12_create_compute_shader(struct d3d12_context *ctx,
|
||||
void
|
||||
d3d12_select_shader_variants(struct d3d12_context *ctx, const struct pipe_draw_info *dinfo)
|
||||
{
|
||||
static unsigned order[] = {PIPE_SHADER_VERTEX, PIPE_SHADER_GEOMETRY, PIPE_SHADER_FRAGMENT};
|
||||
static unsigned order[] = {
|
||||
PIPE_SHADER_VERTEX,
|
||||
PIPE_SHADER_TESS_CTRL,
|
||||
PIPE_SHADER_TESS_EVAL,
|
||||
PIPE_SHADER_GEOMETRY,
|
||||
PIPE_SHADER_FRAGMENT
|
||||
};
|
||||
struct d3d12_selection_context sel_ctx;
|
||||
|
||||
sel_ctx.ctx = ctx;
|
||||
|
||||
@@ -1133,6 +1133,48 @@ d3d12_delete_gs_state(struct pipe_context *pctx, void *gs)
|
||||
(struct d3d12_shader_selector *) gs);
|
||||
}
|
||||
|
||||
static void *
|
||||
d3d12_create_tcs_state(struct pipe_context *pctx,
|
||||
const struct pipe_shader_state *shader)
|
||||
{
|
||||
return d3d12_create_shader(d3d12_context(pctx), PIPE_SHADER_TESS_CTRL, shader);
|
||||
}
|
||||
|
||||
static void
|
||||
d3d12_bind_tcs_state(struct pipe_context *pctx, void *tcss)
|
||||
{
|
||||
bind_stage(d3d12_context(pctx), PIPE_SHADER_TESS_CTRL,
|
||||
(struct d3d12_shader_selector *)tcss);
|
||||
}
|
||||
|
||||
static void
|
||||
d3d12_delete_tcs_state(struct pipe_context *pctx, void *tcs)
|
||||
{
|
||||
delete_shader(d3d12_context(pctx), PIPE_SHADER_TESS_CTRL,
|
||||
(struct d3d12_shader_selector *)tcs);
|
||||
}
|
||||
|
||||
static void *
|
||||
d3d12_create_tes_state(struct pipe_context *pctx,
|
||||
const struct pipe_shader_state *shader)
|
||||
{
|
||||
return d3d12_create_shader(d3d12_context(pctx), PIPE_SHADER_TESS_EVAL, shader);
|
||||
}
|
||||
|
||||
static void
|
||||
d3d12_bind_tes_state(struct pipe_context *pctx, void *tess)
|
||||
{
|
||||
bind_stage(d3d12_context(pctx), PIPE_SHADER_TESS_EVAL,
|
||||
(struct d3d12_shader_selector *)tess);
|
||||
}
|
||||
|
||||
static void
|
||||
d3d12_delete_tes_state(struct pipe_context *pctx, void *tes)
|
||||
{
|
||||
delete_shader(d3d12_context(pctx), PIPE_SHADER_TESS_EVAL,
|
||||
(struct d3d12_shader_selector *)tes);
|
||||
}
|
||||
|
||||
static void *
|
||||
d3d12_create_compute_state(struct pipe_context *pctx,
|
||||
const struct pipe_compute_state *shader)
|
||||
@@ -2272,6 +2314,14 @@ d3d12_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
||||
ctx->base.bind_gs_state = d3d12_bind_gs_state;
|
||||
ctx->base.delete_gs_state = d3d12_delete_gs_state;
|
||||
|
||||
ctx->base.create_tcs_state = d3d12_create_tcs_state;
|
||||
ctx->base.bind_tcs_state = d3d12_bind_tcs_state;
|
||||
ctx->base.delete_tcs_state = d3d12_delete_tcs_state;
|
||||
|
||||
ctx->base.create_tes_state = d3d12_create_tes_state;
|
||||
ctx->base.bind_tes_state = d3d12_bind_tes_state;
|
||||
ctx->base.delete_tes_state = d3d12_delete_tes_state;
|
||||
|
||||
ctx->base.create_compute_state = d3d12_create_compute_state;
|
||||
ctx->base.bind_compute_state = d3d12_bind_compute_state;
|
||||
ctx->base.delete_compute_state = d3d12_delete_compute_state;
|
||||
|
||||
@@ -708,6 +708,8 @@ d3d12_last_vertex_stage(struct d3d12_context *ctx)
|
||||
{
|
||||
struct d3d12_shader_selector *sel = ctx->gfx_stages[PIPE_SHADER_GEOMETRY];
|
||||
if (!sel || sel->is_gs_variant)
|
||||
sel = ctx->gfx_stages[PIPE_SHADER_TESS_EVAL];
|
||||
if (!sel)
|
||||
sel = ctx->gfx_stages[PIPE_SHADER_VERTEX];
|
||||
return sel;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ d3d12_lower_yflip(nir_shader *nir)
|
||||
nir_variable *flip = NULL;
|
||||
|
||||
if (nir->info.stage != MESA_SHADER_VERTEX &&
|
||||
nir->info.stage != MESA_SHADER_TESS_EVAL &&
|
||||
nir->info.stage != MESA_SHADER_GEOMETRY)
|
||||
return;
|
||||
|
||||
@@ -390,6 +391,7 @@ void
|
||||
d3d12_nir_invert_depth(nir_shader *shader)
|
||||
{
|
||||
if (shader->info.stage != MESA_SHADER_VERTEX &&
|
||||
shader->info.stage != MESA_SHADER_TESS_EVAL &&
|
||||
shader->info.stage != MESA_SHADER_GEOMETRY)
|
||||
return;
|
||||
|
||||
|
||||
@@ -213,6 +213,20 @@ create_gfx_pipeline_state(struct d3d12_context *ctx)
|
||||
last_vertex_stage_nir = shader->nir;
|
||||
}
|
||||
|
||||
if (state->stages[PIPE_SHADER_TESS_CTRL]) {
|
||||
auto shader = state->stages[PIPE_SHADER_TESS_CTRL];
|
||||
pso_desc.HS.BytecodeLength = shader->bytecode_length;
|
||||
pso_desc.HS.pShaderBytecode = shader->bytecode;
|
||||
last_vertex_stage_nir = shader->nir;
|
||||
}
|
||||
|
||||
if (state->stages[PIPE_SHADER_TESS_EVAL]) {
|
||||
auto shader = state->stages[PIPE_SHADER_TESS_EVAL];
|
||||
pso_desc.DS.BytecodeLength = shader->bytecode_length;
|
||||
pso_desc.DS.pShaderBytecode = shader->bytecode;
|
||||
last_vertex_stage_nir = shader->nir;
|
||||
}
|
||||
|
||||
if (state->stages[PIPE_SHADER_GEOMETRY]) {
|
||||
auto shader = state->stages[PIPE_SHADER_GEOMETRY];
|
||||
pso_desc.GS.BytecodeLength = shader->bytecode_length;
|
||||
|
||||
Reference in New Issue
Block a user