Lighting problem on Intel HD Graphics 3000

Started by
11 comments, last by Phil UK 87 11 years, 1 month ago

Sorry it took me so long to reply, I'll try and answer everyone.

Can you post your device creation code?

Here is the device creation code and the code surrounding it:


// Display Mode properties
D3DDISPLAYMODE d3ddm;

// Get Adapter Display Mode
V_RETURN( m_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ));

// Zero the DirectX Presentation Parameters
ZeroMemory( &m_d3dpp, sizeof( m_d3dpp ));

// Set the Presentation Parameter properties
m_d3dpp.Windowed               = TRUE;
m_d3dpp.SwapEffect             = D3DSWAPEFFECT_DISCARD;
m_d3dpp.BackBufferFormat       = d3ddm.Format;
m_d3dpp.EnableAutoDepthStencil = TRUE;
m_d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
m_d3dpp.PresentationInterval   = D3DPRESENT_INTERVAL_IMMEDIATE;

// Create the DirectX Device
V_RETURN( m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_MIXED_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, &m_d3dpp, &m_pd3dDevice ));	

// Setup the basic render state
V_RETURN( m_pd3dDevice->SetRenderState( D3DRS_ALPHAREF, ( DWORD )0x00000001 ));
V_RETURN( m_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE ));
V_RETURN( m_pd3dDevice->SetRenderState( D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL ));

V_RETURN( m_pd3dDevice->SetRenderState( D3DRS_LIGHTING,TRUE ));
V_RETURN( m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE ));
V_RETURN( m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE ));
V_RETURN( m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ));
V_RETURN( m_pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE ));
V_RETURN( m_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, TRUE ));
V_RETURN( m_pd3dDevice->SetRenderState( D3DRS_MULTISAMPLEANTIALIAS, TRUE ));

// Setup Texture Rendering States
V_RETURN( m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ));
V_RETURN( m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ));
V_RETURN( m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT ));
V_RETURN( m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE ));
V_RETURN( m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE ));
V_RETURN( m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE ));

V_RETURN( m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ));
V_RETURN( m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR ));

Try analysing a frame with intel GPA (intel's version of Pix/Nsight). It's pretty stable, and should give you a good idea of what is going wrong.

I couldn't get GPA to work on XP, and could only find a version which requires Vista / 7. Do you know if there is still a version available which will run on XP?

Assuming it's not a driver issue, it's most likely some assumption your code is making - perhaps some undefined state that you're relying on, which just happens to be ok with most graphics cards. Or maybe (given the description of your problem) some problem with setting shader constants.

Have you tried enabling the DirectX debug runtime and seeing if it spits out any interesting messages?

the renderer isn't particularly complicated in that it just uses diffuse lighting and some texturing, no shaders as far as I can tell

No shaders? Is it using the fixed function pipeline?

It doesn't seem to be using shaders, at least I haven't seen any shader code. Is there any reason why the fixed funtion pipeline would cause problems, apart from how limiting it is compared to a shader based renderer?

If the geometry is extremely massive (as you say), you may hit the boundary of how many primitives you can draw in one call.

By "later versions" I mean D3D10 and later; in contrast to D3D9, the newer APIs aim to unify the feature set across same-era hardware, while the performance is the biggest varying factor between low and high end.

As I said, I have changed the code to only render one object and the problem still remains. I agree about the DirectX versions though, perhaps if DirectX 10 was used we wouldn't have this problem.

The reason would be the lack of required shader model.

Maybe the GPU has no PS 2.0/3.0 support, which could not be emulated.

The latest Intel's GPUs work correctly, I think.

The Intel HD 3000 is DX 10.1 capable - I don't think we need be concerned with this as a possible explanation.


I agree, especially if it doesn't use any shaders as I think it does.

Also, I've tried running the program with D3DDEVTYPE_REF on both the laptop and one of the machines with Nvidia graphics, and in both cases the same rendering problem occurs (it only works properly on the Nvidia machine using D3DDEVTYPE_HAL). This makes me think there is something wrong with our DirectX code, because I thought that D3DDEVTYPE_REF was meant to work on any hardware.

Advertisement

The reference device is just a software emulation of the entire D3D pipeline, so if it doesn't work on that then the most obvious explanation is that you've got a code bug but the NVIDIA device is doing something non-standard to make it appear as though it's working.

You could try creating with D3DCREATE_SOFTWARE_VERTEXPROCESSING, which will run the per-vertex pipeline in software; this is more of a test than anything else and I'm willing to bet that it will also reproduce the bug on all devices.

One possible explanation is that the NVIDIA has a bad initial state somewhere. The D3D documentation specifies the initial values for all Render/TextureStage/Sampler states, but the NVIDIA driver may be doing something different - in other words what I'm saying is that the devices where it doesn't work are actually doing the right thing, whereas the NVIDIA is doing the wrong thing but the hypothetical bad initial state is causing it to appear as if it were working.

One way of testing this would be to do a bunch of GetRenderState/GetSamplerState/GetTextureStageState calls at startup for each device and comparing the results; if the theory is correct you should see something different for the NVIDIA.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

I tried D3DCREATE_SOFTWARE_VERTEXPROCESSING (with D3DDEVTYPE_HAL) but this caused a blank screen on the laptop i.e. no geometry visible. On the Nvidia machine this causes a BSOD.

I added a lot of GetRenderState/GetSamplerState/GetTextureStageState calls at the end of the main render function, traced the results and did a comparison for both machines. The only difference was:

D3DRS_POINTSIZE_MAX = 1174405120 (Nvidia)
D3DRS_POINTSIZE_MAX = 1132462080 (Laptop)

I don't know if this could cause a problem. I could post some more results from the GetRenderState/GetSamplerState/GetTextureStageState calls if you think that would help.

This topic is closed to new replies.

Advertisement