Iris Shaders

Iris Shaders

36M Downloads

Static initialization of VertexFormatElements is incompatible with other mods

Erdragh opened this issue ยท 0 comments

commented

What happened?

The game crashes when multiple mods try to add new VertexFormatElements if their IDs overlap with Iris'.
Additionally, due to the parallel nature of Mod Startup in NeoForge it probably isn't threadsafe.

The advice I got on what to pass to the ID parameter was to AT the ELEMENTS array in VertexFormatElement and use its size() method; doing so, on the NeoForge side, in FMLClientSetupEvent#enqueueWork, so it's thread safe.

Additionally XFactHD mentioned that the passed values to the index parameter are not correct

ENTITY_ELEMENT = VertexFormatElement.register(10, 10, VertexFormatElement.Type.SHORT, VertexFormatElement.Usage.GENERIC, 2);
ENTITY_ID_ELEMENT = VertexFormatElement.register(11, 11, VertexFormatElement.Type.USHORT, VertexFormatElement.Usage.UV, 3);
MID_TEXTURE_ELEMENT = VertexFormatElement.register(12, 12, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.GENERIC, 2);
TANGENT_ELEMENT = VertexFormatElement.register(13, 13, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, 4);
MID_BLOCK_ELEMENT = VertexFormatElement.register(14, 14, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, 3);

Apparently, what should be passed there is how often the specific USAGE has occurred before, so you'd have to count through the ELEMENTS array how many are there already.

Here's the direct quote from the Discord:

What should be passed to the index parameter?

The occurence of the "element usage". It's 0 for most things, but UV for example has indices 0, 1 and 2 for texture, hurt overlay and light respectively. They'd have to count how many elements with any given usage are already registered and use that as the index (you should ideally do that too)

Screenshots

No response

Log output

https://0x0.st/X69G.txt

Minecraft Version

1.21.1

Iris Version

iris-neoforge-1.8.0-beta.5

Operating System

Arch Linux

What is your GPU?

AMD Radeon 7900XT

Additional context

See discussion on the NeoForge discord

I discovered this while trying my port to 1.21.1 of Stellar View with Iris