Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vk] fix viewport/scissor count validation error #3500

Merged
merged 1 commit into from Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 15 additions & 21 deletions src/backend/vulkan/src/device.rs
Expand Up @@ -49,8 +49,8 @@ struct GraphicsPipelineInfoBuf {
depth_stencil_state: vk::PipelineDepthStencilStateCreateInfo,
color_blend_state: vk::PipelineColorBlendStateCreateInfo,
pipeline_dynamic_state: vk::PipelineDynamicStateCreateInfo,
viewport: vk::Viewport,
scissor: vk::Rect2D,
viewports: [vk::Viewport; 1],
scissors: [vk::Rect2D; 1],
}
impl GraphicsPipelineInfoBuf {
unsafe fn add_stage<'a>(
Expand Down Expand Up @@ -251,36 +251,30 @@ impl GraphicsPipelineInfoBuf {
};

this.viewport_state = {
let scissors = match desc.baked_states.scissor {
//Note: without `multiViewport` feature, there has to be
// the count of 1 for both viewports and scissors, even
// though the actual pointers are ignored.
match desc.baked_states.scissor {
Some(ref rect) => {
this.scissor = conv::map_rect(rect);
Some([this.scissor])
this.scissors = [conv::map_rect(rect)];
}
None => {
this.dynamic_states.push(vk::DynamicState::SCISSOR);
None
}
};
let viewports = match desc.baked_states.viewport {
}
match desc.baked_states.viewport {
Some(ref vp) => {
this.viewport = device.shared.map_viewport(vp);
Some([this.viewport])
this.viewports = [device.shared.map_viewport(vp)];
}
None => {
this.dynamic_states.push(vk::DynamicState::VIEWPORT);
None
}
};

let mut builder = vk::PipelineViewportStateCreateInfo::builder()
.flags(vk::PipelineViewportStateCreateFlags::empty());
if let Some(scissors) = &scissors {
builder = builder.scissors(scissors);
}
if let Some(viewports) = &viewports {
builder = builder.viewports(viewports);
}
builder.build()
vk::PipelineViewportStateCreateInfo::builder()
.flags(vk::PipelineViewportStateCreateFlags::empty())
.scissors(&this.scissors)
.viewports(&this.viewports)
.build()
};

this.multisample_state = match desc.multisampling {
Expand Down
10 changes: 6 additions & 4 deletions src/backend/vulkan/src/lib.rs
Expand Up @@ -65,7 +65,7 @@ lazy_static! {
vec![
DebugUtils::name(),
*KHR_GET_PHYSICAL_DEVICE_PROPERTIES2,
]
]
};
static ref DEVICE_EXTENSIONS: Vec<&'static CStr> = vec![extensions::khr::Swapchain::name()];
static ref SURFACE_EXTENSIONS: Vec<&'static CStr> = vec![
Expand Down Expand Up @@ -449,9 +449,11 @@ impl hal::Instance<Backend> for Instance {
.pfn_user_callback(Some(debug_utils_messenger_callback));
let handle = unsafe { ext.create_debug_utils_messenger(&info, None) }.unwrap();
Some(DebugMessenger::Utils(ext, handle))
} else if cfg!(debug_assertions) && instance_extensions.iter().any(|props| unsafe {
CStr::from_ptr(props.extension_name.as_ptr()) == DebugReport::name()
}) {
} else if cfg!(debug_assertions)
&& instance_extensions.iter().any(|props| unsafe {
CStr::from_ptr(props.extension_name.as_ptr()) == DebugReport::name()
})
{
let ext = DebugReport::new(entry, &instance);
let info = vk::DebugReportCallbackCreateInfoEXT::builder()
.flags(vk::DebugReportFlagsEXT::all())
Expand Down