{
  "id": "unity/graphics-buffer-format-mismatch",
  "signature": "ArgumentException: Buffer 'position' has format 'Float3' but buffer 'position' expects format 'Float4'.",
  "signature_zh": "参数异常：缓冲区 'position' 的格式为 'Float3'，但缓冲区 'position' 期望的格式为 'Float4'。",
  "regex": "ArgumentException: Buffer '.*' has format '.*' but buffer '.*' expects format '.*'\\.",
  "domain": "unity",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A compute shader or graphics API buffer binding has mismatched element size or format between the buffer declaration and the shader/script that reads it.",
  "root_cause_type": "generic",
  "root_cause_zh": "计算着色器或图形 API 缓冲区绑定中，缓冲区声明与读取它的着色器/脚本之间的元素大小或格式不匹配。",
  "versions": [
    {
      "version": "Unity 2022.3.0f1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 2023.1.0a1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Unity 6000.0.0b1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Changing buffer stride without updating shader declarations often leads to data corruption or different errors.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Reimporting assets does not fix runtime buffer format mismatches caused by code changes.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the C# buffer declaration matches the shader struct. For example, if shader expects `float4 position`, declare `ComputeBuffer` with stride = sizeof(float) * 4 and use a struct with `Vector4 position`. Then update the SetBuffer call accordingly.",
      "success_rate": 0.85,
      "how": "Ensure the C# buffer declaration matches the shader struct. For example, if shader expects `float4 position`, declare `ComputeBuffer` with stride = sizeof(float) * 4 and use a struct with `Vector4 position`. Then update the SetBuffer call accordingly.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use `System.Runtime.InteropServices.Marshal.SizeOf` to compute stride dynamically based on the struct definition to avoid manual errors.",
      "success_rate": 0.75,
      "how": "Use `System.Runtime.InteropServices.Marshal.SizeOf` to compute stride dynamically based on the struct definition to avoid manual errors.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保 C# 缓冲区声明与着色器结构体匹配。例如，如果着色器期望 `float4 position`，则使用 stride = sizeof(float) * 4 声明 `ComputeBuffer`，并使用包含 `Vector4 position` 的结构体。然后相应更新 SetBuffer 调用。",
    "使用 `System.Runtime.InteropServices.Marshal.SizeOf` 根据结构体定义动态计算 stride，以避免手动错误。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.unity3d.com/Manual/class-ComputeShader.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2023-06-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}