mirror of
https://github.com/italicsjenga/portability.git
synced 2025-02-23 17:47:43 +11:00
Depth bias dynamic state, using iterator for updating descriptor sets
This commit is contained in:
parent
2aec56a099
commit
7e2ba90232
1 changed files with 25 additions and 25 deletions
|
@ -1701,27 +1701,38 @@ pub extern "C" fn gfxCreateGraphicsPipelines(
|
||||||
let mut cur_shader_stage = 0;
|
let mut cur_shader_stage = 0;
|
||||||
|
|
||||||
let descs = infos.into_iter().map(|info| {
|
let descs = infos.into_iter().map(|info| {
|
||||||
let (rasterizer, rasterizer_discard) = {
|
let rasterizer_discard = unsafe { &*info.pRasterizationState }.rasterizerDiscardEnable == VK_TRUE;
|
||||||
let state = unsafe { &*info.pRasterizationState };
|
|
||||||
|
|
||||||
let rasterizer = pso::Rasterizer {
|
let empty_dyn_states = [];
|
||||||
|
let dyn_states = match unsafe { info.pDynamicState.as_ref() } {
|
||||||
|
Some(state) if !rasterizer_discard => unsafe {
|
||||||
|
slice::from_raw_parts(state.pDynamicStates, state.dynamicStateCount as _)
|
||||||
|
},
|
||||||
|
_ => &empty_dyn_states,
|
||||||
|
};
|
||||||
|
|
||||||
|
let rasterizer = {
|
||||||
|
let state = unsafe { &*info.pRasterizationState };
|
||||||
|
pso::Rasterizer {
|
||||||
polygon_mode: conv::map_polygon_mode(state.polygonMode, state.lineWidth),
|
polygon_mode: conv::map_polygon_mode(state.polygonMode, state.lineWidth),
|
||||||
cull_face: conv::map_cull_face(state.cullMode),
|
cull_face: conv::map_cull_face(state.cullMode),
|
||||||
front_face: conv::map_front_face(state.frontFace),
|
front_face: conv::map_front_face(state.frontFace),
|
||||||
depth_clamping: state.depthClampEnable == VK_TRUE,
|
depth_clamping: state.depthClampEnable == VK_TRUE,
|
||||||
depth_bias: if state.depthBiasEnable == VK_TRUE {
|
depth_bias: if state.depthBiasEnable == VK_TRUE {
|
||||||
Some(pso::DepthBias {
|
Some(if dyn_states.iter().any(|&ds| ds == VkDynamicState::VK_DYNAMIC_STATE_DEPTH_BIAS) {
|
||||||
const_factor: state.depthBiasConstantFactor,
|
pso::State::Dynamic
|
||||||
clamp: state.depthBiasClamp,
|
} else {
|
||||||
slope_factor: state.depthBiasSlopeFactor,
|
pso::State::Static(pso::DepthBias {
|
||||||
|
const_factor: state.depthBiasConstantFactor,
|
||||||
|
clamp: state.depthBiasClamp,
|
||||||
|
slope_factor: state.depthBiasSlopeFactor,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
conservative: false,
|
conservative: false,
|
||||||
};
|
}
|
||||||
|
|
||||||
(rasterizer, state.rasterizerDiscardEnable == VK_TRUE)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let shaders = {
|
let shaders = {
|
||||||
|
@ -1905,14 +1916,6 @@ pub extern "C" fn gfxCreateGraphicsPipelines(
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let empty_dyn_states = [];
|
|
||||||
let dyn_states = match unsafe { info.pDynamicState.as_ref() } {
|
|
||||||
Some(state) if !rasterizer_discard => unsafe {
|
|
||||||
slice::from_raw_parts(state.pDynamicStates, state.dynamicStateCount as _)
|
|
||||||
},
|
|
||||||
_ => &empty_dyn_states,
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: `pDepthStencilState` could contain garbage, but implementations
|
// TODO: `pDepthStencilState` could contain garbage, but implementations
|
||||||
// can ignore it in some circumstances. How to handle it?
|
// can ignore it in some circumstances. How to handle it?
|
||||||
let depth_stencil = if !rasterizer_discard {
|
let depth_stencil = if !rasterizer_discard {
|
||||||
|
@ -2479,10 +2482,7 @@ pub extern "C" fn gfxUpdateDescriptorSets(
|
||||||
let write_infos = unsafe {
|
let write_infos = unsafe {
|
||||||
slice::from_raw_parts(pDescriptorWrites, descriptorWriteCount as _)
|
slice::from_raw_parts(pDescriptorWrites, descriptorWriteCount as _)
|
||||||
};
|
};
|
||||||
//TODO: investigate the safety of passing one giant iterator here
|
let writes = write_infos.iter().map(|write| {
|
||||||
let mut writes = SmallVec::<[pso::DescriptorSetWrite<_, _>; 16]>::with_capacity(write_infos.len());
|
|
||||||
|
|
||||||
for write in write_infos {
|
|
||||||
let image_info = unsafe {
|
let image_info = unsafe {
|
||||||
slice::from_raw_parts(write.pImageInfo, write.descriptorCount as _)
|
slice::from_raw_parts(write.pImageInfo, write.descriptorCount as _)
|
||||||
};
|
};
|
||||||
|
@ -2560,13 +2560,13 @@ pub extern "C" fn gfxUpdateDescriptorSets(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
writes.push(pso::DescriptorSetWrite {
|
pso::DescriptorSetWrite {
|
||||||
set: &*write.dstSet,
|
set: &*write.dstSet,
|
||||||
binding: write.dstBinding as _,
|
binding: write.dstBinding as _,
|
||||||
array_offset: write.dstArrayElement as _,
|
array_offset: write.dstArrayElement as _,
|
||||||
descriptors,
|
descriptors,
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
let copies = unsafe {
|
let copies = unsafe {
|
||||||
slice::from_raw_parts(pDescriptorCopies, descriptorCopyCount as _)
|
slice::from_raw_parts(pDescriptorCopies, descriptorCopyCount as _)
|
||||||
|
|
Loading…
Add table
Reference in a new issue