Repository: google/filament
File: libs/filamat/include/filamat/MaterialBuilder.h (C/C++)

Code before:
    MaterialBuilder& output(VariableQualifier qualifier, OutputTarget target, Precision precision,
            OutputType type, const char* name, int location = -1);

    MaterialBuilder& enableFramebufferFetch() noexcept;

    MaterialBuilder& vertexDomainDeviceJittered(bool enabled) noexcept;

    /**
     * Legacy morphing uses the data in the VertexAttribute slots (\c MORPH_POSITION_0, etc) and is
     * limited to 4 morph targets. See filament::RenderableManager::Builder::morphing().
     */
    MaterialBuilder& useLegacyMorphing() noexcept;

    //! specify compute kernel group size
    MaterialBuilder& groupSize(filament::math::uint3 groupSize) noexcept;

    /**
     * Force Filament to use its default variant for depth passes. Useful if a material provides a
     * custom vertex shader which can be skipped during depth-only passes.
     */
    MaterialBuilder& useDefaultDepthVariant() noexcept;

    /**
     * Sets the source ASCII material.
     */
    MaterialBuilder& materialSource(const char* code, size_t size = 0) noexcept;

    /**
     * Build the material. If you are using the Filament engine with this library, you should use
     * the job system provided by Engine.
     */
    Package build(utils::JobSystem& jobSystem);

public:
    // The methods and types below are for internal use
    /// @cond never

    /**
     * Add a subpass parameter to this material.
     */
    MaterialBuilder& subpass(SubpassType subpassType,
            SamplerFormat format, ParameterPrecision precision, const char* name);
    MaterialBuilder& subpass(SubpassType subpassType,
            SamplerFormat format, const char* name);
    MaterialBuilder& subpass(SubpassType subpassType,
            ParameterPrecision precision, const char* name);
    MaterialBuilder& subpass(SubpassType subpassType, const char* name);

    struct Parameter {
        Parameter() noexcept: parameterType(INVALID) {}


Review comment (suggestion):
`size = 0` seems to be error-prone here. E.g., if users forgot to pass size, they would expect the size to be calculated internally, but it's not. This leads to a null CString. Maybe consider using string_view as mathias suggested.

Code after:
    MaterialBuilder& output(VariableQualifier qualifier, OutputTarget target, Precision precision,
            OutputType type, const char* name, int location = -1);

    MaterialBuilder& enableFramebufferFetch() noexcept;

    MaterialBuilder& vertexDomainDeviceJittered(bool enabled) noexcept;

    /**
     * Legacy morphing uses the data in the VertexAttribute slots (\c MORPH_POSITION_0, etc) and is
     * limited to 4 morph targets. See filament::RenderableManager::Builder::morphing().
     */
    MaterialBuilder& useLegacyMorphing() noexcept;

    //! specify compute kernel group size
    MaterialBuilder& groupSize(filament::math::uint3 groupSize) noexcept;

    /**
     * Force Filament to use its default variant for depth passes. Useful if a material provides a
     * custom vertex shader which can be skipped during depth-only passes.
     */
    MaterialBuilder& useDefaultDepthVariant() noexcept;

    /**
     * Sets the source ASCII material (aka .mat file).
     * The provided `source` string_view must remain valid until MaterialBuilder::build() is called.
     */
    MaterialBuilder& materialSource(std::string_view source) noexcept;

    /**
     * Build the material. If you are using the Filament engine with this library, you should use
     * the job system provided by Engine.
     */
    Package build(utils::JobSystem& jobSystem);

public:
    // The methods and types below are for internal use
    /// @cond never

    /**
     * Add a subpass parameter to this material.
     */
    MaterialBuilder& subpass(SubpassType subpassType,
            SamplerFormat format, ParameterPrecision precision, const char* name);
    MaterialBuilder& subpass(SubpassType subpassType,
            SamplerFormat format, const char* name);
    MaterialBuilder& subpass(SubpassType subpassType,
            ParameterPrecision precision, const char* name);
    MaterialBuilder& subpass(SubpassType subpassType, const char* name);

    struct Parameter {
        Parameter() noexcept: parameterType(INVALID) {}