跳转到正文

Targets、drawBuffers 与 state ​

行为与约束 ​

targets.colors 的 location/resource/view/framesAgo 描述颜色附件,depth 描述深度附件。两者均声明 loadOp/storeOp,clearValue 仅按相应清理合同使用。location 是 fragment output location,不是纹理 binding slot。所有附件尺寸和格式需支持同一目标;颜色不能挂深度格式,深度不能挂颜色格式。

load 保留已有值,clear 写 clearValue,dontCare 不保证初值;store 保留后续消费值,dontCare 不应被后续读者依赖。只在整个有效区域确实被覆盖时使用 dontCare。不要同一绘制采样与写入同一图像;附件存在也不表示当前 draw 已启用输出。

drawBuffers 是 command-local 的活动输出布局,需匹配 shader 的 fragment outputs 以及目标 location。每目标 blendTargets 与布局有独立规则。state 的 blend/depth/rasterizer 使用生成闭集,inherit 不等于所有 Provider 都接受省略;Scene Provider 可以要求显式状态,具体限制见 Catalog.sceneDrawProviders。

viewport 的 target/frame、恢复与 scissor 同步控制执行区域。frameTarget 表示整帧颜色/深度所有权,不是 Terrain 专属 MRT。课程 04 保持 frameTarget 为 RT0+depth,Scene named topology 为三颜色附件,opaque 激活 0/1/2,而 BuiltIn fallback 仅激活 RT0。

自动生成的 v5 结构 ​

必需性只针对所展示的对象/分支。Schema 没写 default 不表示运行时没有默认值。完整定义保留条件规则;Loader 另行解析 ID、所有权、预算及设备约束。

targets · v5 ​

字段 / 分支本对象必需性结构约束
colorsoptional heretype="array"; uniqueItems=true; items=#/$defs/colorTarget
depthoptional here$ref="#/$defs/depthTarget"
完整结构规则: #/$defs/targets
json
{
  "additionalProperties": false,
  "minProperties": 1,
  "properties": {
    "colors": {
      "items": {
        "$ref": "#/$defs/colorTarget"
      },
      "type": "array",
      "uniqueItems": true
    },
    "depth": {
      "$ref": "#/$defs/depthTarget"
    }
  },
  "type": "object"
}

colorTarget · v5 ​

字段 / 分支本对象必需性结构约束
clearValueoptional heretype="array"; minItems=4; maxItems=4
framesAgooptional heretype="integer"; minimum=1
loadOprequiredenum=["load","clear","dontCare"]
locationrequiredtype="integer"; minimum=0
resourcerequired$ref="#/$defs/identifier"
storeOprequiredenum=["store","dontCare"]
viewoptional hereenum=["dawnlight:direct","dawnlight:history/current","dawnlight:history/previous","dawnlight:shadow/consumer","dawnlight:shadow/producer"]
完整结构规则: #/$defs/colorTarget
json
{
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "loadOp": {
            "const": "clear"
          }
        },
        "required": [
          "loadOp"
        ]
      },
      "then": {
        "required": [
          "clearValue"
        ]
      }
    },
    {
      "if": {
        "not": {
          "properties": {
            "loadOp": {
              "const": "clear"
            }
          },
          "required": [
            "loadOp"
          ]
        }
      },
      "then": {
        "not": {
          "anyOf": [
            {
              "required": [
                "clearValue"
              ]
            }
          ]
        }
      }
    }
  ],
  "properties": {
    "clearValue": {
      "items": {
        "type": "number"
      },
      "maxItems": 4,
      "minItems": 4,
      "type": "array"
    },
    "framesAgo": {
      "minimum": 1,
      "type": "integer"
    },
    "loadOp": {
      "enum": [
        "load",
        "clear",
        "dontCare"
      ]
    },
    "location": {
      "minimum": 0,
      "type": "integer"
    },
    "resource": {
      "$ref": "#/$defs/identifier"
    },
    "storeOp": {
      "enum": [
        "store",
        "dontCare"
      ]
    },
    "view": {
      "enum": [
        "dawnlight:direct",
        "dawnlight:history/current",
        "dawnlight:history/previous",
        "dawnlight:shadow/consumer",
        "dawnlight:shadow/producer"
      ]
    }
  },
  "required": [
    "location",
    "resource",
    "loadOp",
    "storeOp"
  ],
  "type": "object"
}

