Commit 193f6bbd authored by H. Verbeet's avatar H. Verbeet Committed by Alexandre Julliard

wined3d: Add support for native NPOT textures.

parent fdefaed4
......@@ -971,11 +971,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
*******************************/
/* Non-power2 support */
/* Find the nearest pow2 match */
pow2Width = pow2Height = 1;
while (pow2Width < Width) pow2Width <<= 1;
while (pow2Height < Height) pow2Height <<= 1;
if (wined3d_settings.nonpower2_mode == NP2_NATIVE) {
pow2Width = Width;
pow2Height = Height;
} else {
/* Find the nearest pow2 match */
pow2Width = pow2Height = 1;
while (pow2Width < Width) pow2Width <<= 1;
while (pow2Height < Height) pow2Height <<= 1;
}
if (pow2Width > Width || pow2Height > Height) {
/** TODO: add support for non power two compressed textures (OpenGL 2 provices support for * non-power-two textures gratis) **/
......@@ -1125,8 +1129,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
UINT tmpW;
UINT tmpH;
HRESULT hr;
unsigned int pow2Width = Width;
unsigned int pow2Height = Height;
unsigned int pow2Width;
unsigned int pow2Height;
TRACE("(%p) : Width %d, Height %d, Levels %d, Usage %#lx\n", This, Width, Height, Levels, Usage);
......@@ -1146,10 +1150,15 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
object->height = Height;
/** Non-power2 support **/
/* Find the nearest pow2 match */
pow2Width = pow2Height = 1;
while (pow2Width < Width) pow2Width <<= 1;
while (pow2Height < Height) pow2Height <<= 1;
if (wined3d_settings.nonpower2_mode == NP2_NATIVE) {
pow2Width = Width;
pow2Height = Height;
} else {
/* Find the nearest pow2 match */
pow2Width = pow2Height = 1;
while (pow2Width < Width) pow2Width <<= 1;
while (pow2Height < Height) pow2Height <<= 1;
}
/** FIXME: add support for real non-power-two if it's provided by the video card **/
/* Precalculated scaling for 'faked' non power of two texture coords */
......
......@@ -590,6 +590,9 @@ BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display) {
} else if (strcmp(ThisExtn, "GL_ARB_texture_mirrored_repeat") == 0) {
TRACE_(d3d_caps)(" FOUND: ARB Texture mirrored repeat support\n");
gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT] = TRUE;
} else if (strcmp(ThisExtn, "GL_ARB_texture_non_power_of_two") == 0) {
TRACE_(d3d_caps)(" FOUND: ARB NPOT texture support\n");
gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] = TRUE;
} else if (strcmp(ThisExtn, "GLX_ARB_multisample") == 0) {
TRACE_(d3d_caps)(" FOUND: ARB multisample support\n");
gl_info->supported[ARB_MULTISAMPLE] = TRUE;
......@@ -765,6 +768,12 @@ BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display) {
gl_info->max_sampler_stages = max(gl_info->max_samplers, gl_info->max_texture_stages);
/* We can only use NP2_NATIVE when the hardware supports it. */
if (wined3d_settings.nonpower2_mode == NP2_NATIVE && !gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]) {
WARN_(d3d_caps)("GL_ARB_texture_non_power_of_two not supported, falling back to NP2_NONE NPOT mode.\n");
wined3d_settings.nonpower2_mode = NP2_NONE;
}
/* Below is a list of Nvidia and ATI GPUs. Both vendors have dozens of different GPUs with roughly the same
* features. In most cases GPUs from a certain family differ in clockspeeds, the amount of video memory and
* in case of the latest videocards in the number of pixel/vertex pipelines.
......
......@@ -42,7 +42,7 @@ wined3d_settings_t wined3d_settings =
FALSE, /* Use of GLSL disabled by default */
SHADER_ARB, /* Use ARB vertex programs, when available */
SHADER_ARB, /* Use ARB fragment programs, when available */
NP2_NONE, /* Box NPOT textures */
NP2_NATIVE, /* Use native NPOT textures, when available */
RTL_AUTO, /* Automatically determine best locking method */
64*1024*1024 /* 64MB texture memory by default */
};
......
......@@ -132,6 +132,7 @@ static WINED3DGLTYPE const glTypeLookup[D3DDECLTYPE_UNUSED] = {
#define NP2_NONE 0
#define NP2_REPACK 1
#define NP2_NATIVE 2
#define SHADER_SW 0
#define SHADER_ARB 1
......
......@@ -1424,6 +1424,7 @@ typedef enum _GL_SupportedExt {
ARB_HALF_FLOAT_PIXEL,
ARB_TEXTURE_BORDER_CLAMP,
ARB_TEXTURE_MIRRORED_REPEAT,
ARB_TEXTURE_NON_POWER_OF_TWO,
ARB_VERTEX_PROGRAM,
ARB_VERTEX_BLEND,
ARB_VERTEX_BUFFER_OBJECT,
......
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