Tobias Klausmann
2015-Jan-02 23:09 UTC
[Nouveau] [PATCH v2] nv50: enable texture compression
We enable compression only for some supported formats
Suggested-by: Ilia Mirkin <imirkin at alum.mit.edu>
Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
---
src/gallium/drivers/nouveau/nv50/nv50_miptree.c | 23 +++++++++++++++++++++--
src/gallium/drivers/nouveau/nv50/nv50_screen.c | 7 +++++++
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
index 1aacaec..13ed8a3 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c
@@ -65,8 +65,7 @@ nv50_tex_choose_tile_dims(unsigned nx, unsigned ny, unsigned
nz)
static uint32_t
nv50_mt_choose_storage_type(struct nv50_miptree *mt, boolean compressed)
{
- const unsigned ms = mt->ms_x + mt->ms_y;
-
+ const unsigned ms = util_logbase2(mt->base.base.nr_samples);
uint32_t tile_flags;
if (unlikely(mt->base.base.flags & NOUVEAU_RESOURCE_FLAG_LINEAR))
@@ -96,6 +95,26 @@ nv50_mt_choose_storage_type(struct nv50_miptree *mt, boolean
compressed)
tile_flags = 0x60 + ms;
break;
default:
+ switch (mt->base.base.format) {
+ case PIPE_FORMAT_R16G16B16A16_FLOAT:
+ case PIPE_FORMAT_R16G16B16X16_FLOAT:
+ case PIPE_FORMAT_R8G8B8A8_UNORM:
+ case PIPE_FORMAT_R8G8B8A8_SRGB:
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_B8G8R8A8_SRGB:
+ case PIPE_FORMAT_R10G10B10A2_UNORM:
+ case PIPE_FORMAT_B10G10R10A2_UNORM:
+ case PIPE_FORMAT_R11G11B10_FLOAT:
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_B8G8R8X8_SRGB:
+ case PIPE_FORMAT_R8G8B8X8_UNORM:
+ case PIPE_FORMAT_R8G8B8X8_SRGB:
+ /* Allow compression for these formats if desired */
+ break;
+ default:
+ compressed = false;
+ break;
+ }
switch (util_format_get_blocksizebits(mt->base.base.format)) {
case 128:
assert(ms < 3);
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index 2d8347b..da237f9 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -449,6 +449,13 @@ nv50_screen_init_hwctx(struct nv50_screen *screen)
PUSH_DATA (push, 0x18);
}
+ BEGIN_NV04(push, NV50_3D(ZETA_COMP_ENABLE), 1);
+ PUSH_DATA(push, screen->base.device->drm_version >= 0x01000101);
+
+ BEGIN_NV04(push, NV50_3D(RT_COMP_ENABLE(0)), 8);
+ for (i = 0; i < 8; ++i)
+ PUSH_DATA(push, screen->base.device->drm_version >= 0x01000101);
+
BEGIN_NV04(push, NV50_3D(RT_CONTROL), 1);
PUSH_DATA (push, 1);
--
2.2.1
On Fri, Jan 2, 2015 at 6:09 PM, Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de> wrote:> We enable compression only for some supported formats > > Suggested-by: Ilia Mirkin <imirkin at alum.mit.edu> > Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de> > --- > src/gallium/drivers/nouveau/nv50/nv50_miptree.c | 23 +++++++++++++++++++++-- > src/gallium/drivers/nouveau/nv50/nv50_screen.c | 7 +++++++ > 2 files changed, 28 insertions(+), 2 deletions(-) > > diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c > index 1aacaec..13ed8a3 100644 > --- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c > +++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c > @@ -65,8 +65,7 @@ nv50_tex_choose_tile_dims(unsigned nx, unsigned ny, unsigned nz) > static uint32_t > nv50_mt_choose_storage_type(struct nv50_miptree *mt, boolean compressed)The caller of this currently always says true. However it should probably be drm_version >= whatever.> { > - const unsigned ms = mt->ms_x + mt->ms_y; > - > + const unsigned ms = util_logbase2(mt->base.base.nr_samples); > uint32_t tile_flags; > > if (unlikely(mt->base.base.flags & NOUVEAU_RESOURCE_FLAG_LINEAR)) > @@ -96,6 +95,26 @@ nv50_mt_choose_storage_type(struct nv50_miptree *mt, boolean compressed) > tile_flags = 0x60 + ms; > break; > default: > + switch (mt->base.base.format) {You're already switching on the format. You could be all clever and do default: compressed = false; /* fallthrough */ case PIPE_FORMAT_A: case PIPE_FORMAT_B: switch (blocksize) { ... } It's a bit unusual to have the default case in the middle, but I'm pretty sure it works. BTW, I assume that there was no dmesg spam or piglit regressions with this change? -ilia
Tobias Klausmann
2015-Jan-02 23:50 UTC
[Nouveau] [PATCH v2] nv50: enable texture compression
On 03.01.2015 00:20, Ilia Mirkin wrote:> On Fri, Jan 2, 2015 at 6:09 PM, Tobias Klausmann > <tobias.johannes.klausmann at mni.thm.de> wrote: >> We enable compression only for some supported formats >> >> Suggested-by: Ilia Mirkin <imirkin at alum.mit.edu> >> Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de> >> --- >> src/gallium/drivers/nouveau/nv50/nv50_miptree.c | 23 +++++++++++++++++++++-- >> src/gallium/drivers/nouveau/nv50/nv50_screen.c | 7 +++++++ >> 2 files changed, 28 insertions(+), 2 deletions(-) >> >> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c >> index 1aacaec..13ed8a3 100644 >> --- a/src/gallium/drivers/nouveau/nv50/nv50_miptree.c >> +++ b/src/gallium/drivers/nouveau/nv50/nv50_miptree.c >> @@ -65,8 +65,7 @@ nv50_tex_choose_tile_dims(unsigned nx, unsigned ny, unsigned nz) >> static uint32_t >> nv50_mt_choose_storage_type(struct nv50_miptree *mt, boolean compressed) > The caller of this currently always says true. However it should > probably be drm_version >= whatever.Oh sure, i'll add it!> >> { >> - const unsigned ms = mt->ms_x + mt->ms_y; >> - >> + const unsigned ms = util_logbase2(mt->base.base.nr_samples); >> uint32_t tile_flags; >> >> if (unlikely(mt->base.base.flags & NOUVEAU_RESOURCE_FLAG_LINEAR)) >> @@ -96,6 +95,26 @@ nv50_mt_choose_storage_type(struct nv50_miptree *mt, boolean compressed) >> tile_flags = 0x60 + ms; >> break; >> default: >> + switch (mt->base.base.format) { > You're already switching on the format. You could be all clever and do > > default: > compressed = false; > /* fallthrough */ > case PIPE_FORMAT_A: > case PIPE_FORMAT_B: > switch (blocksize) { ... } > > It's a bit unusual to have the default case in the middle, but I'm > pretty sure it works.We talked about broken compilers, hope we don't hit one here :D> > BTW, I assume that there was no dmesg spam or piglit regressions with > this change?Indeed!> > -ilia