summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/i915
diff options
context:
space:
mode:
authorStéphane Marchesin <marcheu@chromium.org>2014-05-26 06:48:11 -0700
committerStéphane Marchesin <marcheu@chromium.org>2014-05-26 23:08:49 -0700
commitb419ca937a666b0e5a6aca4cf179d8d43e0a3996 (patch)
tree42b78d1fd6c0be448a3f887426cd52556bfa78a5 /src/gallium/drivers/i915
parenta26e2bc2e3578b50bd581c8f8d8e3c428c85158f (diff)
i915g: handle more formats in copy
We can handle depth, luminance,... copies by simply replacing the format with a known format of the same bpp.
Diffstat (limited to 'src/gallium/drivers/i915')
-rw-r--r--src/gallium/drivers/i915/i915_state.c21
-rw-r--r--src/gallium/drivers/i915/i915_state.h6
-rw-r--r--src/gallium/drivers/i915/i915_surface.c75
3 files changed, 91 insertions, 11 deletions
diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c
index b2f52d5d689..c90fcfd7491 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -42,6 +42,7 @@
#include "i915_state_inlines.h"
#include "i915_fpc.h"
#include "i915_resource.h"
+#include "i915_state.h"
/* The i915 (and related graphics cores) do not support GL_CLAMP. The
* Intel drivers for "other operating systems" implement GL_CLAMP as
@@ -812,6 +813,26 @@ i915_set_sampler_views(struct pipe_context *pipe, unsigned shader,
}
+struct pipe_sampler_view *
+i915_create_sampler_view_custom(struct pipe_context *pipe,
+ struct pipe_resource *texture,
+ const struct pipe_sampler_view *templ,
+ unsigned width0,
+ unsigned height0)
+{
+ struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
+
+ if (view) {
+ *view = *templ;
+ view->reference.count = 1;
+ view->texture = NULL;
+ pipe_resource_reference(&view->texture, texture);
+ view->context = pipe;
+ }
+
+ return view;
+}
+
static struct pipe_sampler_view *
i915_create_sampler_view(struct pipe_context *pipe,
struct pipe_resource *texture,
diff --git a/src/gallium/drivers/i915/i915_state.h b/src/gallium/drivers/i915/i915_state.h
index f529329d8c2..56ebb2ddb86 100644
--- a/src/gallium/drivers/i915/i915_state.h
+++ b/src/gallium/drivers/i915/i915_state.h
@@ -53,5 +53,11 @@ extern struct i915_tracked_state i915_hw_constants;
void i915_update_derived(struct i915_context *i915);
void i915_emit_hardware_state(struct i915_context *i915);
+struct pipe_sampler_view *
+i915_create_sampler_view_custom(struct pipe_context *pipe,
+ struct pipe_resource *texture,
+ const struct pipe_sampler_view *templ,
+ unsigned width0,
+ unsigned height0);
#endif
diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c
index df662873001..6e9558e54df 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -39,6 +39,12 @@
#include "util/u_pack_color.h"
#include "util/u_surface.h"
+static struct pipe_surface *
+i915_create_surface_custom(struct pipe_context *ctx,
+ struct pipe_resource *pt,
+ const struct pipe_surface *surf_tmpl,
+ unsigned width0,
+ unsigned height0);
/*
* surface functions using the render engine
*/
@@ -75,25 +81,61 @@ i915_surface_copy_render(struct pipe_context *pipe,
struct pipe_resource *src, unsigned src_level,
const struct pipe_box *src_box)
{
+ struct pipe_screen *screen = pipe->screen;
struct i915_context *i915 = i915_context(pipe);
+ struct i915_texture *dst_tex = i915_texture(dst);
+ struct i915_texture *src_tex = i915_texture(src);
+ unsigned src_width0 = src->width0;
+ unsigned src_height0 = src->height0;
+ unsigned dst_width0 = dst->width0;
+ unsigned dst_height0 = dst->height0;
+ unsigned layout;
+ struct pipe_box dstbox;
+ struct pipe_sampler_view src_templ, *src_view;
+ struct pipe_surface dst_templ, *dst_view;
/* Fallback for buffers. */
- if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
+ if ((dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER)) {
util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
src, src_level, src_box);
return;
}
+ layout = util_format_description(dst_templ.format)->layout;
+
if (!util_blitter_is_copy_supported(i915->blitter, dst, src)) {
- util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
- src, src_level, src_box);
- return;
+ switch (util_format_get_blocksize(dst_templ.format)) {
+ case 1:
+ dst_templ.format = PIPE_FORMAT_I8_UNORM;
+ break;
+ case 2:
+ dst_templ.format = PIPE_FORMAT_B5G6R5_UNORM;
+ break;
+ case 4:
+ dst_templ.format = PIPE_FORMAT_B8G8R8A8_UNORM;
+ break;
+ default:
+ debug_printf("i915: copy_region: Unhandled format: %s. Falling back to software.\n"
+ "i915: copy_region: Software fallback doesn't work for tiled textures.\n",
+ util_format_short_name(dst_templ.format));
+ }
+ src_templ.format = dst_templ.format;
}
i915_util_blitter_save_states(i915);
- util_blitter_copy_texture(i915->blitter, dst, dst_level, dstx, dsty, dstz,
- src, src_level, src_box);
+ util_blitter_default_dst_texture(&dst_templ, dst, dst_level, dstz);
+ util_blitter_default_src_texture(&src_templ, src, src_level);
+
+ dst_view = i915_create_surface_custom(pipe, dst, &dst_templ, dst_width0, dst_height0);
+ src_view = i915_create_sampler_view_custom(pipe, src, &src_templ, src_width0, src_height0);
+
+ u_box_3d(dstx, dsty, dstz, abs(src_box->width), abs(src_box->height),
+ abs(src_box->depth), &dstbox);
+
+ util_blitter_blit_generic(i915->blitter, dst_view, &dstbox,
+ src_view, src_box, src_width0, src_height0,
+ PIPE_MASK_RGBAZS, PIPE_TEX_FILTER_NEAREST, NULL);
}
static void
@@ -314,9 +356,11 @@ i915_clear_depth_stencil_blitter(struct pipe_context *pipe,
static struct pipe_surface *
-i915_create_surface(struct pipe_context *ctx,
- struct pipe_resource *pt,
- const struct pipe_surface *surf_tmpl)
+i915_create_surface_custom(struct pipe_context *ctx,
+ struct pipe_resource *pt,
+ const struct pipe_surface *surf_tmpl,
+ unsigned width0,
+ unsigned height0)
{
struct pipe_surface *ps;
@@ -331,8 +375,8 @@ i915_create_surface(struct pipe_context *ctx,
pipe_reference_init(&ps->reference, 1);
pipe_resource_reference(&ps->texture, pt);
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->width = u_minify(width0, surf_tmpl->u.tex.level);
+ ps->height = u_minify(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;
@@ -341,6 +385,15 @@ i915_create_surface(struct pipe_context *ctx,
return ps;
}
+static struct pipe_surface *
+i915_create_surface(struct pipe_context *ctx,
+ struct pipe_resource *pt,
+ const struct pipe_surface *surf_tmpl)
+{
+ return i915_create_surface_custom(ctx, pt, surf_tmpl,
+ pt->width0, pt->height0);
+}
+
static void
i915_surface_destroy(struct pipe_context *ctx,
struct pipe_surface *surf)