Skip to content

Move imported geometry GPU resources into per-renderer caches#1211

Open
Copilot wants to merge 3 commits into
developfrom
copilot/fix-dangerous-handling-of-buffers
Open

Move imported geometry GPU resources into per-renderer caches#1211
Copilot wants to merge 3 commits into
developfrom
copilot/fix-dangerous-handling-of-buffers

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

Imported geometry was storing device-bound meshes and textures directly on the shared ImportedGeometry object, unlike wad rendering which caches renderables per device/viewport. That made depth-sorted index updates unsafe when the same imported geometry was rendered from multiple swapchains or devices.

  • Shift imported geometry to shared CPU-side data only

    • ImportedGeometryMesh no longer derives from Mesh<T>.
    • ImportedGeometryTexture no longer owns a Texture2D.
    • ImportedGeometry now keeps only imported mesh/material/texture source data plus versioning for cache invalidation.
  • Add per-device imported geometry renderer

    • Introduced ImportedGeometryRenderer to materialize:
      • vertex/index buffers
      • input layouts
      • DX textures
    • Cache entries are keyed by imported geometry / imported texture and rebuilt when the source version changes.
  • Update all imported geometry render paths

    • Panel3D, item preview, and offscreen thumbnail rendering now resolve imported geometry through ImportedGeometryRenderer.
    • WadObjectRenderHelper uses renderer-provided textures/models instead of reaching into shared objects for DX state.
    • This aligns imported geometry rendering with the existing wad renderer model.
  • Remove global device coupling

    • Removed the static imported-geometry device hookup from DeviceManager.
    • Imported geometry GPU state is now scoped to the renderer instance that owns the current GraphicsDevice.
  • Preserve editor/compiler consumers

    • CPU-side code that reads imported geometry mesh data (room compilation, picking, room import adjustments, bounds calculations) continues to use the shared model data.
    • Added focused tests around imported geometry model/texture version invalidation.

Example of the new usage pattern:

var model = _importedGeometryRenderer.GetModel(instance.Model);
var texture = _importedGeometryRenderer.GetTexture((ImportedGeometryTexture)submesh.Value.Material.Texture);

Instead of sharing mutable DX buffers/textures through ImportedGeometry itself, each renderer now owns its own GPU copy and can depth-sort/update safely in isolation.

Copilot AI and others added 2 commits April 20, 2026 08:33
Copilot AI changed the title [WIP] Fix dangerous handling of vertex/index buffers for imported geometries Move imported geometry GPU resources into per-renderer caches Apr 20, 2026
Copilot AI requested a review from Nickelony April 20, 2026 08:35
@Nickelony Nickelony added bug Something isn't working as intended. high priority Needs urgent attention. ready for review The Pull Request is finished and ready for review. renderer Renderer related task. labels Apr 20, 2026
@Nickelony Nickelony marked this pull request as ready for review April 20, 2026 17:02
@Nickelony Nickelony requested a review from Lwmte April 20, 2026 17:02
@Nickelony Nickelony added this to the Version 2.0 milestone Apr 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as intended. high priority Needs urgent attention. ready for review The Pull Request is finished and ready for review. renderer Renderer related task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TE: Dangerous handling of vertex/index buffers for imported geometries

2 participants