Creator 3.8.6 &3.8.7 自定义材质 原生ios上遇到崩溃 求指点

  • Creator 版本: 3.8.6 3.8.7

  • 目标平台:原生ios

  • 重现方式:用压缩包测试工程构建ios 运行

  • 手机型号: iphone xr

  • 编辑器操作系统: macOS

  • 重现概率: 100%
    Xcode: 16
    ios: 15.6

3.8.7 Demo报错信息如下

4 \cf2 \cb3 11:27:28 [INFO]: for2d/builtin-sprite|sprite-vs:vert|sprite-fs:frag|CC_USE_EMBEDDED_ALPHA0|USE_TEXTURE1|IS_GRAY0 compile succeed.
11:29:31 [ERROR]: [ERROR] file /Applications/Cocos/Creator/3.8.7/CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/renderer/gfx-metal/MTLUtils.mm: line 608
11:29:31 [ERROR]: Unsupported blend factor 14
11:29:31 [ERROR]: [ERROR] file /Applications/Cocos/Creator/3.8.7/CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/renderer/gfx-metal/MTLUtils.mm: line 608
11:29:31 [ERROR]: Unsupported blend factor 14
11:30:03 [INFO]: …/res/mtls/VerticalThreeColorEffect/VerticalThreeColorEffect|sprite-vs:vert|sprite-fs:frag|USE_TEXTURE1 compile succeed.
11:30:04 [INFO]: …/res/mtls/warter/water|sprite-vs:vert|sprite-fs:frag|USE_TEXTURE1|USE_NOISETEX1 compile succeed.
11:30:05 [ERROR]: [ERROR] file /Applications/Cocos/Creator/3.8.7/CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/renderer/gfx-base/SPIRVUtils.cpp: line 132
11:30:05 [ERROR]: GLSL Parsing Failed:
ERROR: 0:121: ‘location’ : overlapping use of location 5
ERROR: 1 compilation errors. No code generated.
11:30:05 [ERROR]: [ERROR] file /Applications/Cocos/Creator/3.8.7/CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/renderer/gfx-base/SPIRVUtils.cpp: line 139
11:30:05 [ERROR]: GLSL Linking Failed:
ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point\


3.8.5 项目内报错信息如下
12:37:25 [ERROR]: [ERROR] file /Applications/Cocos/Creator/3.8.5/CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/renderer/gfx-base/SPIRVUtils.cpp: line 132
12:37:25 [ERROR]: GLSL Parsing Failed:
ERROR: 0:122: ‘location’ : overlapping use of location 5
ERROR: 1 compilation errors. No code generated.



12:37:25 [ERROR]: [ERROR] file /Applications/Cocos/Creator/3.8.5/CocosCreator.app/Contents/Resources/resources/3d/engine/native/cocos/renderer/gfx-base/SPIRVUtils.cpp: line 139
12:37:25 [ERROR]: GLSL Linking Failed:
ERROR: Linking vertex stage: Missing entry point: Each stage requires one entry point\

问题描述 :
搞的是2D游戏 在商店搞来几个shader做背景虚化 和一些混合叠加效果 ,在web 原生安卓上运行和显示都正常 在原生ios上报错 闪退, 我也不太清除是我设置有问题还是其他 ,建了空项目放进去测试还是同样,3.8.6和3.8.7都有尝试, 请各位大佬给帮忙看看 哪里错了请帮我指正指正
真诚感谢!
测试demo如下:IosTest.zip (2.0 MB)

你直接扔错误日志更来得快,不同人的电脑环境不一样,说不定别人的就正常运行

好的 我去整理份传上来

@song2008_2001 跪求大佬

为了不沉 我厚着脸再顶顶

看报错是shader编译报错了好像。把shader贴出来,估计是用了苹果不支持的语法或特性了

(1)GaussianBlur.effect:
CCEffect %{
techniques:

  • name: opaque
    passes:
    • vert: vs:vert
      frag: fs:frag
      properties: &props
      _color: { value: [1, 1, 1, 1], editor: { type: color } }
      _textureSize: { value: [100,100],editor: { type: vector } } #textrueSize尺寸
      _blur: { value: 100,editor: { type: int, slide: true , range : [0,100], step: 1 } }
  • name: transparent
    passes:
    • vert: vs:vert
      frag: fs:frag
      blendState:
      targets:
      • blend: true
        blendSrc: src_alpha
        blendDst: one_minus_src_alpha
        blendSrcAlpha: src_alpha
        blendDstAlpha: one_minus_src_alpha
        properties: *props
        }%

