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

Allow shader params (arrays/structs) empty brace initialization lists #967

Merged
merged 1 commit into from
May 24, 2019

Conversation

lgritz
Copy link
Collaborator

@lgritz lgritz commented Jan 14, 2019

Still gets length 1 (we don't allow 0-length arrays, that's a whole
other can of worms), but this is now treated as equivalent to
= { default_value } (0 for int or float, "" for string).

It's syntactic sugar, but it removes some clutter for people who want to
have shader parameters that are arrays of undetermined length (and thus are
probably expected to have a runtime-assigned instance value or be
conntected to an output of an earlier layer within the shader group),
removes the requirement for spelling out an initializing value that
won't be used anyway.

@fpsunflower
Copy link
Contributor

Maybe worth adding a test for the struct case as well?

@lgritz lgritz force-pushed the lg-emptyarrayparams branch from d595dd8 to d78df9a Compare January 14, 2019 23:59
@lgritz
Copy link
Collaborator Author

lgritz commented Jan 14, 2019

Added test. It worked!
Also amended the commit message to clearly explain that it works for structs as well.

@lgritz lgritz changed the title Allow shader params with empty brace inits: type myarray[] = {} Allow shader params (arrays/structs) empty brace initialization lists Jan 15, 2019
@fpsunflower
Copy link
Contributor

LGTM!

@fpsunflower
Copy link
Contributor

fpsunflower commented May 23, 2019

Did this fall through the cracks? Or was there an issue remaining?

@lgritz
Copy link
Collaborator Author

lgritz commented May 24, 2019

Yes, I think it just fell through the cracks. Will rebase and re-test and if all is well, will merge tomorrow.

    type myarray[] = {},
    mystruct S = {}

Un-lengthed arrays, if they aren't connected or given a concrete
instance value, still default to length 1 (we don't allow 0-length
arrays, that's a whole other can of worms), but this is now treated as
equivalent to `= { default_value }` (0 for int or float, "" for string).

And it works for structs, too, just means to initialize all the elements
to is obvious (0, "") default values.

It's syntactic sugar, but it removes some clutter for people who want to
have shader parameters that are arrays of undetermined length (and thus
are probably expected to have a runtime-assigned instance value or be
conntected to an output of an earlier layer within the shader group),
removes the requirement for spelling out an initializing value that
won't be used anyway.
@lgritz lgritz force-pushed the lg-emptyarrayparams branch from d78df9a to f2969f6 Compare May 24, 2019 04:24
@lgritz lgritz merged commit 2fa4251 into AcademySoftwareFoundation:master May 24, 2019
@lgritz lgritz deleted the lg-emptyarrayparams branch May 24, 2019 16:38
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.

2 participants