The global mask was added with the intention to block PCI-e BAR memory
types from being used, however, this ends up being somewhat clumsy when
we want to allow PCI-e BAR for specific allocations.
Refactor the memory allocation scheme to never end up in a situation
where we accidentally allocate PCI-e BAR memory. We only attempt one
memory type. This makes is so that pure DEVICE cannot fallback to BAR,
and pure HOST allocations (if they somehow fail) cannot fallback to BAR.
The first eligible memory type is always selected.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
If we fail to map memory for whatever reason, we'll end up freeing the
same memory twice when cleaning up resource.
Make sure we memset the allocation properly before returning.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Some dynamic state is at risk of being spammed with same arguments many
times. For the dynamic state that is trivial to check, do so.
Ghostwire: Tokyo has been observed to spam the same OMSetStencilRef
value causing some context rolls, also RSSetShadingRate has been set
redundantly.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Fixes validation error on Intel where we are trying to create
CONCURRENT family with {0, -1}.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
When the disk cache is used, the cache we give back to applications is a
dummy. Therefore, try to use the disk cache blob if we detect a useless
application blob.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
With VKD3D_SHADER_CACHE_PATH, we can add automatic serialization of pipeline
blobs to disk, even for games which do not make any use of GetCachedBlob
of ID3D12PipelineLibrary interfaces. Most applications expect drivers to
have some kind of internal caching.
This is implemented as a system where a disk
thread will manage a private ID3D12PipelineLibrary, and new PSOs are
automatically committed to this library. PSO creation will also consult
this internal pipeline library if applications do not provide their own
blob.
The strategy for updating the cache is based on a read-only cache which
is mmaped from disk, with an exclusive write-only portion for new blobs,
which ensures some degree of safety if there are multiple
concurrent processes using the same cache.
The memory layout of the disk cache is optimized to be very efficient
for appending new blobs, just simple fwrites + fflush.
The format is also robust against sliced files, which solves the problem
where applications tear down without destroying the D3D12 device
properly.
This structure is very similar to Fossilize, and in fact the idea is to
move towards actually using the Fossilize format directly later.
This implementation prepares us for this scenario where e.g. Steam could
potentially manage the vkd3d-proton cache.
The main complication in this implementation is that we have to merge
the read-only and write caches.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
For internal pipeline libraries, we want a somewhat different strategy.
- PSOs are keyed by hash instead of user key.
- We want the option to conditionally store SPIR-V and PSO blobs.
For internal caches, there isn't much of a reason to store PSO blobs
since the disk cache is going to be primed anyways.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Makes sure that we drop private root signature device references when
public pipeline state refcount hits 0.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
Supports more advanced file operations than we'd normally need.
Intended to be used by magic disk cache.
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
This was off by one, at some point, which could cause a stack buffer overrun which is naughty.
Replace this with just an ARRAY_SIZE on the dynamic_state_list for the array size.
Signed-off-by: Joshua Ashton <joshua@froggi.es>
Needed to support SM 6.0 CBufferLoad.
This path is mostly unused since it's opt-in in DXC and horribly broken
...
Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>