Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLSL转 MSL的一些疑问? #60

Open
breakerrorchen opened this issue Dec 24, 2020 · 0 comments
Open

HLSL转 MSL的一些疑问? #60

breakerrorchen opened this issue Dec 24, 2020 · 0 comments

Comments

@breakerrorchen
Copy link

比如这样一个HLSL文件

uniform float4 data = 0;

struct VS_OUT {
float4 pos: SV_POSITION;
float4 color:COLOR;

};

VS_OUT vs_main(float4 pos: POSITION) {
VS_OUT ret = (VS_OUT)0;
ret.pos = pos + data;
return ret;
}

转化成MSL的文件

#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct type_Globals
{
float4 data;
};

struct vs_main_out
{
float4 out_var_COLOR [[user(locn0)]];
float4 gl_Position [[position]];
};

struct vs_main_in
{
float4 in_var_POSITION [[attribute(0)]];
};

vertex vs_main_out vs_main(vs_main_in in [[stage_in]], constant type_Globals& _Globals [[buffer(0)]])
{
vs_main_out out = {};
out.gl_Position = in.in_var_POSITION + _Globals.data;
out.out_var_COLOR = float4(0.0);
return out;
}

这个文件中 定义了type_Globals 并把data放在了里面,问题是我如何拿到这个data的index?如果有2个uniform的话应该如何处理?不可能通过源码的方式来约定吧。 Metal本身好像没有提供这个API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant