Path: blob/21.2-virgl/src/intel/common/intel_aux_map.h
4547 views
/*1* Copyright (c) 2018 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* 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, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#ifndef INTEL_AUX_MAP_H24#define INTEL_AUX_MAP_H2526#include "intel_buffer_alloc.h"2728#include "isl/isl.h"2930#include <stdint.h>3132#ifdef __cplusplus33extern "C" {34#endif3536/**37* Auxiliary surface mapping implementation38*39* These functions are implemented in common code shared by drivers.40*/4142struct intel_aux_map_context;43struct intel_device_info;4445#define INTEL_AUX_MAP_ADDRESS_MASK 0x0000ffffffffff00ull46#define INTEL_AUX_MAP_FORMAT_BITS_MASK 0xfff0000000000000ull47#define INTEL_AUX_MAP_ENTRY_VALID_BIT 0x1ull48#define INTEL_AUX_MAP_GFX12_CCS_SCALE 25649#define INTEL_AUX_MAP_MAIN_PAGE_SIZE (64 * 1024)50#define INTEL_AUX_MAP_AUX_PAGE_SIZE \51(INTEL_AUX_MAP_MAIN_PAGE_SIZE / INTEL_AUX_MAP_GFX12_CCS_SCALE)5253struct intel_aux_map_context *54intel_aux_map_init(void *driver_ctx,55struct intel_mapped_pinned_buffer_alloc *buffer_alloc,56const struct intel_device_info *devinfo);5758void59intel_aux_map_finish(struct intel_aux_map_context *ctx);6061uint32_t62intel_aux_map_get_state_num(struct intel_aux_map_context *ctx);6364/** Returns the current number of buffers used by the aux-map tables65*66* When preparing to execute a new batch, use this function to determine how67* many buffers will be required. More buffers may be added by concurrent68* accesses of the aux-map functions, but they won't be required for since69* they involve surfaces not used by this batch.70*/71uint32_t72intel_aux_map_get_num_buffers(struct intel_aux_map_context *ctx);7374/** Fill an array of exec_object2 with aux-map buffer handles75*76* The intel_aux_map_get_num_buffers call should be made, then the driver can77* make sure the `obj` array is large enough before calling this function.78*/79void80intel_aux_map_fill_bos(struct intel_aux_map_context *ctx, void **driver_bos,81uint32_t max_bos);8283uint64_t84intel_aux_map_get_base(struct intel_aux_map_context *ctx);8586uint64_t87intel_aux_map_format_bits(enum isl_tiling tiling, enum isl_format format,88uint8_t plane);8990uint64_t91intel_aux_map_format_bits_for_isl_surf(const struct isl_surf *isl_surf);9293uint64_t *94intel_aux_map_get_entry(struct intel_aux_map_context *ctx,95uint64_t address,96uint64_t *entry_address);9798void99intel_aux_map_add_mapping(struct intel_aux_map_context *ctx, uint64_t address,100uint64_t aux_address, uint64_t main_size_B,101uint64_t format_bits);102103void104intel_aux_map_unmap_range(struct intel_aux_map_context *ctx, uint64_t address,105uint64_t size);106107#ifdef __cplusplus108}109#endif110111#endif /* INTEL_AUX_MAP_H */112113114