[2/6] wined3d: Make dummy textures black.
Matteo Bruni
matteo.mystral at gmail.com
Mon Jul 4 15:32:30 CDT 2011
This fixes Darkspore bug http://bugs.winehq.org/show_bug.cgi?id=27076,
among other things. Actually the game does something quite
questionable: to disable part of an effect, it sets a texture to NULL
(while still sampling from it). This calls for badly-defined behavior,
in the past it wasn't consistent enough between different drivers to
be relied upon (e.g.
http://tomsdxfaq.blogspot.com/2003_02_01_archive.html#88502992), but
apparently now the situation has changed...
-------------- next part --------------
From 58ed39b8e2e8f04c3b91fb467feee1a12dcc3a83 Mon Sep 17 00:00:00 2001
From: Matteo Bruni <mbruni at codeweavers.com>
Date: Thu, 30 Jun 2011 15:01:07 +0200
Subject: wined3d: Make dummy textures black.
---
dlls/d3d9/tests/visual.c | 2 +-
dlls/wined3d/device.c | 13 ++++++-------
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index 0496896..16047bf 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -12117,7 +12117,7 @@ static void unbound_sampler_test(IDirect3DDevice9 *device)
}
color = getPixelColorFromSurface(rt, 32, 32);
- todo_wine ok(color == 0xff000000, "Unbound sampler color is %#x.\n", color);
+ ok(color == 0xff000000, "Unbound sampler color is %#x.\n", color);
hr = IDirect3DDevice9_SetRenderTarget(device, 0, old_rt);
ok(SUCCEEDED(hr), "IDirect3DDevice9_SetRenderTarget failed, hr %#x.\n", hr);
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index f3fceac..334319e 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -971,11 +971,10 @@ static void create_dummy_textures(struct wined3d_device *device)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
unsigned int i;
- /* Under DirectX you can have texture stage operations even if no texture is
- bound, whereas opengl will only do texture operations when a valid texture is
- bound. We emulate this by creating dummy textures and binding them to each
- texture stage, but disable all stages by default. Hence if a stage is enabled
- then the default texture will kick in until replaced by a SetTexture call */
+ /* Under DirectX you can sample even if no texture is bound, whereas
+ * OpenGL will only allow that when a valid texture is bound.
+ * We emulate this by creating dummy textures and binding them
+ * to each texture stage when the currently set D3D texture is NULL. */
ENTER_GL();
if (gl_info->supported[APPLE_CLIENT_STORAGE])
@@ -987,7 +986,7 @@ static void create_dummy_textures(struct wined3d_device *device)
for (i = 0; i < gl_info->limits.textures; ++i)
{
- GLubyte white = 255;
+ DWORD color = 0x000000ff;
/* Make appropriate texture active */
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
@@ -1003,7 +1002,7 @@ static void create_dummy_textures(struct wined3d_device *device)
glBindTexture(GL_TEXTURE_2D, device->dummyTextureName[i]);
checkGLcall("glBindTexture");
- glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, &white);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 1, 1, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, &color);
checkGLcall("glTexImage2D");
}
--
1.7.3.4
More information about the wine-patches
mailing list