VirtualBox

Ignore:
Timestamp:
Jul 21, 2009 9:16:52 AM (15 years ago)
Author:
vboxsync
Message:

crOpenGL: update to wine 1.1.26

File:
1 edited

Legend:

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

    r20612 r21731  
    4848const WINED3DLIGHT WINED3D_default_light = {
    4949
    50     WINED3DLIGHT_DIRECTIONAL, /* Type */
    51     { 1.0, 1.0, 1.0, 0.0 },  /* Diffuse r,g,b,a */
    52     { 0.0, 0.0, 0.0, 0.0 },  /* Specular r,g,b,a */
    53     { 0.0, 0.0, 0.0, 0.0 },  /* Ambient r,g,b,a, */
    54     { 0.0, 0.0, 0.0 },        /* Position x,y,z */
    55     { 0.0, 0.0, 1.0 },        /* Direction x,y,z */
    56     0.0,                      /* Range */
    57     0.0,                      /* Falloff */
    58     0.0, 0.0, 0.0,            /* Attenuation 0,1,2 */
    59     0.0,                      /* Theta */
    60     0.0                       /* Phi */
     50    WINED3DLIGHT_DIRECTIONAL,   /* Type */
     51    { 1.0f, 1.0f, 1.0f, 0.0f }, /* Diffuse r,g,b,a */
     52    { 0.0f, 0.0f, 0.0f, 0.0f }, /* Specular r,g,b,a */
     53    { 0.0f, 0.0f, 0.0f, 0.0f }, /* Ambient r,g,b,a, */
     54    { 0.0f, 0.0f, 0.0f },       /* Position x,y,z */
     55    { 0.0f, 0.0f, 1.0f },       /* Direction x,y,z */
     56    0.0f,                       /* Range */
     57    0.0f,                       /* Falloff */
     58    0.0f, 0.0f, 0.0f,           /* Attenuation 0,1,2 */
     59    0.0f,                       /* Theta */
     60    0.0f                        /* Phi */
    6161};
    6262
     
    6464 * Global variable / Constants follow
    6565 **********************************************************/
    66 const float identity[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};  /* When needed for comparisons */
     66const float identity[] =
     67{
     68    1.0f, 0.0f, 0.0f, 0.0f,
     69    0.0f, 1.0f, 0.0f, 0.0f,
     70    0.0f, 0.0f, 1.0f, 0.0f,
     71    0.0f, 0.0f, 0.0f, 1.0f,
     72};  /* When needed for comparisons */
    6773
    6874/* Note that except for WINED3DPT_POINTLIST and WINED3DPT_LINELIST these
     
    176182}
    177183
     184/* Context activation is done by the caller. */
    178185void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
    179186        BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup)
     
    899906}
    900907
    901 static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface,
    902         UINT Width, UINT Height, WINED3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level,
    903         IWineD3DSurface **ppSurface, WINED3DRESOURCETYPE Type, DWORD Usage, WINED3DPOOL Pool,
    904         WINED3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, WINED3DSURFTYPE Impl, IUnknown *parent)
     908static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, UINT Width, UINT Height,
     909        WINED3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IWineD3DSurface **ppSurface,
     910        DWORD Usage, WINED3DPOOL Pool, WINED3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality,
     911        WINED3DSURFTYPE Impl, IUnknown *parent)
    905912{
    906913    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
    907     IWineD3DSurfaceImpl *object; /*NOTE: impl ref allowed since this is a create function */
    908     unsigned int Size       = 1;
    909     const struct GlPixelFormatDesc *glDesc = getFormatDescEntry(Format, &GLINFO_LOCATION);
    910     UINT mul_4w, mul_4h;
     914    IWineD3DSurfaceImpl *object;
    911915    HRESULT hr;
    912916
    913917    TRACE("(%p) Create surface\n",This);
    914918
    915     if(MultisampleQuality > 0) {
    916         FIXME("MultisampleQuality set to %d, substituting 0\n", MultisampleQuality);
    917         MultisampleQuality=0;
    918     }
    919 
    920     /** FIXME: Check that the format is supported
    921     *    by the device.
    922       *******************************/
    923 
    924     /** DXTn mipmaps use the same number of 'levels' down to eg. 8x1, but since
    925      *  it is based around 4x4 pixel blocks it requires padding, so allocate enough
    926      *  space!
    927       *********************************/
    928     mul_4w = (Width + 3) & ~3;
    929     mul_4h = (Height + 3) & ~3;
    930     if (WINED3DFMT_UNKNOWN == Format) {
    931         Size = 0;
    932     } else if (Format == WINED3DFMT_DXT1) {
    933         /* DXT1 is half byte per pixel */
    934         Size = (mul_4w * glDesc->byte_count * mul_4h) >> 1;
    935 
    936     } else if (Format == WINED3DFMT_DXT2 || Format == WINED3DFMT_DXT3 ||
    937                Format == WINED3DFMT_DXT4 || Format == WINED3DFMT_DXT5 ||
    938                Format == WINED3DFMT_ATI2N) {
    939         Size = (mul_4w * glDesc->byte_count * mul_4h);
    940     } else {
    941        /* The pitch is a multiple of 4 bytes */
    942         Size = ((Width * glDesc->byte_count) + This->surface_alignment - 1) & ~(This->surface_alignment - 1);
    943         Size *= Height;
    944     }
    945 
    946     if(glDesc->heightscale != 0.0) Size *= glDesc->heightscale;
    947 
    948     /** Create and initialise the surface resource **/
     919    if (Impl == SURFACE_OPENGL && !This->adapter)
     920    {
     921        ERR("OpenGL surfaces are not available without OpenGL.\n");
     922        return WINED3DERR_NOTAVAILABLE;
     923    }
     924
    949925    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
    950926    if (!object)
    951927    {
    952         ERR("Out of memory\n");
     928        ERR("Failed to allocate surface memory.\n");
    953929        *ppSurface = NULL;
    954930        return WINED3DERR_OUTOFVIDEOMEMORY;
    955931    }
    956932
    957     /* Look at the implementation and set the correct Vtable */
    958     switch(Impl)
    959     {
    960         case SURFACE_OPENGL:
    961             /* Check if a 3D adapter is available when creating gl surfaces */
    962             if (!This->adapter)
    963             {
    964                 ERR("OpenGL surfaces are not available without opengl\n");
    965                 HeapFree(GetProcessHeap(), 0, object);
    966                 return WINED3DERR_NOTAVAILABLE;
    967             }
    968             object->lpVtbl = &IWineD3DSurface_Vtbl;
    969             break;
    970 
    971         case SURFACE_GDI:
    972             object->lpVtbl = &IWineGDISurface_Vtbl;
    973             break;
    974 
    975         default:
    976             /* To be sure to catch this */
    977             ERR("Unknown requested surface implementation %d!\n", Impl);
    978             HeapFree(GetProcessHeap(), 0, object);
    979             return WINED3DERR_INVALIDCALL;
    980     }
    981 
    982     hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_SURFACE, This, Size, Usage, glDesc, Pool, parent);
     933    hr = surface_init(object, Impl, This->surface_alignment, Width, Height, Level, Lockable,
     934            Discard, MultiSample, MultisampleQuality, This, Usage, Format, Pool, parent);
    983935    if (FAILED(hr))
    984936    {
    985         WARN("Failed to initialize resource, returning %#x\n", hr);
     937        WARN("Failed to initialize surface, returning %#x.\n", hr);
    986938        HeapFree(GetProcessHeap(), 0, object);
    987939        *ppSurface = NULL;
     
    989941    }
    990942
    991     TRACE("(%p) : Created resource %p\n", This, object);
     943    TRACE("(%p) : Created surface %p\n", This, object);
    992944
    993945    *ppSurface = (IWineD3DSurface *)object;
    994 
    995     /* "Standalone" surface */
    996     IWineD3DSurface_SetContainer((IWineD3DSurface *)object, NULL);
    997 
    998     object->currentDesc.Width      = Width;
    999     object->currentDesc.Height     = Height;
    1000     object->currentDesc.MultiSampleType    = MultiSample;
    1001     object->currentDesc.MultiSampleQuality = MultisampleQuality;
    1002     object->glDescription.level            = Level;
    1003     list_init(&object->overlays);
    1004 
    1005     /* Flags */
    1006     object->Flags      = SFLAG_NORMCOORD; /* Default to normalized coords */
    1007     object->Flags     |= Discard ? SFLAG_DISCARD : 0;
    1008     object->Flags     |= (WINED3DFMT_D16_LOCKABLE == Format) ? SFLAG_LOCKABLE : 0;
    1009     object->Flags     |= Lockable ? SFLAG_LOCKABLE : 0;
    1010 
    1011     TRACE("Pool %d %d %d %d\n",Pool, WINED3DPOOL_DEFAULT, WINED3DPOOL_MANAGED, WINED3DPOOL_SYSTEMMEM);
    1012 
    1013     /** Quick lockable sanity check TODO: remove this after surfaces, usage and lockability have been debugged properly
    1014     * this function is too deep to need to care about things like this.
    1015     * Levels need to be checked too, and possibly Type since they all affect what can be done.
    1016     * ****************************************/
    1017     switch(Pool) {
    1018     case WINED3DPOOL_SCRATCH:
    1019         if(!Lockable)
    1020             FIXME("Create surface called with a pool of SCRATCH and a Lockable of FALSE "
    1021                 "which are mutually exclusive, setting lockable to TRUE\n");
    1022                 Lockable = TRUE;
    1023     break;
    1024     case WINED3DPOOL_SYSTEMMEM:
    1025         if(!Lockable) FIXME("Create surface called with a pool of SYSTEMMEM and a Lockable of FALSE, "
    1026                                     "this is acceptable but unexpected (I can't know how the surface can be usable!)\n");
    1027     case WINED3DPOOL_MANAGED:
    1028         if(Usage == WINED3DUSAGE_DYNAMIC) FIXME("Create surface called with a pool of MANAGED and a "
    1029                                                 "Usage of DYNAMIC which are mutually exclusive, not doing "
    1030                                                 "anything just telling you.\n");
    1031     break;
    1032     case WINED3DPOOL_DEFAULT: /*TODO: Create offscreen plain can cause this check to fail..., find out if it should */
    1033         if(!(Usage & WINED3DUSAGE_DYNAMIC) && !(Usage & WINED3DUSAGE_RENDERTARGET)
    1034            && !(Usage && WINED3DUSAGE_DEPTHSTENCIL ) && Lockable)
    1035             WARN("Creating a surface with a POOL of DEFAULT with Lockable true, that doesn't specify DYNAMIC usage.\n");
    1036     break;
    1037     default:
    1038         FIXME("(%p) Unknown pool %d\n", This, Pool);
    1039     break;
    1040     };
    1041 
    1042     if (Usage & WINED3DUSAGE_RENDERTARGET && Pool != WINED3DPOOL_DEFAULT) {
    1043         FIXME("Trying to create a render target that isn't in the default pool\n");
    1044     }
    1045 
    1046     /* mark the texture as dirty so that it gets loaded first time around*/
    1047     surface_add_dirty_rect(*ppSurface, NULL);
    1048     TRACE("(%p) : w(%d) h(%d) fmt(%d,%s) lockable(%d) surf@%p, surfmem@%p, %d bytes\n",
    1049            This, Width, Height, Format, debug_d3dformat(Format),
    1050            (WINED3DFMT_D16_LOCKABLE == Format), *ppSurface, object->resource.allocatedMemory, object->resource.size);
    1051 
    1052     list_init(&object->renderbuffers);
    1053 
    1054     /* Call the private setup routine */
    1055     hr = IWineD3DSurface_PrivateSetup((IWineD3DSurface *)object);
    1056     if (FAILED(hr))
    1057     {
    1058         ERR("Private setup failed, returning %#x\n", hr);
    1059         IWineD3DSurface_Release(*ppSurface);
    1060         *ppSurface = NULL;
    1061         return hr;
    1062     }
    1063946
    1064947    return hr;
     
    21262009    }
    21272010
    2128     hr = IWineD3DDevice_CreateSurface((IWineD3DDevice *) This, bm.bmWidth, bm.bmHeight, WINED3DFMT_R5G6B5,
    2129                                       TRUE, FALSE, 0, &This->logo_surface, WINED3DRTYPE_SURFACE, 0,
    2130                                       WINED3DPOOL_DEFAULT, WINED3DMULTISAMPLE_NONE, 0, SURFACE_OPENGL, NULL);
     2011    hr = IWineD3DDevice_CreateSurface((IWineD3DDevice *) This, bm.bmWidth, bm.bmHeight, WINED3DFMT_R5G6B5, TRUE,
     2012            FALSE, 0, &This->logo_surface, 0, WINED3DPOOL_DEFAULT, WINED3DMULTISAMPLE_NONE, 0, SURFACE_OPENGL, NULL);
    21312013    if(FAILED(hr)) {
    21322014        ERR("Wine logo requested, but failed to create surface\n");
     
    21582040}
    21592041
     2042/* Context activation is done by the caller. */
    21602043static void create_dummy_textures(IWineD3DDeviceImpl *This) {
    21612044    unsigned int i;
     
    22642147    }
    22652148
    2266     /* Setup the implicit swapchain */
     2149    /* Setup the implicit swapchain. This also initializes a context. */
    22672150    TRACE("Creating implicit swapchain\n");
    22682151    hr = IWineD3DDeviceParent_CreateSwapChain(This->device_parent,
     
    23562239    IWineD3DDevice_Clear((IWineD3DDevice *) This, 0, NULL,
    23572240                          WINED3DCLEAR_TARGET | pPresentationParameters->EnableAutoDepthStencil ? WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL : 0,
    2358                           0x00, 1.0, 0);
     2241                          0x00, 1.0f, 0);
    23592242
    23602243    This->d3d_initialized = TRUE;
     
    29312814             * most wanted
    29322815             */
    2933             if(pLight->Attenuation0 < 0.0 || pLight->Attenuation1 < 0.0 || pLight->Attenuation2 < 0.0) {
     2816            if (pLight->Attenuation0 < 0.0f || pLight->Attenuation1 < 0.0f || pLight->Attenuation2 < 0.0f)
     2817            {
    29342818                WARN("Attenuation is negative, returning WINED3DERR_INVALIDCALL\n");
    29352819                return WINED3DERR_INVALIDCALL;
     
    29932877        object->lightPosn[1] = -pLight->Direction.y;
    29942878        object->lightPosn[2] = -pLight->Direction.z;
    2995         object->lightPosn[3] = 0.0;
     2879        object->lightPosn[3] = 0.0f;
    29962880        object->exponent     = 0.0f;
    29972881        object->cutoff       = 180.0f;
     
    30032887        object->lightPosn[1] = pLight->Position.y;
    30042888        object->lightPosn[2] = pLight->Position.z;
    3005         object->lightPosn[3] = 1.0;
     2889        object->lightPosn[3] = 1.0f;
    30062890
    30072891        /* Direction */
     
    30092893        object->lightDirn[1] = pLight->Direction.y;
    30102894        object->lightDirn[2] = pLight->Direction.z;
    3011         object->lightDirn[3] = 1.0;
     2895        object->lightDirn[3] = 1.0f;
    30122896
    30132897        /*
     
    30242908             * rest of the rather complex calculation
    30252909             */
    3026             object->exponent = 0;
     2910            object->exponent = 0.0f;
    30272911        } else {
    30282912            rho = pLight->Theta + (pLight->Phi - pLight->Theta)/(2*pLight->Falloff);
    3029             if (rho < 0.0001) rho = 0.0001f;
    3030             object->exponent = -0.3/log(cos(rho/2));
    3031         }
    3032         if (object->exponent > 128.0) {
    3033             object->exponent = 128.0;
     2913            if (rho < 0.0001f) rho = 0.0001f;
     2914            object->exponent = -0.3f/log(cos(rho/2));
     2915        }
     2916        if (object->exponent > 128.0f)
     2917        {
     2918            object->exponent = 128.0f;
    30342919        }
    30352920        object->cutoff = pLight->Phi*90/M_PI;
     
    30812966    struct list *e;
    30822967    TRACE("(%p) : Idx(%d), enable? %d\n", This, Index, Enable);
    3083 
    3084     /* Tests show true = 128...not clear why */
    3085     Enable = Enable? 128: 0;
    30862968
    30872969    LIST_FOR_EACH(e, &This->updateStateBlock->lightMap[Hi]) {
     
    41724054}
    41734055
     4056/* Context activation is done by the caller. */
    41744057#define copy_and_next(dest, src, size) memcpy(dest, src, size); dest += (size)
    41754058static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCount,
     
    42994182
    43004183            /* Multiplication with world, view and projection matrix */
    4301             x =   (p[0] * mat.u.s._11) + (p[1] * mat.u.s._21) + (p[2] * mat.u.s._31) + (1.0 * mat.u.s._41);
    4302             y =   (p[0] * mat.u.s._12) + (p[1] * mat.u.s._22) + (p[2] * mat.u.s._32) + (1.0 * mat.u.s._42);
    4303             z =   (p[0] * mat.u.s._13) + (p[1] * mat.u.s._23) + (p[2] * mat.u.s._33) + (1.0 * mat.u.s._43);
    4304             rhw = (p[0] * mat.u.s._14) + (p[1] * mat.u.s._24) + (p[2] * mat.u.s._34) + (1.0 * mat.u.s._44);
     4184            x =   (p[0] * mat.u.s._11) + (p[1] * mat.u.s._21) + (p[2] * mat.u.s._31) + (1.0f * mat.u.s._41);
     4185            y =   (p[0] * mat.u.s._12) + (p[1] * mat.u.s._22) + (p[2] * mat.u.s._32) + (1.0f * mat.u.s._42);
     4186            z =   (p[0] * mat.u.s._13) + (p[1] * mat.u.s._23) + (p[2] * mat.u.s._33) + (1.0f * mat.u.s._43);
     4187            rhw = (p[0] * mat.u.s._14) + (p[1] * mat.u.s._24) + (p[2] * mat.u.s._34) + (1.0f * mat.u.s._44);
    43054188
    43064189            TRACE("x=%f y=%f z=%f rhw=%f\n", x, y, z, rhw);
     
    58655748      ****************************************/
    58665749    IWineD3DSurfaceImpl *pSrcSurface  = (IWineD3DSurfaceImpl *)pSourceSurface;
     5750    IWineD3DSurfaceImpl *dst_impl = (IWineD3DSurfaceImpl *)pDestinationSurface;
    58675751    int srcWidth, srcHeight;
    58685752    unsigned int  srcSurfaceWidth, srcSurfaceHeight, destSurfaceWidth, destSurfaceHeight;
     
    58735757    int offset    = 0;
    58745758    int rowoffset = 0; /* how many bytes to add onto the end of a row to wraparound to the beginning of the next */
    5875     glDescriptor *glDescription = NULL;
    58765759    const struct GlPixelFormatDesc *src_format_desc, *dst_format_desc;
    58775760    GLenum dummy;
     
    58835766
    58845767    TRACE("(%p) : Source (%p)  Rect (%p) Destination (%p) Point(%p)\n", This, pSourceSurface, pSourceRect, pDestinationSurface, pDestPoint);
    5885     memset(&winedesc, 0, sizeof(winedesc));
    5886     winedesc.Width  = &srcSurfaceWidth;
    5887     winedesc.Height = &srcSurfaceHeight;
    5888     winedesc.Pool   = &srcPool;
    5889     winedesc.Format = &srcFormat;
    58905768
    58915769    IWineD3DSurface_GetDesc(pSourceSurface, &winedesc);
    5892 
    5893     winedesc.Width  = &destSurfaceWidth;
    5894     winedesc.Height = &destSurfaceHeight;
    5895     winedesc.Pool   = &destPool;
    5896     winedesc.Format = &destFormat;
    5897     winedesc.Size   = &destSize;
     5770    srcSurfaceWidth = winedesc.width;
     5771    srcSurfaceHeight = winedesc.height;
     5772    srcPool = winedesc.pool;
     5773    srcFormat = winedesc.format;
    58985774
    58995775    IWineD3DSurface_GetDesc(pDestinationSurface, &winedesc);
     5776    destSurfaceWidth = winedesc.width;
     5777    destSurfaceHeight = winedesc.height;
     5778    destPool = winedesc.pool;
     5779    destFormat = winedesc.format;
     5780    destSize = winedesc.size;
    59005781
    59015782    if(srcPool != WINED3DPOOL_SYSTEMMEM  || destPool != WINED3DPOOL_DEFAULT){
     
    59085789     * copy in sysmem and use regular surface loading.
    59095790     */
    5910     d3dfmt_get_conv((IWineD3DSurfaceImpl *) pDestinationSurface, FALSE, TRUE,
    5911                     &dummy, &dummy, &dummy, &convert, &bpp, FALSE);
     5791    d3dfmt_get_conv(dst_impl, FALSE, TRUE, &dummy, &dummy, &dummy, &convert, &bpp, FALSE);
    59125792    if(convert != NO_CONVERSION) {
    59135793        return IWineD3DSurface_BltFast(pDestinationSurface,
     
    59365816    IWineD3DSurface_BindTexture(pDestinationSurface, FALSE);
    59375817
    5938     IWineD3DSurface_GetGlDesc(pDestinationSurface, &glDescription);
    5939 
    59405818    src_format_desc = ((IWineD3DSurfaceImpl *)pSrcSurface)->resource.format_desc;
    5941     dst_format_desc = ((IWineD3DSurfaceImpl *)pDestinationSurface)->resource.format_desc;
     5819    dst_format_desc = dst_impl->resource.format_desc;
    59425820
    59435821    /* this needs to be done in lines if the sourceRect != the sourceWidth */
     
    59625840    }
    59635841    TRACE("(%p) glTexSubImage2D, level %d, left %d, top %d, width %d, height %d, fmt %#x, type %#x, memory %p+%#x\n",
    5964             This, glDescription->level, destLeft, destTop, srcWidth, srcHeight, dst_format_desc->glFormat,
     5842            This, dst_impl->texture_level, destLeft, destTop, srcWidth, srcHeight, dst_format_desc->glFormat,
    59655843            dst_format_desc->glType, IWineD3DSurface_GetData(pSourceSurface), offset);
    59665844
     
    59845862        for (j = destTop; j < (srcHeight + destTop); ++j)
    59855863        {
    5986             glTexSubImage2D(glDescription->target, glDescription->level, destLeft, j,
     5864            glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, destLeft, j,
    59875865                    srcWidth, 1, dst_format_desc->glFormat, dst_format_desc->glType,data);
    59885866            data += rowoffset;
     
    59925870        const unsigned char* data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset;
    59935871
    5994         if (WINED3DFMT_DXT1 == destFormat ||
    5995             WINED3DFMT_DXT2 == destFormat ||
    5996             WINED3DFMT_DXT3 == destFormat ||
    5997             WINED3DFMT_DXT4 == destFormat ||
    5998             WINED3DFMT_DXT5 == destFormat) {
    5999             if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
    6000                 if (destSurfaceHeight != srcHeight || destSurfaceWidth != srcWidth) {
    6001                     /* FIXME: The easy way to do this is to lock the destination, and copy the bits across */
    6002                     FIXME("Updating part of a compressed texture is not supported at the moment\n");
    6003                 } if (destFormat != srcFormat) {
    6004                     FIXME("Updating mixed format compressed texture is not curretly support\n");
    6005                 } else {
    6006                     GL_EXTCALL(glCompressedTexImage2DARB(glDescription->target, glDescription->level,
    6007                             dst_format_desc->glInternal, srcWidth, srcHeight, 0, destSize, data));
    6008                 }
    6009             } else {
    6010                 FIXME("Attempting to update a DXT compressed texture without hardware support\n");
     5872        if (dst_format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED)
     5873        {
     5874            if (destSurfaceHeight != srcHeight || destSurfaceWidth != srcWidth)
     5875            {
     5876                /* FIXME: The easy way to do this is to lock the destination, and copy the bits across. */
     5877                FIXME("Updating part of a compressed texture is not supported.\n");
    60115878            }
    6012 
    6013 
    6014         } else {
    6015             glTexSubImage2D(glDescription->target, glDescription->level, destLeft, destTop,
     5879            if (destFormat != srcFormat)
     5880            {
     5881                FIXME("Updating mixed format compressed textures is not supported.\n");
     5882            }
     5883            else
     5884            {
     5885                GL_EXTCALL(glCompressedTexImage2DARB(dst_impl->texture_target, dst_impl->texture_level,
     5886                        dst_format_desc->glInternal, srcWidth, srcHeight, 0, destSize, data));
     5887            }
     5888        }
     5889        else
     5890        {
     5891            glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, destLeft, destTop,
    60165892                    srcWidth, srcHeight, dst_format_desc->glFormat, dst_format_desc->glType, data);
    60175893        }
     
    61756051        ActivateContext(This, surface, CTXUSAGE_RESOURCELOAD);
    61766052        ENTER_GL();
    6177         GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
     6053        context_bind_fbo(This->activeContext, GL_FRAMEBUFFER_EXT, NULL);
    61786054        buffer = surface_get_gl_buffer(surface, swapchain);
    61796055        glDrawBuffer(buffer);
     
    61846060        ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
    61856061        ENTER_GL();
    6186         context_bind_fbo(iface, GL_FRAMEBUFFER_EXT, &This->activeContext->dst_fbo);
    6187         context_attach_surface_fbo(This, GL_FRAMEBUFFER_EXT, 0, surface);
    6188         GL_EXTCALL(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0));
    6189         checkGLcall("glFramebufferRenderbufferEXT");
     6062        context_bind_fbo(This->activeContext, GL_FRAMEBUFFER_EXT, &This->activeContext->dst_fbo);
     6063        context_attach_surface_fbo(This->activeContext, GL_FRAMEBUFFER_EXT, 0, surface);
     6064        context_attach_depth_stencil_fbo(This->activeContext, GL_FRAMEBUFFER_EXT, NULL, FALSE);
    61906065    }
    61916066
     
    62166091
    62176092    if (This->activeContext->current_fbo) {
    6218         context_bind_fbo(iface, GL_FRAMEBUFFER_EXT, &This->activeContext->current_fbo->id);
     6093        context_bind_fbo(This->activeContext, GL_FRAMEBUFFER_EXT, &This->activeContext->current_fbo->id);
    62196094    } else {
    6220         GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
    6221         checkGLcall("glBindFramebuffer()");
     6095        context_bind_fbo(This->activeContext, GL_FRAMEBUFFER_EXT, NULL);
    62226096    }
    62236097
     
    63976271        WARN("Converting to WINED3DCOLOR, this might give incorrect results\n");
    63986272
    6399         c = ((DWORD)(color[2] * 255.0));
    6400         c |= ((DWORD)(color[1] * 255.0)) << 8;
    6401         c |= ((DWORD)(color[0] * 255.0)) << 16;
    6402         c |= ((DWORD)(color[3] * 255.0)) << 24;
     6273        c = ((DWORD)(color[2] * 255.0f));
     6274        c |= ((DWORD)(color[1] * 255.0f)) << 8;
     6275        c |= ((DWORD)(color[0] * 255.0f)) << 16;
     6276        c |= ((DWORD)(color[3] * 255.0f)) << 24;
    64036277
    64046278        /* Just forward this to the DirectDraw blitting engine */
     
    64916365         * This function is called by IDirect3D7::CreateDevice so in theory its initialization code
    64926366         */
     6367        WARN("No active context?\n");
     6368
    64936369        ENTER_GL();
    64946370        if(!Swapchain->backBuffer[0]) {
     
    65726448    /* Attach src surface to src fbo */
    65736449    src_swapchain = get_swapchain(src_surface);
     6450    dst_swapchain = get_swapchain(dst_surface);
     6451
     6452    if (src_swapchain) ActivateContext(This, src_surface, CTXUSAGE_RESOURCELOAD);
     6453    else if (dst_swapchain) ActivateContext(This, dst_surface, CTXUSAGE_RESOURCELOAD);
     6454    else ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
     6455
    65746456    if (src_swapchain) {
    65756457        GLenum buffer = surface_get_gl_buffer(src_surface, src_swapchain);
    65766458
    65776459        TRACE("Source surface %p is onscreen\n", src_surface);
    6578         ActivateContext(This, src_surface, CTXUSAGE_RESOURCELOAD);
    65796460        /* Make sure the drawable is up to date. In the offscreen case
    65806461         * attach_surface_fbo() implicitly takes care of this. */
     
    65966477
    65976478        ENTER_GL();
    6598         GL_EXTCALL(glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0));
     6479        context_bind_fbo(This->activeContext, GL_READ_FRAMEBUFFER_EXT, NULL);
    65996480        glReadBuffer(buffer);
    66006481        checkGLcall("glReadBuffer()");
     
    66026483        TRACE("Source surface %p is offscreen\n", src_surface);
    66036484        ENTER_GL();
    6604         context_bind_fbo(iface, GL_READ_FRAMEBUFFER_EXT, &This->activeContext->src_fbo);
    6605         context_attach_surface_fbo(This, GL_READ_FRAMEBUFFER_EXT, 0, src_surface);
     6485        context_bind_fbo(This->activeContext, GL_READ_FRAMEBUFFER_EXT, &This->activeContext->src_fbo);
     6486        context_attach_surface_fbo(This->activeContext, GL_READ_FRAMEBUFFER_EXT, 0, src_surface);
    66066487        glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
    66076488        checkGLcall("glReadBuffer()");
    6608         GL_EXTCALL(glFramebufferRenderbufferEXT(GL_READ_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0));
    6609         checkGLcall("glFramebufferRenderbufferEXT");
     6489        context_attach_depth_stencil_fbo(This->activeContext, GL_READ_FRAMEBUFFER_EXT, NULL, FALSE);
    66106490    }
    66116491    LEAVE_GL();
    66126492
    66136493    /* Attach dst surface to dst fbo */
    6614     dst_swapchain = get_swapchain(dst_surface);
    66156494    if (dst_swapchain) {
    66166495        GLenum buffer = surface_get_gl_buffer(dst_surface, dst_swapchain);
    66176496
    66186497        TRACE("Destination surface %p is onscreen\n", dst_surface);
    6619         ActivateContext(This, dst_surface, CTXUSAGE_RESOURCELOAD);
    66206498        /* Make sure the drawable is up to date. In the offscreen case
    66216499         * attach_surface_fbo() implicitly takes care of this. */
     
    66386516
    66396517        ENTER_GL();
    6640         GL_EXTCALL(glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0));
     6518        context_bind_fbo(This->activeContext, GL_DRAW_FRAMEBUFFER_EXT, NULL);
    66416519        glDrawBuffer(buffer);
    66426520        checkGLcall("glDrawBuffer()");
     
    66446522        TRACE("Destination surface %p is offscreen\n", dst_surface);
    66456523
    6646         /* No src or dst swapchain? Make sure some context is active(multithreading) */
    6647         if(!src_swapchain) {
    6648             ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
    6649         }
    6650 
    66516524        ENTER_GL();
    6652         context_bind_fbo(iface, GL_DRAW_FRAMEBUFFER_EXT, &This->activeContext->dst_fbo);
    6653         context_attach_surface_fbo(This, GL_DRAW_FRAMEBUFFER_EXT, 0, dst_surface);
     6525        context_bind_fbo(This->activeContext, GL_DRAW_FRAMEBUFFER_EXT, &This->activeContext->dst_fbo);
     6526        context_attach_surface_fbo(This->activeContext, GL_DRAW_FRAMEBUFFER_EXT, 0, dst_surface);
    66546527        glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
    66556528        checkGLcall("glDrawBuffer()");
    6656         GL_EXTCALL(glFramebufferRenderbufferEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0));
    6657         checkGLcall("glFramebufferRenderbufferEXT");
     6529        context_attach_depth_stencil_fbo(This->activeContext, GL_DRAW_FRAMEBUFFER_EXT, NULL, FALSE);
    66586530    }
    66596531    glDisable(GL_SCISSOR_TEST);
     
    66736545
    66746546    if (This->activeContext->current_fbo) {
    6675         context_bind_fbo(iface, GL_FRAMEBUFFER_EXT, &This->activeContext->current_fbo->id);
     6547        context_bind_fbo(This->activeContext, GL_FRAMEBUFFER_EXT, &This->activeContext->current_fbo->id);
    66766548    } else {
    6677         GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
    6678         checkGLcall("glBindFramebuffer()");
     6549        context_bind_fbo(This->activeContext, GL_FRAMEBUFFER_EXT, NULL);
    66796550    }
    66806551
     
    68556726                    memcpy(&mem[width * bpp * i], &bits[rect.Pitch * i], width * bpp);
    68566727                IWineD3DSurface_UnlockRect(pCursorBitmap);
     6728
     6729                ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
     6730
    68576731                ENTER_GL();
    68586732
     
    70036877}
    70046878
     6879static HRESULT WINAPI evict_managed_resource(IWineD3DResource *resource, void *data) {
     6880    TRACE("checking resource %p for eviction\n", resource);
     6881    if(((IWineD3DResourceImpl *) resource)->resource.pool == WINED3DPOOL_MANAGED) {
     6882        TRACE("Evicting %p\n", resource);
     6883        IWineD3DResource_UnLoad(resource);
     6884    }
     6885    IWineD3DResource_Release(resource);
     6886    return S_OK;
     6887}
    70056888
    70066889static HRESULT  WINAPI  IWineD3DDeviceImpl_EvictManagedResources(IWineD3DDevice* iface) {
    70076890    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
    7008     /** FIXME: Resource tracking needs to be done,
    7009     * The closes we can do to this is set the priorities of all managed textures low
    7010     * and then reset them.
    7011      ***********************************************************/
    7012     FIXME("(%p) : stub\n", This);
     6891    TRACE("(%p)\n", This);
     6892
     6893    IWineD3DDevice_EnumResources(iface, evict_managed_resource, NULL);
    70136894    return WINED3D_OK;
    70146895}
     
    70456926    surface->glRect.bottom = surface->pow2Height;
    70466927
    7047     if(surface->glDescription.textureName) {
     6928    if (surface->texture_name)
     6929    {
    70486930        ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
    70496931        ENTER_GL();
    7050         glDeleteTextures(1, &surface->glDescription.textureName);
     6932        glDeleteTextures(1, &surface->texture_name);
    70516933        LEAVE_GL();
    7052         surface->glDescription.textureName = 0;
     6934        surface->texture_name = 0;
    70536935        surface->Flags &= ~SFLAG_CLIENT;
    70546936    }
     
    71106992    UINT i;
    71116993    IWineD3DBaseShaderImpl *shader;
     6994
     6995    ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
    71126996
    71136997    IWineD3DDevice_EnumResources(iface, reset_unload_resources, NULL);
     
    74657349            unsigned int i;
    74667350
    7467             /* Cleanup any FBO attachments if d3d is enabled */
    7468             if(This->d3d_initialized) {
    7469                 if((IWineD3DSurface *)resource == This->lastActiveRenderTarget) {
    7470                     IWineD3DSwapChainImpl *swapchain = This->swapchains ? (IWineD3DSwapChainImpl *) This->swapchains[0] : NULL;
    7471 
    7472                     TRACE("Last active render target destroyed\n");
    7473                     /* Find a replacement surface for the currently active back buffer. The context manager does not do NULL
    7474                      * checks, so switch to a valid target as long as the currently set surface is still valid. Use the
    7475                      * surface of the implicit swpchain. If that is the same as the destroyed surface the device is destroyed
    7476                      * and the lastActiveRenderTarget member shouldn't matter
    7477                      */
    7478                     if(swapchain) {
    7479                         if(swapchain->backBuffer && swapchain->backBuffer[0] != (IWineD3DSurface *)resource) {
    7480                             TRACE("Activating primary back buffer\n");
    7481                             ActivateContext(This, swapchain->backBuffer[0], CTXUSAGE_RESOURCELOAD);
    7482                         } else if(!swapchain->backBuffer && swapchain->frontBuffer != (IWineD3DSurface *)resource) {
    7483                             /* Single buffering environment */
    7484                             TRACE("Activating primary front buffer\n");
    7485                             ActivateContext(This, swapchain->frontBuffer, CTXUSAGE_RESOURCELOAD);
    7486                         } else {
    7487                             TRACE("Device is being destroyed, setting lastActiveRenderTarget = 0xdeadbabe\n");
    7488                             /* Implicit render target destroyed, that means the device is being destroyed
    7489                              * whatever we set here, it shouldn't matter
    7490                              */
    7491                             This->lastActiveRenderTarget = (IWineD3DSurface *) 0xdeadbabe;
    7492                         }
    7493                     } else {
    7494                         /* May happen during ddraw uninitialization */
    7495                         TRACE("Render target set, but swapchain does not exist!\n");
    7496                         This->lastActiveRenderTarget = (IWineD3DSurface *) 0xdeadcafe;
    7497                     }
    7498                 }
    7499 
     7351            if (This->d3d_initialized)
     7352            {
    75007353                for (i = 0; i < GL_LIMITS(buffers); ++i) {
    75017354                    if (This->render_targets[i] == (IWineD3DSurface *)resource) {
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