Skip to content

Split raw and encoded texture payload sources#320

Closed
esnya wants to merge 10 commits into
mainfrom
codex/type-raw-texture-payload-sources
Closed

Split raw and encoded texture payload sources#320
esnya wants to merge 10 commits into
mainfrom
codex/type-raw-texture-payload-sources

Conversation

@esnya
Copy link
Copy Markdown
Owner

@esnya esnya commented Jun 1, 2026

Summary

  • split in-memory texture sources into raw RGBA and encoded-image variants
  • make raw texture payload constructors require non-null width and height, and remove the raw/encoded format enum from those construction paths
  • make source-backed texture payload constructors encoded-image only
  • remove the runtime path where raw in-memory payloads could be created without dimensions and fail during materialization

Verification

  • dotnet restore PlateauResoniteLink.sln --locked-mode --disable-build-servers
  • dotnet format whitespace . --folder --verify-no-changes
  • dotnet build PlateauResoniteLink.sln --configuration Release --no-restore --disable-build-servers -m:1 -p:UseSharedCompilation=false
  • dotnet test PlateauResoniteLink.sln --configuration Release --no-restore --verbosity normal -m:1 --disable-build-servers -p:UseSharedCompilation=false
  • Fake Live Sink canonical dump for plateau-13213-higashimurayama-shi-2020 mesh 53395325 dem,bldg grid geotiff
  • git diff --no-index against type-dem-grid-projection-result baseline: no diff

Copilot AI review requested due to automatic review settings June 1, 2026 11:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors texture import plumbing by splitting in-memory texture sources into explicit raw RGBA32 vs encoded-image variants, and tightens constructors so raw in-memory payloads always include dimensions (eliminating a runtime failure path during materialization).

Changes:

  • Replaced the unified in-memory texture source with CreateRawRgba32InMemory(...) and CreateEncodedImageInMemory(...).
  • Updated TexturePayload and ResoniteTexturePayload constructors to require non-null width/height for raw payloads and to default source-backed payloads to encoded-image.
  • Updated affected tests and diagnostics utilities, and added coverage ensuring raw constructors create dimensioned raw sources.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/PlateauResoniteLink.Tests/TextureImportSourceTestFactory.cs Switches raw test texture creation to the new raw in-memory factory method.
tests/PlateauResoniteLink.Tests/Targets/SceneImportContractMapperTests.cs Updates contract mapper test to construct encoded-image payloads via an encoded in-memory source.
tests/PlateauResoniteLink.Tests/Targets/ResoniteTexturePayloadTests.cs Adds coverage ensuring the raw ResoniteTexturePayload ctor produces a dimensioned raw source.
tests/PlateauResoniteLink.Tests/Targets/ResoniteLiveSceneImportTargetTestSupport.cs Updates contract payload conversion to the new raw/encoded construction paths.
tests/PlateauResoniteLink.Tests/Application/TexturePayloadTests.cs Adds coverage ensuring the raw TexturePayload ctor produces a dimensioned raw source.
src/PlateauResoniteLink/Targets/Resonite/SceneImportContractMapper.cs Updates mapping logic to select raw-vs-encoded payload construction paths.
src/PlateauResoniteLink/Targets/Resonite/ResoniteTexturePayload.cs Makes raw payload construction dimension-required and removes format selection from constructors.
src/PlateauResoniteLink/Targets/Resonite/ResoniteTextureImportFactory.cs Updates payload creation call-site to new raw constructor signature.
src/PlateauResoniteLink/Targets/Resonite/Diagnostics/CanonicalSceneDumpSink.cs Switches canonical dump texture creation to the new raw in-memory factory method.
src/PlateauResoniteLink/Application/Importing/TextureImportSource.cs Splits InMemoryTextureImportSource into raw vs encoded implementations and exposes new factory helpers.
src/PlateauResoniteLink/Application/Importing/SceneImportContractTypes.cs Makes raw contract payload construction dimension-required and removes format selection from constructors.
src/PlateauResoniteLink/Application/Importing/CityGmlAppearanceStore.cs Updates dataset-backed texture payload construction to the encoded-image-only constructor path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/PlateauResoniteLink/Targets/Resonite/SceneImportContractMapper.cs Outdated
Comment thread src/PlateauResoniteLink/Application/Importing/TextureImportSource.cs Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a304fa7dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/PlateauResoniteLink/Targets/Resonite/SceneImportContractMapper.cs Outdated
Copy link
Copy Markdown
Owner Author

esnya commented Jun 1, 2026

これはマージ可能です。raw RGBA と encoded image を分け、dimension 不明の raw payload が materialization まで流れないなら価値があります。

条件は、作成境界で width > 0 / height > 0 / data.Length == width * height * 4 まで保証することです。non-null にしただけなら弱いです。

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread src/PlateauResoniteLink/Targets/Resonite/ResoniteTexturePayload.cs
@esnya
Copy link
Copy Markdown
Owner Author

esnya commented Jun 1, 2026

レビュー結論: 受け入れ不可です。

