代码之家  ›  专栏  ›  技术社区  ›  Brigapes

像Macbook Air这样的GPU受限设备是广泛市场WebGL性能指标的好来源吗?

  •  0
  • Brigapes  · 技术社区  · 2 年前

    对问题的标题不满意,但我们正在与PixiJS和WebGL合作开发一款网络游戏。游戏应该以合理的帧速率在几乎所有设备上运行(至少是支持WebGL的设备)。我们有一台旧的Macbook Air在工作,我们在那里测试性能和影响它的因素。我们的CPU时间通常在4ms左右,设备的GPU严重受限。我们尝试运行一个简单的着色器来获得简单的草效果,它只是通过片段着色器来摆动图片。但macbook不喜欢它,立即降低了帧速率。

    但真正的问题是,使用macbook air作为通用性能基准有多现实?即使是5年前的手机也有比macbook air更强大的GPU,在这些GPU上,性能也很好,但我们不知道如何确保我们在足够广阔的市场上获得良好的性能,我开始认为macbook air完全不现实,现在的手机有更强大的CPU?

    precision mediump float;
    
    varying vec2 vTextureCoord;
    varying vec4 vColor;
    
    uniform sampler2D uSampler;
    uniform float customUniform;
    uniform float loopLength; // The length of the looping interval
    
    void main(void)
    {
       vec2 uvs = vTextureCoord.xy;
    
       // Calculate the displacement factor based on the texture coordinates and time
       float displacement = sin((1.0 - uvs.y) * customUniform * 2.0 * 3.14159 / loopLength) * 0.05; // Adjust the magnitude of the wave effect
    
       // Apply the displacement to the texture coordinates
       uvs.x += displacement;
    
       // Sample the texture using the modified coordinates
       vec4 fg = texture2D(uSampler, uvs);
    
       gl_FragColor = fg;
    }
    

    这是我们测试过的着色器。这本身就有些无辜。看到Macbook Air的性能如此之低,我们感到非常震惊。我们也会在一些手机和平板电脑上测试我们的应用程序。

    0 回复  |  直到 2 年前
    推荐文章