mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-04-21 20:14:45 +00:00
vk_rasterizer: Use dynamic state for depth bounds and bias
This commit is contained in:
parent
f01d075dac
commit
2cf31a3f5a
4 changed files with 20 additions and 21 deletions
|
@ -492,6 +492,11 @@ struct Liverpool {
|
|||
CullMode CullingMode() const {
|
||||
return static_cast<CullMode>(cull_front | cull_back << 1);
|
||||
}
|
||||
|
||||
bool NeedsBias() const {
|
||||
return enable_polygon_offset_back || enable_polygon_offset_front ||
|
||||
enable_polygon_offset_para;
|
||||
}
|
||||
};
|
||||
|
||||
union VsOutputConfig {
|
||||
|
|
|
@ -134,9 +134,9 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
|
|||
};
|
||||
|
||||
boost::container::static_vector<vk::DynamicState, 14> dynamic_states = {
|
||||
vk::DynamicState::eViewport,
|
||||
vk::DynamicState::eScissor,
|
||||
vk::DynamicState::eBlendConstants,
|
||||
vk::DynamicState::eViewport, vk::DynamicState::eScissor,
|
||||
vk::DynamicState::eBlendConstants, vk::DynamicState::eDepthBounds,
|
||||
vk::DynamicState::eDepthBias,
|
||||
};
|
||||
|
||||
if (instance.IsColorWriteEnableSupported()) {
|
||||
|
|
|
@ -210,26 +210,8 @@ bool PipelineCache::RefreshGraphicsKey() {
|
|||
!regs.depth_render_control.depth_clear_enable;
|
||||
key.depth_stencil.raw |= regs.depth_control.DepthState();
|
||||
key.depth_stencil.depth_write_enable.Assign(depth_write);
|
||||
if (key.depth_stencil.depth_bounds_enable) {
|
||||
key.depth_bounds_min = regs.depth_bounds_min;
|
||||
key.depth_bounds_max = regs.depth_bounds_max;
|
||||
}
|
||||
key.depth_bias_enable = regs.polygon_control.enable_polygon_offset_back ||
|
||||
regs.polygon_control.enable_polygon_offset_front ||
|
||||
regs.polygon_control.enable_polygon_offset_para;
|
||||
if (key.depth_bias_enable) {
|
||||
if (regs.polygon_control.enable_polygon_offset_front) {
|
||||
key.depth_bias_const_factor = regs.poly_offset.front_offset;
|
||||
key.depth_bias_slope_factor = regs.poly_offset.front_scale;
|
||||
} else {
|
||||
key.depth_bias_const_factor = regs.poly_offset.back_offset;
|
||||
key.depth_bias_slope_factor = regs.poly_offset.back_scale;
|
||||
}
|
||||
key.depth_bias_clamp = regs.poly_offset.depth_bias;
|
||||
}
|
||||
|
||||
const auto ds_format = LiverpoolToVK::DepthFormat(db.z_info.format, db.stencil_info.format);
|
||||
|
||||
if (db.z_info.format != AmdGpu::Liverpool::DepthBuffer::ZFormat::Invalid) {
|
||||
key.depth_format = ds_format;
|
||||
} else {
|
||||
|
|
|
@ -297,6 +297,18 @@ void Rasterizer::UpdateDynamicState(const GraphicsPipeline& pipeline) {
|
|||
cmdbuf.setColorWriteEnableEXT(write_ens);
|
||||
cmdbuf.setColorWriteMaskEXT(0, write_masks);
|
||||
}
|
||||
if (regs.depth_control.depth_bounds_enable) {
|
||||
cmdbuf.setDepthBounds(regs.depth_bounds_min, regs.depth_bounds_max);
|
||||
}
|
||||
if (regs.polygon_control.NeedsBias()) {
|
||||
if (regs.polygon_control.enable_polygon_offset_front) {
|
||||
cmdbuf.setDepthBias(regs.poly_offset.front_offset, regs.poly_offset.depth_bias,
|
||||
regs.poly_offset.front_scale);
|
||||
} else {
|
||||
cmdbuf.setDepthBias(regs.poly_offset.back_offset, regs.poly_offset.depth_bias,
|
||||
regs.poly_offset.back_scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Rasterizer::UpdateViewportScissorState() {
|
||||
|
|
Loading…
Add table
Reference in a new issue