Commit 06c49f2
Remove temp buffer alloc get data when reading full texture (MonoGame#8590)
When GetData is called on an OpenGL Texture2D a temporary buffer is
allocated which causes heap allocations.
In scenarios where you request the entire texture (rect param is not
given, or rect param is of full extend (0,0,width,height). We do not
have to allocate a temporary buffer, and we can also skip Array.Copy in
this case.
### Description of Change
The proposed implementation checks for this specific condition, and then
proceeds to fill the given T[]Data directly with GetTexImage results.
---------
Co-authored-by: Tom Spilman <[email protected]>
Co-authored-by: Thomas Altenburger <[email protected]>
Co-authored-by: Harry <[email protected]>1 parent 68b3f6c commit 06c49f2
1 file changed
+9
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| 246 | + | |
| 247 | + | |
246 | 248 | | |
247 | 249 | | |
248 | 250 | | |
| 251 | + | |
249 | 252 | | |
250 | 253 | | |
251 | 254 | | |
252 | | - | |
253 | 255 | | |
254 | 256 | | |
255 | 257 | | |
| |||
264 | 266 | | |
265 | 267 | | |
266 | 268 | | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
267 | 275 | | |
268 | 276 | | |
269 | 277 | | |
| |||
272 | 280 | | |
273 | 281 | | |
274 | 282 | | |
275 | | - | |
276 | 283 | | |
277 | 284 | | |
278 | 285 | | |
| |||
0 commit comments