wined3d: Fake GL_ARB_multitexture.

This commit is contained in:
Stefan Dösinger 2008-12-16 13:18:49 +01:00 committed by Alexandre Julliard
parent b5081dacc0
commit 199a3468bf
10 changed files with 256 additions and 163 deletions

View File

@ -17,6 +17,7 @@ C_SRCS = \
device.c \ device.c \
directx.c \ directx.c \
drawprim.c \ drawprim.c \
gl_compat.c \
glsl_shader.c \ glsl_shader.c \
indexbuffer.c \ indexbuffer.c \
nvidia_texture_shader.c \ nvidia_texture_shader.c \

View File

@ -1066,42 +1066,40 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
/* Disable all textures. The caller can then bind a texture it wants to blit /* Disable all textures. The caller can then bind a texture it wants to blit
* from * from
*
* The blitting code uses (for now) the fixed function pipeline, so make sure to reset all fixed
* function texture unit. No need to care for higher samplers
*/ */
if (GL_SUPPORT(ARB_MULTITEXTURE)) { for(i = GL_LIMITS(textures) - 1; i > 0 ; i--) {
/* The blitting code uses (for now) the fixed function pipeline, so make sure to reset all fixed sampler = This->rev_tex_unit_map[i];
* function texture unit. No need to care for higher samplers GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
*/
for(i = GL_LIMITS(textures) - 1; i > 0 ; i--) {
sampler = This->rev_tex_unit_map[i];
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
checkGLcall("glActiveTextureARB");
if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
checkGLcall("glDisable GL_TEXTURE_CUBE_MAP_ARB");
}
glDisable(GL_TEXTURE_3D);
checkGLcall("glDisable GL_TEXTURE_3D");
if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) {
glDisable(GL_TEXTURE_RECTANGLE_ARB);
checkGLcall("glDisable GL_TEXTURE_RECTANGLE_ARB");
}
glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable GL_TEXTURE_2D");
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);");
if (sampler != -1) {
if (sampler < MAX_TEXTURES) {
Context_MarkStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP), StateTable);
}
Context_MarkStateDirty(context, STATE_SAMPLER(sampler), StateTable);
}
}
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
checkGLcall("glActiveTextureARB"); checkGLcall("glActiveTextureARB");
if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
checkGLcall("glDisable GL_TEXTURE_CUBE_MAP_ARB");
}
glDisable(GL_TEXTURE_3D);
checkGLcall("glDisable GL_TEXTURE_3D");
if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) {
glDisable(GL_TEXTURE_RECTANGLE_ARB);
checkGLcall("glDisable GL_TEXTURE_RECTANGLE_ARB");
}
glDisable(GL_TEXTURE_2D);
checkGLcall("glDisable GL_TEXTURE_2D");
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);");
if (sampler != -1) {
if (sampler < MAX_TEXTURES) {
Context_MarkStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP), StateTable);
}
Context_MarkStateDirty(context, STATE_SAMPLER(sampler), StateTable);
}
} }
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
checkGLcall("glActiveTextureARB");
sampler = This->rev_tex_unit_map[0]; sampler = This->rev_tex_unit_map[0];

View File

@ -2033,12 +2033,8 @@ static void create_dummy_textures(IWineD3DDeviceImpl *This) {
GLubyte white = 255; GLubyte white = 255;
/* Make appropriate texture active */ /* Make appropriate texture active */
if (GL_SUPPORT(ARB_MULTITEXTURE)) { GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i)); checkGLcall("glActiveTextureARB");
checkGLcall("glActiveTextureARB");
} else if (i > 0) {
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
}
/* Generate an opengl texture name */ /* Generate an opengl texture name */
glGenTextures(1, &This->dummyTextureName[i]); glGenTextures(1, &This->dummyTextureName[i]);
@ -5891,12 +5887,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD); ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
if (GL_SUPPORT(ARB_MULTITEXTURE)) { ENTER_GL();
ENTER_GL(); GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB)); checkGLcall("glActiveTextureARB");
checkGLcall("glActiveTextureARB"); LEAVE_GL();
LEAVE_GL();
}
/* Make sure the surface is loaded and up to date */ /* Make sure the surface is loaded and up to date */
IWineD3DSurface_PreLoad(pDestinationSurface); IWineD3DSurface_PreLoad(pDestinationSurface);
@ -6766,10 +6760,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i
} }
/* Make sure that a proper texture unit is selected */ /* Make sure that a proper texture unit is selected */
if (GL_SUPPORT(ARB_MULTITEXTURE)) { GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB));
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB)); checkGLcall("glActiveTextureARB");
checkGLcall("glActiveTextureARB");
}
sampler = This->rev_tex_unit_map[0]; sampler = This->rev_tex_unit_map[0];
if (sampler != -1) { if (sampler != -1) {
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(sampler)); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(sampler));

