Path: blob/21.2-virgl/src/gallium/drivers/freedreno/ir3/ir3_cache.h
4574 views
/*1* Copyright (C) 2018 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 IR3_CACHE_H_27#define IR3_CACHE_H_2829#include "ir3/ir3_shader.h"3031/*32* An in-memory cache for mapping shader state objects plus shader key to33* hw specific state object for the specified shader variant. This is to34* allow re-using things like the register setup for varying linkage, etc.35*/3637/* key into program state cache */38struct ir3_cache_key {39struct ir3_shader_state *vs, *hs, *ds, *gs, *fs; // 5 pointers40struct ir3_shader_key key; // 7 dwords41};4243/* per-gen backend program state object should subclass this for it's44* state object, mainly because we need a copy of the key that is not45* allocated on the stack46*/47struct ir3_program_state {48struct ir3_cache_key key;49};5051struct ir3_cache_funcs {52struct ir3_program_state *(*create_state)(53void *data, struct ir3_shader_variant *bs, /* binning pass vs */54struct ir3_shader_variant *vs, struct ir3_shader_variant *hs,55struct ir3_shader_variant *ds, struct ir3_shader_variant *gs,56struct ir3_shader_variant *fs, const struct ir3_shader_key *key);57void (*destroy_state)(void *data, struct ir3_program_state *state);58};5960struct ir3_cache;6162/* construct a shader cache. Free with ralloc_free() */63struct ir3_cache *ir3_cache_create(const struct ir3_cache_funcs *funcs,64void *data);65void ir3_cache_destroy(struct ir3_cache *cache);6667/* debug callback is used for shader-db logs in case the lookup triggers68* shader variant compilation.69*/70struct ir3_program_state *ir3_cache_lookup(struct ir3_cache *cache,71const struct ir3_cache_key *key,72struct pipe_debug_callback *debug);7374/* call when an API level state object is destroyed, to invalidate75* cache entries which reference that state object.76*/77void ir3_cache_invalidate(struct ir3_cache *cache, void *stobj);7879#endif /* IR3_CACHE_H_ */808182