[1/2] wined3d: unbound texture units should sample black instead of white.
der.fabe at gmx.net
Thu Jul 1 13:58:02 CDT 2010
On Thursday 01 July 2010 17:19:42 Stefan Dösinger wrote:
> Am Donnerstag 01 Juli 2010 16:54:08 schrieb Fabian Bieler:
> > - 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_REV, &black);
> This will only work if the shader samples 2D textures, or is a 1.x pixel
> I am afraid you'll have to add bit for no texture being bound to a sampled
> sampler to the ps_compile_args structure and replace the TEX statement with
> reading a constant instead. Or explicitly bind dummy 2D, 3D, Cube and RECT
> textures to unused samplers. (and e.g. a dummy 2D, 3D and RECT sampler if a
> volume texture is used)
I hoped that OpenGL took care of those cases. According to the spec samplers
with incomplete textures bound to them should return (0, 0, 0, 1), too.
Wouldn't sampling from a texture unit to which the binding of matching
dimensionality is 0 count as incomplete? (At least as long as no one uploads
an image to it, I'm not sure if it's legal to use texture name 0)
Anyhow, I just did some testing and found out that nvidia returns (0, 0, 0, 0)
for incomplete textures and 'unbound' texture units i.e. bound to 0.
Maybe it does that on windows for D3D, too. I only tested on AMD and the
reference rasterizer (which both return (0, 0, 0, 1)) and bug 14942 only
depends on the rgb components.
My suggestion would be to drop the test for the alpha channel, leave the patch
as it is and report the issue to nvidia.
Also: If you want to work around the issue with more dummy textures, wouldn't
you also have to bind dummy textures to all available texture units (and not
just the ones exposed to the fixed-function-pipeline)?
More information about the wine-devel