radeonsi: skip DCC render feedback checking if color writes are disabled
[mesa.git] / src / gallium / drivers / radeonsi / si_pipe.h
index 0c16cfb71b848b2497aa82c8f863f4207f5a9c6a..e65c946d1867166a8c436f09dd4e45013277d672 100644 (file)
@@ -94,9 +94,19 @@ struct hash_table;
 struct u_suballocator;
 
 struct si_screen {
-       struct r600_common_screen       b;
+       struct pipe_screen              b;
+       struct radeon_winsys            *ws;
+       struct disk_cache               *disk_shader_cache;
+
+       struct radeon_info              info;
+       uint64_t                        debug_flags;
+       char                            renderer_string[100];
+
        unsigned                        gs_table_depth;
        unsigned                        tess_offchip_block_dw_size;
+       unsigned                        tess_offchip_ring_size;
+       unsigned                        tess_factor_ring_size;
+       unsigned                        vgt_hs_offchip_param;
        bool                            has_clear_state;
        bool                            has_distributed_tess;
        bool                            has_draw_indirect_multi;
@@ -113,6 +123,66 @@ struct si_screen {
        /* Whether shaders are monolithic (1-part) or separate (3-part). */
        bool                            use_monolithic_shaders;
        bool                            record_llvm_ir;
+       bool                            has_rbplus;     /* if RB+ registers exist */
+       bool                            rbplus_allowed; /* if RB+ is allowed */
+       bool                            dcc_msaa_allowed;
+       bool                            cpdma_prefetch_writes_memory;
+
+       struct slab_parent_pool         pool_transfers;
+
+       /* Texture filter settings. */
+       int                             force_aniso; /* -1 = disabled */
+
+       /* Auxiliary context. Mainly used to initialize resources.
+        * It must be locked prior to using and flushed before unlocking. */
+       struct pipe_context             *aux_context;
+       mtx_t                           aux_context_lock;
+
+       /* This must be in the screen, because UE4 uses one context for
+        * compilation and another one for rendering.
+        */
+       unsigned                        num_compilations;
+       /* Along with ST_DEBUG=precompile, this should show if applications
+        * are loading shaders on demand. This is a monotonic counter.
+        */
+       unsigned                        num_shaders_created;
+       unsigned                        num_shader_cache_hits;
+
+       /* GPU load thread. */
+       mtx_t                           gpu_load_mutex;
+       thrd_t                          gpu_load_thread;
+       union r600_mmio_counters        mmio_counters;
+       volatile unsigned               gpu_load_stop_thread; /* bool */
+
+       /* Performance counters. */
+       struct r600_perfcounters        *perfcounters;
+
+       /* If pipe_screen wants to recompute and re-emit the framebuffer,
+        * sampler, and image states of all contexts, it should atomically
+        * increment this.
+        *
+        * Each context will compare this with its own last known value of
+        * the counter before drawing and re-emit the states accordingly.
+        */
+       unsigned                        dirty_tex_counter;
+
+       /* Atomically increment this counter when an existing texture's
+        * metadata is enabled or disabled in a way that requires changing
+        * contexts' compressed texture binding masks.
+        */
+       unsigned                        compressed_colortex_counter;
+
+       struct {
+               /* Context flags to set so that all writes from earlier jobs
+                * in the CP are seen by L2 clients.
+                */
+               unsigned cp_to_L2;
+
+               /* Context flags to set so that all writes from earlier jobs
+                * that end in L2 are seen by CP.
+                */
+               unsigned L2_to_cp;
+       } barrier_flags;
 
        mtx_t                   shader_parts_mutex;
        struct si_shader_part           *vs_prologs;
@@ -215,6 +285,7 @@ struct si_framebuffer {
        ubyte                           nr_samples:5; /* at most 16xAA */
        ubyte                           log_samples:3; /* at most 4 = 16xAA */
        ubyte                           compressed_cb_mask;
+       ubyte                           uncompressed_cb_mask;
        ubyte                           color_is_int8;
        ubyte                           color_is_int10;
        ubyte                           dirty_cbufs;
@@ -427,8 +498,12 @@ struct si_context {
        bool                            flatshade;
        bool                            do_update_shaders;
 
+       /* vertex buffer descriptors */
+       uint32_t *vb_descriptors_gpu_list;
+       struct r600_resource *vb_descriptors_buffer;
+       unsigned vb_descriptors_offset;
+
        /* shader descriptors */
-       struct si_descriptors           vertex_buffers;
        struct si_descriptors           descriptors[SI_NUM_DESCS];
        unsigned                        descriptors_dirty;
        unsigned                        shader_pointers_dirty;
@@ -442,8 +517,7 @@ struct si_context {
        struct pipe_constant_buffer     null_const_buf; /* used for set_constant_buffer(NULL) on CIK */
        struct pipe_resource            *esgs_ring;
        struct pipe_resource            *gsvs_ring;
-       struct pipe_resource            *tf_ring;
-       struct pipe_resource            *tess_offchip_ring;
+       struct pipe_resource            *tess_rings;
        union pipe_color_union          *border_color_table; /* in CPU memory, any endian */
        struct r600_resource            *border_color_buffer;
        union pipe_color_union          *border_color_map; /* in VRAM (slow access), little endian */
@@ -458,6 +532,7 @@ struct si_context {
 
        /* MSAA config state. */
        int                             ps_iter_samples;
+       bool                            ps_uses_fbfetch;
        bool                            smoothing_enabled;
 
        /* DB render state. */
@@ -753,13 +828,13 @@ static inline struct si_shader* si_get_vs_state(struct si_context *sctx)
 static inline bool si_can_dump_shader(struct si_screen *sscreen,
                                      unsigned processor)
 {
-       return sscreen->b.debug_flags & (1 << processor);
+       return sscreen->debug_flags & (1 << processor);
 }
 
 static inline bool si_extra_shader_checks(struct si_screen *sscreen,
                                          unsigned processor)
 {
-       return (sscreen->b.debug_flags & DBG(CHECK_IR)) ||
+       return (sscreen->debug_flags & DBG(CHECK_IR)) ||
               si_can_dump_shader(sscreen, processor);
 }
 
@@ -780,7 +855,7 @@ si_optimal_tcc_alignment(struct si_context *sctx, unsigned upload_size)
         * If the upload size is greater, align it to the cache line size.
         */
        alignment = util_next_power_of_two(upload_size);
-       tcc_cache_line_size = sctx->screen->b.info.tcc_cache_line_size;
+       tcc_cache_line_size = sctx->screen->info.tcc_cache_line_size;
        return MIN2(alignment, tcc_cache_line_size);
 }
 
@@ -857,4 +932,29 @@ vi_tc_compat_htile_enabled(struct r600_texture *tex, unsigned level)
        return tex->tc_compatible_htile && level == 0;
 }
 
+static inline unsigned si_get_ps_iter_samples(struct si_context *sctx)
+{
+       if (sctx->ps_uses_fbfetch)
+               return sctx->framebuffer.nr_samples;
+
+       return sctx->ps_iter_samples;
+}
+
+static inline unsigned si_get_total_colormask(struct si_context *sctx)
+{
+       if (sctx->queued.named.rasterizer->rasterizer_discard)
+               return 0;
+
+       struct si_shader_selector *ps = sctx->ps_shader.cso;
+       unsigned colormask = sctx->framebuffer.colorbuf_enabled_4bit &
+                            sctx->queued.named.blend->cb_target_mask;
+
+       if (!ps->info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS])
+               colormask &= ps->colors_written_4bit;
+       else if (!ps->colors_written_4bit)
+               colormask = 0; /* color0 writes all cbufs, but it's not written */
+
+       return colormask;
+}
+
 #endif