Re: [Mesa-dev] [PATCH v3 4/6] nouveau: Add framebuffer modifier support

2018-03-02 Thread Thierry Reding
On Fri, Mar 02, 2018 at 12:28:02PM +, Daniel Stone wrote:
> Hi,
> 
> On 2 March 2018 at 12:06, Thierry Reding  wrote:
> > On Thu, Mar 01, 2018 at 09:37:28AM -0500, Ilia Mirkin wrote:
> >> > +static void
> >> > +nvc0_query_dmabuf_modifiers(struct pipe_screen *screen,
> >> > +enum pipe_format format, int max,
> >>
> >> Maybe change this to "unsigned max"? That would avoid unnecessary
> >> complications below to check if it's negative.
> >
> > I would like that very much, but I'm afraid it's probably too late to
> > change this now because the signedness is handed down directly from the
> > EGL_EXT_image_dma_buf_import_modifiers extension:
> >
> > 
> > https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import_modifiers.txt
> >
> > Adding Pekka and Daniel for visibility, maybe there were reasons for why
> > these are explicitly signed. I'm not familiar with the process of
> > getting an extension changed, but, even though a very minor change, this
> > would be changing the API of a completed extension, which doesn't seem
> > like something that you're supposed to do.
> 
> The main reason was the precedent of, e.g., eglChooseConfig using
> EGLint. It's not ideal, but then again every time I type 'int i' these
> days I get a momentary shiver not knowing if it should be an unsigned
> int or not.

It also seems like EGL doesn't even define EGLuint, which would be a
good reason why everything is signed in the EGL API.

> > That said, the revision history of the extension mentions that revision
> > 4 introduced a new type for the modifiers, so perhaps there is some
> > leeway in what we can do.
> 
> r4 was made before the extension was actually finalised/used anywhere,
> so it's not really precedent.
> 
> > I guess we could always force a cast in dri2_query_dma_buf_modifiers()
> > if changing the extension is not possible. That way we could at least
> > internally not worry about the signedness.
> 
> If you think that'd make for a better Gallium interface, by all means
> please go for it, especially if it makes sense in the context of the
> rest of the Gallium API.

Yeah, I think it'd make sense. Gallium is already fairly consistently
using unsigned for values that can never be negative.

I was already halfway through the conversion when I noticed that this
comes originally from the EGL extension, so I'll wrap all of it into a
patch and send it out for review.

Thanks,
Thierry


signature.asc
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3 4/6] nouveau: Add framebuffer modifier support

2018-03-02 Thread Daniel Stone
Hi,

On 2 March 2018 at 12:06, Thierry Reding  wrote:
> On Thu, Mar 01, 2018 at 09:37:28AM -0500, Ilia Mirkin wrote:
>> > +static void
>> > +nvc0_query_dmabuf_modifiers(struct pipe_screen *screen,
>> > +enum pipe_format format, int max,
>>
>> Maybe change this to "unsigned max"? That would avoid unnecessary
>> complications below to check if it's negative.
>
> I would like that very much, but I'm afraid it's probably too late to
> change this now because the signedness is handed down directly from the
> EGL_EXT_image_dma_buf_import_modifiers extension:
>
> 
> https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import_modifiers.txt
>
> Adding Pekka and Daniel for visibility, maybe there were reasons for why
> these are explicitly signed. I'm not familiar with the process of
> getting an extension changed, but, even though a very minor change, this
> would be changing the API of a completed extension, which doesn't seem
> like something that you're supposed to do.

The main reason was the precedent of, e.g., eglChooseConfig using
EGLint. It's not ideal, but then again every time I type 'int i' these
days I get a momentary shiver not knowing if it should be an unsigned
int or not.

> That said, the revision history of the extension mentions that revision
> 4 introduced a new type for the modifiers, so perhaps there is some
> leeway in what we can do.

r4 was made before the extension was actually finalised/used anywhere,
so it's not really precedent.

> I guess we could always force a cast in dri2_query_dma_buf_modifiers()
> if changing the extension is not possible. That way we could at least
> internally not worry about the signedness.

If you think that'd make for a better Gallium interface, by all means
please go for it, especially if it makes sense in the context of the
rest of the Gallium API.

Cheers,
Daniel
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3 4/6] nouveau: Add framebuffer modifier support

2018-03-02 Thread Thierry Reding
On Thu, Mar 01, 2018 at 09:04:58AM -0800, Dylan Baker wrote:
> Quoting Thierry Reding (2018-03-01 05:54:52)
> > From: Thierry Reding 
> > 
> > This adds support for framebuffer modifiers to Nouveau. This will be
> > used by the Tegra driver to share metadata about the format of buffers
> > (such as the tiling mode or compression).
> > 
> > Changes in v2:
> > - remove unused parameters to nouveau_buffer_create()
> > - move format modifier query code to nvc0 backend
> > - restrict format modifiers to 2D textures
> > - implement ->query_dmabuf_modifiers()
> > 
> > Acked-by: Emil Velikov 
> > Tested-by: Andre Heider 
> > Signed-off-by: Thierry Reding 
> > ---
> >  src/gallium/drivers/nouveau/Android.mk   |  3 +
> >  src/gallium/drivers/nouveau/Makefile.am  |  1 +
> >  src/gallium/drivers/nouveau/nouveau_screen.c |  4 ++
> >  src/gallium/drivers/nouveau/nv30/nv30_resource.c |  2 +
> >  src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c  | 81 
> > +++-
> >  src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 59 -
> >  src/gallium/drivers/nouveau/nvc0/nvc0_resource.h |  3 +-
> >  7 files changed, 149 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/gallium/drivers/nouveau/Android.mk 
> > b/src/gallium/drivers/nouveau/Android.mk
> > index 2de22e73ec18..a446774a86e8 100644
> > --- a/src/gallium/drivers/nouveau/Android.mk
> > +++ b/src/gallium/drivers/nouveau/Android.mk
> > @@ -36,6 +36,9 @@ LOCAL_SRC_FILES := \
> > $(NVC0_CODEGEN_SOURCES) \
> > $(NVC0_C_SOURCES)
> >  
> > +LOCAL_C_INCLUDES := \
> > +   $(MESA_TOP)/include/drm-uapi
> > +
> >  LOCAL_SHARED_LIBRARIES := libdrm_nouveau
> >  LOCAL_MODULE := libmesa_pipe_nouveau
> >  
> > diff --git a/src/gallium/drivers/nouveau/Makefile.am 
> > b/src/gallium/drivers/nouveau/Makefile.am
> > index 91547178e397..f6126b544811 100644
> > --- a/src/gallium/drivers/nouveau/Makefile.am
> > +++ b/src/gallium/drivers/nouveau/Makefile.am
> > @@ -24,6 +24,7 @@ include Makefile.sources
> >  include $(top_srcdir)/src/gallium/Automake.inc
> >  
> >  AM_CPPFLAGS = \
> > +   -I$(top_srcdir)/include/drm-uapi \
> 
> This needs to be added for the meson build as well, right? Should just need to
> add "inc_drm_uapi" to the relevant "include_directories" lines.

It seems like this was working "by accident" for me because I was
building against a locally modified version of libdrm that provided the
necessary UABI changes.

Fixed now.

Thierry


signature.asc
Description: PGP signature
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH v3 4/6] nouveau: Add framebuffer modifier support

