Path: blob/21.2-virgl/src/gallium/drivers/freedreno/freedreno_screen.h
4570 views
/*1* Copyright (C) 2012 Rob Clark <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Rob Clark <[email protected]>24*/2526#ifndef FREEDRENO_SCREEN_H_27#define FREEDRENO_SCREEN_H_2829#include "common/freedreno_dev_info.h"30#include "drm/freedreno_drmif.h"31#include "drm/freedreno_ringbuffer.h"32#include "perfcntrs/freedreno_perfcntr.h"3334#include "pipe/p_screen.h"35#include "renderonly/renderonly.h"36#include "util/debug.h"37#include "util/simple_mtx.h"38#include "util/slab.h"39#include "util/u_idalloc.h"40#include "util/u_memory.h"41#include "util/u_queue.h"4243#include "freedreno_batch_cache.h"44#include "freedreno_gmem.h"45#include "freedreno_util.h"4647struct fd_bo;4849/* Potential reasons for needing to skip bypass path and use GMEM, the50* generation backend can override this with screen->gmem_reason_mask51*/52enum fd_gmem_reason {53FD_GMEM_CLEARS_DEPTH_STENCIL = BIT(0),54FD_GMEM_DEPTH_ENABLED = BIT(1),55FD_GMEM_STENCIL_ENABLED = BIT(2),56FD_GMEM_BLEND_ENABLED = BIT(3),57FD_GMEM_LOGICOP_ENABLED = BIT(4),58FD_GMEM_FB_READ = BIT(5),59};6061struct fd_screen {62struct pipe_screen base;6364struct list_head context_list;6566simple_mtx_t lock;6768/* it would be tempting to use pipe_reference here, but that69* really doesn't work well if it isn't the first member of70* the struct, so not quite so awesome to be adding refcnting71* further down the inheritance hierarchy:72*/73int refcnt;7475/* place for winsys to stash it's own stuff: */76void *winsys_priv;7778struct slab_parent_pool transfer_pool;7980uint64_t gmem_base;81uint32_t gmemsize_bytes;82uint32_t device_id;83uint32_t gpu_id; /* 220, 305, etc */84uint32_t chip_id; /* coreid:8 majorrev:8 minorrev:8 patch:8 */85uint32_t max_freq;86uint32_t ram_size;87uint32_t max_rts; /* max # of render targets */88uint32_t priority_mask;89bool has_timestamp;90bool has_robustness;91bool has_syncobj;9293const struct fd_dev_info *info;94uint32_t ccu_offset_gmem;95uint32_t ccu_offset_bypass;9697/* Bitmask of gmem_reasons that do not force GMEM path over bypass98* for current generation.99*/100enum fd_gmem_reason gmem_reason_mask;101102unsigned num_perfcntr_groups;103const struct fd_perfcntr_group *perfcntr_groups;104105/* generated at startup from the perfcntr groups: */106unsigned num_perfcntr_queries;107struct pipe_driver_query_info *perfcntr_queries;108109void *compiler; /* currently unused for a2xx */110struct util_queue compile_queue; /* currently unused for a2xx */111112struct fd_device *dev;113114/* NOTE: we still need a pipe associated with the screen in a few115* places, like screen->get_timestamp(). For anything context116* related, use ctx->pipe instead.117*/118struct fd_pipe *pipe;119120uint32_t (*setup_slices)(struct fd_resource *rsc);121unsigned (*tile_mode)(const struct pipe_resource *prsc);122int (*layout_resource_for_modifier)(struct fd_resource *rsc,123uint64_t modifier);124125/* indirect-branch emit: */126void (*emit_ib)(struct fd_ringbuffer *ring, struct fd_ringbuffer *target);127128/* simple gpu "memcpy": */129void (*mem_to_mem)(struct fd_ringbuffer *ring, struct pipe_resource *dst,130unsigned dst_off, struct pipe_resource *src,131unsigned src_off, unsigned sizedwords);132133int64_t cpu_gpu_time_delta;134135struct fd_batch_cache batch_cache;136struct fd_gmem_cache gmem_cache;137138bool reorder;139140uint16_t rsc_seqno;141uint16_t ctx_seqno;142struct util_idalloc_mt buffer_ids;143144unsigned num_supported_modifiers;145const uint64_t *supported_modifiers;146147struct renderonly *ro;148};149150static inline struct fd_screen *151fd_screen(struct pipe_screen *pscreen)152{153return (struct fd_screen *)pscreen;154}155156static inline void157fd_screen_lock(struct fd_screen *screen)158{159simple_mtx_lock(&screen->lock);160}161162static inline void163fd_screen_unlock(struct fd_screen *screen)164{165simple_mtx_unlock(&screen->lock);166}167168static inline void169fd_screen_assert_locked(struct fd_screen *screen)170{171simple_mtx_assert_locked(&screen->lock);172}173174bool fd_screen_bo_get_handle(struct pipe_screen *pscreen, struct fd_bo *bo,175struct renderonly_scanout *scanout,176unsigned stride, struct winsys_handle *whandle);177struct fd_bo *fd_screen_bo_from_handle(struct pipe_screen *pscreen,178struct winsys_handle *whandle);179180struct pipe_screen *fd_screen_create(struct fd_device *dev,181struct renderonly *ro);182183static inline boolean184is_a20x(struct fd_screen *screen)185{186return (screen->gpu_id >= 200) && (screen->gpu_id < 210);187}188189static inline boolean190is_a2xx(struct fd_screen *screen)191{192return (screen->gpu_id >= 200) && (screen->gpu_id < 300);193}194195/* is a3xx patch revision 0? */196/* TODO a306.0 probably doesn't need this.. be more clever?? */197static inline boolean198is_a3xx_p0(struct fd_screen *screen)199{200return (screen->chip_id & 0xff0000ff) == 0x03000000;201}202203static inline boolean204is_a3xx(struct fd_screen *screen)205{206return (screen->gpu_id >= 300) && (screen->gpu_id < 400);207}208209static inline boolean210is_a4xx(struct fd_screen *screen)211{212return (screen->gpu_id >= 400) && (screen->gpu_id < 500);213}214215static inline boolean216is_a5xx(struct fd_screen *screen)217{218return (screen->gpu_id >= 500) && (screen->gpu_id < 600);219}220221static inline boolean222is_a6xx(struct fd_screen *screen)223{224return (screen->gpu_id >= 600) && (screen->gpu_id < 700);225}226227/* is it using the ir3 compiler (shader isa introduced with a3xx)? */228static inline boolean229is_ir3(struct fd_screen *screen)230{231return is_a3xx(screen) || is_a4xx(screen) || is_a5xx(screen) ||232is_a6xx(screen);233}234235static inline bool236has_compute(struct fd_screen *screen)237{238return is_a5xx(screen) || is_a6xx(screen);239}240241#endif /* FREEDRENO_SCREEN_H_ */242243244