multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.41k stars 438 forks source link

Crashes with dxCreateTexture with pixel count+:setPixels() #287

Open Pirulax opened 6 years ago

Pirulax commented 6 years ago

Describe the bug So, I was doing some random thing, and for some reason I crashed a few times. I was using dxCreateTexture() with some big pixel counts(12k+ on x and y)+setPixels() I crashed out every time, but I dont know exactly caused the crash, but it has something to do with the mentioned functions.

To Reproduce Maybe:

  1. C a texture(dxCreateTexture(20000, 20000))
  2. Set pixels on each axis: for x = 0, math.floor(20000/32), 32 do for y = 0, math.floor(20000/32), 32 do tex:setPixels(<Add pixels here from a 32x32 image>, x, y, 32, 32) end end This is how I crashed, or at least, it was like this.

Expected behavior It should create the texture and set its pixels

MTA Client (please complete the following information):

MTA Server (please complete the following information):

Pirulax commented 6 years ago

Ohh, yeah, and which crash dump should I post? Because I have a few here. I mean should I post only dumps/public, or I can post dumps/private too?

Pirulax commented 6 years ago

https://upload.mtasa.com/u/896366106/texturecreatecrash.zip_ These two aren't the same actually. One was because of drawing too much text, and this is caused by dxCreateTexture thing.

Allerek commented 3 years ago

Link example resource and confirm its still a thing, i'll check on that.

tederis commented 3 years ago

When it comes to operations with textures MTA is relying on D3D9 API. But the largest texture size is 4096 × 4096 in DX9. Of course you can try to create a bigger texture but it's unsafe and can result in unpredictable consequences.

tederis commented 3 years ago

It's not a bug. The only thing you can do is to forbid to create textures with size bigger than 4096x4096 px.

Lpsd commented 3 years ago

A note for this should be added to the wiki page (regarding max texture size for D3D9).

Should we enforce this limit when using dxCreateTexture and throw an error if larger than 4096? Would be better than the client just crashing and having no idea what caused it.