cache: Refactor out pipeline library serialization.
If outer code has taken a reader lock, we don't need to lock again. Also allows a reader lock to go GetSerializedSize + Serialize with one reader lock. This will be relevant for magic cache implementation. Signed-off-by: Hans-Kristian Arntzen <post@arntzen-software.no>
This commit is contained in:
parent
30b4abcea1
commit
7c228139c3
|
@ -1470,10 +1470,9 @@ static void d3d12_pipeline_library_serialize_hash_map(const struct hash_map *map
|
|||
*inout_blob_offset = blob_offset;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_pipeline_library_Serialize(d3d12_pipeline_library_iface *iface,
|
||||
void *data, SIZE_T data_size)
|
||||
static HRESULT d3d12_pipeline_library_serialize(struct d3d12_pipeline_library *pipeline_library,
|
||||
void *data, size_t data_size)
|
||||
{
|
||||
struct d3d12_pipeline_library *pipeline_library = impl_from_ID3D12PipelineLibrary(iface);
|
||||
const VkPhysicalDeviceProperties *device_properties = &pipeline_library->device->device_info.properties2.properties;
|
||||
struct vkd3d_serialized_pipeline_library *header = data;
|
||||
struct vkd3d_serialized_pipeline_toc_entry *toc_entries;
|
||||
|
@ -1485,22 +1484,10 @@ static HRESULT STDMETHODCALLTYPE d3d12_pipeline_library_Serialize(d3d12_pipeline
|
|||
size_t name_offset;
|
||||
size_t blob_offset;
|
||||
uint64_t pso_size;
|
||||
int rc;
|
||||
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
if ((rc = rwlock_lock_read(&pipeline_library->mutex)))
|
||||
{
|
||||
ERR("Failed to lock mutex, rc %d.\n", rc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
required_size = d3d12_pipeline_library_get_serialized_size(pipeline_library);
|
||||
if (data_size < required_size)
|
||||
{
|
||||
rwlock_unlock_read(&pipeline_library->mutex);
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
header->version = VKD3D_PIPELINE_LIBRARY_VERSION;
|
||||
header->vendor_id = device_properties->vendorID;
|
||||
|
@ -1550,10 +1537,29 @@ static HRESULT STDMETHODCALLTYPE d3d12_pipeline_library_Serialize(d3d12_pipeline
|
|||
header->driver_cache_count, driver_cache_size);
|
||||
}
|
||||
|
||||
rwlock_unlock_read(&pipeline_library->mutex);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_pipeline_library_Serialize(d3d12_pipeline_library_iface *iface,
|
||||
void *data, SIZE_T data_size)
|
||||
{
|
||||
struct d3d12_pipeline_library *pipeline_library = impl_from_ID3D12PipelineLibrary(iface);
|
||||
HRESULT hr;
|
||||
int rc;
|
||||
|
||||
TRACE("iface %p.\n", iface);
|
||||
|
||||
if ((rc = rwlock_lock_read(&pipeline_library->mutex)))
|
||||
{
|
||||
ERR("Failed to lock mutex, rc %d.\n", rc);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
hr = d3d12_pipeline_library_serialize(pipeline_library, data, data_size);
|
||||
rwlock_unlock_read(&pipeline_library->mutex);
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT STDMETHODCALLTYPE d3d12_pipeline_library_LoadPipeline(d3d12_pipeline_library_iface *iface,
|
||||
LPCWSTR name, const D3D12_PIPELINE_STATE_STREAM_DESC *desc, REFIID iid, void **pipeline_state)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue