MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / writeCommandHeader

Function writeCommandHeader

packages/core/src/drawlist/builderBase.ts:870–911  ·  view source on GitHub ↗
(opcode: number, size: number)

Source from the content-addressed store, hash-verified

868 }
869
870 protected writeCommandHeader(opcode: number, size: number): void {
871 if (this.error) return;
872
873 if (this.cmdCount + 1 > this.maxCmdCount) {
874 this.fail(
875 "ZRDL_TOO_LARGE",
876 `maxCmdCount exceeded (count=${this.cmdCount + 1}, max=${this.maxCmdCount})`,
877 );
878 return;
879 }
880
881 const expected = this.expectedCmdSize(opcode);
882 if (expected !== size) {
883 this.fail(
884 "ZRDL_FORMAT",
885 `writeCommandHeader: size mismatch for opcode ${opcode} (expected=${expected}, got=${size})`,
886 );
887 return;
888 }
889
890 if ((this.cmdLen & 3) !== 0) {
891 this.fail("ZRDL_INTERNAL", "writeCommandHeader: cmd cursor is not 4-byte aligned");
892 return;
893 }
894
895 const alignedSize = align4(size);
896 const start = this.cmdLen;
897 const end = start + alignedSize;
898 this.ensureCmdCapacity(end);
899 if (this.error) return;
900
901 this.cmdDv.setUint16(start + 0, opcode & 0xffff, true);
902 this.cmdDv.setUint16(start + 2, 0, true);
903 this.cmdDv.setUint32(start + 4, size >>> 0, true);
904
905 if (alignedSize !== size) {
906 this.cmdBuf.fill(0x00, start + size, end);
907 }
908
909 this.cmdLen = start + 8;
910 this.cmdCount += 1;
911 }
912
913 protected expectedCmdSize(_opcode: number): number {
914 return -1;

Callers

nothing calls this directly

Calls 2

failMethod · 0.80
align4Function · 0.70

Tested by

no test coverage detected