» 您尚未登录:请 登录 | 注册 | 标签 | 帮助 | 小黑屋 |


发新话题
打印

[新闻] ios8的metal类似AMD的mantle。。。。

At Apple's WWDC conference today they have just unveiled Metal, a new 3D graphics API to compete with OpenGL.

Like AMD's Mantle and the recent complaints about OpenGL and the overhead of OpenGL drivers, Apple has devised its own graphics API that is "closer to metal" and hence its name.

Apple's Craig Federighi said during the presentation that Metal allows for up to 10x the call rates of OpenGL's current speeds while having substantially less overhead. Initially the Metal graphics API is meant for iOS with driving the mobile gaming experience.

Exactly how open the Metal API will be remains to be seen and if/when the Apple Metal API will appear on the desktop within AMD/NVIDIA graphics drivers. At the very least, hopefully all of this recent attention around 3D graphics APIs will lead to faster innovation and growth within OpenGL / OpenGL ES. Metal will premiere later this year with iOS 8 while developers have early access beginning today.

Apple also announced today OS X Yosemite, their latest OS, which will ship later this calendar year.


TOP

swift看了一上午。
metal api我看了。很简洁。
这玩意的shader是c++11,而且可以直接include c++头文件。
#include <metal_stdlib>
#include <simd/simd.h>
#include "METLSharedTypes.h"

using namespace metal;

// variables in constant address space
constant float3 light_position = float3(0.0, 1.0, -1.0);

typedef struct
{
        packed_float3 position;
        packed_float3 normal;
} vertex_t;

struct ColorInOut {
    float4 position [[position]];
    half4 color;
};

// vertex shader function
vertex ColorInOut lighting_vertex(global vertex_t* vertex_array [[ buffer(0) ]],
                                  constant METL::uniforms_t& uniforms [[ buffer(1) ]],
                                  unsigned int vid [[ vertex_id ]])
{
    ColorInOut out;
   
        float4 in_position = float4(float3(vertex_array[vid].position), 1.0);
    out.position = uniforms.modelview_projection_matrix * in_position;
   
    float3 normal = vertex_array[vid].normal;
    float4 eye_normal = normalize(uniforms.normal_matrix * float4(normal, 0.0));
    float n_dot_l = dot(eye_normal.rgb, normalize(light_position));
    n_dot_l = fmax(0.0, n_dot_l);
   
    out.color = half4(uniforms.ambient_color + uniforms.diffuse_color * n_dot_l);
   
    return out;
}

// fragment shader function
fragment half4 lighting_fragment(ColorInOut in [[stage_in]])
{
    return in.color;
};

swift看了一上午,也会了。

[ 本帖最后由 风间星魂 于 2014-6-3 14:48 编辑 ]



TOP

发新话题
     
官方公众号及微博