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

glsl-in: fix composite constructors #1631

Merged
merged 2 commits into from
Dec 29, 2021

Conversation

JCapucho
Copy link
Collaborator

@JCapucho JCapucho commented Dec 27, 2021

In the recent rework of the constructors it seems that the logic for
composite types (arrays and structs) was accidentally removed by me.

This PR reimplements it, adds implicit conversions that were missing on them and adds tests.

Closes #1623

In the recent rework of the constructors it seems that the logic for
composite types (arrays and structs) was accidentally removed by me.
@@ -891,7 +891,7 @@ impl Context {

pub fn expr_power(
&mut self,
parser: &mut Parser,
parser: &Parser,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

src/front/glsl/functions.rs Show resolved Hide resolved
src/front/glsl/functions.rs Show resolved Hide resolved
src/front/glsl/functions.rs Show resolved Hide resolved
@@ -535,6 +560,26 @@ impl Parser {
TypeInner::Vector { size, kind, width } => {
return self.vector_constructor(ctx, body, ty, size, kind, width, &args, meta)
}
TypeInner::Array { base, .. } => {
for (mut arg, meta) in args.iter().copied() {
let scalar_components = scalar_components(&self.module.types[base].inner);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be easier to do this via

impl crate::TypeInner {
  fn scalar_components(&self) -> ... {... }
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be almost the same thing, I have no preference so if you prefer the method call instead of a function call that's fine by me.

src/front/glsl/functions.rs Show resolved Hide resolved
@kvark kvark merged commit 1d0f484 into gfx-rs:master Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GLSL] "Constructor: Too many arguments" when creating constant array
2 participants