aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/panfrost/pan_context.c4
-rw-r--r--src/gallium/drivers/panfrost/pan_format.c22
-rw-r--r--src/gallium/drivers/panfrost/pan_format.h3
-rw-r--r--src/gallium/drivers/panfrost/pan_mfbd.c30
-rw-r--r--src/gallium/drivers/panfrost/pan_resource.c4
-rw-r--r--src/gallium/drivers/panfrost/pan_sfbd.c87
6 files changed, 104 insertions, 46 deletions
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 5334c686941..e8cedb96187 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -118,7 +118,9 @@ panfrost_emit_sfbd(struct panfrost_batch *batch, unsigned vertex_count)
.width = MALI_POSITIVE(width),
.height = MALI_POSITIVE(height),
.unknown2 = 0x1f,
- .format = 0x30000000,
+ .format = {
+ .unk3 = 0x3,
+ },
.clear_flags = 0x1000,
.unknown_address_0 = panfrost_batch_get_scratchpad(batch)->gpu,
.tiler = panfrost_emit_midg_tiler(batch, vertex_count),
diff --git a/src/gallium/drivers/panfrost/pan_format.c b/src/gallium/drivers/panfrost/pan_format.c
index f272e3a3716..2596b41feac 100644
--- a/src/gallium/drivers/panfrost/pan_format.c
+++ b/src/gallium/drivers/panfrost/pan_format.c
@@ -247,4 +247,26 @@ panfrost_find_format(const struct util_format_description *desc) {
return (enum mali_format) format;
}
+void
+panfrost_invert_swizzle(const unsigned char *in, unsigned char *out)
+{
+ /* First, default to all zeroes to prevent uninitialized junk */
+
+ for (unsigned c = 0; c < 4; ++c)
+ out[c] = PIPE_SWIZZLE_0;
+
+ /* Now "do" what the swizzle says */
+
+ for (unsigned c = 0; c < 4; ++c) {
+ unsigned char i = in[c];
+ /* Who cares? */
+ assert(PIPE_SWIZZLE_X == 0);
+ if (i > PIPE_SWIZZLE_W)
+ continue;
+
+ /* Invert */
+ unsigned idx = i - PIPE_SWIZZLE_X;
+ out[idx] = PIPE_SWIZZLE_X + c;
+ }
+}
diff --git a/src/gallium/drivers/panfrost/pan_format.h b/src/gallium/drivers/panfrost/pan_format.h
index a44d1d80994..4baac8a0e59 100644
--- a/src/gallium/drivers/panfrost/pan_format.h
+++ b/src/gallium/drivers/panfrost/pan_format.h
@@ -37,6 +37,9 @@ panfrost_get_default_swizzle(unsigned components);
enum mali_format
panfrost_find_format(const struct util_format_description *desc);
+void
+panfrost_invert_swizzle(const unsigned char *in, unsigned char *out);
+
#endif
diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c
index b01f8289bf9..75f8887ec6d 100644
--- a/src/gallium/drivers/panfrost/pan_mfbd.c
+++ b/src/gallium/drivers/panfrost/pan_mfbd.c
@@ -29,30 +29,6 @@
#include "util/u_format.h"
-static void
-panfrost_invert_swizzle(const unsigned char *in, unsigned char *out)
-{
- /* First, default to all zeroes to prevent uninitialized junk */
-
- for (unsigned c = 0; c < 4; ++c)
- out[c] = PIPE_SWIZZLE_0;
-
- /* Now "do" what the swizzle says */
-
- for (unsigned c = 0; c < 4; ++c) {
- unsigned char i = in[c];
-
- /* Who cares? */
- assert(PIPE_SWIZZLE_X == 0);
- if (i > PIPE_SWIZZLE_W)
- continue;
-
- /* Invert */
- unsigned idx = i - PIPE_SWIZZLE_X;
- out[idx] = PIPE_SWIZZLE_X + c;
- }
-}
-
static struct mali_rt_format
panfrost_mfbd_format(struct pipe_surface *surf)
{
@@ -224,15 +200,15 @@ panfrost_mfbd_set_cbuf(
/* Now, we set the layout specific pieces */
if (rsrc->layout == PAN_LINEAR) {
- rt->format.block = MALI_MFBD_BLOCK_LINEAR;
+ rt->format.block = MALI_BLOCK_LINEAR;
rt->framebuffer = base;
rt->framebuffer_stride = stride / 16;
} else if (rsrc->layout == PAN_TILED) {
- rt->format.block = MALI_MFBD_BLOCK_TILED;
+ rt->format.block = MALI_BLOCK_TILED;
rt->framebuffer = base;
rt->framebuffer_stride = stride;
} else if (rsrc->layout == PAN_AFBC) {
- rt->format.block = MALI_MFBD_BLOCK_AFBC;
+ rt->format.block = MALI_BLOCK_AFBC;
unsigned header_size = rsrc->slices[level].header_size;
diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c
index d0619a89882..08a3713a84c 100644
--- a/src/gallium/drivers/panfrost/pan_resource.c
+++ b/src/gallium/drivers/panfrost/pan_resource.c
@@ -394,9 +394,7 @@ panfrost_resource_create_bo(struct panfrost_screen *screen, struct panfrost_reso
bool is_2d = res->depth0 == 1 && res->array_size == 1;
bool is_streaming = (res->usage != PIPE_USAGE_STREAM);
- /* TODO: Reenable tiling on SFBD systems when we support rendering to
- * tiled formats with SFBD */
- bool should_tile = is_streaming && is_texture && is_2d && !screen->require_sfbd;
+ bool should_tile = is_streaming && is_texture && is_2d;
/* Depth/stencil can't be tiled, only linear or AFBC */
should_tile &= !(res->bind & PIPE_BIND_DEPTH_STENCIL);
diff --git a/src/gallium/drivers/panfrost/pan_sfbd.c b/src/gallium/drivers/panfrost/pan_sfbd.c
index 882c9990a30..2be48e7155f 100644
--- a/src/gallium/drivers/panfrost/pan_sfbd.c
+++ b/src/gallium/drivers/panfrost/pan_sfbd.c
@@ -29,11 +29,56 @@
#include "util/u_format.h"
-static unsigned
+static struct mali_sfbd_format
panfrost_sfbd_format(struct pipe_surface *surf)
{
- /* TODO */
- return 0xb84e0281; /* RGB32, no MSAA */
+ /* Explode details on the format */
+
+ const struct util_format_description *desc =
+ util_format_description(surf->format);
+
+ /* The swizzle for rendering is inverted from texturing */
+
+ unsigned char swizzle[4];
+ panfrost_invert_swizzle(desc->swizzle, swizzle);
+
+ struct mali_sfbd_format fmt = {
+ .unk1 = 0x1,
+ .swizzle = panfrost_translate_swizzle_4(swizzle),
+ .nr_channels = MALI_POSITIVE(desc->nr_channels),
+ .unk2 = 0x4,
+ .unk3 = 0xb,
+ };
+
+ if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB)
+ fmt.unk2 |= MALI_SFBD_FORMAT_SRGB;
+
+ /* sRGB handled as a dedicated flag */
+ enum pipe_format linearized = util_format_linear(surf->format);
+
+ /* If RGB, we're good to go */
+ if (util_format_is_unorm8(desc))
+ return fmt;
+
+ switch (linearized) {
+ case PIPE_FORMAT_B5G6R5_UNORM:
+ fmt.unk1 = 0x5;
+ fmt.nr_channels = MALI_POSITIVE(2);
+ fmt.unk2 = 0x5;
+ break;
+
+ case PIPE_FORMAT_A4B4G4R4_UNORM:
+ case PIPE_FORMAT_B4G4R4A4_UNORM:
+ fmt.unk1 = 0x4;
+ fmt.nr_channels = MALI_POSITIVE(1);
+ fmt.unk2 = 0x5;
+ break;
+
+ default:
+ unreachable("Invalid format rendering");
+ }
+
+ return fmt;
}
static void
@@ -92,9 +137,14 @@ panfrost_sfbd_set_cbuf(
unsigned offset = rsrc->slices[level].offset;
signed stride = rsrc->slices[level].stride;
- if (rsrc->layout == PAN_LINEAR) {
- fb->framebuffer = rsrc->bo->gpu + offset;
- fb->stride = stride;
+ fb->framebuffer = rsrc->bo->gpu + offset;
+ fb->stride = stride;
+
+ if (rsrc->layout == PAN_LINEAR)
+ fb->format.block = MALI_BLOCK_LINEAR;
+ else if (rsrc->layout == PAN_TILED) {
+ fb->format.block = MALI_BLOCK_TILED;
+ fb->stride *= 16;
} else {
fprintf(stderr, "Invalid render layout\n");
assert(0);
@@ -111,17 +161,22 @@ panfrost_sfbd_set_zsbuf(
unsigned level = surf->u.tex.level;
assert(surf->u.tex.first_layer == 0);
- unsigned offset = rsrc->slices[level].offset;
-
if (rsrc->layout == PAN_LINEAR) {
/* TODO: What about format selection? */
- /* TODO: Z/S stride selection? */
- fb->depth_buffer = rsrc->bo->gpu + offset;
- fb->depth_buffer_enable = MALI_DEPTH_STENCIL_ENABLE;
+ fb->depth_buffer = rsrc->bo->gpu + rsrc->slices[level].offset;
+ fb->depth_stride = rsrc->slices[level].stride;
+
+ fb->stencil_buffer = rsrc->bo->gpu + rsrc->slices[level].offset;
+ fb->stencil_stride = rsrc->slices[level].stride;
- fb->stencil_buffer = rsrc->bo->gpu + offset;
- fb->stencil_buffer_enable = MALI_DEPTH_STENCIL_ENABLE;
+ struct panfrost_resource *stencil = rsrc->separate_stencil;
+ if (stencil) {
+ struct panfrost_slice stencil_slice = stencil->slices[level];
+
+ fb->stencil_buffer = stencil->bo->gpu + stencil_slice.offset;
+ fb->stencil_stride = stencil_slice.stride;
+ }
} else {
fprintf(stderr, "Invalid render layout\n");
assert(0);
@@ -144,8 +199,10 @@ panfrost_sfbd_fragment(struct panfrost_batch *batch, bool has_draws)
if (batch->key.zsbuf)
panfrost_sfbd_set_zsbuf(&fb, batch->key.zsbuf);
- if (batch->requirements & PAN_REQ_MSAA)
- fb.format |= MALI_FRAMEBUFFER_MSAA_A | MALI_FRAMEBUFFER_MSAA_B;
+ if (batch->requirements & PAN_REQ_MSAA) {
+ fb.format.unk1 |= MALI_SFBD_FORMAT_MSAA_A;
+ fb.format.unk2 |= MALI_SFBD_FORMAT_MSAA_B;
+ }
struct pipe_surface *surf = batch->key.cbufs[0];
struct panfrost_resource *rsrc = pan_resource(surf->texture);