Skip to content

Fix for Minimap texture copy warning - #474

Closed
MidnightsFX wants to merge 1 commit into
Valheim-Modding:devfrom
MidnightsFX:mfx/minimap_texture_mismatch_fixes
Closed

Fix for Minimap texture copy warning#474
MidnightsFX wants to merge 1 commit into
Valheim-Modding:devfrom
MidnightsFX:mfx/minimap_texture_mismatch_fixes

Conversation

@MidnightsFX

Copy link
Copy Markdown
Contributor

Fix texture mismatch when writing multiple layers, avoid format incompatibilities.

This fixes the discrepancy created when copying textures currently (CPU vs GPU do not match).

[Warning: Unity Log] Graphics.CopyTexture called with mismatching CPU texture memory sizes, perhaps formats are incompatible? Pixel data was successfully copied on the GPU, but not copied on the CPU. (srcsize=8388608 dstsize=16777216)

Which is caused by using the minimap overlay system. Currently creating an overlay causes this warning each time the texture is written.

While technically harmless unless another Copy(), or GetPixels() is called, if either is invoked it will use stale data from the CPU cache (which is outdated).

To fix this and address the formatting issues which cause it, this performs just a GPU -> GPU copy.

If you would like to test or reproduce, StarLevelSystems includes an overlay by default which runs into this issue.

@MSchmoecker

Copy link
Copy Markdown
Member

The underlying reason for the error seems to be because Valheim changed the TextureFormat of the fog texture. Copying the texture over via a RenderTexture and Graphics.Blit is more expensive than a Graphics.CopyTexture call. So the real fix is to adjust the textures to match the vanilla format again.

@MidnightsFX

Copy link
Copy Markdown
Contributor Author

Closing this to replace with just texture format changes as requested. #476

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants