summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/ilo/ilo_blitter_pipe.c
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2013-06-17 12:24:17 +0800
committerChia-I Wu <[email protected]>2013-06-17 14:37:10 +0800
commitb4b3a5c6dc159dd46fecca7ce64fe90f0c6c7496 (patch)
tree7db4c9663c8954ef095b4dc2f24eca2ed337a00d /src/gallium/drivers/ilo/ilo_blitter_pipe.c
parent6d7abafdc86c6d8533bcb798465452c78c2694e8 (diff)
ilo: replace util_blitter by ilo_blitter
ilo_blitter is just a wrapper for util_blitter for now. We will port BLT code to ilo_blitter shortly.
Diffstat (limited to 'src/gallium/drivers/ilo/ilo_blitter_pipe.c')
-rw-r--r--src/gallium/drivers/ilo/ilo_blitter_pipe.c196
1 files changed, 196 insertions, 0 deletions
diff --git a/src/gallium/drivers/ilo/ilo_blitter_pipe.c b/src/gallium/drivers/ilo/ilo_blitter_pipe.c
new file mode 100644
index 00000000000..cfec8b10e5f
--- /dev/null
+++ b/src/gallium/drivers/ilo/ilo_blitter_pipe.c
@@ -0,0 +1,196 @@
+/*
+ * Mesa 3-D graphics library
+ *
+ * Copyright (C) 2013 LunarG, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Chia-I Wu <[email protected]>
+ */
+
+#include "util/u_blitter.h"
+#include "util/u_surface.h"
+
+#include "ilo_context.h"
+#include "ilo_blitter.h"
+
+enum ilo_blitter_pipe_op {
+ ILO_BLITTER_PIPE_BLIT,
+ ILO_BLITTER_PIPE_COPY,
+ ILO_BLITTER_PIPE_CLEAR,
+ ILO_BLITTER_PIPE_CLEAR_FB,
+};
+
+static void
+ilo_blitter_pipe_begin(struct ilo_blitter *blitter,
+ enum ilo_blitter_pipe_op op)
+{
+ struct blitter_context *b = blitter->pipe_blitter;
+ struct ilo_context *ilo = blitter->ilo;
+
+ /* as documented in util/u_blitter.h */
+ util_blitter_save_vertex_buffer_slot(b, ilo->vb.states);
+ util_blitter_save_vertex_elements(b, (void *) ilo->ve);
+ util_blitter_save_vertex_shader(b, ilo->vs);
+ util_blitter_save_geometry_shader(b, ilo->gs);
+ util_blitter_save_so_targets(b, ilo->so.count, ilo->so.states);
+
+ util_blitter_save_fragment_shader(b, ilo->fs);
+ util_blitter_save_depth_stencil_alpha(b, (void *) ilo->dsa);
+ util_blitter_save_blend(b, (void *) ilo->blend);
+
+ /* undocumented? */
+ util_blitter_save_viewport(b, &ilo->viewport.viewport0);
+ util_blitter_save_stencil_ref(b, &ilo->stencil_ref);
+ util_blitter_save_sample_mask(b, ilo->sample_mask);
+
+ switch (op) {
+ case ILO_BLITTER_PIPE_BLIT:
+ case ILO_BLITTER_PIPE_COPY:
+ util_blitter_save_rasterizer(b, (void *) ilo->rasterizer);
+ util_blitter_save_framebuffer(b, &ilo->fb.state);
+
+ util_blitter_save_fragment_sampler_states(b,
+ ilo->sampler[PIPE_SHADER_FRAGMENT].count,
+ (void **) ilo->sampler[PIPE_SHADER_FRAGMENT].cso);
+
+ util_blitter_save_fragment_sampler_views(b,
+ ilo->view[PIPE_SHADER_FRAGMENT].count,
+ ilo->view[PIPE_SHADER_FRAGMENT].states);
+
+ /* disable render condition? */
+ break;
+ case ILO_BLITTER_PIPE_CLEAR:
+ util_blitter_save_rasterizer(b, (void *) ilo->rasterizer);
+ util_blitter_save_framebuffer(b, &ilo->fb.state);
+
+ /* disable render condition? */
+ break;
+ case ILO_BLITTER_PIPE_CLEAR_FB:
+ util_blitter_save_rasterizer(b, (void *) ilo->rasterizer);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+ilo_blitter_pipe_end(struct ilo_blitter *blitter)
+{
+}
+
+bool
+ilo_blitter_pipe_blit(struct ilo_blitter *blitter,
+ const struct pipe_blit_info *info)
+{
+ struct blitter_context *b = blitter->pipe_blitter;
+ struct pipe_blit_info skip_stencil;
+
+ if (util_try_blit_via_copy_region(&blitter->ilo->base, info))
+ return true;
+
+ if (!util_blitter_is_blit_supported(b, info)) {
+ /* try without stencil */
+ if (info->mask & PIPE_MASK_S) {
+ skip_stencil = *info;
+ skip_stencil.mask = info->mask & ~PIPE_MASK_S;
+
+ if (util_blitter_is_blit_supported(blitter->pipe_blitter,
+ &skip_stencil)) {
+ ilo_warn("ignore stencil buffer blitting\n");
+ info = &skip_stencil;
+ }
+ }
+
+ if (info != &skip_stencil) {
+ ilo_warn("failed to blit with pipe blitter\n");
+ return false;
+ }
+ }
+
+ ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_BLIT);
+ util_blitter_blit(b, info);
+ ilo_blitter_pipe_end(blitter);
+
+ return true;
+}
+
+bool
+ilo_blitter_pipe_copy_resource(struct ilo_blitter *blitter,
+ struct pipe_resource *dst, unsigned dst_level,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ struct pipe_resource *src, unsigned src_level,
+ const struct pipe_box *src_box)
+{
+ return false;
+}
+
+bool
+ilo_blitter_pipe_clear_rt(struct ilo_blitter *blitter,
+ struct pipe_surface *rt,
+ const union pipe_color_union *color,
+ unsigned x, unsigned y,
+ unsigned width, unsigned height)
+{
+ ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_CLEAR);
+
+ util_blitter_clear_render_target(blitter->pipe_blitter,
+ rt, color, x, y, width, height);
+
+ ilo_blitter_pipe_end(blitter);
+
+ return true;
+}
+
+bool
+ilo_blitter_pipe_clear_zs(struct ilo_blitter *blitter,
+ struct pipe_surface *zs,
+ unsigned clear_flags,
+ double depth, unsigned stencil,
+ unsigned x, unsigned y,
+ unsigned width, unsigned height)
+{
+ ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_CLEAR);
+
+ util_blitter_clear_depth_stencil(blitter->pipe_blitter,
+ zs, clear_flags, depth, stencil, x, y, width, height);
+
+ ilo_blitter_pipe_end(blitter);
+
+ return true;
+}
+
+bool
+ilo_blitter_pipe_clear_fb(struct ilo_blitter *blitter,
+ unsigned buffers,
+ const union pipe_color_union *color,
+ double depth, unsigned stencil)
+{
+ /* TODO we should pause/resume some queries */
+ ilo_blitter_pipe_begin(blitter, ILO_BLITTER_PIPE_CLEAR_FB);
+
+ util_blitter_clear(blitter->pipe_blitter,
+ blitter->ilo->fb.state.width, blitter->ilo->fb.state.height,
+ buffers, color, depth, stencil);
+
+ ilo_blitter_pipe_end(blitter);
+
+ return true;
+}