246: Implement `gfxGetPipelineCacheData` r=kvark a=expenses

Based (slightly) on 1d5ee31553/src/amd/vulkan/radv_pipeline_cache.c (L525). 

Is it not safe enough / too safe?

Co-authored-by: Ashley Ruglys <ashley.ruglys@gmail.com>
This commit is contained in:
bors[bot] 2021-04-06 19:20:21 +00:00 committed by GitHub
commit 5c1b75fd01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1971,13 +1971,23 @@ pub unsafe extern "C" fn gfxDestroyPipelineCache(
} }
#[inline] #[inline]
pub unsafe extern "C" fn gfxGetPipelineCacheData( pub unsafe extern "C" fn gfxGetPipelineCacheData(
_gpu: VkDevice, gpu: VkDevice,
_pipelineCache: VkPipelineCache, pipelineCache: VkPipelineCache,
pDataSize: *mut usize, pDataSize: *mut usize,
_pData: *mut c_void, pData: *mut c_void,
) -> VkResult { ) -> VkResult {
//TODO: save let data = match gpu.device.get_pipeline_cache_data(&pipelineCache) {
*pDataSize = 0; 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 VkResult::VK_SUCCESS
} }
#[inline] #[inline]