View File

@ -187,7 +187,6 @@ glAttribFunc diffuse_funcs[WINED3DDECLTYPE_UNUSED];
glAttribFunc specular_funcs[WINED3DDECLTYPE_UNUSED]; glAttribFunc specular_funcs[WINED3DDECLTYPE_UNUSED];
glAttribFunc normal_funcs[WINED3DDECLTYPE_UNUSED]; glAttribFunc normal_funcs[WINED3DDECLTYPE_UNUSED];
glMultiTexCoordFunc multi_texcoord_funcs[WINED3DDECLTYPE_UNUSED]; glMultiTexCoordFunc multi_texcoord_funcs[WINED3DDECLTYPE_UNUSED];
glAttribFunc texcoord_funcs[WINED3DDECLTYPE_UNUSED];
/** /**
* Note: GL seems to trap if GetDeviceCaps is called before any HWND's created, * Note: GL seems to trap if GetDeviceCaps is called before any HWND's created,
@ -4154,30 +4153,6 @@ static void fillGLAttribFuncs(const WineD3D_GL_Info *gl_info)
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_texcoord_func; multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_texcoord_func;
} }
texcoord_funcs[WINED3DDECLTYPE_FLOAT1] = (glAttribFunc)glTexCoord1fv;
texcoord_funcs[WINED3DDECLTYPE_FLOAT2] = (glAttribFunc)glTexCoord2fv;
texcoord_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)glTexCoord3fv;
texcoord_funcs[WINED3DDECLTYPE_FLOAT4] = (glAttribFunc)glTexCoord4fv;
texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_SHORT2] = (glAttribFunc)glTexCoord2sv;
texcoord_funcs[WINED3DDECLTYPE_SHORT4] = (glAttribFunc)glTexCoord4sv;
texcoord_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
if (GL_SUPPORT(NV_HALF_FLOAT))
{
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (glAttribFunc)GL_EXTCALL(glTexCoord2hvNV);
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (glAttribFunc)GL_EXTCALL(glTexCoord4hvNV);
} else {
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
}
} }
#define PUSH1(att) attribs[nAttribs++] = (att); #define PUSH1(att) attribs[nAttribs++] = (att);
@ -4375,6 +4350,7 @@ BOOL InitAdapters(void) {
} }
fixup_extensions(&Adapters[0].gl_info); fixup_extensions(&Adapters[0].gl_info);
add_gl_compat_wrappers(&Adapters[0].gl_info);
WineD3D_ReleaseFakeGLContext(); WineD3D_ReleaseFakeGLContext();

View File

@ -440,21 +440,15 @@ static void drawStridedSlow(IWineD3DDevice *iface, const WineDirect3DVertexStrid
{ {
int coord_idx; int coord_idx;
const void *ptr; const void *ptr;
int texture_idx;
if (!(tmp_tex_mask & 1)) continue; if (!(tmp_tex_mask & 1)) continue;
coord_idx = This->stateBlock->textureState[texture][WINED3DTSS_TEXCOORDINDEX]; coord_idx = This->stateBlock->textureState[texture][WINED3DTSS_TEXCOORDINDEX];
ptr = texCoords[coord_idx] + (SkipnStrides * sd->u.s.texCoords[coord_idx].dwStride); ptr = texCoords[coord_idx] + (SkipnStrides * sd->u.s.texCoords[coord_idx].dwStride);
if (GL_SUPPORT(ARB_MULTITEXTURE)) texture_idx = This->texUnitMap[texture];
{ multi_texcoord_funcs[sd->u.s.texCoords[coord_idx].dwType](GL_TEXTURE0_ARB + texture_idx, ptr);
int texture_idx = This->texUnitMap[texture];
multi_texcoord_funcs[sd->u.s.texCoords[coord_idx].dwType](GL_TEXTURE0_ARB + texture_idx, ptr);
}
else
{
texcoord_funcs[sd->u.s.texCoords[coord_idx].dwType](ptr);
}
} }
/* Diffuse -------------------------------- */ /* Diffuse -------------------------------- */

