| 1 |
/* |
| 2 |
* Copyright 2008 Ben Skeggs |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included in |
| 12 |
* all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
|
| 23 |
#include "nvc0/nvc0_context.h" |
| 24 |
#include "nvc0/nvc0_resource.h" |
| 25 |
#include "nvc0/gm107_texture.xml.h" |
| 26 |
#include "nvc0/nvc0_compute.xml.h" |
| 27 |
#include "nv50/g80_texture.xml.h" |
| 28 |
#include "nv50/g80_defs.xml.h" |
| 29 |
|
| 30 |
#include "util/format/u_format.h" |
| 31 |
|
| 32 |
#define NVE4_TIC_ENTRY_INVALID 0x000fffff |
| 33 |
#define NVE4_TSC_ENTRY_INVALID 0xfff00000 |
| 34 |
|
| 35 |
static inline uint32_t |
| 36 |
nv50_tic_swizzle(const struct nvc0_format *fmt, unsigned swz, bool tex_int) |
| 37 |
{ |
| 38 |
switch (swz) { |
| 39 |
case PIPE_SWIZZLE_X : return fmt->tic.src_x; |
| 40 |
case PIPE_SWIZZLE_Y: return fmt->tic.src_y; |
| 41 |
case PIPE_SWIZZLE_Z : return fmt->tic.src_z; |
| 42 |
case PIPE_SWIZZLE_W: return fmt->tic.src_w; |
| 43 |
case PIPE_SWIZZLE_1: |
| 44 |
return tex_int ? G80_TIC_SOURCE_ONE_INT : G80_TIC_SOURCE_ONE_FLOAT; |
| 45 |
case PIPE_SWIZZLE_0: |
| 46 |
default: |
| 47 |
return G80_TIC_SOURCE_ZERO; |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
struct pipe_sampler_view * |
| 52 |
nvc0_create_sampler_view(struct pipe_context *pipe, |
| 53 |
struct pipe_resource *res, |
| 54 |
const struct pipe_sampler_view *templ) |
| 55 |
{ |
| 56 |
uint32_t flags = 0; |
| 57 |
|
| 58 |
if (templ->target == PIPE_TEXTURE_RECT || templ->target == PIPE_BUFFER) |
| 59 |
flags |= NV50_TEXVIEW_SCALED_COORDS; |
| 60 |
|
| 61 |
return nvc0_create_texture_view(pipe, res, templ, flags); |
| 62 |
} |
| 63 |
|
| 64 |
static struct pipe_sampler_view * |
| 65 |
gm107_create_texture_view(struct pipe_context *pipe, |
| 66 |
struct pipe_resource *texture, |
| 67 |
const struct pipe_sampler_view *templ, |
| 68 |
uint32_t flags) |
| 69 |
{ |
| 70 |
const struct util_format_description *desc; |
| 71 |
const struct nvc0_format *fmt; |
| 72 |
uint64_t address; |
| 73 |
uint32_t *tic; |
| 74 |
uint32_t swz[4]; |
| 75 |
uint32_t width, height; |
| 76 |
uint32_t depth; |
| 77 |
struct nv50_tic_entry *view; |
| 78 |
struct nv50_miptree *mt; |
| 79 |
bool tex_int; |
| 80 |
|
| 81 |
view = MALLOC_STRUCT(nv50_tic_entry); |
| 82 |
if (!view) |
| 83 |
return NULL; |
| 84 |
mt = nv50_miptree(texture); |
| 85 |
|
| 86 |
view->pipe = *templ; |
| 87 |
view->pipe.reference.count = 1; |
| 88 |
view->pipe.texture = NULL; |
| 89 |
view->pipe.context = pipe; |
| 90 |
|
| 91 |
view->id = -1; |
| 92 |
view->bindless = 0; |
| 93 |
|
| 94 |
pipe_resource_reference(&view->pipe.texture, texture); |
| 95 |
|
| 96 |
tic = &view->tic[0]; |
| 97 |
|
| 98 |
desc = util_format_description(view->pipe.format); |
| 99 |
tex_int = util_format_is_pure_integer(view->pipe.format); |
| 100 |
|
| 101 |
fmt = &nvc0_format_table[view->pipe.format]; |
| 102 |
swz[0] = nv50_tic_swizzle(fmt, view->pipe.swizzle_r, tex_int); |
| 103 |
swz[1] = nv50_tic_swizzle(fmt, view->pipe.swizzle_g, tex_int); |
| 104 |
swz[2] = nv50_tic_swizzle(fmt, view->pipe.swizzle_b, tex_int); |
| 105 |
swz[3] = nv50_tic_swizzle(fmt, view->pipe.swizzle_a, tex_int); |
| 106 |
|
| 107 |
tic[0] = fmt->tic.format << GM107_TIC2_0_COMPONENTS_SIZES__SHIFT; |
| 108 |
tic[0] |= fmt->tic.type_r << GM107_TIC2_0_R_DATA_TYPE__SHIFT; |
| 109 |
tic[0] |= fmt->tic.type_g << GM107_TIC2_0_G_DATA_TYPE__SHIFT; |
| 110 |
tic[0] |= fmt->tic.type_b << GM107_TIC2_0_B_DATA_TYPE__SHIFT; |
| 111 |
tic[0] |= fmt->tic.type_a << GM107_TIC2_0_A_DATA_TYPE__SHIFT; |
| 112 |
tic[0] |= swz[0] << GM107_TIC2_0_X_SOURCE__SHIFT; |
| 113 |
tic[0] |= swz[1] << GM107_TIC2_0_Y_SOURCE__SHIFT; |
| 114 |
tic[0] |= swz[2] << GM107_TIC2_0_Z_SOURCE__SHIFT; |
| 115 |
tic[0] |= swz[3] << GM107_TIC2_0_W_SOURCE__SHIFT; |
| 116 |
|
| 117 |
address = mt->base.address; |
| 118 |
|
| 119 |
tic[3] = GM107_TIC2_3_LOD_ANISO_QUALITY_2; |
| 120 |
tic[4] = GM107_TIC2_4_BORDER_SIZE_SAMPLER_COLOR; |
| 121 |
|
| 122 |
if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) |
| 123 |
tic[4] |= GM107_TIC2_4_SRGB_CONVERSION; |
| 124 |
|
| 125 |
if (!(flags & NV50_TEXVIEW_SCALED_COORDS)) |
| 126 |
tic[5] = GM107_TIC2_5_NORMALIZED_COORDS; |
| 127 |
else |
| 128 |
tic[5] = 0; |
| 129 |
|
| 130 |
/* check for linear storage type */ |
| 131 |
if (unlikely(!nouveau_bo_memtype(nv04_resource(texture)->bo))) { |
| 132 |
if (texture->target == PIPE_BUFFER) { |
| 133 |
assert(!(tic[5] & GM107_TIC2_5_NORMALIZED_COORDS)); |
| 134 |
width = view->pipe.u.buf.size / (desc->block.bits / 8) - 1; |
| 135 |
address += |
| 136 |
view->pipe.u.buf.offset; |
| 137 |
tic[2] = GM107_TIC2_2_HEADER_VERSION_ONE_D_BUFFER; |
| 138 |
tic[3] |= width >> 16; |
| 139 |
tic[4] |= GM107_TIC2_4_TEXTURE_TYPE_ONE_D_BUFFER; |
| 140 |
tic[4] |= width & 0xffff; |
| 141 |
} else { |
| 142 |
assert(!(mt->level[0].pitch & 0x1f)); |
| 143 |
/* must be 2D texture without mip maps */ |
| 144 |
tic[2] = GM107_TIC2_2_HEADER_VERSION_PITCH; |
| 145 |
tic[4] |= GM107_TIC2_4_TEXTURE_TYPE_TWO_D_NO_MIPMAP; |
| 146 |
tic[3] |= mt->level[0].pitch >> 5; |
| 147 |
tic[4] |= mt->base.base.width0 - 1; |
| 148 |
tic[5] |= 0 << GM107_TIC2_5_DEPTH_MINUS_ONE__SHIFT; |
| 149 |
tic[5] |= mt->base.base.height0 - 1; |
| 150 |
} |
| 151 |
tic[1] = address; |
| 152 |
tic[2] |= address >> 32; |
| 153 |
tic[6] = 0; |
| 154 |
tic[7] = 0; |
| 155 |
return &view->pipe; |
| 156 |
} |
| 157 |
|
| 158 |
tic[2] = GM107_TIC2_2_HEADER_VERSION_BLOCKLINEAR; |
| 159 |
tic[3] |= |
| 160 |
((mt->level[0].tile_mode & 0x0f0) >> 4 << 3) | |
| 161 |
((mt->level[0].tile_mode & 0xf00) >> 8 << 6); |
| 162 |
|
| 163 |
depth = MAX2(mt->base.base.array_size, mt->base.base.depth0); |
| 164 |
|
| 165 |
if (mt->base.base.array_size > 1) { |
| 166 |
/* there doesn't seem to be a base layer field in TIC */ |
| 167 |
address += view->pipe.u.tex.first_layer * mt->layer_stride; |
| 168 |
depth = view->pipe.u.tex.last_layer - view->pipe.u.tex.first_layer + 1; |
| 169 |
} |
| 170 |
tic[1] = address; |
| 171 |
tic[2] |= address >> 32; |
| 172 |
|
| 173 |
switch (templ->target) { |
| 174 |
case PIPE_TEXTURE_1D: |
| 175 |
tic[4] |= GM107_TIC2_4_TEXTURE_TYPE_ONE_D; |
| 176 |
break; |
| 177 |
case PIPE_TEXTURE_2D: |
| 178 |
tic[4] |= GM107_TIC2_4_TEXTURE_TYPE_TWO_D; |
| 179 |
break; |
| 180 |
case PIPE_TEXTURE_RECT: |
| 181 |
tic[4] |= GM107_TIC2_4_TEXTURE_TYPE_TWO_D; |
| 182 |
break; |
| 183 |
case PIPE_TEXTURE_3D: |
| 184 |
tic[4] |= GM107_TIC2_4_TEXTURE_TYPE_THREE_D; |
| 185 |
break; |
| 186 |
case PIPE_TEXTURE_CUBE: |
| 187 |
depth /= 6; |
| 188 |
tic[4] |= GM107_TIC2_4_TEXTURE_TYPE_CUBEMAP; |
| 189 |
break; |
| 190 |
case PIPE_TEXTURE_1D_ARRAY: |
| 191 |
tic[4] |= GM107_TIC2_4_TEXTURE_TYPE_ONE_D_ARRAY; |
| 192 |
break; |
| 193 |
case PIPE_TEXTURE_2D_ARRAY: |
| 194 |
tic[4] |= GM107_TIC2_4_TEXTURE_TYPE_TWO_D_ARRAY; |
| 195 |
break; |
| 196 |
case PIPE_TEXTURE_CUBE_ARRAY: |
| 197 |
depth /= 6; |
| 198 |
tic[4] |= GM107_TIC2_4_TEXTURE_TYPE_CUBE_ARRAY; |
| 199 |
break; |
| 200 |
default: |
| 201 |
UNREACHABLE("unexpected/invalid texture target"); |
| 202 |
} |
| 203 |
|
| 204 |
tic[3] |= (flags & NV50_TEXVIEW_FILTER_MSAA8) ? |
| 205 |
GM107_TIC2_3_USE_HEADER_OPT_CONTROL : |
| 206 |
GM107_TIC2_3_LOD_ANISO_QUALITY_HIGH | |
| 207 |
GM107_TIC2_3_LOD_ISO_QUALITY_HIGH; |
| 208 |
|
| 209 |
if (flags & (NV50_TEXVIEW_ACCESS_RESOLVE | NV50_TEXVIEW_IMAGE_GM107)) { |
| 210 |
width = mt->base.base.width0 << mt->ms_x; |
| 211 |
height = mt->base.base.height0 << mt->ms_y; |
| 212 |
} else { |
| 213 |
width = mt->base.base.width0; |
| 214 |
height = mt->base.base.height0; |
| 215 |
} |
| 216 |
|
| 217 |
tic[4] |= width - 1; |
| 218 |
|
| 219 |
tic[5] |= (height - 1) & 0xffff; |
| 220 |
tic[5] |= (depth - 1) << GM107_TIC2_5_DEPTH_MINUS_ONE__SHIFT; |
| 221 |
tic[3] |= mt->base.base.last_level << GM107_TIC2_3_MAX_MIP_LEVEL__SHIFT; |
| 222 |
|
| 223 |
/* sampling points: (?) */ |
| 224 |
if ((flags & NV50_TEXVIEW_ACCESS_RESOLVE) && mt->ms_x > 1) { |
| 225 |
tic[6] = GM107_TIC2_6_ANISO_FINE_SPREAD_MODIFIER_CONST_TWO; |
| 226 |
tic[6] |= GM107_TIC2_6_MAX_ANISOTROPY_2_TO_1; |
| 227 |
} else { |
| 228 |
tic[6] = GM107_TIC2_6_ANISO_FINE_SPREAD_FUNC_TWO; |
| 229 |
tic[6] |= GM107_TIC2_6_ANISO_COARSE_SPREAD_FUNC_ONE; |
| 230 |
} |
| 231 |
|
| 232 |
tic[7] = (view->pipe.u.tex.last_level << 4) | view->pipe.u.tex.first_level; |
| 233 |
tic[7] |= mt->ms_mode << GM107_TIC2_7_MULTI_SAMPLE_COUNT__SHIFT; |
| 234 |
|
| 235 |
return &view->pipe; |
| 236 |
} |
| 237 |
|
| 238 |
struct pipe_sampler_view * |
| 239 |
gm107_create_texture_view_from_image(struct pipe_context *pipe, |
| 240 |
const struct pipe_image_view *view) |
| 241 |
{ |
| 242 |
struct nv04_resource *res = nv04_resource(view->resource); |
| 243 |
struct pipe_sampler_view templ = {}; |
| 244 |
enum pipe_texture_target target; |
| 245 |
uint32_t flags = 0; |
| 246 |
|
| 247 |
if (!res) |
| 248 |
return NULL; |
| 249 |
target = res->base.target; |
| 250 |
|
| 251 |
if (target == PIPE_TEXTURE_CUBE || target == PIPE_TEXTURE_CUBE_ARRAY) |
| 252 |
target = PIPE_TEXTURE_2D_ARRAY; |
| 253 |
|
| 254 |
templ.target = target; |
| 255 |
templ.format = view->format; |
| 256 |
templ.swizzle_r = PIPE_SWIZZLE_X; |
| 257 |
templ.swizzle_g = PIPE_SWIZZLE_Y; |
| 258 |
templ.swizzle_b = PIPE_SWIZZLE_Z; |
| 259 |
templ.swizzle_a = PIPE_SWIZZLE_W; |
| 260 |
|
| 261 |
if (target == PIPE_BUFFER) { |
| 262 |
templ.u.buf.offset = view->u.buf.offset; |
| 263 |
templ.u.buf.size = view->u.buf.size; |
| 264 |
} else { |
| 265 |
templ.u.tex.first_layer = view->u.tex.first_layer; |
| 266 |
templ.u.tex.last_layer = view->u.tex.last_layer; |
| 267 |
templ.u.tex.first_level = templ.u.tex.last_level = view->u.tex.level; |
| 268 |
} |
| 269 |
|
| 270 |
flags = NV50_TEXVIEW_SCALED_COORDS | NV50_TEXVIEW_IMAGE_GM107; |
| 271 |
|
| 272 |
return nvc0_create_texture_view(pipe, &res->base, &templ, flags); |
| 273 |
} |
| 274 |
|
| 275 |
static struct pipe_sampler_view * |
| 276 |
gf100_create_texture_view(struct pipe_context *pipe, |
| 277 |
struct pipe_resource *texture, |
| 278 |
const struct pipe_sampler_view *templ, |
| 279 |
uint32_t flags) |
| 280 |
{ |
| 281 |
const struct util_format_description *desc; |
| 282 |
const struct nvc0_format *fmt; |
| 283 |
uint64_t address; |
| 284 |
uint32_t *tic; |
| 285 |
uint32_t swz[4]; |
| 286 |
uint32_t width, height; |
| 287 |
uint32_t depth; |
| 288 |
uint32_t tex_fmt; |
| 289 |
struct nv50_tic_entry *view; |
| 290 |
struct nv50_miptree *mt; |
| 291 |
bool tex_int; |
| 292 |
|
| 293 |
view = MALLOC_STRUCT(nv50_tic_entry); |
| 294 |
if (!view) |
| 295 |
return NULL; |
| 296 |
mt = nv50_miptree(texture); |
| 297 |
|
| 298 |
view->pipe = *templ; |
| 299 |
view->pipe.reference.count = 1; |
| 300 |
view->pipe.texture = NULL; |
| 301 |
view->pipe.context = pipe; |
| 302 |
|
| 303 |
view->id = -1; |
| 304 |
view->bindless = 0; |
| 305 |
|
| 306 |
pipe_resource_reference(&view->pipe.texture, texture); |
| 307 |
|
| 308 |
tic = &view->tic[0]; |
| 309 |
|
| 310 |
desc = util_format_description(view->pipe.format); |
| 311 |
|
| 312 |
fmt = &nvc0_format_table[view->pipe.format]; |
| 313 |
|
| 314 |
tex_int = util_format_is_pure_integer(view->pipe.format); |
| 315 |
tex_fmt = fmt->tic.format & 0x3f; |
| 316 |
|
| 317 |
swz[0] = nv50_tic_swizzle(fmt, view->pipe.swizzle_r, tex_int); |
| 318 |
swz[1] = nv50_tic_swizzle(fmt, view->pipe.swizzle_g, tex_int); |
| 319 |
swz[2] = nv50_tic_swizzle(fmt, view->pipe.swizzle_b, tex_int); |
| 320 |
swz[3] = nv50_tic_swizzle(fmt, view->pipe.swizzle_a, tex_int); |
| 321 |
tic[0] = (tex_fmt << G80_TIC_0_COMPONENTS_SIZES__SHIFT) | |
| 322 |
(fmt->tic.type_r << G80_TIC_0_R_DATA_TYPE__SHIFT) | |
| 323 |
(fmt->tic.type_g << G80_TIC_0_G_DATA_TYPE__SHIFT) | |
| 324 |
(fmt->tic.type_b << G80_TIC_0_B_DATA_TYPE__SHIFT) | |
| 325 |
(fmt->tic.type_a << G80_TIC_0_A_DATA_TYPE__SHIFT) | |
| 326 |
(swz[0] << G80_TIC_0_X_SOURCE__SHIFT) | |
| 327 |
(swz[1] << G80_TIC_0_Y_SOURCE__SHIFT) | |
| 328 |
(swz[2] << G80_TIC_0_Z_SOURCE__SHIFT) | |
| 329 |
(swz[3] << G80_TIC_0_W_SOURCE__SHIFT) | |
| 330 |
((fmt->tic.format & 0x40) << (GK20A_TIC_0_USE_COMPONENT_SIZES_EXTENDED__SHIFT - 6)); |
| 331 |
|
| 332 |
address = mt->base.address; |
| 333 |
|
| 334 |
tic[2] = 0x00001000 | G80_TIC_2_BORDER_SOURCE_COLOR; |
| 335 |
|
| 336 |
if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) |
| 337 |
tic[2] |= G80_TIC_2_SRGB_CONVERSION; |
| 338 |
|
| 339 |
if (!(flags & NV50_TEXVIEW_SCALED_COORDS)) |
| 340 |
tic[2] |= G80_TIC_2_NORMALIZED_COORDS; |
| 341 |
|
| 342 |
/* check for linear storage type */ |
| 343 |
if (unlikely(!nouveau_bo_memtype(nv04_resource(texture)->bo))) { |
| 344 |
if (texture->target == PIPE_BUFFER) { |
| 345 |
assert(!(tic[2] & G80_TIC_2_NORMALIZED_COORDS)); |
| 346 |
address += |
| 347 |
view->pipe.u.buf.offset; |
| 348 |
tic[2] |= G80_TIC_2_LAYOUT_PITCH | G80_TIC_2_TEXTURE_TYPE_ONE_D_BUFFER; |
| 349 |
tic[3] = 0; |
| 350 |
tic[4] = /* width */ |
| 351 |
view->pipe.u.buf.size / (desc->block.bits / 8); |
| 352 |
tic[5] = 0; |
| 353 |
} else { |
| 354 |
/* must be 2D texture without mip maps */ |
| 355 |
tic[2] |= G80_TIC_2_LAYOUT_PITCH | G80_TIC_2_TEXTURE_TYPE_TWO_D_NO_MIPMAP; |
| 356 |
tic[3] = mt->level[0].pitch; |
| 357 |
tic[4] = mt->base.base.width0; |
| 358 |
tic[5] = (1 << 16) | mt->base.base.height0; |
| 359 |
} |
| 360 |
tic[6] = |
| 361 |
tic[7] = 0; |
| 362 |
tic[1] = address; |
| 363 |
tic[2] |= address >> 32; |
| 364 |
return &view->pipe; |
| 365 |
} |
| 366 |
|
| 367 |
tic[2] |= |
| 368 |
((mt->level[0].tile_mode & 0x0f0) << (22 - 4)) | |
| 369 |
((mt->level[0].tile_mode & 0xf00) << (25 - 8)); |
| 370 |
|
| 371 |
depth = MAX2(mt->base.base.array_size, mt->base.base.depth0); |
| 372 |
|
| 373 |
if (mt->base.base.array_size > 1) { |
| 374 |
/* there doesn't seem to be a base layer field in TIC */ |
| 375 |
address += view->pipe.u.tex.first_layer * mt->layer_stride; |
| 376 |
depth = view->pipe.u.tex.last_layer - view->pipe.u.tex.first_layer + 1; |
| 377 |
} |
| 378 |
tic[1] = address; |
| 379 |
tic[2] |= address >> 32; |
| 380 |
|
| 381 |
switch (templ->target) { |
| 382 |
case PIPE_TEXTURE_1D: |
| 383 |
tic[2] |= G80_TIC_2_TEXTURE_TYPE_ONE_D; |
| 384 |
break; |
| 385 |
case PIPE_TEXTURE_2D: |
| 386 |
tic[2] |= G80_TIC_2_TEXTURE_TYPE_TWO_D; |
| 387 |
break; |
| 388 |
case PIPE_TEXTURE_RECT: |
| 389 |
tic[2] |= G80_TIC_2_TEXTURE_TYPE_TWO_D; |
| 390 |
break; |
| 391 |
case PIPE_TEXTURE_3D: |
| 392 |
tic[2] |= G80_TIC_2_TEXTURE_TYPE_THREE_D; |
| 393 |
break; |
| 394 |
case PIPE_TEXTURE_CUBE: |
| 395 |
depth /= 6; |
| 396 |
tic[2] |= G80_TIC_2_TEXTURE_TYPE_CUBEMAP; |
| 397 |
break; |
| 398 |
case PIPE_TEXTURE_1D_ARRAY: |
| 399 |
tic[2] |= G80_TIC_2_TEXTURE_TYPE_ONE_D_ARRAY; |
| 400 |
break; |
| 401 |
case PIPE_TEXTURE_2D_ARRAY: |
| 402 |
tic[2] |= G80_TIC_2_TEXTURE_TYPE_TWO_D_ARRAY; |
| 403 |
break; |
| 404 |
case PIPE_TEXTURE_CUBE_ARRAY: |
| 405 |
depth /= 6; |
| 406 |
tic[2] |= G80_TIC_2_TEXTURE_TYPE_CUBE_ARRAY; |
| 407 |
break; |
| 408 |
default: |
| 409 |
UNREACHABLE("unexpected/invalid texture target"); |
| 410 |
} |
| 411 |
|
| 412 |
tic[3] = (flags & NV50_TEXVIEW_FILTER_MSAA8) ? 0x20000000 : 0x00300000; |
| 413 |
|
| 414 |
if (flags & NV50_TEXVIEW_ACCESS_RESOLVE) { |
| 415 |
width = mt->base.base.width0 << mt->ms_x; |
| 416 |
height = mt->base.base.height0 << mt->ms_y; |
| 417 |
} else { |
| 418 |
width = mt->base.base.width0; |
| 419 |
height = mt->base.base.height0; |
| 420 |
} |
| 421 |
|
| 422 |
tic[4] = (1 << 31) | width; |
| 423 |
|
| 424 |
tic[5] = height & 0xffff; |
| 425 |
tic[5] |= depth << 16; |
| 426 |
tic[5] |= mt->base.base.last_level << 28; |
| 427 |
|
| 428 |
/* sampling points: (?) */ |
| 429 |
if (flags & NV50_TEXVIEW_ACCESS_RESOLVE) |
| 430 |
tic[6] = (mt->ms_x > 1) ? 0x88000000 : 0x03000000; |
| 431 |
else |
| 432 |
tic[6] = 0x03000000; |
| 433 |
|
| 434 |
tic[7] = (view->pipe.u.tex.last_level << 4) | view->pipe.u.tex.first_level; |
| 435 |
tic[7] |= mt->ms_mode << 12; |
| 436 |
|
| 437 |
return &view->pipe; |
| 438 |
} |
| 439 |
|
| 440 |
struct pipe_sampler_view * |
| 441 |
nvc0_create_texture_view(struct pipe_context *pipe, |
| 442 |
struct pipe_resource *texture, |
| 443 |
const struct pipe_sampler_view *templ, |
| 444 |
uint32_t flags) |
| 445 |
{ |
| 446 |
if (nvc0_context(pipe)->screen->tic.maxwell) |
| 447 |
return gm107_create_texture_view(pipe, texture, templ, flags); |
| 448 |
return gf100_create_texture_view(pipe, texture, templ, flags); |
| 449 |
} |
| 450 |
|
| 451 |
bool |
| 452 |
nvc0_update_tic(struct nvc0_context *nvc0, struct nv50_tic_entry *tic, |
| 453 |
struct nv04_resource *res) |
| 454 |
{ |
| 455 |
uint64_t address = res->address; |
| 456 |
if (res->base.target != PIPE_BUFFER) |
| 457 |
return false; |
| 458 |
address += tic->pipe.u.buf.offset; |
| 459 |
if (tic->tic[1] == (uint32_t)address && |
| 460 |
(tic->tic[2] & 0xff) == address >> 32) |
| 461 |
return false; |
| 462 |
|
| 463 |
tic->tic[1] = address; |
| 464 |
tic->tic[2] &= 0xffffff00; |
| 465 |
tic->tic[2] |= address >> 32; |
| 466 |
|
| 467 |
if (tic->id >= 0) { |
| 468 |
nvc0->base.push_data(&nvc0->base, nvc0->screen->txc, tic->id * 32, |
| 469 |
NV_VRAM_DOMAIN(&nvc0->screen->base), 32, |
| 470 |
tic->tic); |
| 471 |
return true; |
| 472 |
} |
| 473 |
|
| 474 |
return false; |
| 475 |
} |
| 476 |
|
| 477 |
bool |
| 478 |
nvc0_validate_tic(struct nvc0_context *nvc0, int s) |
| 479 |
{ |
| 480 |
uint32_t commands[32]; |
| 481 |
struct nouveau_pushbuf *push = nvc0->base.pushbuf; |
| 482 |
unsigned i; |
| 483 |
unsigned n = 0; |
| 484 |
bool need_flush = false; |
| 485 |
|
| 486 |
for (i = 0; i < nvc0->num_textures[s]; ++i) { |
| 487 |
struct nv50_tic_entry *tic = nv50_tic_entry(nvc0->textures[s][i]); |
| 488 |
struct nv04_resource *res; |
| 489 |
const bool dirty = !!(nvc0->textures_dirty[s] & (1 << i)); |
| 490 |
|
| 491 |
if (!tic) { |
| 492 |
if (dirty) |
| 493 |
commands[n++] = (i << 1) | 0; |
| 494 |
continue; |
| 495 |
} |
| 496 |
res = nv04_resource(tic->pipe.texture); |
| 497 |
need_flush |= nvc0_update_tic(nvc0, tic, res); |
| 498 |
|
| 499 |
if (tic->id < 0) { |
| 500 |
tic->id = nvc0_screen_tic_alloc(nvc0->screen, tic); |
| 501 |
|
| 502 |
nvc0->base.push_data(&nvc0->base, nvc0->screen->txc, tic->id * 32, |
| 503 |
NV_VRAM_DOMAIN(&nvc0->screen->base), 32, |
| 504 |
tic->tic); |
| 505 |
need_flush = true; |
| 506 |
} else |
| 507 |
if (res->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING) { |
| 508 |
if (unlikely(s == 5)) |
| 509 |
BEGIN_NVC0(push, NVC0_CP(TEX_CACHE_CTL), 1); |
| 510 |
else |
| 511 |
BEGIN_NVC0(push, NVC0_3D(TEX_CACHE_CTL), 1); |
| 512 |
PUSH_DATA (push, (tic->id << 4) | 1); |
| 513 |
NOUVEAU_DRV_STAT(&nvc0->screen->base, tex_cache_flush_count, 1); |
| 514 |
} |
| 515 |
nvc0->screen->tic.lock[tic->id / 32] |= 1 << (tic->id % 32); |
| 516 |
|
| 517 |
res->status &= ~NOUVEAU_BUFFER_STATUS_GPU_WRITING; |
| 518 |
res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; |
| 519 |
|
| 520 |
if (!dirty) |
| 521 |
continue; |
| 522 |
commands[n++] = (tic->id << 9) | (i << 1) | 1; |
| 523 |
|
| 524 |
if (unlikely(s == 5)) |
| 525 |
BCTX_REFN(nvc0->bufctx_cp, CP_TEX(i), res, RD); |
| 526 |
else |
| 527 |
BCTX_REFN(nvc0->bufctx_3d, 3D_TEX(s, i), res, RD); |
| 528 |
} |
| 529 |
for (; i < nvc0->state.num_textures[s]; ++i) |
| 530 |
commands[n++] = (i << 1) | 0; |
| 531 |
|
| 532 |
nvc0->state.num_textures[s] = nvc0->num_textures[s]; |
| 533 |
|
| 534 |
if (n) { |
| 535 |
if (unlikely(s == 5)) |
| 536 |
BEGIN_NIC0(push, NVC0_CP(BIND_TIC), n); |
| 537 |
else |
| 538 |
BEGIN_NIC0(push, NVC0_3D(BIND_TIC(s)), n); |
| 539 |
PUSH_DATAp(push, commands, n); |
| 540 |
} |
| 541 |
nvc0->textures_dirty[s] = 0; |
| 542 |
|
| 543 |
return need_flush; |
| 544 |
} |
| 545 |
|
| 546 |
static bool |
| 547 |
nve4_validate_tic(struct nvc0_context *nvc0, unsigned s) |
| 548 |
{ |
| 549 |
struct nouveau_pushbuf *push = nvc0->base.pushbuf; |
| 550 |
unsigned i; |
| 551 |
bool need_flush = false; |
| 552 |
|
| 553 |
for (i = 0; i < nvc0->num_textures[s]; ++i) { |
| 554 |
struct nv50_tic_entry *tic = nv50_tic_entry(nvc0->textures[s][i]); |
| 555 |
struct nv04_resource *res; |
| 556 |
const bool dirty = !!(nvc0->textures_dirty[s] & (1 << i)); |
| 557 |
|
| 558 |
if (!tic) { |
| 559 |
nvc0->tex_handles[s][i] |= NVE4_TIC_ENTRY_INVALID; |
| 560 |
continue; |
| 561 |
} |
| 562 |
res = nv04_resource(tic->pipe.texture); |
| 563 |
need_flush |= nvc0_update_tic(nvc0, tic, res); |
| 564 |
|
| 565 |
if (tic->id < 0) { |
| 566 |
tic->id = nvc0_screen_tic_alloc(nvc0->screen, tic); |
| 567 |
|
| 568 |
nvc0->base.push_data(&nvc0->base, nvc0->screen->txc, tic->id * 32, |
| 569 |
NV_VRAM_DOMAIN(&nvc0->screen->base), 32, |
| 570 |
tic->tic); |
| 571 |
need_flush = true; |
| 572 |
} else |
| 573 |
if (res->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING) { |
| 574 |
BEGIN_NVC0(push, NVC0_3D(TEX_CACHE_CTL), 1); |
| 575 |
PUSH_DATA (push, (tic->id << 4) | 1); |
| 576 |
} |
| 577 |
nvc0->screen->tic.lock[tic->id / 32] |= 1 << (tic->id % 32); |
| 578 |
|
| 579 |
res->status &= ~NOUVEAU_BUFFER_STATUS_GPU_WRITING; |
| 580 |
res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; |
| 581 |
|
| 582 |
nvc0->tex_handles[s][i] &= ~NVE4_TIC_ENTRY_INVALID; |
| 583 |
nvc0->tex_handles[s][i] |= tic->id; |
| 584 |
if (dirty) |
| 585 |
BCTX_REFN(nvc0->bufctx_3d, 3D_TEX(s, i), res, RD); |
| 586 |
} |
| 587 |
for (; i < nvc0->state.num_textures[s]; ++i) { |
| 588 |
nvc0->tex_handles[s][i] |= NVE4_TIC_ENTRY_INVALID; |
| 589 |
nvc0->textures_dirty[s] |= 1 << i; |
| 590 |
} |
| 591 |
|
| 592 |
nvc0->state.num_textures[s] = nvc0->num_textures[s]; |
| 593 |
|
| 594 |
return need_flush; |
| 595 |
} |
| 596 |
|
| 597 |
void nvc0_validate_textures(struct nvc0_context *nvc0) |
| 598 |
{ |
| 599 |
bool need_flush = false; |
| 600 |
int i; |
| 601 |
|
| 602 |
for (i = 0; i < 5; i++) { |
| 603 |
if (nvc0->screen->base.class_3d >= NVE4_3D_CLASS) |
| 604 |
need_flush |= nve4_validate_tic(nvc0, i); |
| 605 |
else |
| 606 |
need_flush |= nvc0_validate_tic(nvc0, i); |
| 607 |
} |
| 608 |
|
| 609 |
if (need_flush) { |
| 610 |
BEGIN_NVC0(nvc0->base.pushbuf, NVC0_3D(TIC_FLUSH), 1); |
| 611 |
PUSH_DATA (nvc0->base.pushbuf, 0); |
| 612 |
} |
| 613 |
|
| 614 |
/* Invalidate all CP textures because they are aliased. */ |
| 615 |
for (int i = 0; i < nvc0->num_textures[5]; i++) |
| 616 |
nouveau_bufctx_reset(nvc0->bufctx_cp, NVC0_BIND_CP_TEX(i)); |
| 617 |
nvc0->textures_dirty[5] = ~0; |
| 618 |
nvc0->dirty_cp |= NVC0_NEW_CP_TEXTURES; |
| 619 |
} |
| 620 |
|
| 621 |
bool |
| 622 |
nvc0_validate_tsc(struct nvc0_context *nvc0, int s) |
| 623 |
{ |
| 624 |
uint32_t commands[16]; |
| 625 |
struct nouveau_pushbuf *push = nvc0->base.pushbuf; |
| 626 |
unsigned i; |
| 627 |
unsigned n = 0; |
| 628 |
bool need_flush = false; |
| 629 |
|
| 630 |
for (i = 0; i < nvc0->num_samplers[s]; ++i) { |
| 631 |
struct nv50_tsc_entry *tsc = nv50_tsc_entry(nvc0->samplers[s][i]); |
| 632 |
|
| 633 |
if (!(nvc0->samplers_dirty[s] & (1 << i))) |
| 634 |
continue; |
| 635 |
if (!tsc) { |
| 636 |
commands[n++] = (i << 4) | 0; |
| 637 |
continue; |
| 638 |
} |
| 639 |
nvc0->seamless_cube_map = tsc->seamless_cube_map; |
| 640 |
if (tsc->id < 0) { |
| 641 |
tsc->id = nvc0_screen_tsc_alloc(nvc0->screen, tsc); |
| 642 |
|
| 643 |
nvc0_m2mf_push_linear(&nvc0->base, nvc0->screen->txc, |
| 644 |
65536 + tsc->id * 32, NV_VRAM_DOMAIN(&nvc0->screen->base), |
| 645 |
32, tsc->tsc); |
| 646 |
need_flush = true; |
| 647 |
} |
| 648 |
nvc0->screen->tsc.lock[tsc->id / 32] |= 1 << (tsc->id % 32); |
| 649 |
|
| 650 |
commands[n++] = (tsc->id << 12) | (i << 4) | 1; |
| 651 |
} |
| 652 |
for (; i < nvc0->state.num_samplers[s]; ++i) |
| 653 |
commands[n++] = (i << 4) | 0; |
| 654 |
|
| 655 |
nvc0->state.num_samplers[s] = nvc0->num_samplers[s]; |
| 656 |
|
| 657 |
// TXF, in unlinked tsc mode, will always use sampler 0. So we have to |
| 658 |
// ensure that it remains bound. Its contents don't matter, all samplers we |
| 659 |
// ever create have the SRGB_CONVERSION bit set, so as long as the first |
| 660 |
// entry is initialized, we're good to go. This is the only bit that has |
| 661 |
// any effect on what TXF does. |
| 662 |
if ((nvc0->samplers_dirty[s] & 1) && !nvc0->samplers[s][0]) { |
| 663 |
if (n == 0) |
| 664 |
n = 1; |
| 665 |
// We're guaranteed that the first command refers to the first slot, so |
| 666 |
// we're not overwriting a valid entry. |
| 667 |
commands[0] = (0 << 12) | (0 << 4) | 1; |
| 668 |
} |
| 669 |
|
| 670 |
if (n) { |
| 671 |
if (unlikely(s == 5)) |
| 672 |
BEGIN_NIC0(push, NVC0_CP(BIND_TSC), n); |
| 673 |
else |
| 674 |
BEGIN_NIC0(push, NVC0_3D(BIND_TSC(s)), n); |
| 675 |
PUSH_DATAp(push, commands, n); |
| 676 |
} |
| 677 |
nvc0->samplers_dirty[s] = 0; |
| 678 |
|
| 679 |
return need_flush; |
| 680 |
} |
| 681 |
|
| 682 |
bool |
| 683 |
nve4_validate_tsc(struct nvc0_context *nvc0, int s) |
| 684 |
{ |
| 685 |
unsigned i; |
| 686 |
bool need_flush = false; |
| 687 |
|
| 688 |
for (i = 0; i < nvc0->num_samplers[s]; ++i) { |
| 689 |
struct nv50_tsc_entry *tsc = nv50_tsc_entry(nvc0->samplers[s][i]); |
| 690 |
|
| 691 |
if (!tsc) { |
| 692 |
nvc0->tex_handles[s][i] |= NVE4_TSC_ENTRY_INVALID; |
| 693 |
continue; |
| 694 |
} |
| 695 |
if (tsc->id < 0) { |
| 696 |
tsc->id = nvc0_screen_tsc_alloc(nvc0->screen, tsc); |
| 697 |
|
| 698 |
nve4_p2mf_push_linear(&nvc0->base, nvc0->screen->txc, |
| 699 |
65536 + tsc->id * 32, |
| 700 |
NV_VRAM_DOMAIN(&nvc0->screen->base), |
| 701 |
32, tsc->tsc); |
| 702 |
need_flush = true; |
| 703 |
} |
| 704 |
nvc0->screen->tsc.lock[tsc->id / 32] |= 1 << (tsc->id % 32); |
| 705 |
|
| 706 |
nvc0->tex_handles[s][i] &= ~NVE4_TSC_ENTRY_INVALID; |
| 707 |
nvc0->tex_handles[s][i] |= tsc->id << 20; |
| 708 |
} |
| 709 |
for (; i < nvc0->state.num_samplers[s]; ++i) { |
| 710 |
nvc0->tex_handles[s][i] |= NVE4_TSC_ENTRY_INVALID; |
| 711 |
nvc0->samplers_dirty[s] |= 1 << i; |
| 712 |
} |
| 713 |
|
| 714 |
nvc0->state.num_samplers[s] = nvc0->num_samplers[s]; |
| 715 |
|
| 716 |
return need_flush; |
| 717 |
} |
| 718 |
|
| 719 |
void nvc0_validate_samplers(struct nvc0_context *nvc0) |
| 720 |
{ |
| 721 |
bool need_flush = false; |
| 722 |
int i; |
| 723 |
|
| 724 |
for (i = 0; i < 5; i++) { |
| 725 |
if (nvc0->screen->base.class_3d >= NVE4_3D_CLASS) |
| 726 |
need_flush |= nve4_validate_tsc(nvc0, i); |
| 727 |
else |
| 728 |
need_flush |= nvc0_validate_tsc(nvc0, i); |
| 729 |
} |
| 730 |
|
| 731 |
if (need_flush) { |
| 732 |
BEGIN_NVC0(nvc0->base.pushbuf, NVC0_3D(TSC_FLUSH), 1); |
| 733 |
PUSH_DATA (nvc0->base.pushbuf, 0); |
| 734 |
} |
| 735 |
|
| 736 |
/* Invalidate all CP samplers because they are aliased. */ |
| 737 |
nvc0->samplers_dirty[5] = ~0; |
| 738 |
nvc0->dirty_cp |= NVC0_NEW_CP_SAMPLERS; |
| 739 |
} |
| 740 |
|
| 741 |
void |
| 742 |
nvc0_upload_tsc0(struct nvc0_context *nvc0) |
| 743 |
{ |
| 744 |
struct nouveau_pushbuf *push = nvc0->base.pushbuf; |
| 745 |
u32 data[8] = { G80_TSC_0_SRGB_CONVERSION }; |
| 746 |
nvc0->base.push_data(&nvc0->base, nvc0->screen->txc, |
| 747 |
65536 /*+ tsc->id * 32*/, |
| 748 |
NV_VRAM_DOMAIN(&nvc0->screen->base), 32, data); |
| 749 |
BEGIN_NVC0(push, NVC0_3D(TSC_FLUSH), 1); |
| 750 |
PUSH_DATA (push, 0); |
| 751 |
} |
| 752 |
|
| 753 |
/* Upload the "diagonal" entries for the possible texture sources ($t == $s). |
| 754 |
* At some point we might want to get a list of the combinations used by a |
| 755 |
* shader and fill in those entries instead of having it extract the handles. |
| 756 |
*/ |
| 757 |
void |
| 758 |
nve4_set_tex_handles(struct nvc0_context *nvc0) |
| 759 |
{ |
| 760 |
struct nouveau_pushbuf *push = nvc0->base.pushbuf; |
| 761 |
struct nvc0_screen *screen = nvc0->screen; |
| 762 |
unsigned s; |
| 763 |
|
| 764 |
if (nvc0->screen->base.class_3d < NVE4_3D_CLASS) |
| 765 |
return; |
| 766 |
|
| 767 |
for (s = 0; s < 5; ++s) { |
| 768 |
uint32_t dirty = nvc0->textures_dirty[s] | nvc0->samplers_dirty[s]; |
| 769 |
if (!dirty) |
| 770 |
continue; |
| 771 |
BEGIN_NVC0(push, NVC0_3D(CB_SIZE), 3); |
| 772 |
PUSH_DATA (push, NVC0_CB_AUX_SIZE); |
| 773 |
PUSH_DATAh(push, screen->uniform_bo->offset + NVC0_CB_AUX_INFO(s)); |
| 774 |
PUSH_DATA (push, screen->uniform_bo->offset + NVC0_CB_AUX_INFO(s)); |
| 775 |
do { |
| 776 |
int i = ffs(dirty) - 1; |
| 777 |
dirty &= ~(1 << i); |
| 778 |
|
| 779 |
BEGIN_NVC0(push, NVC0_3D(CB_POS), 2); |
| 780 |
PUSH_DATA (push, NVC0_CB_AUX_TEX_INFO(i)); |
| 781 |
PUSH_DATA (push, nvc0->tex_handles[s][i]); |
| 782 |
} while (dirty); |
| 783 |
|
| 784 |
nvc0->textures_dirty[s] = 0; |
| 785 |
nvc0->samplers_dirty[s] = 0; |
| 786 |
} |
| 787 |
} |
| 788 |
|
| 789 |
static uint64_t |
| 790 |
nve4_create_texture_handle(struct pipe_context *pipe, |
| 791 |
struct pipe_sampler_view *view, |
| 792 |
const struct pipe_sampler_state *sampler) |
| 793 |
{ |
| 794 |
/* We have to create persistent handles that won't change for these objects |
| 795 |
* That means that we have to upload them into place and lock them so that |
| 796 |
* they can't be kicked out later. |
| 797 |
*/ |
| 798 |
struct nvc0_context *nvc0 = nvc0_context(pipe); |
| 799 |
struct nouveau_pushbuf *push = nvc0->base.pushbuf; |
| 800 |
struct nv50_tic_entry *tic = nv50_tic_entry(view); |
| 801 |
struct nv50_tsc_entry *tsc = pipe->create_sampler_state(pipe, sampler); |
| 802 |
struct pipe_sampler_view *v = NULL; |
| 803 |
|
| 804 |
tsc->id = nvc0_screen_tsc_alloc(nvc0->screen, tsc); |
| 805 |
if (tsc->id < 0) |
| 806 |
goto fail; |
| 807 |
|
| 808 |
if (tic->id < 0) { |
| 809 |
tic->id = nvc0_screen_tic_alloc(nvc0->screen, tic); |
| 810 |
if (tic->id < 0) |
| 811 |
goto fail; |
| 812 |
|
| 813 |
nve4_p2mf_push_linear(&nvc0->base, nvc0->screen->txc, tic->id * 32, |
| 814 |
NV_VRAM_DOMAIN(&nvc0->screen->base), 32, |
| 815 |
tic->tic); |
| 816 |
|
| 817 |
IMMED_NVC0(push, NVC0_3D(TIC_FLUSH), 0); |
| 818 |
} |
| 819 |
|
| 820 |
nve4_p2mf_push_linear(&nvc0->base, nvc0->screen->txc, |
| 821 |
65536 + tsc->id * 32, |
| 822 |
NV_VRAM_DOMAIN(&nvc0->screen->base), |
| 823 |
32, tsc->tsc); |
| 824 |
|
| 825 |
IMMED_NVC0(push, NVC0_3D(TSC_FLUSH), 0); |
| 826 |
|
| 827 |
// Add an extra reference to this sampler view effectively held by this |
| 828 |
// texture handle. This is to deal with the sampler view being dereferenced |
| 829 |
// before the handle is. However we need the view to still be live until the |
| 830 |
// handle to it is deleted. |
| 831 |
pipe_sampler_view_reference(&v, view); |
| 832 |
p_atomic_inc(&tic->bindless); |
| 833 |
|
| 834 |
nvc0->screen->tic.lock[tic->id / 32] |= 1 << (tic->id % 32); |
| 835 |
nvc0->screen->tsc.lock[tsc->id / 32] |= 1 << (tsc->id % 32); |
| 836 |
|
| 837 |
return 0x100000000ULL | (tsc->id << 20) | tic->id; |
| 838 |
|
| 839 |
fail: |
| 840 |
pipe->delete_sampler_state(pipe, tsc); |
| 841 |
return 0; |
| 842 |
} |
| 843 |
|
| 844 |
static bool |
| 845 |
view_bound(struct nvc0_context *nvc0, struct pipe_sampler_view *view) { |
| 846 |
for (int s = 0; s < 6; s++) { |
| 847 |
for (int i = 0; i < nvc0->num_textures[s]; i++) |
| 848 |
if (nvc0->textures[s][i] == view) |
| 849 |
return true; |
| 850 |
} |
| 851 |
return false; |
| 852 |
} |
| 853 |
|
| 854 |
static void |
| 855 |
nve4_delete_texture_handle(struct pipe_context *pipe, uint64_t handle) |
| 856 |
{ |
| 857 |
struct nvc0_context *nvc0 = nvc0_context(pipe); |
| 858 |
uint32_t tic = handle & NVE4_TIC_ENTRY_INVALID; |
| 859 |
uint32_t tsc = (handle & NVE4_TSC_ENTRY_INVALID) >> 20; |
| 860 |
struct nv50_tic_entry *entry = nvc0->screen->tic.entries[tic]; |
| 861 |
|
| 862 |
if (entry) { |
| 863 |
struct pipe_sampler_view *view = &entry->pipe; |
| 864 |
assert(entry->bindless); |
| 865 |
p_atomic_dec(&entry->bindless); |
| 866 |
if (!view_bound(nvc0, view)) |
| 867 |
nvc0_screen_tic_unlock(nvc0->screen, entry); |
| 868 |
pipe_sampler_view_reference(&view, NULL); |
| 869 |
} |
| 870 |
|
| 871 |
pipe->delete_sampler_state(pipe, nvc0->screen->tsc.entries[tsc]); |
| 872 |
} |
| 873 |
|
| 874 |
static void |
| 875 |
nve4_make_texture_handle_resident(struct pipe_context *pipe, |
| 876 |
uint64_t handle, bool resident) |
| 877 |
{ |
| 878 |
struct nvc0_context *nvc0 = nvc0_context(pipe); |
| 879 |
if (resident) { |
| 880 |
struct nvc0_resident *res = calloc(1, sizeof(struct nvc0_resident)); |
| 881 |
struct nv50_tic_entry *tic = |
| 882 |
nvc0->screen->tic.entries[handle & NVE4_TIC_ENTRY_INVALID]; |
| 883 |
assert(tic); |
| 884 |
assert(tic->bindless); |
| 885 |
|
| 886 |
res->handle = handle; |
| 887 |
res->buf = nv04_resource(tic->pipe.texture); |
| 888 |
res->flags = NOUVEAU_BO_RD; |
| 889 |
list_add(&res->list, &nvc0->tex_head); |
| 890 |
} else { |
| 891 |
list_for_each_entry_safe(struct nvc0_resident, pos, &nvc0->tex_head, list) { |
| 892 |
if (pos->handle == handle) { |
| 893 |
list_del(&pos->list); |
| 894 |
free(pos); |
| 895 |
break; |
| 896 |
} |
| 897 |
} |
| 898 |
} |
| 899 |
} |
| 900 |
|
| 901 |
static const uint8_t nve4_su_format_map[PIPE_FORMAT_COUNT]; |
| 902 |
static const uint16_t nve4_su_format_aux_map[PIPE_FORMAT_COUNT]; |
| 903 |
static const uint16_t nve4_suldp_lib_offset[PIPE_FORMAT_COUNT]; |
| 904 |
|
| 905 |
static void |
| 906 |
nvc0_get_surface_dims(const struct pipe_image_view *view, |
| 907 |
int *width, int *height, int *depth) |
| 908 |
{ |
| 909 |
struct nv04_resource *res = nv04_resource(view->resource); |
| 910 |
int level; |
| 911 |
|
| 912 |
*width = *height = *depth = 1; |
| 913 |
if (res->base.target == PIPE_BUFFER) { |
| 914 |
*width = view->u.buf.size / util_format_get_blocksize(view->format); |
| 915 |
return; |
| 916 |
} |
| 917 |
|
| 918 |
level = view->u.tex.level; |
| 919 |
*width = u_minify(view->resource->width0, level); |
| 920 |
*height = u_minify(view->resource->height0, level); |
| 921 |
*depth = u_minify(view->resource->depth0, level); |
| 922 |
|
| 923 |
switch (res->base.target) { |
| 924 |
case PIPE_TEXTURE_1D_ARRAY: |
| 925 |
case PIPE_TEXTURE_2D_ARRAY: |
| 926 |
case PIPE_TEXTURE_CUBE: |
| 927 |
case PIPE_TEXTURE_CUBE_ARRAY: |
| 928 |
*depth = view->u.tex.last_layer - view->u.tex.first_layer + 1; |
| 929 |
break; |
| 930 |
case PIPE_TEXTURE_1D: |
| 931 |
case PIPE_TEXTURE_2D: |
| 932 |
case PIPE_TEXTURE_RECT: |
| 933 |
case PIPE_TEXTURE_3D: |
| 934 |
break; |
| 935 |
default: |
| 936 |
assert(!"unexpected texture target"); |
| 937 |
break; |
| 938 |
} |
| 939 |
} |
| 940 |
|
| 941 |
void |
| 942 |
nvc0_mark_image_range_valid(const struct pipe_image_view *view) |
| 943 |
{ |
| 944 |
struct nv04_resource *res = (struct nv04_resource *)view->resource; |
| 945 |
|
| 946 |
assert(view->resource->target == PIPE_BUFFER); |
| 947 |
|
| 948 |
util_range_add(&res->base, &res->valid_buffer_range, |
| 949 |
view->u.buf.offset, |
| 950 |
view->u.buf.offset + view->u.buf.size); |
| 951 |
} |
| 952 |
|
| 953 |
void |
| 954 |
nve4_set_surface_info(struct nouveau_pushbuf *push, |
| 955 |
const struct pipe_image_view *view, |
| 956 |
struct nvc0_context *nvc0) |
| 957 |
{ |
| 958 |
struct nvc0_screen *screen = nvc0->screen; |
| 959 |
struct nv04_resource *res; |
| 960 |
uint64_t address; |
| 961 |
uint32_t *const info = push->cur; |
| 962 |
int width, height, depth; |
| 963 |
uint8_t log2cpp; |
| 964 |
|
| 965 |
if (view && !nve4_su_format_map[view->format]) |
| 966 |
NOUVEAU_ERR("unsupported surface format, try is_format_supported() !\n"); |
| 967 |
|
| 968 |
push->cur += 16; |
| 969 |
|
| 970 |
if (!view || !nve4_su_format_map[view->format]) { |
| 971 |
memset(info, 0, 16 * sizeof(*info)); |
| 972 |
|
| 973 |
info[0] = 0xbadf0000; |
| 974 |
info[1] = 0x80004000; |
| 975 |
info[12] = nve4_suldp_lib_offset[PIPE_FORMAT_R32G32B32A32_UINT] + |
| 976 |
screen->lib_code->start; |
| 977 |
return; |
| 978 |
} |
| 979 |
res = nv04_resource(view->resource); |
| 980 |
|
| 981 |
address = res->address; |
| 982 |
|
| 983 |
/* get surface dimensions based on the target. */ |
| 984 |
nvc0_get_surface_dims(view, &width, &height, &depth); |
| 985 |
|
| 986 |
info[8] = width; |
| 987 |
info[9] = height; |
| 988 |
info[10] = depth; |
| 989 |
switch (res->base.target) { |
| 990 |
case PIPE_TEXTURE_1D_ARRAY: |
| 991 |
info[11] = 1; |
| 992 |
break; |
| 993 |
case PIPE_TEXTURE_2D: |
| 994 |
case PIPE_TEXTURE_RECT: |
| 995 |
info[11] = 2; |
| 996 |
break; |
| 997 |
case PIPE_TEXTURE_3D: |
| 998 |
info[11] = 3; |
| 999 |
break; |
| 1000 |
case PIPE_TEXTURE_2D_ARRAY: |
| 1001 |
case PIPE_TEXTURE_CUBE: |
| 1002 |
case PIPE_TEXTURE_CUBE_ARRAY: |
| 1003 |
info[11] = 4; |
| 1004 |
break; |
| 1005 |
default: |
| 1006 |
info[11] = 0; |
| 1007 |
break; |
| 1008 |
} |
| 1009 |
log2cpp = (0xf000 & nve4_su_format_aux_map[view->format]) >> 12; |
| 1010 |
|
| 1011 |
/* Stick the blockwidth (ie. number of bytes per pixel) to check if the |
| 1012 |
* format doesn't mismatch. */ |
| 1013 |
info[12] = util_format_get_blocksize(view->format); |
| 1014 |
|
| 1015 |
/* limit in bytes for raw access */ |
| 1016 |
info[13] = (0x06 << 22) | ((width << log2cpp) - 1); |
| 1017 |
|
| 1018 |
info[1] = nve4_su_format_map[view->format]; |
| 1019 |
|
| 1020 |
#if 0 |
| 1021 |
switch (util_format_get_blocksizebits(view->format)) { |
| 1022 |
case 16: info[1] |= 1 << 16; break; |
| 1023 |
case 32: info[1] |= 2 << 16; break; |
| 1024 |
case 64: info[1] |= 3 << 16; break; |
| 1025 |
case 128: info[1] |= 4 << 16; break; |
| 1026 |
default: |
| 1027 |
break; |
| 1028 |
} |
| 1029 |
#else |
| 1030 |
info[1] |= log2cpp << 16; |
| 1031 |
info[1] |= 0x4000; |
| 1032 |
info[1] |= (0x0f00 & nve4_su_format_aux_map[view->format]); |
| 1033 |
#endif |
| 1034 |
|
| 1035 |
if (res->base.target == PIPE_BUFFER) { |
| 1036 |
address += view->u.buf.offset; |
| 1037 |
|
| 1038 |
info[0] = address >> 8; |
| 1039 |
info[2] = width - 1; |
| 1040 |
info[2] |= (0xff & nve4_su_format_aux_map[view->format]) << 22; |
| 1041 |
info[3] = 0; |
| 1042 |
info[4] = 0; |
| 1043 |
info[5] = 0; |
| 1044 |
info[6] = 0; |
| 1045 |
info[7] = 0; |
| 1046 |
info[14] = 0; |
| 1047 |
info[15] = 0; |
| 1048 |
} else { |
| 1049 |
struct nv50_miptree *mt = nv50_miptree(&res->base); |
| 1050 |
struct nv50_miptree_level *lvl = &mt->level[view->u.tex.level]; |
| 1051 |
unsigned z = view->u.tex.first_layer; |
| 1052 |
|
| 1053 |
if (!mt->layout_3d) { |
| 1054 |
address += mt->layer_stride * z; |
| 1055 |
z = 0; |
| 1056 |
} |
| 1057 |
|
| 1058 |
address += lvl->offset; |
| 1059 |
|
| 1060 |
info[0] = address >> 8; |
| 1061 |
info[2] = (width << mt->ms_x) - 1; |
| 1062 |
/* NOTE: this is really important: */ |
| 1063 |
info[2] |= (0xff & nve4_su_format_aux_map[view->format]) << 22; |
| 1064 |
info[3] = (0x88 << 24) | (lvl->pitch / 64); |
| 1065 |
info[4] = (height << mt->ms_y) - 1; |
| 1066 |
info[4] |= (lvl->tile_mode & 0x0f0) << 25; |
| 1067 |
info[4] |= NVC0_TILE_SHIFT_Y(lvl->tile_mode) << 22; |
| 1068 |
info[5] = mt->layer_stride >> 8; |
| 1069 |
info[6] = depth - 1; |
| 1070 |
info[6] |= (lvl->tile_mode & 0xf00) << 21; |
| 1071 |
info[6] |= NVC0_TILE_SHIFT_Z(lvl->tile_mode) << 22; |
| 1072 |
info[7] = mt->layout_3d ? 1 : 0; |
| 1073 |
info[7] |= z << 16; |
| 1074 |
info[14] = mt->ms_x; |
| 1075 |
info[15] = mt->ms_y; |
| 1076 |
} |
| 1077 |
} |
| 1078 |
|
| 1079 |
static inline void |
| 1080 |
nvc0_set_surface_info(struct nouveau_pushbuf *push, |
| 1081 |
const struct pipe_image_view *view, uint64_t address, |
| 1082 |
int width, int height, int depth) |
| 1083 |
{ |
| 1084 |
struct nv04_resource *res; |
| 1085 |
uint32_t *const info = push->cur; |
| 1086 |
|
| 1087 |
push->cur += 16; |
| 1088 |
|
| 1089 |
/* Make sure to always initialize the surface information area because it's |
| 1090 |
* used to check if the given image is bound or not. */ |
| 1091 |
memset(info, 0, 16 * sizeof(*info)); |
| 1092 |
|
| 1093 |
if (!view || !view->resource) |
| 1094 |
return; |
| 1095 |
res = nv04_resource(view->resource); |
| 1096 |
|
| 1097 |
/* Stick the image dimensions for the imageSize() builtin. */ |
| 1098 |
info[8] = width; |
| 1099 |
info[9] = height; |
| 1100 |
info[10] = depth; |
| 1101 |
|
| 1102 |
/* Stick the blockwidth (ie. number of bytes per pixel) to calculate pixel |
| 1103 |
* offset and to check if the format doesn't mismatch. */ |
| 1104 |
info[12] = ffs(util_format_get_blocksize(view->format)) - 1; |
| 1105 |
|
| 1106 |
if (res->base.target == PIPE_BUFFER) { |
| 1107 |
info[0] = address >> 8; |
| 1108 |
info[2] = width; |
| 1109 |
} else { |
| 1110 |
struct nv50_miptree *mt = nv50_miptree(&res->base); |
| 1111 |
struct nv50_miptree_level *lvl = &mt->level[view->u.tex.level]; |
| 1112 |
unsigned z = mt->layout_3d ? view->u.tex.first_layer : 0; |
| 1113 |
unsigned nby = align(util_format_get_nblocksy(view->format, height), |
| 1114 |
NVC0_TILE_SIZE_Y(lvl->tile_mode)); |
| 1115 |
|
| 1116 |
/* NOTE: this does not precisely match nve4; the values are made to be |
| 1117 |
* easier for the shader to consume. |
| 1118 |
*/ |
| 1119 |
info[0] = address >> 8; |
| 1120 |
info[2] = (NVC0_TILE_SHIFT_X(lvl->tile_mode) - info[12]) << 24; |
| 1121 |
info[4] = NVC0_TILE_SHIFT_Y(lvl->tile_mode) << 24 | nby; |
| 1122 |
info[5] = mt->layer_stride >> 8; |
| 1123 |
info[6] = NVC0_TILE_SHIFT_Z(lvl->tile_mode) << 24; |
| 1124 |
info[7] = z; |
| 1125 |
info[14] = mt->ms_x; |
| 1126 |
info[15] = mt->ms_y; |
| 1127 |
} |
| 1128 |
} |
| 1129 |
|
| 1130 |
void |
| 1131 |
nvc0_validate_suf(struct nvc0_context *nvc0, int s) |
| 1132 |
{ |
| 1133 |
struct nouveau_pushbuf *push = nvc0->base.pushbuf; |
| 1134 |
struct nvc0_screen *screen = nvc0->screen; |
| 1135 |
|
| 1136 |
for (int i = 0; i < NVC0_MAX_IMAGES; ++i) { |
| 1137 |
struct pipe_image_view *view = &nvc0->images[s][i]; |
| 1138 |
int width = 0, height = 0, depth = 0; |
| 1139 |
uint64_t address = 0; |
| 1140 |
|
| 1141 |
if (s == 5) |
| 1142 |
BEGIN_NVC0(push, NVC0_CP(IMAGE(i)), 6); |
| 1143 |
else |
| 1144 |
BEGIN_NVC0(push, NVC0_3D(IMAGE(i)), 6); |
| 1145 |
|
| 1146 |
if (view->resource) { |
| 1147 |
struct nv04_resource *res = nv04_resource(view->resource); |
| 1148 |
unsigned rt = nvc0_format_table[view->format].rt; |
| 1149 |
|
| 1150 |
if (util_format_is_depth_or_stencil(view->format)) |
| 1151 |
rt = rt << 12; |
| 1152 |
else |
| 1153 |
rt = (rt << 4) | (0x14 << 12); |
| 1154 |
|
| 1155 |
/* get surface dimensions based on the target. */ |
| 1156 |
nvc0_get_surface_dims(view, &width, &height, &depth); |
| 1157 |
|
| 1158 |
address = res->address; |
| 1159 |
if (res->base.target == PIPE_BUFFER) { |
| 1160 |
unsigned blocksize = util_format_get_blocksize(view->format); |
| 1161 |
|
| 1162 |
address += view->u.buf.offset; |
| 1163 |
assert(!(address & 0xff)); |
| 1164 |
|
| 1165 |
if (view->access & PIPE_IMAGE_ACCESS_WRITE) |
| 1166 |
nvc0_mark_image_range_valid(view); |
| 1167 |
|
| 1168 |
PUSH_DATAh(push, address); |
| 1169 |
PUSH_DATA (push, address); |
| 1170 |
PUSH_DATA (push, align(width * blocksize, 0x100)); |
| 1171 |
PUSH_DATA (push, NVC0_3D_IMAGE_HEIGHT_LINEAR | 1); |
| 1172 |
PUSH_DATA (push, rt); |
| 1173 |
PUSH_DATA (push, 0); |
| 1174 |
} else { |
| 1175 |
struct nv50_miptree *mt = nv50_miptree(view->resource); |
| 1176 |
struct nv50_miptree_level *lvl = &mt->level[view->u.tex.level]; |
| 1177 |
unsigned adjusted_width = width, adjusted_height = height; |
| 1178 |
|
| 1179 |
if (mt->layout_3d) { |
| 1180 |
// We have to adjust the size of the 3d surface to be |
| 1181 |
// accessible within 2d limits. The size of each z tile goes |
| 1182 |
// into the x direction, while the number of z tiles goes into |
| 1183 |
// the y direction. |
| 1184 |
const unsigned nbx = util_format_get_nblocksx(view->format, width); |
| 1185 |
const unsigned nby = util_format_get_nblocksy(view->format, height); |
| 1186 |
const unsigned tsx = NVC0_TILE_SIZE_X(lvl->tile_mode); |
| 1187 |
const unsigned tsy = NVC0_TILE_SIZE_Y(lvl->tile_mode); |
| 1188 |
const unsigned tsz = NVC0_TILE_SIZE_Z(lvl->tile_mode); |
| 1189 |
|
| 1190 |
adjusted_width = align(nbx, tsx / util_format_get_blocksize(view->format)) * tsz; |
| 1191 |
adjusted_height = align(nby, tsy) * align(depth, tsz) >> NVC0_TILE_SHIFT_Z(lvl->tile_mode); |
| 1192 |
} else { |
| 1193 |
const unsigned z = view->u.tex.first_layer; |
| 1194 |
address += mt->layer_stride * z; |
| 1195 |
} |
| 1196 |
address += lvl->offset; |
| 1197 |
|
| 1198 |
PUSH_DATAh(push, address); |
| 1199 |
PUSH_DATA (push, address); |
| 1200 |
PUSH_DATA (push, adjusted_width << mt->ms_x); |
| 1201 |
PUSH_DATA (push, adjusted_height << mt->ms_y); |
| 1202 |
PUSH_DATA (push, rt); |
| 1203 |
PUSH_DATA (push, lvl->tile_mode & 0xff); /* mask out z-tiling */ |
| 1204 |
} |
| 1205 |
|
| 1206 |
if (s == 5) |
| 1207 |
BCTX_REFN(nvc0->bufctx_cp, CP_SUF, res, RDWR); |
| 1208 |
else |
| 1209 |
BCTX_REFN(nvc0->bufctx_3d, 3D_SUF, res, RDWR); |
| 1210 |
} else { |
| 1211 |
PUSH_DATA(push, 0); |
| 1212 |
PUSH_DATA(push, 0); |
| 1213 |
PUSH_DATA(push, 0); |
| 1214 |
PUSH_DATA(push, 0); |
| 1215 |
PUSH_DATA(push, 0x14000); |
| 1216 |
PUSH_DATA(push, 0); |
| 1217 |
} |
| 1218 |
|
| 1219 |
/* stick surface information into the driver constant buffer */ |
| 1220 |
if (s == 5) |
| 1221 |
BEGIN_NVC0(push, NVC0_CP(CB_SIZE), 3); |
| 1222 |
else |
| 1223 |
BEGIN_NVC0(push, NVC0_3D(CB_SIZE), 3); |
| 1224 |
PUSH_DATA (push, NVC0_CB_AUX_SIZE); |
| 1225 |
PUSH_DATAh(push, screen->uniform_bo->offset + NVC0_CB_AUX_INFO(s)); |
| 1226 |
PUSH_DATA (push, screen->uniform_bo->offset + NVC0_CB_AUX_INFO(s)); |
| 1227 |
if (s == 5) |
| 1228 |
BEGIN_1IC0(push, NVC0_CP(CB_POS), 1 + 16); |
| 1229 |
else |
| 1230 |
BEGIN_1IC0(push, NVC0_3D(CB_POS), 1 + 16); |
| 1231 |
PUSH_DATA (push, NVC0_CB_AUX_SU_INFO(i)); |
| 1232 |
|
| 1233 |
nvc0_set_surface_info(push, view, address, width, height, depth); |
| 1234 |
} |
| 1235 |
} |
| 1236 |
|
| 1237 |
static inline void |
| 1238 |
nvc0_update_surface_bindings(struct nvc0_context *nvc0) |
| 1239 |
{ |
| 1240 |
nvc0_validate_suf(nvc0, 4); |
| 1241 |
|
| 1242 |
/* Invalidate all COMPUTE images because they are aliased with FRAGMENT. */ |
| 1243 |
nouveau_bufctx_reset(nvc0->bufctx_cp, NVC0_BIND_CP_SUF); |
| 1244 |
nvc0->dirty_cp |= NVC0_NEW_CP_SURFACES; |
| 1245 |
nvc0->images_dirty[5] |= nvc0->images_valid[5]; |
| 1246 |
} |
| 1247 |
|
| 1248 |
static void |
| 1249 |
gm107_validate_surfaces(struct nvc0_context *nvc0, |
| 1250 |
struct pipe_image_view *view, int stage, int slot) |
| 1251 |
{ |
| 1252 |
struct nv04_resource *res = nv04_resource(view->resource); |
| 1253 |
struct nouveau_pushbuf *push = nvc0->base.pushbuf; |
| 1254 |
struct nvc0_screen *screen = nvc0->screen; |
| 1255 |
struct nv50_tic_entry *tic; |
| 1256 |
|
| 1257 |
tic = nv50_tic_entry(nvc0->images_tic[stage][slot]); |
| 1258 |
|
| 1259 |
res = nv04_resource(tic->pipe.texture); |
| 1260 |
nvc0_update_tic(nvc0, tic, res); |
| 1261 |
|
| 1262 |
if (tic->id < 0) { |
| 1263 |
tic->id = nvc0_screen_tic_alloc(nvc0->screen, tic); |
| 1264 |
|
| 1265 |
/* upload the texture view */ |
| 1266 |
nve4_p2mf_push_linear(&nvc0->base, nvc0->screen->txc, tic->id * 32, |
| 1267 |
NV_VRAM_DOMAIN(&nvc0->screen->base), 32, tic->tic); |
| 1268 |
|
| 1269 |
BEGIN_NVC0(push, NVC0_3D(TIC_FLUSH), 1); |
| 1270 |
PUSH_DATA (push, 0); |
| 1271 |
} else |
| 1272 |
if (res->status & NOUVEAU_BUFFER_STATUS_GPU_WRITING) { |
| 1273 |
BEGIN_NVC0(push, NVC0_3D(TEX_CACHE_CTL), 1); |
| 1274 |
PUSH_DATA (push, (tic->id << 4) | 1); |
| 1275 |
} |
| 1276 |
nvc0->screen->tic.lock[tic->id / 32] |= 1 << (tic->id % 32); |
| 1277 |
|
| 1278 |
res->status &= ~NOUVEAU_BUFFER_STATUS_GPU_WRITING; |
| 1279 |
res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; |
| 1280 |
|
| 1281 |
BCTX_REFN(nvc0->bufctx_3d, 3D_SUF, res, RD); |
| 1282 |
|
| 1283 |
/* upload the texture handle */ |
| 1284 |
BEGIN_NVC0(push, NVC0_3D(CB_SIZE), 3); |
| 1285 |
PUSH_DATA (push, NVC0_CB_AUX_SIZE); |
| 1286 |
PUSH_DATAh(push, screen->uniform_bo->offset + NVC0_CB_AUX_INFO(stage)); |
| 1287 |
PUSH_DATA (push, screen->uniform_bo->offset + NVC0_CB_AUX_INFO(stage)); |
| 1288 |
BEGIN_NVC0(push, NVC0_3D(CB_POS), 2); |
| 1289 |
PUSH_DATA (push, NVC0_CB_AUX_TEX_INFO(slot + 32)); |
| 1290 |
PUSH_DATA (push, tic->id); |
| 1291 |
} |
| 1292 |
|
| 1293 |
static inline void |
| 1294 |
nve4_update_surface_bindings(struct nvc0_context *nvc0) |
| 1295 |
{ |
| 1296 |
struct nouveau_pushbuf *push = nvc0->base.pushbuf; |
| 1297 |
struct nvc0_screen *screen = nvc0->screen; |
| 1298 |
int i, j, s; |
| 1299 |
|
| 1300 |
for (s = 0; s < 5; s++) { |
| 1301 |
if (!nvc0->images_dirty[s]) |
| 1302 |
continue; |
| 1303 |
|
| 1304 |
for (i = 0; i < NVC0_MAX_IMAGES; ++i) { |
| 1305 |
struct pipe_image_view *view = &nvc0->images[s][i]; |
| 1306 |
|
| 1307 |
BEGIN_NVC0(push, NVC0_3D(CB_SIZE), 3); |
| 1308 |
PUSH_DATA (push, NVC0_CB_AUX_SIZE); |
| 1309 |
PUSH_DATAh(push, screen->uniform_bo->offset + NVC0_CB_AUX_INFO(s)); |
| 1310 |
PUSH_DATA (push, screen->uniform_bo->offset + NVC0_CB_AUX_INFO(s)); |
| 1311 |
BEGIN_1IC0(push, NVC0_3D(CB_POS), 1 + 16); |
| 1312 |
PUSH_DATA (push, NVC0_CB_AUX_SU_INFO(i)); |
| 1313 |
|
| 1314 |
if (view->resource) { |
| 1315 |
struct nv04_resource *res = nv04_resource(view->resource); |
| 1316 |
|
| 1317 |
if (res->base.target == PIPE_BUFFER) { |
| 1318 |
if (view->access & PIPE_IMAGE_ACCESS_WRITE) |
| 1319 |
nvc0_mark_image_range_valid(view); |
| 1320 |
} |
| 1321 |
|
| 1322 |
nve4_set_surface_info(push, view, nvc0); |
| 1323 |
BCTX_REFN(nvc0->bufctx_3d, 3D_SUF, res, RDWR); |
| 1324 |
|
| 1325 |
if (nvc0->screen->base.class_3d >= GM107_3D_CLASS) |
| 1326 |
gm107_validate_surfaces(nvc0, view, s, i); |
| 1327 |
} else { |
| 1328 |
for (j = 0; j < 16; j++) |
| 1329 |
PUSH_DATA(push, 0); |
| 1330 |
} |
| 1331 |
} |
| 1332 |
} |
| 1333 |
} |
| 1334 |
|
| 1335 |
void |
| 1336 |
nvc0_validate_surfaces(struct nvc0_context *nvc0) |
| 1337 |
{ |
| 1338 |
if (nvc0->screen->base.class_3d >= NVE4_3D_CLASS) { |
| 1339 |
nve4_update_surface_bindings(nvc0); |
| 1340 |
} else { |
| 1341 |
nvc0_update_surface_bindings(nvc0); |
| 1342 |
} |
| 1343 |
} |
| 1344 |
|
| 1345 |
static uint64_t |
| 1346 |
nve4_create_image_handle(struct pipe_context *pipe, |
| 1347 |
const struct pipe_image_view *view) |
| 1348 |
{ |
| 1349 |
struct nvc0_context *nvc0 = nvc0_context(pipe); |
| 1350 |
struct nouveau_pushbuf *push = nvc0->base.pushbuf; |
| 1351 |
struct nvc0_screen *screen = nvc0->screen; |
| 1352 |
int i = screen->img.next, s; |
| 1353 |
|
| 1354 |
while (screen->img.entries[i]) { |
| 1355 |
i = (i + 1) & (NVE4_IMG_MAX_HANDLES - 1); |
| 1356 |
if (i == screen->img.next) |
| 1357 |
return 0; |
| 1358 |
} |
| 1359 |
|
| 1360 |
screen->img.next = (i + 1) & (NVE4_IMG_MAX_HANDLES - 1); |
| 1361 |
screen->img.entries[i] = calloc(1, sizeof(struct pipe_image_view)); |
| 1362 |
*screen->img.entries[i] = *view; |
| 1363 |
|
| 1364 |
for (s = 0; s < 6; s++) { |
| 1365 |
BEGIN_NVC0(push, NVC0_3D(CB_SIZE), 3); |
| 1366 |
PUSH_DATA (push, NVC0_CB_AUX_SIZE); |
| 1367 |
PUSH_DATAh(push, screen->uniform_bo->offset + NVC0_CB_AUX_INFO(s)); |
| 1368 |
PUSH_DATA (push, screen->uniform_bo->offset + NVC0_CB_AUX_INFO(s)); |
| 1369 |
BEGIN_1IC0(push, NVC0_3D(CB_POS), 1 + 16); |
| 1370 |
PUSH_DATA (push, NVC0_CB_AUX_BINDLESS_INFO(i)); |
| 1371 |
nve4_set_surface_info(push, view, nvc0); |
| 1372 |
} |
| 1373 |
|
| 1374 |
return 0x100000000ULL | i; |
| 1375 |
} |
| 1376 |
|
| 1377 |
static void |
| 1378 |
nve4_delete_image_handle(struct pipe_context *pipe, uint64_t handle) |
| 1379 |
{ |
| 1380 |
struct nvc0_context *nvc0 = nvc0_context(pipe); |
| 1381 |
struct nvc0_screen *screen = nvc0->screen; |
| 1382 |
int i = handle & (NVE4_IMG_MAX_HANDLES - 1); |
| 1383 |
|
| 1384 |
free(screen->img.entries[i]); |
| 1385 |
screen->img.entries[i] = NULL; |
| 1386 |
} |
| 1387 |
|
| 1388 |
static void |
| 1389 |
nve4_make_image_handle_resident(struct pipe_context *pipe, uint64_t handle, |
| 1390 |
unsigned access, bool resident) |
| 1391 |
{ |
| 1392 |
struct nvc0_context *nvc0 = nvc0_context(pipe); |
| 1393 |
struct nvc0_screen *screen = nvc0->screen; |
| 1394 |
|
| 1395 |
if (resident) { |
| 1396 |
struct nvc0_resident *res = calloc(1, sizeof(struct nvc0_resident)); |
| 1397 |
struct pipe_image_view *view = |
| 1398 |
screen->img.entries[handle & (NVE4_IMG_MAX_HANDLES - 1)]; |
| 1399 |
assert(view); |
| 1400 |
|
| 1401 |
if (view->resource->target == PIPE_BUFFER && |
| 1402 |
access & PIPE_IMAGE_ACCESS_WRITE) |
| 1403 |
nvc0_mark_image_range_valid(view); |
| 1404 |
res->handle = handle; |
| 1405 |
res->buf = nv04_resource(view->resource); |
| 1406 |
res->flags = (access & 3) << 8; |
| 1407 |
list_add(&res->list, &nvc0->img_head); |
| 1408 |
} else { |
| 1409 |
list_for_each_entry_safe(struct nvc0_resident, pos, &nvc0->img_head, list) { |
| 1410 |
if (pos->handle == handle) { |
| 1411 |
list_del(&pos->list); |
| 1412 |
free(pos); |
| 1413 |
break; |
| 1414 |
} |
| 1415 |
} |
| 1416 |
} |
| 1417 |
} |
| 1418 |
|
| 1419 |
static uint64_t |
| 1420 |
gm107_create_image_handle(struct pipe_context *pipe, |
| 1421 |
const struct pipe_image_view *view) |
| 1422 |
{ |
| 1423 |
/* GM107+ use TIC handles to reference images. As such, image handles are |
| 1424 |
* just the TIC id. |
| 1425 |
*/ |
| 1426 |
struct nvc0_context *nvc0 = nvc0_context(pipe); |
| 1427 |
struct nouveau_pushbuf *push = nvc0->base.pushbuf; |
| 1428 |
struct pipe_sampler_view *sview = |
| 1429 |
gm107_create_texture_view_from_image(pipe, view); |
| 1430 |
struct nv50_tic_entry *tic = nv50_tic_entry(sview); |
| 1431 |
|
| 1432 |
if (tic == NULL) |
| 1433 |
goto fail; |
| 1434 |
|
| 1435 |
tic->bindless = 1; |
| 1436 |
tic->id = nvc0_screen_tic_alloc(nvc0->screen, tic); |
| 1437 |
if (tic->id < 0) |
| 1438 |
goto fail; |
| 1439 |
|
| 1440 |
nve4_p2mf_push_linear(&nvc0->base, nvc0->screen->txc, tic->id * 32, |
| 1441 |
NV_VRAM_DOMAIN(&nvc0->screen->base), 32, |
| 1442 |
tic->tic); |
| 1443 |
|
| 1444 |
IMMED_NVC0(push, NVC0_3D(TIC_FLUSH), 0); |
| 1445 |
|
| 1446 |
nvc0->screen->tic.lock[tic->id / 32] |= 1 << (tic->id % 32); |
| 1447 |
|
| 1448 |
// Compute handle. This will include the TIC as well as some additional |
| 1449 |
// info regarding the bound 3d surface layer, if applicable. |
| 1450 |
uint64_t handle = 0x100000000ULL | tic->id; |
| 1451 |
struct nv04_resource *res = nv04_resource(view->resource); |
| 1452 |
if (res->base.target == PIPE_TEXTURE_3D) { |
| 1453 |
handle |= 1 << 11; |
| 1454 |
handle |= view->u.tex.first_layer << (11 + 16); |
| 1455 |
} |
| 1456 |
return handle; |
| 1457 |
|
| 1458 |
fail: |
| 1459 |
FREE(tic); |
| 1460 |
return 0; |
| 1461 |
} |
| 1462 |
|
| 1463 |
static void |
| 1464 |
gm107_delete_image_handle(struct pipe_context *pipe, uint64_t handle) |
| 1465 |
{ |
| 1466 |
struct nvc0_context *nvc0 = nvc0_context(pipe); |
| 1467 |
int tic = handle & NVE4_TIC_ENTRY_INVALID; |
| 1468 |
struct nv50_tic_entry *entry = nvc0->screen->tic.entries[tic]; |
| 1469 |
struct pipe_sampler_view *view = &entry->pipe; |
| 1470 |
assert(entry->bindless == 1); |
| 1471 |
assert(!view_bound(nvc0, view)); |
| 1472 |
entry->bindless = 0; |
| 1473 |
nvc0_screen_tic_unlock(nvc0->screen, entry); |
| 1474 |
pipe_sampler_view_reference(&view, NULL); |
| 1475 |
} |
| 1476 |
|
| 1477 |
static void |
| 1478 |
gm107_make_image_handle_resident(struct pipe_context *pipe, uint64_t handle, |
| 1479 |
unsigned access, bool resident) |
| 1480 |
{ |
| 1481 |
struct nvc0_context *nvc0 = nvc0_context(pipe); |
| 1482 |
|
| 1483 |
if (resident) { |
| 1484 |
struct nvc0_resident *res = calloc(1, sizeof(struct nvc0_resident)); |
| 1485 |
struct nv50_tic_entry *tic = |
| 1486 |
nvc0->screen->tic.entries[handle & NVE4_TIC_ENTRY_INVALID]; |
| 1487 |
assert(tic); |
| 1488 |
assert(tic->bindless); |
| 1489 |
|
| 1490 |
res->handle = handle; |
| 1491 |
res->buf = nv04_resource(tic->pipe.texture); |
| 1492 |
res->flags = (access & 3) << 8; |
| 1493 |
if (res->buf->base.target == PIPE_BUFFER && |
| 1494 |
access & PIPE_IMAGE_ACCESS_WRITE) |
| 1495 |
util_range_add(&res->buf->base, &res->buf->valid_buffer_range, |
| 1496 |
tic->pipe.u.buf.offset, |
| 1497 |
tic->pipe.u.buf.offset + tic->pipe.u.buf.size); |
| 1498 |
list_add(&res->list, &nvc0->img_head); |
| 1499 |
} else { |
| 1500 |
list_for_each_entry_safe(struct nvc0_resident, pos, &nvc0->img_head, list) { |
| 1501 |
if (pos->handle == handle) { |
| 1502 |
list_del(&pos->list); |
| 1503 |
free(pos); |
| 1504 |
break; |
| 1505 |
} |
| 1506 |
} |
| 1507 |
} |
| 1508 |
} |
| 1509 |
|
| 1510 |
void |
| 1511 |
nvc0_init_bindless_functions(struct pipe_context *pipe) { |
| 1512 |
pipe->create_texture_handle = nve4_create_texture_handle; |
| 1513 |
pipe->delete_texture_handle = nve4_delete_texture_handle; |
| 1514 |
pipe->make_texture_handle_resident = nve4_make_texture_handle_resident; |
| 1515 |
|
| 1516 |
if (nvc0_context(pipe)->screen->base.class_3d < GM107_3D_CLASS) { |
| 1517 |
pipe->create_image_handle = nve4_create_image_handle; |
| 1518 |
pipe->delete_image_handle = nve4_delete_image_handle; |
| 1519 |
pipe->make_image_handle_resident = nve4_make_image_handle_resident; |
| 1520 |
} else { |
| 1521 |
pipe->create_image_handle = gm107_create_image_handle; |
| 1522 |
pipe->delete_image_handle = gm107_delete_image_handle; |
| 1523 |
pipe->make_image_handle_resident = gm107_make_image_handle_resident; |
| 1524 |
} |
| 1525 |
} |
| 1526 |
|
| 1527 |
|
| 1528 |
static const uint8_t nve4_su_format_map[PIPE_FORMAT_COUNT] = |
| 1529 |
{ |
| 1530 |
[PIPE_FORMAT_R32G32B32A32_FLOAT] = GK104_IMAGE_FORMAT_RGBA32_FLOAT, |
| 1531 |
[PIPE_FORMAT_R32G32B32A32_SINT] = GK104_IMAGE_FORMAT_RGBA32_SINT, |
| 1532 |
[PIPE_FORMAT_R32G32B32A32_UINT] = GK104_IMAGE_FORMAT_RGBA32_UINT, |
| 1533 |
[PIPE_FORMAT_R16G16B16A16_FLOAT] = GK104_IMAGE_FORMAT_RGBA16_FLOAT, |
| 1534 |
[PIPE_FORMAT_R16G16B16A16_UNORM] = GK104_IMAGE_FORMAT_RGBA16_UNORM, |
| 1535 |
[PIPE_FORMAT_R16G16B16A16_SNORM] = GK104_IMAGE_FORMAT_RGBA16_SNORM, |
| 1536 |
[PIPE_FORMAT_R16G16B16A16_SINT] = GK104_IMAGE_FORMAT_RGBA16_SINT, |
| 1537 |
[PIPE_FORMAT_R16G16B16A16_UINT] = GK104_IMAGE_FORMAT_RGBA16_UINT, |
| 1538 |
[PIPE_FORMAT_B8G8R8A8_UNORM] = GK104_IMAGE_FORMAT_BGRA8_UNORM, |
| 1539 |
[PIPE_FORMAT_R8G8B8A8_UNORM] = GK104_IMAGE_FORMAT_RGBA8_UNORM, |
| 1540 |
[PIPE_FORMAT_R8G8B8A8_SNORM] = GK104_IMAGE_FORMAT_RGBA8_SNORM, |
| 1541 |
[PIPE_FORMAT_R8G8B8A8_SINT] = GK104_IMAGE_FORMAT_RGBA8_SINT, |
| 1542 |
[PIPE_FORMAT_R8G8B8A8_UINT] = GK104_IMAGE_FORMAT_RGBA8_UINT, |
| 1543 |
[PIPE_FORMAT_R11G11B10_FLOAT] = GK104_IMAGE_FORMAT_R11G11B10_FLOAT, |
| 1544 |
[PIPE_FORMAT_R10G10B10A2_UNORM] = GK104_IMAGE_FORMAT_RGB10_A2_UNORM, |
| 1545 |
[PIPE_FORMAT_R10G10B10A2_UINT] = GK104_IMAGE_FORMAT_RGB10_A2_UINT, |
| 1546 |
[PIPE_FORMAT_R32G32_FLOAT] = GK104_IMAGE_FORMAT_RG32_FLOAT, |
| 1547 |
[PIPE_FORMAT_R32G32_SINT] = GK104_IMAGE_FORMAT_RG32_SINT, |
| 1548 |
[PIPE_FORMAT_R32G32_UINT] = GK104_IMAGE_FORMAT_RG32_UINT, |
| 1549 |
[PIPE_FORMAT_R16G16_FLOAT] = GK104_IMAGE_FORMAT_RG16_FLOAT, |
| 1550 |
[PIPE_FORMAT_R16G16_UNORM] = GK104_IMAGE_FORMAT_RG16_UNORM, |
| 1551 |
[PIPE_FORMAT_R16G16_SNORM] = GK104_IMAGE_FORMAT_RG16_SNORM, |
| 1552 |
[PIPE_FORMAT_R16G16_SINT] = GK104_IMAGE_FORMAT_RG16_SINT, |
| 1553 |
[PIPE_FORMAT_R16G16_UINT] = GK104_IMAGE_FORMAT_RG16_UINT, |
| 1554 |
[PIPE_FORMAT_R8G8_UNORM] = GK104_IMAGE_FORMAT_RG8_UNORM, |
| 1555 |
[PIPE_FORMAT_R8G8_SNORM] = GK104_IMAGE_FORMAT_RG8_SNORM, |
| 1556 |
[PIPE_FORMAT_R8G8_SINT] = GK104_IMAGE_FORMAT_RG8_SINT, |
| 1557 |
[PIPE_FORMAT_R8G8_UINT] = GK104_IMAGE_FORMAT_RG8_UINT, |
| 1558 |
[PIPE_FORMAT_R32_FLOAT] = GK104_IMAGE_FORMAT_R32_FLOAT, |
| 1559 |
[PIPE_FORMAT_R32_SINT] = GK104_IMAGE_FORMAT_R32_SINT, |
| 1560 |
[PIPE_FORMAT_R32_UINT] = GK104_IMAGE_FORMAT_R32_UINT, |
| 1561 |
[PIPE_FORMAT_R16_FLOAT] = GK104_IMAGE_FORMAT_R16_FLOAT, |
| 1562 |
[PIPE_FORMAT_R16_UNORM] = GK104_IMAGE_FORMAT_R16_UNORM, |
| 1563 |
[PIPE_FORMAT_R16_SNORM] = GK104_IMAGE_FORMAT_R16_SNORM, |
| 1564 |
[PIPE_FORMAT_R16_SINT] = GK104_IMAGE_FORMAT_R16_SINT, |
| 1565 |
[PIPE_FORMAT_R16_UINT] = GK104_IMAGE_FORMAT_R16_UINT, |
| 1566 |
[PIPE_FORMAT_R8_UNORM] = GK104_IMAGE_FORMAT_R8_UNORM, |
| 1567 |
[PIPE_FORMAT_R8_SNORM] = GK104_IMAGE_FORMAT_R8_SNORM, |
| 1568 |
[PIPE_FORMAT_R8_SINT] = GK104_IMAGE_FORMAT_R8_SINT, |
| 1569 |
[PIPE_FORMAT_R8_UINT] = GK104_IMAGE_FORMAT_R8_UINT, |
| 1570 |
}; |
| 1571 |
|
| 1572 |
/* Auxiliary format description values for surface instructions. |
| 1573 |
* (log2(bytes per pixel) << 12) | (unk8 << 8) | unk22 |
| 1574 |
*/ |
| 1575 |
static const uint16_t nve4_su_format_aux_map[PIPE_FORMAT_COUNT] = |
| 1576 |
{ |
| 1577 |
[PIPE_FORMAT_R32G32B32A32_FLOAT] = 0x4842, |
| 1578 |
[PIPE_FORMAT_R32G32B32A32_SINT] = 0x4842, |
| 1579 |
[PIPE_FORMAT_R32G32B32A32_UINT] = 0x4842, |
| 1580 |
|
| 1581 |
[PIPE_FORMAT_R16G16B16A16_UNORM] = 0x3933, |
| 1582 |
[PIPE_FORMAT_R16G16B16A16_SNORM] = 0x3933, |
| 1583 |
[PIPE_FORMAT_R16G16B16A16_SINT] = 0x3933, |
| 1584 |
[PIPE_FORMAT_R16G16B16A16_UINT] = 0x3933, |
| 1585 |
[PIPE_FORMAT_R16G16B16A16_FLOAT] = 0x3933, |
| 1586 |
|
| 1587 |
[PIPE_FORMAT_R32G32_FLOAT] = 0x3433, |
| 1588 |
[PIPE_FORMAT_R32G32_SINT] = 0x3433, |
| 1589 |
[PIPE_FORMAT_R32G32_UINT] = 0x3433, |
| 1590 |
|
| 1591 |
[PIPE_FORMAT_R10G10B10A2_UNORM] = 0x2a24, |
| 1592 |
[PIPE_FORMAT_R10G10B10A2_UINT] = 0x2a24, |
| 1593 |
[PIPE_FORMAT_B8G8R8A8_UNORM] = 0x2a24, |
| 1594 |
[PIPE_FORMAT_R8G8B8A8_UNORM] = 0x2a24, |
| 1595 |
[PIPE_FORMAT_R8G8B8A8_SNORM] = 0x2a24, |
| 1596 |
[PIPE_FORMAT_R8G8B8A8_SINT] = 0x2a24, |
| 1597 |
[PIPE_FORMAT_R8G8B8A8_UINT] = 0x2a24, |
| 1598 |
[PIPE_FORMAT_R11G11B10_FLOAT] = 0x2a24, |
| 1599 |
|
| 1600 |
[PIPE_FORMAT_R16G16_UNORM] = 0x2524, |
| 1601 |
[PIPE_FORMAT_R16G16_SNORM] = 0x2524, |
| 1602 |
[PIPE_FORMAT_R16G16_SINT] = 0x2524, |
| 1603 |
[PIPE_FORMAT_R16G16_UINT] = 0x2524, |
| 1604 |
[PIPE_FORMAT_R16G16_FLOAT] = 0x2524, |
| 1605 |
|
| 1606 |
[PIPE_FORMAT_R32_SINT] = 0x2024, |
| 1607 |
[PIPE_FORMAT_R32_UINT] = 0x2024, |
| 1608 |
[PIPE_FORMAT_R32_FLOAT] = 0x2024, |
| 1609 |
|
| 1610 |
[PIPE_FORMAT_R8G8_UNORM] = 0x1615, |
| 1611 |
[PIPE_FORMAT_R8G8_SNORM] = 0x1615, |
| 1612 |
[PIPE_FORMAT_R8G8_SINT] = 0x1615, |
| 1613 |
[PIPE_FORMAT_R8G8_UINT] = 0x1615, |
| 1614 |
|
| 1615 |
[PIPE_FORMAT_R16_UNORM] = 0x1115, |
| 1616 |
[PIPE_FORMAT_R16_SNORM] = 0x1115, |
| 1617 |
[PIPE_FORMAT_R16_SINT] = 0x1115, |
| 1618 |
[PIPE_FORMAT_R16_UINT] = 0x1115, |
| 1619 |
[PIPE_FORMAT_R16_FLOAT] = 0x1115, |
| 1620 |
|
| 1621 |
[PIPE_FORMAT_R8_UNORM] = 0x0206, |
| 1622 |
[PIPE_FORMAT_R8_SNORM] = 0x0206, |
| 1623 |
[PIPE_FORMAT_R8_SINT] = 0x0206, |
| 1624 |
[PIPE_FORMAT_R8_UINT] = 0x0206 |
| 1625 |
}; |
| 1626 |
|
| 1627 |
/* NOTE: These are hardcoded offsets for the shader library. |
| 1628 |
* TODO: Automate them. |
| 1629 |
*/ |
| 1630 |
static const uint16_t nve4_suldp_lib_offset[PIPE_FORMAT_COUNT] = |
| 1631 |
{ |
| 1632 |
[PIPE_FORMAT_R32G32B32A32_FLOAT] = 0x218, |
| 1633 |
[PIPE_FORMAT_R32G32B32A32_SINT] = 0x218, |
| 1634 |
[PIPE_FORMAT_R32G32B32A32_UINT] = 0x218, |
| 1635 |
[PIPE_FORMAT_R16G16B16A16_UNORM] = 0x248, |
| 1636 |
[PIPE_FORMAT_R16G16B16A16_SNORM] = 0x2b8, |
| 1637 |
[PIPE_FORMAT_R16G16B16A16_SINT] = 0x330, |
| 1638 |
[PIPE_FORMAT_R16G16B16A16_UINT] = 0x388, |
| 1639 |
[PIPE_FORMAT_R16G16B16A16_FLOAT] = 0x3d8, |
| 1640 |
[PIPE_FORMAT_R32G32_FLOAT] = 0x428, |
| 1641 |
[PIPE_FORMAT_R32G32_SINT] = 0x468, |
| 1642 |
[PIPE_FORMAT_R32G32_UINT] = 0x468, |
| 1643 |
[PIPE_FORMAT_R10G10B10A2_UNORM] = 0x4a8, |
| 1644 |
[PIPE_FORMAT_R10G10B10A2_UINT] = 0x530, |
| 1645 |
[PIPE_FORMAT_R8G8B8A8_UNORM] = 0x588, |
| 1646 |
[PIPE_FORMAT_R8G8B8A8_SNORM] = 0x5f8, |
| 1647 |
[PIPE_FORMAT_R8G8B8A8_SINT] = 0x670, |
| 1648 |
[PIPE_FORMAT_R8G8B8A8_UINT] = 0x6c8, |
| 1649 |
[PIPE_FORMAT_B5G6R5_UNORM] = 0x718, |
| 1650 |
[PIPE_FORMAT_B5G5R5X1_UNORM] = 0x7a0, |
| 1651 |
[PIPE_FORMAT_R16G16_UNORM] = 0x828, |
| 1652 |
[PIPE_FORMAT_R16G16_SNORM] = 0x890, |
| 1653 |
[PIPE_FORMAT_R16G16_SINT] = 0x8f0, |
| 1654 |
[PIPE_FORMAT_R16G16_UINT] = 0x948, |
| 1655 |
[PIPE_FORMAT_R16G16_FLOAT] = 0x998, |
| 1656 |
[PIPE_FORMAT_R32_FLOAT] = 0x9e8, |
| 1657 |
[PIPE_FORMAT_R32_SINT] = 0xa30, |
| 1658 |
[PIPE_FORMAT_R32_UINT] = 0xa30, |
| 1659 |
[PIPE_FORMAT_R8G8_UNORM] = 0xa78, |
| 1660 |
[PIPE_FORMAT_R8G8_SNORM] = 0xae0, |
| 1661 |
[PIPE_FORMAT_R8G8_UINT] = 0xb48, |
| 1662 |
[PIPE_FORMAT_R8G8_SINT] = 0xb98, |
| 1663 |
[PIPE_FORMAT_R16_UNORM] = 0xbe8, |
| 1664 |
[PIPE_FORMAT_R16_SNORM] = 0xc48, |
| 1665 |
[PIPE_FORMAT_R16_SINT] = 0xca0, |
| 1666 |
[PIPE_FORMAT_R16_UINT] = 0xce8, |
| 1667 |
[PIPE_FORMAT_R16_FLOAT] = 0xd30, |
| 1668 |
[PIPE_FORMAT_R8_UNORM] = 0xd88, |
| 1669 |
[PIPE_FORMAT_R8_SNORM] = 0xde0, |
| 1670 |
[PIPE_FORMAT_R8_SINT] = 0xe38, |
| 1671 |
[PIPE_FORMAT_R8_UINT] = 0xe88, |
| 1672 |
[PIPE_FORMAT_R11G11B10_FLOAT] = 0xed0 |
| 1673 |
}; |