summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/d3d12/d3d12_context.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/d3d12/d3d12_context.h')
-rw-r--r--src/gallium/drivers/d3d12/d3d12_context.h161
1 files changed, 125 insertions, 36 deletions
diff --git a/src/gallium/drivers/d3d12/d3d12_context.h b/src/gallium/drivers/d3d12/d3d12_context.h
index 362b8022278..68822cc30aa 100644
--- a/src/gallium/drivers/d3d12/d3d12_context.h
+++ b/src/gallium/drivers/d3d12/d3d12_context.h
@@ -27,7 +27,6 @@
#include "d3d12_batch.h"
#include "d3d12_descriptor_pool.h"
#include "d3d12_pipeline_state.h"
-#include "d3d12_nir_lower_texcmp.h"
#include "dxil_nir_lower_int_samplers.h"
@@ -36,8 +35,7 @@
#include "util/list.h"
#include "util/slab.h"
#include "util/u_suballoc.h"
-
-#include <directx/d3d12.h>
+#include "util/u_threaded_context.h"
#define D3D12_GFX_SHADER_STAGES (PIPE_SHADER_TYPES - 1)
@@ -61,6 +59,8 @@ enum d3d12_dirty_flags
D3D12_DIRTY_ROOT_SIGNATURE = (1 << 14),
D3D12_DIRTY_STREAM_OUTPUT = (1 << 15),
D3D12_DIRTY_STRIP_CUT_VALUE = (1 << 16),
+ D3D12_DIRTY_COMPUTE_SHADER = (1 << 17),
+ D3D12_DIRTY_COMPUTE_ROOT_SIGNATURE = (1 << 18),
};
enum d3d12_shader_dirty_flags
@@ -68,22 +68,32 @@ enum d3d12_shader_dirty_flags
D3D12_SHADER_DIRTY_CONSTBUF = (1 << 0),
D3D12_SHADER_DIRTY_SAMPLER_VIEWS = (1 << 1),
D3D12_SHADER_DIRTY_SAMPLERS = (1 << 2),
+ D3D12_SHADER_DIRTY_SSBO = (1 << 3),
+ D3D12_SHADER_DIRTY_IMAGE = (1 << 4),
};
-#define D3D12_DIRTY_PSO (D3D12_DIRTY_BLEND | D3D12_DIRTY_RASTERIZER | D3D12_DIRTY_ZSA | \
- D3D12_DIRTY_FRAMEBUFFER | D3D12_DIRTY_SAMPLE_MASK | \
- D3D12_DIRTY_VERTEX_ELEMENTS | D3D12_DIRTY_PRIM_MODE | \
- D3D12_DIRTY_SHADER | D3D12_DIRTY_ROOT_SIGNATURE | \
- D3D12_DIRTY_STRIP_CUT_VALUE)
+#define D3D12_DIRTY_GFX_PSO (D3D12_DIRTY_BLEND | D3D12_DIRTY_RASTERIZER | D3D12_DIRTY_ZSA | \
+ D3D12_DIRTY_FRAMEBUFFER | D3D12_DIRTY_SAMPLE_MASK | \
+ D3D12_DIRTY_VERTEX_ELEMENTS | D3D12_DIRTY_PRIM_MODE | \
+ D3D12_DIRTY_SHADER | D3D12_DIRTY_ROOT_SIGNATURE | \
+ D3D12_DIRTY_STRIP_CUT_VALUE | D3D12_DIRTY_STREAM_OUTPUT)
+#define D3D12_DIRTY_COMPUTE_PSO (D3D12_DIRTY_COMPUTE_SHADER | D3D12_DIRTY_COMPUTE_ROOT_SIGNATURE)
+
+#define D3D12_DIRTY_COMPUTE_MASK (D3D12_DIRTY_COMPUTE_SHADER | D3D12_DIRTY_COMPUTE_ROOT_SIGNATURE)
+#define D3D12_DIRTY_GFX_MASK ~D3D12_DIRTY_COMPUTE_MASK
+
#define D3D12_SHADER_DIRTY_ALL (D3D12_SHADER_DIRTY_CONSTBUF | D3D12_SHADER_DIRTY_SAMPLER_VIEWS | \
- D3D12_SHADER_DIRTY_SAMPLERS)
+ D3D12_SHADER_DIRTY_SAMPLERS | D3D12_SHADER_DIRTY_SSBO | \
+ D3D12_SHADER_DIRTY_IMAGE)
enum d3d12_binding_type {
D3D12_BINDING_CONSTANT_BUFFER,
D3D12_BINDING_SHADER_RESOURCE_VIEW,
D3D12_BINDING_SAMPLER,
D3D12_BINDING_STATE_VARS,
+ D3D12_BINDING_SSBO,
+ D3D12_BINDING_IMAGE,
D3D12_NUM_BINDING_TYPES
};
@@ -113,6 +123,7 @@ struct d3d12_sampler_view {
struct d3d12_descriptor_handle handle;
unsigned mip_levels;
unsigned array_size;
+ unsigned texture_generation_id;
unsigned swizzle_override_r:3; /**< PIPE_SWIZZLE_x for red component */
unsigned swizzle_override_g:3; /**< PIPE_SWIZZLE_x for green component */
unsigned swizzle_override_b:3; /**< PIPE_SWIZZLE_x for blue component */
@@ -129,7 +140,6 @@ struct d3d12_stream_output_target {
struct pipe_stream_output_target base;
struct pipe_resource *fill_buffer;
unsigned fill_buffer_offset;
- uint64_t cached_filled_size;
};
struct d3d12_shader_state {
@@ -139,25 +149,58 @@ struct d3d12_shader_state {
struct blitter_context;
struct primconvert_context;
-struct d3d12_validation_tools;
+
+#ifdef _WIN32
+struct dxil_validator;
+#endif
#ifdef __cplusplus
class ResourceStateManager;
#endif
+#define D3D12_CONTEXT_NO_ID 0xffffffff
+
struct d3d12_context {
struct pipe_context base;
+
+ unsigned id;
struct slab_child_pool transfer_pool;
- struct primconvert_context *primconvert;
+ struct slab_child_pool transfer_pool_unsync;
+ struct list_head context_list_entry;
+ struct threaded_context *threaded_context;
+ struct d3d12_batch batches[8];
+ unsigned current_batch_idx;
+ struct util_dynarray recently_destroyed_bos;
+ struct util_dynarray barrier_scratch;
+ struct set *pending_barriers_bos;
+ struct util_dynarray local_pending_barriers_bos;
+ uint64_t submit_id;
+ ID3D12GraphicsCommandList *cmdlist;
+ ID3D12GraphicsCommandList2 *cmdlist2;
+ ID3D12GraphicsCommandList8 *cmdlist8;
+ ID3D12GraphicsCommandList *state_fixup_cmdlist;
+ struct hash_table_u64 *bo_state_table;
struct blitter_context *blitter;
+ uint flags;
+ bool queries_disabled;
+
+#ifdef __cplusplus
+ ResourceStateManager *resource_state_manager;
+#else
+ void *resource_state_manager; /* opaque pointer; we don't know about classes in C */
+#endif
+
+#ifdef HAVE_GALLIUM_D3D12_GRAPHICS
+ struct primconvert_context *primconvert;
struct u_suballocator query_allocator;
struct u_suballocator so_allocator;
struct hash_table *pso_cache;
+ struct hash_table *compute_pso_cache;
struct hash_table *root_signature_cache;
+ struct hash_table *cmd_signature_cache;
struct hash_table *gs_variant_cache;
-
- struct d3d12_batch batches[4];
- unsigned current_batch_idx;
+ struct hash_table *tcs_variant_cache;
+ struct hash_table *compute_transform_cache;
struct pipe_constant_buffer cbufs[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
struct pipe_framebuffer_state fb;
@@ -166,7 +209,7 @@ struct d3d12_context {
unsigned num_vbs;
float flip_y;
bool need_zero_one_depth_range;
- enum pipe_prim_type initial_api_prim;
+ enum mesa_prim initial_api_prim;
struct pipe_viewport_state viewport_states[PIPE_MAX_VIEWPORTS];
D3D12_VIEWPORT viewports[PIPE_MAX_VIEWPORTS];
unsigned num_viewports;
@@ -177,10 +220,18 @@ struct d3d12_context {
struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
unsigned num_sampler_views[PIPE_SHADER_TYPES];
unsigned has_int_samplers;
+ struct pipe_shader_buffer ssbo_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_BUFFERS];
+ unsigned num_ssbo_views[PIPE_SHADER_TYPES];
+ struct pipe_image_view image_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
+ enum pipe_format image_view_emulation_formats[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
+ unsigned num_image_views[PIPE_SHADER_TYPES];
struct d3d12_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
unsigned num_samplers[PIPE_SHADER_TYPES];
D3D12_INDEX_BUFFER_VIEW ibv;
+
dxil_wrap_sampler_state tex_wrap_states[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
+ dxil_wrap_sampler_state tex_wrap_states_shader_key[PIPE_MAX_SHADER_SAMPLER_VIEWS];
+
dxil_texture_swizzle_state tex_swizzle_state[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
enum compare_func tex_compare_func[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
@@ -197,40 +248,49 @@ 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;
+ float default_outer_tess_factor[4];
+ float default_inner_tess_factor[2];
struct d3d12_shader_selector *gfx_stages[D3D12_GFX_SHADER_STAGES];
+ struct d3d12_shader_selector *compute_state;
+
+ bool has_flat_varyings;
+ bool missing_dual_src_outputs;
+ bool manual_depth_range;
struct d3d12_gfx_pipeline_state gfx_pipeline_state;
- unsigned shader_dirty[D3D12_GFX_SHADER_STAGES];
+ struct d3d12_compute_pipeline_state compute_pipeline_state;
+ unsigned shader_dirty[PIPE_SHADER_TYPES];
unsigned state_dirty;
unsigned cmdlist_dirty;
- ID3D12PipelineState *current_pso;
- bool reverse_depth_range;
-
- ID3D12Fence *cmdqueue_fence;
- uint64_t fence_value;
- ID3D12GraphicsCommandList *cmdlist;
+ ID3D12PipelineState *current_gfx_pso;
+ ID3D12PipelineState *current_compute_pso;
+ uint16_t reverse_depth_range;
struct list_head active_queries;
- bool queries_disabled;
struct d3d12_descriptor_pool *sampler_pool;
struct d3d12_descriptor_handle null_sampler;
PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE D3D12SerializeVersionedRootSignature;
- struct d3d12_validation_tools *validation_tools;
+#ifndef _GAMING_XBOX
+ ID3D12DeviceConfiguration *dev_config;
+#endif
+#ifdef _WIN32
+ struct dxil_validator *dxil_validator;
+#endif
struct d3d12_resource *current_predication;
+ bool predication_condition;
+ bool queries_suspended;
-#ifdef __cplusplus
- ResourceStateManager *resource_state_manager;
-#else
- void *resource_state_manager; /* opaque pointer; we don't know about classes in C */
-#endif
+ uint32_t transform_state_vars[8];
struct pipe_query *timestamp_query;
/* used by d3d12_blit.cpp */
void *stencil_resolve_vs, *stencil_resolve_fs, *stencil_resolve_fs_no_flip, *sampler_state;
+#endif // HAVE_GALLIUM_D3D12_GRAPHICS
};
static inline struct d3d12_context *
@@ -271,16 +331,18 @@ void
d3d12_flush_cmdlist_and_wait(struct d3d12_context *ctx);
-enum d3d12_bind_invalidate_option {
- D3D12_BIND_INVALIDATE_NONE,
- D3D12_BIND_INVALIDATE_FULL,
+enum d3d12_transition_flags {
+ D3D12_TRANSITION_FLAG_NONE = 0,
+ D3D12_TRANSITION_FLAG_INVALIDATE_BINDINGS = 1,
+ D3D12_TRANSITION_FLAG_ACCUMULATE_STATE = 2,
+ D3D12_TRANSITION_FLAG_PENDING_MEMORY_BARRIER = 4,
};
void
d3d12_transition_resource_state(struct d3d12_context* ctx,
struct d3d12_resource* res,
D3D12_RESOURCE_STATES state,
- d3d12_bind_invalidate_option bind_invalidate);
+ d3d12_transition_flags flags);
void
d3d12_transition_subresources_state(struct d3d12_context *ctx,
@@ -289,10 +351,10 @@ d3d12_transition_subresources_state(struct d3d12_context *ctx,
unsigned start_layer, unsigned num_layers,
unsigned start_plane, unsigned num_planes,
D3D12_RESOURCE_STATES state,
- d3d12_bind_invalidate_option bind_invalidate);
+ d3d12_transition_flags flags);
void
-d3d12_apply_resource_states(struct d3d12_context* ctx);
+d3d12_apply_resource_states(struct d3d12_context* ctx, bool is_implicit_dispatch);
void
d3d12_draw_vbo(struct pipe_context *pctx,
@@ -303,6 +365,10 @@ d3d12_draw_vbo(struct pipe_context *pctx,
unsigned num_draws);
void
+d3d12_launch_grid(struct pipe_context *pctx,
+ const struct pipe_grid_info *info);
+
+void
d3d12_blit(struct pipe_context *pctx,
const struct pipe_blit_info *info);
@@ -312,4 +378,27 @@ d3d12_context_query_init(struct pipe_context *pctx);
bool
d3d12_need_zero_one_depth_range(struct d3d12_context *ctx);
+void
+d3d12_init_sampler_view_descriptor(struct d3d12_sampler_view *sampler_view);
+
+void
+d3d12_invalidate_context_bindings(struct d3d12_context *ctx, struct d3d12_resource *res);
+
+void
+d3d12_rebind_buffer(struct d3d12_context *ctx, struct d3d12_resource *res);
+
+void
+d3d12_init_null_sampler(struct d3d12_context *ctx);
+
+bool
+d3d12_init_polygon_stipple(struct pipe_context *pctx);
+
+void
+d3d12_init_graphics_context_functions(struct d3d12_context *ctx);
+
+#ifdef HAVE_GALLIUM_D3D12_VIDEO
+struct pipe_video_codec* d3d12_video_create_codec( struct pipe_context *context,
+ const struct pipe_video_codec *t);
+#endif
+
#endif