Firefox Plugin Rendering Artifacts

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

I am creating an NPAPI plugin based on DirectX 9. It seems to work well in Chrome and Opera, but in Firefox I get strange rendering artifacts. After initializing DirectX (no rendering is required to display the artifact), all or parts of the Firefox user interface will turn black. Window resizing (IE: triggering redrawing) clears artifacts, and the plugin seems to be working correctly at this point, but this is obviously not a desirable β€œfeature”. I found that some other users on the Internet mentioned this problem, most claim that it started with Firefox 3. Only one message mentions any solution found, but the author does not seem to seek to disclose it.

Is anyone familiar with this problem and a possible solution? From a related post, this seems to be related to how the DX is initialized, but I have yet to find a combination that prevents the problem.

This is the DX initialization code I am using (error removal 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 );
+1
source share
1 answer

The only thing I can think of with my head is to set the D3DCREATE_NOWINDOWCHANGES behavior flag when creating the device.

Edit1: You can try setting backbufferwidth and height to 0 and letting it inherit information from the window.

Perhaps you should try setting the D3DCREATE_FPU_PRESERVE and D3DCREATE_MULTITHREADED flags.

+2
source

Source: https://habr.com/ru/post/1786538/


All Articles