Skip to content

Decal Performance 2 - #5393

Merged
redmushie merged 3 commits into
ss14Starlight:starlight-devfrom
CrazyPhantom779:Decal-Fixes-2
Jul 29, 2026
Merged

Decal Performance 2#5393
redmushie merged 3 commits into
ss14Starlight:starlight-devfrom
CrazyPhantom779:Decal-Fixes-2

Conversation

@CrazyPhantom779

@CrazyPhantom779 CrazyPhantom779 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Short description

Decals were still lagging on creation due to them dirtying the whole chunk if anything was added, So I made them delta the changes and only sync the diff to clients unless they are only getting it for the first time they they get the whole chunk.

Why we need to add this

Perf fix

Media (Video/Screenshots)

image image

Checks

  • I do not require assistance to complete the PR.
  • Before posting/requesting review of a PR, I have verified that the changes work.
  • I have added screenshots/videos of the changes, or this PR does not change in-game mechanics.
  • I affirm that my changes are licensed under the MIT License and grant permission for use in this repository under its conditions.

Changelog

🆑 CrazyPhantom

  • fix: Fixed decal performance issue on decal creation.

@CrazyPhantom779
CrazyPhantom779 requested a review from a team July 29, 2026 05:09
@github-actions github-actions Bot added S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. Changes: C# S: Needs Review Status: Requires additional reviews before being fully accepted. Not to be replaced by S: Approved. size/M and removed S: Untriaged Status: Indicates an item has not been triaged and doesn't have appropriate labels. labels Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 430b7aeb-7672-442f-b0a9-dd070a79bfe1

📥 Commits

Reviewing files that changed from the base of the PR and between 4e31dc0 and 1b1ee17.

📒 Files selected for processing (2)
  • Content.Client/Decals/DecalSystem.cs
  • Content.Server/Decals/DecalSystem.cs
🚧 Files skipped from review as they are similar to previous changes (2)
  • Content.Client/Decals/DecalSystem.cs
  • Content.Server/Decals/DecalSystem.cs

📝 Walkthrough

Walkthrough

DecalChunkUpdateEvent now transmits per-chunk decal diffs. The server records decal mutations and sends full snapshots or incremental updates based on player visibility, while the client merges removals and upserts into existing chunks.

Changes

Decal chunk synchronization

