DirectX Firefox 插件渲染工件

发布于 2024-08-02 23:01:19 字数 1873 浏览 4 评论 0原文

快速解答:对于那些通过 Google 访问此页面寻找 相同问题的解决方案,尝试 这个快速修复(由 Goz 建议)- 将 D3DCREATE_FPU_PRESERVE 添加到 CreateDevice() 上的行为标志 称呼。这让我明白了!

我正在创建一个基于 DirectX 9 的 NPAPI 插件。它似乎在 Chrome 和 Opera 中运行良好,但在 Firefox 中我得到了奇怪的渲染伪影。初始化 DirectX 后(无需进行渲染即可显示工件),全部或部分 Firefox UI 将变黑。调整窗口大小(即:启动重新绘制)可以清除工件,并且插件此时似乎可以正常工作,但这显然不是一个理想的“功能”。我发现网上其他几个人都提到了这个问题,大多数声称它是从 Firefox 3 开始的。只有 一篇文章提到了正在找到的任何解决方案,但作者似乎并不热衷于透露如何解决。

有谁熟悉这个问题和可能的解决方案?从链接的帖子来看,它似乎与 DX 的初始化方式有关,但我还没有找到可以防止该问题的组合。

这是我正在使用的 DX 初始化代码(为了清楚起见,删除了错误处理):

RECT rc;
GetClientRect(pluginHwnd, &rc);

D3DPRESENT_PARAMETERS d3d9PresentParams;
ZeroMemory(&d3d9PresentParams, sizeof(D3DPRESENT_PARAMETERS));    

d3d9PresentParams.hDeviceWindow = pluginHwnd;
d3d9PresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3d9PresentParams.Flags = D3DPRESENTFLAG_DEVICECLIP; // Failed attempt to solve FF issue
d3d9PresentParams.EnableAutoDepthStencil = FALSE; // No depth testing
d3d9PresentParams.PresentationInterval = D3DPRESENT_INTERVAL_ONE; // Use Vsync

d3d9PresentParams.MultiSampleType = D3DMULTISAMPLE_NONE; // Don't care about Multisampling
d3d9PresentParams.MultiSampleQuality = 0;

d3d9PresentParams.BackBufferCount = 1; 
d3d9PresentParams.BackBufferWidth = rc.right - rc.left; 
d3d9PresentParams.BackBufferHeight = rc.bottom - rc.top;  
d3d9PresentParams.BackBufferFormat = D3DFMT_UNKNOWN; // Use the same color format as windows 

d3d9PresentParams.Windowed = TRUE; // Explicitly windowed
d3d9PresentParams.FullScreen_RefreshRateInHz = 0;

d3d9->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pluginHwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3d9PresentParams, &d3d9Device );

QUICK ANSWER: For those of you who reach this page via Google looking for
a solution to the same problem, try
this quick fix (suggested by Goz) -
Add D3DCREATE_FPU_PRESERVE to the
behavior flags on your CreateDevice()
call. That cleared it up for me!

I'm creating a DirectX 9-based NPAPI plugin. It seems to be working well in Chrome and Opera, but in Firefox I get strange rendering artifacts. Upon initializing DirectX (no rendering needs to be done for the artifact to appear) all or parts of the Firefox UI will turn black. Resizing the window (IE: Initiating a repaint) clears up the artifacts and the plugin seems to work properly at that point, but this is obviously not a desirable "feature". I have found that several others online have mentioned this issue, most claiming that it began with Firefox 3. Only one post mentions any solution being found, but the author doesn't seem to keen on divulging how.

Is anyone familiar with this issue and a possible solution? From the linked post it would seem to be related to the way DX is initialized, but I've yet to find a combination that prevents the issue.

This is the DX Initialization code I'm using (Error Handling removed for clarity):

RECT rc;
GetClientRect(pluginHwnd, &rc);

D3DPRESENT_PARAMETERS d3d9PresentParams;
ZeroMemory(&d3d9PresentParams, sizeof(D3DPRESENT_PARAMETERS));    

d3d9PresentParams.hDeviceWindow = pluginHwnd;
d3d9PresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3d9PresentParams.Flags = D3DPRESENTFLAG_DEVICECLIP; // Failed attempt to solve FF issue
d3d9PresentParams.EnableAutoDepthStencil = FALSE; // No depth testing
d3d9PresentParams.PresentationInterval = D3DPRESENT_INTERVAL_ONE; // Use Vsync

d3d9PresentParams.MultiSampleType = D3DMULTISAMPLE_NONE; // Don't care about Multisampling
d3d9PresentParams.MultiSampleQuality = 0;

d3d9PresentParams.BackBufferCount = 1; 
d3d9PresentParams.BackBufferWidth = rc.right - rc.left; 
d3d9PresentParams.BackBufferHeight = rc.bottom - rc.top;  
d3d9PresentParams.BackBufferFormat = D3DFMT_UNKNOWN; // Use the same color format as windows 

d3d9PresentParams.Windowed = TRUE; // Explicitly windowed
d3d9PresentParams.FullScreen_RefreshRateInHz = 0;

d3d9->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pluginHwnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3d9PresentParams, &d3d9Device );

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

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

发布评论

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

评论(1

楠木可依 2024-08-09 23:01:20

我唯一能想到的就是在设备创建时设置“D3DCREATE_NOWINDOWCHANGES”行为标志。

编辑1:
您可以尝试将 backbufferwidth 和 height 设置为 0 并让它继承窗口的信息。

可能还值得尝试设置 D3DCREATE_FPU_PRESERVE 标志和 D3DCREATE_MULTITHREADED。

The only thing I can think of off the top of my head is setting the "D3DCREATE_NOWINDOWCHANGES" behaviour flag on device creation.

Edit1:
You could try setting backbufferwidth and height to 0 and let it inherit the info from the window.

Might also be worth trying setting the D3DCREATE_FPU_PRESERVE flag and D3DCREATE_MULTITHREADED.

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