2 /**************************************************************************
4 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
29 #include "nv30_context.h"
30 #include "pipe/p_defines.h"
31 #include "pipe/p_util.h"
32 #include "pipe/p_winsys.h"
33 #include "pipe/p_inlines.h"
34 #include "util/p_tile.h"
37 nv30_surface_format_supported(struct pipe_context
*pipe
,
38 enum pipe_format format
, uint type
)
43 case PIPE_FORMAT_A8R8G8B8_UNORM
:
44 case PIPE_FORMAT_R5G6B5_UNORM
:
45 case PIPE_FORMAT_Z24S8_UNORM
:
46 case PIPE_FORMAT_Z16_UNORM
:
54 case PIPE_FORMAT_A8R8G8B8_UNORM
:
55 case PIPE_FORMAT_A1R5G5B5_UNORM
:
56 case PIPE_FORMAT_A4R4G4B4_UNORM
:
57 case PIPE_FORMAT_R5G6B5_UNORM
:
58 case PIPE_FORMAT_U_L8
:
59 case PIPE_FORMAT_U_A8
:
60 case PIPE_FORMAT_U_I8
:
61 case PIPE_FORMAT_U_A8_L8
:
62 case PIPE_FORMAT_Z16_UNORM
:
63 case PIPE_FORMAT_Z24S8_UNORM
:
76 static struct pipe_surface
*
77 nv30_get_tex_surface(struct pipe_context
*pipe
, struct pipe_texture
*pt
,
78 unsigned face
, unsigned level
, unsigned zslice
)
80 struct pipe_winsys
*ws
= pipe
->winsys
;
81 struct nv30_miptree
*nv30mt
= (struct nv30_miptree
*)pt
;
82 struct pipe_surface
*ps
;
84 ps
= ws
->surface_alloc(ws
);
87 pipe_buffer_reference(ws
, &ps
->buffer
, nv30mt
->buffer
);
88 ps
->format
= pt
->format
;
90 ps
->width
= pt
->width
[level
];
91 ps
->height
= pt
->height
[level
];
92 ps
->pitch
= nv30mt
->level
[level
].pitch
/ ps
->cpp
;
94 if (pt
->target
== PIPE_TEXTURE_CUBE
) {
95 ps
->offset
= nv30mt
->level
[level
].image_offset
[face
];
97 if (pt
->target
== PIPE_TEXTURE_3D
) {
98 ps
->offset
= nv30mt
->level
[level
].image_offset
[zslice
];
100 ps
->offset
= nv30mt
->level
[level
].image_offset
[0];
107 nv30_surface_copy(struct pipe_context
*pipe
, unsigned do_flip
,
108 struct pipe_surface
*dest
, unsigned destx
, unsigned desty
,
109 struct pipe_surface
*src
, unsigned srcx
, unsigned srcy
,
110 unsigned width
, unsigned height
)
112 struct nv30_context
*nv30
= nv30_context(pipe
);
113 struct nouveau_winsys
*nvws
= nv30
->nvws
;
115 nvws
->surface_copy(nvws
, dest
, destx
, desty
, src
, srcx
, srcy
,
120 nv30_surface_fill(struct pipe_context
*pipe
, struct pipe_surface
*dest
,
121 unsigned destx
, unsigned desty
, unsigned width
,
122 unsigned height
, unsigned value
)
124 struct nv30_context
*nv30
= nv30_context(pipe
);
125 struct nouveau_winsys
*nvws
= nv30
->nvws
;
127 nvws
->surface_fill(nvws
, dest
, destx
, desty
, width
, height
, value
);
131 nv30_init_surface_functions(struct nv30_context
*nv30
)
133 nv30
->pipe
.is_format_supported
= nv30_surface_format_supported
;
134 nv30
->pipe
.get_tex_surface
= nv30_get_tex_surface
;
135 nv30
->pipe
.surface_copy
= nv30_surface_copy
;
136 nv30
->pipe
.surface_fill
= nv30_surface_fill
;