Commit 3e5899b3 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

d3d9: Some Windows drivers set undefined attributes to 0.0.

parent 1c3e725d
...@@ -6078,11 +6078,13 @@ void test_vshader_input(IDirect3DDevice9 *device) ...@@ -6078,11 +6078,13 @@ void test_vshader_input(IDirect3DDevice9 *device)
ok(color == 0x00FFFF80 || color == 0x00FFFF7f || color == 0x00FFFF81, ok(color == 0x00FFFF80 || color == 0x00FFFF7f || color == 0x00FFFF81,
"Input test: Quad 1(2crd) returned color 0x%08x, expected 0x00FFFF80\n", color); "Input test: Quad 1(2crd) returned color 0x%08x, expected 0x00FFFF80\n", color);
/* The last value of the read but undefined stream is used */ /* The last value of the read but undefined stream is used, it is 0x00. The defined input is vec4(1, 0, 0, 0) */
color = getPixelColor(device, 480, 360); color = getPixelColor(device, 480, 360);
ok(color == 0x00FFFF00, "Input test: Quad 2(1crd) returned color 0x%08x, expected 0x00FFFF00\n", color); ok(color == 0x00FFFF00 || color ==0x00FF0000,
"Input test: Quad 2(1crd) returned color 0x%08x, expected 0x00FFFF00\n", color);
color = getPixelColor(device, 160, 120); color = getPixelColor(device, 160, 120);
ok(color == 0x00FF0080 || color == 0x00FF007f || color == 0x00FF0081, /* Same as above, accept both the last used value and 0.0 for the undefined streams */
ok(color == 0x00FF0080 || color == 0x00FF007f || color == 0x00FF0081 || color == 0x00FF0000,
"Input test: Quad 3(2crd-wrongidx) returned color 0x%08x, expected 0x00FF0080\n", color); "Input test: Quad 3(2crd-wrongidx) returned color 0x%08x, expected 0x00FF0080\n", color);
color = getPixelColor(device, 480, 160); color = getPixelColor(device, 480, 160);
...@@ -6149,7 +6151,8 @@ void test_vshader_input(IDirect3DDevice9 *device) ...@@ -6149,7 +6151,8 @@ void test_vshader_input(IDirect3DDevice9 *device)
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %s\n", DXGetErrorString9(hr)); ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %s\n", DXGetErrorString9(hr));
color = getPixelColor(device, 480, 350); color = getPixelColor(device, 480, 350);
/* vs_1_1 may fail, accept the clear color /* vs_1_1 may fail, accept the clear color. Some drivers also set the undefined streams to 0, accept that
* as well.
* *
* NOTE: This test fails on the reference rasterizer. In the refrast, the 4 vertices have different colors, * NOTE: This test fails on the reference rasterizer. In the refrast, the 4 vertices have different colors,
* i.e., the whole old stream is read, and not just the last used attribute. Some games require that this * i.e., the whole old stream is read, and not just the last used attribute. Some games require that this
...@@ -6158,8 +6161,8 @@ void test_vshader_input(IDirect3DDevice9 *device) ...@@ -6158,8 +6161,8 @@ void test_vshader_input(IDirect3DDevice9 *device)
* *
* A test app for this behavior is Half Life 2 Episode 2 in dxlevel 95, and related games(Portal, TF2). * A test app for this behavior is Half Life 2 Episode 2 in dxlevel 95, and related games(Portal, TF2).
*/ */
ok(color == 0x000000FF || color == 0x00808080, ok(color == 0x000000FF || color == 0x00808080 || color == 0x00000000,
"Input test: Quad 2(different colors) returned color 0x%08x, expected 0x000000FF\n", color); "Input test: Quad 2(different colors) returned color 0x%08x, expected 0x000000FF, 0x00808080 or 0x00000000\n", color);
color = getPixelColor(device, 160, 120); color = getPixelColor(device, 160, 120);
IDirect3DDevice9_SetVertexShader(device, NULL); IDirect3DDevice9_SetVertexShader(device, NULL);
......
...@@ -3017,6 +3017,14 @@ static inline void unloadNumberedArrays(IWineD3DStateBlockImpl *stateblock) { ...@@ -3017,6 +3017,14 @@ static inline void unloadNumberedArrays(IWineD3DStateBlockImpl *stateblock) {
for (i = 0; i < maxAttribs; ++i) { for (i = 0; i < maxAttribs; ++i) {
GL_EXTCALL(glDisableVertexAttribArrayARB(i)); GL_EXTCALL(glDisableVertexAttribArrayARB(i));
checkGLcall("glDisableVertexAttribArrayARB(reg)"); checkGLcall("glDisableVertexAttribArrayARB(reg)");
/* Some Windows drivers(NV GF 7) use the latest value that was used when drawing with the now
* deactivated stream disabled, some other drivers(ATI, NV GF 8) set the undefined values to 0x00.
* Let's set them to 0x00 to avoid hitting some undefined aspects of OpenGL. All that is really
* important here is the glDisableVertexAttribArrayARB call above. The test shows that the refrast
* keeps dereferencing the pointers, which would cause crashes in some games like Half Life 2 Eposide 2
*/
GL_EXTCALL(glVertexAttrib4NubARB(i, 0, 0, 0, 0));
checkGLcall("glVertexAttrib4NubARB(i, 0, 0, 0, 0)");
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment