File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -87,20 +87,22 @@ package struct Framebuffer<Depth: UnsignedInteger>: ~Copyable {
8787 // success?
8888 guard mboxCall ( ch: . property) else { fatalError ( ) }
8989
90- let pixelCount = unsafe Int( mbox. 29 ) / MemoryLayout< Depth> . stride
90+ let pixelCount = unsafe Int( mbox. 10 &* mbox. 11 )
91+ let byteCount = unsafe mbox. 29
92+ let gpuAddr = unsafe mbox. 28
9193
9294 guard
9395 unsafe mbox. 20 == depth,
94- unsafe mbox . 28 != 0 , // pointer is not null
95- unsafe pixelCount == mbox . 10 &* mbox . 11
96+ gpuAddr != 0 ,
97+ byteCount >= pixelCount &* MemoryLayout < Depth > . size
9698 else { fatalError ( ) }
9799
98100 self . width = unsafe mbox. 10
99101 self . height = unsafe mbox. 11
100102 // swift-format-ignore: NeverForceUnwrap
101103 self . pixelOrder = unsafe . init ( rawValue: mbox. 24 ) !
102104 // GPU address to ARM address
103- let addr = unsafe UInt( mbox . 28 & 0x3FFF_FFFF )
105+ let addr = UInt ( gpuAddr & 0x3FFF_FFFF )
104106 // swift-format-ignore: NeverForceUnwrap
105107 unsafe self. baseAddress = UnsafeMutableRawPointer ( bitPattern: addr) !
106108 . bindMemory ( to: Depth . self, capacity: pixelCount)
You can’t perform that action at this time.
0 commit comments