Layer / File(s) Summary
Shared diff event contract
Content.Shared/Decals/DecalChunkUpdateEvent.cs
The update event now carries per-grid, per-chunk DecalChunkDiff payloads containing upserted and removed decal IDs.
Server delta tracking and batching
Content.Server/Decals/DecalSystem.cs
Decal mutations are recorded per chunk and scoped to PVS batches; player updates distinguish full snapshots from dirty known chunks and serialize incremental diffs accordingly.
Client incremental diff application
Content.Client/Decals/DecalSystem.cs
The client validates target grids and merges removals and upserts into existing decal chunks and decal indices.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DecalSystem
  participant UpdatePlayer
  participant SendChunkUpdates
  participant DecalChunkUpdateEvent
  participant ClientDecalSystem
  DecalSystem->>UpdatePlayer: record decal deltas and select visible chunks
  UpdatePlayer->>SendChunkUpdates: pass fullChunks and diffChunks
  SendChunkUpdates->>DecalChunkUpdateEvent: serialize snapshots and chunk diffs
  DecalChunkUpdateEvent->>ClientDecalSystem: deliver decal update event
  ClientDecalSystem->>ClientDecalSystem: merge removals and upserted decals
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 29.41% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
No Magic Numbers ⚠️ Warning Nontrivial literals remain in Content.Server/Decals/DecalSystem.cs, including pool capacity 64 and distance 0.75f, without named constants. Extract the pool capacity, decal range, and any other repeated thresholds into clearly named constants; keep only obvious literals like 0/1/2.
Title check ❓ Inconclusive The title points to decal performance, but "2" makes it too vague to describe the actual sync-diff change. Rename it to something like "Sync decal chunk diffs instead of dirtying whole chunks".
✅ Passed checks (5 passed)
Check name Status Explanation
Description check ✅ Passed The description matches the change: it explains delta syncing decals for new and existing clients.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No Hardcoded Ecs Parameters ✅ Passed No entity-level ECS parameters were hardcoded; the PR only adds decal diff sync logic, and DecalGridComponent still carries storage, not behavior config.
Avoid Service Locator ✅ Passed PASS — No IoCManager/Resolve/GetService usage was added; the new decal sync code relies on explicit [Dependency] injection. Nice cleanup!

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Content.Client/Decals/DecalSystem.cs`:
- Around line 174-180: Update the removal loop in the diff merge path to invoke
OnDecalRemoved before removing the corresponding entry from chunk.Decals,
preserving the hook’s requirement that the decal still exists. Keep
gridComp.DecalIndex.Remove(removedId) after the hook and ensure each removal is
processed only when the decal is present.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: b954997a-5cd6-4ec1-94ea-558c9c2e6450

📥 Commits

Reviewing files that changed from the base of the PR and between f88ef61 and 561ab90.

📒 Files selected for processing (3)
  • Content.Client/Decals/DecalSystem.cs
  • Content.Server/Decals/DecalSystem.cs
  • Content.Shared/Decals/DecalChunkUpdateEvent.cs

Comment thread Content.Client/Decals/DecalSystem.cs
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 29, 2026

@redmushie redmushie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great as always Crazy, just one pair of missing comments and some naming nitpicks to reduce confusion when reading

Comment thread Content.Server/Decals/DecalSystem.cs Outdated
Comment thread Content.Server/Decals/DecalSystem.cs Outdated
Comment thread Content.Server/Decals/DecalSystem.cs Outdated
Comment thread Content.Server/Decals/DecalSystem.cs Outdated
Comment thread Content.Client/Decals/DecalSystem.cs Outdated
@starlightgithub starlightgithub Bot added S: Awaiting Changes Status: Changes are required before another review can happen and removed S: Needs Review Status: Requires additional reviews before being fully accepted. Not to be replaced by S: Approved. labels Jul 29, 2026
@redmushie redmushie self-assigned this Jul 29, 2026
@github-actions github-actions Bot added S: Needs Review Status: Requires additional reviews before being fully accepted. Not to be replaced by S: Approved. and removed S: Awaiting Changes Status: Changes are required before another review can happen labels Jul 29, 2026
@starlightgithub starlightgithub Bot added S: Approved Status: Reviewed and approved by at least one maintainer or dev; a PR may require another approval. and removed S: Needs Review Status: Requires additional reviews before being fully accepted. Not to be replaced by S: Approved. labels Jul 29, 2026
@redmushie
redmushie added this pull request to the merge queue Jul 29, 2026
Merged via the queue into ss14Starlight:starlight-dev with commit a4b625c Jul 29, 2026
24 checks passed
starlightgithub Bot added a commit that referenced this pull request Jul 29, 2026
Limerent-Sun pushed a commit to Blimpuf-Station/BlimpufStation that referenced this pull request Aug 5, 2026
## Short description
<!-- What do you propose to change with your PR? -->
Decals were still lagging on creation due to them dirtying the whole
chunk if anything was added, So I made them delta the changes and only
sync the diff to clients unless they are only getting it for the first
time they they get the whole chunk.
## Why we need to add this
<!-- What is the reason for adding these changes? Please post links to
Discussions as well as Bug Reports here. Please describe how this will
change the game balance. -->
Perf fix
## Media (Video/Screenshots)
<!--
If your PR contains in-game changes you must provide screenshots/videos
of the changes.
-->
<img width="456" height="298" alt="image"
src="https://github.com/user-attachments/assets/1e858476-f3d2-4420-9aae-778f1750ab17"
/>

<img width="1228" height="841" alt="image"
src="https://github.com/user-attachments/assets/6980aab6-96cc-452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3Ny_xjTnMGvCbk_ZFtnwlYr--TUHq8W2g92YoD1li2LdJ6HsSL8ou1su75fZwyov8kW5WBVz9B4oy-br-yJflXmeZVmB_tOMfve0c7Sv53iK1aJcrsuyOP0Dx35svA)


## Checks
<!-- check boxes for faster reviewing of your PR -->

- [X] I do not require assistance to complete the PR.
- [X] Before posting/requesting review of a PR, I have verified that the
changes work.
- [X] I have added screenshots/videos of the changes, or this PR does
not change in-game mechanics.
- [X] I affirm that my changes are licensed under the [MIT
License](https://github.com/ss14Starlight/space-station-14/blob/Starlight/LICENSE.TXT)
and grant permission for use in this repository under its conditions.

**Changelog**
<!--
If you want the players to know about changes made in this PR, specify
them using the template outside the comment. Short and informative.

:cl: STARLIGHT TEAM
- add: Added Starlight.
- remove: Removed SS13.
- tweak: Changed SS14.
- fix: Fixed Rinary.
-->
:cl: CrazyPhantom
- fix: Fixed decal performance issue on decal creation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changes: C# S: Approved Status: Reviewed and approved by at least one maintainer or dev; a PR may require another approval. size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants