http://bugs.winehq.org/show_bug.cgi?id=14762
--- Comment #44 from Stefan Dösinger stefandoesinger@gmx.at 2008-12-04 18:42:41 --- Yes, this is the problem:
/* can we safely assume that the cast works here? */ const IWineD3DSurfaceImpl *surf = (IWineD3DSurfaceImpl*)stateBlock->textures[i]; const float tex_dim[2] = {surf->currentDesc.Width, surf->currentDesc.Height};
The cast is not safe, because a texture is not a surface. It is a container that contains one or more surfaces(or volumes, in case of a 3D texture).
I also noticed this: if(arg->opcode_token & WINED3DSI_TEXLD_BIAS) { ... + /* what to do here when texrect is enabled? */ shader_addline(arg->buffer, "%s(Psampler%u, %s, %s)%s);\n", }
I'd argue that this should never happen, because D3DSI_TEXLD_BIAS specifies a level of detail bias to use a different mipmap sublevel(see below), which doesn't make much sense with RECT textures since they only have one level anyway. However, it could happen that D3D supports this, and simply ignores the LOD Bias in this case. I think this is a candidate for a test case.
FYI: A 1024x1024 2D texture can for example contain 10 surfaces, which are then usually called mipmap sublevels. The first one has 1024x1024 pixels, the 2nd 512x512, then 256x256 etc. Depending on the level of detail needed when sampling from the texture, different a different mipmap is read. This reduces filtering artifacts because the artist can draw the smaller mipmaps separately and optimize the content for looking well instead of relying on strictly mathematical filtering algorithms. (Ever played an old game where fences, bricks or other recursive patterns start flickering or show other odd effects?)
Don't worry: You don't have to care about mipmaps here. Why?
There are also cube textures. Those essentially 6 2D textures(possibly with mipmaps) arranged in a cubic layout. When sampling from such a texture, you sit in the center of the cube, and a 3D direction vector points to a texel. This is often used for drawing reflections.
If you do need a surface in this code