carmineos / rage-toolkit

Other
19 stars 6 forks source link

Fix ResourceDataReader block pool #11

Open carmineos opened 3 years ago

carmineos commented 3 years ago

The ResourceDataReader block pool currently will create a duplicated block if you read a derived type after a base type at the same position.

Considering https://github.com/carmineos/gta-toolkit/commit/81e55a04062cc5df1309c38dd0724b78c1974dd9 : Reading the shader parameters first will add the Texture Data blocks to the pool. If the ShaderGroup has an embedded texture dictionary it will also read blocks of type TextureDX11 (which derives from Texture ) which are the same blocks and so they are at the same position in the resource. At this point it will create a duplicated object as the cached one is not of type TextureDX11 but a base Texture. The block pool should replace the block with the most derived one but also somehow update all the blocks which referenced to the old one to now reference the replaced one.