[Mesa-dev] [PATCH 2/4] util/disk_cache: add struct cache_item_metadata
Pierre-Loup A. Griffais
pgriffais at valvesoftware.com
Tue Aug 22 18:10:50 UTC 2017
On 08/22/2017 02:40 AM, Michel Dänzer wrote:
> On 22/08/17 06:31 PM, Timothy Arceri wrote:
>> On 22/08/17 18:02, Michel Dänzer wrote:
>>> On 22/08/17 10:02 AM, Pierre-Loup A. Griffais wrote:
>>>> On 08/18/2017 04:02 AM, Nicolai Hähnle wrote:
>>>>> On 15.08.2017 01:26, Timothy Arceri wrote:
>>>>>> This will be used to store more information about the cache item
>>>>>> in it's header. This information is intended for 3rd party and
>>>>>> cache analysis use but can also be used for detecting the unlikely
>>>>>> scenario of cache collisions.
>>>>>> ---
>>>>>> src/util/disk_cache.h | 22 ++++++++++++++++++++++
>>>>>> 1 file changed, 22 insertions(+)
>>>>>>
>>>>>> diff --git a/src/util/disk_cache.h b/src/util/disk_cache.h
>>>>>> index 9aade16a9e..d6d7609ffb 100644
>>>>>> --- a/src/util/disk_cache.h
>>>>>> +++ b/src/util/disk_cache.h
>>>>>> @@ -34,20 +34,42 @@
>>>>>> #ifdef __cplusplus
>>>>>> extern "C" {
>>>>>> #endif
>>>>>> /* Size of cache keys in bytes. */
>>>>>> #define CACHE_KEY_SIZE 20
>>>>>> typedef uint8_t cache_key[CACHE_KEY_SIZE];
>>>>>> +/* WARNING: 3rd party applications might be reading the cache item
>>>>>> metadata.
>>>>>> + * Do not change these values without making the change widely known.
>>>>>> + * Please contact Valve developers and make them aware of this
>>>>>> change.
>>>>>> + */
>>>>>> +#define CACHE_ITEM_TYPE_UNKNOWN 0x0
>>>>>> +#define CACHE_ITEM_TYPE_GLSL 0x1
>>>>>> +
>>>>>> +typedef uint32_t cache_item_metadata_type;
>>>>>
>>>>> Please don't do typedefs like that, they just obfuscate. If you don't
>>>>> want to just use uint32_t, I'd suggest to use an enum.
>>>>>
>>>>> At a higher level, what is this actually good for? So I get Valve
>>>>> wants to parse something in the shader cache, but why / what for?
>>>>
>>>> Steam looks at local entries and delete leftover ones should you upgrade
>>>> Mesa or your GPU.
>>>
>>> That's rather questionable. Steam should leave purging old cache entries
>>> to Mesa.
>>
>> My understanding is steam overrides the environment var so that each
>> game with have its own local cache. If they don't get cleaned up it
>> could potentially waste a significant amount of space.
>
> I see, thanks for the clarification. I thought Pierre-Loup was referring
> to the default Mesa shader cache.
Yes, Steam only messes with the caches it's managing in the first place;
it's in a good position to improve shader cache usage as it has a lot
more context on games and where they live, and can run code at points
Mesa cannot (like when you switch GPUs but never play a given game
again, or a game is uninstalled, or before a game starts), so it can use
that information to ensure optimal cache hit patterns. You can always
opt out of any shader cache related shenanigans by setting this:
STEAM_ENABLE_SHADER_CACHE_MANAGEMENT=0
Thanks,
- Pierre-Loup
>
>
More information about the mesa-dev
mailing list