wined3d: Get rid of some calls to getFormatDescEntry().

Use the format description stored in the resource instead.
This commit is contained in:
Henri Verbeet 2009-03-12 09:53:15 +01:00 committed by Alexandre Julliard
parent 38178541b0
commit 1dcf222ab2
4 changed files with 17 additions and 30 deletions

View File

@ -911,8 +911,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface,
HRESULT hr;
unsigned int pow2Width;
unsigned int pow2Height;
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
TRACE("(%p) : Width %d, Height %d, Levels %d, Usage %#x\n", This, Width, Height, Levels, Usage);
TRACE("Format %#x (%s), Pool %#x, ppTexture %p, pSharedHandle %p, parent %p\n",
@ -1000,7 +998,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface,
object->width = Width;
object->height = Height;
if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) {
if (object->resource.format_desc->Flags & WINED3DFMT_FLAG_FILTERING)
{
object->baseTexture.minMipLookup = minMipLookup;
object->baseTexture.magLookup = magLookup;
} else {
@ -1068,7 +1067,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface,
tmpW = max(1, tmpW >> 1);
tmpH = max(1, tmpH >> 1);
}
object->baseTexture.shader_color_fixup = glDesc->color_fixup;
object->baseTexture.shader_color_fixup = object->resource.format_desc->color_fixup;
object->baseTexture.internal_preload = texture_internal_preload;
TRACE("(%p) : Created texture %p\n", This, object);
@ -1085,11 +1084,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa
UINT tmpW;
UINT tmpH;
UINT tmpD;
const struct GlPixelFormatDesc *glDesc;
HRESULT hr;
getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
/* TODO: It should only be possible to create textures for formats
that are reported as supported */
if (WINED3DFMT_UNKNOWN >= Format) {
@ -1157,7 +1153,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa
object->baseTexture.pow2Matrix[10] = 1.0;
object->baseTexture.pow2Matrix[15] = 1.0;
if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) {
if (object->resource.format_desc->Flags & WINED3DFMT_FLAG_FILTERING)
{
object->baseTexture.minMipLookup = minMipLookup;
object->baseTexture.magLookup = magLookup;
} else {
@ -1191,7 +1188,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa
tmpH = max(1, tmpH >> 1);
tmpD = max(1, tmpD >> 1);
}
object->baseTexture.shader_color_fixup = glDesc->color_fixup;
object->baseTexture.shader_color_fixup = object->resource.format_desc->color_fixup;
object->baseTexture.internal_preload = volumetexture_internal_preload;
*ppVolumeTexture = (IWineD3DVolumeTexture *) object;
@ -1270,8 +1267,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
UINT tmpW;
HRESULT hr;
unsigned int pow2EdgeLength;
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
/* TODO: It should only be possible to create textures for formats
that are reported as supported */
@ -1352,7 +1347,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
object->baseTexture.pow2Matrix[15] = 1.0;
}
if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) {
if (object->resource.format_desc->Flags & WINED3DFMT_FLAG_FILTERING)
{
object->baseTexture.minMipLookup = minMipLookup;
object->baseTexture.magLookup = magLookup;
} else {
@ -1390,7 +1386,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
}
tmpW = max(1, tmpW >> 1);
}
object->baseTexture.shader_color_fixup = glDesc->color_fixup;
object->baseTexture.shader_color_fixup = object->resource.format_desc->color_fixup;
object->baseTexture.internal_preload = cubetexture_internal_preload;
TRACE("(%p) : Created Cube Texture %p\n", This, object);
@ -5806,7 +5802,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetFrontBufferData(IWineD3DDevice *if
static HRESULT WINAPI IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface, DWORD* pNumPasses) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DBaseTextureImpl *texture;
const struct GlPixelFormatDesc *gl_info;
DWORD i;
TRACE("(%p) : %p\n", This, pNumPasses);
@ -5822,9 +5817,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface,
}
texture = (IWineD3DBaseTextureImpl *) This->stateBlock->textures[i];
if(!texture) continue;
getFormatDescEntry(texture->resource.format, &GLINFO_LOCATION, &gl_info);
if(gl_info->Flags & WINED3DFMT_FLAG_FILTERING) continue;
if (!texture || texture->resource.format_desc->Flags & WINED3DFMT_FLAG_FILTERING) continue;
if(This->stateBlock->samplerState[i][WINED3DSAMP_MAGFILTER] != WINED3DTEXF_POINT) {
WARN("Non-filterable texture and mag filter enabled on samper %u, returning E_FAIL\n", i);

View File

@ -243,12 +243,11 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE] ||
stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(target->resource.format, &GLINFO_LOCATION, &glDesc);
/* Disable blending in all cases even without pixelshaders. With blending on we could face a big performance penalty.
* The d3d9 visual test confirms the behavior. */
if(!(glDesc->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)) {
if (!(target->resource.format_desc->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING))
{
glDisable(GL_BLEND);
checkGLcall("glDisable GL_BLEND");
return;

View File

@ -445,12 +445,10 @@ void surface_set_compatible_renderbuffer(IWineD3DSurface *iface, unsigned int wi
}
if (!renderbuffer) {
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc);
GL_EXTCALL(glGenRenderbuffersEXT(1, &renderbuffer));
GL_EXTCALL(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderbuffer));
GL_EXTCALL(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, glDesc->glInternal, width, height));
GL_EXTCALL(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
This->resource.format_desc->glInternal, width, height));
entry = HeapAlloc(GetProcessHeap(), 0, sizeof(renderbuffer_entry_t));
entry->width = width;
@ -1604,9 +1602,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC
HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format, GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode) {
BOOL colorkey_active = need_alpha_ck && (This->CKeyFlags & WINEDDSD_CKSRCBLT);
const struct GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc = This->resource.format_desc;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc);
/* Default values: From the surface */
*format = glDesc->glFormat;
@ -3838,10 +3835,9 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface)
static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
/** Check against the maximum texture sizes supported by the video card **/
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
const struct GlPixelFormatDesc *glDesc = This->resource.format_desc;
unsigned int pow2Width, pow2Height;
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc);
/* Setup some glformat defaults */
This->glDescription.glFormat = glDesc->glFormat;
This->glDescription.glFormatInternal = glDesc->glInternal;

View File

@ -301,9 +301,8 @@ static HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IWi
static HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, int gl_level, BOOL srgb_mode) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
const struct GlPixelFormatDesc *glDesc = This->resource.format_desc;
WINED3DFORMAT format = This->resource.format;
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(format, &GLINFO_LOCATION, &glDesc);
TRACE("(%p) : level %u, format %s (0x%08x)\n", This, gl_level, debug_d3dformat(format), format);