CCProgram vs %{
precision highp float;
#include
#if USE_LOCAL
#include
#endif

#if SAMPLE_FROM_RT
#include <common/common-define>
//#include
#endif

in vec3 a_position;
in vec2 a_texCoord;
in vec4 a_color;

uniform Constant {
vec4 _color;
vec2 _textureSize;
float _blur;
};

out vec4 i_color;
out vec2 uv0;
out vec2 uv1;
out vec3 v_position;
out float offset_x[5];
out float offset_y[5];
out float weight[5];
void init()
{
offset_x[0] = 0.0 * _blur/_textureSize.x;
offset_x[1] = 0.1 * _blur/_textureSize.x;
offset_x[2] = 0.2 * _blur/_textureSize.x;
offset_x[3] = 0.3 * _blur/_textureSize.x;
offset_x[4] = 0.4 * _blur/_textureSize.x;
offset_y[0] = 0.0 * _blur/_textureSize.y;
offset_y[1] = 0.1 * _blur/_textureSize.y;
offset_y[2] = 0.2 * _blur/_textureSize.y;
offset_y[3] = 0.3 * _blur/_textureSize.y;
offset_y[4] = 0.4 * _blur/_textureSize.y;
weight[0] = 0.2270270270;
weight[1] = 0.1945945946;
weight[2] = 0.1216216216;
weight[3] = 0.0540540541;
weight[4] = 0.0162162162;
}

vec4 vert () {
vec4 pos = vec4(a_position, 1);

#if USE_LOCAL
  pos = cc_matWorld * pos;
#endif

#if USE_PIXEL_ALIGNMENT
  pos = cc_matView * pos;
  pos.xyz = floor(pos.xyz);
  pos = cc_matProj * pos;
#else
  pos = cc_matViewProj * pos;
#endif

uv0 = a_texCoord;
#if SAMPLE_FROM_RT
  uv1 = uv0;
  CC_HANDLE_RT_SAMPLE_FLIP(uv1);
#endif
i_color = a_color;
#if USE_GAUSSIAN_BLUR
    init();
#endif
return pos;

}
}%

CCProgram fs %{
precision highp float;
#include

#if USE_TEXTURE
#include
//#include
#endif

in vec4 i_color;
in vec2 uv0;

in float offset_x[5];
in float offset_y[5];
in float weight[5];

uniform Constant {
vec4 _color;
vec2 _textureSize;
float _blur;
};

vec4 frag () {
vec4 color =_color;
#if USE_GAUSSIAN_BLUR
color = texture(cc_spriteTexture, uv0) * weight[0];
for (int i=1; i<5; i++) {
color +=
texture(cc_spriteTexture, (vec2(uv0)+vec2(offset_x[i], 0)))
* weight[i]/2.0;
color +=
texture(cc_spriteTexture, (vec2(uv0)-vec2(offset_x[i], 0)))
* weight[i]/2.0;
color +=
texture(cc_spriteTexture, (vec2(uv0)+vec2(0, offset_y[i])))
* weight[i]/2.0;
color +=
texture(cc_spriteTexture, (vec2(uv0)-vec2(0, offset_y[i])))
* weight[i]/2.0;
}
#else
color = texture(cc_spriteTexture, uv0);
#endif
return color;
}
}%

贴了3个 您帮我看看 跪谢!

每日一顶 希望有懂的大佬帮看看

能否上传完整的demo?

传了的 在上边

崩溃的问题是 offset_x, offset_y, weight等是数组(数组每个元素是一个location,总共15个),应该是超过了设备限定的 vary 数量限制,造成某个location 会有多个变量。

可以通过uniform的方式规避

1赞

引擎组牛逼,活儿(技术)硬,还这么勤快

好的 感谢 !
我改改看下

这个报错是解决了 感谢!
请问这种原生端深层报错 怎样调试或者定位的?能不能教一下我 ,因为我又遇到了新bug :sweat_smile:下图,看见这种bug我就不知如何下手,还请大佬赐教!再次鞠躬!

我这个报错和[这个帖子极度相似
https://forum.cocos.org/t/topic/158366
DescriptorSetValidator.cpp ine 149
但是我甚至连是哪个.effect 或者哪个图 文件报出来的错都不知如何定位 :weary:

你可以在编辑器上 看下你spine使用了哪个自定义材质,然后找到材质双击,查看使用的effect,之后查看里面的内容

查了 新崩溃位置没有使用材质 shader 请问DescriptorSetValidator.cpp ine 149 这个ios崩溃都有什么可能会引起 或者怎样规避

要看具体的崩溃堆栈,不确定崩溃的起点是哪,就确定不了问题根本问题


公司项目不能上传demo 请大佬帮看下 如果还需要什么信息请告诉我

fillBuffersAndMerge是ts的什么组件引发的呢,spine还是什么,没demo是不好定位。