summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util/u_surface.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/util/u_surface.c')
-rw-r--r--src/gallium/auxiliary/util/u_surface.c78
1 files changed, 46 insertions, 32 deletions
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index f78b6838a72..4eddd3f519e 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -42,6 +42,18 @@
#include "util/u_surface.h"
#include "util/u_pack_color.h"
+void
+u_surface_default_template(struct pipe_surface *view,
+ const struct pipe_resource *texture,
+ unsigned bind)
+{
+ view->format = texture->format;
+ view->u.tex.level = 0;
+ view->u.tex.first_layer = 0;
+ view->u.tex.last_layer = 0;
+ /* XXX should filter out all non-rt/ds bind flags ? */
+ view->usage = bind;
+}
/**
* Helper to quickly create an RGBA rendering surface of a certain size.
@@ -50,9 +62,9 @@
* \return TRUE for success, FALSE if failure
*/
boolean
-util_create_rgba_surface(struct pipe_screen *screen,
+util_create_rgba_surface(struct pipe_context *pipe,
uint width, uint height,
- uint bind,
+ uint bind,
struct pipe_resource **textureOut,
struct pipe_surface **surfaceOut)
{
@@ -65,6 +77,8 @@ util_create_rgba_surface(struct pipe_screen *screen,
const uint target = PIPE_TEXTURE_2D;
enum pipe_format format = PIPE_FORMAT_NONE;
struct pipe_resource templ;
+ struct pipe_surface surf_templ;
+ struct pipe_screen *screen = pipe->screen;
uint i;
/* Choose surface format */
@@ -86,17 +100,20 @@ util_create_rgba_surface(struct pipe_screen *screen,
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
+ templ.array_size = 1;
templ.bind = bind;
*textureOut = screen->resource_create(screen, &templ);
if (!*textureOut)
return FALSE;
+ /* create surface */
+ memset(&surf_templ, 0, sizeof(surf_templ));
+ u_surface_default_template(&surf_templ, *textureOut, bind);
/* create surface / view into texture */
- *surfaceOut = screen->get_tex_surface(screen,
- *textureOut,
- 0, 0, 0,
- bind);
+ *surfaceOut = pipe->create_surface(pipe,
+ *textureOut,
+ &surf_templ);
if (!*surfaceOut) {
pipe_resource_reference(textureOut, NULL);
return FALSE;
@@ -126,17 +143,18 @@ util_destroy_rgba_surface(struct pipe_resource *texture,
void
util_resource_copy_region(struct pipe_context *pipe,
struct pipe_resource *dst,
- struct pipe_subresource subdst,
+ unsigned dst_level,
unsigned dst_x, unsigned dst_y, unsigned dst_z,
struct pipe_resource *src,
- struct pipe_subresource subsrc,
- unsigned src_x, unsigned src_y, unsigned src_z,
- unsigned w, unsigned h)
+ unsigned src_level,
+ const struct pipe_box *src_box)
{
struct pipe_transfer *src_trans, *dst_trans;
void *dst_map;
const void *src_map;
enum pipe_format src_format, dst_format;
+ unsigned w = src_box->width;
+ unsigned h = src_box->height;
assert(src && dst);
if (!src || !dst)
@@ -146,20 +164,18 @@ util_resource_copy_region(struct pipe_context *pipe,
dst_format = dst->format;
src_trans = pipe_get_transfer(pipe,
- src,
- subsrc.face,
- subsrc.level,
- src_z,
- PIPE_TRANSFER_READ,
- src_x, src_y, w, h);
+ src,
+ src_level,
+ src_box->z,
+ PIPE_TRANSFER_READ,
+ src_box->x, src_box->y, w, h);
dst_trans = pipe_get_transfer(pipe,
- dst,
- subdst.face,
- subdst.level,
- src_z,
- PIPE_TRANSFER_WRITE,
- dst_x, dst_y, w, h);
+ dst,
+ dst_level,
+ dst_z,
+ PIPE_TRANSFER_WRITE,
+ dst_x, dst_y, w, h);
assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format));
assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format));
@@ -216,14 +232,13 @@ util_clear_render_target(struct pipe_context *pipe,
assert(dst->texture);
if (!dst->texture)
return;
-
+ /* XXX: should handle multiple layers */
dst_trans = pipe_get_transfer(pipe,
- dst->texture,
- dst->face,
- dst->level,
- dst->zslice,
- PIPE_TRANSFER_WRITE,
- dstx, dsty, width, height);
+ dst->texture,
+ dst->u.tex.level,
+ dst->u.tex.first_layer,
+ PIPE_TRANSFER_WRITE,
+ dstx, dsty, width, height);
dst_map = pipe->transfer_map(pipe, dst_trans);
@@ -271,9 +286,8 @@ util_clear_depth_stencil(struct pipe_context *pipe,
return;
dst_trans = pipe_get_transfer(pipe,
dst->texture,
- dst->face,
- dst->level,
- dst->zslice,
+ dst->u.tex.level,
+ dst->u.tex.first_layer,
(need_rmw ? PIPE_TRANSFER_READ_WRITE :
PIPE_TRANSFER_WRITE),
dstx, dsty, width, height);