GLSL大型/小型兼容性

发布于 2025-01-25 11:45:09 字数 483 浏览 1 评论 0原文

以我的像素格式,我有以下联盟(C ++结束):

union
{
    int mInteger;
    struct
    {
        short mData1;
        short mData2;
    };
};

在GLSL中,我想访问MDATA1中的​​任何内容...所以我这样做:

layout (location=4) in uint input_mInteger;
...
uint access_mData1=(input_mInteger&uint(0x0000FFFF));
// Do something with access_mData1...

我的问题是...这对Bigendian和Littleendian Systems都可以使用吗?还是我必须将我的和掩码切换到0xffff0000(否则它将是相同的代码,还是我需要做更多的工作以访问Minteger低音的值?)

In my pixel format, I have the following union (c++ end):

union
{
    int mInteger;
    struct
    {
        short mData1;
        short mData2;
    };
};

in GLSL I want to access whatever's in mData1... so I do this:

layout (location=4) in uint input_mInteger;
...
uint access_mData1=(input_mInteger&uint(0x0000FFFF));
// Do something with access_mData1...

My question is... will that work on both BigEndian and LittleEndian systems? Or will I have to switch my and mask to 0xFFFF0000 (and will it otherwise be the same code, or will I need to do even more work to access the value in the low word of mInteger?)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文