小编t91*_*t91的帖子

在金属着色语言中创建全局可访问的常量缓冲区


我有一个关于Metal中常量缓冲区的问题。假设我有类似的东西:

...list of includes goes here...

using namespace metal; 

struct ConstantBuffer {
     float ANY_VALUE;
};

struct VS_INPUTS { 
    float4 i_pos_ms [ [ attribute ( 0 ) ] ] ; 
} ; 

struct V2P_STRUCT { 
    float4 v_pos_out [ [ position ] ] ;  
} ; 

float3 CalcSomething() {
    return float3(ANY_VALUE, ANY_VALUE, ANY_VALUE); // !!!!!!!!
}

vertex V2P_STRUCT VertexFunc(VS_INPUTS vs_inputs [ [ stage_in ] ] , 
                             constant ConstantBuffer& cb [ [ buffer (1) ] ] )
{
    V2P_STRUCT vs_outputs;

    vs_outputs.v_pos_out.xyz = CalcSomething(); …
Run Code Online (Sandbox Code Playgroud)

ios metal

2
推荐指数
1
解决办法
1695
查看次数

标签 统计

ios ×1

metal ×1