Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6334

Including a .metal file that just defines a function causes fragment shader app to run slow

$
0
0

If I include a .metal file with just these three lines in my app with other .metal files, a fragment shader in the app runs about 10x slower, even though the code in the .metal file is not used anywhere and the two .metal files are completely unrelated:

#include <metal_stdlib>using namespace metal;kernel void myKernel(texture2d<half> detailTexture [[texture(0)]]) {}

When the above .metal file is included, in the frame capture this warning is shown:

Shader "fragment_particle" in pipeline "RenderPipelineState 0x122847a00" exceeded the available number of registers and data was spilled into slower GPU memory. (144 bytes) Issue
reduce function’s register usage to avoid costly spills. reduce stack memory usage

If I include these three lines instead, the fragment shader in the app works as expected and the warning above is not shown:

#include <metal_stdlib>using namespace metal;kernel void myKernel() {}

Changing the name of the function or texture does not help.

If I put the three lines in the .metal file with the fragment shader, all is well.

What could be causing this?


Viewing all articles
Browse latest Browse all 6334

Trending Articles