#ifndef ILO_STATE_H
#define ILO_STATE_H
+#include "core/ilo_builder_3d.h" /* for gen6_3dprimitive_info */
+#include "core/ilo_state_cc.h"
+#include "core/ilo_state_compute.h"
+#include "core/ilo_state_raster.h"
+#include "core/ilo_state_sampler.h"
+#include "core/ilo_state_sbe.h"
+#include "core/ilo_state_shader.h"
+#include "core/ilo_state_sol.h"
+#include "core/ilo_state_surface.h"
+#include "core/ilo_state_urb.h"
+#include "core/ilo_state_vf.h"
+#include "core/ilo_state_viewport.h"
+#include "core/ilo_state_zs.h"
#include "pipe/p_state.h"
+#include "util/u_dynarray.h"
#include "ilo_common.h"
ILO_DIRTY_ALL = 0xffffffff,
};
-struct intel_bo;
-struct ilo_buffer;
struct ilo_context;
struct ilo_shader_state;
-struct ilo_texture;
+
+struct ilo_ve_state {
+ unsigned vb_mapping[PIPE_MAX_ATTRIBS];
+ unsigned vb_count;
+
+ /* these are not valid until the state is finalized */
+ uint32_t vf_data[PIPE_MAX_ATTRIBS][4];
+ struct ilo_state_vf_params_info vf_params;
+ struct ilo_state_vf vf;
+};
struct ilo_vb_state {
struct pipe_vertex_buffer states[PIPE_MAX_ATTRIBS];
+ struct ilo_state_vertex_buffer vb[PIPE_MAX_ATTRIBS];
uint32_t enabled_mask;
};
struct ilo_ib_state {
- struct pipe_resource *buffer;
- const void *user_buffer;
- unsigned offset;
- unsigned index_size;
+ struct pipe_index_buffer state;
/* these are not valid until the state is finalized */
struct pipe_resource *hw_resource;
unsigned hw_index_size;
- /* an offset to be added to pipe_draw_info::start */
- int64_t draw_start_offset;
+ struct ilo_state_index_buffer ib;
};
-struct ilo_ve_cso {
- /* VERTEX_ELEMENT_STATE */
- uint32_t payload[2];
-};
+struct ilo_cbuf_cso {
+ struct pipe_resource *resource;
+ struct ilo_state_surface_buffer_info info;
+ struct ilo_state_surface surface;
-struct ilo_ve_state {
- struct ilo_ve_cso cso[PIPE_MAX_ATTRIBS];
- unsigned count;
+ /*
+ * this CSO is not so constant because user buffer needs to be uploaded in
+ * finalize_constant_buffers()
+ */
+ const void *user_buffer;
+};
- unsigned instance_divisors[PIPE_MAX_ATTRIBS];
- unsigned vb_mapping[PIPE_MAX_ATTRIBS];
- unsigned vb_count;
+struct ilo_sampler_cso {
+ struct ilo_state_sampler sampler;
+ struct ilo_state_sampler_border border;
+ bool saturate_s;
+ bool saturate_t;
+ bool saturate_r;
+};
- /* these are not valid until the state is finalized */
- struct ilo_ve_cso edgeflag_cso;
- bool last_cso_edgeflag;
+struct ilo_sampler_state {
+ const struct ilo_sampler_cso *cso[ILO_MAX_SAMPLERS];
+};
- struct ilo_ve_cso nosrc_cso;
- bool prepend_nosrc_cso;
+struct ilo_cbuf_state {
+ struct ilo_cbuf_cso cso[ILO_MAX_CONST_BUFFERS];
+ uint32_t enabled_mask;
};
-struct ilo_so_state {
- struct pipe_stream_output_target *states[ILO_MAX_SO_BUFFERS];
+struct ilo_resource_state {
+ struct pipe_surface *states[PIPE_MAX_SHADER_IMAGES];
unsigned count;
- unsigned append_bitmask;
-
- bool enabled;
};
-struct ilo_viewport_cso {
- /* matrix form */
- float m00, m11, m22, m30, m31, m32;
-
- /* guardband in NDC space */
- float min_gbx, min_gby, max_gbx, max_gby;
+struct ilo_view_cso {
+ struct pipe_sampler_view base;
- /* viewport in screen space */
- float min_x, min_y, min_z;
- float max_x, max_y, max_z;
+ struct ilo_state_surface surface;
};
-struct ilo_viewport_state {
- struct ilo_viewport_cso cso[ILO_MAX_VIEWPORTS];
+struct ilo_view_state {
+ struct pipe_sampler_view *states[ILO_MAX_SAMPLER_VIEWS];
unsigned count;
-
- struct pipe_viewport_state viewport0;
};
-struct ilo_scissor_state {
- /* SCISSOR_RECT */
- uint32_t payload[ILO_MAX_VIEWPORTS * 2];
+struct ilo_stream_output_target {
+ struct pipe_stream_output_target base;
- struct pipe_scissor_state scissor0;
+ struct ilo_state_sol_buffer sb;
};
-struct ilo_rasterizer_clip {
- /* 3DSTATE_CLIP */
- uint32_t payload[3];
-
- uint32_t can_enable_guardband;
-};
+struct ilo_so_state {
+ struct pipe_stream_output_target *states[ILO_MAX_SO_BUFFERS];
+ unsigned count;
+ unsigned append_bitmask;
-struct ilo_rasterizer_sf {
- /* 3DSTATE_SF */
- uint32_t payload[6];
- uint32_t dw_msaa;
-};
+ struct ilo_state_sol_buffer dummy_sb;
-struct ilo_rasterizer_wm {
- /* 3DSTATE_WM */
- uint32_t payload[2];
- uint32_t dw_msaa_rast;
- uint32_t dw_msaa_disp;
+ bool enabled;
};
struct ilo_rasterizer_state {
struct pipe_rasterizer_state state;
- struct ilo_rasterizer_clip clip;
- struct ilo_rasterizer_sf sf;
- struct ilo_rasterizer_wm wm;
+ /* these are invalid until finalize_rasterizer() */
+ struct ilo_state_raster_info info;
+ struct ilo_state_raster rs;
};
-struct ilo_dsa_state {
- /* DEPTH_STENCIL_STATE */
- uint32_t payload[3];
-
- uint32_t dw_alpha;
- ubyte alpha_ref;
-};
-
-struct ilo_blend_cso {
- /* BLEND_STATE */
- uint32_t payload[2];
+struct ilo_viewport_state {
+ struct ilo_state_viewport_matrix_info matrices[ILO_MAX_VIEWPORTS];
+ struct ilo_state_viewport_scissor_info scissors[ILO_MAX_VIEWPORTS];
+ struct ilo_state_viewport_params_info params;
- uint32_t dw_blend;
- uint32_t dw_blend_dst_alpha_forced_one;
+ struct pipe_viewport_state viewport0;
+ struct pipe_scissor_state scissor0;
- uint32_t dw_logicop;
- uint32_t dw_alpha_mod;
+ struct ilo_state_viewport vp;
+ uint32_t vp_data[20 * ILO_MAX_VIEWPORTS];
};
-struct ilo_blend_state {
- struct ilo_blend_cso cso[ILO_MAX_DRAW_BUFFERS];
+struct ilo_surface_cso {
+ struct pipe_surface base;
- bool independent_blend_enable;
- bool dual_blend;
- bool alpha_to_coverage;
+ bool is_rt;
+ union {
+ struct ilo_state_surface rt;
+ struct ilo_state_zs zs;
+ } u;
};
-struct ilo_sampler_cso {
- /* SAMPLER_STATE and SAMPLER_BORDER_COLOR_STATE */
- uint32_t payload[15];
-
- uint32_t dw_filter;
- uint32_t dw_filter_aniso;
- uint32_t dw_wrap;
- uint32_t dw_wrap_1d;
- uint32_t dw_wrap_cube;
-
- bool anisotropic;
- bool saturate_r;
- bool saturate_s;
- bool saturate_t;
-};
+struct ilo_fb_state {
+ struct pipe_framebuffer_state state;
-struct ilo_sampler_state {
- const struct ilo_sampler_cso *cso[ILO_MAX_SAMPLERS];
-};
+ struct ilo_state_surface null_rt;
+ struct ilo_state_zs null_zs;
-struct ilo_view_surface {
- /* SURFACE_STATE */
- uint32_t payload[8];
- struct intel_bo *bo;
-};
+ struct ilo_fb_blend_caps {
+ bool is_unorm;
+ bool is_integer;
+ bool force_dst_alpha_one;
-struct ilo_view_cso {
- struct pipe_sampler_view base;
+ bool can_logicop;
+ bool can_blend;
+ bool can_alpha_test;
+ } blend_caps[PIPE_MAX_COLOR_BUFS];
- struct ilo_view_surface surface;
-};
+ unsigned num_samples;
-struct ilo_view_state {
- struct pipe_sampler_view *states[ILO_MAX_SAMPLER_VIEWS];
- unsigned count;
+ bool has_integer_rt;
+ bool has_hiz;
+ enum gen_depth_format depth_offset_format;
};
-struct ilo_cbuf_cso {
- struct pipe_resource *resource;
- struct ilo_view_surface surface;
-
- /*
- * this CSO is not so constant because user buffer needs to be uploaded in
- * finalize_constant_buffers()
- */
- const void *user_buffer;
- unsigned user_buffer_size;
-};
+struct ilo_dsa_state {
+ struct ilo_state_cc_depth_info depth;
-struct ilo_cbuf_state {
- struct ilo_cbuf_cso cso[ILO_MAX_CONST_BUFFERS];
- uint32_t enabled_mask;
-};
+ struct ilo_state_cc_stencil_info stencil;
+ struct {
+ uint8_t test_mask;
+ uint8_t write_mask;
+ } stencil_front, stencil_back;
-struct ilo_resource_state {
- struct pipe_surface *states[PIPE_MAX_SHADER_RESOURCES];
- unsigned count;
+ bool alpha_test;
+ float alpha_ref;
+ enum gen_compare_function alpha_func;
};
-struct ilo_surface_cso {
- struct pipe_surface base;
+struct ilo_blend_state {
+ struct ilo_state_cc_blend_rt_info rt[PIPE_MAX_COLOR_BUFS];
+ struct ilo_state_cc_blend_rt_info dummy_rt;
+ bool dual_blend;
- bool is_rt;
- union {
- struct ilo_view_surface rt;
- struct ilo_zs_surface {
- uint32_t payload[10];
- uint32_t dw_aligned_8x4;
-
- struct intel_bo *bo;
- struct intel_bo *hiz_bo;
- struct intel_bo *separate_s8_bo;
- } zs;
- } u;
+ /* these are invalid until finalize_blend() */
+ struct ilo_state_cc_blend_rt_info effective_rt[PIPE_MAX_COLOR_BUFS];
+ struct ilo_state_cc_info info;
+ struct ilo_state_cc cc;
+ bool alpha_may_kill;
};
-struct ilo_fb_state {
- struct pipe_framebuffer_state state;
-
- struct ilo_view_surface null_rt;
- struct ilo_zs_surface null_zs;
-
- unsigned num_samples;
+struct ilo_global_binding_cso {
+ struct pipe_resource *resource;
+ uint32_t *handle;
};
+/*
+ * In theory, we would like a "virtual" bo that serves as the global memory
+ * region. The virtual bo would reserve a region in the GTT aperture, but the
+ * pages of it would come from those of the global bindings.
+ *
+ * The virtual bo would be created in launch_grid(). The global bindings
+ * would be added to the virtual bo. A SURFACE_STATE for the virtual bo would
+ * be created. The handles returned by set_global_binding() would be offsets
+ * into the virtual bo.
+ *
+ * But for now, we will create a SURFACE_STATE for each of the bindings. The
+ * handle of a global binding consists of the offset and the binding table
+ * index.
+ */
struct ilo_global_binding {
- /*
- * XXX These should not be treated as real resources (and there could be
- * thousands of them). They should be treated as regions in GLOBAL
- * resource, which is the only real resource.
- *
- * That is, a resource here should instead be
- *
- * struct ilo_global_region {
- * struct pipe_resource base;
- * int offset;
- * int size;
- * };
- *
- * and it describes the region [offset, offset + size) in GLOBAL
- * resource.
- */
- struct pipe_resource *resources[PIPE_MAX_SHADER_RESOURCES];
- uint32_t *handles[PIPE_MAX_SHADER_RESOURCES];
+ struct util_dynarray bindings;
unsigned count;
};
-struct ilo_shader_cso {
- uint32_t payload[5];
-};
-
struct ilo_state_vector {
const struct pipe_draw_info *draw;
+ struct gen6_3dprimitive_info draw_info;
uint32_t dirty;
struct ilo_shader_state *vs;
struct ilo_shader_state *gs;
+ struct ilo_state_hs disabled_hs;
+ struct ilo_state_ds disabled_ds;
+ struct ilo_state_gs disabled_gs;
+
struct ilo_so_state so;
struct pipe_clip_state clip;
+
struct ilo_viewport_state viewport;
- struct ilo_scissor_state scissor;
- const struct ilo_rasterizer_state *rasterizer;
- struct pipe_poly_stipple poly_stipple;
+ struct ilo_rasterizer_state *rasterizer;
+
+ struct ilo_state_line_stipple line_stipple;
+ struct ilo_state_poly_stipple poly_stipple;
unsigned sample_mask;
struct ilo_shader_state *fs;
- const struct ilo_dsa_state *dsa;
+ struct ilo_state_cc_params_info cc_params;
struct pipe_stencil_ref stencil_ref;
- const struct ilo_blend_state *blend;
- struct pipe_blend_color blend_color;
+ const struct ilo_dsa_state *dsa;
+ struct ilo_blend_state *blend;
+
struct ilo_fb_state fb;
+ struct ilo_state_urb urb;
+
/* shader resources */
struct ilo_sampler_state sampler[PIPE_SHADER_TYPES];
struct ilo_view_state view[PIPE_SHADER_TYPES];
struct ilo_cbuf_state cbuf[PIPE_SHADER_TYPES];
struct ilo_resource_state resource;
+ struct ilo_state_sampler disabled_sampler;
+
/* GPGPU */
struct ilo_shader_state *cs;
struct ilo_resource_state cs_resource;
const struct pipe_draw_info *draw);
void
-ilo_state_vector_init(const struct ilo_dev_info *dev,
+ilo_finalize_compute_states(struct ilo_context *ilo);
+
+void
+ilo_state_vector_init(const struct ilo_dev *dev,
struct ilo_state_vector *vec);
void