From fdcb2add5b9096b91e7a8bb3ceb20c5d6073fb61 Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Tue, 6 Apr 2021 19:53:01 +0200 Subject: [PATCH] Implement gfxGetPipelineCacheData --- libportability-gfx/src/impls.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/libportability-gfx/src/impls.rs b/libportability-gfx/src/impls.rs index 3f2de6f..5cfab56 100644 --- a/libportability-gfx/src/impls.rs +++ b/libportability-gfx/src/impls.rs @@ -1971,13 +1971,23 @@ pub unsafe extern "C" fn gfxDestroyPipelineCache( } #[inline] pub unsafe extern "C" fn gfxGetPipelineCacheData( - _gpu: VkDevice, - _pipelineCache: VkPipelineCache, + gpu: VkDevice, + pipelineCache: VkPipelineCache, pDataSize: *mut usize, - _pData: *mut c_void, + pData: *mut c_void, ) -> VkResult { - //TODO: save - *pDataSize = 0; + let data = match gpu.device.get_pipeline_cache_data(&pipelineCache) { + Ok(data) => data, + Err(oom) => return map_oom(oom) + }; + + if pData.is_null() { + *pDataSize = data.len(); + } else { + let output = slice::from_raw_parts_mut(pData as *mut u8, *pDataSize); + output.copy_from_slice(&data); + } + VkResult::VK_SUCCESS } #[inline]