2018-03-02 Thread Thierry Reding
On Thu, Mar 01, 2018 at 09:37:28AM -0500, Ilia Mirkin wrote:
> On Thu, Mar 1, 2018 at 8:54 AM, Thierry Reding  
> wrote:
> > From: Thierry Reding 
> >
> > This adds support for framebuffer modifiers to Nouveau. This will be
> > used by the Tegra driver to share metadata about the format of buffers
> > (such as the tiling mode or compression).
> >
> > Changes in v2:
> > - remove unused parameters to nouveau_buffer_create()
> > - move format modifier query code to nvc0 backend
> > - restrict format modifiers to 2D textures
> > - implement ->query_dmabuf_modifiers()
> >
> > Acked-by: Emil Velikov 
> > Tested-by: Andre Heider 
> > Signed-off-by: Thierry Reding 
> > ---
> >  src/gallium/drivers/nouveau/Android.mk   |  3 +
> >  src/gallium/drivers/nouveau/Makefile.am  |  1 +
> >  src/gallium/drivers/nouveau/nouveau_screen.c |  4 ++
> >  src/gallium/drivers/nouveau/nv30/nv30_resource.c |  2 +
> >  src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c  | 81 
> > +++-
> >  src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 59 -
> >  src/gallium/drivers/nouveau/nvc0/nvc0_resource.h |  3 +-
> >  7 files changed, 149 insertions(+), 4 deletions(-)
> >
> > diff --git a/src/gallium/drivers/nouveau/Android.mk 
> > b/src/gallium/drivers/nouveau/Android.mk
> > index 2de22e73ec18..a446774a86e8 100644
> > --- a/src/gallium/drivers/nouveau/Android.mk
> > +++ b/src/gallium/drivers/nouveau/Android.mk
> > @@ -36,6 +36,9 @@ LOCAL_SRC_FILES := \
> > $(NVC0_CODEGEN_SOURCES) \
> > $(NVC0_C_SOURCES)
> >
> > +LOCAL_C_INCLUDES := \
> > +   $(MESA_TOP)/include/drm-uapi
> > +
> >  LOCAL_SHARED_LIBRARIES := libdrm_nouveau
> >  LOCAL_MODULE := libmesa_pipe_nouveau
> >
> > diff --git a/src/gallium/drivers/nouveau/Makefile.am 
> > b/src/gallium/drivers/nouveau/Makefile.am
> > index 91547178e397..f6126b544811 100644
> > --- a/src/gallium/drivers/nouveau/Makefile.am
> > +++ b/src/gallium/drivers/nouveau/Makefile.am
> > @@ -24,6 +24,7 @@ include Makefile.sources
> >  include $(top_srcdir)/src/gallium/Automake.inc
> >
> >  AM_CPPFLAGS = \
> > +   -I$(top_srcdir)/include/drm-uapi \
> > $(GALLIUM_DRIVER_CFLAGS) \
> > $(LIBDRM_CFLAGS) \
> > $(NOUVEAU_CFLAGS)
> 
> Someone is likely to complain about forgetting about the N+1 build
> system, meson.

Interestingly I wasn't seeing any build issues without the Meson change.
I think that was probably just out of luck because I was building
against a locally modifier version of libdrm which had the UAPI changes.

Fixed now.

> > diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c 
> > b/src/gallium/drivers/nouveau/nouveau_screen.c
> > index c144b39b2dd2..b84ef13ebe7f 100644
> > --- a/src/gallium/drivers/nouveau/nouveau_screen.c
> > +++ b/src/gallium/drivers/nouveau/nouveau_screen.c
> > @@ -1,3 +1,5 @@
> > +#include 
> > +
> >  #include "pipe/p_defines.h"
> >  #include "pipe/p_screen.h"
> >  #include "pipe/p_state.h"
> > @@ -23,6 +25,8 @@
> >  #include "nouveau_mm.h"
> >  #include "nouveau_buffer.h"
> >
> > +#include "nvc0/nvc0_resource.h"
> 
> Can't have that... why do you need it here?

I don't. This is left over from an earlier version where code later in
this file was calling into the nvc0 backend directly. I've since then
pushed that code into the nvc0 backend itself but forgot to remove the
include here.

Dropped now.

