static HRESULT STDMETHODCALLTYPE d3d10_texture3d_Map(ID3D10Texture3D *iface, UINT sub_resource_idx, D3D10_MAP map_type, UINT map_flags, D3D10_MAPPED_TEXTURE3D *mapped_texture) { struct d3d10_texture3d *texture = impl_from_ID3D10Texture3D(iface); struct wined3d_map_desc wined3d_map_desc; struct wined3d_resource *sub_resource; HRESULT hr; TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, mapped_texture %p.\n", iface, sub_resource_idx, map_type, map_flags, mapped_texture); if (map_type != D3D10_MAP_READ_WRITE) FIXME("Ignoring map_type %#x.\n", map_type); if (map_flags) FIXME("Ignoring map_flags %#x.\n", map_flags); if (!(sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, sub_resource_idx))) hr = E_INVALIDARG; else if (SUCCEEDED(hr = wined3d_volume_map(wined3d_volume_from_resource(sub_resource), &wined3d_map_desc, NULL, 0))) { mapped_texture->pData = wined3d_map_desc.data; mapped_texture->RowPitch = wined3d_map_desc.row_pitch; mapped_texture->DepthPitch = wined3d_map_desc.slice_pitch; } return hr; }
static HRESULT WINAPI IDirect3DVolume9Impl_LockBox(IDirect3DVolume9 *iface, D3DLOCKED_BOX *pLockedVolume, const D3DBOX *pBox, DWORD Flags) { IDirect3DVolume9Impl *This = impl_from_IDirect3DVolume9(iface); HRESULT hr; TRACE("iface %p, locked_box %p, box %p, flags %#x.\n", iface, pLockedVolume, pBox, Flags); wined3d_mutex_lock(); hr = wined3d_volume_map(This->wined3d_volume, (struct wined3d_mapped_box *)pLockedVolume, (const struct wined3d_box *)pBox, Flags); wined3d_mutex_unlock(); return hr; }
static HRESULT WINAPI d3d8_volume_LockBox(IDirect3DVolume8 *iface, D3DLOCKED_BOX *locked_box, const D3DBOX *box, DWORD flags) { struct d3d8_volume *volume = impl_from_IDirect3DVolume8(iface); struct wined3d_map_desc map_desc; HRESULT hr; TRACE("iface %p, locked_box %p, box %p, flags %#x.\n", iface, locked_box, box, flags); wined3d_mutex_lock(); hr = wined3d_volume_map(volume->wined3d_volume, &map_desc, (const struct wined3d_box *)box, flags); wined3d_mutex_unlock(); locked_box->RowPitch = map_desc.row_pitch; locked_box->SlicePitch = map_desc.slice_pitch; locked_box->pBits = map_desc.data; return hr; }
HRESULT CDECL wined3d_device_blt_vol(struct wined3d_device *device, struct wined3d_volume *src, struct wined3d_volume *dst, const struct wined3d_box *pSrcBoxArg, const VBOXPOINT3D *pDstPoin3D) { struct wined3d_map_desc src_desc, dst_desc; HRESULT hr; struct wined3d_box DstBox, SrcBox; const struct wined3d_box *pDstBox; const struct wined3d_box *pSrcBox; int dstW, dstH, dstD, srcW, srcH, srcD; int j, k; uint8_t * pDstBits; uint8_t * pSrcBits; TRACE("device %p, src_volume %p, dst_volume %p.\n", device, src, dst); pSrcBox = pSrcBoxArg; if (!pSrcBox) { SrcBox.left = 0; SrcBox.top = 0; SrcBox.front = 0; SrcBox.right = src->resource.width; SrcBox.bottom = src->resource.height; SrcBox.back = src->resource.depth; pSrcBox = &SrcBox; } if (!pDstPoin3D) pDstBox = pSrcBox; else { vboxWddmBoxTranslated((VBOXBOX3D*)&DstBox, (const VBOXBOX3D *)pSrcBox, pDstPoin3D->x, pDstPoin3D->y, pDstPoin3D->z); pDstBox = &DstBox; } dstW = pDstBox->right - pDstBox->left; dstH = pDstBox->bottom - pDstBox->top; dstD = pDstBox->back - pDstBox->front; srcW = pSrcBox->right - pSrcBox->left; srcH = pSrcBox->bottom - pSrcBox->top; srcD = pSrcBox->back - pSrcBox->front; if (srcW != dstW || srcH != dstH || srcD != dstD) { ERR("dimensions do not match, stretching not supported for volumes!"); return WINED3DERR_INVALIDCALL; } /* TODO: Implement direct loading into the gl volume instead of using memcpy and * dirtification to improve loading performance. */ hr = wined3d_volume_map(src, &src_desc, pSrcBox, WINED3D_MAP_READONLY); if(FAILED(hr)) { ERR("wined3d_volume_map src failed"); return hr; } hr = wined3d_volume_map(dst, &dst_desc, pDstBox, WINED3D_MAP_DISCARD); if(FAILED(hr)) { ERR("wined3d_volume_map dst failed"); wined3d_volume_unmap(src); return hr; } pDstBits = dst_desc.data; pSrcBits = src_desc.data; for (k = 0; k < srcD; ++k) { uint8_t * pRowDstBits = pDstBits; uint8_t * pRowSrcBits = pSrcBits; for (j = 0; j < srcH; ++j) { memcpy(pRowDstBits, pRowSrcBits, srcW * dst->resource.format->byte_count); pRowDstBits += dst_desc.row_pitch; pRowSrcBits += src_desc.row_pitch; } pDstBits += dst_desc.slice_pitch; pSrcBits += src_desc.slice_pitch; } hr = wined3d_volume_unmap(dst); if(FAILED(hr)) { wined3d_volume_unmap(src); } else { hr = wined3d_volume_unmap(src); } return hr; }