181
dlls/wined3d/gl_compat.c Normal file
View File

@ -0,0 +1,181 @@
/*
* Compatibility functions for older GL implementations
*
* Copyright 2008 Stefan Dösinger for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdio.h>
#ifdef HAVE_FLOAT_H
# include <float.h>
#endif
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(gl_compat);
static void WINE_GLAPI wine_glMultiTexCoord1fARB(GLenum target, GLfloat s) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord1f(s);
}
static void WINE_GLAPI wine_glMultiTexCoord1fvARB(GLenum target, const GLfloat *v) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord1fv(v);
}
static void WINE_GLAPI wine_glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord2f(s, t);
}
static void WINE_GLAPI wine_glMultiTexCoord2fvARB(GLenum target, const GLfloat *v) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord2fv(v);
}
static void WINE_GLAPI wine_glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord3f(s, t, r);
}
static void WINE_GLAPI wine_glMultiTexCoord3fvARB(GLenum target, const GLfloat *v) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord3fv(v);
}
static void WINE_GLAPI wine_glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord4f(s, t, r, q);
}
static void WINE_GLAPI wine_glMultiTexCoord4fvARB(GLenum target, const GLfloat *v) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord4fv(v);
}
static void WINE_GLAPI wine_glMultiTexCoord2svARB(GLenum target, const const GLshort *v) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord2sv(v);
}
static void WINE_GLAPI wine_glMultiTexCoord4svARB(GLenum target, const const GLshort *v) {
if(target != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
glTexCoord4sv(v);
}
static void WINE_GLAPI wine_glActiveTextureARB(GLenum texture) {
if(texture != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
}
static void WINE_GLAPI wine_glClientActiveTextureARB(GLenum texture) {
if(texture != GL_TEXTURE0) {
ERR("Texture unit > 0 used, but GL_ARB_multitexture is not supported\n");
return;
}
}
static void (WINE_GLAPI *old_multitex_glGetIntegerv) (GLenum pname, GLint* params) = NULL;
static void WINE_GLAPI wine_glGetIntegerv(GLenum pname, GLint* params) {
switch(pname) {
case GL_ACTIVE_TEXTURE: *params = 0; break;
case GL_MAX_TEXTURE_UNITS_ARB: *params = 1; break;
default: old_multitex_glGetIntegerv(pname, params);
}
}
static void (WINE_GLAPI *old_multitex_glGetFloatv) (GLenum pname, GLfloat* params) = NULL;
static void WINE_GLAPI wine_glGetFloatv(GLenum pname, GLfloat* params) {
if(pname == GL_ACTIVE_TEXTURE) *params = 0.0;
else old_multitex_glGetFloatv(pname, params);
}
static void (WINE_GLAPI *old_multitex_glGetDoublev) (GLenum pname, GLdouble* params) = NULL;
static void WINE_GLAPI wine_glGetDoublev(GLenum pname, GLdouble* params) {
if(pname == GL_ACTIVE_TEXTURE) *params = 0.0;
else old_multitex_glGetDoublev(pname, params);
}
#define GLINFO_LOCATION (*gl_info)
void add_gl_compat_wrappers(WineD3D_GL_Info *gl_info) {
if(!GL_SUPPORT(ARB_MULTITEXTURE)) {
gl_info->glActiveTextureARB = wine_glActiveTextureARB;
gl_info->glClientActiveTextureARB = wine_glClientActiveTextureARB;
gl_info->glMultiTexCoord1fARB = wine_glMultiTexCoord1fARB;
gl_info->glMultiTexCoord1fvARB = wine_glMultiTexCoord1fvARB;
gl_info->glMultiTexCoord2fARB = wine_glMultiTexCoord2fARB;
gl_info->glMultiTexCoord2fvARB = wine_glMultiTexCoord2fvARB;
gl_info->glMultiTexCoord3fARB = wine_glMultiTexCoord3fARB;
gl_info->glMultiTexCoord3fvARB = wine_glMultiTexCoord3fvARB;
gl_info->glMultiTexCoord4fARB = wine_glMultiTexCoord4fARB;
gl_info->glMultiTexCoord4fvARB = wine_glMultiTexCoord4fvARB;
gl_info->glMultiTexCoord2svARB = wine_glMultiTexCoord2svARB;
gl_info->glMultiTexCoord4svARB = wine_glMultiTexCoord4svARB;
if(old_multitex_glGetIntegerv) {
FIXME("GL_ARB_multitexture glGetIntegerv hook already applied\n");
} else {
old_multitex_glGetIntegerv = glGetIntegerv;
glGetIntegerv = wine_glGetIntegerv;
}
if(old_multitex_glGetFloatv) {
FIXME("GL_ARB_multitexture glGetGloatv hook already applied\n");
} else {
old_multitex_glGetFloatv = glGetFloatv;
glGetFloatv = wine_glGetFloatv;
}
if(old_multitex_glGetDoublev) {
FIXME("GL_ARB_multitexture glGetDoublev hook already applied\n");
} else {
old_multitex_glGetDoublev = glGetDoublev;
glGetDoublev = wine_glGetDoublev;
}
gl_info->supported[ARB_MULTITEXTURE] = TRUE;
}
}
#undef GLINFO_LOCATION

View File

@ -463,17 +463,12 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3
if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage); if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage);
if (mapped_stage != -1) { if (mapped_stage != -1) {
if (GL_SUPPORT(ARB_MULTITEXTURE)) { if (tex_used && mapped_stage >= GL_LIMITS(textures)) {
if (tex_used && mapped_stage >= GL_LIMITS(textures)) { FIXME("Attempt to enable unsupported stage!\n");
FIXME("Attempt to enable unsupported stage!\n");
return;
}
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
} else if (stage > 0) {
WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
return; return;
} }
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
} }
if(stateblock->lowest_disabled_stage > 0) { if(stateblock->lowest_disabled_stage > 0) {

View File

@ -752,14 +752,10 @@ static void state_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, Win
/* And now the default texture color as well */ /* And now the default texture color as well */
for (i = 0; i < GL_LIMITS(texture_stages); i++) { for (i = 0; i < GL_LIMITS(texture_stages); i++) {
/* Note the WINED3DRS value applies to all textures, but GL has one /* Note the WINED3DRS value applies to all textures, but GL has one
* per texture, so apply it now ready to be used! * per texture, so apply it now ready to be used!
*/ */
if (GL_SUPPORT(ARB_MULTITEXTURE)) { GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i));
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i)); checkGLcall("glActiveTextureARB");
checkGLcall("glActiveTextureARB");
} else if (i>0) {
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
}
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, &col[0]);
checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);"); checkGLcall("glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);");
@ -2923,17 +2919,12 @@ static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage); if (stage != mapped_stage) WARN("Using non 1:1 mapping: %d -> %d!\n", stage, mapped_stage);
if (mapped_stage != -1) { if (mapped_stage != -1) {
if (GL_SUPPORT(ARB_MULTITEXTURE)) { if (tex_used && mapped_stage >= GL_LIMITS(textures)) {
if (tex_used && mapped_stage >= GL_LIMITS(textures)) { FIXME("Attempt to enable unsupported stage!\n");
FIXME("Attempt to enable unsupported stage!\n");
return;
}
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
} else if (stage > 0) {
WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
return; return;
} }
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
} }
if(stage >= stateblock->lowest_disabled_stage) { if(stage >= stateblock->lowest_disabled_stage) {
@ -2980,18 +2971,12 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext
TRACE("Setting alpha op for stage %d\n", stage); TRACE("Setting alpha op for stage %d\n", stage);
/* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */ /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */
if (mapped_stage != -1) { if (mapped_stage != -1) {
if (GL_SUPPORT(ARB_MULTITEXTURE)) { if (tex_used && mapped_stage >= GL_LIMITS(textures)) {
if (tex_used && mapped_stage >= GL_LIMITS(textures)) { FIXME("Attempt to enable unsupported stage!\n");
FIXME("Attempt to enable unsupported stage!\n");
return;
}
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
} else if (stage > 0) {
/* We can't do anything here */
WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
return; return;
} }
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
} }
op = stateblock->textureState[stage][WINED3DTSS_ALPHAOP]; op = stateblock->textureState[stage][WINED3DTSS_ALPHAOP];
@ -3091,17 +3076,11 @@ static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, W
if (mapped_stage == -1) return; if (mapped_stage == -1) return;
if (GL_SUPPORT(ARB_MULTITEXTURE)) { if(mapped_stage >= GL_LIMITS(textures)) {
if(mapped_stage >= GL_LIMITS(textures)) {
return;
}
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
} else if (mapped_stage > 0) {
/* We can't do anything here */
WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
return; return;
} }
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
generated = (stateblock->textureState[texUnit][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) != WINED3DTSS_TCI_PASSTHRU; generated = (stateblock->textureState[texUnit][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) != WINED3DTSS_TCI_PASSTHRU;
coordIdx = min(stateblock->textureState[texUnit][WINED3DTSS_TEXCOORDINDEX & 0x0000FFFF], MAX_TEXTURES - 1); coordIdx = min(stateblock->textureState[texUnit][WINED3DTSS_TEXCOORDINDEX & 0x0000FFFF], MAX_TEXTURES - 1);
@ -3139,13 +3118,6 @@ static void loadTexCoords(IWineD3DStateBlockImpl *stateblock, const WineDirect3D
unsigned int mapped_stage = 0; unsigned int mapped_stage = 0;
unsigned int textureNo = 0; unsigned int textureNo = 0;
/* The code below uses glClientActiveTexture and glMultiTexCoord* which are all part of the GL_ARB_multitexture extension. */
/* Abort if we don't support the extension. */
if (!GL_SUPPORT(ARB_MULTITEXTURE)) {
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
return;
}
for (textureNo = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) { for (textureNo = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
int coordIdx = stateblock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX]; int coordIdx = stateblock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
@ -3199,17 +3171,11 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
return; return;
} }
if (GL_SUPPORT(ARB_MULTITEXTURE)) { if(mapped_stage >= GL_LIMITS(fragment_samplers)) {
if(mapped_stage >= GL_LIMITS(fragment_samplers)) {
return;
}
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
} else if (stage > 0) {
/* We can't do anything here */
WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
return; return;
} }
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
/* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive /* Values 0-7 are indexes into the FVF tex coords - See comments in DrawPrimitive
* *
@ -3443,17 +3409,11 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont
return; return;
} }
if (GL_SUPPORT(ARB_MULTITEXTURE)) { if (mapped_stage >= GL_LIMITS(combined_samplers)) {
if (mapped_stage >= GL_LIMITS(combined_samplers)) {
return;
}
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
} else if (sampler > 0) {
/* We can't do anything here */
WARN("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
return; return;
} }
GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage));
checkGLcall("glActiveTextureARB");
if(stateblock->textures[sampler]) { if(stateblock->textures[sampler]) {
IWineD3DBaseTexture_PreLoad(stateblock->textures[sampler]); IWineD3DBaseTexture_PreLoad(stateblock->textures[sampler]);

View File

@ -99,15 +99,11 @@ static void surface_bind_and_dirtify(IWineD3DSurfaceImpl *This) {
* *
* TODO: Track the current active texture per GL context instead of using glGet * TODO: Track the current active texture per GL context instead of using glGet
*/ */
if (GL_SUPPORT(ARB_MULTITEXTURE)) { GLint active_texture;
GLint active_texture; ENTER_GL();
ENTER_GL(); glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); LEAVE_GL();
LEAVE_GL(); active_sampler = This->resource.wineD3DDevice->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
active_sampler = This->resource.wineD3DDevice->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
} else {
active_sampler = 0;
}
if (active_sampler != -1) { if (active_sampler != -1) {
IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(active_sampler)); IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(active_sampler));

View File

@ -637,7 +637,6 @@ extern glAttribFunc diffuse_funcs[WINED3DDECLTYPE_UNUSED];
extern glAttribFunc specular_funcs[WINED3DDECLTYPE_UNUSED]; extern glAttribFunc specular_funcs[WINED3DDECLTYPE_UNUSED];
extern glAttribFunc normal_funcs[WINED3DDECLTYPE_UNUSED]; extern glAttribFunc normal_funcs[WINED3DDECLTYPE_UNUSED];
extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3DDECLTYPE_UNUSED]; extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3DDECLTYPE_UNUSED];
extern glAttribFunc texcoord_funcs[WINED3DDECLTYPE_UNUSED];
#define eps 1e-8 #define eps 1e-8
@ -889,6 +888,7 @@ struct WineD3DAdapter
extern BOOL InitAdapters(void); extern BOOL InitAdapters(void);
extern BOOL initPixelFormats(WineD3D_GL_Info *gl_info); extern BOOL initPixelFormats(WineD3D_GL_Info *gl_info);
extern long WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *D3DDevice, long glram); extern long WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *D3DDevice, long glram);
extern void add_gl_compat_wrappers(WineD3D_GL_Info *gl_info);
/***************************************************************************** /*****************************************************************************
* High order patch management * High order patch management