Commit 28170f04 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Implement environment bump mapping with GL_ATI_envmap_bumpmap.

parent 99283401
......@@ -1119,6 +1119,16 @@ IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
WINED3DFMT_DXT5,
};
WINED3DFORMAT BumpFormatList[] = {
WINED3DFMT_V8U8,
WINED3DFMT_L6V5U5,
WINED3DFMT_X8L8V8U8,
WINED3DFMT_Q8W8V8U8,
WINED3DFMT_V16U16,
WINED3DFMT_W11V11U10,
WINED3DFMT_A2W10V10U10
};
TRACE("(%p)->(%p,%p): Relay\n", This, Callback, Arg);
if(!Callback)
......@@ -1150,6 +1160,33 @@ IDirect3DDeviceImpl_7_EnumTextureFormats(IDirect3DDevice7 *iface,
}
}
}
for(i = 0; i < sizeof(BumpFormatList) / sizeof(WINED3DFORMAT); i++)
{
hr = IWineD3D_CheckDeviceFormat(This->ddraw->wineD3D,
0 /* Adapter */,
0 /* DeviceType */,
0 /* AdapterFormat */,
WINED3DUSAGE_QUERY_LEGACYBUMPMAP,
0 /* ResourceType */,
BumpFormatList[i]);
if(hr == D3D_OK)
{
DDPIXELFORMAT pformat;
memset(&pformat, 0, sizeof(pformat));
pformat.dwSize = sizeof(pformat);
PixelFormat_WineD3DtoDD(&pformat, BumpFormatList[i]);
TRACE("Enumerating WineD3DFormat %d\n", BumpFormatList[i]);
hr = Callback(&pformat, Arg);
if(hr != DDENUMRET_OK)
{
TRACE("Format enumeration cancelled by application\n");
return D3D_OK;
}
}
}
TRACE("End of enumeration\n");
return D3D_OK;
}
......
......@@ -1679,6 +1679,20 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt
TRACE_(d3d_caps)("[FAILED]\n");
return WINED3DERR_NOTAVAILABLE;
}
} else if(Usage & WINED3DUSAGE_QUERY_LEGACYBUMPMAP) {
if(GL_SUPPORT(ATI_ENVMAP_BUMPMAP)) {
switch (CheckFormat) {
case WINED3DFMT_V8U8:
TRACE_(d3d_caps)("[OK]\n");
return WINED3D_OK;
default:
TRACE_(d3d_caps)("[FAILED]\n");
return WINED3DERR_NOTAVAILABLE;
}
/* TODO: GL_NV_TEXTURE_SHADER */
}
TRACE_(d3d_caps)("[FAILED]\n");
return WINED3DERR_NOTAVAILABLE;
}
if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
......@@ -2209,12 +2223,15 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA;
}
if(GL_SUPPORT(ATI_ENVMAP_BUMPMAP)) {
*pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAP;
} else if(GL_SUPPORT(NV_TEXTURE_SHADER)) {
/* TODO: environment bump mapping support with GL_NV_texture_shader */
}
#if 0
*pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAP;
/* FIXME: Add
WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE
WINED3DTEXOPCAPS_PREMODULATE */
/* FIXME: Add
*pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE
WINED3DTEXOPCAPS_PREMODULATE */
#endif
*pCaps->MaxTextureBlendStages = GL_LIMITS(texture_stages);
......
......@@ -2164,6 +2164,19 @@ static void tex_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
shaderconstant(STATE_PIXELSHADERCONSTANT, stateblock, context);
}
}
if(GL_SUPPORT(ATI_ENVMAP_BUMPMAP)) {
if(stage >= GL_LIMITS(texture_stages)) {
WARN("Bump env matrix of unsupported stage set\n");
} else if(GL_SUPPORT(ARB_MULTITEXTURE)) {
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + stage));
checkGLcall("GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + stage))");
}
GL_EXTCALL(glTexBumpParameterfvATI(GL_BUMP_ROT_MATRIX_ATI,
(float *) &(stateblock->textureState[stage][WINED3DTSS_BUMPENVMAT00])));
checkGLcall("glTexBumpParameterfvATI");
}
/* TODO: GL_NV_texture_shader */
}
static void transform_world(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
......
......@@ -2168,6 +2168,46 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, WINED3DTEXTUREOP
} else
Handled = FALSE;
break;
case WINED3DTOP_BUMPENVMAPLUMINANCE:
if(GL_SUPPORT(ATI_ENVMAP_BUMPMAP)) {
/* Some apps use BUMPENVMAPLUMINANCE instead of D3DTOP_BUMPENVMAP, although
* they check for the non-luminance cap flag. Well, give them what they asked
* for :-)
*/
WARN("Application uses WINED3DTOP_BUMPENVMAPLUMINANCE\n");
} else {
Handled = FALSE;
break;
}
/* Fall through */
case WINED3DTOP_BUMPENVMAP:
if(GL_SUPPORT(ATI_ENVMAP_BUMPMAP)) {
TRACE("Using ati bumpmap on stage %d, target %d\n", Stage, Stage + 1);
glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_BUMP_ENVMAP_ATI);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_BUMP_ENVMAP_ATI)");
glTexEnvi(GL_TEXTURE_ENV, GL_BUMP_TARGET_ATI, GL_TEXTURE0_ARB + Stage + 1);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_BUMP_TARGET_ATI, GL_TEXTURE0_ARB + Stage + 1)");
glTexEnvi(GL_TEXTURE_ENV, src0_target, src3);
checkGLcall("GL_TEXTURE_ENV, src0_target, src3");
glTexEnvi(GL_TEXTURE_ENV, opr0_target, opr3);
checkGLcall("GL_TEXTURE_ENV, opr0_target, opr3");
glTexEnvi(GL_TEXTURE_ENV, src1_target, src1);
checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
glTexEnvi(GL_TEXTURE_ENV, opr1_target, opr1);
checkGLcall("GL_TEXTURE_ENV, opr1_target, opr1");
glTexEnvi(GL_TEXTURE_ENV, src2_target, src2);
checkGLcall("GL_TEXTURE_ENV, src0_target, src1");
glTexEnvi(GL_TEXTURE_ENV, opr2_target, opr2);
checkGLcall("GL_TEXTURE_ENV, opr2_target, opr2");
Handled = TRUE;
} else {
/* If GL_NV_TEXTURE_SHADER is supported insted the GL_NV_register_combiner path
* will be taken instead
*/
Handled = FALSE;
}
break;
default:
Handled = FALSE;
}
......
......@@ -1192,10 +1192,10 @@ typedef void (APIENTRY * PGLFNFINISHOBJECTAPPLEPROC) (GLenum, GLuint);
#define GL_BUMP_ENVMAP_ATI 0x877B
#define GL_BUMP_TARGET_ATI 0x877C
#endif
typedef void (APIENTRY * PGLFNTEXBUMPPARAMETERIVATIPROC) (GLenum, GLuint);
typedef void (APIENTRY * PGLFNTEXBUMPPARAMETERFVATIPROC) (GLenum, GLuint);
typedef void (APIENTRY * PGLFNGETTEXBUMPPARAMETERIVATIPROC) (GLenum, GLuint);
typedef void (APIENTRY * PGLFNGETTEXBUMPPARAMETERFVATIPROC) (GLenum, GLuint);
typedef void (APIENTRY * PGLFNTEXBUMPPARAMETERIVATIPROC) (GLenum, GLint *);
typedef void (APIENTRY * PGLFNTEXBUMPPARAMETERFVATIPROC) (GLenum, GLfloat *);
typedef void (APIENTRY * PGLFNGETTEXBUMPPARAMETERIVATIPROC) (GLenum, GLint *);
typedef void (APIENTRY * PGLFNGETTEXBUMPPARAMETERFVATIPROC) (GLenum, GLfloat *);
/* GL_VERSION_2_0 */
#ifndef GL_VERSION_2_0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment