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

C# API #314

Closed
laurentlb opened this issue Sep 19, 2023 · 6 comments · Fixed by #425
Closed

C# API #314

laurentlb opened this issue Sep 19, 2023 · 6 comments · Fixed by #425

Comments

@laurentlb
Copy link
Owner

We could provide a better, documented API usable from C#. This would help tools minify code without having to call the .exe (and saving content to disk and parsing error messages).

@LeStahL
Copy link

LeStahL commented Feb 20, 2024

I'd love this. Maybe it would be also possible to expose an API to the AST?

@laurentlb
Copy link
Owner Author

What would you like to do with the AST?

I'd like to be cautious. If we expose too much, we won't be able to keep the API stable.

@LeStahL
Copy link

LeStahL commented Feb 20, 2024

What would you like to do with the AST?

I had a tool in mind for some time that performs a file size optimization on a specific intro using a global optimization technique (like CMA-ES). The optimization parameter space would be "shaders that produce identical results on screen", the cost function would be "build the intro with a specific shader, link it with a compressing linker and determine the file size."

So the task in the first step would be to generate shaders from an existing input shader with all the identical source transformations that do not change the shader output; like reordering independent nodes (for example independent elements of initializer lists or independent statements, functions, ...).

While it is perfectly possible to achieve with a separate parser/rewriter and using the shader_minifier executable in the cost function, it would be much cleaner to use shader_minifier's AST for this imho.

I'd like to be cautious. If we expose too much, we won't be able to keep the API stable.

I agree. Maybe just using the executable is the way :)

@laurentlb
Copy link
Owner Author

generate shaders from an existing input shader with all the identical source transformations that do not change the shader output;

This sounds like a feature that should be built inside Shader Minifier.

@LeStahL
Copy link

LeStahL commented Feb 20, 2024

This sounds like a feature that should be built inside Shader Minifier.

that would be even cooler! :)

laurentlb added a commit that referenced this issue May 31, 2024
laurentlb added a commit that referenced this issue Jun 1, 2024
laurentlb added a commit that referenced this issue Jun 1, 2024
Progress towards #314
laurentlb added a commit that referenced this issue Jun 1, 2024
Progress towards #314
laurentlb added a commit that referenced this issue Jun 1, 2024
laurentlb added a commit that referenced this issue Jun 1, 2024
Progress towards #314
@laurentlb laurentlb mentioned this issue Jun 1, 2024
laurentlb added a commit that referenced this issue Jun 1, 2024
@laurentlb
Copy link
Owner Author

The C# is very simple; feel free to file new feature requests as needed.

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 a pull request may close this issue.

2 participants