ParameterKeys: split FindByName (lookup only) and GetOrCreate

オープン
#3,700 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
活発
技術スタック
csharp
領域
backend

調査の方向性

Start with ParameterKeys.cs, the three ParameterKeySerializer.cs serializers, and Effect.cs methods FindOrCreateResourceKey and FindOrCreateValueKey; trace how key types and registration work. Update those callers to use the proposed lookup and get-or-create behavior, then check the related tests for matching types, missing names, type mismatches, and concurrent creation. Done means lookup has no side effects and key creation is registered atomically under one lock.

索引モデルが issue の本文から書いたものです。

説明

area-Graphics area-Serialization area-Shaders enhancement

Today ParameterKeys.FindByName is used both to look up a key and, by the callers, to create a key when the name is unknown. Each caller does it its own way.

  • The three key serializers (ParameterKeySerializer.cs) call FindByName, then create a key and Merge it if the name was not found. The lookup and the Merge take the lock separately, so two threads can create two keys for the same name.
  • Effect.cs (FindOrCreateResourceKey, FindOrCreateValueKey) creates a key for an unknown name but never registers it.
  • FindByName itself has a side effect: for a name like X.Y.Z it creates and registers a subkey of X.Y.

Unknown names are normal here. A key's identity is its name (Equals compares Name), and shaders can have variables with no C# key. So creating the key is the right behavior. A key that exists with a different type is the real error.

Proposal:

  • FindByName returns ParameterKey? and only looks up.
  • Add GetOrCreate…<T>(name, length) for value, object and permutation keys. Under one lock, it returns the existing key if the type matches, creates and registers it if the name is missing, and throws if the type is different.
  • The serializers and Effect.cs use it.

Came up in #3584.

主要言語
C#
スター
8k
フォーク
1.2k
平均マージ
1日 1時間
マージ済み PR(30日)
321

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

stride3d/stride のほかの issue

stride3d/stride の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。