mirror of https://github.com/xemu-project/xemu.git
nv2a: Const-ify LRU callback key parameters
This commit is contained in:
parent
62ab68b2ab
commit
8b067c5d42
|
@ -131,7 +131,8 @@ static void update_shader_uniform_locs(ShaderBinding *binding)
|
|||
}
|
||||
}
|
||||
|
||||
static void shader_module_cache_entry_init(Lru *lru, LruNode *node, void *key)
|
||||
static void shader_module_cache_entry_init(Lru *lru, LruNode *node,
|
||||
const void *key)
|
||||
{
|
||||
ShaderModuleCacheEntry *module =
|
||||
container_of(node, ShaderModuleCacheEntry, node);
|
||||
|
@ -175,7 +176,7 @@ static void shader_module_cache_entry_post_evict(Lru *lru, LruNode *node)
|
|||
}
|
||||
|
||||
static bool shader_module_cache_entry_compare(Lru *lru, LruNode *node,
|
||||
void *key)
|
||||
const void *key)
|
||||
{
|
||||
ShaderModuleCacheEntry *module =
|
||||
container_of(node, ShaderModuleCacheEntry, node);
|
||||
|
@ -491,7 +492,7 @@ static void *shader_reload_lru_from_disk(void *arg)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void shader_cache_entry_init(Lru *lru, LruNode *node, void *state)
|
||||
static void shader_cache_entry_init(Lru *lru, LruNode *node, const void *state)
|
||||
{
|
||||
ShaderBinding *binding = container_of(node, ShaderBinding, node);
|
||||
memcpy(&binding->state, state, sizeof(ShaderState));
|
||||
|
@ -521,7 +522,7 @@ static void shader_cache_entry_post_evict(Lru *lru, LruNode *node)
|
|||
memset(&binding->state, 0, sizeof(ShaderState));
|
||||
}
|
||||
|
||||
static bool shader_cache_entry_compare(Lru *lru, LruNode *node, void *key)
|
||||
static bool shader_cache_entry_compare(Lru *lru, LruNode *node, const void *key)
|
||||
{
|
||||
ShaderBinding *binding = container_of(node, ShaderBinding, node);
|
||||
return memcmp(&binding->state, key, sizeof(ShaderState));
|
||||
|
|
|
@ -746,7 +746,7 @@ static void texture_binding_destroy(gpointer data)
|
|||
}
|
||||
|
||||
/* functions for texture LRU cache */
|
||||
static void texture_cache_entry_init(Lru *lru, LruNode *node, void *key)
|
||||
static void texture_cache_entry_init(Lru *lru, LruNode *node, const void *key)
|
||||
{
|
||||
TextureLruNode *tnode = container_of(node, TextureLruNode, node);
|
||||
memcpy(&tnode->key, key, sizeof(TextureKey));
|
||||
|
@ -765,7 +765,8 @@ static void texture_cache_entry_post_evict(Lru *lru, LruNode *node)
|
|||
}
|
||||
}
|
||||
|
||||
static bool texture_cache_entry_compare(Lru *lru, LruNode *node, void *key)
|
||||
static bool texture_cache_entry_compare(Lru *lru, LruNode *node,
|
||||
const void *key)
|
||||
{
|
||||
TextureLruNode *tnode = container_of(node, TextureLruNode, node);
|
||||
return memcmp(&tnode->key, key, sizeof(TextureKey));
|
||||
|
|
|
@ -232,14 +232,14 @@ unsigned int pgraph_gl_bind_inline_array(NV2AState *d)
|
|||
return index_count;
|
||||
}
|
||||
|
||||
static void vertex_cache_entry_init(Lru *lru, LruNode *node, void *key)
|
||||
static void vertex_cache_entry_init(Lru *lru, LruNode *node, const void *key)
|
||||
{
|
||||
VertexLruNode *vnode = container_of(node, VertexLruNode, node);
|
||||
memcpy(&vnode->key, key, sizeof(struct VertexKey));
|
||||
vnode->initialized = false;
|
||||
}
|
||||
|
||||
static bool vertex_cache_entry_compare(Lru *lru, LruNode *node, void *key)
|
||||
static bool vertex_cache_entry_compare(Lru *lru, LruNode *node, const void *key)
|
||||
{
|
||||
VertexLruNode *vnode = container_of(node, VertexLruNode, node);
|
||||
return memcmp(&vnode->key, key, sizeof(VertexKey));
|
||||
|
|
|
@ -93,7 +93,8 @@ static VkPrimitiveTopology get_primitive_topology(PGRAPHState *pg)
|
|||
}
|
||||
}
|
||||
|
||||
static void pipeline_cache_entry_init(Lru *lru, LruNode *node, void *state)
|
||||
static void pipeline_cache_entry_init(Lru *lru, LruNode *node,
|
||||
const void *state)
|
||||
{
|
||||
PipelineBinding *snode = container_of(node, PipelineBinding, node);
|
||||
snode->layout = VK_NULL_HANDLE;
|
||||
|
@ -117,7 +118,8 @@ static void pipeline_cache_entry_post_evict(Lru *lru, LruNode *node)
|
|||
snode->layout = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
static bool pipeline_cache_entry_compare(Lru *lru, LruNode *node, void *key)
|
||||
static bool pipeline_cache_entry_compare(Lru *lru, LruNode *node,
|
||||
const void *key)
|
||||
{
|
||||
PipelineBinding *snode = container_of(node, PipelineBinding, node);
|
||||
return memcmp(&snode->key, key, sizeof(PipelineKey));
|
||||
|
|
|
@ -242,7 +242,8 @@ static void update_shader_uniform_locs(ShaderBinding *binding)
|
|||
}
|
||||
|
||||
static ShaderModuleInfo *
|
||||
get_and_ref_shader_module_for_key(PGRAPHVkState *r, ShaderModuleCacheKey *key)
|
||||
get_and_ref_shader_module_for_key(PGRAPHVkState *r,
|
||||
const ShaderModuleCacheKey *key)
|
||||
{
|
||||
uint64_t hash = fast_hash((void *)key, sizeof(ShaderModuleCacheKey));
|
||||
LruNode *node = lru_lookup(&r->shader_module_cache, hash, key);
|
||||
|
@ -252,7 +253,7 @@ get_and_ref_shader_module_for_key(PGRAPHVkState *r, ShaderModuleCacheKey *key)
|
|||
return module->module_info;
|
||||
}
|
||||
|
||||
static void shader_cache_entry_init(Lru *lru, LruNode *node, void *state)
|
||||
static void shader_cache_entry_init(Lru *lru, LruNode *node, const void *state)
|
||||
{
|
||||
PGRAPHVkState *r = container_of(lru, PGRAPHVkState, shader_cache);
|
||||
ShaderBinding *binding = container_of(node, ShaderBinding, node);
|
||||
|
@ -312,13 +313,14 @@ static void shader_cache_entry_post_evict(Lru *lru, LruNode *node)
|
|||
}
|
||||
}
|
||||
|
||||
static bool shader_cache_entry_compare(Lru *lru, LruNode *node, void *key)
|
||||
static bool shader_cache_entry_compare(Lru *lru, LruNode *node, const void *key)
|
||||
{
|
||||
ShaderBinding *snode = container_of(node, ShaderBinding, node);
|
||||
return memcmp(&snode->state, key, sizeof(ShaderState));
|
||||
}
|
||||
|
||||
static void shader_module_cache_entry_init(Lru *lru, LruNode *node, void *key)
|
||||
static void shader_module_cache_entry_init(Lru *lru, LruNode *node,
|
||||
const void *key)
|
||||
{
|
||||
PGRAPHVkState *r = container_of(lru, PGRAPHVkState, shader_module_cache);
|
||||
ShaderModuleCacheEntry *module =
|
||||
|
@ -361,7 +363,7 @@ static void shader_module_cache_entry_post_evict(Lru *lru, LruNode *node)
|
|||
}
|
||||
|
||||
static bool shader_module_cache_entry_compare(Lru *lru, LruNode *node,
|
||||
void *key)
|
||||
const void *key)
|
||||
{
|
||||
ShaderModuleCacheEntry *module =
|
||||
container_of(node, ShaderModuleCacheEntry, node);
|
||||
|
|
|
@ -524,7 +524,8 @@ void pgraph_vk_unpack_depth_stencil(PGRAPHState *pg, SurfaceBinding *surface,
|
|||
pgraph_vk_end_debug_marker(r, cmd);
|
||||
}
|
||||
|
||||
static void pipeline_cache_entry_init(Lru *lru, LruNode *node, void *state)
|
||||
static void pipeline_cache_entry_init(Lru *lru, LruNode *node,
|
||||
const void *state)
|
||||
{
|
||||
PGRAPHVkState *r = container_of(lru, PGRAPHVkState, compute.pipeline_cache);
|
||||
ComputePipeline *snode = container_of(node, ComputePipeline, node);
|
||||
|
@ -556,7 +557,8 @@ static void pipeline_cache_entry_post_evict(Lru *lru, LruNode *node)
|
|||
pipeline_cache_release_node_resources(r, snode);
|
||||
}
|
||||
|
||||
static bool pipeline_cache_entry_compare(Lru *lru, LruNode *node, void *key)
|
||||
static bool pipeline_cache_entry_compare(Lru *lru, LruNode *node,
|
||||
const void *key)
|
||||
{
|
||||
ComputePipeline *snode = container_of(node, ComputePipeline, node);
|
||||
return memcmp(&snode->key, key, sizeof(ComputePipelineKey));
|
||||
|
|
|
@ -1433,7 +1433,7 @@ void pgraph_vk_bind_textures(NV2AState *d)
|
|||
NV2A_VK_DGROUP_END();
|
||||
}
|
||||
|
||||
static void texture_cache_entry_init(Lru *lru, LruNode *node, void *state)
|
||||
static void texture_cache_entry_init(Lru *lru, LruNode *node, const void *state)
|
||||
{
|
||||
TextureBinding *snode = container_of(node, TextureBinding, node);
|
||||
|
||||
|
@ -1486,7 +1486,8 @@ static void texture_cache_entry_post_evict(Lru *lru, LruNode *node)
|
|||
texture_cache_release_node_resources(r, snode);
|
||||
}
|
||||
|
||||
static bool texture_cache_entry_compare(Lru *lru, LruNode *node, void *key)
|
||||
static bool texture_cache_entry_compare(Lru *lru, LruNode *node,
|
||||
const void *key)
|
||||
{
|
||||
TextureBinding *snode = container_of(node, TextureBinding, node);
|
||||
return memcmp(&snode->key, key, sizeof(TextureKey));
|
||||
|
|
|
@ -46,10 +46,10 @@ struct Lru {
|
|||
int num_free;
|
||||
|
||||
/* Initialize a node. */
|
||||
void (*init_node)(Lru *lru, LruNode *node, void *key);
|
||||
void (*init_node)(Lru *lru, LruNode *node, const void *key);
|
||||
|
||||
/* In case of hash collision. Return `true` if nodes differ. */
|
||||
bool (*compare_nodes)(Lru *lru, LruNode *node, void *key);
|
||||
bool (*compare_nodes)(Lru *lru, LruNode *node, const void *key);
|
||||
|
||||
/* Optional. Called before eviction. Return `false` to prevent eviction. */
|
||||
bool (*pre_node_evict)(Lru *lru, LruNode *node);
|
||||
|
@ -172,7 +172,7 @@ bool lru_contains_hash(Lru *lru, uint64_t hash)
|
|||
}
|
||||
|
||||
static inline
|
||||
LruNode *lru_lookup(Lru *lru, uint64_t hash, void *key)
|
||||
LruNode *lru_lookup(Lru *lru, uint64_t hash, const void *key)
|
||||
{
|
||||
unsigned int bin = lru_hash_to_bin(lru, hash);
|
||||
LruNode *iter, *found = NULL;
|
||||
|
|
Loading…
Reference in New Issue