diff options
author | Axel Davy <[email protected]> | 2016-02-06 13:39:58 +0100 |
---|---|---|
committer | Axel Davy <[email protected]> | 2016-02-12 23:26:36 +0100 |
commit | cc0114f30b587a10766ec212afb3ad356099ef23 (patch) | |
tree | 0a1c7bb8e508d73a04977e85af25c2a6eaa9cd68 /src/gallium/state_trackers/nine/buffer9.h | |
parent | 77d6c11f8fa87ba1070028cb036807dc8a115633 (diff) |
st/nine: Implement Managed vertex/index buffers
We were implementing those the same way than
the default pool, which is sub-optimal.
The buffer is supposed to return pointer to
a ram copy when user locks, and automatically
update the vram copy when needed.
v2: Rename NineBuffer9_Validate to NineBuffer9_Upload
Rename validate_buffers to update_managed_buffers
Initialize NineBuffer9 managed fields after the resource
is allocated. In case of allocation failure, when the dtor
is executed, This->base.pool is then rightfully set.
Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers/nine/buffer9.h')
-rw-r--r-- | src/gallium/state_trackers/nine/buffer9.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/nine/buffer9.h b/src/gallium/state_trackers/nine/buffer9.h index 955b8193f9c..8bdb4326a4c 100644 --- a/src/gallium/state_trackers/nine/buffer9.h +++ b/src/gallium/state_trackers/nine/buffer9.h @@ -25,6 +25,9 @@ #define _NINE_BUFFER9_H_ #include "resource9.h" +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "util/list.h" struct pipe_screen; struct pipe_context; @@ -39,6 +42,15 @@ struct NineBuffer9 struct pipe_transfer **maps; int nmaps, maxmaps; UINT size; + + /* Specific to managed buffers */ + struct { + void *data; + boolean dirty; + struct pipe_box dirty_box; + struct list_head list; /* for update_buffers */ + struct list_head list2; /* for managed_buffers */ + } managed; }; static inline struct NineBuffer9 * NineBuffer9( void *data ) @@ -70,4 +82,20 @@ NineBuffer9_Lock( struct NineBuffer9 *This, HRESULT NINE_WINAPI NineBuffer9_Unlock( struct NineBuffer9 *This ); +static inline void +NineBuffer9_Upload( struct NineBuffer9 *This ) +{ + struct pipe_context *pipe = This->pipe; + + assert(This->base.pool == D3DPOOL_MANAGED && This->managed.dirty); + pipe->transfer_inline_write(pipe, This->base.resource, 0, 0, + &This->managed.dirty_box, + (char *)This->managed.data + This->managed.dirty_box.x, + This->size, This->size); + This->managed.dirty = FALSE; +} + +void +NineBuffer9_SetDirty( struct NineBuffer9 *This ); + #endif /* _NINE_BUFFER9_H_ */ |