> > +
> >  /* XXX this should go away */
> >  #include "state_tracker/drm_driver.h"
> >
> > diff --git a/src/gallium/drivers/nouveau/nv30/nv30_resource.c 
> > b/src/gallium/drivers/nouveau/nv30/nv30_resource.c
> > index ff34f6e5f9fa..386bd3459bd3 100644
> > --- a/src/gallium/drivers/nouveau/nv30/nv30_resource.c
> > +++ b/src/gallium/drivers/nouveau/nv30/nv30_resource.c
> > @@ -23,6 +23,8 @@
> >   *
> >   */
> >
> > +#include 
> > +
> >  #include "util/u_format.h"
> >  #include "util/u_inlines.h"
> >
> > diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c 
> > b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
> > index 27674f72a7c0..7983c4030876 100644
> > --- a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
> > +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
> > @@ -20,8 +20,11 @@
> >   * OTHER DEALINGS IN THE SOFTWARE.
> >   */
> >
> > +#include 
> > +
> >  #include "pipe/p_state.h"
> >  #include "pipe/p_defines.h"
> > +#include "state_tracker/drm_driver.h"
> >  #include "util/u_inlines.h"
> >  #include "util/u_format.h"
> >
> > @@ -233,9 +236,79 @@ nvc0_miptree_init_layout_tiled(struct nv50_miptree *mt)
> > }
> >  }
> >
> > +static uint64_t nvc0_miptree_get_modifier(struct nv50_miptree *mt)
> > +{
> > +   union nouveau_bo_config *config = >base.bo->config;
> > +   uint64_t modifier;
> > +
> > +   if (mt->layout_3d)
> > +  return DRM_FORMAT_MOD_INVALID;
> > +
> > +   switch (config->nvc0.memtype) {
> > +   case 0x00:
> > +  modifier = 

Re: [Mesa-dev] [PATCH v3 4/6] nouveau: Add framebuffer modifier support

2018-03-01 Thread Dylan Baker
Quoting Thierry Reding (2018-03-01 05:54:52)
> From: Thierry Reding 
> 
> This adds support for framebuffer modifiers to Nouveau. This will be
> used by the Tegra driver to share metadata about the format of buffers
> (such as the tiling mode or compression).
> 
> Changes in v2:
> - remove unused parameters to nouveau_buffer_create()
> - move format modifier query code to nvc0 backend
> - restrict format modifiers to 2D textures
> - implement ->query_dmabuf_modifiers()
> 
> Acked-by: Emil Velikov 
> Tested-by: Andre Heider 
> Signed-off-by: Thierry Reding 
> ---
>  src/gallium/drivers/nouveau/Android.mk   |  3 +
>  src/gallium/drivers/nouveau/Makefile.am  |  1 +
>  src/gallium/drivers/nouveau/nouveau_screen.c |  4 ++
>  src/gallium/drivers/nouveau/nv30/nv30_resource.c |  2 +
>  src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c  | 81 
> +++-
>  src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 59 -
>  src/gallium/drivers/nouveau/nvc0/nvc0_resource.h |  3 +-
>  7 files changed, 149 insertions(+), 4 deletions(-)
> 
> diff --git a/src/gallium/drivers/nouveau/Android.mk 
> b/src/gallium/drivers/nouveau/Android.mk
> index 2de22e73ec18..a446774a86e8 100644
> --- a/src/gallium/drivers/nouveau/Android.mk
> +++ b/src/gallium/drivers/nouveau/Android.mk
> @@ -36,6 +36,9 @@ LOCAL_SRC_FILES := \
> $(NVC0_CODEGEN_SOURCES) \
> $(NVC0_C_SOURCES)
>  
> +LOCAL_C_INCLUDES := \
> +   $(MESA_TOP)/include/drm-uapi
> +
>  LOCAL_SHARED_LIBRARIES := libdrm_nouveau
>  LOCAL_MODULE := libmesa_pipe_nouveau
>  
> diff --git a/src/gallium/drivers/nouveau/Makefile.am 
> b/src/gallium/drivers/nouveau/Makefile.am
> index 91547178e397..f6126b544811 100644
> --- a/src/gallium/drivers/nouveau/Makefile.am
> +++ b/src/gallium/drivers/nouveau/Makefile.am
> @@ -24,6 +24,7 @@ include Makefile.sources
>  include $(top_srcdir)/src/gallium/Automake.inc
>  
>  AM_CPPFLAGS = \
> +   -I$(top_srcdir)/include/drm-uapi \

This needs to be added for the meson build as well, right? Should just need to
add "inc_drm_uapi" to the relevant "include_directories" lines.

> $(GALLIUM_DRIVER_CFLAGS) \
> $(LIBDRM_CFLAGS) \
> $(NOUVEAU_CFLAGS)
> diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c 
> b/src/gallium/drivers/nouveau/nouveau_screen.c
> index c144b39b2dd2..b84ef13ebe7f 100644
> --- a/src/gallium/drivers/nouveau/nouveau_screen.c
> +++ b/src/gallium/drivers/nouveau/nouveau_screen.c
> @@ -1,3 +1,5 @@
> +#include 
> +
>  #include "pipe/p_defines.h"
>  #include "pipe/p_screen.h"
>  #include "pipe/p_state.h"
> @@ -23,6 +25,8 @@
>  #include "nouveau_mm.h"
>  #include "nouveau_buffer.h"
>  
> +#include "nvc0/nvc0_resource.h"
> +
>  /* XXX this should go away */
>  #include "state_tracker/drm_driver.h"
>  
> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_resource.c 
> b/src/gallium/drivers/nouveau/nv30/nv30_resource.c
> index ff34f6e5f9fa..386bd3459bd3 100644
> --- a/src/gallium/drivers/nouveau/nv30/nv30_resource.c
> +++ b/src/gallium/drivers/nouveau/nv30/nv30_resource.c
> @@ -23,6 +23,8 @@
>   *
>   */
>  
> +#include 
> +
>  #include "util/u_format.h"
>  #include "util/u_inlines.h"
>  
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c 
> b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
> index 27674f72a7c0..7983c4030876 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
> @@ -20,8 +20,11 @@
>   * OTHER DEALINGS IN THE SOFTWARE.
>   */
>  
> +#include 
> +
>  #include "pipe/p_state.h"
>  #include "pipe/p_defines.h"
> +#include "state_tracker/drm_driver.h"
>  #include "util/u_inlines.h"
>  #include "util/u_format.h"
>  
> @@ -233,9 +236,79 @@ nvc0_miptree_init_layout_tiled(struct nv50_miptree *mt)
> }
>  }
>  
> +static uint64_t nvc0_miptree_get_modifier(struct nv50_miptree *mt)
> +{
> +   union nouveau_bo_config *config = >base.bo->config;
> +   uint64_t modifier;
> +
> +   if (mt->layout_3d)
> +  return DRM_FORMAT_MOD_INVALID;
> +
> +   switch (config->nvc0.memtype) {
> +   case 0x00:
> +  modifier = DRM_FORMAT_MOD_LINEAR;
> +  break;
> +
> +   case 0xfe:
> +  switch (NVC0_TILE_MODE_Y(config->nvc0.tile_mode)) {
> +  case 0:
> + modifier = DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB;
> + break;
> +
> +  case 1:
> + modifier = DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB;
> + break;
> +
> +  case 2:
> + modifier = DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB;
> + break;
> +
> +  case 3:
> + modifier = DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB;
> + break;
> +
> +  case 4:
> + modifier = DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB;
> + break;
> +
> +  case 5:
> + modifier = DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB;
> + break;
> +
> +  default:

Re: [Mesa-dev] [PATCH v3 4/6] nouveau: Add framebuffer modifier support

2018-03-01 Thread Ilia Mirkin
On Thu, Mar 1, 2018 at 8:54 AM, Thierry Reding  wrote:
> From: Thierry Reding 
>
> This adds support for framebuffer modifiers to Nouveau. This will be
> used by the Tegra driver to share metadata about the format of buffers
> (such as the tiling mode or compression).
>
> Changes in v2:
> - remove unused parameters to nouveau_buffer_create()
> - move format modifier query code to nvc0 backend
> - restrict format modifiers to 2D textures
> - implement ->query_dmabuf_modifiers()
>
> Acked-by: Emil Velikov 
> Tested-by: Andre Heider 
> Signed-off-by: Thierry Reding 
> ---
>  src/gallium/drivers/nouveau/Android.mk   |  3 +
>  src/gallium/drivers/nouveau/Makefile.am  |  1 +
>  src/gallium/drivers/nouveau/nouveau_screen.c |  4 ++
>  src/gallium/drivers/nouveau/nv30/nv30_resource.c |  2 +
>  src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c  | 81 
> +++-
>  src/gallium/drivers/nouveau/nvc0/nvc0_resource.c | 59 -
>  src/gallium/drivers/nouveau/nvc0/nvc0_resource.h |  3 +-
>  7 files changed, 149 insertions(+), 4 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/Android.mk 
> b/src/gallium/drivers/nouveau/Android.mk
> index 2de22e73ec18..a446774a86e8 100644
> --- a/src/gallium/drivers/nouveau/Android.mk
> +++ b/src/gallium/drivers/nouveau/Android.mk
> @@ -36,6 +36,9 @@ LOCAL_SRC_FILES := \
> $(NVC0_CODEGEN_SOURCES) \
> $(NVC0_C_SOURCES)
>
> +LOCAL_C_INCLUDES := \
> +   $(MESA_TOP)/include/drm-uapi
> +
>  LOCAL_SHARED_LIBRARIES := libdrm_nouveau
>  LOCAL_MODULE := libmesa_pipe_nouveau
>
> diff --git a/src/gallium/drivers/nouveau/Makefile.am 
> b/src/gallium/drivers/nouveau/Makefile.am
> index 91547178e397..f6126b544811 100644
> --- a/src/gallium/drivers/nouveau/Makefile.am
> +++ b/src/gallium/drivers/nouveau/Makefile.am
> @@ -24,6 +24,7 @@ include Makefile.sources
>  include $(top_srcdir)/src/gallium/Automake.inc
>
>  AM_CPPFLAGS = \
> +   -I$(top_srcdir)/include/drm-uapi \
> $(GALLIUM_DRIVER_CFLAGS) \
> $(LIBDRM_CFLAGS) \
> $(NOUVEAU_CFLAGS)

Someone is likely to complain about forgetting about the N+1 build
system, meson.

> diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c 
> b/src/gallium/drivers/nouveau/nouveau_screen.c
> index c144b39b2dd2..b84ef13ebe7f 100644
> --- a/src/gallium/drivers/nouveau/nouveau_screen.c
> +++ b/src/gallium/drivers/nouveau/nouveau_screen.c
> @@ -1,3 +1,5 @@
> +#include 
> +
>  #include "pipe/p_defines.h"
>  #include "pipe/p_screen.h"
>  #include "pipe/p_state.h"
> @@ -23,6 +25,8 @@
>  #include "nouveau_mm.h"
>  #include "nouveau_buffer.h"
>
> +#include "nvc0/nvc0_resource.h"

Can't have that... why do you need it here?

> +
>  /* XXX this should go away */
>  #include "state_tracker/drm_driver.h"
>
> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_resource.c 
> b/src/gallium/drivers/nouveau/nv30/nv30_resource.c
> index ff34f6e5f9fa..386bd3459bd3 100644
> --- a/src/gallium/drivers/nouveau/nv30/nv30_resource.c
> +++ b/src/gallium/drivers/nouveau/nv30/nv30_resource.c
> @@ -23,6 +23,8 @@
>   *
>   */
>
> +#include 
> +
>  #include "util/u_format.h"
>  #include "util/u_inlines.h"
>
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c 
> b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
> index 27674f72a7c0..7983c4030876 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_miptree.c
> @@ -20,8 +20,11 @@
>   * OTHER DEALINGS IN THE SOFTWARE.
>   */
>
> +#include 
> +
>  #include "pipe/p_state.h"
>  #include "pipe/p_defines.h"
> +#include "state_tracker/drm_driver.h"
>  #include "util/u_inlines.h"
>  #include "util/u_format.h"
>
> @@ -233,9 +236,79 @@ nvc0_miptree_init_layout_tiled(struct nv50_miptree *mt)
> }
>  }
>
> +static uint64_t nvc0_miptree_get_modifier(struct nv50_miptree *mt)
> +{
> +   union nouveau_bo_config *config = >base.bo->config;
> +   uint64_t modifier;
> +
> +   if (mt->layout_3d)
> +  return DRM_FORMAT_MOD_INVALID;
> +
> +   switch (config->nvc0.memtype) {
> +   case 0x00:
> +  modifier = DRM_FORMAT_MOD_LINEAR;
> +  break;
> +
> +   case 0xfe:
> +  switch (NVC0_TILE_MODE_Y(config->nvc0.tile_mode)) {
> +  case 0:
> + modifier = DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_ONE_GOB;
> + break;
> +
> +  case 1:
> + modifier = DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_TWO_GOB;
> + break;
> +
> +  case 2:
> + modifier = DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_FOUR_GOB;
> + break;
> +
> +  case 3:
> + modifier = DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_EIGHT_GOB;
> + break;
> +
> +  case 4:
> + modifier = DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_SIXTEEN_GOB;
> + break;
> +
> +  case 5:
> + modifier = DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK_THIRTYTWO_GOB;
> + break;
> +
> +  default:
> +