[ZScript compiler] Func builder ignores "out" for reg count

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
phantombeta
Posts: 2184
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

[ZScript compiler] Func builder ignores "out" for reg count

Post by phantombeta »

Found out the actual cause. It's this section of the code. It's not accounting for "out" parameters when calculating the register count.
However, it seems there's still some underlying bug, as the Y component seems to always return 0 for some reason. Not sure what's causing that, though.

This is my proposed fix for the incorrect register count:

Code: Select all

// NumArgs for the VMFunction must be the amount of stack elements, which can differ from the amount of logical function arguments if vectors are in the list.
// For the VM a vector is 2 or 3 args, depending on size.
auto funcVariant = item.Func->Variants[0];
for (unsigned int i = 0; i < funcVariant.Proto->ArgumentTypes.Size(); i++)
{
    auto argType = funcVariant.Proto->ArgumentTypes[i];
    auto argFlags = funcVariant.ArgFlags[i];
    if (argFlags & VARF_Out)
    {
        auto argPointer = NewPointer(argType);
        sfunc->NumArgs += argPointer->GetRegCount();
    }
    else
    {
        sfunc->NumArgs += argType->GetRegCount();
    }
}
Seems to work fine on my end.
Spoiler: Previous, incorrect thread contents
Last edited by phantombeta on Mon Oct 21, 2019 10:01 am, edited 1 time in total.
User avatar
phantombeta
Posts: 2184
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: [ZScript compiler] Func builder ignores "out" for reg co

Post by phantombeta »

Bumping this so the edits can be seen by the other devs.

Edit: Fixed.
Post Reply

Return to “Closed Bugs [GZDoom]”