wined3d: Add a function for initializing surface sysmem.
This commit is contained in:
parent
7c2e09615c
commit
54f0d3f785
|
@ -6514,7 +6514,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EvictManagedResources(IWineD3DDevice*
|
||||||
return WINED3D_OK;
|
return WINED3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRESENT_PARAMETERS* pPresentationParameters)
|
static HRESULT updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRESENT_PARAMETERS* pPresentationParameters)
|
||||||
{
|
{
|
||||||
IWineD3DDeviceImpl *device = surface->resource.wineD3DDevice;
|
IWineD3DDeviceImpl *device = surface->resource.wineD3DDevice;
|
||||||
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
|
||||||
|
@ -6567,12 +6567,14 @@ static void updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRESENT
|
||||||
surface->resource.allocatedMemory = NULL;
|
surface->resource.allocatedMemory = NULL;
|
||||||
surface->resource.heapMemory = NULL;
|
surface->resource.heapMemory = NULL;
|
||||||
surface->resource.size = IWineD3DSurface_GetPitch((IWineD3DSurface *) surface) * surface->pow2Width;
|
surface->resource.size = IWineD3DSurface_GetPitch((IWineD3DSurface *) surface) * surface->pow2Width;
|
||||||
/* INDRAWABLE is a sane place for implicit targets after the reset, INSYSMEM is more appropriate for depth stencils. */
|
|
||||||
if (surface->resource.usage & WINED3DUSAGE_DEPTHSTENCIL) {
|
/* Put all surfaces into sysmem - the drawable might disappear if the backbuffer was rendered
|
||||||
IWineD3DSurface_ModifyLocation((IWineD3DSurface *) surface, SFLAG_INSYSMEM, TRUE);
|
* to a FBO */
|
||||||
} else {
|
if(!surface_init_sysmem((IWineD3DSurface *) surface))
|
||||||
IWineD3DSurface_ModifyLocation((IWineD3DSurface *) surface, SFLAG_INDRAWABLE, TRUE);
|
{
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
return WINED3D_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT WINAPI reset_unload_resources(IWineD3DResource *resource, void *data) {
|
static HRESULT WINAPI reset_unload_resources(IWineD3DResource *resource, void *data) {
|
||||||
|
@ -6830,12 +6832,28 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRE
|
||||||
swapchain->presentParms.BackBufferWidth = pPresentationParameters->BackBufferWidth;
|
swapchain->presentParms.BackBufferWidth = pPresentationParameters->BackBufferWidth;
|
||||||
swapchain->presentParms.BackBufferHeight = pPresentationParameters->BackBufferHeight;
|
swapchain->presentParms.BackBufferHeight = pPresentationParameters->BackBufferHeight;
|
||||||
|
|
||||||
updateSurfaceDesc((IWineD3DSurfaceImpl *)swapchain->frontBuffer, pPresentationParameters);
|
hr = updateSurfaceDesc((IWineD3DSurfaceImpl *)swapchain->frontBuffer, pPresentationParameters);
|
||||||
|
if(FAILED(hr))
|
||||||
|
{
|
||||||
|
IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
for(i = 0; i < swapchain->presentParms.BackBufferCount; i++) {
|
for(i = 0; i < swapchain->presentParms.BackBufferCount; i++) {
|
||||||
updateSurfaceDesc((IWineD3DSurfaceImpl *)swapchain->backBuffer[i], pPresentationParameters);
|
hr = updateSurfaceDesc((IWineD3DSurfaceImpl *)swapchain->backBuffer[i], pPresentationParameters);
|
||||||
|
if(FAILED(hr))
|
||||||
|
{
|
||||||
|
IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(This->auto_depth_stencil_buffer) {
|
if(This->auto_depth_stencil_buffer) {
|
||||||
updateSurfaceDesc((IWineD3DSurfaceImpl *)This->auto_depth_stencil_buffer, pPresentationParameters);
|
hr = updateSurfaceDesc((IWineD3DSurfaceImpl *)This->auto_depth_stencil_buffer, pPresentationParameters);
|
||||||
|
if(FAILED(hr))
|
||||||
|
{
|
||||||
|
IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -820,6 +820,30 @@ static void surface_remove_pbo(IWineD3DSurfaceImpl *This) {
|
||||||
This->Flags &= ~SFLAG_PBO;
|
This->Flags &= ~SFLAG_PBO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOL surface_init_sysmem(IWineD3DSurface *iface)
|
||||||
|
{
|
||||||
|
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
|
||||||
|
|
||||||
|
if(!This->resource.allocatedMemory)
|
||||||
|
{
|
||||||
|
This->resource.heapMemory = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, This->resource.size + RESOURCE_ALIGNMENT);
|
||||||
|
if(!This->resource.heapMemory)
|
||||||
|
{
|
||||||
|
ERR("Out of memory\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
This->resource.allocatedMemory =
|
||||||
|
(BYTE *)(((ULONG_PTR) This->resource.heapMemory + (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memset(This->resource.allocatedMemory, 0, This->resource.size);
|
||||||
|
}
|
||||||
|
|
||||||
|
IWineD3DSurface_ModifyLocation(iface, SFLAG_INSYSMEM, TRUE);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void WINAPI IWineD3DSurfaceImpl_UnLoad(IWineD3DSurface *iface) {
|
static void WINAPI IWineD3DSurfaceImpl_UnLoad(IWineD3DSurface *iface) {
|
||||||
IWineD3DBaseTexture *texture = NULL;
|
IWineD3DBaseTexture *texture = NULL;
|
||||||
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
|
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
|
||||||
|
@ -836,18 +860,12 @@ static void WINAPI IWineD3DSurfaceImpl_UnLoad(IWineD3DSurface *iface) {
|
||||||
* or depth stencil. The content may be destroyed, but we still have to tear down
|
* or depth stencil. The content may be destroyed, but we still have to tear down
|
||||||
* opengl resources, so we cannot leave early.
|
* opengl resources, so we cannot leave early.
|
||||||
*
|
*
|
||||||
* Put the most up to date surface location into the drawable. D3D-wise this content
|
* Put the surfaces into sysmem, and reset the content. The D3D content is undefined,
|
||||||
* is undefined, so it would be nowhere, but that would make the location management
|
* but we can't set the sysmem INDRAWABLE because when we're rendering the swapchain
|
||||||
* more complicated. The drawable is a sane location, because if we mark sysmem or
|
* or the depth stencil into an FBO the texture or render buffer will be removed
|
||||||
* texture up to date, drawPrim will copy the uninitialized texture or sysmem to the
|
* and all flags get lost
|
||||||
* uninitialized drawable. That's pointless and we'd have to allocate the texture /
|
|
||||||
* sysmem copy here.
|
|
||||||
*/
|
*/
|
||||||
if (This->resource.usage & WINED3DUSAGE_DEPTHSTENCIL) {
|
surface_init_sysmem(iface);
|
||||||
IWineD3DSurface_ModifyLocation(iface, SFLAG_INSYSMEM, TRUE);
|
|
||||||
} else {
|
|
||||||
IWineD3DSurface_ModifyLocation(iface, SFLAG_INDRAWABLE, TRUE);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* Load the surface into system memory */
|
/* Load the surface into system memory */
|
||||||
IWineD3DSurface_LoadLocation(iface, SFLAG_INSYSMEM, NULL);
|
IWineD3DSurface_LoadLocation(iface, SFLAG_INSYSMEM, NULL);
|
||||||
|
|
|
@ -1726,6 +1726,7 @@ typedef struct IWineD3DBaseTextureClass
|
||||||
} IWineD3DBaseTextureClass;
|
} IWineD3DBaseTextureClass;
|
||||||
|
|
||||||
void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN;
|
void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN;
|
||||||
|
BOOL surface_init_sysmem(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
typedef struct IWineD3DBaseTextureImpl
|
typedef struct IWineD3DBaseTextureImpl
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue