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
| 字段 / 分支 | 本对象必需性 | 结构约束 |
|---|---|---|
colors | optional here | type="array"; uniqueItems=true; items=#/$defs/colorTarget |
depth | optional here | $ref="#/$defs/depthTarget" |
完整结构规则: #/$defs/targets
{
"additionalProperties": false,
"minProperties": 1,
"properties": {
"colors": {
"items": {
"$ref": "#/$defs/colorTarget"
},
"type": "array",
"uniqueItems": true
},
"depth": {
"$ref": "#/$defs/depthTarget"
}
},
"type": "object"
}colorTarget · v5
| 字段 / 分支 | 本对象必需性 | 结构约束 |
|---|---|---|
clearValue | optional here | type="array"; minItems=4; maxItems=4 |
framesAgo | optional here | type="integer"; minimum=1 |
loadOp | required | enum=["load","clear","dontCare"] |
location | required | type="integer"; minimum=0 |
resource | required | $ref="#/$defs/identifier" |
storeOp | required | enum=["store","dontCare"] |
view | optional here | enum=["dawnlight:direct","dawnlight:history/current","dawnlight:history/previous","dawnlight:shadow/consumer","dawnlight:shadow/producer"] |
完整结构规则: #/$defs/colorTarget
{
"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
| 字段 / 分支 | 本对象必需性 | 结构约束 |
|---|---|---|
clearValue | optional here | type="number"; minimum=0; maximum=1 |
framesAgo | optional here | type="integer"; minimum=1 |
loadOp | required | enum=["load","clear","dontCare"] |
resource | required | $ref="#/$defs/identifier" |
storeOp | required | enum=["store","dontCare"] |
view | optional here | enum=["dawnlight:direct","dawnlight:history/current","dawnlight:history/previous","dawnlight:shadow/consumer","dawnlight:shadow/producer"] |
完整结构规则: #/$defs/depthTarget
{
"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
| 字段 / 分支 | 本对象必需性 | 结构约束 |
|---|---|---|
blend | optional here | enum=["inherit","opaque","alphaBlend","nonPremultiplied"] |
blendTargets | optional here | type="array"; minItems=1; uniqueItems=true |
depth | optional here | enum=["inherit","default","depthWrite","depthTestWriteLess","disabled"] |
rasterizer | optional here | enum=["inherit","cullCounterClockwiseScissor","cullClockwiseScissor","cullNoneScissor"] |
完整结构规则: #/$defs/state
{
"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
{
"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 ·