Direct3D10:没有 32 位 ARGB 格式?

发布于 2024-07-15 08:53:51 字数 538 浏览 8 评论 0原文

我开始添加 d3d10 支持以配合我现有的 d3d9 图形后端。

问题是所有现有代码(在多个应用程序中......)都使用 ARGB 格式的颜色,但是我找不到与 d3d10 匹配的格式模式。 d3d10 根本不支持 ARGB 颜色格式还是我错过了一些东西? 如果我没有错过什么是在它们之间进行转换的好方法,它只需要将第一个字节移到末尾,这似乎是一个非常简单的概念,但是除了将颜色分解为其组件之外,我看不到其他方法并重建它...例如:

//unsigned colIn, colOut
unsigned char
    a = (colIn & 0xFF000000) >> 24,
    r = (colIn & 0x00FF0000) >> 16,
    g = (colIn & 0x0000FF00) >> 8,
    b = (colIn & 0x000000FF);
colOut = (r << 24) | (g << 16) | (b << 8) | a;

Im starting to add d3d10 support to go along with my existing d3d9 graphics backend.

The problem is all the existing code (in several applications...) uses ARGB formatted colours however I couldnt find a format mode that matches for d3d10. Does d3d10 not support ARGB colour formats at all or have I just missed something? If I havnt missed something what is a good way to convert between them, It just requires the first byte be moved to the end, this seems like a pretty simple concept however I cant see anyway to do it other than breaking the colour into its components and reconstructing it...eg:

//unsigned colIn, colOut
unsigned char
    a = (colIn & 0xFF000000) >> 24,
    r = (colIn & 0x00FF0000) >> 16,
    g = (colIn & 0x0000FF00) >> 8,
    b = (colIn & 0x000000FF);
colOut = (r << 24) | (g << 16) | (b << 8) | a;

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你与清晨阳光 2024-07-22 08:53:51

在我看来,该格式已丢失,因此您需要重新排序数据。 但是,如果您要使用 RGBA,则不需要像示例那样分离所有颜色,因为 R、G 和 B 仍然连续处于相同的顺序,您可以将这 3 个通道作为一个块移动。

It looks to me like that format has gone missing so you would need to re-order your data. However if you're going to use RGBA, you wouldn't need to separate all your colors like your example does since R,G,&B are still in the same order consecutively, you could move those 3 channels as one chunk.

一桥轻雨一伞开 2024-07-22 08:53:51

查看相关的 枚举类型,我(也)找不到任何 AxRxGxBx 格式。 那么看来您需要自己进行调配。

这非常适合SSE优化当然,检查你的编译器是否能够优化代码进入使用 SSE 的东西并且性能应该很好。

在编写这段代码时要考虑字节序问题,很容易出错,而且如果不关心字节序,这段代码就很难编写。

Looking at the relevant enum type, I (too) fail to find any AxRxGxBx formats. So it seems you need to do the swizzling by yourself, then.

This is extremely suitable for SSE optimization of course, check if your compiler is able to optimize the code into something that uses SSE and performance should be fine.

Think about endianness issues when doing this code, it's easy to make a mistake and this code is hard to write without caring about endianness.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文