Skip to content

Conversation

@pcwalton
Copy link
Contributor

@pcwalton pcwalton commented Jul 4, 2024

Currently, the MeshInputUniform data, which is used to prepare MeshUniform data for use by the GPU, is constructed during the extraction phase. This poses a problem for bindless materials. With bindless, we need the MeshUniform to contain the index of the material in a buffer, and the material isn't prepared until after extraction, at which point it's too late because the MeshInputUniforms have already been built. By moving collect_meshes_for_gpu_building to the new CollectMeshes phase, which runs after asset preparation but before mesh queuing, we fix this ordering problem.

Because an up-to-date RenderMeshInstances is no longer available during extraction, the lightmap extraction system has been reworked to fetch the mesh ID directly from the main world instead of going through RenderMeshInstances.

This patch was broken out from the larger forthcoming bindless patch because it has performance benefits on its own. It allows the extraction phase to finish quicker, which allows main world systems to resume faster.

bindless textures.

Currently, the `MeshInputUniform` data, which is used to prepare
`MeshUniform` data for use by the GPU, is constructed during the
extraction phase. This poses a problem for bindless materials. With
bindless, we need the `MeshUniform` to contain the index of the material
in a buffer, and the material isn't prepared until *after* extraction,
at which point it's too late because the `MeshInputUniform`s have
already been built. By moving `collect_meshes_for_gpu_building` to the
new `CollectMeshes` phase, which runs after extraction but before asset
preparation, we fix this ordering problem.

Because an up-to-date `RenderMeshInstances` is no longer available
during extraction, the lightmap extraction system has been reworked to
fetch the mesh ID directly from the main world instead of going through
`RenderMeshInstances`.

This patch was broken out from the larger forthcoming bindless patch
because it has performance benefits on its own. It allows the extraction
phase to finish quicker, which allows main world systems to resume
faster.
@pcwalton pcwalton added A-Rendering Drawing game state to the screen C-Performance A change motivated by improving speed, memory usage or compile times C-Code-Quality A section of code that is hard to understand or change S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 4, 2024
@pcwalton pcwalton added this to the 0.15 milestone Jul 4, 2024
@pcwalton
Copy link
Contributor Author

pcwalton commented Jul 4, 2024

Actually let me mark this as a draft because there's more stuff I may want to do (note to self: get rid of RenderMaterialInstances in favor of putting more stuff in RenderMeshInstance)

@pcwalton pcwalton marked this pull request as draft July 4, 2024 05:38
@JMS55
Copy link
Contributor

JMS55 commented Jul 4, 2024

Fyi RenderMaterialInstances is used for meshlets, so be careful there.

Materials for meshlets are less tied to entities. Each entity has a material ID (u32) associated with it, but the actual material rendering are fullscreen draws independent of the mesh rasterization.

@pcwalton pcwalton closed this Jul 10, 2024
@pcwalton
Copy link
Contributor Author

I'm just going to roll this into bindless textures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change C-Performance A change motivated by improving speed, memory usage or compile times S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants