{"record":{"id":"8663074d489e6584","repo":"3b1b/manim","slug":"no-room-in-a-block-for-name-of-size-floats","errorCode":null,"errorMessage":"No room in a block for {name}, of {size} floats","messagePattern":"No room in a block for (.+?), of (.+?) floats","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"manimlib/renderer/uniform_block.py","lineNumber":67,"sourceCode":"    held to be compared against and sent.\n    \"\"\"\n    names: list[str] = []\n    formats: list[Any] = []\n\n    def add(name: str, shape: tuple[int, ...]) -> None:\n        names.append(name)\n        formats.append(np.float32 if shape == (1,) else (np.float32, shape))\n\n    size_so_far = 0\n    for name, size, *rest in members:\n        count = rest[0] if rest else 1\n        if count > 1 and size != ARRAY_ELEMENT_SIZE:\n            raise ValueError(\n                f\"An array in a block holds {ARRAY_ELEMENT_SIZE} floats to an element, so \"\n                f\"{name} cannot hold {count} of {size}\"\n            )\n        if size not in BLOCK_MEMBER_TYPES:\n            raise ValueError(f\"No room in a block for {name}, of {size} floats\")\n        skipped = -size_so_far % (size if size <= 2 else 4)\n        if skipped:\n            add(f\"_pad{len(names)}\", (skipped,))\n        add(name, (size,) if count == 1 else (count, size))\n        size_so_far += skipped + count * size\n    if -size_so_far % 4:\n        add(f\"_pad{len(names)}\", (-size_so_far % 4,))\n    # Left to pack the fields itself, numpy places them back to back, which is where the\n    # padding above has been chosen to put them\n    return np.dtype({\"names\": names, \"formats\": formats})\n\n\ndef uniform_block_code(dtype: np.dtype) -> str:\n    \"\"\"\n    A dtype written as the members of a shader struct, which is where a shader gets them,\n    leaving nothing for the two sides to disagree about. WGSL lays a struct out as std140 does\n    for everything declared here, so the padding uniform_block_dtype inserted is left out and\n    the compiler arrives at the same offsets.","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/3b1b/manim/blob/dee01804d47b9f94402d71472674710dcac125b8/manimlib/renderer/uniform_block.py#L49-L85","documentation":"While building a uniform block's numpy dtype, each member's float size must be one of the supported GLSL/WGSL types in BLOCK_MEMBER_TYPES (uniform_block.py:31: 1='f32', 2='vec2f', 3='vec3f', 4='vec4f', 16='mat4x4f'). A member whose size isn't in that set — e.g. 5, 8, or 12 floats — has no representable block type and raises ValueError immediately.","triggerScenarios":"Declaring a uniform block member like ('transform', 9) or ('weights', 5) — sizes with no scalar/vector/matrix counterpart; passing sizes like 12 instead of splitting into three vec4s or using 16 for a mat4.","commonSituations":"Custom shaders with hand-rolled member lists; packing several logical values into one member and miscounting floats; assuming arbitrary-size arrays are allowed (they are not — arrays must be size 4, see error 52).","solutions":["Split oversized members into vec3/vec4-sized members: ('a', 3), ('b', 4) instead of ('ab', 7)","Use size 16 for a 4x4 matrix member","Use size 1/2/3/4/16 only — these map to f32, vec2f, vec3f, vec4f, mat4x4f"],"exampleFix":"# before\nmembers=[('model_data', 7)]\n# after\nmembers=[('model_pos', 3), ('model_flag', 4)]","handlingStrategy":"validation","validationCode":"BLOCK_MEMBER_TYPES = {1, 2, 3, 4, 16}\nfor name, size, *rest in members:\n    assert size in BLOCK_MEMBER_TYPES, f\"{name}: size {size} has no block type (use 1/2/3/4/16 floats)\"","typeGuard":"def valid_member_size(size: int) -> bool:\n    return size in {1, 2, 3, 4, 16}","tryCatchPattern":null,"preventionTips":["Think in GLSL types when writing member lists: float/vec2/vec3/vec4/mat4 only","Split aggregates larger than 4 floats into several members; the packer inserts alignment padding for you"],"tags":["opengl","uniforms","shader","wgsl","layout"],"backgroundTag":null,"analyzedSha":"dee01804d47b9f94402d71472674710dcac125b8","analyzedAt":"2026-08-14T19:53:44.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}