Skip to content

engine: encapsulate material cache handling#9663

Open
elizagamedev wants to merge 5 commits intomainfrom
exv/material-programs
Open

engine: encapsulate material cache handling#9663
elizagamedev wants to merge 5 commits intomainfrom
exv/material-programs

Conversation

@elizagamedev
Copy link
Contributor

We will soon allow MaterialInstance to override the value of spec constants. To avoid code duplication, we introduce a new class MaterialPrograms which handles the chunky bits of managing the program cache and values of the spec constants.

@elizagamedev elizagamedev added the internal Issue/PR does not affect clients label Jan 29, 2026
Copy link
Collaborator

@pixelflinger pixelflinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not in love calling a ctor from a ctor passing "this". (i.e. FMaterial calling MaterialProgram(..., this)). I've been bit by this before.

material.getMaterialParser(), mSpecializationConstants, material.isDefaultMaterial());
}

void MaterialPrograms::initializeForMaterialInstance(FEngine& engine, FMaterial const& material) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel that we really just need one init function. And the call site can make that distinction between material vs material instance and pass in the appropriate params.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the two different methods/names make it really clear why you would call one method vs the other. For example, using the same method obscures the meaning of passing in a FixedCapacityVector vs relying on what Material owns.

We will soon allow `MaterialInstance` to override the value of spec constants.
To avoid code duplication, we introduce a new class `MaterialPrograms` which
handles the chunky bits of managing the program cache and values of the spec
constants.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Issue/PR does not affect clients

3 participants