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

msl: emit point size even when there is no struct #1696

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1701,6 +1701,7 @@ impl<W: Write> Writer<W> {
) -> BackendResult {
match result_struct {
Some(struct_name) => {
let mut has_point_size = false;
let result_ty = context.function.result.as_ref().unwrap().ty;
match context.module.types[result_ty].inner {
crate::TypeInner::Struct { ref members, .. } => {
Expand All @@ -1711,7 +1712,6 @@ impl<W: Write> Writer<W> {
write!(self.out, "{}return {} {{", level, struct_name)?;

let mut is_first = true;
let mut has_point_size = false;

for (index, member) in members.iter().enumerate() {
match member.binding {
Expand Down Expand Up @@ -1758,23 +1758,23 @@ impl<W: Write> Writer<W> {
write!(self.out, "{} {}.{}", comma, tmp, name)?;
}
}

if let FunctionOrigin::EntryPoint(ep_index) = context.origin {
let stage = context.module.entry_points[ep_index as usize].stage;
if context.pipeline_options.allow_point_size
&& stage == crate::ShaderStage::Vertex
&& !has_point_size
{
// point size was injected and comes last
write!(self.out, ", 1.0")?;
}
}
}
_ => {
write!(self.out, "{}return {} {{ ", level, struct_name)?;
self.put_expression(expr_handle, context, true)?;
}
}

if let FunctionOrigin::EntryPoint(ep_index) = context.origin {
let stage = context.module.entry_points[ep_index as usize].stage;
if context.pipeline_options.allow_point_size
&& stage == crate::ShaderStage::Vertex
&& !has_point_size
{
// point size was injected and comes last
write!(self.out, ", 1.0")?;
}
}
write!(self.out, " }}")?;
}
None => {
Expand Down