d3d12: Handle patch_vertices and patch topology
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:
@@ -2264,6 +2264,14 @@ d3d12_get_sample_position(struct pipe_context *pctx, unsigned sample_count, unsi
|
||||
positions[i] = (float)(samples[i] + 8) / 16.0f;
|
||||
}
|
||||
|
||||
static void
|
||||
d3d12_set_patch_vertices(struct pipe_context *pctx, uint8_t patch_vertices)
|
||||
{
|
||||
struct d3d12_context *ctx = d3d12_context(pctx);
|
||||
ctx->patch_vertices = patch_vertices;
|
||||
ctx->cmdlist_dirty |= D3D12_DIRTY_PRIM_MODE;
|
||||
}
|
||||
|
||||
struct pipe_context *
|
||||
d3d12_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
||||
{
|
||||
@@ -2322,6 +2330,8 @@ d3d12_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
|
||||
ctx->base.bind_tes_state = d3d12_bind_tes_state;
|
||||
ctx->base.delete_tes_state = d3d12_delete_tes_state;
|
||||
|
||||
ctx->base.set_patch_vertices = d3d12_set_patch_vertices;
|
||||
|
||||
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;
|
||||
|
||||
@@ -221,6 +221,7 @@ struct d3d12_context {
|
||||
struct pipe_stream_output_target *fake_so_targets[PIPE_MAX_SO_BUFFERS];
|
||||
D3D12_STREAM_OUTPUT_BUFFER_VIEW fake_so_buffer_views[PIPE_MAX_SO_BUFFERS];
|
||||
unsigned fake_so_buffer_factor;
|
||||
uint8_t patch_vertices;
|
||||
|
||||
struct d3d12_shader_selector *gfx_stages[D3D12_GFX_SHADER_STAGES];
|
||||
struct d3d12_shader_selector *compute_state;
|
||||
|
||||
@@ -586,7 +586,7 @@ validate_stream_output_targets(struct d3d12_context *ctx)
|
||||
}
|
||||
|
||||
static D3D_PRIMITIVE_TOPOLOGY
|
||||
topology(enum pipe_prim_type prim_type)
|
||||
topology(enum pipe_prim_type prim_type, uint8_t patch_vertices)
|
||||
{
|
||||
switch (prim_type) {
|
||||
case PIPE_PRIM_POINTS:
|
||||
@@ -616,10 +616,8 @@ topology(enum pipe_prim_type prim_type)
|
||||
case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
|
||||
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP_ADJ;
|
||||
|
||||
/*
|
||||
case PIPE_PRIM_PATCHES:
|
||||
return D3D_PRIMITIVE_TOPOLOGY_PATCHLIST;
|
||||
*/
|
||||
return (D3D_PRIMITIVE_TOPOLOGY)(D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + patch_vertices - 1);
|
||||
|
||||
case PIPE_PRIM_QUADS:
|
||||
case PIPE_PRIM_QUAD_STRIP:
|
||||
@@ -696,6 +694,7 @@ prim_supported(enum pipe_prim_type prim_type)
|
||||
case PIPE_PRIM_LINE_STRIP_ADJACENCY:
|
||||
case PIPE_PRIM_TRIANGLES_ADJACENCY:
|
||||
case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
|
||||
case PIPE_PRIM_PATCHES:
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -1045,7 +1044,7 @@ d3d12_draw_vbo(struct pipe_context *pctx,
|
||||
ctx->cmdlist->OMSetStencilRef(ctx->stencil_ref.ref_value[0]);
|
||||
|
||||
if (ctx->cmdlist_dirty & D3D12_DIRTY_PRIM_MODE)
|
||||
ctx->cmdlist->IASetPrimitiveTopology(topology((enum pipe_prim_type)dinfo->mode));
|
||||
ctx->cmdlist->IASetPrimitiveTopology(topology((enum pipe_prim_type)dinfo->mode, ctx->patch_vertices));
|
||||
|
||||
for (unsigned i = 0; i < ctx->num_vbs; ++i) {
|
||||
if (ctx->vbs[i].buffer.resource) {
|
||||
|
||||
@@ -196,7 +196,8 @@ create_gfx_pipeline_state(struct d3d12_context *ctx)
|
||||
{
|
||||
struct d3d12_screen *screen = d3d12_screen(ctx->base.screen);
|
||||
struct d3d12_gfx_pipeline_state *state = &ctx->gfx_pipeline_state;
|
||||
enum pipe_prim_type reduced_prim = u_reduced_prim(state->prim_type);
|
||||
enum pipe_prim_type reduced_prim = state->prim_type == PIPE_PRIM_PATCHES ?
|
||||
PIPE_PRIM_PATCHES : u_reduced_prim(state->prim_type);
|
||||
D3D12_SO_DECLARATION_ENTRY entries[PIPE_MAX_SO_OUTPUTS] = {};
|
||||
UINT strides[PIPE_MAX_SO_OUTPUTS] = { 0 };
|
||||
UINT num_entries = 0, num_strides = 0;
|
||||
|
||||
Reference in New Issue
Block a user