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

a tool and a helper to statically analyze shader sources #3157

Open
11 tasks
hajimehoshi opened this issue Nov 7, 2024 · 2 comments
Open
11 tasks

a tool and a helper to statically analyze shader sources #3157

hajimehoshi opened this issue Nov 7, 2024 · 2 comments
Labels
Milestone

Comments

@hajimehoshi
Copy link
Owner

hajimehoshi commented Nov 7, 2024

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

What feature would you like to be added?

In order to introduce shader precompilation, we need to know what shader sources are used. We have to list them before the compilation. Listing them by users would not be a good solution since unknown dependencies might use shaders internally, and users couldn't know them.

In order to resolve this issue, what about this?

  1. Introduce a new function ebiten.RegisterShader(src []byte) (or string?). This function is just a marker and does nothing.
  2. Introduce a new tool to analyaze all the source of a specified package and its dependencies, list all the invocations of RegisterShader, and output them as JSON or something.

Libralies using shaders would have to call RegisterShader to precompile the shader source, but it should be much better than having to export shader sources as a public API.

Why is this needed?

No response

@hajimehoshi hajimehoshi added this to the v2.9.0 milestone Nov 7, 2024
@hajimehoshi
Copy link
Owner Author

Probably commenting is better since any library can prepare this without waiting for Ebitengine 2.9.

//ebitengine:shader
const superUltraShader = "package main

func Fragment(..."

hajimehoshi added a commit that referenced this issue Nov 10, 2024
This adds a new compiler directive `//ebitengine:shader` indicating
a shader source. A new tool internal/shaderlister can iterates all
the shader strings with the directive. The tool might be exposed
in the future.

Updates #3157
@hajimehoshi
Copy link
Owner Author

Add a new field to provide compilation results like GLSL, HLSL, and MSL.

See also: 48f79af

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant