vc4: Move the blit code to a separate file.
authorEric Anholt <eric@anholt.net>
Thu, 9 Apr 2015 19:12:20 +0000 (12:12 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 14 Apr 2015 06:20:45 +0000 (23:20 -0700)
There will be other blit code showing up, and it seems like the place
you'd look.

src/gallium/drivers/vc4/Makefile.sources
src/gallium/drivers/vc4/vc4_blit.c [new file with mode: 0644]
src/gallium/drivers/vc4/vc4_context.h
src/gallium/drivers/vc4/vc4_resource.c

index 62cd0e00d900d2b971da578a80c34bc663e34f2a..49474df354814b221e75968de528d284f4a51866 100644 (file)
@@ -1,4 +1,5 @@
 C_SOURCES := \
+       vc4_blit.c \
        vc4_bufmgr.c \
        vc4_bufmgr.h \
        vc4_cl.c \
diff --git a/src/gallium/drivers/vc4/vc4_blit.c b/src/gallium/drivers/vc4/vc4_blit.c
new file mode 100644 (file)
index 0000000..5c98fb6
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright © 2015 Broadcom
+ *
+ * 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 (including the next
+ * paragraph) 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.
+ */
+
+#include "util/u_format.h"
+#include "util/u_surface.h"
+#include "util/u_blitter.h"
+#include "vc4_context.h"
+
+static bool
+vc4_render_blit(struct pipe_context *ctx, struct pipe_blit_info *info)
+{
+        struct vc4_context *vc4 = vc4_context(ctx);
+
+        if (!util_blitter_is_blit_supported(vc4->blitter, info)) {
+                fprintf(stderr, "blit unsupported %s -> %s",
+                    util_format_short_name(info->src.resource->format),
+                    util_format_short_name(info->dst.resource->format));
+                return false;
+        }
+
+        util_blitter_save_vertex_buffer_slot(vc4->blitter, vc4->vertexbuf.vb);
+        util_blitter_save_vertex_elements(vc4->blitter, vc4->vtx);
+        util_blitter_save_vertex_shader(vc4->blitter, vc4->prog.bind_vs);
+        util_blitter_save_rasterizer(vc4->blitter, vc4->rasterizer);
+        util_blitter_save_viewport(vc4->blitter, &vc4->viewport);
+        util_blitter_save_scissor(vc4->blitter, &vc4->scissor);
+        util_blitter_save_fragment_shader(vc4->blitter, vc4->prog.bind_fs);
+        util_blitter_save_blend(vc4->blitter, vc4->blend);
+        util_blitter_save_depth_stencil_alpha(vc4->blitter, vc4->zsa);
+        util_blitter_save_stencil_ref(vc4->blitter, &vc4->stencil_ref);
+        util_blitter_save_sample_mask(vc4->blitter, vc4->sample_mask);
+        util_blitter_save_framebuffer(vc4->blitter, &vc4->framebuffer);
+        util_blitter_save_fragment_sampler_states(vc4->blitter,
+                        vc4->fragtex.num_samplers,
+                        (void **)vc4->fragtex.samplers);
+        util_blitter_save_fragment_sampler_views(vc4->blitter,
+                        vc4->fragtex.num_textures, vc4->fragtex.textures);
+
+        util_blitter_blit(vc4->blitter, info);
+
+        return true;
+}
+
+/* Optimal hardware path for blitting pixels.
+ * Scaling, format conversion, up- and downsampling (resolve) are allowed.
+ */
+void
+vc4_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info)
+{
+        struct pipe_blit_info info = *blit_info;
+
+        if (info.src.resource->nr_samples > 1 &&
+            info.dst.resource->nr_samples <= 1 &&
+            !util_format_is_depth_or_stencil(info.src.resource->format) &&
+            !util_format_is_pure_integer(info.src.resource->format)) {
+                fprintf(stderr, "color resolve unimplemented");
+                return;
+        }
+
+        if (util_try_blit_via_copy_region(pctx, &info)) {
+                return; /* done */
+        }
+
+        if (info.mask & PIPE_MASK_S) {
+                fprintf(stderr, "cannot blit stencil, skipping");
+                info.mask &= ~PIPE_MASK_S;
+        }
+
+        vc4_render_blit(pctx, &info);
+}
index 72d655e4cc27bc8168de8e9e1550501d90c0b358..68eacb84fd1cdf2b61b956c0779e307bef55e525 100644 (file)
@@ -341,4 +341,5 @@ bool vc4_tex_format_supported(enum pipe_format f);
 uint8_t vc4_get_tex_format(enum pipe_format f);
 const uint8_t *vc4_get_format_swizzle(enum pipe_format f);
 void vc4_init_query_functions(struct vc4_context *vc4);
+void vc4_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info);
 #endif /* VC4_CONTEXT_H */
index 10e1d6c34ed6bf9710c1a055473e9b3bc92f3246..f6ca0759012d7abc85b9a1a557ae1ba51a359fb5 100644 (file)
@@ -26,7 +26,6 @@
 #include "util/u_format.h"
 #include "util/u_inlines.h"
 #include "util/u_surface.h"
-#include "util/u_blitter.h"
 
 #include "vc4_screen.h"
 #include "vc4_context.h"
@@ -576,69 +575,6 @@ vc4_flush_resource(struct pipe_context *pctx, struct pipe_resource *resource)
          */
 }
 
-static bool
-render_blit(struct pipe_context *ctx, struct pipe_blit_info *info)
-{
-        struct vc4_context *vc4 = vc4_context(ctx);
-
-        if (!util_blitter_is_blit_supported(vc4->blitter, info)) {
-                fprintf(stderr, "blit unsupported %s -> %s",
-                    util_format_short_name(info->src.resource->format),
-                    util_format_short_name(info->dst.resource->format));
-                return false;
-        }
-
-        util_blitter_save_vertex_buffer_slot(vc4->blitter, vc4->vertexbuf.vb);
-        util_blitter_save_vertex_elements(vc4->blitter, vc4->vtx);
-        util_blitter_save_vertex_shader(vc4->blitter, vc4->prog.bind_vs);
-        util_blitter_save_rasterizer(vc4->blitter, vc4->rasterizer);
-        util_blitter_save_viewport(vc4->blitter, &vc4->viewport);
-        util_blitter_save_scissor(vc4->blitter, &vc4->scissor);
-        util_blitter_save_fragment_shader(vc4->blitter, vc4->prog.bind_fs);
-        util_blitter_save_blend(vc4->blitter, vc4->blend);
-        util_blitter_save_depth_stencil_alpha(vc4->blitter, vc4->zsa);
-        util_blitter_save_stencil_ref(vc4->blitter, &vc4->stencil_ref);
-        util_blitter_save_sample_mask(vc4->blitter, vc4->sample_mask);
-        util_blitter_save_framebuffer(vc4->blitter, &vc4->framebuffer);
-        util_blitter_save_fragment_sampler_states(vc4->blitter,
-                        vc4->fragtex.num_samplers,
-                        (void **)vc4->fragtex.samplers);
-        util_blitter_save_fragment_sampler_views(vc4->blitter,
-                        vc4->fragtex.num_textures, vc4->fragtex.textures);
-
-        util_blitter_blit(vc4->blitter, info);
-
-        return true;
-}
-
-/* Optimal hardware path for blitting pixels.
- * Scaling, format conversion, up- and downsampling (resolve) are allowed.
- */
-static void
-vc4_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info)
-{
-        struct pipe_blit_info info = *blit_info;
-
-        if (info.src.resource->nr_samples > 1 &&
-            info.dst.resource->nr_samples <= 1 &&
-            !util_format_is_depth_or_stencil(info.src.resource->format) &&
-            !util_format_is_pure_integer(info.src.resource->format)) {
-                fprintf(stderr, "color resolve unimplemented");
-                return;
-        }
-
-        if (util_try_blit_via_copy_region(pctx, &info)) {
-                return; /* done */
-        }
-
-        if (info.mask & PIPE_MASK_S) {
-                fprintf(stderr, "cannot blit stencil, skipping");
-                info.mask &= ~PIPE_MASK_S;
-        }
-
-        render_blit(pctx, &info);
-}
-
 void
 vc4_update_shadow_baselevel_texture(struct pipe_context *pctx,
                                     struct pipe_sampler_view *view)