nvc0_tex.c revision 95058bdec31d3faa76be01731a26939f3039a66b
14c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller/*
24c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * Copyright 2008 Ben Skeggs
34c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller *
44c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * Permission is hereby granted, free of charge, to any person obtaining a
54c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * copy of this software and associated documentation files (the "Software"),
64c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * to deal in the Software without restriction, including without limitation
74c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * the rights to use, copy, modify, merge, publish, distribute, sublicense,
84c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * and/or sell copies of the Software, and to permit persons to whom the
94c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * Software is furnished to do so, subject to the following conditions:
104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller *
114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * The above copyright notice and this permission notice shall be included in
124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * all copies or substantial portions of the Software.
134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller *
144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
173d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
183d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
193d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
203d8d5b298a268b119d840bc9bae0ee9e0c9244a9Kenneth Graunke * OTHER DEALINGS IN THE SOFTWARE.
214c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller */
224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
235eb7ff1175a644ffe3b0f1a75cb235400355f9fbJohannes Obermayr#include "nvc0/nvc0_context.h"
245eb7ff1175a644ffe3b0f1a75cb235400355f9fbJohannes Obermayr#include "nvc0/nvc0_resource.h"
25e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller#include "nv50/nv50_texture.xml.h"
26e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller#include "nv50/nv50_defs.xml.h"
274c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller#include "util/u_format.h"
294c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
30e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller#define NVE4_TIC_ENTRY_INVALID 0x000fffff
31e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller#define NVE4_TSC_ENTRY_INVALID 0xfff00000
32e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
33e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller#define NV50_TIC_0_SWIZZLE__MASK                      \
34e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller   (NV50_TIC_0_MAPA__MASK | NV50_TIC_0_MAPB__MASK |   \
35e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller    NV50_TIC_0_MAPG__MASK | NV50_TIC_0_MAPR__MASK)
36e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller
374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic INLINE uint32_t
38e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumillernv50_tic_swizzle(uint32_t tc, unsigned swz, boolean tex_int)
394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
404c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   switch (swz) {
414c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_SWIZZLE_RED:
424c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      return (tc & NV50_TIC_0_MAPR__MASK) >> NV50_TIC_0_MAPR__SHIFT;
434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_SWIZZLE_GREEN:
444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      return (tc & NV50_TIC_0_MAPG__MASK) >> NV50_TIC_0_MAPG__SHIFT;
454c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_SWIZZLE_BLUE:
464c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      return (tc & NV50_TIC_0_MAPB__MASK) >> NV50_TIC_0_MAPB__SHIFT;
474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_SWIZZLE_ALPHA:
484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      return (tc & NV50_TIC_0_MAPA__MASK) >> NV50_TIC_0_MAPA__SHIFT;
494c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_SWIZZLE_ONE:
50e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller      return tex_int ? NV50_TIC_MAP_ONE_INT : NV50_TIC_MAP_ONE_FLOAT;
514c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_SWIZZLE_ZERO:
524c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   default:
534c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      return NV50_TIC_MAP_ZERO;
544c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
554c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
564c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
574c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstruct pipe_sampler_view *
584c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_create_sampler_view(struct pipe_context *pipe,
5936ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller                         struct pipe_resource *res,
604c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller                         const struct pipe_sampler_view *templ)
614c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
6236ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller   uint32_t flags = 0;
6336ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller
6495058bdec31d3faa76be01731a26939f3039a66bIlia Mirkin   if (templ->target == PIPE_TEXTURE_RECT || templ->target == PIPE_BUFFER)
6536ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller      flags |= NV50_TEXVIEW_SCALED_COORDS;
6636ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller
6795058bdec31d3faa76be01731a26939f3039a66bIlia Mirkin   return nvc0_create_texture_view(pipe, res, templ, flags, templ->target);
6836ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller}
6936ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller
7036ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumillerstruct pipe_sampler_view *
7136ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumillernvc0_create_texture_view(struct pipe_context *pipe,
7236ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller                         struct pipe_resource *texture,
7336ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller                         const struct pipe_sampler_view *templ,
7436ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller                         uint32_t flags,
7536ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller                         enum pipe_texture_target target)
7636ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller{
774c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   const struct util_format_description *desc;
786d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller   uint64_t address;
794c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   uint32_t *tic;
804c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   uint32_t swz[4];
814da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller   uint32_t width, height;
82ca5deb0c355cc4a120b754a228ff5f51007fbceaChristoph Bumiller   uint32_t depth;
831f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller   struct nv50_tic_entry *view;
8428271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller   struct nv50_miptree *mt;
85e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller   boolean tex_int;
864c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
871f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller   view = MALLOC_STRUCT(nv50_tic_entry);
884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   if (!view)
894c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      return NULL;
906d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller   mt = nv50_miptree(texture);
914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
924c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   view->pipe = *templ;
934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   view->pipe.reference.count = 1;
944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   view->pipe.texture = NULL;
954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   view->pipe.context = pipe;
964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
974c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   view->id = -1;
984c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
994c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   pipe_resource_reference(&view->pipe.texture, texture);
1004c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1014c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   tic = &view->tic[0];
1024c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
103b0698396dcc70f6c8a16090dfb1674996538db3aChristoph Bumiller   desc = util_format_description(view->pipe.format);
1044c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1054c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   tic[0] = nvc0_format_table[view->pipe.format].tic;
1064c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1079934bfe28d3c0f6551ba2cc806a7fe8e0a16ed7cChristoph Bumiller   tex_int = util_format_is_pure_integer(view->pipe.format);
108e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller
109e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller   swz[0] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_r, tex_int);
110e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller   swz[1] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_g, tex_int);
111e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller   swz[2] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_b, tex_int);
112e4c968cdbbdc020afbf869d12b536c0a0dbf9de8Christoph Bumiller   swz[3] = nv50_tic_swizzle(tic[0], view->pipe.swizzle_a, tex_int);
1134c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   tic[0] = (tic[0] & ~NV50_TIC_0_SWIZZLE__MASK) |
1144c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      (swz[0] << NV50_TIC_0_MAPR__SHIFT) |
1154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      (swz[1] << NV50_TIC_0_MAPG__SHIFT) |
1164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      (swz[2] << NV50_TIC_0_MAPB__SHIFT) |
1174c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      (swz[3] << NV50_TIC_0_MAPA__SHIFT);
1184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1196d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller   address = mt->base.address;
1204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1216d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller   tic[2] = 0x10001000 | NV50_TIC_2_NO_BORDER;
1224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1234c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB)
1244c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      tic[2] |= NV50_TIC_2_COLORSPACE_SRGB;
1254c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
126f0a0d59f0fdceb756838ad6dad012852ba48362eChristoph Bumiller   if (!(flags & NV50_TEXVIEW_SCALED_COORDS))
127f0a0d59f0fdceb756838ad6dad012852ba48362eChristoph Bumiller      tic[2] |= NV50_TIC_2_NORMALIZED_COORDS;
128f0a0d59f0fdceb756838ad6dad012852ba48362eChristoph Bumiller
12928271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller   /* check for linear storage type */
1306d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller   if (unlikely(!nouveau_bo_memtype(nv04_resource(texture)->bo))) {
13128271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller      if (texture->target == PIPE_BUFFER) {
132f0a0d59f0fdceb756838ad6dad012852ba48362eChristoph Bumiller         assert(!(tic[2] & NV50_TIC_2_NORMALIZED_COORDS));
1336d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         address +=
13428271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller            view->pipe.u.buf.first_element * desc->block.bits / 8;
1356d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         tic[2] |= NV50_TIC_2_LINEAR | NV50_TIC_2_TARGET_BUFFER;
13628271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller         tic[3] = 0;
13728271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller         tic[4] = /* width */
13828271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller            view->pipe.u.buf.last_element - view->pipe.u.buf.first_element + 1;
1396d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         tic[5] = 0;
14028271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller      } else {
14128271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller         /* must be 2D texture without mip maps */
14228271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller         tic[2] |= NV50_TIC_2_LINEAR | NV50_TIC_2_TARGET_RECT;
14328271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller         tic[3] = mt->level[0].pitch;
14428271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller         tic[4] = mt->base.base.width0;
14528271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller         tic[5] = (1 << 16) | mt->base.base.height0;
14628271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller      }
14728271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller      tic[6] =
14828271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller      tic[7] = 0;
1496d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller      tic[1] = address;
1506d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller      tic[2] |= address >> 32;
15128271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller      return &view->pipe;
15228271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller   }
15328271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller
1544c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   tic[2] |=
1556d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller      ((mt->level[0].tile_mode & 0x0f0) << (22 - 4)) |
1566d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller      ((mt->level[0].tile_mode & 0xf00) << (25 - 8));
157ca5deb0c355cc4a120b754a228ff5f51007fbceaChristoph Bumiller
158ca5deb0c355cc4a120b754a228ff5f51007fbceaChristoph Bumiller   depth = MAX2(mt->base.base.array_size, mt->base.base.depth0);
1594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
1608828004e674b2036c23dd6b4a26cf94b98327792Christoph Bumiller   if (mt->base.base.array_size > 1) {
1614fae7da9a3a3849ca08ffc6fcbdccc6a9c065ad2Christoph Bumiller      /* there doesn't seem to be a base layer field in TIC */
1626d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller      address += view->pipe.u.tex.first_layer * mt->layer_stride;
1634fae7da9a3a3849ca08ffc6fcbdccc6a9c065ad2Christoph Bumiller      depth = view->pipe.u.tex.last_layer - view->pipe.u.tex.first_layer + 1;
1644fae7da9a3a3849ca08ffc6fcbdccc6a9c065ad2Christoph Bumiller   }
1656d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller   tic[1] = address;
1666d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller   tic[2] |= address >> 32;
1674fae7da9a3a3849ca08ffc6fcbdccc6a9c065ad2Christoph Bumiller
16836ea744f58e5b436c45ed857bd92bbb472e641d5Christoph Bumiller   switch (target) {
1694c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_TEXTURE_1D:
1704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      tic[2] |= NV50_TIC_2_TARGET_1D;
1714c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      break;
1724c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_TEXTURE_2D:
1734c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      tic[2] |= NV50_TIC_2_TARGET_2D;
1744c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      break;
1754c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_TEXTURE_RECT:
1761baf77dbe89e58c83287aa1662d64bafc727d565Ilia Mirkin      tic[2] |= NV50_TIC_2_TARGET_2D;
1774c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      break;
1784c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_TEXTURE_3D:
1794c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      tic[2] |= NV50_TIC_2_TARGET_3D;
1804c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      break;
1814c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   case PIPE_TEXTURE_CUBE:
182ca5deb0c355cc4a120b754a228ff5f51007fbceaChristoph Bumiller      depth /= 6;
183f7599b2c32185535b4c215de0ba0454129fa523fChristoph Bumiller      tic[2] |= NV50_TIC_2_TARGET_CUBE;
184ca5deb0c355cc4a120b754a228ff5f51007fbceaChristoph Bumiller      break;
185ca5deb0c355cc4a120b754a228ff5f51007fbceaChristoph Bumiller   case PIPE_TEXTURE_1D_ARRAY:
186ca5deb0c355cc4a120b754a228ff5f51007fbceaChristoph Bumiller      tic[2] |= NV50_TIC_2_TARGET_1D_ARRAY;
187ca5deb0c355cc4a120b754a228ff5f51007fbceaChristoph Bumiller      break;
188ca5deb0c355cc4a120b754a228ff5f51007fbceaChristoph Bumiller   case PIPE_TEXTURE_2D_ARRAY:
189ca5deb0c355cc4a120b754a228ff5f51007fbceaChristoph Bumiller      tic[2] |= NV50_TIC_2_TARGET_2D_ARRAY;
1904c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      break;
191f7599b2c32185535b4c215de0ba0454129fa523fChristoph Bumiller   case PIPE_TEXTURE_CUBE_ARRAY:
192f7599b2c32185535b4c215de0ba0454129fa523fChristoph Bumiller      depth /= 6;
193f7599b2c32185535b4c215de0ba0454129fa523fChristoph Bumiller      tic[2] |= NV50_TIC_2_TARGET_CUBE_ARRAY;
194f7599b2c32185535b4c215de0ba0454129fa523fChristoph Bumiller      break;
1954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   default:
1964da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller      NOUVEAU_ERR("unexpected/invalid texture target: %d\n",
1974da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller                  mt->base.base.target);
1984c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      return FALSE;
1994c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
2004c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2014da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller   tic[3] = (flags & NV50_TEXVIEW_FILTER_MSAA8) ? 0x20000000 : 0x00300000;
2024da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller
2034da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller   if (flags & NV50_TEXVIEW_ACCESS_RESOLVE) {
2044da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller      width = mt->base.base.width0 << mt->ms_x;
2054da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller      height = mt->base.base.height0 << mt->ms_y;
2064da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller   } else {
2074da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller      width = mt->base.base.width0;
2084da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller      height = mt->base.base.height0;
2094da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller   }
2104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2114da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller   tic[4] = (1 << 31) | width;
2124c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2134da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller   tic[5] = height & 0xffff;
214ca5deb0c355cc4a120b754a228ff5f51007fbceaChristoph Bumiller   tic[5] |= depth << 16;
2154c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   tic[5] |= mt->base.base.last_level << 28;
2164c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2174da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller   /* sampling points: (?) */
2184da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller   if (flags & NV50_TEXVIEW_ACCESS_RESOLVE)
2194da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller      tic[6] = (mt->ms_x > 1) ? 0x88000000 : 0x03000000;
2204da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller   else
2214da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller      tic[6] = 0x03000000;
2224c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
223ca5deb0c355cc4a120b754a228ff5f51007fbceaChristoph Bumiller   tic[7] = (view->pipe.u.tex.last_level << 4) | view->pipe.u.tex.first_level;
2244da54c91d24da891c56957f29274e7821c8254f6Christoph Bumiller   tic[7] |= mt->ms_mode << 12;
225b2dcf880e8bcd61be59602f5a2d18c77a5fc60c1Christoph Bumiller
2264c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   return &view->pipe;
2274c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
2284c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2294c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic boolean
2304c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_validate_tic(struct nvc0_context *nvc0, int s)
2314c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
232784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   uint32_t commands[32];
2336d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller   struct nouveau_pushbuf *push = nvc0->base.pushbuf;
23492f3642a4fe71b272b4ceb6953fbf55d1efcbeb5Christoph Bumiller   struct nouveau_bo *txc = nvc0->screen->txc;
2354c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   unsigned i;
236784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   unsigned n = 0;
2374c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   boolean need_flush = FALSE;
2384c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2394c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   for (i = 0; i < nvc0->num_textures[s]; ++i) {
2401f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller      struct nv50_tic_entry *tic = nv50_tic_entry(nvc0->textures[s][i]);
2414826cd0f6125b071530026143ffd8205d84b3d5eBen Skeggs      struct nv04_resource *res;
242784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      const boolean dirty = !!(nvc0->textures_dirty[s] & (1 << i));
2434c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2444c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      if (!tic) {
245784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller         if (dirty)
246784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller            commands[n++] = (i << 1) | 0;
2474c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller         continue;
2484c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      }
24928271fd00dc5dd83f95b5cb890e0ab2c0ff6159dChristoph Bumiller      res = nv04_resource(tic->pipe.texture);
2504c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2514c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      if (tic->id < 0) {
2524c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller         tic->id = nvc0_screen_tic_alloc(nvc0->screen, tic);
2534c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2546d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         PUSH_SPACE(push, 17);
2556d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         BEGIN_NVC0(push, NVC0_M2MF(OFFSET_OUT_HIGH), 2);
2566d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         PUSH_DATAh(push, txc->offset + (tic->id * 32));
2576d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         PUSH_DATA (push, txc->offset + (tic->id * 32));
2586d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         BEGIN_NVC0(push, NVC0_M2MF(LINE_LENGTH_IN), 2);
2596d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         PUSH_DATA (push, 32);
2606d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         PUSH_DATA (push, 1);
2616d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         BEGIN_NVC0(push, NVC0_M2MF(EXEC), 1);
2626d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         PUSH_DATA (push, 0x100111);
2636d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         BEGIN_NIC0(push, NVC0_M2MF(DATA), 8);
2646d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         PUSH_DATAp(push, &tic->tic[0], 8);
26592f3642a4fe71b272b4ceb6953fbf55d1efcbeb5Christoph Bumiller
2664c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller         need_flush = TRUE;
26767c7aefea33a7935e42ede30463eb7ca5009b068Christoph Bumiller      } else
2684826cd0f6125b071530026143ffd8205d84b3d5eBen Skeggs      if (res->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING) {
2696d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         BEGIN_NVC0(push, NVC0_3D(TEX_CACHE_CTL), 1);
2706d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller         PUSH_DATA (push, (tic->id << 4) | 1);
271198f514aa6f08bc43a3002519843b0fe94f340bdChristoph Bumiller         NOUVEAU_DRV_STAT(&nvc0->screen->base, tex_cache_flush_count, 1);
2724c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      }
2734c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      nvc0->screen->tic.lock[tic->id / 32] |= 1 << (tic->id % 32);
2744c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
2754826cd0f6125b071530026143ffd8205d84b3d5eBen Skeggs      res->status &= ~NOUVEAU_BUFFER_STATUS_GPU_WRITING;
2764826cd0f6125b071530026143ffd8205d84b3d5eBen Skeggs      res->status |=  NOUVEAU_BUFFER_STATUS_GPU_READING;
27767c7aefea33a7935e42ede30463eb7ca5009b068Christoph Bumiller
278784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      if (!dirty)
279784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller         continue;
280784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      commands[n++] = (tic->id << 9) | (i << 1) | 1;
2814c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
282784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      BCTX_REFN(nvc0->bufctx_3d, TEX(s, i), res, RD);
2834c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
284784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   for (; i < nvc0->state.num_textures[s]; ++i)
285784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      commands[n++] = (i << 1) | 0;
286784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller
2874c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0->state.num_textures[s] = nvc0->num_textures[s];
2884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
289784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   if (n) {
290784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      BEGIN_NIC0(push, NVC0_3D(BIND_TIC(s)), n);
291784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      PUSH_DATAp(push, commands, n);
292784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   }
293784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   nvc0->textures_dirty[s] = 0;
294784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller
2954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   return need_flush;
2964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
2974c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
298e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumillerstatic boolean
299e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumillernve4_validate_tic(struct nvc0_context *nvc0, unsigned s)
300e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller{
301e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   struct nouveau_bo *txc = nvc0->screen->txc;
302e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   struct nouveau_pushbuf *push = nvc0->base.pushbuf;
303e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   unsigned i;
304e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   boolean need_flush = FALSE;
305e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
306e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   for (i = 0; i < nvc0->num_textures[s]; ++i) {
307e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      struct nv50_tic_entry *tic = nv50_tic_entry(nvc0->textures[s][i]);
308e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      struct nv04_resource *res;
309e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      const boolean dirty = !!(nvc0->textures_dirty[s] & (1 << i));
310e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
311e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      if (!tic) {
312e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         nvc0->tex_handles[s][i] |= NVE4_TIC_ENTRY_INVALID;
313e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         continue;
314e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      }
315e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      res = nv04_resource(tic->pipe.texture);
316e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
317e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      if (tic->id < 0) {
318e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         tic->id = nvc0_screen_tic_alloc(nvc0->screen, tic);
319e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
320e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_SPACE(push, 16);
321e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         BEGIN_NVC0(push, NVE4_P2MF(DST_ADDRESS_HIGH), 2);
322e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATAh(push, txc->offset + (tic->id * 32));
323e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATA (push, txc->offset + (tic->id * 32));
324e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         BEGIN_NVC0(push, NVE4_P2MF(LINE_LENGTH_IN), 2);
325e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATA (push, 32);
326e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATA (push, 1);
327e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         BEGIN_1IC0(push, NVE4_P2MF(EXEC), 9);
328e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATA (push, 0x1001);
329e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATAp(push, &tic->tic[0], 8);
330e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
331e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         need_flush = TRUE;
332e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      } else
333e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      if (res->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING) {
334e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         BEGIN_NVC0(push, NVC0_3D(TEX_CACHE_CTL), 1);
335e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATA (push, (tic->id << 4) | 1);
336e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      }
337e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      nvc0->screen->tic.lock[tic->id / 32] |= 1 << (tic->id % 32);
338e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
339e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      res->status &= ~NOUVEAU_BUFFER_STATUS_GPU_WRITING;
340e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      res->status |=  NOUVEAU_BUFFER_STATUS_GPU_READING;
341e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
342e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      nvc0->tex_handles[s][i] &= ~NVE4_TIC_ENTRY_INVALID;
343e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      nvc0->tex_handles[s][i] |= tic->id;
344e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      if (dirty)
345e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         BCTX_REFN(nvc0->bufctx_3d, TEX(s, i), res, RD);
346e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   }
347c321b1bef15e2807de3f6225c4abcbf48969997aChristoph Bumiller   for (; i < nvc0->state.num_textures[s]; ++i) {
348e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      nvc0->tex_handles[s][i] |= NVE4_TIC_ENTRY_INVALID;
349c321b1bef15e2807de3f6225c4abcbf48969997aChristoph Bumiller      nvc0->textures_dirty[s] |= 1 << i;
350c321b1bef15e2807de3f6225c4abcbf48969997aChristoph Bumiller   }
351e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
352e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   nvc0->state.num_textures[s] = nvc0->num_textures[s];
353e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
354e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   return need_flush;
355e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller}
356e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
3574c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillervoid nvc0_validate_textures(struct nvc0_context *nvc0)
3584c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
3594c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   boolean need_flush;
3604c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
361e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   if (nvc0->screen->base.class_3d >= NVE4_3D_CLASS) {
362e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      need_flush  = nve4_validate_tic(nvc0, 0);
363e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      need_flush |= nve4_validate_tic(nvc0, 3);
364e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      need_flush |= nve4_validate_tic(nvc0, 4);
365e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   } else {
366e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      need_flush  = nvc0_validate_tic(nvc0, 0);
367e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      need_flush |= nvc0_validate_tic(nvc0, 3);
368e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      need_flush |= nvc0_validate_tic(nvc0, 4);
369e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   }
3704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3714c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   if (need_flush) {
3726d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller      BEGIN_NVC0(nvc0->base.pushbuf, NVC0_3D(TIC_FLUSH), 1);
3736d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller      PUSH_DATA (nvc0->base.pushbuf, 0);
3744c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
3754c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
3764c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3774c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillerstatic boolean
3784c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillernvc0_validate_tsc(struct nvc0_context *nvc0, int s)
3794c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
380784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   uint32_t commands[16];
3816d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller   struct nouveau_pushbuf *push = nvc0->base.pushbuf;
3824c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   unsigned i;
383784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   unsigned n = 0;
3844c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   boolean need_flush = FALSE;
3854c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3864c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   for (i = 0; i < nvc0->num_samplers[s]; ++i) {
3871f5d6fc59bd899e211c70026eb74cd2219858008Christoph Bumiller      struct nv50_tsc_entry *tsc = nv50_tsc_entry(nvc0->samplers[s][i]);
3884c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
389784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      if (!(nvc0->samplers_dirty[s] & (1 << i)))
390784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller         continue;
3914c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      if (!tsc) {
392784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller         commands[n++] = (i << 4) | 0;
3934c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller         continue;
3944c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      }
3954c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      if (tsc->id < 0) {
3964c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller         tsc->id = nvc0_screen_tsc_alloc(nvc0->screen, tsc);
3974c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
3981ba8e9510812f155359d380bda6876cdee5ba21eBen Skeggs         nvc0_m2mf_push_linear(&nvc0->base, nvc0->screen->txc,
3994826cd0f6125b071530026143ffd8205d84b3d5eBen Skeggs                               65536 + tsc->id * 32, NOUVEAU_BO_VRAM,
4004826cd0f6125b071530026143ffd8205d84b3d5eBen Skeggs                               32, tsc->tsc);
4014c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller         need_flush = TRUE;
4024c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      }
4034c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller      nvc0->screen->tsc.lock[tsc->id / 32] |= 1 << (tsc->id % 32);
4044c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
405784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      commands[n++] = (tsc->id << 12) | (i << 4) | 1;
4064c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
407784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   for (; i < nvc0->state.num_samplers[s]; ++i)
408784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      commands[n++] = (i << 4) | 0;
409784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller
4104c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   nvc0->state.num_samplers[s] = nvc0->num_samplers[s];
4114c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
412784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   if (n) {
413784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      BEGIN_NIC0(push, NVC0_3D(BIND_TSC(s)), n);
414784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller      PUSH_DATAp(push, commands, n);
415784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   }
416784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller   nvc0->samplers_dirty[s] = 0;
417784f49e69624cba07616fd5a22ccb80ad3b5111bChristoph Bumiller
4184c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   return need_flush;
4194c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
4204c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
421e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillerboolean
422e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumillernve4_validate_tsc(struct nvc0_context *nvc0, int s)
423e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller{
424e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   struct nouveau_bo *txc = nvc0->screen->txc;
425e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   struct nouveau_pushbuf *push = nvc0->base.pushbuf;
426e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   unsigned i;
427e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   boolean need_flush = FALSE;
428e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
429e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   for (i = 0; i < nvc0->num_samplers[s]; ++i) {
430e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      struct nv50_tsc_entry *tsc = nv50_tsc_entry(nvc0->samplers[s][i]);
431e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
432e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      if (!tsc) {
433e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         nvc0->tex_handles[s][i] |= NVE4_TSC_ENTRY_INVALID;
434e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         continue;
435e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      }
436e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      if (tsc->id < 0) {
437e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         tsc->id = nvc0_screen_tsc_alloc(nvc0->screen, tsc);
438e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
439e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_SPACE(push, 16);
440e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         BEGIN_NVC0(push, NVE4_P2MF(DST_ADDRESS_HIGH), 2);
441e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATAh(push, txc->offset + 65536 + (tsc->id * 32));
442e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATA (push, txc->offset + 65536 + (tsc->id * 32));
443e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         BEGIN_NVC0(push, NVE4_P2MF(LINE_LENGTH_IN), 2);
444e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATA (push, 32);
445e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATA (push, 1);
446e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         BEGIN_1IC0(push, NVE4_P2MF(EXEC), 9);
447e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATA (push, 0x1001);
448e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATAp(push, &tsc->tsc[0], 8);
449e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
450e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         need_flush = TRUE;
451e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      }
452e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      nvc0->screen->tsc.lock[tsc->id / 32] |= 1 << (tsc->id % 32);
453e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
454e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      nvc0->tex_handles[s][i] &= ~NVE4_TSC_ENTRY_INVALID;
455e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      nvc0->tex_handles[s][i] |= tsc->id << 20;
456e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   }
457c321b1bef15e2807de3f6225c4abcbf48969997aChristoph Bumiller   for (; i < nvc0->state.num_samplers[s]; ++i) {
458e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      nvc0->tex_handles[s][i] |= NVE4_TSC_ENTRY_INVALID;
459c321b1bef15e2807de3f6225c4abcbf48969997aChristoph Bumiller      nvc0->samplers_dirty[s] |= 1 << i;
460c321b1bef15e2807de3f6225c4abcbf48969997aChristoph Bumiller   }
461e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
462e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   nvc0->state.num_samplers[s] = nvc0->num_samplers[s];
463e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
464e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   return need_flush;
465e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller}
466e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
4674c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumillervoid nvc0_validate_samplers(struct nvc0_context *nvc0)
4684c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller{
4694c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   boolean need_flush;
4704c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
471e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   if (nvc0->screen->base.class_3d >= NVE4_3D_CLASS) {
472e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      need_flush  = nve4_validate_tsc(nvc0, 0);
473e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      need_flush |= nve4_validate_tsc(nvc0, 3);
474e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      need_flush |= nve4_validate_tsc(nvc0, 4);
475e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   } else {
476e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      need_flush  = nvc0_validate_tsc(nvc0, 0);
477e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      need_flush |= nvc0_validate_tsc(nvc0, 3);
478e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      need_flush |= nvc0_validate_tsc(nvc0, 4);
479e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   }
4804c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller
4814c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   if (need_flush) {
4826d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller      BEGIN_NVC0(nvc0->base.pushbuf, NVC0_3D(TSC_FLUSH), 1);
4836d1cdec3ba151168bfc3aef222fba6265dfb41fbChristoph Bumiller      PUSH_DATA (nvc0->base.pushbuf, 0);
4844c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller   }
4854c2247538394a313e1e90bfcd07c1ab9c7d41281Christoph Bumiller}
486e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
487e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller/* Upload the "diagonal" entries for the possible texture sources ($t == $s).
488e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller * At some point we might want to get a list of the combinations used by a
489e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller * shader and fill in those entries instead of having it extract the handles.
490e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller */
491e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumillervoid
492e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumillernve4_set_tex_handles(struct nvc0_context *nvc0)
493e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller{
494e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   struct nouveau_pushbuf *push = nvc0->base.pushbuf;
495e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   uint64_t address;
496e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   unsigned s;
497e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
498e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   if (nvc0->screen->base.class_3d < NVE4_3D_CLASS)
499e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      return;
500e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   address = nvc0->screen->uniform_bo->offset + (5 << 16);
501e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
502e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   for (s = 0; s < 5; ++s, address += (1 << 9)) {
503e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      uint32_t dirty = nvc0->textures_dirty[s] | nvc0->samplers_dirty[s];
504e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      if (!dirty)
505e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         continue;
506e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      BEGIN_NVC0(push, NVC0_3D(CB_SIZE), 3);
507e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      PUSH_DATA (push, 512);
508e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      PUSH_DATAh(push, address);
509e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      PUSH_DATA (push, address);
510e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      do {
511e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         int i = ffs(dirty) - 1;
512e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         dirty &= ~(1 << i);
513e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
514e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         BEGIN_NVC0(push, NVC0_3D(CB_POS), 2);
515e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATA (push, (8 + i) * 4);
516e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller         PUSH_DATA (push, nvc0->tex_handles[s][i]);
517e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      } while (dirty);
518e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller
519e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      nvc0->textures_dirty[s] = 0;
520e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller      nvc0->samplers_dirty[s] = 0;
521e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller   }
522e44089b2f79aa2dcaacf348911433d1e21235c0cChristoph Bumiller}
523e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
524e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
525e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillerstatic const uint8_t nve4_su_format_map[PIPE_FORMAT_COUNT];
526e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillerstatic const uint16_t nve4_su_format_aux_map[PIPE_FORMAT_COUNT];
527e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillerstatic const uint16_t nve4_suldp_lib_offset[PIPE_FORMAT_COUNT];
528e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
529e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillervoid
530e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillernve4_set_surface_info(struct nouveau_pushbuf *push,
531e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller                      struct pipe_surface *psf,
532e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller                      struct nvc0_screen *screen)
533e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller{
534e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   struct nv50_surface *sf = nv50_surface(psf);
535e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   struct nv04_resource *res;
536e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   uint64_t address;
537e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   uint32_t *const info = push->cur;
538e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   uint8_t log2cpp;
539e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
540e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   if (psf && !nve4_su_format_map[psf->format])
541e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      NOUVEAU_ERR("unsupported surface format, try is_format_supported() !\n");
542e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
543e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   push->cur += 16;
544e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
545e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   if (!psf || !nve4_su_format_map[psf->format]) {
546e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      memset(info, 0, 16 * sizeof(*info));
547e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
548e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[0] = 0xbadf0000;
549e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[1] = 0x80004000;
550e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[12] = nve4_suldp_lib_offset[PIPE_FORMAT_R32G32B32A32_UINT] +
551e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller         screen->lib_code->start;
552e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      return;
553e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   }
554e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   res = nv04_resource(sf->base.texture);
555e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
556e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   address = res->address + sf->offset;
557e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
558e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   info[8] = sf->width;
559e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   info[9] = sf->height;
560e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   info[10] = sf->depth;
561e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   switch (res->base.target) {
562e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   case PIPE_TEXTURE_1D_ARRAY:
563e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[11] = 1;
564e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      break;
565e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   case PIPE_TEXTURE_2D:
566e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   case PIPE_TEXTURE_RECT:
567e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[11] = 2;
568e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      break;
569e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   case PIPE_TEXTURE_3D:
570e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[11] = 3;
571e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      break;
572e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   case PIPE_TEXTURE_2D_ARRAY:
573e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   case PIPE_TEXTURE_CUBE:
574e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   case PIPE_TEXTURE_CUBE_ARRAY:
575e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[11] = 4;
576e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      break;
577e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   default:
578e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[11] = 0;
579e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      break;
580e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   }
581e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   log2cpp = (0xf000 & nve4_su_format_aux_map[sf->base.format]) >> 12;
582e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
583e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   info[12] = nve4_suldp_lib_offset[sf->base.format] + screen->lib_code->start;
584e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
585e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   /* limit in bytes for raw access */
586e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   info[13] = (0x06 << 22) | ((sf->width << log2cpp) - 1);
587e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
588e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   info[1] = nve4_su_format_map[sf->base.format];
589e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
590e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller#if 0
591e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   switch (util_format_get_blocksizebits(sf->base.format)) {
592e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   case  16: info[1] |= 1 << 16; break;
593e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   case  32: info[1] |= 2 << 16; break;
594e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   case  64: info[1] |= 3 << 16; break;
595e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   case 128: info[1] |= 4 << 16; break;
596e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   default:
597e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      break;
598e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   }
599e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller#else
600e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   info[1] |= log2cpp << 16;
601e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   info[1] |=  0x4000;
602e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   info[1] |= (0x0f00 & nve4_su_format_aux_map[sf->base.format]);
603e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller#endif
604e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
605e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   if (res->base.target == PIPE_BUFFER) {
606e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[0]  = address >> 8;
607e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[2]  = sf->width - 1;
608e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[2] |= (0xff & nve4_su_format_aux_map[sf->base.format]) << 22;
609e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[3]  = 0;
610e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[4]  = 0;
611e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[5]  = 0;
612e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[6]  = 0;
613e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[7]  = 0;
614e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[14] = 0;
615e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[15] = 0;
616e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   } else {
617e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      struct nv50_miptree *mt = nv50_miptree(&res->base);
618e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      struct nv50_miptree_level *lvl = &mt->level[sf->base.u.tex.level];
619e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      const unsigned z = sf->base.u.tex.first_layer;
620e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
621e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      if (z) {
622e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller         if (mt->layout_3d) {
623e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller            address += nvc0_mt_zslice_offset(mt, psf->u.tex.level, z);
624e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller            /* doesn't work if z passes z-tile boundary */
625e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller            assert(sf->depth == 1);
626e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller         } else {
627e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller            address += mt->layer_stride * z;
628e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller         }
629e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      }
630e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[0]  = address >> 8;
631e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[2]  = sf->width - 1;
632e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      /* NOTE: this is really important: */
633e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[2] |= (0xff & nve4_su_format_aux_map[sf->base.format]) << 22;
634e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[3]  = (0x88 << 24) | (lvl->pitch / 64);
635e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[4]  = sf->height - 1;
636e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[4] |= (lvl->tile_mode & 0x0f0) << 25;
637e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[4] |= NVC0_TILE_SHIFT_Y(lvl->tile_mode) << 22;
638e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[5]  = mt->layer_stride >> 8;
639e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[6]  = sf->depth - 1;
640e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[6] |= (lvl->tile_mode & 0xf00) << 21;
641e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[6] |= NVC0_TILE_SHIFT_Z(lvl->tile_mode) << 22;
642e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[7]  = 0;
643e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[14] = mt->ms_x;
644e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      info[15] = mt->ms_y;
645e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   }
646e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller}
647e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
648e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillerstatic INLINE void
649e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillernvc0_update_surface_bindings(struct nvc0_context *nvc0)
650e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller{
651e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   /* TODO */
652e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller}
653e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
654e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillerstatic INLINE void
655e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillernve4_update_surface_bindings(struct nvc0_context *nvc0)
656e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller{
657e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   /* TODO */
658e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller}
659e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
660e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillervoid
661e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillernvc0_validate_surfaces(struct nvc0_context *nvc0)
662e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller{
663e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   if (nvc0->screen->base.class_3d >= NVE4_3D_CLASS) {
664e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      nve4_update_surface_bindings(nvc0);
665e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   } else {
666e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller      nvc0_update_surface_bindings(nvc0);
667e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   }
668e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller}
669e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
670e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
671e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillerstatic const uint8_t nve4_su_format_map[PIPE_FORMAT_COUNT] =
672e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller{
673e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32B32A32_FLOAT] = NVE4_IMAGE_FORMAT_RGBA32_FLOAT,
674e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32B32A32_SINT] = NVE4_IMAGE_FORMAT_RGBA32_SINT,
675e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32B32A32_UINT] = NVE4_IMAGE_FORMAT_RGBA32_UINT,
676e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_FLOAT] = NVE4_IMAGE_FORMAT_RGBA16_FLOAT,
677e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_UNORM] = NVE4_IMAGE_FORMAT_RGBA16_UNORM,
678e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_SNORM] = NVE4_IMAGE_FORMAT_RGBA16_SNORM,
679e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_SINT] = NVE4_IMAGE_FORMAT_RGBA16_SINT,
680e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_UINT] = NVE4_IMAGE_FORMAT_RGBA16_UINT,
681e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8B8A8_UNORM] = NVE4_IMAGE_FORMAT_RGBA8_UNORM,
682e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8B8A8_SNORM] = NVE4_IMAGE_FORMAT_RGBA8_SNORM,
683e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8B8A8_SINT] = NVE4_IMAGE_FORMAT_RGBA8_SINT,
684e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8B8A8_UINT] = NVE4_IMAGE_FORMAT_RGBA8_UINT,
685e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R11G11B10_FLOAT] = NVE4_IMAGE_FORMAT_R11G11B10_FLOAT,
686e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R10G10B10A2_UNORM] = NVE4_IMAGE_FORMAT_RGB10_A2_UNORM,
687e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller/* [PIPE_FORMAT_R10G10B10A2_UINT] = NVE4_IMAGE_FORMAT_RGB10_A2_UINT, */
688e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32_FLOAT] = NVE4_IMAGE_FORMAT_RG32_FLOAT,
689e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32_SINT] = NVE4_IMAGE_FORMAT_RG32_SINT,
690e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32_UINT] = NVE4_IMAGE_FORMAT_RG32_UINT,
691e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_FLOAT] = NVE4_IMAGE_FORMAT_RG16_FLOAT,
692e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_UNORM] = NVE4_IMAGE_FORMAT_RG16_UNORM,
693e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_SNORM] = NVE4_IMAGE_FORMAT_RG16_SNORM,
694e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_SINT] = NVE4_IMAGE_FORMAT_RG16_SINT,
695e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_UINT] = NVE4_IMAGE_FORMAT_RG16_UINT,
696e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8_UNORM] = NVE4_IMAGE_FORMAT_RG8_UNORM,
697e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8_SNORM] = NVE4_IMAGE_FORMAT_RG8_SNORM,
698e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8_SINT] = NVE4_IMAGE_FORMAT_RG8_SINT,
699e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8_UINT] = NVE4_IMAGE_FORMAT_RG8_UINT,
700e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32_FLOAT] = NVE4_IMAGE_FORMAT_R32_FLOAT,
701e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32_SINT] = NVE4_IMAGE_FORMAT_R32_SINT,
702e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32_UINT] = NVE4_IMAGE_FORMAT_R32_UINT,
703e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_FLOAT] = NVE4_IMAGE_FORMAT_R16_FLOAT,
704e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_UNORM] = NVE4_IMAGE_FORMAT_R16_UNORM,
705e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_SNORM] = NVE4_IMAGE_FORMAT_R16_SNORM,
706e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_SINT] = NVE4_IMAGE_FORMAT_R16_SINT,
707e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_UINT] = NVE4_IMAGE_FORMAT_R16_UINT,
708e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8_UNORM] = NVE4_IMAGE_FORMAT_R8_UNORM,
709e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8_SNORM] = NVE4_IMAGE_FORMAT_R8_SNORM,
710e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8_SINT] = NVE4_IMAGE_FORMAT_R8_SINT,
711e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8_UINT] = NVE4_IMAGE_FORMAT_R8_UINT,
712e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller};
713e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
714e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller/* Auxiliary format description values for surface instructions.
715e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller * (log2(bytes per pixel) << 12) | (unk8 << 8) | unk22
716e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller */
717e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillerstatic const uint16_t nve4_su_format_aux_map[PIPE_FORMAT_COUNT] =
718e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller{
719e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32B32A32_FLOAT] = 0x4842,
720e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32B32A32_SINT] = 0x4842,
721e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32B32A32_UINT] = 0x4842,
722e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
723e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_UNORM] = 0x3933,
724e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_SNORM] = 0x3933,
725e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_SINT] = 0x3933,
726e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_UINT] = 0x3933,
727e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_FLOAT] = 0x3933,
728e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
729e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32_FLOAT] = 0x3433,
730e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32_SINT] = 0x3433,
731e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32_UINT] = 0x3433,
732e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
733e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R10G10B10A2_UNORM] = 0x2a24,
734e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller/* [PIPE_FORMAT_R10G10B10A2_UINT] = 0x2a24, */
735e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8B8A8_UNORM] = 0x2a24,
736e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8B8A8_SNORM] = 0x2a24,
737e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8B8A8_SINT] = 0x2a24,
738e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8B8A8_UINT] = 0x2a24,
739e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R11G11B10_FLOAT] = 0x2a24,
740e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
741e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_UNORM] = 0x2524,
742e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_SNORM] = 0x2524,
743e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_SINT] = 0x2524,
744e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_UINT] = 0x2524,
745e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_FLOAT] = 0x2524,
746e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
747e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32_SINT] = 0x2024,
748e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32_UINT] = 0x2024,
749e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32_FLOAT] = 0x2024,
750e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
751e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8_UNORM] = 0x1615,
752e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8_SNORM] = 0x1615,
753e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8_SINT] = 0x1615,
754e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8_UINT] = 0x1615,
755e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
756e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_UNORM] = 0x1115,
757e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_SNORM] = 0x1115,
758e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_SINT] = 0x1115,
759e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_UINT] = 0x1115,
760e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_FLOAT] = 0x1115,
761e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
762e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8_UNORM] = 0x0206,
763e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8_SNORM] = 0x0206,
764e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8_SINT] = 0x0206,
765e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8_UINT] = 0x0206
766e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller};
767e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller
768e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller/* NOTE: These are hardcoded offsets for the shader library.
769e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller * TODO: Automate them.
770e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller */
771e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumillerstatic const uint16_t nve4_suldp_lib_offset[PIPE_FORMAT_COUNT] =
772e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller{
773e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32B32A32_FLOAT] = 0x218,
774e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32B32A32_SINT]  = 0x218,
775e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32B32A32_UINT]  = 0x218,
776e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_UNORM] = 0x248,
777e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_SNORM] = 0x2b8,
778e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_SINT]  = 0x330,
779e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_UINT]  = 0x388,
780e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16B16A16_FLOAT] = 0x3d8,
781e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32_FLOAT]       = 0x428,
782e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32_SINT]        = 0x468,
783e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32G32_UINT]        = 0x468,
784e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R10G10B10A2_UNORM]  = 0x4a8,
785e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller/* [PIPE_FORMAT_R10G10B10A2_UINT]   = 0x530, */
786e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8B8A8_UNORM]     = 0x588,
787e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8B8A8_SNORM]     = 0x5f8,
788e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8B8A8_SINT]      = 0x670,
789e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8B8A8_UINT]      = 0x6c8,
790e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_B5G6R5_UNORM]       = 0x718,
791e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_B5G5R5X1_UNORM]     = 0x7a0,
792e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_UNORM]       = 0x828,
793e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_SNORM]       = 0x890,
794e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_SINT]        = 0x8f0,
795e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_UINT]        = 0x948,
796e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16G16_FLOAT]       = 0x998,
797e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32_FLOAT]          = 0x9e8,
798e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32_SINT]           = 0xa30,
799e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R32_UINT]           = 0xa30,
800e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8_UNORM]         = 0xa78,
801e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8_SNORM]         = 0xae0,
802e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8_UINT]          = 0xb48,
803e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8G8_SINT]          = 0xb98,
804e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_UNORM]          = 0xbe8,
805e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_SNORM]          = 0xc48,
806e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_SINT]           = 0xca0,
807e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_UINT]           = 0xce8,
808e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R16_FLOAT]          = 0xd30,
809e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8_UNORM]           = 0xd88,
810e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8_SNORM]           = 0xde0,
811e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8_SINT]            = 0xe38,
812e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R8_UINT]            = 0xe88,
813e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller   [PIPE_FORMAT_R11G11B10_FLOAT]    = 0xed0
814e066f2f62f6043d43385bcdce4e7fa07ffa3ecbeChristoph Bumiller};
815