# ArgumentException: Buffer 'position' has format 'Float3' but buffer 'position' expects format 'Float4'.

- **ID:** `unity/graphics-buffer-format-mismatch`
- **Domain:** unity
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## 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.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Unity 2022.3.0f1 | active | — | — |
| Unity 2023.1.0a1 | active | — | — |
| Unity 6000.0.0b1 | active | — | — |

## Workarounds

1. **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.** (85% success)
   ```
   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.
   ```
2. **Use `System.Runtime.InteropServices.Marshal.SizeOf` to compute stride dynamically based on the struct definition to avoid manual errors.** (75% success)
   ```
   Use `System.Runtime.InteropServices.Marshal.SizeOf` to compute stride dynamically based on the struct definition to avoid manual errors.
   ```

## Dead Ends

- **** — Changing buffer stride without updating shader declarations often leads to data corruption or different errors. (70% fail)
- **** — Reimporting assets does not fix runtime buffer format mismatches caused by code changes. (90% fail)
