Commit 342a71b2 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Replace the "stateLookup" tables with a single "wrap_lookup" table.

parent fff8b09f
......@@ -319,29 +319,30 @@ HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surfac
}
/* GL locking is done by the caller */
static inline void apply_wrap(const GLint textureDimensions, const DWORD state, const GLint type,
BOOL cond_np2) {
GLint wrapParm;
static void apply_wrap(GLenum target, WINED3DTEXTUREADDRESS d3d_wrap, GLenum param, BOOL cond_np2)
{
GLint gl_wrap;
if (state < minLookup[WINELOOKUP_WARPPARAM] || state > maxLookup[WINELOOKUP_WARPPARAM]) {
FIXME("Unrecognized or unsupported WINED3DTADDRESS_U value %d\n", state);
} else {
if(textureDimensions==GL_TEXTURE_CUBE_MAP_ARB) {
/* Cubemaps are always set to clamp, regardless of the sampler state. */
wrapParm = GL_CLAMP_TO_EDGE;
} else if(cond_np2) {
if(state == WINED3DTADDRESS_WRAP) {
wrapParm = GL_CLAMP_TO_EDGE;
} else {
wrapParm = stateLookup[WINELOOKUP_WARPPARAM][state - minLookup[WINELOOKUP_WARPPARAM]];
}
} else {
wrapParm = stateLookup[WINELOOKUP_WARPPARAM][state - minLookup[WINELOOKUP_WARPPARAM]];
}
TRACE("Setting WRAP_S to %d for %x\n", wrapParm, textureDimensions);
glTexParameteri(textureDimensions, type, wrapParm);
checkGLcall("glTexParameteri(..., type, wrapParm)");
if (d3d_wrap < WINED3DTADDRESS_WRAP || d3d_wrap > WINED3DTADDRESS_MIRRORONCE)
{
FIXME("Unrecognized or unsupported WINED3DTEXTUREADDRESS %#x.\n", d3d_wrap);
return;
}
if (target == GL_TEXTURE_CUBE_MAP_ARB
|| (cond_np2 && d3d_wrap == WINED3DTADDRESS_WRAP))
{
/* Cubemaps are always set to clamp, regardless of the sampler state. */
gl_wrap = GL_CLAMP_TO_EDGE;
}
else
{
gl_wrap = wrap_lookup[d3d_wrap - WINED3DTADDRESS_WRAP];
}
TRACE("Setting param %#x to %#x for target %#x.\n", param, gl_wrap, target);
glTexParameteri(target, param, gl_wrap);
checkGLcall("glTexParameteri(target, param, gl_wrap)");
}
/* GL locking is done by the caller (state handler) */
......
......@@ -160,18 +160,7 @@ static const struct fragment_pipeline *select_fragment_implementation(struct win
static const shader_backend_t *select_shader_backend(struct wined3d_adapter *adapter, WINED3DDEVTYPE DeviceType);
static const struct blit_shader *select_blit_implementation(struct wined3d_adapter *adapter, WINED3DDEVTYPE DeviceType);
/* lookup tables */
const int minLookup[MAX_LOOKUPS] =
{
WINED3DTADDRESS_WRAP, /* WINELOOKUP_WARPPARAM */
};
const int maxLookup[MAX_LOOKUPS] =
{
WINED3DTADDRESS_MIRRORONCE, /* WINELOOKUP_WARPPARAM */
};
DWORD *stateLookup[MAX_LOOKUPS];
GLint wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP + 1];
const struct min_lookup minMipLookup[] =
{
......@@ -2031,21 +2020,14 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_gl_info *gl_info)
else
gl_info->vidmem = WINE_DEFAULT_VIDMEM;
/* Load all the lookup tables */
for (i = 0; i < MAX_LOOKUPS; i++) {
stateLookup[i] = HeapAlloc(GetProcessHeap(), 0, sizeof(*stateLookup[i]) * (1 + maxLookup[i] - minLookup[i]) );
}
stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_WRAP - minLookup[WINELOOKUP_WARPPARAM]] = GL_REPEAT;
stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_CLAMP - minLookup[WINELOOKUP_WARPPARAM]] = GL_CLAMP_TO_EDGE;
stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_BORDER - minLookup[WINELOOKUP_WARPPARAM]] =
gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_BORDER - minLookup[WINELOOKUP_WARPPARAM]] =
gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_MIRROR - minLookup[WINELOOKUP_WARPPARAM]] =
gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
stateLookup[WINELOOKUP_WARPPARAM][WINED3DTADDRESS_MIRRORONCE - minLookup[WINELOOKUP_WARPPARAM]] =
gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] ? GL_MIRROR_CLAMP_TO_EDGE_ATI : GL_REPEAT;
wrap_lookup[WINED3DTADDRESS_WRAP - WINED3DTADDRESS_WRAP] = GL_REPEAT;
wrap_lookup[WINED3DTADDRESS_MIRROR - WINED3DTADDRESS_WRAP] =
gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] ? GL_MIRRORED_REPEAT_ARB : GL_REPEAT;
wrap_lookup[WINED3DTADDRESS_CLAMP - WINED3DTADDRESS_WRAP] = GL_CLAMP_TO_EDGE;
wrap_lookup[WINED3DTADDRESS_BORDER - WINED3DTADDRESS_WRAP] =
gl_info->supported[ARB_TEXTURE_BORDER_CLAMP] ? GL_CLAMP_TO_BORDER_ARB : GL_REPEAT;
wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP] =
gl_info->supported[ATI_TEXTURE_MIRROR_ONCE] ? GL_MIRROR_CLAMP_TO_EDGE_ATI : GL_REPEAT;
/* Make sure there's an active HDC else the WGL extensions will fail */
hdc = pwglGetCurrentDC();
......
......@@ -148,14 +148,7 @@ void wined3d_rb_free(void *ptr) DECLSPEC_HIDDEN;
#define MAX_ACTIVE_LIGHTS 8
#define MAX_CLIPPLANES WINED3DMAXUSERCLIPPLANES
typedef enum _WINELOOKUP {
WINELOOKUP_WARPPARAM = 0,
MAX_LOOKUPS = 1
} WINELOOKUP;
extern const int minLookup[MAX_LOOKUPS] DECLSPEC_HIDDEN;
extern const int maxLookup[MAX_LOOKUPS] DECLSPEC_HIDDEN;
extern DWORD *stateLookup[MAX_LOOKUPS] DECLSPEC_HIDDEN;
extern GLint wrap_lookup[WINED3DTADDRESS_MIRRORONCE - WINED3DTADDRESS_WRAP + 1] DECLSPEC_HIDDEN;
struct min_lookup
{
......
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