BradLarson / GPUImage3

GPUImage 3 is a BSD-licensed Swift framework for GPU-accelerated video and image processing using Metal.
BSD 3-Clause "New" or "Revised" License
2.73k stars 342 forks source link

Runtime crash due to incorrect uniform buffer size #63

Closed Bavitharan closed 7 months ago

Bavitharan commented 4 years ago

validateFunctionArguments:3485: failed assertion `Fragment Function(vignetteFragment): argument uniform[0] from buffer(1) with offset(0) and length(40) has space for 40 bytes, but argument has a length(48).'

BradLarson commented 4 years ago

This is due to a tricky issue that we recently uncovered with the way that we handle uniform buffers. At some point in our logic, we're allocating a buffer that is slightly too big for the size of the uniform values we are passing in.

In previous OS versions, this silently worked, even though the buffer size was wrong. In more recent OS versions, this now fails at runtime.

We're working to fix this.

Bavitharan commented 4 years ago

Thank you for your response. I am waiting for solution.

wbtvc commented 4 years ago

I has same problem,and i fixed it。This bug is in : ShaderUniformSettings.appendBufferSpace,i rewrite this function to fixed it.

Bavitharan commented 4 years ago

@wbtvc Please give more details.

artsector commented 4 years ago

as fast fix you can increase uniformBuffer here https://github.com/BradLarson/GPUImage3/blob/master/framework/Source/ShaderUniformSettings.swift#L194

length: uniformValues.count * 6,

but it is wrong way, i do not now how fix it correctly :)

joshbernfeld commented 4 years ago

Temporary fix.

Change the following in Vignette.metal from:

typedef struct {
    float2 vignetteCenter;
    float3 vignetteColor;
    float vignetteStart;
    float vignetteEnd;
} VignetteUniform;

to:

typedef struct {
    float vignetteStart;
    float vignetteEnd;
    float2 vignetteCenter;
    float3 vignetteColor;
} VignetteUniform;
joshbernfeld commented 4 years ago

See #91 for permanent fix