radeonsi: update copyrights
[mesa.git] / src / gallium / drivers / radeon / r600_pipe_common.h
index e9b6d46d02f01c5bc39b652a769c8951c4c5d4ef..f40f8faefc2288d9fd2c24a91cbbf539e406d223 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2013 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -53,6 +54,8 @@ struct si_context;
 #define R600_RESOURCE_FLAG_FORCE_TILING                (PIPE_RESOURCE_FLAG_DRV_PRIV << 2)
 #define R600_RESOURCE_FLAG_DISABLE_DCC         (PIPE_RESOURCE_FLAG_DRV_PRIV << 3)
 #define R600_RESOURCE_FLAG_UNMAPPABLE          (PIPE_RESOURCE_FLAG_DRV_PRIV << 4)
+#define R600_RESOURCE_FLAG_READ_ONLY           (PIPE_RESOURCE_FLAG_DRV_PRIV << 5)
+#define R600_RESOURCE_FLAG_32BIT               (PIPE_RESOURCE_FLAG_DRV_PRIV << 6)
 
 /* Debug flags. */
 enum {
@@ -75,7 +78,6 @@ enum {
 
        /* Shader compiler options (with no effect on the shader cache): */
        DBG_CHECK_IR,
-       DBG_PRECOMPILE,
        DBG_NIR,
        DBG_MONOLITHIC_SHADERS,
        DBG_NO_OPT_VARIANT,
@@ -109,6 +111,7 @@ enum {
        DBG_NO_DCC_FB,
        DBG_NO_DCC_MSAA,
        DBG_DCC_MSAA,
+       DBG_NO_FMASK,
 
        /* Tests: */
        DBG_TEST_DMA,
@@ -359,91 +362,13 @@ struct r600_memory_object {
        uint32_t                        offset;
 };
 
-struct r600_common_screen {
-       struct pipe_screen              b;
-       struct radeon_winsys            *ws;
-       enum radeon_family              family;
-       enum chip_class                 chip_class;
-       struct radeon_info              info;
-       uint64_t                        debug_flags;
-       bool                            has_rbplus;     /* if RB+ registers exist */
-       bool                            rbplus_allowed; /* if RB+ is allowed */
-       bool                            dcc_msaa_allowed;
-
-       struct disk_cache               *disk_shader_cache;
-
-       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 */
-
-       char                            renderer_string[100];
-
-       /* 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;
-};
-
 /* This encapsulates a state or an operation which can emitted into the GPU
  * command stream. */
 struct r600_atom {
-       void (*emit)(struct r600_common_context *ctx, struct r600_atom *state);
+       void (*emit)(struct si_context *ctx, struct r600_atom *state);
        unsigned short          id;
 };
 
-struct r600_ring {
-       struct radeon_winsys_cs         *cs;
-       void (*flush)(void *ctx, unsigned flags,
-                     struct pipe_fence_handle **fence);
-};
-
 /* Saved CS data for debugging features. */
 struct radeon_saved_cs {
        uint32_t                        *ib;
@@ -456,16 +381,17 @@ struct radeon_saved_cs {
 struct r600_common_context {
        struct pipe_context b; /* base class */
 
-       struct r600_common_screen       *screen;
+       struct si_screen                *screen;
        struct radeon_winsys            *ws;
        struct radeon_winsys_ctx        *ctx;
        enum radeon_family              family;
        enum chip_class                 chip_class;
-       struct r600_ring                gfx;
-       struct r600_ring                dma;
+       struct radeon_winsys_cs         *gfx_cs;
+       struct radeon_winsys_cs         *dma_cs;
        struct pipe_fence_handle        *last_gfx_fence;
        struct pipe_fence_handle        *last_sdma_fence;
        struct r600_resource            *eop_bug_scratch;
+       struct u_upload_mgr             *cached_gtt_allocator;
        unsigned                        num_gfx_cs_flushes;
        unsigned                        initial_gfx_cs_size;
        unsigned                        gpu_reset_counter;
@@ -554,57 +480,19 @@ struct r600_common_context {
 
        void (*dma_clear_buffer)(struct pipe_context *ctx, struct pipe_resource *dst,
                                 uint64_t offset, uint64_t size, unsigned value);
-
-       void (*blit_decompress_depth)(struct pipe_context *ctx,
-                                     struct r600_texture *texture,
-                                     struct r600_texture *staging,
-                                     unsigned first_level, unsigned last_level,
-                                     unsigned first_layer, unsigned last_layer,
-                                     unsigned first_sample, unsigned last_sample);
-
-       void (*decompress_dcc)(struct pipe_context *ctx,
-                              struct r600_texture *rtex);
-
-       /* Reallocate the buffer and update all resource bindings where
-        * the buffer is bound, including all resource descriptors. */
-       void (*invalidate_buffer)(struct pipe_context *ctx, struct pipe_resource *buf);
-
-       /* Update all resource bindings where the buffer is bound, including
-        * all resource descriptors. This is invalidate_buffer without
-        * the invalidation. */
-       void (*rebind_buffer)(struct pipe_context *ctx, struct pipe_resource *buf,
-                             uint64_t old_gpu_address);
-
-       /* Enable or disable occlusion queries. */
-       void (*set_occlusion_query_state)(struct pipe_context *ctx,
-                                         bool old_enable,
-                                         bool old_perfect_enable);
-
-       void (*save_qbo_state)(struct pipe_context *ctx, struct r600_qbo_state *st);
-
-       /* This ensures there is enough space in the command stream. */
-       void (*need_gfx_cs_space)(struct pipe_context *ctx, unsigned num_dw,
-                                 bool include_draw_vbo);
-
-       void (*set_atom_dirty)(struct r600_common_context *ctx,
-                              struct r600_atom *atom, bool dirty);
-
-       void (*check_vm_faults)(struct r600_common_context *ctx,
-                               struct radeon_saved_cs *saved,
-                               enum ring_type ring);
 };
 
 /* r600_buffer_common.c */
-bool si_rings_is_buffer_referenced(struct r600_common_context *ctx,
+bool si_rings_is_buffer_referenced(struct si_context *sctx,
                                   struct pb_buffer *buf,
                                   enum radeon_bo_usage usage);
-void *si_buffer_map_sync_with_rings(struct r600_common_context *ctx,
+void *si_buffer_map_sync_with_rings(struct si_context *sctx,
                                    struct r600_resource *resource,
                                    unsigned usage);
-void si_init_resource_fields(struct r600_common_screen *rscreen,
+void si_init_resource_fields(struct si_screen *sscreen,
                             struct r600_resource *res,
                             uint64_t size, unsigned alignment);
-bool si_alloc_resource(struct r600_common_screen *rscreen,
+bool si_alloc_resource(struct si_screen *sscreen,
                       struct r600_resource *res);
 struct pipe_resource *si_aligned_buffer_create(struct pipe_screen *screen,
                                               unsigned flags,
@@ -618,61 +506,50 @@ void si_init_screen_buffer_functions(struct si_screen *sscreen);
 void si_init_buffer_functions(struct si_context *sctx);
 
 /* r600_common_pipe.c */
-void si_gfx_write_event_eop(struct r600_common_context *ctx,
-                           unsigned event, unsigned event_flags,
-                           unsigned data_sel,
-                           struct r600_resource *buf, uint64_t va,
-                           uint32_t new_fence, unsigned query_type);
-unsigned si_gfx_write_fence_dwords(struct r600_common_screen *screen);
-void si_gfx_wait_fence(struct r600_common_context *ctx,
-                      uint64_t va, uint32_t ref, uint32_t mask);
 bool si_common_context_init(struct r600_common_context *rctx,
-                           struct r600_common_screen *rscreen,
+                           struct si_screen *sscreen,
                            unsigned context_flags);
 void si_common_context_cleanup(struct r600_common_context *rctx);
-void si_screen_clear_buffer(struct r600_common_screen *rscreen, struct pipe_resource *dst,
-                           uint64_t offset, uint64_t size, unsigned value);
-void si_need_dma_space(struct r600_common_context *ctx, unsigned num_dw,
-                      struct r600_resource *dst, struct r600_resource *src);
-void si_save_cs(struct radeon_winsys *ws, struct radeon_winsys_cs *cs,
-               struct radeon_saved_cs *saved, bool get_buffer_list);
-void si_clear_saved_cs(struct radeon_saved_cs *saved);
 bool si_check_device_reset(struct r600_common_context *rctx);
 
 /* r600_gpu_load.c */
-void si_gpu_load_kill_thread(struct r600_common_screen *rscreen);
-uint64_t si_begin_counter(struct r600_common_screen *rscreen, unsigned type);
-unsigned si_end_counter(struct r600_common_screen *rscreen, unsigned type,
+void si_gpu_load_kill_thread(struct si_screen *sscreen);
+uint64_t si_begin_counter(struct si_screen *sscreen, unsigned type);
+unsigned si_end_counter(struct si_screen *sscreen, unsigned type,
                        uint64_t begin);
 
 /* r600_perfcounters.c */
-void si_perfcounters_destroy(struct r600_common_screen *rscreen);
+void si_perfcounters_destroy(struct si_screen *sscreen);
 
 /* r600_query.c */
-void si_init_screen_query_functions(struct r600_common_screen *rscreen);
-void si_init_query_functions(struct r600_common_context *rctx);
-void si_suspend_queries(struct r600_common_context *ctx);
-void si_resume_queries(struct r600_common_context *ctx);
+void si_init_screen_query_functions(struct si_screen *sscreen);
+void si_init_query_functions(struct si_context *sctx);
+void si_suspend_queries(struct si_context *sctx);
+void si_resume_queries(struct si_context *sctx);
 
 /* r600_texture.c */
-bool si_prepare_for_dma_blit(struct r600_common_context *rctx,
+bool si_prepare_for_dma_blit(struct si_context *sctx,
                             struct r600_texture *rdst,
                             unsigned dst_level, unsigned dstx,
                             unsigned dsty, unsigned dstz,
                             struct r600_texture *rsrc,
                             unsigned src_level,
                             const struct pipe_box *src_box);
-void si_texture_get_fmask_info(struct r600_common_screen *rscreen,
+void si_texture_get_fmask_info(struct si_screen *sscreen,
                               struct r600_texture *rtex,
                               unsigned nr_samples,
                               struct r600_fmask_info *out);
-void si_texture_get_cmask_info(struct r600_common_screen *rscreen,
+void si_texture_get_cmask_info(struct si_screen *sscreen,
                               struct r600_texture *rtex,
                               struct r600_cmask_info *out);
+void si_eliminate_fast_color_clear(struct si_context *sctx,
+                                  struct r600_texture *rtex);
+void si_texture_discard_cmask(struct si_screen *sscreen,
+                             struct r600_texture *rtex);
 bool si_init_flushed_depth_texture(struct pipe_context *ctx,
                                   struct pipe_resource *texture,
                                   struct r600_texture **staging);
-void si_print_texture_info(struct r600_common_screen *rscreen,
+void si_print_texture_info(struct si_screen *sscreen,
                           struct r600_texture *rtex, struct u_log_context *log);
 struct pipe_resource *si_texture_create(struct pipe_screen *screen,
                                        const struct pipe_resource *templ);
@@ -681,7 +558,7 @@ bool vi_dcc_formats_compatible(enum pipe_format format1,
 bool vi_dcc_formats_are_incompatible(struct pipe_resource *tex,
                                     unsigned level,
                                     enum pipe_format view_format);
-void vi_disable_dcc_if_incompatible_format(struct r600_common_context *rctx,
+void vi_disable_dcc_if_incompatible_format(struct si_context *sctx,
                                           struct pipe_resource *tex,
                                           unsigned level,
                                           enum pipe_format view_format);
@@ -691,7 +568,7 @@ struct pipe_surface *si_create_surface_custom(struct pipe_context *pipe,
                                              unsigned width0, unsigned height0,
                                              unsigned width, unsigned height);
 unsigned si_translate_colorswap(enum pipe_format format, bool do_endian_swap);
-void vi_separate_dcc_try_enable(struct r600_common_context *rctx,
+void vi_separate_dcc_try_enable(struct si_context *sctx,
                                struct r600_texture *tex);
 void vi_separate_dcc_start_query(struct pipe_context *ctx,
                                 struct r600_texture *tex);
@@ -699,10 +576,10 @@ void vi_separate_dcc_stop_query(struct pipe_context *ctx,
                                struct r600_texture *tex);
 void vi_separate_dcc_process_and_reset_stats(struct pipe_context *ctx,
                                             struct r600_texture *tex);
-bool si_texture_disable_dcc(struct r600_common_context *rctx,
+bool si_texture_disable_dcc(struct si_context *sctx,
                            struct r600_texture *rtex);
-void si_init_screen_texture_functions(struct r600_common_screen *rscreen);
-void si_init_context_texture_functions(struct r600_common_context *rctx);
+void si_init_screen_texture_functions(struct si_screen *sscreen);
+void si_init_context_texture_functions(struct si_context *sctx);
 
 
 /* Inline helpers. */