{
struct pipe_box box;
void *data;
- unsigned usage = d3dlock_buffer_to_pipe_transfer_usage(Flags);
+ unsigned usage;
DBG("This=%p(pipe=%p) OffsetToLock=0x%x, SizeToLock=0x%x, Flags=0x%x\n",
This, This->base.resource,
return D3D_OK;
}
+ /* Driver ddi doc: READONLY is never passed to the device. So it can only
+ * have effect on things handled by the driver (MANAGED pool for example).
+ * Msdn doc: DISCARD and NOOVERWRITE are only for DYNAMIC.
+ * ATI doc: You can use DISCARD and NOOVERWRITE without DYNAMIC.
+ * Msdn doc: D3DLOCK_DONOTWAIT is not among the valid flags for buffers.
+ * Our tests: On win 7 nvidia, D3DLOCK_DONOTWAIT does return
+ * D3DERR_WASSTILLDRAWING if the resource is in use, except for DYNAMIC.
+ * Our tests: some apps do use both DISCARD and NOOVERWRITE at the same
+ * time. On windows it seems to return different pointer, thus indicating
+ * DISCARD is taken into account. */
+
+ if (Flags & D3DLOCK_DISCARD)
+ usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
+ else if (Flags & D3DLOCK_NOOVERWRITE)
+ usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_UNSYNCHRONIZED;
+ else
+ usage = PIPE_TRANSFER_READ_WRITE;
+ if (Flags & D3DLOCK_DONOTWAIT && !(This->base.usage & D3DUSAGE_DYNAMIC))
+ usage |= PIPE_TRANSFER_DONTBLOCK;
+
if (This->nmaps == This->maxmaps) {
struct pipe_transfer **newmaps =
REALLOC(This->maps, sizeof(struct pipe_transfer *)*This->maxmaps,
" 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;
void nine_pipe_context_clear(struct NineDevice9 *);
-static inline unsigned d3dlock_buffer_to_pipe_transfer_usage(DWORD Flags)
-{
- unsigned usage;
-
- if (Flags & D3DLOCK_DISCARD)
- usage = PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE;
- else
- if (Flags & D3DLOCK_READONLY)
- usage = PIPE_TRANSFER_READ;
- else
- usage = PIPE_TRANSFER_READ_WRITE;
-
- if (Flags & D3DLOCK_NOOVERWRITE)
- usage = (PIPE_TRANSFER_UNSYNCHRONIZED |
- PIPE_TRANSFER_DISCARD_RANGE | usage) & ~PIPE_TRANSFER_READ;
- else
- if (Flags & D3DLOCK_DONOTWAIT)
- usage |= PIPE_TRANSFER_DONTBLOCK;
-
- /*
- if (Flags & D3DLOCK_NO_DIRTY_UPDATE)
- usage |= PIPE_TRANSFER_FLUSH_EXPLICIT;
- */
-
- return usage;
-}
-
static inline void
rect_to_pipe_box(struct pipe_box *dst, const RECT *src)
{