Home » Flash相关 » Stage3D » 理解Stage3D profiles

理解Stage3D profiles

原文链接:http://www.adobe.com/devnet/flashplayer/articles/stage3d-profiles.html

翻译和理解可能出现偏差。建议直接阅读原文。

简述

当我request一个Context3D对象的时候,通常会指定一个profile(配置参数),不同profile对应的Stage3D会有不同的特征。具体profile的选择,要根据开发者具体面上的用户,以及用户所使用的设备/平台。

可供选择的Profile

当前可供选择的profile如下:

  • Standard
    • Standard Extended
    • Standard
    • Standard Constrained
  • Baseline
    • Baseline Extended
    • Baseline
    • Baseline Constrained

如何使用profile创建Context3D

1、通常代码示例如下:

public function requestContext3D(context3DRenderMode:String = "auto", profile:String ="baseline")

默认情况下,是使用“Baseline”这套配置参数的。

2、另外一种方式requestContext3DMatchingProfile

public function requestContext3DMatchingProfiles(profiles:Vector.<String>):void

profiles:Vector.<String>是个profile名称的数组。如果指定多个,系统会自动创建设备能够兼容的最高级别的那个。

所有Profile的特征表

大致区别表现在,寄存器数量、AGAL代码数量上限,纹理尺寸大小上限,以及一些其他的特征。

Features Baseline Constrained Baseline Baseline Extended Standard Constrained Standard Standard Extended
Register:va 8 8 8 8 8 16
Register:vc 128 128 128 250 250 250
Register:vt 7 8 8 26 26 26
Register:v 8 8 8 8 10 10
Register:fc 28 28 28 64 64 200
Register:ft 8 8 8 26 26 26
Register:fs 8 8 8 8 16 16
Register:iid 0 0 0 0 0 1
Token 200 200 200 1024 1024 2048
Rectangle Texture NO YES YES YES YES YES
4k+ Texture NO NO YES YES YES YES
MRT NO NO NO NO YES YES
Half-precision floating-point texture NO NO NO YES YES YES
AGAL:Conditional forward jump instructions NO NO NO YES YES YES
AGAL:Fragment depth output NO NO NO NO YES YES
AGAL:Partial derivative instructions NO NO NO YES YES YES

Baseline Constrained: Baseline是Stage3D的默认配置,虽然有很多设备都支持。但是还是有不少设备不支持的。为了获得最多的用户终端,所以又搞出个Baseline Constrained。

Baseline: 默认配置。主要支持设备必须支持PS_2.0 级别的 shader。比如GMA 9xx 系列. 此外,这个模式下,会在直接渲染到后台缓冲区的时候尝试提高显存带宽的使用。

Baseline Extended: 跟上面的Baseline和Baseline Constrained相比,这个模式下,可以支持4096*4096大小的纹理,而上面两个只支持2048*2048.

Standard Constrained: 在桌面系统,绝大多数显卡都支持 “standard” 配置。所有的非Pepper Flash Player,都是直接使用操作系统的图形接口 。所以除了Pepper Flash Player之外,基本上都没有问题。

由于在Windows平台上,Pepper API是封装了操作系统的D3D9(或者D3D11)的图形接口,然后提供 OpenGL ES2.0接口给Flash.所以,Pepper只支持在基于D3D11上面的才具备MutipeRenderTarget特征。而基于D3D9接口的,则不具备MRT这个功能。

具体是使用D3D9还是D3D11,取决于Chrome浏览器。(访问这个地址: chrome://gpu/ ,然后搜索 GL_RENDERER 可以查看后台到底基于什么渲染实现的。)

由于某些原因(比如 驱动BUG,旧的硬件,以及其他),Chrome大多数情况都是强制使用D3D9进行渲染。这个也是为什么“standard”配置没有得到广泛使用的原因。(顺便吐槽一下,作为一名Flash游戏开发者,真心觉得谷歌PepperAPI好垃圾。在图形渲染方面,OpenGL已然完败DirectX)

而且现在Chrome强制所有Intel显卡都使用D3D9.大多数基于OpenGLES2.0的设备,都不支持Mutiple Render Target 和 fragmentation depth 系列特征。

为了在功能和用户终端覆盖之间做出权衡,所有才会有Constrained版本的Standard.

Standard:  新增支持AGAL2, Multiple Render Target (MRT), 以及 Floating point texture.

Standard Extended: 支持AGAL v3,增加了一些寄存器。

    分享到: