mirror of
https://github.com/italicsjenga/portability.git
synced 2024-11-23 15:31:32 +11:00
Merge #80
80: Map compute specialization constants r=kvark a=grovesNL Shares code between graphics/compute pipelines setup to map compute specialization constants Co-authored-by: Joshua Groves <josh@joshgroves.com>
This commit is contained in:
commit
1da17c2050
|
@ -727,3 +727,43 @@ pub fn map_pipeline_statistics(flags: VkQueryPipelineStatisticFlags) -> query::P
|
||||||
// Vulkan and HAL flags are equal
|
// Vulkan and HAL flags are equal
|
||||||
unsafe { mem::transmute(flags) }
|
unsafe { mem::transmute(flags) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn map_specialization_info(specialization: &VkSpecializationInfo) -> Vec<pso::Specialization> {
|
||||||
|
let data = unsafe { slice::from_raw_parts(
|
||||||
|
specialization.pData as *const u8,
|
||||||
|
specialization.dataSize as _,
|
||||||
|
)};
|
||||||
|
let entries = unsafe { slice::from_raw_parts(
|
||||||
|
specialization.pMapEntries,
|
||||||
|
specialization.mapEntryCount as _,
|
||||||
|
)};
|
||||||
|
|
||||||
|
entries
|
||||||
|
.into_iter()
|
||||||
|
.map(|entry| {
|
||||||
|
let offset = entry.offset as usize;
|
||||||
|
pso::Specialization {
|
||||||
|
id: entry.constantID,
|
||||||
|
value: match entry.size {
|
||||||
|
4 => pso::Constant::U32(
|
||||||
|
data[offset] as u32 |
|
||||||
|
(data[offset+1] as u32) << 8 |
|
||||||
|
(data[offset+2] as u32) << 16 |
|
||||||
|
(data[offset+3] as u32) << 24
|
||||||
|
),
|
||||||
|
8 => pso::Constant::U64(
|
||||||
|
data[offset] as u64 |
|
||||||
|
(data[offset+1] as u64) << 8 |
|
||||||
|
(data[offset+2] as u64) << 16 |
|
||||||
|
(data[offset+3] as u64) << 24 |
|
||||||
|
(data[offset+4] as u64) << 32 |
|
||||||
|
(data[offset+5] as u64) << 40 |
|
||||||
|
(data[offset+6] as u64) << 48 |
|
||||||
|
(data[offset+7] as u64) << 56
|
||||||
|
),
|
||||||
|
size => panic!("Unexpected specialization constant size: {:?}", size),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
}
|
||||||
|
|
|
@ -1404,6 +1404,7 @@ pub extern "C" fn gfxMergePipelineCaches(
|
||||||
) -> VkResult {
|
) -> VkResult {
|
||||||
VkResult::VK_SUCCESS
|
VkResult::VK_SUCCESS
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub extern "C" fn gfxCreateGraphicsPipelines(
|
pub extern "C" fn gfxCreateGraphicsPipelines(
|
||||||
gpu: VkDevice,
|
gpu: VkDevice,
|
||||||
|
@ -1433,45 +1434,7 @@ pub extern "C" fn gfxCreateGraphicsPipelines(
|
||||||
let specialization = unsafe { stage
|
let specialization = unsafe { stage
|
||||||
.pSpecializationInfo
|
.pSpecializationInfo
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|specialization| {
|
.map(conv::map_specialization_info)
|
||||||
let data = slice::from_raw_parts(
|
|
||||||
specialization.pData as *const u8,
|
|
||||||
specialization.dataSize as _,
|
|
||||||
);
|
|
||||||
let entries = slice::from_raw_parts(
|
|
||||||
specialization.pMapEntries,
|
|
||||||
specialization.mapEntryCount as _,
|
|
||||||
);
|
|
||||||
|
|
||||||
entries
|
|
||||||
.into_iter()
|
|
||||||
.map(|entry| {
|
|
||||||
let offset = entry.offset as usize;
|
|
||||||
pso::Specialization {
|
|
||||||
id: entry.constantID,
|
|
||||||
value: match entry.size {
|
|
||||||
4 => pso::Constant::U32(
|
|
||||||
data[offset] as u32 |
|
|
||||||
(data[offset+1] as u32) << 8 |
|
|
||||||
(data[offset+2] as u32) << 16 |
|
|
||||||
(data[offset+3] as u32) << 24
|
|
||||||
),
|
|
||||||
8 => pso::Constant::U64(
|
|
||||||
data[offset] as u64 |
|
|
||||||
(data[offset+1] as u64) << 8 |
|
|
||||||
(data[offset+2] as u64) << 16 |
|
|
||||||
(data[offset+3] as u64) << 24 |
|
|
||||||
(data[offset+4] as u64) << 32 |
|
|
||||||
(data[offset+5] as u64) << 40 |
|
|
||||||
(data[offset+6] as u64) << 48 |
|
|
||||||
(data[offset+7] as u64) << 56
|
|
||||||
),
|
|
||||||
size => panic!("Unexpected specialization constant size: {:?}", size),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect::<Vec<pso::Specialization>>()
|
|
||||||
})
|
|
||||||
.unwrap_or(vec![])
|
.unwrap_or(vec![])
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1853,24 +1816,7 @@ pub extern "C" fn gfxCreateComputePipelines(
|
||||||
let specialization = unsafe { info.stage
|
let specialization = unsafe { info.stage
|
||||||
.pSpecializationInfo
|
.pSpecializationInfo
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|specialization| {
|
.map(conv::map_specialization_info)
|
||||||
let _data = slice::from_raw_parts(
|
|
||||||
specialization.pData,
|
|
||||||
specialization.dataSize as _,
|
|
||||||
);
|
|
||||||
let entries = slice::from_raw_parts(
|
|
||||||
specialization.pMapEntries,
|
|
||||||
specialization.mapEntryCount as _,
|
|
||||||
);
|
|
||||||
|
|
||||||
entries
|
|
||||||
.into_iter()
|
|
||||||
.map(|_entry| {
|
|
||||||
// Currently blocked due to lack of specialization type knowledge
|
|
||||||
unimplemented!()
|
|
||||||
})
|
|
||||||
.collect::<Vec<pso::Specialization>>()
|
|
||||||
})
|
|
||||||
.unwrap_or(vec![])
|
.unwrap_or(vec![])
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue