Re: wined3d: Set wrapmode for cubemags to clamp regardeless of the sampler state

2007-03-12 Thread H. Verbeet

On 12/03/07, H. Verbeet <[EMAIL PROTECTED]> wrote:

I've written a test for this, I'll send it tomorrow together with some
other patches.


Since this patch doesn't appear to have been applied yet, I can't
submit my test yet. I've attached it to this mail instead.
---

 dlls/d3d9/tests/visual.c |  133 ++
 1 files changed, 133 insertions(+), 0 deletions(-)

diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c
index d1d39b1..ac56cd5 100644
--- a/dlls/d3d9/tests/visual.c
+++ b/dlls/d3d9/tests/visual.c
@@ -412,6 +412,138 @@ static void test_mova(IDirect3DDevice9 *device)
 IDirect3DVertexShader9_Release(mova_shader);
 }
 
+/* This test verifies the behaviour of cube maps wrt. texture wrapping.
+ * D3D cube map wrapping always behaves like GL_CLAMP_TO_EDGE,
+ * regardless of the actual addressing mode set. */
+static void test_cube_wrap(IDirect3DDevice9 *device)
+{
+static const float quad[][6] = {
+{-1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f},
+{-1.0f,  1.0f, 0.0f, 1.0f, 1.0f, 1.0f},
+{ 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f},
+{ 1.0f,  1.0f, 0.0f, 1.0f, 1.0f, 1.0f},
+};
+
+static const D3DVERTEXELEMENT9 decl_elements[] = {
+{0, 0,  D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, 
D3DDECLUSAGE_POSITION, 0},
+{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, 
D3DDECLUSAGE_TEXCOORD, 0},
+D3DDECL_END()
+};
+
+static const struct {
+D3DTEXTUREADDRESS mode;
+const char *name;
+} address_modes[] = {
+{D3DTADDRESS_WRAP, "D3DTADDRESS_WRAP"},
+{D3DTADDRESS_MIRROR, "D3DTADDRESS_MIRROR"},
+{D3DTADDRESS_CLAMP, "D3DTADDRESS_CLAMP"},
+{D3DTADDRESS_BORDER, "D3DTADDRESS_BORDER"},
+{D3DTADDRESS_MIRRORONCE, "D3DTADDRESS_MIRRORONCE"},
+};
+
+IDirect3DVertexDeclaration9 *vertex_declaration = NULL;
+IDirect3DCubeTexture9 *texture = NULL;
+IDirect3DSurface9 *surface = NULL;
+D3DLOCKED_RECT locked_rect;
+HRESULT hr;
+INT x, y, face;
+
+hr = IDirect3DDevice9_CreateVertexDeclaration(device, decl_elements, 
&vertex_declaration);
+ok(SUCCEEDED(hr), "CreateVertexDeclaration failed (0x%08x)\n", hr);
+hr = IDirect3DDevice9_SetVertexDeclaration(device, vertex_declaration);
+ok(SUCCEEDED(hr), "SetVertexDeclaration failed (0x%08x)\n", hr);
+
+hr = IDirect3DDevice9_CreateOffscreenPlainSurface(device, 128, 128,
+D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, NULL);
+ok(SUCCEEDED(hr), "CreateOffscreenPlainSurface failed (0x%08x)\n", hr);
+
+hr = IDirect3DSurface9_LockRect(surface, &locked_rect, NULL, 
D3DLOCK_DISCARD);
+ok(SUCCEEDED(hr), "LockRect failed (0x%08x)\n", hr);
+
+for (y = 0; y < 128; ++y)
+{
+DWORD *ptr = (DWORD *)(((BYTE *)locked_rect.pBits) + (y * 
locked_rect.Pitch));
+for (x = 0; x < 64; ++x)
+{
+*ptr++ = 0x;
+}
+for (x = 64; x < 128; ++x)
+{
+*ptr++ = 0xffff;
+}
+}
+
+hr = IDirect3DSurface9_UnlockRect(surface);
+ok(SUCCEEDED(hr), "UnlockRect failed (0x%08x)\n", hr);
+
+hr = IDirect3DDevice9_CreateCubeTexture(device, 128, 1, 0, D3DFMT_A8R8G8B8,
+D3DPOOL_DEFAULT, &texture, NULL);
+ok(SUCCEEDED(hr), "CreateCubeTexture failed (0x%08x)\n", hr);
+
+/* Create cube faces */
+for (face = 0; face < 6; ++face)
+{
+IDirect3DSurface9 *face_surface = NULL;
+
+hr= IDirect3DCubeTexture9_GetCubeMapSurface(texture, face, 0, 
&face_surface);
+ok(SUCCEEDED(hr), "GetCubeMapSurface failed (0x%08x)\n", hr);
+
+hr = IDirect3DDevice9_UpdateSurface(device, surface, NULL, 
face_surface, NULL);
+ok(SUCCEEDED(hr), "UpdateSurface failed (0x%08x)\n", hr);
+
+IDirect3DSurface9_Release(face_surface);
+}
+
+hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 
*)texture);
+ok(SUCCEEDED(hr), "SetTexture failed (0x%08x)\n", hr);
+
+hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MINFILTER, 
D3DTEXF_LINEAR);
+ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_MINFILTER failed (0x%08x)\n", 
hr);
+hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_MAGFILTER, 
D3DTEXF_LINEAR);
+ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_MAGFILTER failed (0x%08x)\n", 
hr);
+hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_BORDERCOLOR, 
0xff00ff00);
+ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_BORDERCOLOR failed (0x%08x)\n", 
hr);
+
+hr = IDirect3DDevice9_SetRenderState(device, D3DRS_LIGHTING, FALSE);
+ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState returned %s\n", 
DXGetErrorString9(hr));
+
+for (x = 0; x < (sizeof(address_modes) / sizeof(*address_modes)); ++x)
+{
+DWORD color;
+
+hr = IDirect3DDevice9_SetSamplerState(device, 0, D3DSAMP_ADDRESSU, 
address_modes[x].mode);
+ok(SUCCEEDED(hr), "SetSamplerState D3DSAMP_ADDRESSU (%s) failed 
(0x%08x)

Re: wined3d: Set wrapmode for cubemags to clamp regardeless of the sampler state

2007-03-11 Thread H. Verbeet

On 11/03/07, Stefan Dösinger <[EMAIL PROTECTED]> wrote:

But I cannot think of any good way to test this, so I
prefer to wait for an application to show up what can go wrong :-)


I've written a test for this, I'll send it tomorrow together with some
other patches.




Re: wined3d: Set wrapmode for cubemags to clamp regardeless of the sampler state

2007-03-11 Thread Stefan Dösinger
> I adapted a Directx9 HLSL tutorial to display a black cubemap with one
> white line on one edge of one side and visually (by hand or better to say
> by eye) confirmed that the line is not "mirrored" on the opposite edge.
I'd say the patch is fine. Anything else but clamp to edge does not make sense 
for cube maps anyway, considering how the location of the pixel is 
calculated[1]. The only way I can imagine that a texture coordinate gets > 
1.0 or < -1.0 is due to filtering.

So the patch has my blessing to go in, if any regressions occur then we can 
always add a test case. But I cannot think of any good way to test this, so I 
prefer to wait for an application to show up what can go wrong :-)

