Path: blob/21.2-virgl/src/gallium/drivers/crocus/crocus_screen.h
4570 views
/*1* Copyright © 2017 Intel Corporation2*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* on the rights to use, copy, modify, merge, publish, distribute, sub7* license, and/or sell copies of the Software, and to permit persons to whom8* the 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 NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20* USE OR OTHER DEALINGS IN THE SOFTWARE.21*/22#ifndef CROCUS_SCREEN_H23#define CROCUS_SCREEN_H2425#include "pipe/p_screen.h"26#include "pipe/p_state.h"27#include "frontend/drm_driver.h"28#include "util/disk_cache.h"29#include "util/slab.h"30#include "util/u_screen.h"31#include "intel/dev/intel_device_info.h"32#include "intel/isl/isl.h"33#include "crocus_bufmgr.h"34#include "compiler/shader_enums.h"3536struct crocus_monitor_config;37struct crocus_resource;38struct crocus_context;39struct crocus_sampler_state;40struct brw_vue_map;41struct brw_tcs_prog_key;42struct brw_tes_prog_key;43struct brw_cs_prog_key;44struct brw_wm_prog_key;45struct brw_vs_prog_key;46struct brw_gs_prog_key;47struct shader_info;4849#define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x))50#define WRITE_ONCE(x, v) *(volatile __typeof__(x) *)&(x) = (v)5152#define CROCUS_MAX_TEXTURE_SAMPLERS 3253#define CROCUS_MAX_SOL_BUFFERS 454#define CROCUS_MAP_BUFFER_ALIGNMENT 64555657/**58* Virtual table for generation-specific (genxml) function calls.59*/60struct crocus_vtable {61void (*destroy_state)(struct crocus_context *ice);62void (*init_render_context)(struct crocus_batch *batch);63void (*init_compute_context)(struct crocus_batch *batch);64void (*upload_render_state)(struct crocus_context *ice,65struct crocus_batch *batch,66const struct pipe_draw_info *draw,67unsigned drawid_offset,68const struct pipe_draw_indirect_info *indirect,69const struct pipe_draw_start_count_bias *sc);70void (*update_surface_base_address)(struct crocus_batch *batch);7172void (*upload_compute_state)(struct crocus_context *ice,73struct crocus_batch *batch,74const struct pipe_grid_info *grid);75void (*rebind_buffer)(struct crocus_context *ice,76struct crocus_resource *res);77void (*resolve_conditional_render)(struct crocus_context *ice);78void (*emit_compute_predicate)(struct crocus_batch *batch);79void (*load_register_reg32)(struct crocus_batch *batch, uint32_t dst,80uint32_t src);81void (*load_register_reg64)(struct crocus_batch *batch, uint32_t dst,82uint32_t src);83void (*load_register_imm32)(struct crocus_batch *batch, uint32_t reg,84uint32_t val);85void (*load_register_imm64)(struct crocus_batch *batch, uint32_t reg,86uint64_t val);87void (*load_register_mem32)(struct crocus_batch *batch, uint32_t reg,88struct crocus_bo *bo, uint32_t offset);89void (*load_register_mem64)(struct crocus_batch *batch, uint32_t reg,90struct crocus_bo *bo, uint32_t offset);91void (*store_register_mem32)(struct crocus_batch *batch, uint32_t reg,92struct crocus_bo *bo, uint32_t offset,93bool predicated);94void (*store_register_mem64)(struct crocus_batch *batch, uint32_t reg,95struct crocus_bo *bo, uint32_t offset,96bool predicated);97void (*store_data_imm32)(struct crocus_batch *batch,98struct crocus_bo *bo, uint32_t offset,99uint32_t value);100void (*store_data_imm64)(struct crocus_batch *batch,101struct crocus_bo *bo, uint32_t offset,102uint64_t value);103void (*copy_mem_mem)(struct crocus_batch *batch,104struct crocus_bo *dst_bo, uint32_t dst_offset,105struct crocus_bo *src_bo, uint32_t src_offset,106unsigned bytes);107void (*emit_raw_pipe_control)(struct crocus_batch *batch,108const char *reason, uint32_t flags,109struct crocus_bo *bo, uint32_t offset,110uint64_t imm);111112void (*emit_mi_report_perf_count)(struct crocus_batch *batch,113struct crocus_bo *bo,114uint32_t offset_in_bytes,115uint32_t report_id);116117uint32_t *(*create_so_decl_list)(const struct pipe_stream_output_info *sol,118const struct brw_vue_map *vue_map);119void (*populate_vs_key)(const struct crocus_context *ice,120const struct shader_info *info,121gl_shader_stage last_stage,122struct brw_vs_prog_key *key);123void (*populate_tcs_key)(const struct crocus_context *ice,124struct brw_tcs_prog_key *key);125void (*populate_tes_key)(const struct crocus_context *ice,126const struct shader_info *info,127gl_shader_stage last_stage,128struct brw_tes_prog_key *key);129void (*populate_gs_key)(const struct crocus_context *ice,130const struct shader_info *info,131gl_shader_stage last_stage,132struct brw_gs_prog_key *key);133void (*populate_fs_key)(const struct crocus_context *ice,134const struct shader_info *info,135struct brw_wm_prog_key *key);136void (*populate_cs_key)(const struct crocus_context *ice,137struct brw_cs_prog_key *key);138void (*fill_clamp_mask)(const struct crocus_sampler_state *state,139int s,140uint32_t *clamp_mask);141void (*lost_genx_state)(struct crocus_context *ice, struct crocus_batch *batch);142143void (*finish_batch)(struct crocus_batch *batch); /* haswell only */144145void (*upload_urb_fence)(struct crocus_batch *batch); /* gen4/5 only */146147bool (*blit_blt)(struct crocus_batch *batch,148const struct pipe_blit_info *info);149bool (*copy_region_blt)(struct crocus_batch *batch,150struct crocus_resource *dst,151unsigned dst_level,152unsigned dstx, unsigned dsty, unsigned dstz,153struct crocus_resource *src,154unsigned src_level,155const struct pipe_box *src_box);156bool (*calculate_urb_fence)(struct crocus_batch *batch, unsigned csize,157unsigned vsize, unsigned sfsize);158void (*batch_reset_dirty)(struct crocus_batch *batch);159unsigned (*translate_prim_type)(enum pipe_prim_type prim, uint8_t verts_per_patch);160161void (*update_so_strides)(struct crocus_context *ice,162uint16_t *strides);163164uint32_t (*get_so_offset)(struct pipe_stream_output_target *tgt);165};166167struct crocus_screen {168struct pipe_screen base;169170uint32_t refcount;171172/** Global slab allocator for crocus_transfer_map objects */173struct slab_parent_pool transfer_pool;174175/** drm device file descriptor, shared with bufmgr, do not close. */176int fd;177178/**179* drm device file descriptor to used for window system integration, owned180* by iris_screen, can be a different DRM instance than fd.181*/182int winsys_fd;183184/** PCI ID for our GPU device */185int pci_id;186187bool no_hw;188189struct crocus_vtable vtbl;190191/** Global program_string_id counter (see get_program_string_id()) */192unsigned program_id;193194/** Precompile shaders at link time? (Can be disabled for debugging.) */195bool precompile;196197/** driconf options and application workarounds */198struct {199/** Dual color blend by location instead of index (for broken apps) */200bool dual_color_blend_by_location;201bool disable_throttling;202bool always_flush_cache;203} driconf;204205unsigned subslice_total;206207uint64_t aperture_bytes;208209struct intel_device_info devinfo;210struct isl_device isl_dev;211struct crocus_bufmgr *bufmgr;212struct brw_compiler *compiler;213struct crocus_monitor_config *monitor_cfg;214bool has_swizzling;215216const struct intel_l3_config *l3_config_3d;217const struct intel_l3_config *l3_config_cs;218219struct disk_cache *disk_cache;220};221222struct pipe_screen *223crocus_screen_create(int fd, const struct pipe_screen_config *config);224225void crocus_screen_destroy(struct crocus_screen *screen);226227UNUSED static inline struct pipe_screen *228crocus_pscreen_ref(struct pipe_screen *pscreen)229{230struct crocus_screen *screen = (struct crocus_screen *) pscreen;231232p_atomic_inc(&screen->refcount);233return pscreen;234}235236UNUSED static inline void237crocus_pscreen_unref(struct pipe_screen *pscreen)238{239struct crocus_screen *screen = (struct crocus_screen *) pscreen;240241if (p_atomic_dec_zero(&screen->refcount))242crocus_screen_destroy(screen);243}244245bool246crocus_is_format_supported(struct pipe_screen *pscreen,247enum pipe_format format,248enum pipe_texture_target target,249unsigned sample_count,250unsigned storage_sample_count,251unsigned usage);252253void crocus_disk_cache_init(struct crocus_screen *screen);254255#endif256257258