summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/i915/i915_surface.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/i915/i915_surface.c')
-rw-r--r--src/gallium/drivers/i915/i915_surface.c101
1 files changed, 38 insertions, 63 deletions
diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c
index 8a09f930a0..becc6e93c2 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -43,11 +43,10 @@
*/
static void
i915_surface_copy(struct pipe_context *pipe,
- struct pipe_resource *dst, struct pipe_subresource subdst,
+ struct pipe_resource *dst, unsigned dst_level,
unsigned dstx, unsigned dsty, unsigned dstz,
- struct pipe_resource *src, struct pipe_subresource subsrc,
- unsigned srcx, unsigned srcy, unsigned srcz,
- unsigned width, unsigned height)
+ struct pipe_resource *src, unsigned src_level,
+ const struct pipe_box *src_box)
{
struct i915_texture *dst_tex = i915_texture(dst);
struct i915_texture *src_tex = i915_texture(src);
@@ -55,29 +54,17 @@ i915_surface_copy(struct pipe_context *pipe,
struct pipe_resource *spt = &src_tex->b.b;
unsigned dst_offset, src_offset; /* in bytes */
- if (dst->target == PIPE_TEXTURE_CUBE) {
- dst_offset = i915_texture_offset(dst_tex, subdst.level, subdst.face);
- }
- else if (dst->target == PIPE_TEXTURE_3D) {
- dst_offset = i915_texture_offset(dst_tex, subdst.level, dstz);
- }
- else {
- dst_offset = i915_texture_offset(dst_tex, subdst.level, 0);
- assert(subdst.face == 0);
+ /* XXX cannot copy 3d regions at this time */
+ assert(src_box->depth == 1);
+ if (dst->target != PIPE_TEXTURE_CUBE &&
+ dst->target != PIPE_TEXTURE_3D)
assert(dstz == 0);
- }
- if (src->target == PIPE_TEXTURE_CUBE) {
- src_offset = i915_texture_offset(src_tex, subsrc.level, subsrc.face);
- }
- else if (src->target == PIPE_TEXTURE_3D) {
- src_offset = i915_texture_offset(src_tex, subsrc.level, srcz);
- }
- else {
- src_offset = i915_texture_offset(src_tex, subsrc.level, 0);
- assert(subsrc.face == 0);
- assert(srcz == 0);
- }
+ dst_offset = i915_texture_offset(dst_tex, dst_level, dstz);
+ if (src->target != PIPE_TEXTURE_CUBE &&
+ src->target != PIPE_TEXTURE_3D)
+ assert(src_box->z == 0);
+ src_offset = i915_texture_offset(src_tex, src_level, src_box->z);
assert( dst != src );
assert( util_format_get_blocksize(dpt->format) == util_format_get_blocksize(spt->format) );
@@ -90,7 +77,8 @@ i915_surface_copy(struct pipe_context *pipe,
util_format_get_blocksize(dpt->format),
(unsigned short) src_tex->stride, src_tex->buffer, src_offset,
(unsigned short) dst_tex->stride, dst_tex->buffer, dst_offset,
- (short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
+ (short) src_box->x, (short) src_box->y, (short) dstx, (short) dsty,
+ (short) src_box->width, (short) src_box->height );
}
@@ -104,6 +92,7 @@ i915_clear_render_target(struct pipe_context *pipe,
struct i915_texture *tex = i915_texture(dst->texture);
struct pipe_resource *pt = &tex->b.b;
union util_color uc;
+ unsigned offset = i915_texture_offset(tex, dst->u.tex.level, dst->u.tex.first_layer);
assert(util_format_get_blockwidth(pt->format) == 1);
assert(util_format_get_blockheight(pt->format) == 1);
@@ -113,7 +102,7 @@ i915_clear_render_target(struct pipe_context *pipe,
util_format_get_blocksize(pt->format),
XY_COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB,
(unsigned short) tex->stride,
- tex->buffer, dst->offset,
+ tex->buffer, offset,
(short) dstx, (short) dsty,
(short) width, (short) height,
uc.ui );
@@ -132,6 +121,7 @@ i915_clear_depth_stencil(struct pipe_context *pipe,
struct pipe_resource *pt = &tex->b.b;
unsigned packedds;
unsigned mask = 0;
+ unsigned offset = i915_texture_offset(tex, dst->u.tex.level, dst->u.tex.first_layer);
assert(util_format_get_blockwidth(pt->format) == 1);
assert(util_format_get_blockheight(pt->format) == 1);
@@ -151,7 +141,7 @@ i915_clear_depth_stencil(struct pipe_context *pipe,
util_format_get_blocksize(pt->format),
mask,
(unsigned short) tex->stride,
- tex->buffer, dst->offset,
+ tex->buffer, offset,
(short) dstx, (short) dsty,
(short) width, (short) height,
packedds );
@@ -163,45 +153,37 @@ i915_clear_depth_stencil(struct pipe_context *pipe,
static struct pipe_surface *
-i915_get_tex_surface(struct pipe_screen *screen,
- struct pipe_resource *pt,
- unsigned face, unsigned level, unsigned zslice,
- unsigned flags)
+i915_create_surface(struct pipe_context *ctx,
+ struct pipe_resource *pt,
+ const struct pipe_surface *surf_tmpl)
{
- struct i915_texture *tex = i915_texture(pt);
struct pipe_surface *ps;
- unsigned offset; /* in bytes */
- if (pt->target == PIPE_TEXTURE_CUBE) {
- offset = i915_texture_offset(tex, level, face);
- }
- else if (pt->target == PIPE_TEXTURE_3D) {
- offset = i915_texture_offset(tex, level, zslice);
- }
- else {
- offset = i915_texture_offset(tex, level, 0);
- assert(face == 0);
- assert(zslice == 0);
- }
+ assert(surf_tmpl->u.tex.first_layer == surf_tmpl->u.tex.last_layer);
+ if (pt->target != PIPE_TEXTURE_CUBE &&
+ pt->target != PIPE_TEXTURE_3D)
+ assert(surf_tmpl->u.tex.first_layer == 0);
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
+ /* could subclass pipe_surface and store offset as it used to do */
pipe_reference_init(&ps->reference, 1);
pipe_resource_reference(&ps->texture, pt);
- ps->format = pt->format;
- ps->width = u_minify(pt->width0, level);
- ps->height = u_minify(pt->height0, level);
- ps->offset = offset;
- ps->usage = flags;
- ps->zslice = zslice;
- ps->level = level;
- ps->face = face;
+ ps->format = surf_tmpl->format;
+ ps->width = u_minify(pt->width0, surf_tmpl->u.tex.level);
+ ps->height = u_minify(pt->height0, surf_tmpl->u.tex.level);
+ ps->u.tex.level = surf_tmpl->u.tex.level;
+ ps->u.tex.first_layer = surf_tmpl->u.tex.first_layer;
+ ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
+ ps->usage = surf_tmpl->usage;
+ ps->context = ctx;
}
return ps;
}
static void
-i915_tex_surface_destroy(struct pipe_surface *surf)
+i915_surface_destroy(struct pipe_context *ctx,
+ struct pipe_surface *surf)
{
pipe_resource_reference(&surf->texture, NULL);
FREE(surf);
@@ -214,13 +196,6 @@ i915_init_surface_functions(struct i915_context *i915)
i915->base.resource_copy_region = i915_surface_copy;
i915->base.clear_render_target = i915_clear_render_target;
i915->base.clear_depth_stencil = i915_clear_depth_stencil;
-}
-
-/* No good reason for these to be in the screen.
- */
-void
-i915_init_screen_surface_functions(struct i915_screen *is)
-{
- is->base.get_tex_surface = i915_get_tex_surface;
- is->base.tex_surface_destroy = i915_tex_surface_destroy;
+ i915->base.create_surface = i915_create_surface;
+ i915->base.surface_destroy = i915_surface_destroy;
}