wined3d: Implement D3DFMT_G16R16.

This commit is contained in:
Stefan Dösinger 2007-12-15 23:47:10 +01:00 committed by Alexandre Julliard
parent 70868dfa61
commit df77e28854
5 changed files with 109 additions and 3 deletions

View File

@ -2054,6 +2054,78 @@ out:
IDirect3D9_Release(d3d);
}
static void g16r16_texture_test(IDirect3DDevice9 *device)
{
IDirect3D9 *d3d = NULL;
HRESULT hr;
IDirect3DTexture9 *texture = NULL;
D3DLOCKED_RECT lr;
DWORD *data;
DWORD color, red, green, blue;
float quad[] = {
-1.0, -1.0, 0.1, 0.0, 0.0,
-1.0, 1.0, 0.1, 0.0, 1.0,
1.0, -1.0, 0.1, 1.0, 0.0,
1.0, 1.0, 0.1, 1.0, 1.0,
};
memset(&lr, 0, sizeof(lr));
IDirect3DDevice9_GetDirect3D(device, &d3d);
if(IDirect3D9_CheckDeviceFormat(d3d, 0, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0,
D3DRTYPE_TEXTURE, D3DFMT_G16R16) != D3D_OK) {
skip("D3DFMT_G16R16 textures not supported\n");
goto out;
}
hr = IDirect3DDevice9_CreateTexture(device, 1, 1, 1, 0, D3DFMT_G16R16,
D3DPOOL_MANAGED, &texture, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_CreateTexture failed with %s\n", DXGetErrorString9(hr));
if(!texture) {
skip("Failed to create D3DFMT_G16R16 texture\n");
goto out;
}
hr = IDirect3DTexture9_LockRect(texture, 0, &lr, NULL, 0);
ok(hr == D3D_OK, "IDirect3DTexture9_LockRect failed with %s\n", DXGetErrorString9(hr));
data = lr.pBits;
*data = 0x0f00f000;
hr = IDirect3DTexture9_UnlockRect(texture, 0);
ok(hr == D3D_OK, "IDirect3DTexture9_UnlockRect failed with %s\n", DXGetErrorString9(hr));
hr = IDirect3DDevice9_SetTexture(device, 0, (IDirect3DBaseTexture9 *) texture);
ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed with %s\n", DXGetErrorString9(hr));
hr = IDirect3DDevice9_BeginScene(device);
ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed with %s\n", DXGetErrorString9(hr));
if(SUCCEEDED(hr))
{
hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_TEX1);
ok(hr == D3D_OK, "IDirect3DDevice9_SetFVF failed with %s\n", DXGetErrorString9(hr));
hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, 5 * sizeof(float));
ok(SUCCEEDED(hr), "DrawPrimitiveUP failed (%08x)\n", hr);
hr = IDirect3DDevice9_EndScene(device);
ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed with %s\n", DXGetErrorString9(hr));
}
hr = IDirect3DDevice9_SetTexture(device, 0, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_SetTexture failed with %s\n", DXGetErrorString9(hr));
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL);
ok(hr == D3D_OK, "IDirect3DDevice9_Present failed with %s\n", DXGetErrorString9(hr));
color = getPixelColor(device, 240, 320);
red = (color & 0x00ff0000) >> 16;
green = (color & 0x0000ff00) >> 8;
blue = (color & 0x000000ff) >> 0;
ok(blue == 0xff && red >= 0xef && red <= 0xf1 && green >= 0x0e && green <= 0x10,
"D3DFMT_G16R16 with value 0x00ffff00 has color %08x, expected 0x00F00FFF\n", color);
out:
if(texture) IDirect3DTexture9_Release(texture);
IDirect3D9_Release(d3d);
}
static void texture_transform_flags_test(IDirect3DDevice9 *device)
{
HRESULT hr;
@ -5442,6 +5514,7 @@ START_TEST(visual)
alpha_test(device_ptr);
release_buffer_test(device_ptr);
float_texture_test(device_ptr);
g16r16_texture_test(device_ptr);
texture_transform_flags_test(device_ptr);
autogen_mipmap_test(device_ptr);

View File

@ -1746,6 +1746,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
case WINED3DFMT_R16F:
case WINED3DFMT_X8L8V8U8:
case WINED3DFMT_L6V5U5:
case WINED3DFMT_G16R16:
TRACE_(d3d_caps)("[FAILED] - No converted formats on volumes\n");
return WINED3DERR_NOTAVAILABLE;
@ -1842,6 +1843,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
case WINED3DFMT_A8B8G8R8:
case WINED3DFMT_X8B8G8R8:
case WINED3DFMT_P8:
case WINED3DFMT_G16R16:
TRACE_(d3d_caps)("[OK]\n");
return WINED3D_OK;
case WINED3DFMT_R16F:
@ -1973,6 +1975,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
case WINED3DFMT_X8B8G8R8:
case WINED3DFMT_A2R10G10B10:
case WINED3DFMT_A2B10G10R10:
case WINED3DFMT_G16R16:
TRACE_(d3d_caps)("[OK]\n");
return WINED3D_OK;
@ -2045,7 +2048,6 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
return WINED3DERR_NOTAVAILABLE;
/* Not supported */
case WINED3DFMT_G16R16:
case WINED3DFMT_A16B16G16R16:
case WINED3DFMT_A8R3G3B2:
TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */

View File

@ -1567,6 +1567,14 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
*target_bpp = 6;
break;
case WINED3DFMT_G16R16:
*convert = CONVERT_G16R16;
*format = GL_RGB;
*internal = GL_RGB16_EXT;
*type = GL_UNSIGNED_SHORT;
*target_bpp = 6;
break;
default:
break;
}
@ -1883,6 +1891,28 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
}
break;
}
case CONVERT_G16R16:
{
unsigned int x, y;
WORD *Source;
WORD *Dest;
for(y = 0; y < height; y++) {
Source = (WORD *) (src + y * pitch);
Dest = (WORD *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) {
WORD green = (*Source++);
WORD red = (*Source++);
Dest[0] = green;
Dest[1] = red;
Dest[2] = 0xffff;
Dest += 3;
}
}
break;
}
default:
ERR("Unsupported conversation type %d\n", convert);
}

