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 shader.
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)
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 shader.
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)?
Fabian
Am 01.07.2010 um 20:58 schrieb Fabian Bieler:
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)
Part of the problem is that we don't maintain a texture dimension that isn't used on a sampler. E.g.
bind Volume texture to sampler 0 draw with a shader reading the volume texture bind 2D texture to sampler 0 draw with a shader reading the 2D texture bind a shader reading volume textures draw with that shader
The last step reads from the volume texture bound in step 0, but I guess the correct thing would be to return 0,0,0,1 because the sampler doesn't match the shader. That's why I am afraid you'll have to fix this in the shader, by not sampling at all if the texture doesn't match.
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.
I can do some testing, but first I have to fix the existing tests. I get about 1000 failures on my Win7+Nvidia box.
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)?
I don't think dummy textures are the way to go here. They're needed for fixed function for texture ops that don't involve textures, because otherwise ARB_texture_combiners returns an error. E.g.
stage 1 texture: NULL stage 1 color op: D3DTOP_ADD stage 1 color arg1: D3DTA_PREVIOUS stage 1 color arg2: D3DTA_TEXFACTOR
The texture isn't used here, but the texture_combiner API says that using a stage without a texture is an error, hence the dummy textures. We shouldn't need them for the nvrc, arbfp and atifs pipelines.
On 1 July 2010 20:58, Fabian Bieler der.fabe@gmx.net wrote:
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)
I don't think we actually unbind the old texture for anything other than 2D textures. In that sense the whole dummy texture scheme is a bit broken anyway.