radeonsi: update hack for HTILE corruption in ARK: Survival Evolved
[mesa.git] / src / gallium / drivers / radeonsi / si_pipe.h
index 8db7028c9a109bb89acfb02243ce2338ccc9a01a..8d7703b0e4b0f150d4dd1badd202b20c84724374 100644 (file)
@@ -81,6 +81,7 @@
 #define SI_PREFETCH_PS                 (1 << 6)
 
 #define SI_MAX_BORDER_COLORS   4096
+#define SI_MAX_VIEWPORTS        16
 #define SIX_BITS               0x3F
 
 struct si_compute;
@@ -94,7 +95,10 @@ struct si_screen {
        bool                            has_clear_state;
        bool                            has_distributed_tess;
        bool                            has_draw_indirect_multi;
-       bool                            has_ds_bpermute;
+       bool                            has_out_of_order_rast;
+       bool                            assume_no_z_fights;
+       bool                            commutative_blend_add;
+       bool                            clear_db_cache_before_clear;
        bool                            has_msaa_sample_loc_bug;
        bool                            dpbb_allowed;
        bool                            dfsm_allowed;
@@ -155,6 +159,7 @@ struct si_sampler_view {
        ubyte                           base_level;
        ubyte                           block_width;
        bool is_stencil_sampler;
+       bool is_integer;
        bool dcc_incompatible;
 };
 
@@ -165,6 +170,8 @@ struct si_sampler_state {
        unsigned                        magic;
 #endif
        uint32_t                        val[4];
+       uint32_t                        integer_val[4];
+       uint32_t                        upgraded_depth_val[4];
 };
 
 struct si_cs_shader_state {
@@ -175,13 +182,17 @@ struct si_cs_shader_state {
        bool                            uses_scratch;
 };
 
-struct si_textures_info {
-       struct si_sampler_views         views;
+struct si_samplers {
+       struct pipe_sampler_view        *views[SI_NUM_SAMPLERS];
+       struct si_sampler_state         *sampler_states[SI_NUM_SAMPLERS];
+
+       /* The i-th bit is set if that element is enabled (non-NULL resource). */
+       unsigned                        enabled_mask;
        uint32_t                        needs_depth_decompress_mask;
        uint32_t                        needs_color_decompress_mask;
 };
 
-struct si_images_info {
+struct si_images {
        struct pipe_image_view          views[SI_NUM_IMAGES];
        uint32_t                        needs_color_decompress_mask;
        unsigned                        enabled_mask;
@@ -207,6 +218,27 @@ struct si_framebuffer {
        bool                            DB_has_shader_readable_metadata;
 };
 
+struct si_signed_scissor {
+       int minx;
+       int miny;
+       int maxx;
+       int maxy;
+};
+
+struct si_scissors {
+       struct r600_atom                atom;
+       unsigned                        dirty_mask;
+       struct pipe_scissor_state       states[SI_MAX_VIEWPORTS];
+};
+
+struct si_viewports {
+       struct r600_atom                atom;
+       unsigned                        dirty_mask;
+       unsigned                        depth_range_dirty_mask;
+       struct pipe_viewport_state      states[SI_MAX_VIEWPORTS];
+       struct si_signed_scissor        as_scissor[SI_MAX_VIEWPORTS];
+};
+
 struct si_clip_state {
        struct r600_atom                atom;
        struct pipe_clip_state          state;
@@ -223,6 +255,43 @@ struct si_sample_mask {
        uint16_t                sample_mask;
 };
 
+struct si_streamout_target {
+       struct pipe_stream_output_target b;
+
+       /* The buffer where BUFFER_FILLED_SIZE is stored. */
+       struct r600_resource    *buf_filled_size;
+       unsigned                buf_filled_size_offset;
+       bool                    buf_filled_size_valid;
+
+       unsigned                stride_in_dw;
+};
+
+struct si_streamout {
+       struct r600_atom                begin_atom;
+       bool                            begin_emitted;
+
+       unsigned                        enabled_mask;
+       unsigned                        num_targets;
+       struct si_streamout_target      *targets[PIPE_MAX_SO_BUFFERS];
+
+       unsigned                        append_bitmask;
+       bool                            suspended;
+
+       /* External state which comes from the vertex shader,
+        * it must be set explicitly when binding a shader. */
+       uint16_t                        *stride_in_dw;
+       unsigned                        enabled_stream_buffers_mask; /* stream0 buffers0-3 in 4 LSB */
+
+       /* The state of VGT_STRMOUT_BUFFER_(CONFIG|EN). */
+       unsigned                        hw_enabled_mask;
+
+       /* The state of VGT_STRMOUT_(CONFIG|EN). */
+       struct r600_atom                enable_atom;
+       bool                            streamout_enabled;
+       bool                            prims_gen_query_enabled;
+       int                             num_prims_gen_queries;
+};
+
 /* A shader state consists of the shader selector, which is a constant state
  * object shared by multiple contexts and shouldn't be modified, and
  * the current shader variant selected for this context.
@@ -288,6 +357,11 @@ struct si_context {
        void                            *custom_blend_fmask_decompress;
        void                            *custom_blend_eliminate_fastclear;
        void                            *custom_blend_dcc_decompress;
+       void                            *vs_blit_pos;
+       void                            *vs_blit_pos_layered;
+       void                            *vs_blit_color;
+       void                            *vs_blit_color_layered;
+       void                            *vs_blit_texcoord;
        struct si_screen                *screen;
        LLVMTargetMachineRef            tm; /* only non-threaded compilation */
        struct si_shader_ctx_state      fixed_func_tcs_shader;
@@ -321,6 +395,9 @@ struct si_context {
        struct si_shader_data           shader_pointers;
        struct si_stencil_ref           stencil_ref;
        struct r600_atom                spi_map;
+       struct si_scissors              scissors;
+       struct si_streamout             streamout;
+       struct si_viewports             viewports;
 
        /* Precomputed states. */
        struct si_pm4_state             *init_config;
@@ -350,8 +427,8 @@ struct si_context {
        unsigned                        shader_needs_decompress_mask;
        struct si_buffer_resources      rw_buffers;
        struct si_buffer_resources      const_and_shader_buffers[SI_NUM_SHADERS];
-       struct si_textures_info         samplers[SI_NUM_SHADERS];
-       struct si_images_info           images[SI_NUM_SHADERS];
+       struct si_samplers              samplers[SI_NUM_SHADERS];
+       struct si_images                images[SI_NUM_SHADERS];
 
        /* other shader resources */
        struct pipe_constant_buffer     null_const_buf; /* used for set_constant_buffer(NULL) on CIK */
@@ -363,6 +440,8 @@ struct si_context {
        struct r600_resource            *border_color_buffer;
        union pipe_color_union          *border_color_map; /* in VRAM (slow access), little endian */
        unsigned                        border_color_count;
+       unsigned                        num_vs_blit_sgprs;
+       uint32_t                        vs_blit_sh_data[SI_VS_BLIT_SGPRS_POS_TEXCOORD];
 
        /* Vertex and index buffers. */
        bool                            vertex_buffers_dirty;
@@ -433,6 +512,9 @@ struct si_context {
        bool need_check_render_feedback;
        bool                    decompression_enabled;
 
+       bool                    vs_writes_viewport_index;
+       bool                    vs_disables_clipping_viewport;
+
        /* Precomputed IA_MULTI_VGT_PARAM */
        union si_vgt_param_key  ia_multi_vgt_param_key;
        unsigned                ia_multi_vgt_param[SI_NUM_VGT_PARAM_STATES];
@@ -461,6 +543,15 @@ struct si_context {
        /* Bindless state */
        bool                    uses_bindless_samplers;
        bool                    uses_bindless_images;
+
+       /* MSAA sample locations.
+        * The first index is the sample index.
+        * The second index is the coordinate: X, Y. */
+       float                   sample_locations_1x[1][2];
+       float                   sample_locations_2x[2][2];
+       float                   sample_locations_4x[4][2];
+       float                   sample_locations_8x[8][2];
+       float                   sample_locations_16x[16][2];
 };
 
 /* cik_sdma.c */
@@ -468,8 +559,7 @@ void cik_init_sdma_functions(struct si_context *sctx);
 
 /* si_blit.c */
 void si_init_blit_functions(struct si_context *sctx);
-void si_decompress_graphics_textures(struct si_context *sctx);
-void si_decompress_compute_textures(struct si_context *sctx);
+void si_decompress_textures(struct si_context *sctx, unsigned shader_mask);
 void si_resource_copy_region(struct pipe_context *ctx,
                             struct pipe_resource *dst,
                             unsigned dst_level,
@@ -532,6 +622,11 @@ struct pipe_video_codec *si_uvd_create_decoder(struct pipe_context *context,
 struct pipe_video_buffer *si_video_buffer_create(struct pipe_context *pipe,
                                                 const struct pipe_video_buffer *tmpl);
 
+/* si_viewport.c */
+void si_update_vs_viewport_state(struct si_context *ctx);
+void si_init_viewport_functions(struct si_context *ctx);
+
+
 /*
  * common helpers
  */
@@ -596,6 +691,12 @@ static inline struct si_shader* si_get_vs_state(struct si_context *sctx)
        return vs->current ? vs->current : NULL;
 }
 
+static inline bool si_get_strmout_en(struct si_context *sctx)
+{
+       return sctx->streamout.streamout_enabled ||
+              sctx->streamout.prims_gen_query_enabled;
+}
+
 static inline unsigned
 si_optimal_tcc_alignment(struct si_context *sctx, unsigned upload_size)
 {