wined3d: Set the pow2 sizes in gl surface private setup.
This commit is contained in:
parent
30724a6ec2
commit
59efd5c7ec
|
@ -575,7 +575,6 @@ If this flag is set, the contents of the depth stencil buffer will be invalid af
|
||||||
static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Width, UINT Height, WINED3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IWineD3DSurface **ppSurface,WINED3DRESOURCETYPE Type, DWORD Usage, WINED3DPOOL Pool, WINED3DMULTISAMPLE_TYPE MultiSample ,DWORD MultisampleQuality, HANDLE* pSharedHandle, WINED3DSURFTYPE Impl, IUnknown *parent) {
|
static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Width, UINT Height, WINED3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IWineD3DSurface **ppSurface,WINED3DRESOURCETYPE Type, DWORD Usage, WINED3DPOOL Pool, WINED3DMULTISAMPLE_TYPE MultiSample ,DWORD MultisampleQuality, HANDLE* pSharedHandle, WINED3DSURFTYPE Impl, IUnknown *parent) {
|
||||||
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
|
||||||
IWineD3DSurfaceImpl *object; /*NOTE: impl ref allowed since this is a create function */
|
IWineD3DSurfaceImpl *object; /*NOTE: impl ref allowed since this is a create function */
|
||||||
unsigned int pow2Width, pow2Height;
|
|
||||||
unsigned int Size = 1;
|
unsigned int Size = 1;
|
||||||
const PixelFormatDesc *tableEntry = getFormatDescEntry(Format);
|
const PixelFormatDesc *tableEntry = getFormatDescEntry(Format);
|
||||||
TRACE("(%p) Create surface\n",This);
|
TRACE("(%p) Create surface\n",This);
|
||||||
|
@ -616,27 +615,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
|
||||||
* by the device.
|
* by the device.
|
||||||
*******************************/
|
*******************************/
|
||||||
|
|
||||||
/* Non-power2 support */
|
|
||||||
if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO)) {
|
|
||||||
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) **/
|
|
||||||
if (Format == WINED3DFMT_DXT1 || Format == WINED3DFMT_DXT2 || Format == WINED3DFMT_DXT3
|
|
||||||
|| Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5) {
|
|
||||||
FIXME("(%p) Compressed non-power-two textures are not supported w(%d) h(%d)\n",
|
|
||||||
This, Width, Height);
|
|
||||||
return WINED3DERR_NOTAVAILABLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** DXTn mipmaps use the same number of 'levels' down to eg. 8x1, but since
|
/** DXTn mipmaps use the same number of 'levels' down to eg. 8x1, but since
|
||||||
* it is based around 4x4 pixel blocks it requires padding, so allocate enough
|
* it is based around 4x4 pixel blocks it requires padding, so allocate enough
|
||||||
* space!
|
* space!
|
||||||
|
@ -675,13 +653,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
|
||||||
object->glDescription.level = Level;
|
object->glDescription.level = Level;
|
||||||
object->glDescription.target = GL_TEXTURE_2D;
|
object->glDescription.target = GL_TEXTURE_2D;
|
||||||
|
|
||||||
/* Internal data */
|
|
||||||
object->pow2Width = pow2Width;
|
|
||||||
object->pow2Height = pow2Height;
|
|
||||||
|
|
||||||
/* Flags */
|
/* Flags */
|
||||||
object->Flags = 0;
|
object->Flags = 0;
|
||||||
object->Flags |= (pow2Width != Width || pow2Height != Height) ? SFLAG_NONPOW2 : 0;
|
|
||||||
object->Flags |= Discard ? SFLAG_DISCARD : 0;
|
object->Flags |= Discard ? SFLAG_DISCARD : 0;
|
||||||
object->Flags |= (WINED3DFMT_D16_LOCKABLE == Format) ? SFLAG_LOCKABLE : 0;
|
object->Flags |= (WINED3DFMT_D16_LOCKABLE == Format) ? SFLAG_LOCKABLE : 0;
|
||||||
object->Flags |= Lockable ? SFLAG_LOCKABLE : 0;
|
object->Flags |= Lockable ? SFLAG_LOCKABLE : 0;
|
||||||
|
|
|
@ -3435,6 +3435,36 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Fla
|
||||||
static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
|
static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
|
||||||
/** Check against the maximum texture sizes supported by the video card **/
|
/** Check against the maximum texture sizes supported by the video card **/
|
||||||
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
|
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
|
||||||
|
unsigned int pow2Width, pow2Height;
|
||||||
|
|
||||||
|
/* Non-power2 support */
|
||||||
|
if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO)) {
|
||||||
|
pow2Width = This->currentDesc.Width;
|
||||||
|
pow2Height = This->currentDesc.Height;
|
||||||
|
} else {
|
||||||
|
/* Find the nearest pow2 match */
|
||||||
|
pow2Width = pow2Height = 1;
|
||||||
|
while (pow2Width < This->currentDesc.Width) pow2Width <<= 1;
|
||||||
|
while (pow2Height < This->currentDesc.Height) pow2Height <<= 1;
|
||||||
|
}
|
||||||
|
This->pow2Width = pow2Width;
|
||||||
|
This->pow2Height = pow2Height;
|
||||||
|
|
||||||
|
if (pow2Width > This->currentDesc.Width || pow2Height > This->currentDesc.Height) {
|
||||||
|
WINED3DFORMAT Format = This->resource.format;
|
||||||
|
/** TODO: add support for non power two compressed textures **/
|
||||||
|
if (Format == WINED3DFMT_DXT1 || Format == WINED3DFMT_DXT2 || Format == WINED3DFMT_DXT3
|
||||||
|
|| Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5) {
|
||||||
|
FIXME("(%p) Compressed non-power-two textures are not supported w(%d) h(%d)\n",
|
||||||
|
This, This->currentDesc.Width, This->currentDesc.Height);
|
||||||
|
return WINED3DERR_NOTAVAILABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pow2Width != This->currentDesc.Width ||
|
||||||
|
pow2Height != This->currentDesc.Height) {
|
||||||
|
This->Flags |= SFLAG_NONPOW2;
|
||||||
|
}
|
||||||
|
|
||||||
TRACE("%p\n", This);
|
TRACE("%p\n", This);
|
||||||
if ((This->pow2Width > GL_LIMITS(texture_size) || This->pow2Height > GL_LIMITS(texture_size)) && !(This->resource.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL))) {
|
if ((This->pow2Width > GL_LIMITS(texture_size) || This->pow2Height > GL_LIMITS(texture_size)) && !(This->resource.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL))) {
|
||||||
|
|
|
@ -1513,7 +1513,6 @@ IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
|
||||||
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
|
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
long oldsize = This->resource.size;
|
|
||||||
|
|
||||||
if(This->resource.usage & WINED3DUSAGE_OVERLAY)
|
if(This->resource.usage & WINED3DUSAGE_OVERLAY)
|
||||||
{
|
{
|
||||||
|
@ -1527,13 +1526,8 @@ IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
|
||||||
This->resource.allocatedMemory = NULL;
|
This->resource.allocatedMemory = NULL;
|
||||||
|
|
||||||
/* We don't mind the nonpow2 stuff in GDI */
|
/* We don't mind the nonpow2 stuff in GDI */
|
||||||
This->resource.size = IWineD3DSurface_GetPitch(iface) * This->currentDesc.Height;
|
|
||||||
This->pow2Width = This->currentDesc.Width;
|
This->pow2Width = This->currentDesc.Width;
|
||||||
This->pow2Height = This->currentDesc.Height;
|
This->pow2Height = This->currentDesc.Height;
|
||||||
This->Flags &= ~SFLAG_NONPOW2;
|
|
||||||
|
|
||||||
/* Adjust the opengl mem counter */
|
|
||||||
globalChangeGlRam(This->resource.size - oldsize);
|
|
||||||
|
|
||||||
/* Call GetDC to create a DIB section. We will use that
|
/* Call GetDC to create a DIB section. We will use that
|
||||||
* DIB section for rendering
|
* DIB section for rendering
|
||||||
|
|
Loading…
Reference in New Issue