depthTarget · v5 ​

字段 / 分支本对象必需性结构约束
clearValueoptional heretype="number"; minimum=0; maximum=1
framesAgooptional heretype="integer"; minimum=1
loadOprequiredenum=["load","clear","dontCare"]
resourcerequired$ref="#/$defs/identifier"
storeOprequiredenum=["store","dontCare"]
viewoptional hereenum=["dawnlight:direct","dawnlight:history/current","dawnlight:history/previous","dawnlight:shadow/consumer","dawnlight:shadow/producer"]
完整结构规则: #/$defs/depthTarget
json
{
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "loadOp": {
            "const": "clear"
          }
        },
        "required": [
          "loadOp"
        ]
      },
      "then": {
        "required": [
          "clearValue"
        ]
      }
    },
    {
      "if": {
        "not": {
          "properties": {
            "loadOp": {
              "const": "clear"
            }
          },
          "required": [
            "loadOp"
          ]
        }
      },
      "then": {
        "not": {
          "anyOf": [
            {
              "required": [
                "clearValue"
              ]
            }
          ]
        }
      }
    }
  ],
  "properties": {
    "clearValue": {
      "maximum": 1,
      "minimum": 0,
      "type": "number"
    },
    "framesAgo": {
      "minimum": 1,
      "type": "integer"
    },
    "loadOp": {
      "enum": [
        "load",
        "clear",
        "dontCare"
      ]
    },
    "resource": {
      "$ref": "#/$defs/identifier"
    },
    "storeOp": {
      "enum": [
        "store",
        "dontCare"
      ]
    },
    "view": {
      "enum": [
        "dawnlight:direct",
        "dawnlight:history/current",
        "dawnlight:history/previous",
        "dawnlight:shadow/consumer",
        "dawnlight:shadow/producer"
      ]
    }
  },
  "required": [
    "resource",
    "loadOp",
    "storeOp"
  ],
  "type": "object"
}

state · v5 ​

字段 / 分支本对象必需性结构约束
blendoptional hereenum=["inherit","opaque","alphaBlend","nonPremultiplied"]
blendTargetsoptional heretype="array"; minItems=1; uniqueItems=true
depthoptional hereenum=["inherit","default","depthWrite","depthTestWriteLess","disabled"]
rasterizeroptional hereenum=["inherit","cullCounterClockwiseScissor","cullClockwiseScissor","cullNoneScissor"]
完整结构规则: #/$defs/state
json
{
  "additionalProperties": false,
  "properties": {
    "blend": {
      "enum": [
        "inherit",
        "opaque",
        "alphaBlend",
        "nonPremultiplied"
      ]
    },
    "blendTargets": {
      "items": {
        "minimum": 0,
        "type": "integer"
      },
      "minItems": 1,
      "type": "array",
      "uniqueItems": true
    },
    "depth": {
      "enum": [
        "inherit",
        "default",
        "depthWrite",
        "depthTestWriteLess",
        "disabled"
      ]
    },
    "rasterizer": {
      "enum": [
        "inherit",
        "cullCounterClockwiseScissor",
        "cullClockwiseScissor",
        "cullNoneScissor"
      ]
    }
  },
  "type": "object"
}

drawBufferLayout · v5 ​

type="array"

完整结构规则: #/$defs/drawBufferLayout
json
{
  "items": {
    "oneOf": [
      {
        "const": "disabled"
      },
      {
        "minimum": 0,
        "type": "integer"
      }
    ]
  },
  "type": "array"
}

完整示例 ​

来源与机器记录 ​

字段归属清单 · Schema v5 · Catalog v2 · Completion v2

schema-v3 · schema-v4 · schema-v5 · completion-v1 · completion-v2 · temporal · settings-guide ·

ShaderPackManifestLoader.cs

作者文档 · Manifest v5 / Scene ABI v2