mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d: Implement opening and closing shader caches.
This commit is contained in:
committed by
Alexandre Julliard
parent
26387e1d4b
commit
f24005507c
Notes:
Alexandre Julliard
2024-04-11 17:04:06 -05:00
Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/766
59
libs/vkd3d/cache.c
Normal file
59
libs/vkd3d/cache.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2024 Stefan Dösinger for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "vkd3d_private.h"
|
||||
|
||||
struct vkd3d_shader_cache
|
||||
{
|
||||
unsigned int refcount;
|
||||
};
|
||||
|
||||
int vkd3d_shader_open_cache(struct vkd3d_shader_cache **cache)
|
||||
{
|
||||
struct vkd3d_shader_cache *object;
|
||||
|
||||
TRACE("%p.\n", cache);
|
||||
|
||||
object = vkd3d_malloc(sizeof(*object));
|
||||
if (!object)
|
||||
return VKD3D_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
object->refcount = 1;
|
||||
*cache = object;
|
||||
|
||||
return VKD3D_OK;
|
||||
}
|
||||
|
||||
unsigned int vkd3d_shader_cache_incref(struct vkd3d_shader_cache *cache)
|
||||
{
|
||||
unsigned int refcount = vkd3d_atomic_increment_u32(&cache->refcount);
|
||||
TRACE("cache %p refcount %u.\n", cache, refcount);
|
||||
return refcount;
|
||||
}
|
||||
|
||||
unsigned int vkd3d_shader_cache_decref(struct vkd3d_shader_cache *cache)
|
||||
{
|
||||
unsigned int refcount = vkd3d_atomic_decrement_u32(&cache->refcount);
|
||||
TRACE("cache %p refcount %u.\n", cache, refcount);
|
||||
|
||||
if (refcount)
|
||||
return refcount;
|
||||
|
||||
vkd3d_free(cache);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user