summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2018-06-12 09:56:12 -0400
committerRob Clark <[email protected]>2018-06-19 13:02:28 -0400
commitf07154421ac5bb546dbd75fb74e8f2f8883c59c0 (patch)
treefe277db35f7ec8437879f6daa252fee1c7acf6fa /src/gallium/drivers/freedreno
parentced14f1c7a821dbb3fdb3c76b50a256c6568c714 (diff)
freedreno/a5xx: bordercolor fixes
Need a bit of hand-holding for stencil bordercolor, and add border color values for sRGB. Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno')
-rw-r--r--src/gallium/drivers/freedreno/a5xx/fd5_emit.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
index 62f96358600..6ce99549a1a 100644
--- a/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
+++ b/src/gallium/drivers/freedreno/a5xx/fd5_emit.c
@@ -135,6 +135,7 @@ struct PACKED bcolor_entry {
uint32_t fp32[4];
uint16_t ui16[4];
int16_t si16[4];
+
uint16_t fp16[4];
uint16_t rgb565;
uint16_t rgb5a1;
@@ -144,7 +145,9 @@ struct PACKED bcolor_entry {
int8_t si8[4];
uint32_t rgb10a2;
uint32_t z24; /* also s8? */
- uint8_t __pad1[32];
+
+ uint16_t srgb[4]; /* appears to duplicate fp16[], but clamped, used for srgb */
+ uint8_t __pad1[24];
};
#define FD5_BORDER_COLOR_SIZE 0x60
@@ -178,8 +181,9 @@ setup_border_colors(struct fd_texture_stateobj *tex, struct bcolor_entry *entrie
if ((i >= tex->num_textures) || !tex->textures[i])
continue;
+ enum pipe_format format = tex->textures[i]->format;
const struct util_format_description *desc =
- util_format_description(tex->textures[i]->format);
+ util_format_description(format);
e->rgb565 = 0;
e->rgb5a1 = 0;
@@ -189,6 +193,24 @@ setup_border_colors(struct fd_texture_stateobj *tex, struct bcolor_entry *entrie
for (j = 0; j < 4; j++) {
int c = desc->swizzle[j];
+ int cd = c;
+
+ /*
+ * HACK: for PIPE_FORMAT_X24S8_UINT we end up w/ the
+ * stencil border color value in bc->ui[0] but according
+ * to desc->swizzle and desc->channel, the .x component
+ * is NONE and the stencil value is in the y component.
+ * Meanwhile the hardware wants this in the .x componetn.
+ */
+ if ((format == PIPE_FORMAT_X24S8_UINT) ||
+ (format == PIPE_FORMAT_X32_S8X24_UINT)) {
+ if (j == 0) {
+ c = 1;
+ cd = 0;
+ } else {
+ continue;
+ }
+ }
if (c >= 4)
continue;
@@ -222,8 +244,8 @@ setup_border_colors(struct fd_texture_stateobj *tex, struct bcolor_entry *entrie
clamped = 0;
break;
}
- e->fp32[c] = bc->ui[j];
- e->fp16[c] = clamped;
+ e->fp32[cd] = bc->ui[j];
+ e->fp16[cd] = clamped;
} else {
float f = bc->f[j];
float f_u = CLAMP(f, 0, 1);
@@ -231,6 +253,7 @@ setup_border_colors(struct fd_texture_stateobj *tex, struct bcolor_entry *entrie
e->fp32[c] = fui(f);
e->fp16[c] = util_float_to_half(f);
+ e->srgb[c] = util_float_to_half(f_u);
e->ui16[c] = f_u * 0xffff;
e->si16[c] = f_s * 0x7fff;
e->ui8[c] = f_u * 0xff;