View File

@ -165,7 +165,7 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = {
{WINED3DFMT_A2B10G10R10 ,GL_RGBA ,GL_RGBA , 0, GL_RGBA ,GL_UNSIGNED_INT_2_10_10_10_REV },
{WINED3DFMT_A8B8G8R8 ,GL_RGBA8 ,GL_RGBA8 , 0, GL_RGBA ,GL_UNSIGNED_INT_8_8_8_8_REV },
{WINED3DFMT_X8B8G8R8 ,GL_RGB8 ,GL_RGB8 , 0, GL_RGBA ,GL_UNSIGNED_INT_8_8_8_8_REV },
{WINED3DFMT_G16R16 ,0 ,0 , 0, 0 ,0 },
{WINED3DFMT_G16R16 ,GL_RGB16_EXT ,GL_RGB16_EXT , 0, GL_RGB ,GL_UNSIGNED_SHORT },
{WINED3DFMT_A2R10G10B10 ,GL_RGBA ,GL_RGBA , 0, GL_BGRA ,GL_UNSIGNED_INT_2_10_10_10_REV },
{WINED3DFMT_A16B16G16R16 ,GL_RGBA16_EXT ,GL_RGBA16_EXT , 0, GL_RGBA ,GL_UNSIGNED_SHORT },
/* Luminance */

View File

@ -1238,7 +1238,8 @@ typedef enum {
CONVERT_V16U16,
CONVERT_A4L4,
CONVERT_R32F,
CONVERT_R16F
CONVERT_R16F,
CONVERT_G16R16,
} CONVERT_TYPES;
HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format, GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode);