* Move the include resolution functionality to matp
- matp::MaterialParser now has a function resolveIncludes that returns a pair of status and resolve string.
- all the include resolution classes are moved to matp private src.
- matp::resolveIncludes is renamed to matp::resolveIncludesRecursively and only used internally.
- added insertLineDirectives and insertLineDirectiveChecks in Config; add those in the CommandlineConfig.
- moved output format to public use.
Note: MaterialParser::resolveIncludes could take a includer instead of the materialFilePath, but i decided
to go with the materialFilePath because the most common use case is resolving from the file's directory.
This allows the parser to just create the default DirIncluder internally, and we don't need to expose it publicly.
* add const to the buffer param
* Move resolving #includes from MaterialBuilder to MaterialCompiler, before parsing the material.
- resolving #includes was happening after parsing, now moving before parsing.
this is because we could offload this resolution at build time for RuntimeMaterialCompiler
- filamat::resolveIncludes used to have an assumption where the given text was already
a shader block. this assumption is now broken so it finds the line offset internally.
thus the line offset field is removed from IncludeResult.
* Move include related classes to matc
* Add missing includes.
* Add parenthesis around operators to suppress compiler warning.
* Remove duplicate definition of is_supported_aux_t.
* Explicitly create descriptions.
* Remove usage of anonymous struct with non-trivially constructible members.
This is an error on some compilers (e.g. gcc).
* Remove unnecessary rvalue-reference on pointer type.
* Explicitly construct SamplerParams to suppress compiler warnings.
* Place attribute specifier before declaration.
* Remove usage of anonymous struct with a non-trivially constructible member.
Replace the `array` union member with an `operator[]` to provide similar
functionality.
Some compilers (e.g. gcc) do not support this non-standard use-case.
* Use same warning settings as main filament project.
* Use utils::Status in MaterialParser
* Use utils::sstream instead of std::stringstream
* Remove remaining std::cerr and dep; update MaterialParser::reflectParameters
* make error message in utils::Status more generic
---------
Co-authored-by: Powei Feng <powei@google.com>
In the current implementation, the function std::cout is used inside a signal handler. This is problematic because std::cout is not
async-signal-safe. According to POSIX standards, only a small set of
functions are guaranteed to be safe when called from signal handlers,
and std::cout is not one of them. Using non-async-signal-safe functions
inside signal handlers leads to undefined behavior and can cause
crashes, deadlocks, or other unpredictable issues.
By making these changes, we avoid undefined behavior and ensure the
program can handle signals safely.
The workaround option is now set to none by default. Use
```
matc -Wall
```
if you want to restore the previous behavior.
Current material workarounds:
- remove MergeReturnPass (except on Metal)
- remove SimplificationPass (except on Metal)
There are reason to believe these workarounds are no longer needed,
due to changes in spirv-opt.
It's possible that older devices might still need them.
These workaround affect *all* devices, this is why it is important
to disable them if not needed.
The script uses os.system to execute external commands like nm and
objdump. Instead we use the subprocess module, which is the recommended
approach in modern Python.
Properly handle potential errors if nm or objdump fail.
Currently the only values possible are 'none' and 'all'. 'all' is the
default. This option will be used to control code generation
workarounds individually. Currently 'all' disable the
MergeReturn and Simplification passes, which have causes issues in
the past on some older Android devices.
This commit enhances the material compilation process by embedding the
`matc` command-line parameters directly into the compiled material file.
This feature is valuable for debugging, as it allows developers to
inspect the exact compilation settings used for a given material.
A key consideration is the potential for personally identifiable
information (PII) in the command-line arguments (e.g., file paths). To
address this, a `toPIISafeString` method has been implemented to filter
out PII-sensitive options before they are stored in the material.
With this change, the matc command below
/path/to/matc -a opengl --api vulkan -p desktop -g -o /path/to/my.filamat /path/to/my.mat
is stored to the package as below. (veryfied by running `matinfo my.filamat`)
Compilation Parameters: -a opengl --api vulkan -p desktop -g
This commit introduces a CRC32 checksum to material packages to ensure
data integrity.
When a material is loaded, this checksum is verified. If the check
fails, an error is logged, and the material fails to load. For older
material packages without a CRC32 checksum, a warning is logged and
proceed.
BUGS=[373396840]
- when generating the DFG LUT as a text file, make sure to faithfully
reproduce the command used in the comments
- add a "bin" format that will output a headerless raw binary of the
LUT data.
A test for how Gemini can clean-up code. Changes:
- Configuration Struct: Global variables have been grouped into an
AppConfig struct. This makes the program's configuration explicit and
avoids polluting the global namespace.
- Clearer Argument Parsing: The handleArguments function now returns an
AppConfig object, encapsulating all parsing logic and making the main
function cleaner.
- Helper Functions: Repetitive tasks like string replacement, file I/O,
and writing file entries have been extracted into small, well-defined
helper functions (replaceAll, openOutputFile, readFile, etc.).
- Simplified main Function: The main function is now a high-level
coordinator, delegating work to helper functions. This makes the overall
program flow much easier to follow.
- Modern C++ Idioms: The code now consistently uses C++ streams
(std::cout, std::ofstream) and std::string objects, which is more
idiomatic than a mix of C and C++ styles.
- added short comments
instead of using a single resource binary for all materials, each
postfx set of materials (e.g. dof, bloom) gets its own resource file
based on the directory it is in.
resgen now generates the resources size/offset directly as #define
instead of as an `extern` variable. The assembly file also
doesn't generate the corresponding global variables, saving some binary
space.
`unfiterable : true` indicates that the sampling of the texture
will not apply filtering.
This is mainly to satisfy the webgpu requirement for
bindGroupLayouts.
- Documentation has been updated for both `unfilterable` and
`multisample`.
- Internal materials have been updated where necessary (depth
samplers have to be marked as `unfilterable`.)
- webgpu code has been changed appropriately.
BUGS=420745987
* materials: introduce mutable spec constants
Rationale & design of this feature has been discussed internally.
The current implementation uses a `FixedCapacityVector` to store the new program
handles, but I wouldn't object to replacing it with a hasmap as discussed
offline.
I have compiled but not tested this yet on Android, so I'm not certain that the
API bindings are correctly wired up.
* materials: mutable spec constant feedback
* materials: address mutable spec constant comments
Shader model (desktop or mobile) wasn't really accounted for
in the UI. This means that we will get shaders that look like
duplicates (same variant). In this work, we pass the current
shader model from engine into the frontend and filter out
variants of a different shader model.
Moreover, for matinfo, we use a specific dbg shader model (matinfo)
to indicate it is in that mode. We add UI in matinfo to show the
shadermodel.
So UI updates as well.
- reduce the number of calls to notify_one() and notify_all().
notify_one() is not only called when running a new job, and
notify_all() only when a job finishes.
- don't hold the condition lock while calling notify_*(), as it is not
strictly needed, and because notify_*() can be very slow, there can
be a lot of contention on this lock as a result; blocking the whole
jobsystem thread pool.
- add a new version of run() that takes an opaque thread id that can
be retrieved from a job's execute function; this is especially
intended to be used by parallel_for(); it's just a more efficient
version of run() that avoids a hashmap lookup.
Overall these change yield a significant performance boost:
- running + waiting a job: +200%
- running many jobs: +150%
- running many jobs in parallel: +50%
This change introduces a new chunk type to material files for precompiled Metal libraries. Previously, SPIR-V was the only binary type, so there's also a couple of refactor commits present here. Nothing is changed in Filament or matc yet.
BUGS=[333547148]