2 * Copyright 2012 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 #include "util/format/u_format.h"
27 #include "util/u_inlines.h"
29 #include "nv30/nv30_screen.h"
30 #include "nv30/nv30_context.h"
31 #include "nv30/nv30_resource.h"
32 #include "nv30/nv30_transfer.h"
35 nv30_memory_barrier(struct pipe_context
*pipe
, unsigned flags
)
37 struct nv30_context
*nv30
= nv30_context(pipe
);
40 if (flags
& PIPE_BARRIER_MAPPED_BUFFER
) {
41 for (i
= 0; i
< nv30
->num_vtxbufs
; ++i
) {
42 if (!nv30
->vtxbuf
[i
].buffer
.resource
)
44 if (nv30
->vtxbuf
[i
].buffer
.resource
->flags
& PIPE_RESOURCE_FLAG_MAP_PERSISTENT
)
45 nv30
->base
.vbo_dirty
= true;
50 static struct pipe_resource
*
51 nv30_resource_create(struct pipe_screen
*pscreen
,
52 const struct pipe_resource
*tmpl
)
54 switch (tmpl
->target
) {
56 return nouveau_buffer_create(pscreen
, tmpl
);
58 return nv30_miptree_create(pscreen
, tmpl
);
62 static struct pipe_resource
*
63 nv30_resource_from_handle(struct pipe_screen
*pscreen
,
64 const struct pipe_resource
*tmpl
,
65 struct winsys_handle
*handle
,
68 if (tmpl
->target
== PIPE_BUFFER
)
71 return nv30_miptree_from_handle(pscreen
, tmpl
, handle
);
75 nv30_resource_screen_init(struct pipe_screen
*pscreen
)
77 pscreen
->resource_create
= nv30_resource_create
;
78 pscreen
->resource_from_handle
= nv30_resource_from_handle
;
79 pscreen
->resource_get_handle
= u_resource_get_handle_vtbl
;
80 pscreen
->resource_destroy
= u_resource_destroy_vtbl
;
84 nv30_resource_init(struct pipe_context
*pipe
)
86 pipe
->transfer_map
= u_transfer_map_vtbl
;
87 pipe
->transfer_flush_region
= u_transfer_flush_region_vtbl
;
88 pipe
->transfer_unmap
= u_transfer_unmap_vtbl
;
89 pipe
->buffer_subdata
= u_default_buffer_subdata
;
90 pipe
->texture_subdata
= u_default_texture_subdata
;
91 pipe
->create_surface
= nv30_miptree_surface_new
;
92 pipe
->surface_destroy
= nv30_miptree_surface_del
;
93 pipe
->resource_copy_region
= nv30_resource_copy_region
;
94 pipe
->blit
= nv30_blit
;
95 pipe
->flush_resource
= nv30_flush_resource
;
96 pipe
->memory_barrier
= nv30_memory_barrier
;