Changeset 21731 in vbox for trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c
- Timestamp:
- Jul 21, 2009 9:16:52 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c
r20612 r21731 48 48 const WINED3DLIGHT WINED3D_default_light = { 49 49 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 */ 61 61 }; 62 62 … … 64 64 * Global variable / Constants follow 65 65 **********************************************************/ 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 */ 66 const 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 */ 67 73 68 74 /* Note that except for WINED3DPT_POINTLIST and WINED3DPT_LINELIST these … … 176 182 } 177 183 184 /* Context activation is done by the caller. */ 178 185 void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, 179 186 BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) … … 899 906 } 900 907 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 WINED3D MULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, WINED3DSURFTYPE Impl, IUnknown *parent)908 static 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) 905 912 { 906 913 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; 911 915 HRESULT hr; 912 916 913 917 TRACE("(%p) Create surface\n",This); 914 918 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 949 925 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); 950 926 if (!object) 951 927 { 952 ERR(" Out of memory\n");928 ERR("Failed to allocate surface memory.\n"); 953 929 *ppSurface = NULL; 954 930 return WINED3DERR_OUTOFVIDEOMEMORY; 955 931 } 956 932 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); 983 935 if (FAILED(hr)) 984 936 { 985 WARN("Failed to initialize resource, returning %#x\n", hr);937 WARN("Failed to initialize surface, returning %#x.\n", hr); 986 938 HeapFree(GetProcessHeap(), 0, object); 987 939 *ppSurface = NULL; … … 989 941 } 990 942 991 TRACE("(%p) : Created resource %p\n", This, object);943 TRACE("(%p) : Created surface %p\n", This, object); 992 944 993 945 *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 properly1014 * 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 }1063 946 1064 947 return hr; … … 2126 2009 } 2127 2010 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); 2131 2013 if(FAILED(hr)) { 2132 2014 ERR("Wine logo requested, but failed to create surface\n"); … … 2158 2040 } 2159 2041 2042 /* Context activation is done by the caller. */ 2160 2043 static void create_dummy_textures(IWineD3DDeviceImpl *This) { 2161 2044 unsigned int i; … … 2264 2147 } 2265 2148 2266 /* Setup the implicit swapchain */2149 /* Setup the implicit swapchain. This also initializes a context. */ 2267 2150 TRACE("Creating implicit swapchain\n"); 2268 2151 hr = IWineD3DDeviceParent_CreateSwapChain(This->device_parent, … … 2356 2239 IWineD3DDevice_Clear((IWineD3DDevice *) This, 0, NULL, 2357 2240 WINED3DCLEAR_TARGET | pPresentationParameters->EnableAutoDepthStencil ? WINED3DCLEAR_ZBUFFER | WINED3DCLEAR_STENCIL : 0, 2358 0x00, 1.0 , 0);2241 0x00, 1.0f, 0); 2359 2242 2360 2243 This->d3d_initialized = TRUE; … … 2931 2814 * most wanted 2932 2815 */ 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 { 2934 2818 WARN("Attenuation is negative, returning WINED3DERR_INVALIDCALL\n"); 2935 2819 return WINED3DERR_INVALIDCALL; … … 2993 2877 object->lightPosn[1] = -pLight->Direction.y; 2994 2878 object->lightPosn[2] = -pLight->Direction.z; 2995 object->lightPosn[3] = 0.0 ;2879 object->lightPosn[3] = 0.0f; 2996 2880 object->exponent = 0.0f; 2997 2881 object->cutoff = 180.0f; … … 3003 2887 object->lightPosn[1] = pLight->Position.y; 3004 2888 object->lightPosn[2] = pLight->Position.z; 3005 object->lightPosn[3] = 1.0 ;2889 object->lightPosn[3] = 1.0f; 3006 2890 3007 2891 /* Direction */ … … 3009 2893 object->lightDirn[1] = pLight->Direction.y; 3010 2894 object->lightDirn[2] = pLight->Direction.z; 3011 object->lightDirn[3] = 1.0 ;2895 object->lightDirn[3] = 1.0f; 3012 2896 3013 2897 /* … … 3024 2908 * rest of the rather complex calculation 3025 2909 */ 3026 object->exponent = 0 ;2910 object->exponent = 0.0f; 3027 2911 } else { 3028 2912 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; 3034 2919 } 3035 2920 object->cutoff = pLight->Phi*90/M_PI; … … 3081 2966 struct list *e; 3082 2967 TRACE("(%p) : Idx(%d), enable? %d\n", This, Index, Enable); 3083 3084 /* Tests show true = 128...not clear why */3085 Enable = Enable? 128: 0;3086 2968 3087 2969 LIST_FOR_EACH(e, &This->updateStateBlock->lightMap[Hi]) { … … 4172 4054 } 4173 4055 4056 /* Context activation is done by the caller. */ 4174 4057 #define copy_and_next(dest, src, size) memcpy(dest, src, size); dest += (size) 4175 4058 static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCount, … … 4299 4182 4300 4183 /* 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); 4305 4188 4306 4189 TRACE("x=%f y=%f z=%f rhw=%f\n", x, y, z, rhw); … … 5865 5748 ****************************************/ 5866 5749 IWineD3DSurfaceImpl *pSrcSurface = (IWineD3DSurfaceImpl *)pSourceSurface; 5750 IWineD3DSurfaceImpl *dst_impl = (IWineD3DSurfaceImpl *)pDestinationSurface; 5867 5751 int srcWidth, srcHeight; 5868 5752 unsigned int srcSurfaceWidth, srcSurfaceHeight, destSurfaceWidth, destSurfaceHeight; … … 5873 5757 int offset = 0; 5874 5758 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;5876 5759 const struct GlPixelFormatDesc *src_format_desc, *dst_format_desc; 5877 5760 GLenum dummy; … … 5883 5766 5884 5767 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;5890 5768 5891 5769 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; 5898 5774 5899 5775 IWineD3DSurface_GetDesc(pDestinationSurface, &winedesc); 5776 destSurfaceWidth = winedesc.width; 5777 destSurfaceHeight = winedesc.height; 5778 destPool = winedesc.pool; 5779 destFormat = winedesc.format; 5780 destSize = winedesc.size; 5900 5781 5901 5782 if(srcPool != WINED3DPOOL_SYSTEMMEM || destPool != WINED3DPOOL_DEFAULT){ … … 5908 5789 * copy in sysmem and use regular surface loading. 5909 5790 */ 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); 5912 5792 if(convert != NO_CONVERSION) { 5913 5793 return IWineD3DSurface_BltFast(pDestinationSurface, … … 5936 5816 IWineD3DSurface_BindTexture(pDestinationSurface, FALSE); 5937 5817 5938 IWineD3DSurface_GetGlDesc(pDestinationSurface, &glDescription);5939 5940 5818 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; 5942 5820 5943 5821 /* this needs to be done in lines if the sourceRect != the sourceWidth */ … … 5962 5840 } 5963 5841 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, 5965 5843 dst_format_desc->glType, IWineD3DSurface_GetData(pSourceSurface), offset); 5966 5844 … … 5984 5862 for (j = destTop; j < (srcHeight + destTop); ++j) 5985 5863 { 5986 glTexSubImage2D( glDescription->target, glDescription->level, destLeft, j,5864 glTexSubImage2D(dst_impl->texture_target, dst_impl->texture_level, destLeft, j, 5987 5865 srcWidth, 1, dst_format_desc->glFormat, dst_format_desc->glType,data); 5988 5866 data += rowoffset; … … 5992 5870 const unsigned char* data = ((const unsigned char *)IWineD3DSurface_GetData(pSourceSurface)) + offset; 5993 5871 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"); 6011 5878 } 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, 6016 5892 srcWidth, srcHeight, dst_format_desc->glFormat, dst_format_desc->glType, data); 6017 5893 } … … 6175 6051 ActivateContext(This, surface, CTXUSAGE_RESOURCELOAD); 6176 6052 ENTER_GL(); 6177 GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));6053 context_bind_fbo(This->activeContext, GL_FRAMEBUFFER_EXT, NULL); 6178 6054 buffer = surface_get_gl_buffer(surface, swapchain); 6179 6055 glDrawBuffer(buffer); … … 6184 6060 ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD); 6185 6061 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); 6190 6065 } 6191 6066 … … 6216 6091 6217 6092 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); 6219 6094 } else { 6220 GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)); 6221 checkGLcall("glBindFramebuffer()"); 6095 context_bind_fbo(This->activeContext, GL_FRAMEBUFFER_EXT, NULL); 6222 6096 } 6223 6097 … … 6397 6271 WARN("Converting to WINED3DCOLOR, this might give incorrect results\n"); 6398 6272 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; 6403 6277 6404 6278 /* Just forward this to the DirectDraw blitting engine */ … … 6491 6365 * This function is called by IDirect3D7::CreateDevice so in theory its initialization code 6492 6366 */ 6367 WARN("No active context?\n"); 6368 6493 6369 ENTER_GL(); 6494 6370 if(!Swapchain->backBuffer[0]) { … … 6572 6448 /* Attach src surface to src fbo */ 6573 6449 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 6574 6456 if (src_swapchain) { 6575 6457 GLenum buffer = surface_get_gl_buffer(src_surface, src_swapchain); 6576 6458 6577 6459 TRACE("Source surface %p is onscreen\n", src_surface); 6578 ActivateContext(This, src_surface, CTXUSAGE_RESOURCELOAD);6579 6460 /* Make sure the drawable is up to date. In the offscreen case 6580 6461 * attach_surface_fbo() implicitly takes care of this. */ … … 6596 6477 6597 6478 ENTER_GL(); 6598 GL_EXTCALL(glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0));6479 context_bind_fbo(This->activeContext, GL_READ_FRAMEBUFFER_EXT, NULL); 6599 6480 glReadBuffer(buffer); 6600 6481 checkGLcall("glReadBuffer()"); … … 6602 6483 TRACE("Source surface %p is offscreen\n", src_surface); 6603 6484 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); 6606 6487 glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); 6607 6488 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); 6610 6490 } 6611 6491 LEAVE_GL(); 6612 6492 6613 6493 /* Attach dst surface to dst fbo */ 6614 dst_swapchain = get_swapchain(dst_surface);6615 6494 if (dst_swapchain) { 6616 6495 GLenum buffer = surface_get_gl_buffer(dst_surface, dst_swapchain); 6617 6496 6618 6497 TRACE("Destination surface %p is onscreen\n", dst_surface); 6619 ActivateContext(This, dst_surface, CTXUSAGE_RESOURCELOAD);6620 6498 /* Make sure the drawable is up to date. In the offscreen case 6621 6499 * attach_surface_fbo() implicitly takes care of this. */ … … 6638 6516 6639 6517 ENTER_GL(); 6640 GL_EXTCALL(glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0));6518 context_bind_fbo(This->activeContext, GL_DRAW_FRAMEBUFFER_EXT, NULL); 6641 6519 glDrawBuffer(buffer); 6642 6520 checkGLcall("glDrawBuffer()"); … … 6644 6522 TRACE("Destination surface %p is offscreen\n", dst_surface); 6645 6523 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 6651 6524 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); 6654 6527 glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); 6655 6528 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); 6658 6530 } 6659 6531 glDisable(GL_SCISSOR_TEST); … … 6673 6545 6674 6546 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); 6676 6548 } else { 6677 GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)); 6678 checkGLcall("glBindFramebuffer()"); 6549 context_bind_fbo(This->activeContext, GL_FRAMEBUFFER_EXT, NULL); 6679 6550 } 6680 6551 … … 6855 6726 memcpy(&mem[width * bpp * i], &bits[rect.Pitch * i], width * bpp); 6856 6727 IWineD3DSurface_UnlockRect(pCursorBitmap); 6728 6729 ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD); 6730 6857 6731 ENTER_GL(); 6858 6732 … … 7003 6877 } 7004 6878 6879 static 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 } 7005 6888 7006 6889 static HRESULT WINAPI IWineD3DDeviceImpl_EvictManagedResources(IWineD3DDevice* iface) { 7007 6890 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); 7013 6894 return WINED3D_OK; 7014 6895 } … … 7045 6926 surface->glRect.bottom = surface->pow2Height; 7046 6927 7047 if(surface->glDescription.textureName) { 6928 if (surface->texture_name) 6929 { 7048 6930 ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD); 7049 6931 ENTER_GL(); 7050 glDeleteTextures(1, &surface-> glDescription.textureName);6932 glDeleteTextures(1, &surface->texture_name); 7051 6933 LEAVE_GL(); 7052 surface-> glDescription.textureName = 0;6934 surface->texture_name = 0; 7053 6935 surface->Flags &= ~SFLAG_CLIENT; 7054 6936 } … … 7110 6992 UINT i; 7111 6993 IWineD3DBaseShaderImpl *shader; 6994 6995 ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD); 7112 6996 7113 6997 IWineD3DDevice_EnumResources(iface, reset_unload_resources, NULL); … … 7465 7349 unsigned int i; 7466 7350 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 { 7500 7353 for (i = 0; i < GL_LIMITS(buffers); ++i) { 7501 7354 if (This->render_targets[i] == (IWineD3DSurface *)resource) {
Note:
See TracChangeset
for help on using the changeset viewer.