HRESULT WINAPI NineTexture9_AddDirtyRect( struct NineTexture9 *This, const RECT *pDirtyRect ) { DBG("This=%p pDirtyRect=%p[(%u,%u)-(%u,%u)]\n", This, pDirtyRect, pDirtyRect ? pDirtyRect->left : 0, pDirtyRect ? pDirtyRect->top : 0, pDirtyRect ? pDirtyRect->right : 0, pDirtyRect ? pDirtyRect->bottom : 0); /* Tracking dirty regions on DEFAULT or SYSTEMMEM resources is pointless, * because we always write to the final storage. Just marked it dirty in * case we need to generate mip maps. */ if (This->base.base.pool != D3DPOOL_MANAGED) { if (This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP) This->base.dirty_mip = TRUE; return D3D_OK; } This->base.managed.dirty = TRUE; BASETEX_REGISTER_UPDATE(&This->base); if (!pDirtyRect) { u_box_origin_2d(This->base.base.info.width0, This->base.base.info.height0, &This->dirty_rect); } else { struct pipe_box box; rect_to_pipe_box_clamp(&box, pDirtyRect); u_box_union_2d(&This->dirty_rect, &This->dirty_rect, &box); (void) u_box_clip_2d(&This->dirty_rect, &This->dirty_rect, This->base.base.info.width0, This->base.base.info.height0); } return D3D_OK; }
HRESULT NINE_WINAPI NineCubeTexture9_AddDirtyRect( struct NineCubeTexture9 *This, D3DCUBEMAP_FACES FaceType, const RECT *pDirtyRect ) { DBG("This=%p FaceType=%d pDirtyRect=%p\n", This, FaceType, pDirtyRect); user_assert(FaceType < 6, D3DERR_INVALIDCALL); if (This->base.base.pool != D3DPOOL_MANAGED) { if (This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP) { This->base.dirty_mip = TRUE; BASETEX_REGISTER_UPDATE(&This->base); } return D3D_OK; } if (This->base.base.pool == D3DPOOL_MANAGED) { This->base.managed.dirty = TRUE; BASETEX_REGISTER_UPDATE(&This->base); } if (!pDirtyRect) { u_box_origin_2d(This->base.base.info.width0, This->base.base.info.height0, &This->dirty_rect[FaceType]); } else { struct pipe_box box; rect_to_pipe_box_clamp(&box, pDirtyRect); u_box_union_2d(&This->dirty_rect[FaceType], &This->dirty_rect[FaceType], &box); (void) u_box_clip_2d(&This->dirty_rect[FaceType], &This->dirty_rect[FaceType], This->base.base.info.width0, This->base.base.info.height0); } return D3D_OK; }
HRESULT NINE_WINAPI NineBuffer9_Lock( struct NineBuffer9 *This, UINT OffsetToLock, UINT SizeToLock, void **ppbData, DWORD Flags ) { struct pipe_box box; void *data; unsigned usage = d3dlock_buffer_to_pipe_transfer_usage(Flags); DBG("This=%p(pipe=%p) OffsetToLock=0x%x, SizeToLock=0x%x, Flags=0x%x\n", This, This->base.resource, OffsetToLock, SizeToLock, Flags); user_assert(ppbData, E_POINTER); user_assert(!(Flags & ~(D3DLOCK_DISCARD | D3DLOCK_DONOTWAIT | D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY | D3DLOCK_NOOVERWRITE)), D3DERR_INVALIDCALL); if (SizeToLock == 0) { SizeToLock = This->size - OffsetToLock; user_warn(OffsetToLock != 0); } u_box_1d(OffsetToLock, SizeToLock, &box); if (This->base.pool == D3DPOOL_MANAGED) { if (!This->managed.dirty) { assert(LIST_IS_EMPTY(&This->managed.list)); list_add(&This->managed.list, &This->base.base.device->update_buffers); This->managed.dirty = TRUE; This->managed.dirty_box = box; } else { u_box_union_2d(&This->managed.dirty_box, &This->managed.dirty_box, &box); } *ppbData = (char *)This->managed.data + OffsetToLock; DBG("returning pointer %p\n", *ppbData); This->nmaps++; return D3D_OK; } if (This->nmaps == This->maxmaps) { struct pipe_transfer **newmaps = REALLOC(This->maps, sizeof(struct pipe_transfer *)*This->maxmaps, sizeof(struct pipe_transfer *)*(This->maxmaps << 1)); if (newmaps == NULL) return E_OUTOFMEMORY; This->maxmaps <<= 1; This->maps = newmaps; } data = This->pipe->transfer_map(This->pipe, This->base.resource, 0, usage, &box, &This->maps[This->nmaps]); if (!data) { DBG("pipe::transfer_map failed\n" " usage = %x\n" " box.x = %u\n" " box.width = %u\n", usage, box.x, box.width); /* not sure what to return, msdn suggests this */ if (Flags & D3DLOCK_DONOTWAIT) return D3DERR_WASSTILLDRAWING; return D3DERR_INVALIDCALL; } DBG("returning pointer %p\n", data); This->nmaps++; *ppbData = data; return D3D_OK; }