VirtualBox

Ignore:
Timestamp:
Jun 16, 2009 9:20:54 AM (16 years ago)
Author:
vboxsync
Message:

crOpenGL: update wine to 1.1.23

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/volumetexture.c

    r19678 r20612  
    3434
    3535WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
    36 #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
     36
     37#define GLINFO_LOCATION (*gl_info)
     38
     39static void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb)
     40{
     41    /* Override the IWineD3DResource Preload method. */
     42    IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
     43    IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
     44    const WineD3D_GL_Info *gl_info = &device->adapter->gl_info;
     45    BOOL srgb_mode = This->baseTexture.is_srgb;
     46    BOOL srgb_was_toggled = FALSE;
     47    unsigned int i;
     48
     49    TRACE("(%p) : About to load texture.\n", This);
     50
     51    if (!device->isInDraw)
     52    {
     53        ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
     54    }
     55    else if (GL_SUPPORT(EXT_TEXTURE_SRGB) && This->baseTexture.bindCount > 0)
     56    {
     57        srgb_mode = device->stateBlock->samplerState[This->baseTexture.sampler][WINED3DSAMP_SRGBTEXTURE];
     58        srgb_was_toggled = This->baseTexture.is_srgb != srgb_mode;
     59        This->baseTexture.is_srgb = srgb_mode;
     60    }
     61
     62    /* If the texture is marked dirty or the srgb sampler setting has changed
     63     * since the last load then reload the volumes. */
     64    if (This->baseTexture.dirty)
     65    {
     66        for (i = 0; i < This->baseTexture.levels; ++i)
     67        {
     68            IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
     69        }
     70    }
     71    else if (srgb_was_toggled)
     72    {
     73        for (i = 0; i < This->baseTexture.levels; ++i)
     74        {
     75            volume_add_dirty_box(This->volumes[i], NULL);
     76            IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
     77        }
     78    }
     79    else
     80    {
     81        TRACE("(%p) Texture not dirty, nothing to do.\n", iface);
     82    }
     83
     84    /* No longer dirty */
     85    This->baseTexture.dirty = FALSE;
     86}
     87
     88static void volumetexture_cleanup(IWineD3DVolumeTextureImpl *This, D3DCB_DESTROYVOLUMEFN volume_destroy_cb)
     89{
     90    unsigned int i;
     91
     92    TRACE("(%p) : Cleaning up.\n", This);
     93
     94    for (i = 0; i < This->baseTexture.levels; ++i)
     95    {
     96        IWineD3DVolume *volume = This->volumes[i];
     97
     98        if (volume)
     99        {
     100            /* Cleanup the container. */
     101            IWineD3DVolume_SetContainer(volume, NULL);
     102            volume_destroy_cb(volume);
     103        }
     104    }
     105    basetexture_cleanup((IWineD3DBaseTexture *)This);
     106}
     107
     108HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT height, UINT depth, UINT levels,
     109        IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, IUnknown *parent)
     110{
     111    const WineD3D_GL_Info *gl_info = &device->adapter->gl_info;
     112    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
     113    UINT tmp_w, tmp_h, tmp_d;
     114    unsigned int i;
     115    HRESULT hr;
     116
     117    /* TODO: It should only be possible to create textures for formats
     118     * that are reported as supported. */
     119    if (WINED3DFMT_UNKNOWN >= format)
     120    {
     121        WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
     122        return WINED3DERR_INVALIDCALL;
     123    }
     124
     125    if (!GL_SUPPORT(EXT_TEXTURE3D))
     126    {
     127        WARN("(%p) : Texture cannot be created - no volume texture support.\n", texture);
     128        return WINED3DERR_INVALIDCALL;
     129    }
     130
     131    /* Calculate levels for mip mapping. */
     132    if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
     133    {
     134        if (!GL_SUPPORT(SGIS_GENERATE_MIPMAP))
     135        {
     136            WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
     137            return WINED3DERR_INVALIDCALL;
     138        }
     139
     140        if (levels > 1)
     141        {
     142            WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n");
     143            return WINED3DERR_INVALIDCALL;
     144        }
     145
     146        levels = 1;
     147    }
     148    else if (!levels)
     149    {
     150        levels = wined3d_log2i(max(max(width, height), depth)) + 1;
     151        TRACE("Calculated levels = %u.\n", levels);
     152    }
     153
     154    hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels,
     155            WINED3DRTYPE_VOLUMETEXTURE, device, 0, usage, format_desc, pool, parent);
     156    if (FAILED(hr))
     157    {
     158        WARN("Failed to initialize basetexture, returning %#x.\n", hr);
     159        return hr;
     160    }
     161
     162    if (texture->resource.format_desc->Flags & WINED3DFMT_FLAG_FILTERING)
     163    {
     164        texture->baseTexture.minMipLookup = minMipLookup;
     165        texture->baseTexture.magLookup = magLookup;
     166    }
     167    else
     168    {
     169        texture->baseTexture.minMipLookup = minMipLookup_noFilter;
     170        texture->baseTexture.magLookup = magLookup_noFilter;
     171    }
     172
     173    /* Is NP2 support for volumes needed? */
     174    texture->baseTexture.pow2Matrix[0] = 1.0;
     175    texture->baseTexture.pow2Matrix[5] = 1.0;
     176    texture->baseTexture.pow2Matrix[10] = 1.0;
     177    texture->baseTexture.pow2Matrix[15] = 1.0;
     178
     179    /* Generate all the surfaces. */
     180    tmp_w = width;
     181    tmp_h = height;
     182    tmp_d = depth;
     183
     184    for (i = 0; i < texture->baseTexture.levels; ++i)
     185    {
     186        /* Create the volume. */
     187        hr = IWineD3DDeviceParent_CreateVolume(device->device_parent, parent,
     188                tmp_w, tmp_h, tmp_d, format, pool, usage, &texture->volumes[i]);
     189        if (FAILED(hr))
     190        {
     191            ERR("Creating a volume for the volume texture failed, hr %#x.\n", hr);
     192            texture->volumes[i] = NULL;
     193            volumetexture_cleanup(texture, D3DCB_DefaultDestroyVolume);
     194            return hr;
     195        }
     196
     197        /* Set its container to this texture. */
     198        IWineD3DVolume_SetContainer(texture->volumes[i], (IWineD3DBase *)texture);
     199
     200        /* Calculate the next mipmap level. */
     201        tmp_w = max(1, tmp_w >> 1);
     202        tmp_h = max(1, tmp_h >> 1);
     203        tmp_d = max(1, tmp_d >> 1);
     204    }
     205    texture->baseTexture.internal_preload = volumetexture_internal_preload;
     206
     207    return WINED3D_OK;
     208}
     209
     210#undef GLINFO_LOCATION
    37211
    38212/* *******************************************
    39213   IWineD3DTexture IUnknown parts follow
    40214   ******************************************* */
     215
     216#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
     217
    41218static HRESULT WINAPI IWineD3DVolumeTextureImpl_QueryInterface(IWineD3DVolumeTexture *iface, REFIID riid, LPVOID *ppobj)
    42219{
     
    100277}
    101278
    102 void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb) {
    103     /* Overrider the IWineD3DResource Preload method */
    104     unsigned int i;
    105     IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
    106     IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
    107     BOOL srgb_mode = This->baseTexture.is_srgb;
    108     BOOL srgb_was_toggled = FALSE;
    109 
    110     TRACE("(%p) : About to load texture\n", This);
    111 
    112     if(!device->isInDraw) {
    113         ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
    114     } else if (GL_SUPPORT(EXT_TEXTURE_SRGB) && This->baseTexture.bindCount > 0) {
    115         srgb_mode = device->stateBlock->samplerState[This->baseTexture.sampler][WINED3DSAMP_SRGBTEXTURE];
    116         srgb_was_toggled = This->baseTexture.is_srgb != srgb_mode;
    117         This->baseTexture.is_srgb = srgb_mode;
    118     }
    119 
    120     /* If the texture is marked dirty or the srgb sampler setting has changed since the last load then reload the surfaces */
    121     if (This->baseTexture.dirty) {
    122         for (i = 0; i < This->baseTexture.levels; i++)
    123             IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
    124     } else if (srgb_was_toggled) {
    125         for (i = 0; i < This->baseTexture.levels; i++) {
    126             volume_add_dirty_box(This->volumes[i], NULL);
    127             IWineD3DVolume_LoadTexture(This->volumes[i], i, srgb_mode);
    128         }
    129     } else {
    130         TRACE("(%p) Texture not dirty, nothing to do\n" , iface);
    131     }
    132 
    133     /* No longer dirty */
    134     This->baseTexture.dirty = FALSE;
    135 
    136     return ;
    137 }
    138 
    139279static void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *iface) {
    140280    volumetexture_internal_preload((IWineD3DBaseTexture *) iface, SRGB_ANY);
     
    221361}
    222362
    223 static void WINAPI IWineD3DVolumeTextureImpl_ApplyStateChanges(IWineD3DVolumeTexture *iface,
    224                                                         const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
    225                                                         const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
    226     IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
    227     TRACE("(%p) : nothing to do, passing to base texture\n", This);
    228     basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
    229 }
    230 
    231 
    232363/* *******************************************
    233364   IWineD3DVolumeTexture IWineD3DVolumeTexture parts follow
     
    235366static void WINAPI IWineD3DVolumeTextureImpl_Destroy(IWineD3DVolumeTexture *iface, D3DCB_DESTROYVOLUMEFN D3DCB_DestroyVolume) {
    236367    IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
    237     unsigned int i;
    238     TRACE("(%p) : Cleaning up\n",This);
    239     for (i = 0; i < This->baseTexture.levels; i++) {
    240         if (This->volumes[i] != NULL) {
    241             /* Cleanup the container */
    242             IWineD3DVolume_SetContainer(This->volumes[i], 0);
    243             D3DCB_DestroyVolume(This->volumes[i]);
    244         }
    245     }
    246     basetexture_cleanup((IWineD3DBaseTexture *)iface);
     368
     369    volumetexture_cleanup(This, D3DCB_DestroyVolume);
     370
    247371    HeapFree(GetProcessHeap(), 0, This);
    248372}
     
    340464    IWineD3DVolumeTextureImpl_GetTextureDimensions,
    341465    IWineD3DVolumeTextureImpl_IsCondNP2,
    342     IWineD3DVolumeTextureImpl_ApplyStateChanges,
    343466    /* volume texture */
    344467    IWineD3DVolumeTextureImpl_Destroy,
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette