summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRohan Garg <[email protected]>2019-06-05 19:04:04 +0200
committerAlyssa Rosenzweig <[email protected]>2019-06-18 12:32:43 -0700
commitad284f794cdd1de7d4546b1cb2a3772860436da4 (patch)
tree89a47893d8fe1ce28da45dcefba2887e829adb8d /src
parent98eda99ab88b8a5bcf5da5daa7ca4edbf34592fd (diff)
panfrost: Move clearing logic into pan_job
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/panfrost/pan_context.c49
-rw-r--r--src/gallium/drivers/panfrost/pan_job.c59
-rw-r--r--src/gallium/drivers/panfrost/pan_job.h8
3 files changed, 68 insertions, 48 deletions
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 86a9533089c..3b2b6304596 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -221,40 +221,6 @@ panfrost_is_scanout(struct panfrost_context *ctx)
ctx->pipe_framebuffer.cbufs[0]->texture->bind & PIPE_BIND_SHARED;
}
-static uint32_t
-pan_pack_color(const union pipe_color_union *color, enum pipe_format format)
-{
- /* Alpha magicked to 1.0 if there is no alpha */
-
- bool has_alpha = util_format_has_alpha(format);
- float clear_alpha = has_alpha ? color->f[3] : 1.0f;
-
- /* Packed color depends on the framebuffer format */
-
- const struct util_format_description *desc =
- util_format_description(format);
-
- if (util_format_is_rgba8_variant(desc)) {
- return (float_to_ubyte(clear_alpha) << 24) |
- (float_to_ubyte(color->f[2]) << 16) |
- (float_to_ubyte(color->f[1]) << 8) |
- (float_to_ubyte(color->f[0]) << 0);
- } else if (format == PIPE_FORMAT_B5G6R5_UNORM) {
- /* First, we convert the components to R5, G6, B5 separately */
- unsigned r5 = CLAMP(color->f[0], 0.0, 1.0) * 31.0;
- unsigned g6 = CLAMP(color->f[1], 0.0, 1.0) * 63.0;
- unsigned b5 = CLAMP(color->f[2], 0.0, 1.0) * 31.0;
-
- /* Then we pack into a sparse u32. TODO: Why these shifts? */
- return (b5 << 25) | (g6 << 14) | (r5 << 5);
- } else {
- /* Unknown format */
- assert(0);
- }
-
- return 0;
-}
-
static void
panfrost_clear(
struct pipe_context *pipe,
@@ -265,20 +231,7 @@ panfrost_clear(
struct panfrost_context *ctx = pan_context(pipe);
struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);
- if (buffers & PIPE_CLEAR_COLOR) {
- enum pipe_format format = ctx->pipe_framebuffer.cbufs[0]->format;
- job->clear_color = pan_pack_color(color, format);
- }
-
- if (buffers & PIPE_CLEAR_DEPTH) {
- job->clear_depth = depth;
- }
-
- if (buffers & PIPE_CLEAR_STENCIL) {
- job->clear_stencil = stencil;
- }
-
- job->clear |= buffers;
+ panfrost_job_clear(ctx, job, buffers, color, depth, stencil);
}
static mali_ptr
diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c
index a7fc5f975cf..1882cc4faf3 100644
--- a/src/gallium/drivers/panfrost/pan_job.c
+++ b/src/gallium/drivers/panfrost/pan_job.c
@@ -26,6 +26,7 @@
#include "pan_context.h"
#include "util/hash_table.h"
#include "util/ralloc.h"
+#include "util/u_format.h"
struct panfrost_job *
panfrost_create_job(struct panfrost_context *ctx)
@@ -176,6 +177,64 @@ panfrost_job_set_requirements(struct panfrost_context *ctx,
job->requirements |= PAN_REQ_DEPTH_WRITE;
}
+static uint32_t
+pan_pack_color(const union pipe_color_union *color, enum pipe_format format)
+{
+ /* Alpha magicked to 1.0 if there is no alpha */
+
+ bool has_alpha = util_format_has_alpha(format);
+ float clear_alpha = has_alpha ? color->f[3] : 1.0f;
+
+ /* Packed color depends on the framebuffer format */
+
+ const struct util_format_description *desc =
+ util_format_description(format);
+
+ if (util_format_is_rgba8_variant(desc)) {
+ return (float_to_ubyte(clear_alpha) << 24) |
+ (float_to_ubyte(color->f[2]) << 16) |
+ (float_to_ubyte(color->f[1]) << 8) |
+ (float_to_ubyte(color->f[0]) << 0);
+ } else if (format == PIPE_FORMAT_B5G6R5_UNORM) {
+ /* First, we convert the components to R5, G6, B5 separately */
+ unsigned r5 = CLAMP(color->f[0], 0.0, 1.0) * 31.0;
+ unsigned g6 = CLAMP(color->f[1], 0.0, 1.0) * 63.0;
+ unsigned b5 = CLAMP(color->f[2], 0.0, 1.0) * 31.0;
+
+ /* Then we pack into a sparse u32. TODO: Why these shifts? */
+ return (b5 << 25) | (g6 << 14) | (r5 << 5);
+ } else {
+ /* Unknown format */
+ assert(0);
+ }
+
+ return 0;
+}
+
+void
+panfrost_job_clear(struct panfrost_context *ctx,
+ struct panfrost_job *job,
+ unsigned buffers,
+ const union pipe_color_union *color,
+ double depth, unsigned stencil)
+
+{
+ if (buffers & PIPE_CLEAR_COLOR) {
+ enum pipe_format format = ctx->pipe_framebuffer.cbufs[0]->format;
+ job->clear_color = pan_pack_color(color, format);
+ }
+
+ if (buffers & PIPE_CLEAR_DEPTH) {
+ job->clear_depth = depth;
+ }
+
+ if (buffers & PIPE_CLEAR_STENCIL) {
+ job->clear_stencil = stencil;
+ }
+
+ job->clear |= buffers;
+}
+
void
panfrost_flush_jobs_reading_resource(struct panfrost_context *panfrost,
struct pipe_resource *prsc)
diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h
index cbfd6cb0c7f..2e7c0532341 100644
--- a/src/gallium/drivers/panfrost/pan_job.h
+++ b/src/gallium/drivers/panfrost/pan_job.h
@@ -94,4 +94,12 @@ panfrost_job_submit(struct panfrost_context *ctx, struct panfrost_job *job);
void
panfrost_job_set_requirements(struct panfrost_context *ctx,
struct panfrost_job *job);
+
+void
+panfrost_job_clear(struct panfrost_context *ctx,
+ struct panfrost_job *job,
+ unsigned buffers,
+ const union pipe_color_union *color,
+ double depth, unsigned stencil);
+
#endif