[1]... 
http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_cube_map.txt


pgpXK2LkwoMrp.pgp
Description: PGP signature



Re: wined3d: Set wrapmode for cubemags to clamp regardeless of the sampler state

2007-03-10 Thread Fabian Bieler

> Am Samstag 10 März 2007 15:02 schrieb Fabian Bieler:
> > This Patch forces GL_CLAMP_TO_EDGE on all cubemaps.
> >
> > I tested this on XP with some Radeon X1???.
> >
> > Also, this fixes some renderissues Half-Life 2.
> Say, does that fix the strange quad boarders like in this screenshot? 
> http://bugs.winehq.org/attachment.cgi?id=5297&action=view (Eve Online). It
> sounds like it would do that, I'm very impressed :-)
I don't have Eve Online, but the screenshot looks like a glitch with the 
flashlight in Half-Life 2 that this patch fixes.
> 
> How did you test that? It sounds like a test case using the visual test 
> framework is worth an investigation. I can try to write a test for that.
I adapted a Directx9 HLSL tutorial to display a black cubemap with one white 
line on one edge of one side and visually (by hand or better to say by eye) 
confirmed that the line is not "mirrored" on the opposite edge.

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer




Re: wined3d: Set wrapmode for cubemags to clamp regardeless of the sampler state

2007-03-10 Thread Stefan Dösinger
Am Samstag 10 März 2007 15:02 schrieb Fabian Bieler:
> This Patch forces GL_CLAMP_TO_EDGE on all cubemaps.
>
> I tested this on XP with some Radeon X1???.
>
> Also, this fixes some renderissues Half-Life 2.
Say, does that fix the strange quad boarders like in this screenshot? 
http://bugs.winehq.org/attachment.cgi?id=5297&action=view (Eve Online). It 
sounds like it would do that, I'm very impressed :-)

How did you test that? It sounds like a test case using the visual test 
framework is worth an investigation. I can try to write a test for that.


pgpNOyFvXlHWa.pgp
Description: PGP signature