raw bytes constructor で payload の IdentitySource.Identity が食い違い得ます。MaterialGroupingPolicy など identity-based logic が payload 側を見る以上、source 側だけ generated identity を持つ状態は grouping/reuse のバグを増やします。effective identity を一度決めて payload と source の両方に使う必要があります。

@esnya
Copy link
Copy Markdown
Owner Author

esnya commented Jun 2, 2026

レビュー対応しました。

  • raw bytes payload は width > 0 / height > 0 / bytes.Length == width * height * bytesPerPixelRawTexturePayload / in-memory raw source / contract payload / Resonite payload の作成境界で検証するようにしました。
  • TexturePayload / ResoniteTexturePayloadIdentity / Source / Format / payload fields を get-only にし、with で payload identity と source identity を後から食い違わせる経路を削除しました。
  • encoded source constructor でも明示 identitysource.Identity と異なる場合は拒否し、identity-based grouping/reuse が payload 側と source 側で分裂しないようにしました。
  • 「後段 mapper が stale identity を補正する」テストは、壊れた状態を作れない契約に変えたため削除し、constructor boundary の拒否テストに置き換えました。

検証:

  • dotnet restore PlateauResoniteLink.sln --locked-mode --disable-build-servers
  • dotnet format whitespace . --folder --verify-no-changes
  • dotnet build PlateauResoniteLink.sln --configuration Release --no-restore --disable-build-servers -m:1 -p:UseSharedCompilation=false
  • dotnet test PlateauResoniteLink.sln --configuration Release --no-restore --verbosity normal -m:1 --disable-build-servers -p:UseSharedCompilation=false (1001 passed)
  • Fake Live Sink canonical dump を baseline と git diff --no-index で比較し一致。一時 dump は削除済み。

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a062d537ce

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@esnya
Copy link
Copy Markdown
Owner Author

esnya commented Jun 2, 2026

追加レビュー対応しました。

ResoniteLiveSceneImportTargetTestSupport.ToContractTexturePayload が source-backed raw payload を BinaryPayload から再構築していたため、raw source を保持する contract raw payload 経路を追加しました。

  • TexturePayload(int width, int height, ..., IRawTexturePayloadSource source) を internal に追加し、source-backed raw payload を RawRgba32 のまま保持
  • test support の raw round-trip は byte-backed raw なら bytes を使い、source-backed raw なら raw source をそのまま渡すよう分岐
  • ContractRoundTripPreservesSourceBackedRawPayload を追加し、空 BinaryPayload の source-backed raw payload が source/identity/format を保つことを固定

検証:

  • dotnet restore PlateauResoniteLink.sln --locked-mode --disable-build-servers
  • dotnet format whitespace . --folder --verify-no-changes
  • dotnet build PlateauResoniteLink.sln --configuration Release --no-restore --disable-build-servers -m:1 -p:UseSharedCompilation=false
  • dotnet test PlateauResoniteLink.sln --configuration Release --no-restore --verbosity normal -m:1 --disable-build-servers -p:UseSharedCompilation=false (1002 passed)
  • Fake Live Sink canonical dump を baseline と git diff --no-index で比較し一致。一時 dump は削除済み。

@esnya
Copy link
Copy Markdown
Owner Author

esnya commented Jun 2, 2026

レビュー結論: 現時点では受け入れ不可です。

未解決 thread の byte[] clone 回数/性能影響が残っています。raw/encoded source 分離自体は価値がありますが、この変更は texture payload の hot path と大きな画像データを扱う経路に入るため、clone が何回・どのサイズで発生するか、既存比で増えていないかを説明または実装で閉じる必要があります。

この点が未解決のままでは、境界を締めるメリットに対して性能退行リスクを受け入れられません。

@esnya esnya force-pushed the codex/type-raw-texture-payload-sources branch from ed1067d to ebf09ba Compare June 2, 2026 10:29
Comment thread src/PlateauResoniteLink/Application/Importing/SceneImportContractTypes.cs Outdated
@@ -14,4 +19,109 @@ public void ConstructorCopiesBinaryPayloadBytes()

Assert.Equal<byte>([4, 3, 2, 1], payload.BinaryPayload);
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

このテスト群は contract 側 TexturePayloadTests とかなり重複しています。raw shape 拒否、source identity、dimensioned raw source などは TexturePayloadResoniteTexturePayload の両方にほぼ同じ形で追加されており、PR全体では test だけで +237 行増えています。

raw/encoded source 分離の価値はありますが、コード量抑制を前提にすると、この重複テストをそのまま受け入れるだけの必然性は弱いです。target 側で本当に固めるべきなのは contract round-trip や Resonite 固有変換だけに絞り、共通の raw payload/source 境界は shared helper/theory か application 側テストに寄せて、同じ仕様を2ファイルに固定しないでください。

@esnya
Copy link
Copy Markdown
Owner Author

esnya commented Jun 2, 2026

この PR は閉じます。後続の #356 で raw/encoded/RGBA32/HDR の source/payload variant 化を小さい差分と focused tests で実装し直しました。この PR の target-side test 重複や広い差分はレビュー指摘どおり残す価値が低いため、後続 stack を採用します。

@esnya esnya closed this Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants