#define ILO_RENDER_GEN_H
#include "ilo_common.h"
+#include "ilo_builder.h"
+#include "ilo_state.h"
+#include "ilo_render.h"
-struct ilo_3d_pipeline;
-struct ilo_query;
+struct ilo_bo;
+struct ilo_blitter;
+struct ilo_render;
struct ilo_state_vector;
-struct gen6_pipeline_session {
- uint32_t pipe_dirty;
+/**
+ * Render Engine.
+ */
+struct ilo_render {
+ const struct ilo_dev_info *dev;
+ struct ilo_builder *builder;
- int reduced_prim;
+ struct intel_bo *workaround_bo;
+
+ uint32_t sample_pattern_1x;
+ uint32_t sample_pattern_2x;
+ uint32_t sample_pattern_4x;
+ uint32_t sample_pattern_8x[2];
+ uint32_t sample_pattern_16x[4];
bool hw_ctx_changed;
+
+ /*
+ * Any state that involves resources needs to be re-emitted when the
+ * batch bo changed. This is because we do not pin the resources and
+ * their offsets (or existence) may change between batch buffers.
+ */
bool batch_bo_changed;
bool state_bo_changed;
- bool kernel_bo_changed;
+ bool instruction_bo_changed;
+
+ /**
+ * HW states.
+ */
+ struct ilo_render_state {
+ /*
+ * When a WA is needed before some command, we always emit the WA right
+ * before the command. Knowing what have already been done since last
+ * 3DPRIMITIVE allows us to skip some WAs.
+ */
+ uint32_t current_pipe_control_dw1;
+
+ /*
+ * When a WA is needed after some command, we may have the WA follow the
+ * command immediately or defer it. If this is non-zero, a PIPE_CONTROL
+ * will be emitted before 3DPRIMITIVE.
+ */
+ uint32_t deferred_pipe_control_dw1;
+
+ bool primitive_restart;
+ int reduced_prim;
+ int so_max_vertices;
+
+ uint32_t SF_VIEWPORT;
+ uint32_t CLIP_VIEWPORT;
+ uint32_t SF_CLIP_VIEWPORT; /* GEN7+ */
+ uint32_t CC_VIEWPORT;
+
+ uint32_t COLOR_CALC_STATE;
+ uint32_t BLEND_STATE;
+ uint32_t DEPTH_STENCIL_STATE;
+
+ uint32_t SCISSOR_RECT;
+
+ struct {
+ uint32_t BINDING_TABLE_STATE;
+ uint32_t SURFACE_STATE[ILO_MAX_SURFACES];
+ uint32_t SAMPLER_STATE;
+ uint32_t SAMPLER_BORDER_COLOR_STATE[ILO_MAX_SAMPLERS];
+ uint32_t PUSH_CONSTANT_BUFFER;
+ int PUSH_CONSTANT_BUFFER_size;
+ } vs;
+
+ struct {
+ uint32_t BINDING_TABLE_STATE;
+ uint32_t SURFACE_STATE[ILO_MAX_SURFACES];
+ bool active;
+ } gs;
+
+ struct {
+ uint32_t BINDING_TABLE_STATE;
+ uint32_t SURFACE_STATE[ILO_MAX_SURFACES];
+ uint32_t SAMPLER_STATE;
+ uint32_t SAMPLER_BORDER_COLOR_STATE[ILO_MAX_SAMPLERS];
+ uint32_t PUSH_CONSTANT_BUFFER;
+ int PUSH_CONSTANT_BUFFER_size;
+ } wm;
+
+ struct {
+ uint32_t BINDING_TABLE_STATE;
+ uint32_t SURFACE_STATE[ILO_MAX_SURFACES];
+ uint32_t SAMPLER_STATE;
+ uint32_t SAMPLER_BORDER_COLOR_STATE[ILO_MAX_SAMPLERS];
+ uint32_t PUSH_CONSTANT_BUFFER;
+ int PUSH_CONSTANT_BUFFER_size;
+ } cs;
+ } state;
+};
+
+struct ilo_render_draw_session {
+ uint32_t pipe_dirty;
+
+ /* commands */
+ int reduced_prim;
+
bool prim_changed;
bool primitive_restart_changed;
- void (*emit_draw_states)(struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ /* dynamic states */
+ bool viewport_changed;
+ bool scissor_changed;
- void (*emit_draw_commands)(struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
-
- /* indirect states */
- bool viewport_state_changed;
- bool cc_state_blend_changed;
- bool cc_state_dsa_changed;
- bool cc_state_cc_changed;
- bool scissor_state_changed;
+ bool cc_changed;
+ bool dsa_changed;
+ bool blend_changed;
+
+ bool sampler_vs_changed;
+ bool sampler_gs_changed;
+ bool sampler_fs_changed;
+
+ bool pcb_vs_changed;
+ bool pcb_gs_changed;
+ bool pcb_fs_changed;
+
+ /* surface states */
bool binding_table_vs_changed;
bool binding_table_gs_changed;
bool binding_table_fs_changed;
- bool sampler_state_vs_changed;
- bool sampler_state_gs_changed;
- bool sampler_state_fs_changed;
- bool pcb_state_vs_changed;
- bool pcb_state_gs_changed;
- bool pcb_state_fs_changed;
-
- int num_surfaces[PIPE_SHADER_TYPES];
};
-struct gen6_rectlist_session {
- uint32_t DEPTH_STENCIL_STATE;
- uint32_t COLOR_CALC_STATE;
- uint32_t CC_VIEWPORT;
+struct ilo_render_rectlist_session {
+ uint32_t vb_start;
+ uint32_t vb_end;
+};
+
+struct ilo_render_launch_grid_session {
+ const unsigned *thread_group_offset;
+ const unsigned *thread_group_dim;
+ unsigned thread_group_size;
+ const struct pipe_constant_buffer *input;
+ uint32_t pc;
+
+ uint32_t idrt;
+ int idrt_size;
};
+int
+ilo_render_get_draw_commands_len_gen6(const struct ilo_render *render,
+ const struct ilo_state_vector *vec);
+
+int
+ilo_render_get_draw_commands_len_gen7(const struct ilo_render *render,
+ const struct ilo_state_vector *vec);
+
+int
+ilo_render_get_draw_commands_len_gen8(const struct ilo_render *render,
+ const struct ilo_state_vector *vec);
+
+static inline int
+ilo_render_get_draw_commands_len(const struct ilo_render *render,
+ const struct ilo_state_vector *vec)
+{
+ if (ilo_dev_gen(render->dev) >= ILO_GEN(8))
+ return ilo_render_get_draw_commands_len_gen8(render, vec);
+ else if (ilo_dev_gen(render->dev) >= ILO_GEN(7))
+ return ilo_render_get_draw_commands_len_gen7(render, vec);
+ else
+ return ilo_render_get_draw_commands_len_gen6(render, vec);
+}
+
void
-gen6_pipeline_prepare(const struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ilo_render_emit_draw_commands_gen6(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
void
-gen6_pipeline_draw(struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ilo_render_emit_draw_commands_gen7(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
void
-gen6_pipeline_end(struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ilo_render_emit_draw_commands_gen8(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
+
+static inline void
+ilo_render_emit_draw_commands(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session)
+{
+ const unsigned batch_used = ilo_builder_batch_used(render->builder);
+
+ if (ilo_dev_gen(render->dev) >= ILO_GEN(8))
+ ilo_render_emit_draw_commands_gen8(render, vec, session);
+ else if (ilo_dev_gen(render->dev) >= ILO_GEN(7))
+ ilo_render_emit_draw_commands_gen7(render, vec, session);
+ else
+ ilo_render_emit_draw_commands_gen6(render, vec, session);
+
+ assert(ilo_builder_batch_used(render->builder) <= batch_used +
+ ilo_render_get_draw_commands_len(render, vec));
+}
+
+int
+ilo_render_get_rectlist_commands_len_gen6(const struct ilo_render *render,
+ const struct ilo_blitter *blitter);
+
+int
+ilo_render_get_rectlist_commands_len_gen8(const struct ilo_render *render,
+ const struct ilo_blitter *blitter);
+
+static inline int
+ilo_render_get_rectlist_commands_len(const struct ilo_render *render,
+ const struct ilo_blitter *blitter)
+{
+ if (ilo_dev_gen(render->dev) >= ILO_GEN(8))
+ return ilo_render_get_rectlist_commands_len_gen8(render, blitter);
+ else
+ return ilo_render_get_rectlist_commands_len_gen6(render, blitter);
+}
+
+void
+ilo_render_emit_rectlist_commands_gen6(struct ilo_render *r,
+ const struct ilo_blitter *blitter,
+ const struct ilo_render_rectlist_session *session);
+
+void
+ilo_render_emit_rectlist_commands_gen7(struct ilo_render *r,
+ const struct ilo_blitter *blitter,
+ const struct ilo_render_rectlist_session *session);
void
-gen6_pipeline_common_select(struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ilo_render_emit_rectlist_commands_gen8(struct ilo_render *r,
+ const struct ilo_blitter *blitter,
+ const struct ilo_render_rectlist_session *session);
+
+static inline void
+ilo_render_emit_rectlist_commands(struct ilo_render *render,
+ const struct ilo_blitter *blitter,
+ const struct ilo_render_rectlist_session *session)
+{
+ const unsigned batch_used = ilo_builder_batch_used(render->builder);
+
+ if (ilo_dev_gen(render->dev) >= ILO_GEN(8))
+ ilo_render_emit_rectlist_commands_gen8(render, blitter, session);
+ else if (ilo_dev_gen(render->dev) >= ILO_GEN(7))
+ ilo_render_emit_rectlist_commands_gen7(render, blitter, session);
+ else
+ ilo_render_emit_rectlist_commands_gen6(render, blitter, session);
+
+ assert(ilo_builder_batch_used(render->builder) <= batch_used +
+ ilo_render_get_rectlist_commands_len(render, blitter));
+}
+
+int
+ilo_render_get_launch_grid_commands_len(const struct ilo_render *render,
+ const struct ilo_state_vector *vec);
void
-gen6_pipeline_common_sip(struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ilo_render_emit_launch_grid_commands(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ const struct ilo_render_launch_grid_session *session);
+
+int
+ilo_render_get_draw_dynamic_states_len(const struct ilo_render *render,
+ const struct ilo_state_vector *vec);
void
-gen6_pipeline_common_base_address(struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ilo_render_emit_draw_dynamic_states(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
+
+int
+ilo_render_get_rectlist_dynamic_states_len(const struct ilo_render *render,
+ const struct ilo_blitter *blitter);
void
-gen6_pipeline_vf(struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ilo_render_emit_rectlist_dynamic_states(struct ilo_render *render,
+ const struct ilo_blitter *blitter,
+ struct ilo_render_rectlist_session *session);
+
+int
+ilo_render_get_launch_grid_dynamic_states_len(const struct ilo_render *render,
+ const struct ilo_state_vector *vec);
void
-gen6_pipeline_vf_statistics(struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ilo_render_emit_launch_grid_dynamic_states(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_launch_grid_session *session);
+
+int
+ilo_render_get_draw_surface_states_len(const struct ilo_render *render,
+ const struct ilo_state_vector *vec);
void
-gen6_pipeline_vs(struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ilo_render_emit_draw_surface_states(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
+
+int
+ilo_render_get_launch_grid_surface_states_len(const struct ilo_render *render,
+ const struct ilo_state_vector *vec);
void
-gen6_pipeline_clip(struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ilo_render_emit_launch_grid_surface_states(struct ilo_render *render,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_launch_grid_session *session);
void
-gen6_pipeline_sf_rect(struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+gen6_wa_pre_pipe_control(struct ilo_render *r, uint32_t dw1);
void
-gen6_pipeline_wm_raster(struct ilo_3d_pipeline *p,
+gen6_draw_common_select(struct ilo_render *r,
const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ struct ilo_render_draw_session *session);
void
-gen6_pipeline_states(struct ilo_3d_pipeline *p,
+gen6_draw_common_sip(struct ilo_render *r,
const struct ilo_state_vector *ilo,
- struct gen6_pipeline_session *session);
+ struct ilo_render_draw_session *session);
-int
-gen6_pipeline_estimate_state_size(const struct ilo_3d_pipeline *p,
- const struct ilo_state_vector *ilo);
+void
+gen6_draw_common_base_address(struct ilo_render *r,
+ const struct ilo_state_vector *ilo,
+ struct ilo_render_draw_session *session);
-int
-gen6_pipeline_estimate_query_size(const struct ilo_3d_pipeline *p,
- const struct ilo_query *q);
+void
+gen6_draw_vf(struct ilo_render *r,
+ const struct ilo_state_vector *ilo,
+ struct ilo_render_draw_session *session);
+
+void
+gen6_draw_vf_statistics(struct ilo_render *r,
+ const struct ilo_state_vector *ilo,
+ struct ilo_render_draw_session *session);
+
+void
+gen6_draw_vs(struct ilo_render *r,
+ const struct ilo_state_vector *ilo,
+ struct ilo_render_draw_session *session);
+
+void
+gen6_draw_clip(struct ilo_render *r,
+ const struct ilo_state_vector *ilo,
+ struct ilo_render_draw_session *session);
+
+void
+gen6_draw_sf_rect(struct ilo_render *r,
+ const struct ilo_state_vector *ilo,
+ struct ilo_render_draw_session *session);
+
+void
+gen6_draw_wm_raster(struct ilo_render *r,
+ const struct ilo_state_vector *ilo,
+ struct ilo_render_draw_session *session);
+
+void
+gen7_draw_common_pcb_alloc(struct ilo_render *r,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
+
+void
+gen7_draw_common_pointers_1(struct ilo_render *r,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
+
+void
+gen7_draw_common_urb(struct ilo_render *r,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
+
+void
+gen7_draw_common_pointers_2(struct ilo_render *r,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
+
+void
+gen7_draw_vs(struct ilo_render *r,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
+
+void
+gen7_draw_ds(struct ilo_render *r,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
+
+void
+gen7_draw_te(struct ilo_render *r,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
+
+void
+gen7_draw_hs(struct ilo_render *r,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
void
-ilo_3d_pipeline_emit_flush_gen6(struct ilo_3d_pipeline *p);
+gen7_draw_gs(struct ilo_render *r,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
void
-ilo_3d_pipeline_emit_query_gen6(struct ilo_3d_pipeline *p,
- struct ilo_query *q, uint32_t offset);
+gen7_draw_sol(struct ilo_render *r,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
void
-ilo_3d_pipeline_init_gen6(struct ilo_3d_pipeline *p);
+gen7_draw_vf_draw(struct ilo_render *r,
+ const struct ilo_state_vector *vec,
+ struct ilo_render_draw_session *session);
#endif /* ILO_RENDER_GEN_H */