| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
#include <llvm/Config/llvm-config.h> |
| 38 |
|
| 39 |
#include "util/format/u_format.h" |
| 40 |
#include "util/u_math.h" |
| 41 |
#include "util/u_cpu_detect.h" |
| 42 |
|
| 43 |
#include "lp_bld_arit.h" |
| 44 |
#include "lp_bld_type.h" |
| 45 |
#include "lp_bld_const.h" |
| 46 |
#include "lp_bld_conv.h" |
| 47 |
#include "lp_bld_gather.h" |
| 48 |
#include "lp_bld_format.h" |
| 49 |
#include "lp_bld_logic.h" |
| 50 |
#include "lp_bld_pack.h" |
| 51 |
#include "lp_bld_flow.h" |
| 52 |
#include "lp_bld_swizzle.h" |
| 53 |
#include "lp_bld_init.h" |
| 54 |
#include "lp_bld_debug.h" |
| 55 |
#include "lp_bld_intr.h" |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
static LLVMValueRef |
| 71 |
lp_build_uninterleave2_half(struct gallivm_state *gallivm, |
| 72 |
struct lp_type type, |
| 73 |
LLVMValueRef a, |
| 74 |
LLVMValueRef b, |
| 75 |
unsigned lo_hi) |
| 76 |
{ |
| 77 |
LLVMValueRef shuffle, elems[LP_MAX_VECTOR_LENGTH]; |
| 78 |
unsigned i; |
| 79 |
|
| 80 |
assert(type.length <= LP_MAX_VECTOR_LENGTH); |
| 81 |
assert(lo_hi < 2); |
| 82 |
|
| 83 |
if (type.length * type.width == 256) { |
| 84 |
assert(type.length == 8); |
| 85 |
assert(type.width == 32); |
| 86 |
static const unsigned shufvals[8] = {0, 2, 8, 10, 4, 6, 12, 14}; |
| 87 |
for (i = 0; i < type.length; ++i) { |
| 88 |
elems[i] = lp_build_const_int32(gallivm, shufvals[i] + lo_hi); |
| 89 |
} |
| 90 |
} else { |
| 91 |
for (i = 0; i < type.length; ++i) { |
| 92 |
elems[i] = lp_build_const_int32(gallivm, 2*i + lo_hi); |
| 93 |
} |
| 94 |
} |
| 95 |
|
| 96 |
shuffle = LLVMConstVector(elems, type.length); |
| 97 |
|
| 98 |
return LLVMBuildShuffleVector(gallivm->builder, a, b, shuffle, ""); |
| 99 |
|
| 100 |
} |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
static LLVMValueRef |
| 107 |
lp_build_const_extend_shuffle(struct gallivm_state *gallivm, |
| 108 |
unsigned n, unsigned length) |
| 109 |
{ |
| 110 |
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH]; |
| 111 |
unsigned i; |
| 112 |
|
| 113 |
assert(n <= length); |
| 114 |
assert(length <= LP_MAX_VECTOR_LENGTH); |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
for(i = 0; i < n; i++) { |
| 119 |
elems[i] = lp_build_const_int32(gallivm, i); |
| 120 |
} |
| 121 |
for (i = n; i < length; i++) { |
| 122 |
elems[i] = LLVMGetUndef(LLVMInt32TypeInContext(gallivm->context)); |
| 123 |
} |
| 124 |
|
| 125 |
return LLVMConstVector(elems, length); |
| 126 |
} |
| 127 |
|
| 128 |
static LLVMValueRef |
| 129 |
lp_build_const_unpackx2_shuffle(struct gallivm_state *gallivm, unsigned n) |
| 130 |
{ |
| 131 |
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH]; |
| 132 |
unsigned i, j; |
| 133 |
|
| 134 |
assert(n <= LP_MAX_VECTOR_LENGTH); |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
for(i = 0, j = 0; i < n; i += 2, ++j) { |
| 139 |
elems[i + 0] = lp_build_const_int32(gallivm, 0 + j); |
| 140 |
elems[i + 1] = lp_build_const_int32(gallivm, n + j); |
| 141 |
elems[n + i + 0] = lp_build_const_int32(gallivm, 0 + n/2 + j); |
| 142 |
elems[n + i + 1] = lp_build_const_int32(gallivm, n + n/2 + j); |
| 143 |
} |
| 144 |
|
| 145 |
return LLVMConstVector(elems, n * 2); |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
static LLVMValueRef |
| 152 |
lp_build_const_shuffle1(struct gallivm_state *gallivm, |
| 153 |
unsigned index, unsigned n) |
| 154 |
{ |
| 155 |
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH]; |
| 156 |
unsigned i; |
| 157 |
|
| 158 |
assert(n <= LP_MAX_VECTOR_LENGTH); |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
for (i = 0; i < n; i++) { |
| 163 |
elems[i] = lp_build_const_int32(gallivm, index); |
| 164 |
} |
| 165 |
|
| 166 |
return LLVMConstVector(elems, n); |
| 167 |
} |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
static LLVMValueRef |
| 173 |
lp_build_shuffle1undef(struct gallivm_state *gallivm, |
| 174 |
LLVMValueRef a, unsigned index, unsigned n) |
| 175 |
{ |
| 176 |
LLVMValueRef elems[LP_MAX_VECTOR_LENGTH], shuf; |
| 177 |
unsigned i; |
| 178 |
|
| 179 |
assert(n <= LP_MAX_VECTOR_LENGTH); |
| 180 |
|
| 181 |
elems[0] = lp_build_const_int32(gallivm, index); |
| 182 |
|
| 183 |
for (i = 1; i < n; i++) { |
| 184 |
elems[i] = LLVMGetUndef(LLVMInt32TypeInContext(gallivm->context)); |
| 185 |
} |
| 186 |
shuf = LLVMConstVector(elems, n); |
| 187 |
|
| 188 |
return LLVMBuildShuffleVector(gallivm->builder, a, a, shuf, ""); |
| 189 |
} |
| 190 |
|
| 191 |
static bool |
| 192 |
format_dxt1_variant(enum pipe_format format) |
| 193 |
{ |
| 194 |
return format == PIPE_FORMAT_DXT1_RGB || |
| 195 |
format == PIPE_FORMAT_DXT1_RGBA || |
| 196 |
format == PIPE_FORMAT_DXT1_SRGB || |
| 197 |
format == PIPE_FORMAT_DXT1_SRGBA; |
| 198 |
|
| 199 |
} |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
static void |
| 215 |
lp_build_gather_s3tc(struct gallivm_state *gallivm, |
| 216 |
unsigned length, |
| 217 |
const struct util_format_description *format_desc, |
| 218 |
LLVMValueRef *colors, |
| 219 |
LLVMValueRef *codewords, |
| 220 |
LLVMValueRef *alpha_lo, |
| 221 |
LLVMValueRef *alpha_hi, |
| 222 |
LLVMValueRef base_ptr, |
| 223 |
LLVMValueRef offsets) |
| 224 |
{ |
| 225 |
LLVMBuilderRef builder = gallivm->builder; |
| 226 |
unsigned block_bits = format_desc->block.bits; |
| 227 |
unsigned i; |
| 228 |
LLVMValueRef elems[8]; |
| 229 |
LLVMTypeRef type32 = LLVMInt32TypeInContext(gallivm->context); |
| 230 |
LLVMTypeRef type64 = LLVMInt64TypeInContext(gallivm->context); |
| 231 |
LLVMTypeRef type32dxt; |
| 232 |
struct lp_type lp_type32dxt; |
| 233 |
|
| 234 |
memset(&lp_type32dxt, 0, sizeof lp_type32dxt); |
| 235 |
lp_type32dxt.width = 32; |
| 236 |
lp_type32dxt.length = block_bits / 32; |
| 237 |
type32dxt = lp_build_vec_type(gallivm, lp_type32dxt); |
| 238 |
|
| 239 |
assert(block_bits == 64 || block_bits == 128); |
| 240 |
assert(length == 1 || length == 4 || length == 8); |
| 241 |
|
| 242 |
for (i = 0; i < length; ++i) { |
| 243 |
elems[i] = lp_build_gather_elem(gallivm, length, |
| 244 |
block_bits, block_bits, true, |
| 245 |
base_ptr, offsets, i, false); |
| 246 |
elems[i] = LLVMBuildBitCast(builder, elems[i], type32dxt, ""); |
| 247 |
} |
| 248 |
if (length == 1) { |
| 249 |
LLVMValueRef elem = elems[0]; |
| 250 |
if (block_bits == 128) { |
| 251 |
*alpha_lo = LLVMBuildExtractElement(builder, elem, |
| 252 |
lp_build_const_int32(gallivm, 0), ""); |
| 253 |
*alpha_hi = LLVMBuildExtractElement(builder, elem, |
| 254 |
lp_build_const_int32(gallivm, 1), ""); |
| 255 |
*colors = LLVMBuildExtractElement(builder, elem, |
| 256 |
lp_build_const_int32(gallivm, 2), ""); |
| 257 |
*codewords = LLVMBuildExtractElement(builder, elem, |
| 258 |
lp_build_const_int32(gallivm, 3), ""); |
| 259 |
} |
| 260 |
else { |
| 261 |
*alpha_lo = LLVMGetUndef(type32); |
| 262 |
*alpha_hi = LLVMGetUndef(type32); |
| 263 |
*colors = LLVMBuildExtractElement(builder, elem, |
| 264 |
lp_build_const_int32(gallivm, 0), ""); |
| 265 |
*codewords = LLVMBuildExtractElement(builder, elem, |
| 266 |
lp_build_const_int32(gallivm, 1), ""); |
| 267 |
} |
| 268 |
} |
| 269 |
else { |
| 270 |
LLVMValueRef tmp[4], cc01, cc23; |
| 271 |
struct lp_type lp_type32, lp_type64; |
| 272 |
memset(&lp_type32, 0, sizeof lp_type32); |
| 273 |
lp_type32.width = 32; |
| 274 |
lp_type32.length = length; |
| 275 |
memset(&lp_type64, 0, sizeof lp_type64); |
| 276 |
lp_type64.width = 64; |
| 277 |
lp_type64.length = length/2; |
| 278 |
|
| 279 |
if (block_bits == 128) { |
| 280 |
if (length == 8) { |
| 281 |
for (i = 0; i < 4; ++i) { |
| 282 |
tmp[0] = elems[i]; |
| 283 |
tmp[1] = elems[i+4]; |
| 284 |
elems[i] = lp_build_concat(gallivm, tmp, lp_type32dxt, 2); |
| 285 |
} |
| 286 |
} |
| 287 |
lp_build_transpose_aos(gallivm, lp_type32, elems, tmp); |
| 288 |
*colors = tmp[2]; |
| 289 |
*codewords = tmp[3]; |
| 290 |
*alpha_lo = tmp[0]; |
| 291 |
*alpha_hi = tmp[1]; |
| 292 |
} else { |
| 293 |
LLVMTypeRef type64_vec = LLVMVectorType(type64, length/2); |
| 294 |
LLVMTypeRef type32_vec = LLVMVectorType(type32, length); |
| 295 |
|
| 296 |
for (i = 0; i < length; ++i) { |
| 297 |
|
| 298 |
elems[i] = LLVMBuildShuffleVector(builder, elems[i], |
| 299 |
LLVMGetUndef(type32dxt), |
| 300 |
lp_build_const_extend_shuffle(gallivm, 2, 4), ""); |
| 301 |
} |
| 302 |
if (length == 8) { |
| 303 |
struct lp_type lp_type32_4 = {0}; |
| 304 |
lp_type32_4.width = 32; |
| 305 |
lp_type32_4.length = 4; |
| 306 |
for (i = 0; i < 4; ++i) { |
| 307 |
tmp[0] = elems[i]; |
| 308 |
tmp[1] = elems[i+4]; |
| 309 |
elems[i] = lp_build_concat(gallivm, tmp, lp_type32_4, 2); |
| 310 |
} |
| 311 |
} |
| 312 |
cc01 = lp_build_interleave2_half(gallivm, lp_type32, elems[0], elems[1], 0); |
| 313 |
cc23 = lp_build_interleave2_half(gallivm, lp_type32, elems[2], elems[3], 0); |
| 314 |
cc01 = LLVMBuildBitCast(builder, cc01, type64_vec, ""); |
| 315 |
cc23 = LLVMBuildBitCast(builder, cc23, type64_vec, ""); |
| 316 |
*colors = lp_build_interleave2_half(gallivm, lp_type64, cc01, cc23, 0); |
| 317 |
*codewords = lp_build_interleave2_half(gallivm, lp_type64, cc01, cc23, 1); |
| 318 |
*colors = LLVMBuildBitCast(builder, *colors, type32_vec, ""); |
| 319 |
*codewords = LLVMBuildBitCast(builder, *codewords, type32_vec, ""); |
| 320 |
} |
| 321 |
} |
| 322 |
} |
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
static void |
| 332 |
color_expand2_565_to_8888(struct gallivm_state *gallivm, |
| 333 |
unsigned n, |
| 334 |
LLVMValueRef colors, |
| 335 |
LLVMValueRef *color0, |
| 336 |
LLVMValueRef *color1) |
| 337 |
{ |
| 338 |
LLVMBuilderRef builder = gallivm->builder; |
| 339 |
LLVMValueRef r, g, b, rblo, glo; |
| 340 |
LLVMValueRef rgblomask, rb, rgb0, rgb1; |
| 341 |
struct lp_type type, type16, type8; |
| 342 |
|
| 343 |
assert(n > 1); |
| 344 |
|
| 345 |
memset(&type, 0, sizeof type); |
| 346 |
type.width = 32; |
| 347 |
type.length = n; |
| 348 |
|
| 349 |
memset(&type16, 0, sizeof type16); |
| 350 |
type16.width = 16; |
| 351 |
type16.length = 2 * n; |
| 352 |
|
| 353 |
memset(&type8, 0, sizeof type8); |
| 354 |
type8.width = 8; |
| 355 |
type8.length = 4 * n; |
| 356 |
|
| 357 |
rgblomask = lp_build_const_int_vec(gallivm, type16, 0x0707); |
| 358 |
colors = LLVMBuildBitCast(builder, colors, |
| 359 |
lp_build_vec_type(gallivm, type16), ""); |
| 360 |
|
| 361 |
|
| 362 |
r = LLVMBuildLShr(builder, colors, lp_build_const_int_vec(gallivm, type16, 11), ""); |
| 363 |
r = LLVMBuildShl(builder, r, lp_build_const_int_vec(gallivm, type16, 3), ""); |
| 364 |
b = LLVMBuildShl(builder, colors, lp_build_const_int_vec(gallivm, type16, 11), ""); |
| 365 |
rb = LLVMBuildOr(builder, r, b, ""); |
| 366 |
rblo = LLVMBuildLShr(builder, rb, lp_build_const_int_vec(gallivm, type16, 5), ""); |
| 367 |
|
| 368 |
rblo = LLVMBuildAnd(builder, rblo, rgblomask, ""); |
| 369 |
rb = LLVMBuildOr(builder, rb, rblo, ""); |
| 370 |
|
| 371 |
|
| 372 |
g = LLVMBuildAnd(builder, colors, lp_build_const_int_vec(gallivm, type16, 0x07e0), ""); |
| 373 |
g = LLVMBuildLShr(builder, g, lp_build_const_int_vec(gallivm, type16, 3), ""); |
| 374 |
glo = LLVMBuildLShr(builder, g, lp_build_const_int_vec(gallivm, type16, 6), ""); |
| 375 |
g = LLVMBuildOr(builder, g, glo, ""); |
| 376 |
|
| 377 |
rb = LLVMBuildBitCast(builder, rb, lp_build_vec_type(gallivm, type8), ""); |
| 378 |
g = LLVMBuildBitCast(builder, g, lp_build_vec_type(gallivm, type8), ""); |
| 379 |
rgb0 = lp_build_interleave2_half(gallivm, type8, rb, g, 0); |
| 380 |
rgb1 = lp_build_interleave2_half(gallivm, type8, rb, g, 1); |
| 381 |
|
| 382 |
rgb0 = LLVMBuildBitCast(builder, rgb0, lp_build_vec_type(gallivm, type), ""); |
| 383 |
rgb1 = LLVMBuildBitCast(builder, rgb1, lp_build_vec_type(gallivm, type), ""); |
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
*color0 = lp_build_uninterleave2_half(gallivm, type, rgb0, rgb1, 0); |
| 390 |
*color1 = lp_build_uninterleave2_half(gallivm, type, rgb0, rgb1, 1); |
| 391 |
} |
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
static LLVMValueRef |
| 401 |
color_expand_565_to_8888(struct gallivm_state *gallivm, |
| 402 |
unsigned n, |
| 403 |
LLVMValueRef colors) |
| 404 |
{ |
| 405 |
LLVMBuilderRef builder = gallivm->builder; |
| 406 |
LLVMValueRef rgba, r, g, b, rgblo, glo; |
| 407 |
LLVMValueRef rbhimask, g6mask, rgblomask; |
| 408 |
struct lp_type type; |
| 409 |
memset(&type, 0, sizeof type); |
| 410 |
type.width = 32; |
| 411 |
type.length = n; |
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
g6mask = lp_build_const_int_vec(gallivm, type, 0x07e0); |
| 434 |
rbhimask = lp_build_const_int_vec(gallivm, type, 0x00f800f8); |
| 435 |
rgblomask = lp_build_const_int_vec(gallivm, type, 0x00070307); |
| 436 |
|
| 437 |
r = LLVMBuildLShr(builder, colors, lp_build_const_int_vec(gallivm, type, 8), ""); |
| 438 |
b = LLVMBuildShl(builder, colors, lp_build_const_int_vec(gallivm, type, 19), ""); |
| 439 |
g = LLVMBuildAnd(builder, colors, g6mask, ""); |
| 440 |
g = LLVMBuildShl(builder, g, lp_build_const_int_vec(gallivm, type, 5), ""); |
| 441 |
rgba = LLVMBuildOr(builder, r, b, ""); |
| 442 |
rgba = LLVMBuildAnd(builder, rgba, rbhimask, ""); |
| 443 |
rgblo = LLVMBuildLShr(builder, rgba, lp_build_const_int_vec(gallivm, type, 5), ""); |
| 444 |
glo = LLVMBuildLShr(builder, g, lp_build_const_int_vec(gallivm, type, 6), ""); |
| 445 |
rgblo = LLVMBuildOr(builder, rgblo, glo, ""); |
| 446 |
rgblo = LLVMBuildAnd(builder, rgblo, rgblomask, ""); |
| 447 |
rgba = LLVMBuildOr(builder, rgba, g, ""); |
| 448 |
rgba = LLVMBuildOr(builder, rgba, rgblo, ""); |
| 449 |
|
| 450 |
return rgba; |
| 451 |
} |
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
static LLVMValueRef |
| 458 |
lp_build_pavgb(struct lp_build_context *bld8, |
| 459 |
LLVMValueRef v0, |
| 460 |
LLVMValueRef v1) |
| 461 |
{ |
| 462 |
struct gallivm_state *gallivm = bld8->gallivm; |
| 463 |
LLVMBuilderRef builder = gallivm->builder; |
| 464 |
assert(bld8->type.width == 8); |
| 465 |
assert(bld8->type.length == 16 || bld8->type.length == 32); |
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
struct lp_type type_ext = bld8->type; |
| 473 |
LLVMTypeRef vec_type_ext; |
| 474 |
LLVMValueRef res; |
| 475 |
LLVMValueRef ext_one; |
| 476 |
type_ext.width = 16; |
| 477 |
vec_type_ext = lp_build_vec_type(gallivm, type_ext); |
| 478 |
ext_one = lp_build_const_vec(gallivm, type_ext, 1); |
| 479 |
|
| 480 |
v0 = LLVMBuildZExt(builder, v0, vec_type_ext, ""); |
| 481 |
v1 = LLVMBuildZExt(builder, v1, vec_type_ext, ""); |
| 482 |
res = LLVMBuildAdd(builder, v0, v1, ""); |
| 483 |
res = LLVMBuildAdd(builder, res, ext_one, ""); |
| 484 |
res = LLVMBuildLShr(builder, res, ext_one, ""); |
| 485 |
res = LLVMBuildTrunc(builder, res, bld8->vec_type, ""); |
| 486 |
return res; |
| 487 |
} |
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
static void |
| 494 |
lp_build_lerp23(struct lp_build_context *bld, |
| 495 |
LLVMValueRef v0, |
| 496 |
LLVMValueRef v1, |
| 497 |
LLVMValueRef *res0, |
| 498 |
LLVMValueRef *res1) |
| 499 |
{ |
| 500 |
struct gallivm_state *gallivm = bld->gallivm; |
| 501 |
LLVMValueRef x, x_lo, x_hi, delta_lo, delta_hi; |
| 502 |
LLVMValueRef mul_lo, mul_hi, v0_lo, v0_hi, v1_lo, v1_hi, tmp; |
| 503 |
const struct lp_type type = bld->type; |
| 504 |
LLVMBuilderRef builder = bld->gallivm->builder; |
| 505 |
struct lp_type i16_type = lp_wider_type(type); |
| 506 |
struct lp_build_context bld2; |
| 507 |
|
| 508 |
assert(lp_check_value(type, v0)); |
| 509 |
assert(lp_check_value(type, v1)); |
| 510 |
assert(!type.floating && !type.fixed && !type.norm && type.width == 8); |
| 511 |
|
| 512 |
lp_build_context_init(&bld2, gallivm, i16_type); |
| 513 |
bld2.type.sign = true; |
| 514 |
x = lp_build_const_int_vec(gallivm, bld->type, 255*1/3); |
| 515 |
|
| 516 |
|
| 517 |
lp_build_unpack2(gallivm, type, i16_type, x, &x_lo, &x_hi); |
| 518 |
lp_build_unpack2(gallivm, type, i16_type, v0, &v0_lo, &v0_hi); |
| 519 |
lp_build_unpack2(gallivm, type, i16_type, v1, &v1_lo, &v1_hi); |
| 520 |
delta_lo = lp_build_sub(&bld2, v1_lo, v0_lo); |
| 521 |
delta_hi = lp_build_sub(&bld2, v1_hi, v0_hi); |
| 522 |
|
| 523 |
mul_lo = LLVMBuildMul(builder, x_lo, delta_lo, ""); |
| 524 |
mul_hi = LLVMBuildMul(builder, x_hi, delta_hi, ""); |
| 525 |
|
| 526 |
x_lo = LLVMBuildLShr(builder, mul_lo, lp_build_const_int_vec(gallivm, i16_type, 8), ""); |
| 527 |
x_hi = LLVMBuildLShr(builder, mul_hi, lp_build_const_int_vec(gallivm, i16_type, 8), ""); |
| 528 |
|
| 529 |
tmp = lp_build_pack2(gallivm, i16_type, type, x_lo, x_hi); |
| 530 |
*res0 = lp_build_add(bld, tmp, v0); |
| 531 |
|
| 532 |
x_lo = LLVMBuildLShr(builder, mul_lo, lp_build_const_int_vec(gallivm, i16_type, 7), ""); |
| 533 |
x_hi = LLVMBuildLShr(builder, mul_hi, lp_build_const_int_vec(gallivm, i16_type, 7), ""); |
| 534 |
|
| 535 |
x_lo = LLVMBuildAnd(builder, x_lo, lp_build_const_int_vec(gallivm, i16_type, 0xff), ""); |
| 536 |
x_hi = LLVMBuildAnd(builder, x_hi, lp_build_const_int_vec(gallivm, i16_type, 0xff), ""); |
| 537 |
tmp = lp_build_pack2(gallivm, i16_type, type, x_lo, x_hi); |
| 538 |
*res1 = lp_build_add(bld, tmp, v0); |
| 539 |
} |
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
static LLVMValueRef |
| 549 |
s3tc_dxt1_full_to_rgba_aos(struct gallivm_state *gallivm, |
| 550 |
unsigned n, |
| 551 |
enum pipe_format format, |
| 552 |
LLVMValueRef colors, |
| 553 |
LLVMValueRef codewords, |
| 554 |
LLVMValueRef i, |
| 555 |
LLVMValueRef j) |
| 556 |
{ |
| 557 |
LLVMBuilderRef builder = gallivm->builder; |
| 558 |
LLVMValueRef color0, color1, color2, color3, color2_2, color3_2; |
| 559 |
LLVMValueRef rgba, a, colors0, colors1, col0, col1, const2; |
| 560 |
LLVMValueRef bit_pos, sel_mask, sel_lo, sel_hi, indices; |
| 561 |
struct lp_type type, type8; |
| 562 |
struct lp_build_context bld8, bld32; |
| 563 |
bool is_dxt1_variant = format_dxt1_variant(format); |
| 564 |
|
| 565 |
memset(&type, 0, sizeof type); |
| 566 |
type.width = 32; |
| 567 |
type.length = n; |
| 568 |
|
| 569 |
memset(&type8, 0, sizeof type8); |
| 570 |
type8.width = 8; |
| 571 |
type8.length = 4*n; |
| 572 |
|
| 573 |
assert(lp_check_value(type, i)); |
| 574 |
assert(lp_check_value(type, j)); |
| 575 |
|
| 576 |
a = lp_build_const_int_vec(gallivm, type, 0xff000000); |
| 577 |
|
| 578 |
lp_build_context_init(&bld32, gallivm, type); |
| 579 |
lp_build_context_init(&bld8, gallivm, type8); |
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
col0 = LLVMBuildAnd(builder, colors, lp_build_const_int_vec(gallivm, type, 0x0000ffff), ""); |
| 595 |
col1 = LLVMBuildLShr(builder, colors, lp_build_const_int_vec(gallivm, type, 16), ""); |
| 596 |
if (n > 1) { |
| 597 |
color_expand2_565_to_8888(gallivm, n, colors, &color0, &color1); |
| 598 |
} |
| 599 |
else { |
| 600 |
color0 = color_expand_565_to_8888(gallivm, n, col0); |
| 601 |
color1 = color_expand_565_to_8888(gallivm, n, col1); |
| 602 |
} |
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
colors0 = LLVMBuildBitCast(builder, color0, bld8.vec_type, ""); |
| 613 |
colors1 = LLVMBuildBitCast(builder, color1, bld8.vec_type, ""); |
| 614 |
|
| 615 |
lp_build_lerp23(&bld8, colors0, colors1, &color2, &color3); |
| 616 |
color2 = LLVMBuildBitCast(builder, color2, bld32.vec_type, ""); |
| 617 |
color3 = LLVMBuildBitCast(builder, color3, bld32.vec_type, ""); |
| 618 |
|
| 619 |
|
| 620 |
if (is_dxt1_variant) { |
| 621 |
|
| 622 |
if (format == PIPE_FORMAT_DXT1_RGBA || |
| 623 |
format == PIPE_FORMAT_DXT1_SRGBA) { |
| 624 |
color0 = LLVMBuildOr(builder, color0, a, ""); |
| 625 |
color1 = LLVMBuildOr(builder, color1, a, ""); |
| 626 |
color3 = LLVMBuildOr(builder, color3, a, ""); |
| 627 |
} |
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
if ((util_get_cpu_caps()->has_sse2 && n == 4) || |
| 633 |
(util_get_cpu_caps()->has_avx2 && n == 8)) { |
| 634 |
color2_2 = lp_build_pavgb(&bld8, colors0, colors1); |
| 635 |
color2_2 = LLVMBuildBitCast(builder, color2_2, bld32.vec_type, ""); |
| 636 |
} |
| 637 |
else { |
| 638 |
struct lp_type i16_type = lp_wider_type(type8); |
| 639 |
struct lp_build_context bld2; |
| 640 |
LLVMValueRef v0_lo, v0_hi, v1_lo, v1_hi, addlo, addhi; |
| 641 |
|
| 642 |
lp_build_context_init(&bld2, gallivm, i16_type); |
| 643 |
bld2.type.sign = true; |
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
lp_build_unpack2(gallivm, type8, i16_type, colors0, &v0_lo, &v0_hi); |
| 653 |
lp_build_unpack2(gallivm, type8, i16_type, colors1, &v1_lo, &v1_hi); |
| 654 |
|
| 655 |
addlo = lp_build_add(&bld2, v0_lo, v1_lo); |
| 656 |
addhi = lp_build_add(&bld2, v0_hi, v1_hi); |
| 657 |
addlo = LLVMBuildLShr(builder, addlo, |
| 658 |
lp_build_const_int_vec(gallivm, i16_type, 1), ""); |
| 659 |
addhi = LLVMBuildLShr(builder, addhi, |
| 660 |
lp_build_const_int_vec(gallivm, i16_type, 1), ""); |
| 661 |
color2_2 = lp_build_pack2(gallivm, i16_type, type8, addlo, addhi); |
| 662 |
color2_2 = LLVMBuildBitCast(builder, color2_2, bld32.vec_type, ""); |
| 663 |
} |
| 664 |
color3_2 = lp_build_const_int_vec(gallivm, type, 0); |
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
type.sign = true; |
| 669 |
sel_mask = lp_build_compare(gallivm, type, PIPE_FUNC_GREATER, col0, col1); |
| 670 |
color2 = lp_build_select(&bld32, sel_mask, color2, color2_2); |
| 671 |
color3 = lp_build_select(&bld32, sel_mask, color3, color3_2); |
| 672 |
type.sign = false; |
| 673 |
|
| 674 |
if (format == PIPE_FORMAT_DXT1_RGBA || |
| 675 |
format == PIPE_FORMAT_DXT1_SRGBA) { |
| 676 |
color2 = LLVMBuildOr(builder, color2, a, ""); |
| 677 |
} |
| 678 |
} |
| 679 |
|
| 680 |
const2 = lp_build_const_int_vec(gallivm, type, 2); |
| 681 |
|
| 682 |
bit_pos = LLVMBuildShl(builder, j, const2, ""); |
| 683 |
bit_pos = LLVMBuildAdd(builder, bit_pos, i, ""); |
| 684 |
bit_pos = LLVMBuildAdd(builder, bit_pos, bit_pos, ""); |
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
indices = LLVMBuildLShr(builder, codewords, bit_pos, ""); |
| 703 |
|
| 704 |
|
| 705 |
sel_lo = LLVMBuildAnd(builder, indices, bld32.one, ""); |
| 706 |
sel_lo = lp_build_compare(gallivm, type, PIPE_FUNC_EQUAL, sel_lo, bld32.one); |
| 707 |
color0 = lp_build_select(&bld32, sel_lo, color1, color0); |
| 708 |
color2 = lp_build_select(&bld32, sel_lo, color3, color2); |
| 709 |
sel_hi = LLVMBuildAnd(builder, indices, const2, ""); |
| 710 |
sel_hi = lp_build_compare(gallivm, type, PIPE_FUNC_EQUAL, sel_hi, const2); |
| 711 |
rgba = lp_build_select(&bld32, sel_hi, color2, color0); |
| 712 |
|
| 713 |
|
| 714 |
if (format == PIPE_FORMAT_DXT1_RGB || |
| 715 |
format == PIPE_FORMAT_DXT1_SRGB) { |
| 716 |
rgba = LLVMBuildOr(builder, rgba, a, ""); |
| 717 |
} |
| 718 |
return LLVMBuildBitCast(builder, rgba, bld8.vec_type, ""); |
| 719 |
} |
| 720 |
|
| 721 |
|
| 722 |
static LLVMValueRef |
| 723 |
s3tc_dxt1_to_rgba_aos(struct gallivm_state *gallivm, |
| 724 |
unsigned n, |
| 725 |
enum pipe_format format, |
| 726 |
LLVMValueRef colors, |
| 727 |
LLVMValueRef codewords, |
| 728 |
LLVMValueRef i, |
| 729 |
LLVMValueRef j) |
| 730 |
{ |
| 731 |
return s3tc_dxt1_full_to_rgba_aos(gallivm, n, format, |
| 732 |
colors, codewords, i, j); |
| 733 |
} |
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
static LLVMValueRef |
| 745 |
s3tc_dxt3_to_rgba_aos(struct gallivm_state *gallivm, |
| 746 |
unsigned n, |
| 747 |
enum pipe_format format, |
| 748 |
LLVMValueRef colors, |
| 749 |
LLVMValueRef codewords, |
| 750 |
LLVMValueRef alpha_low, |
| 751 |
LLVMValueRef alpha_hi, |
| 752 |
LLVMValueRef i, |
| 753 |
LLVMValueRef j) |
| 754 |
{ |
| 755 |
LLVMBuilderRef builder = gallivm->builder; |
| 756 |
LLVMValueRef rgba, tmp, tmp2; |
| 757 |
LLVMValueRef bit_pos, sel_mask; |
| 758 |
struct lp_type type, type8; |
| 759 |
struct lp_build_context bld; |
| 760 |
|
| 761 |
memset(&type, 0, sizeof type); |
| 762 |
type.width = 32; |
| 763 |
type.length = n; |
| 764 |
|
| 765 |
memset(&type8, 0, sizeof type8); |
| 766 |
type8.width = 8; |
| 767 |
type8.length = n*4; |
| 768 |
|
| 769 |
assert(lp_check_value(type, i)); |
| 770 |
assert(lp_check_value(type, j)); |
| 771 |
|
| 772 |
lp_build_context_init(&bld, gallivm, type); |
| 773 |
|
| 774 |
rgba = s3tc_dxt1_to_rgba_aos(gallivm, n, format, |
| 775 |
colors, codewords, i, j); |
| 776 |
|
| 777 |
rgba = LLVMBuildBitCast(builder, rgba, bld.vec_type, ""); |
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
bit_pos = LLVMBuildShl(builder, j, lp_build_const_int_vec(gallivm, type, 2), ""); |
| 790 |
bit_pos = LLVMBuildAdd(builder, bit_pos, i, ""); |
| 791 |
bit_pos = LLVMBuildShl(builder, bit_pos, |
| 792 |
lp_build_const_int_vec(gallivm, type, 2), ""); |
| 793 |
sel_mask = LLVMBuildLShr(builder, bit_pos, |
| 794 |
lp_build_const_int_vec(gallivm, type, 5), ""); |
| 795 |
sel_mask = LLVMBuildSub(builder, sel_mask, bld.one, ""); |
| 796 |
tmp = lp_build_select(&bld, sel_mask, alpha_low, alpha_hi); |
| 797 |
bit_pos = LLVMBuildAnd(builder, bit_pos, |
| 798 |
lp_build_const_int_vec(gallivm, type, 0xffffffdf), ""); |
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
tmp = LLVMBuildLShr(builder, tmp, bit_pos, ""); |
| 806 |
|
| 807 |
|
| 808 |
tmp = LLVMBuildShl(builder, tmp, lp_build_const_int_vec(gallivm, type, 28), ""); |
| 809 |
tmp2 = LLVMBuildLShr(builder, tmp, lp_build_const_int_vec(gallivm, type, 4), ""); |
| 810 |
tmp = LLVMBuildOr(builder, tmp, tmp2, ""); |
| 811 |
|
| 812 |
rgba = LLVMBuildOr(builder, tmp, rgba, ""); |
| 813 |
|
| 814 |
return LLVMBuildBitCast(builder, rgba, lp_build_vec_type(gallivm, type8), ""); |
| 815 |
} |
| 816 |
|
| 817 |
static LLVMValueRef |
| 818 |
lp_build_lerpdxta(struct gallivm_state *gallivm, |
| 819 |
LLVMValueRef alpha0, |
| 820 |
LLVMValueRef alpha1, |
| 821 |
LLVMValueRef code, |
| 822 |
LLVMValueRef sel_mask, |
| 823 |
unsigned n) |
| 824 |
{ |
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
LLVMBuilderRef builder = gallivm->builder; |
| 832 |
LLVMValueRef delta, ainterp; |
| 833 |
LLVMValueRef weight5, weight7, weight; |
| 834 |
struct lp_type type32, type16, type8; |
| 835 |
struct lp_build_context bld16; |
| 836 |
|
| 837 |
memset(&type32, 0, sizeof type32); |
| 838 |
type32.width = 32; |
| 839 |
type32.length = n; |
| 840 |
memset(&type16, 0, sizeof type16); |
| 841 |
type16.width = 16; |
| 842 |
type16.length = 2*n; |
| 843 |
type16.sign = true; |
| 844 |
memset(&type8, 0, sizeof type8); |
| 845 |
type8.width = 8; |
| 846 |
type8.length = 4*n; |
| 847 |
|
| 848 |
lp_build_context_init(&bld16, gallivm, type16); |
| 849 |
|
| 850 |
sel_mask = LLVMBuildBitCast(builder, sel_mask, bld16.vec_type, ""); |
| 851 |
weight5 = lp_build_const_int_vec(gallivm, type16, 255*64/5); |
| 852 |
weight7 = lp_build_const_int_vec(gallivm, type16, 255*64/7); |
| 853 |
weight = lp_build_select(&bld16, sel_mask, weight7, weight5); |
| 854 |
|
| 855 |
alpha0 = LLVMBuildBitCast(builder, alpha0, bld16.vec_type, ""); |
| 856 |
alpha1 = LLVMBuildBitCast(builder, alpha1, bld16.vec_type, ""); |
| 857 |
code = LLVMBuildBitCast(builder, code, bld16.vec_type, ""); |
| 858 |
|
| 859 |
|
| 860 |
code = LLVMBuildSub(builder, code, bld16.one, ""); |
| 861 |
|
| 862 |
weight = LLVMBuildMul(builder, weight, code, ""); |
| 863 |
weight = LLVMBuildLShr(builder, weight, |
| 864 |
lp_build_const_int_vec(gallivm, type16, 6), ""); |
| 865 |
|
| 866 |
delta = LLVMBuildSub(builder, alpha1, alpha0, ""); |
| 867 |
|
| 868 |
ainterp = LLVMBuildMul(builder, delta, weight, ""); |
| 869 |
ainterp = LLVMBuildLShr(builder, ainterp, |
| 870 |
lp_build_const_int_vec(gallivm, type16, 8), ""); |
| 871 |
|
| 872 |
ainterp = LLVMBuildBitCast(builder, ainterp, lp_build_vec_type(gallivm, type8), ""); |
| 873 |
alpha0 = LLVMBuildBitCast(builder, alpha0, lp_build_vec_type(gallivm, type8), ""); |
| 874 |
ainterp = LLVMBuildAdd(builder, alpha0, ainterp, ""); |
| 875 |
ainterp = LLVMBuildBitCast(builder, ainterp, lp_build_vec_type(gallivm, type32), ""); |
| 876 |
|
| 877 |
return ainterp; |
| 878 |
} |
| 879 |
|
| 880 |
static LLVMValueRef |
| 881 |
s3tc_dxt5_alpha_channel(struct gallivm_state *gallivm, |
| 882 |
bool is_signed, |
| 883 |
unsigned n, |
| 884 |
LLVMValueRef alpha_hi, LLVMValueRef alpha_lo, |
| 885 |
LLVMValueRef i, LLVMValueRef j) |
| 886 |
{ |
| 887 |
LLVMBuilderRef builder = gallivm->builder; |
| 888 |
struct lp_type type, type8; |
| 889 |
LLVMValueRef tmp, alpha0, alpha1, alphac, alphac0, bit_pos, shift; |
| 890 |
LLVMValueRef sel_mask, tmp_mask, alpha, alpha64, code_s; |
| 891 |
LLVMValueRef mask6, mask7, ainterp; |
| 892 |
LLVMTypeRef i64t = LLVMInt64TypeInContext(gallivm->context); |
| 893 |
LLVMTypeRef i32t = LLVMInt32TypeInContext(gallivm->context); |
| 894 |
struct lp_build_context bld32; |
| 895 |
|
| 896 |
memset(&type, 0, sizeof type); |
| 897 |
type.width = 32; |
| 898 |
type.length = n; |
| 899 |
|
| 900 |
memset(&type8, 0, sizeof type8); |
| 901 |
type8.width = 8; |
| 902 |
type8.length = n; |
| 903 |
type8.sign = is_signed; |
| 904 |
|
| 905 |
lp_build_context_init(&bld32, gallivm, type); |
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
alpha0 = LLVMBuildAnd(builder, alpha_lo, |
| 916 |
lp_build_const_int_vec(gallivm, type, 0xff), ""); |
| 917 |
if (is_signed) { |
| 918 |
alpha0 = LLVMBuildTrunc(builder, alpha0, lp_build_vec_type(gallivm, type8), ""); |
| 919 |
alpha0 = LLVMBuildSExt(builder, alpha0, lp_build_vec_type(gallivm, type), ""); |
| 920 |
} |
| 921 |
|
| 922 |
alpha1 = LLVMBuildLShr(builder, alpha_lo, |
| 923 |
lp_build_const_int_vec(gallivm, type, 8), ""); |
| 924 |
alpha1 = LLVMBuildAnd(builder, alpha1, |
| 925 |
lp_build_const_int_vec(gallivm, type, 0xff), ""); |
| 926 |
if (is_signed) { |
| 927 |
alpha1 = LLVMBuildTrunc(builder, alpha1, lp_build_vec_type(gallivm, type8), ""); |
| 928 |
alpha1 = LLVMBuildSExt(builder, alpha1, lp_build_vec_type(gallivm, type), ""); |
| 929 |
} |
| 930 |
|
| 931 |
|
| 932 |
bit_pos = LLVMBuildShl(builder, j, lp_build_const_int_vec(gallivm, type, 2), ""); |
| 933 |
bit_pos = LLVMBuildAdd(builder, bit_pos, i, ""); |
| 934 |
tmp = LLVMBuildAdd(builder, bit_pos, bit_pos, ""); |
| 935 |
bit_pos = LLVMBuildAdd(builder, bit_pos, tmp, ""); |
| 936 |
|
| 937 |
bit_pos = LLVMBuildAdd(builder, bit_pos, |
| 938 |
lp_build_const_int_vec(gallivm, type, 16), ""); |
| 939 |
|
| 940 |
if (n == 1) { |
| 941 |
struct lp_type type64; |
| 942 |
memset(&type64, 0, sizeof type64); |
| 943 |
type64.width = 64; |
| 944 |
type64.length = 1; |
| 945 |
|
| 946 |
|
| 947 |
alpha_lo = LLVMBuildZExt(builder, alpha_lo, i64t, ""); |
| 948 |
alpha_hi = LLVMBuildZExt(builder, alpha_hi, i64t, ""); |
| 949 |
alphac0 = LLVMBuildShl(builder, alpha_hi, |
| 950 |
lp_build_const_int_vec(gallivm, type64, 32), ""); |
| 951 |
alphac0 = LLVMBuildOr(builder, alpha_lo, alphac0, ""); |
| 952 |
|
| 953 |
shift = LLVMBuildZExt(builder, bit_pos, i64t, ""); |
| 954 |
alphac0 = LLVMBuildLShr(builder, alphac0, shift, ""); |
| 955 |
alphac0 = LLVMBuildTrunc(builder, alphac0, i32t, ""); |
| 956 |
alphac = LLVMBuildAnd(builder, alphac0, |
| 957 |
lp_build_const_int_vec(gallivm, type, 0x7), ""); |
| 958 |
} |
| 959 |
else { |
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
alpha64 = LLVMBuildShuffleVector(builder, alpha_lo, alpha_hi, |
| 969 |
lp_build_const_unpackx2_shuffle(gallivm, n), ""); |
| 970 |
|
| 971 |
alpha64 = LLVMBuildBitCast(builder, alpha64, LLVMVectorType(i64t, n), ""); |
| 972 |
shift = LLVMBuildZExt(builder, bit_pos, LLVMVectorType(i64t, n), ""); |
| 973 |
alphac = LLVMBuildLShr(builder, alpha64, shift, ""); |
| 974 |
alphac = LLVMBuildTrunc(builder, alphac, bld32.vec_type, ""); |
| 975 |
|
| 976 |
alphac = LLVMBuildAnd(builder, alphac, |
| 977 |
lp_build_const_int_vec(gallivm, type, 0x7), ""); |
| 978 |
} |
| 979 |
|
| 980 |
|
| 981 |
type.sign = true; |
| 982 |
|
| 983 |
sel_mask = lp_build_compare(gallivm, type, PIPE_FUNC_GREATER, |
| 984 |
alpha0, alpha1); |
| 985 |
ainterp = lp_build_lerpdxta(gallivm, alpha0, alpha1, alphac, sel_mask, n); |
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
tmp_mask = lp_build_compare(gallivm, type, PIPE_FUNC_EQUAL, |
| 998 |
alphac, bld32.zero); |
| 999 |
alpha = lp_build_select(&bld32, tmp_mask, alpha0, alpha1); |
| 1000 |
tmp_mask = lp_build_compare(gallivm, type, PIPE_FUNC_GREATER, |
| 1001 |
alphac, bld32.one); |
| 1002 |
alpha = lp_build_select(&bld32, tmp_mask, ainterp, alpha); |
| 1003 |
|
| 1004 |
code_s = LLVMBuildAnd(builder, alphac, |
| 1005 |
LLVMBuildNot(builder, sel_mask, ""), ""); |
| 1006 |
mask6 = lp_build_compare(gallivm, type, PIPE_FUNC_EQUAL, |
| 1007 |
code_s, lp_build_const_int_vec(gallivm, type, 6)); |
| 1008 |
mask7 = lp_build_compare(gallivm, type, PIPE_FUNC_EQUAL, |
| 1009 |
code_s, lp_build_const_int_vec(gallivm, type, 7)); |
| 1010 |
if (is_signed) { |
| 1011 |
alpha = lp_build_select(&bld32, mask6, lp_build_const_int_vec(gallivm, type, -127), alpha); |
| 1012 |
alpha = lp_build_select(&bld32, mask7, lp_build_const_int_vec(gallivm, type, 127), alpha); |
| 1013 |
} else { |
| 1014 |
alpha = LLVMBuildAnd(builder, alpha, LLVMBuildNot(builder, mask6, ""), ""); |
| 1015 |
alpha = LLVMBuildOr(builder, alpha, mask7, ""); |
| 1016 |
} |
| 1017 |
|
| 1018 |
alpha = LLVMBuildAnd(builder, alpha, lp_build_const_int_vec(gallivm, type, 0xff), ""); |
| 1019 |
|
| 1020 |
return alpha; |
| 1021 |
} |
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
|
| 1031 |
static LLVMValueRef |
| 1032 |
s3tc_dxt5_full_to_rgba_aos(struct gallivm_state *gallivm, |
| 1033 |
unsigned n, |
| 1034 |
enum pipe_format format, |
| 1035 |
LLVMValueRef colors, |
| 1036 |
LLVMValueRef codewords, |
| 1037 |
LLVMValueRef alpha_lo, |
| 1038 |
LLVMValueRef alpha_hi, |
| 1039 |
LLVMValueRef i, |
| 1040 |
LLVMValueRef j) |
| 1041 |
{ |
| 1042 |
LLVMBuilderRef builder = gallivm->builder; |
| 1043 |
LLVMValueRef rgba, alpha; |
| 1044 |
struct lp_type type, type8; |
| 1045 |
struct lp_build_context bld32; |
| 1046 |
|
| 1047 |
memset(&type, 0, sizeof type); |
| 1048 |
type.width = 32; |
| 1049 |
type.length = n; |
| 1050 |
|
| 1051 |
memset(&type8, 0, sizeof type8); |
| 1052 |
type8.width = 8; |
| 1053 |
type8.length = n*4; |
| 1054 |
|
| 1055 |
assert(lp_check_value(type, i)); |
| 1056 |
assert(lp_check_value(type, j)); |
| 1057 |
|
| 1058 |
lp_build_context_init(&bld32, gallivm, type); |
| 1059 |
|
| 1060 |
assert(lp_check_value(type, i)); |
| 1061 |
assert(lp_check_value(type, j)); |
| 1062 |
|
| 1063 |
rgba = s3tc_dxt1_to_rgba_aos(gallivm, n, format, |
| 1064 |
colors, codewords, i, j); |
| 1065 |
|
| 1066 |
rgba = LLVMBuildBitCast(builder, rgba, bld32.vec_type, ""); |
| 1067 |
|
| 1068 |
alpha = s3tc_dxt5_alpha_channel(gallivm, false, n, alpha_hi, alpha_lo, i, j); |
| 1069 |
alpha = LLVMBuildShl(builder, alpha, lp_build_const_int_vec(gallivm, type, 24), ""); |
| 1070 |
rgba = LLVMBuildOr(builder, alpha, rgba, ""); |
| 1071 |
|
| 1072 |
return LLVMBuildBitCast(builder, rgba, lp_build_vec_type(gallivm, type8), ""); |
| 1073 |
} |
| 1074 |
|
| 1075 |
|
| 1076 |
static void |
| 1077 |
lp_build_gather_s3tc_simple_scalar(struct gallivm_state *gallivm, |
| 1078 |
const struct util_format_description *format_desc, |
| 1079 |
LLVMValueRef *dxt_block, |
| 1080 |
LLVMValueRef ptr) |
| 1081 |
{ |
| 1082 |
LLVMBuilderRef builder = gallivm->builder; |
| 1083 |
unsigned block_bits = format_desc->block.bits; |
| 1084 |
LLVMValueRef elem, shuf; |
| 1085 |
LLVMTypeRef type32 = LLVMIntTypeInContext(gallivm->context, 32); |
| 1086 |
LLVMTypeRef src_type = LLVMIntTypeInContext(gallivm->context, block_bits); |
| 1087 |
LLVMTypeRef type32_4 = LLVMVectorType(type32, 4); |
| 1088 |
|
| 1089 |
assert(block_bits == 64 || block_bits == 128); |
| 1090 |
|
| 1091 |
ptr = LLVMBuildBitCast(builder, ptr, LLVMPointerType(src_type, 0), ""); |
| 1092 |
elem = LLVMBuildLoad2(builder, src_type, ptr, ""); |
| 1093 |
|
| 1094 |
if (block_bits == 128) { |
| 1095 |
|
| 1096 |
*dxt_block = LLVMBuildBitCast(builder, elem, type32_4, ""); |
| 1097 |
} |
| 1098 |
else { |
| 1099 |
LLVMTypeRef type32_2 = LLVMVectorType(type32, 2); |
| 1100 |
shuf = lp_build_const_extend_shuffle(gallivm, 2, 4); |
| 1101 |
elem = LLVMBuildBitCast(builder, elem, type32_2, ""); |
| 1102 |
*dxt_block = LLVMBuildShuffleVector(builder, elem, |
| 1103 |
LLVMGetUndef(type32_2), shuf, ""); |
| 1104 |
} |
| 1105 |
} |
| 1106 |
|
| 1107 |
|
| 1108 |
static void |
| 1109 |
s3tc_store_cached_block(struct gallivm_state *gallivm, |
| 1110 |
LLVMValueRef *col, |
| 1111 |
LLVMValueRef tag_value, |
| 1112 |
LLVMValueRef hash_index, |
| 1113 |
LLVMValueRef cache) |
| 1114 |
{ |
| 1115 |
LLVMBuilderRef builder = gallivm->builder; |
| 1116 |
LLVMValueRef ptr, indices[3]; |
| 1117 |
LLVMTypeRef type_ptr4x32; |
| 1118 |
unsigned count; |
| 1119 |
|
| 1120 |
type_ptr4x32 = LLVMPointerType(LLVMVectorType(LLVMInt32TypeInContext(gallivm->context), 4), 0); |
| 1121 |
indices[0] = lp_build_const_int32(gallivm, 0); |
| 1122 |
indices[1] = lp_build_const_int32(gallivm, LP_BUILD_FORMAT_CACHE_MEMBER_TAGS); |
| 1123 |
indices[2] = hash_index; |
| 1124 |
LLVMTypeRef cache_type = lp_build_format_cache_type(gallivm); |
| 1125 |
ptr = LLVMBuildGEP2(builder, cache_type, cache, indices, ARRAY_SIZE(indices), ""); |
| 1126 |
LLVMBuildStore(builder, tag_value, ptr); |
| 1127 |
|
| 1128 |
indices[1] = lp_build_const_int32(gallivm, LP_BUILD_FORMAT_CACHE_MEMBER_DATA); |
| 1129 |
hash_index = LLVMBuildMul(builder, hash_index, lp_build_const_int32(gallivm, 16), ""); |
| 1130 |
for (count = 0; count < 4; count++) { |
| 1131 |
indices[2] = hash_index; |
| 1132 |
ptr = LLVMBuildGEP2(builder, cache_type, cache, indices, ARRAY_SIZE(indices), ""); |
| 1133 |
ptr = LLVMBuildBitCast(builder, ptr, type_ptr4x32, ""); |
| 1134 |
LLVMBuildStore(builder, col[count], ptr); |
| 1135 |
hash_index = LLVMBuildAdd(builder, hash_index, lp_build_const_int32(gallivm, 4), ""); |
| 1136 |
} |
| 1137 |
} |
| 1138 |
|
| 1139 |
static LLVMValueRef |
| 1140 |
lookup_cache_member(struct gallivm_state *gallivm, LLVMValueRef cache, enum cache_member member, LLVMValueRef index) { |
| 1141 |
assert(member == LP_BUILD_FORMAT_CACHE_MEMBER_DATA || member == LP_BUILD_FORMAT_CACHE_MEMBER_TAGS); |
| 1142 |
LLVMBuilderRef builder = gallivm->builder; |
| 1143 |
LLVMValueRef member_ptr, indices[3]; |
| 1144 |
|
| 1145 |
indices[0] = lp_build_const_int32(gallivm, 0); |
| 1146 |
indices[1] = lp_build_const_int32(gallivm, member); |
| 1147 |
indices[2] = index; |
| 1148 |
|
| 1149 |
const char *name = |
| 1150 |
member == LP_BUILD_FORMAT_CACHE_MEMBER_DATA ? "cache_data" : |
| 1151 |
member == LP_BUILD_FORMAT_CACHE_MEMBER_TAGS ? "tag_data" : ""; |
| 1152 |
|
| 1153 |
member_ptr = LLVMBuildGEP2(builder, lp_build_format_cache_type(gallivm), |
| 1154 |
cache, indices, ARRAY_SIZE(indices), "cache_gep"); |
| 1155 |
|
| 1156 |
return LLVMBuildLoad2(builder, lp_build_format_cache_elem_type(gallivm, member), member_ptr, name); |
| 1157 |
} |
| 1158 |
|
| 1159 |
static LLVMValueRef |
| 1160 |
s3tc_lookup_cached_pixel(struct gallivm_state *gallivm, |
| 1161 |
LLVMValueRef cache, |
| 1162 |
LLVMValueRef index) |
| 1163 |
{ |
| 1164 |
return lookup_cache_member(gallivm, cache, LP_BUILD_FORMAT_CACHE_MEMBER_DATA, index); |
| 1165 |
} |
| 1166 |
|
| 1167 |
static LLVMValueRef |
| 1168 |
s3tc_lookup_tag_data(struct gallivm_state *gallivm, |
| 1169 |
LLVMValueRef cache, |
| 1170 |
LLVMValueRef index) |
| 1171 |
{ |
| 1172 |
return lookup_cache_member(gallivm, cache, LP_BUILD_FORMAT_CACHE_MEMBER_TAGS, index); |
| 1173 |
} |
| 1174 |
|
| 1175 |
#if LP_BUILD_FORMAT_CACHE_DEBUG |
| 1176 |
static void |
| 1177 |
s3tc_update_cache_access(struct gallivm_state *gallivm, |
| 1178 |
LLVMValueRef ptr, |
| 1179 |
unsigned count, |
| 1180 |
unsigned index) |
| 1181 |
{ |
| 1182 |
LLVMBuilderRef builder = gallivm->builder; |
| 1183 |
LLVMValueRef member_ptr, cache_access; |
| 1184 |
|
| 1185 |
assert(index == LP_BUILD_FORMAT_CACHE_MEMBER_ACCESS_TOTAL || |
| 1186 |
index == LP_BUILD_FORMAT_CACHE_MEMBER_ACCESS_MISS); |
| 1187 |
LLVMTypeRef cache_type = lp_build_format_cache_type(gallivm); |
| 1188 |
member_ptr = lp_build_struct_get_ptr2(gallivm, cache_type, ptr, index, ""); |
| 1189 |
cache_access = LLVMBuildLoad2(builder, LLVMInt64TypeInContext(gallivm->context), member_ptr, "cache_access"); |
| 1190 |
cache_access = LLVMBuildAdd(builder, cache_access, |
| 1191 |
LLVMConstInt(LLVMInt64TypeInContext(gallivm->context), count, 0), ""); |
| 1192 |
LLVMBuildStore(builder, cache_access, member_ptr); |
| 1193 |
} |
| 1194 |
#endif |
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
|
| 1200 |
|
| 1201 |
static LLVMValueRef |
| 1202 |
lp_build_lerp23_single(struct lp_build_context *bld, |
| 1203 |
LLVMValueRef v01) |
| 1204 |
{ |
| 1205 |
struct gallivm_state *gallivm = bld->gallivm; |
| 1206 |
LLVMValueRef x, mul, delta, res, v0, v1, elems[8]; |
| 1207 |
const struct lp_type type = bld->type; |
| 1208 |
LLVMBuilderRef builder = bld->gallivm->builder; |
| 1209 |
struct lp_type i16_type = lp_wider_type(type); |
| 1210 |
struct lp_type i32_type = lp_wider_type(i16_type); |
| 1211 |
struct lp_build_context bld2; |
| 1212 |
|
| 1213 |
assert(!type.floating && !type.fixed && !type.norm && type.width == 8); |
| 1214 |
|
| 1215 |
lp_build_context_init(&bld2, gallivm, i16_type); |
| 1216 |
bld2.type.sign = true; |
| 1217 |
|
| 1218 |
|
| 1219 |
elems[0] = elems[1] = elems[2] = elems[3] = |
| 1220 |
lp_build_const_elem(gallivm, i16_type, 255*1/3); |
| 1221 |
elems[4] = elems[5] = elems[6] = elems[7] = |
| 1222 |
lp_build_const_elem(gallivm, i16_type, 171); |
| 1223 |
x = LLVMConstVector(elems, 8); |
| 1224 |
|
| 1225 |
|
| 1226 |
|
| 1227 |
|
| 1228 |
|
| 1229 |
v01 = lp_build_interleave2(gallivm, i32_type, v01, v01, 0); |
| 1230 |
v01 = LLVMBuildBitCast(builder, v01, bld->vec_type, ""); |
| 1231 |
|
| 1232 |
lp_build_unpack2(gallivm, type, i16_type, v01, &v0, &v1); |
| 1233 |
delta = lp_build_sub(&bld2, v1, v0); |
| 1234 |
|
| 1235 |
mul = LLVMBuildMul(builder, x, delta, ""); |
| 1236 |
|
| 1237 |
mul = LLVMBuildLShr(builder, mul, lp_build_const_int_vec(gallivm, i16_type, 8), ""); |
| 1238 |
|
| 1239 |
res = lp_build_pack2(gallivm, i16_type, type, mul, bld2.undef); |
| 1240 |
|
| 1241 |
return lp_build_add(bld, res, v01); |
| 1242 |
} |
| 1243 |
|
| 1244 |
|
| 1245 |
|
| 1246 |
|
| 1247 |
static void |
| 1248 |
s3tc_decode_block_dxt1(struct gallivm_state *gallivm, |
| 1249 |
enum pipe_format format, |
| 1250 |
LLVMValueRef dxt_block, |
| 1251 |
LLVMValueRef *col) |
| 1252 |
{ |
| 1253 |
LLVMBuilderRef builder = gallivm->builder; |
| 1254 |
LLVMValueRef color01, color23, color01_16, color0123; |
| 1255 |
LLVMValueRef rgba, tmp, a, sel_mask, indices, code, const2; |
| 1256 |
struct lp_type type8, type32, type16, type64; |
| 1257 |
struct lp_build_context bld8, bld32, bld16, bld64; |
| 1258 |
unsigned i; |
| 1259 |
bool is_dxt1_variant = format_dxt1_variant(format); |
| 1260 |
|
| 1261 |
memset(&type32, 0, sizeof type32); |
| 1262 |
type32.width = 32; |
| 1263 |
type32.length = 4; |
| 1264 |
type32.sign = true; |
| 1265 |
|
| 1266 |
memset(&type8, 0, sizeof type8); |
| 1267 |
type8.width = 8; |
| 1268 |
type8.length = 16; |
| 1269 |
|
| 1270 |
memset(&type16, 0, sizeof type16); |
| 1271 |
type16.width = 16; |
| 1272 |
type16.length = 8; |
| 1273 |
|
| 1274 |
memset(&type64, 0, sizeof type64); |
| 1275 |
type64.width = 64; |
| 1276 |
type64.length = 2; |
| 1277 |
|
| 1278 |
a = lp_build_const_int_vec(gallivm, type32, 0xff000000); |
| 1279 |
const2 = lp_build_const_int_vec(gallivm, type32, 2); |
| 1280 |
|
| 1281 |
lp_build_context_init(&bld32, gallivm, type32); |
| 1282 |
lp_build_context_init(&bld16, gallivm, type16); |
| 1283 |
lp_build_context_init(&bld8, gallivm, type8); |
| 1284 |
lp_build_context_init(&bld64, gallivm, type64); |
| 1285 |
|
| 1286 |
if (is_dxt1_variant) { |
| 1287 |
color01 = lp_build_shuffle1undef(gallivm, dxt_block, 0, 4); |
| 1288 |
code = lp_build_shuffle1undef(gallivm, dxt_block, 1, 4); |
| 1289 |
} else { |
| 1290 |
color01 = lp_build_shuffle1undef(gallivm, dxt_block, 2, 4); |
| 1291 |
code = lp_build_shuffle1undef(gallivm, dxt_block, 3, 4); |
| 1292 |
} |
| 1293 |
code = LLVMBuildBitCast(builder, code, bld8.vec_type, ""); |
| 1294 |
|
| 1295 |
code = lp_build_interleave2(gallivm, type8, code, code, 0); |
| 1296 |
code = lp_build_interleave2(gallivm, type8, code, code, 0); |
| 1297 |
|
| 1298 |
|
| 1299 |
|
| 1300 |
|
| 1301 |
|
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
color01 = LLVMBuildBitCast(builder, color01, bld16.vec_type, ""); |
| 1314 |
color01 = lp_build_interleave2(gallivm, type16, color01, |
| 1315 |
bld16.zero, 0); |
| 1316 |
color01_16 = LLVMBuildBitCast(builder, color01, bld32.vec_type, ""); |
| 1317 |
color01 = color_expand_565_to_8888(gallivm, 4, color01_16); |
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
if (format == PIPE_FORMAT_DXT1_RGBA || |
| 1332 |
format == PIPE_FORMAT_DXT1_SRGBA) { |
| 1333 |
color01 = LLVMBuildOr(builder, color01, a, ""); |
| 1334 |
} |
| 1335 |
|
| 1336 |
color23 = lp_build_lerp23_single(&bld8, color01); |
| 1337 |
color23 = LLVMBuildBitCast(builder, color23, bld32.vec_type, ""); |
| 1338 |
|
| 1339 |
|
| 1340 |
if (is_dxt1_variant) { |
| 1341 |
LLVMValueRef color23_2, color2_2; |
| 1342 |
|
| 1343 |
if (util_get_cpu_caps()->has_sse2) { |
| 1344 |
LLVMValueRef intrargs[2]; |
| 1345 |
intrargs[0] = LLVMBuildBitCast(builder, color01, bld8.vec_type, ""); |
| 1346 |
|
| 1347 |
intrargs[1] = lp_build_interleave2(gallivm, type32, color01, color01, 0); |
| 1348 |
intrargs[1] = LLVMBuildBitCast(builder, intrargs[1], bld8.vec_type, ""); |
| 1349 |
color2_2 = lp_build_pavgb(&bld8, intrargs[0], intrargs[1]); |
| 1350 |
} |
| 1351 |
else { |
| 1352 |
LLVMValueRef v01, v0, v1, vhalf; |
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
v01 = lp_build_interleave2(gallivm, type32, color01, color01, 0); |
| 1360 |
v01 = LLVMBuildBitCast(builder, v01, bld8.vec_type, ""); |
| 1361 |
lp_build_unpack2(gallivm, type8, type16, v01, &v0, &v1); |
| 1362 |
vhalf = lp_build_add(&bld16, v0, v1); |
| 1363 |
vhalf = LLVMBuildLShr(builder, vhalf, bld16.one, ""); |
| 1364 |
color2_2 = lp_build_pack2(gallivm, type16, type8, vhalf, bld16.undef); |
| 1365 |
} |
| 1366 |
|
| 1367 |
color23_2 = LLVMBuildBitCast(builder, color2_2, bld64.vec_type, ""); |
| 1368 |
color23_2 = LLVMBuildLShr(builder, color23_2, |
| 1369 |
lp_build_const_int_vec(gallivm, type64, 32), ""); |
| 1370 |
color23_2 = LLVMBuildBitCast(builder, color23_2, bld32.vec_type, ""); |
| 1371 |
|
| 1372 |
tmp = LLVMBuildBitCast(builder, color01_16, bld64.vec_type, ""); |
| 1373 |
tmp = LLVMBuildLShr(builder, tmp, |
| 1374 |
lp_build_const_int_vec(gallivm, type64, 32), ""); |
| 1375 |
tmp = LLVMBuildBitCast(builder, tmp, bld32.vec_type, ""); |
| 1376 |
sel_mask = lp_build_compare(gallivm, type32, PIPE_FUNC_GREATER, |
| 1377 |
color01_16, tmp); |
| 1378 |
sel_mask = lp_build_interleave2(gallivm, type32, sel_mask, sel_mask, 0); |
| 1379 |
color23 = lp_build_select(&bld32, sel_mask, color23, color23_2); |
| 1380 |
} |
| 1381 |
|
| 1382 |
if (util_get_cpu_caps()->has_ssse3) { |
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
|
| 1387 |
LLVMValueRef shuf[16], low2mask; |
| 1388 |
LLVMValueRef intrargs[2], lut_ind, lut_adj; |
| 1389 |
|
| 1390 |
color01 = LLVMBuildBitCast(builder, color01, bld64.vec_type, ""); |
| 1391 |
color23 = LLVMBuildBitCast(builder, color23, bld64.vec_type, ""); |
| 1392 |
color0123 = lp_build_interleave2(gallivm, type64, color01, color23, 0); |
| 1393 |
color0123 = LLVMBuildBitCast(builder, color0123, bld32.vec_type, ""); |
| 1394 |
|
| 1395 |
if (format == PIPE_FORMAT_DXT1_RGB || |
| 1396 |
format == PIPE_FORMAT_DXT1_SRGB) { |
| 1397 |
color0123 = LLVMBuildOr(builder, color0123, a, ""); |
| 1398 |
} |
| 1399 |
|
| 1400 |
|
| 1401 |
for (i = 0; i < 4; i++) { |
| 1402 |
shuf[4*i] = lp_build_const_int32(gallivm, 0 + i); |
| 1403 |
shuf[4*i+1] = lp_build_const_int32(gallivm, 4 + i); |
| 1404 |
shuf[4*i+2] = lp_build_const_int32(gallivm, 8 + i); |
| 1405 |
shuf[4*i+3] = lp_build_const_int32(gallivm, 12 + i); |
| 1406 |
} |
| 1407 |
color0123 = LLVMBuildBitCast(builder, color0123, bld8.vec_type, ""); |
| 1408 |
color0123 = LLVMBuildShuffleVector(builder, color0123, bld8.undef, |
| 1409 |
LLVMConstVector(shuf, 16), ""); |
| 1410 |
|
| 1411 |
|
| 1412 |
low2mask = lp_build_const_int_vec(gallivm, type8, 3); |
| 1413 |
|
| 1414 |
lut_adj = lp_build_const_int_vec(gallivm, type32, 0x0c080400); |
| 1415 |
lut_adj = LLVMBuildBitCast(builder, lut_adj, bld8.vec_type, ""); |
| 1416 |
intrargs[0] = color0123; |
| 1417 |
for (i = 0; i < 4; i++) { |
| 1418 |
lut_ind = LLVMBuildAnd(builder, code, low2mask, ""); |
| 1419 |
lut_ind = LLVMBuildOr(builder, lut_ind, lut_adj, ""); |
| 1420 |
intrargs[1] = lut_ind; |
| 1421 |
col[i] = lp_build_intrinsic(builder, "llvm.x86.ssse3.pshuf.b.128", |
| 1422 |
bld8.vec_type, intrargs, 2, 0); |
| 1423 |
col[i] = LLVMBuildBitCast(builder, col[i], bld32.vec_type, ""); |
| 1424 |
code = LLVMBuildBitCast(builder, code, bld32.vec_type, ""); |
| 1425 |
code = LLVMBuildLShr(builder, code, const2, ""); |
| 1426 |
code = LLVMBuildBitCast(builder, code, bld8.vec_type, ""); |
| 1427 |
} |
| 1428 |
} |
| 1429 |
else { |
| 1430 |
|
| 1431 |
LLVMValueRef color0, color1, color2, color3; |
| 1432 |
if (format == PIPE_FORMAT_DXT1_RGB || |
| 1433 |
format == PIPE_FORMAT_DXT1_SRGB) { |
| 1434 |
color01 = LLVMBuildOr(builder, color01, a, ""); |
| 1435 |
color23 = LLVMBuildOr(builder, color23, a, ""); |
| 1436 |
} |
| 1437 |
color0 = LLVMBuildShuffleVector(builder, color01, bld32.undef, |
| 1438 |
lp_build_const_shuffle1(gallivm, 0, 4), ""); |
| 1439 |
color1 = LLVMBuildShuffleVector(builder, color01, bld32.undef, |
| 1440 |
lp_build_const_shuffle1(gallivm, 1, 4), ""); |
| 1441 |
color2 = LLVMBuildShuffleVector(builder, color23, bld32.undef, |
| 1442 |
lp_build_const_shuffle1(gallivm, 0, 4), ""); |
| 1443 |
color3 = LLVMBuildShuffleVector(builder, color23, bld32.undef, |
| 1444 |
lp_build_const_shuffle1(gallivm, 1, 4), ""); |
| 1445 |
code = LLVMBuildBitCast(builder, code, bld32.vec_type, ""); |
| 1446 |
|
| 1447 |
for (i = 0; i < 4; i++) { |
| 1448 |
|
| 1449 |
LLVMValueRef selmasklo, rgba01, rgba23, bitlo; |
| 1450 |
bitlo = bld32.one; |
| 1451 |
indices = LLVMBuildAnd(builder, code, bitlo, ""); |
| 1452 |
selmasklo = lp_build_compare(gallivm, type32, PIPE_FUNC_EQUAL, |
| 1453 |
indices, bitlo); |
| 1454 |
rgba01 = lp_build_select(&bld32, selmasklo, color1, color0); |
| 1455 |
|
| 1456 |
LLVMValueRef selmaskhi; |
| 1457 |
indices = LLVMBuildAnd(builder, code, const2, ""); |
| 1458 |
selmaskhi = lp_build_compare(gallivm, type32, PIPE_FUNC_EQUAL, |
| 1459 |
indices, const2); |
| 1460 |
rgba23 = lp_build_select(&bld32, selmasklo, color3, color2); |
| 1461 |
rgba = lp_build_select(&bld32, selmaskhi, rgba23, rgba01); |
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
|
| 1468 |
|
| 1469 |
|
| 1470 |
col[i] = rgba; |
| 1471 |
code = LLVMBuildLShr(builder, code, const2, ""); |
| 1472 |
} |
| 1473 |
} |
| 1474 |
} |
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
static void |
| 1480 |
s3tc_decode_block_dxt3(struct gallivm_state *gallivm, |
| 1481 |
enum pipe_format format, |
| 1482 |
LLVMValueRef dxt_block, |
| 1483 |
LLVMValueRef *col) |
| 1484 |
{ |
| 1485 |
LLVMBuilderRef builder = gallivm->builder; |
| 1486 |
LLVMValueRef alpha, alphas0, alphas1, shift4_16, a[4], mask8hi; |
| 1487 |
struct lp_type type32, type8, type16; |
| 1488 |
unsigned i; |
| 1489 |
|
| 1490 |
memset(&type32, 0, sizeof type32); |
| 1491 |
type32.width = 32; |
| 1492 |
type32.length = 4; |
| 1493 |
|
| 1494 |
memset(&type8, 0, sizeof type8); |
| 1495 |
type8.width = 8; |
| 1496 |
type8.length = 16; |
| 1497 |
|
| 1498 |
memset(&type16, 0, sizeof type16); |
| 1499 |
type16.width = 16; |
| 1500 |
type16.length = 8; |
| 1501 |
|
| 1502 |
s3tc_decode_block_dxt1(gallivm, format, dxt_block, col); |
| 1503 |
|
| 1504 |
shift4_16 = lp_build_const_int_vec(gallivm, type16, 4); |
| 1505 |
mask8hi = lp_build_const_int_vec(gallivm, type32, 0xff000000); |
| 1506 |
|
| 1507 |
alpha = LLVMBuildBitCast(builder, dxt_block, |
| 1508 |
lp_build_vec_type(gallivm, type8), ""); |
| 1509 |
alpha = lp_build_interleave2(gallivm, type8, alpha, alpha, 0); |
| 1510 |
alpha = LLVMBuildBitCast(builder, alpha, |
| 1511 |
lp_build_vec_type(gallivm, type16), ""); |
| 1512 |
alpha = LLVMBuildAnd(builder, alpha, |
| 1513 |
lp_build_const_int_vec(gallivm, type16, 0xf00f), ""); |
| 1514 |
alphas0 = LLVMBuildLShr(builder, alpha, shift4_16, ""); |
| 1515 |
alphas1 = LLVMBuildShl(builder, alpha, shift4_16, ""); |
| 1516 |
alpha = LLVMBuildOr(builder, alphas0, alpha, ""); |
| 1517 |
alpha = LLVMBuildOr(builder, alphas1, alpha, ""); |
| 1518 |
alpha = LLVMBuildBitCast(builder, alpha, |
| 1519 |
lp_build_vec_type(gallivm, type32), ""); |
| 1520 |
|
| 1521 |
|
| 1522 |
|
| 1523 |
|
| 1524 |
|
| 1525 |
a[0] = LLVMBuildShl(builder, alpha, |
| 1526 |
lp_build_const_int_vec(gallivm, type32, 24), ""); |
| 1527 |
a[1] = LLVMBuildShl(builder, alpha, |
| 1528 |
lp_build_const_int_vec(gallivm, type32, 16), ""); |
| 1529 |
a[1] = LLVMBuildAnd(builder, a[1], mask8hi, ""); |
| 1530 |
a[2] = LLVMBuildShl(builder, alpha, |
| 1531 |
lp_build_const_int_vec(gallivm, type32, 8), ""); |
| 1532 |
a[2] = LLVMBuildAnd(builder, a[2], mask8hi, ""); |
| 1533 |
a[3] = LLVMBuildAnd(builder, alpha, mask8hi, ""); |
| 1534 |
|
| 1535 |
for (i = 0; i < 4; i++) { |
| 1536 |
col[i] = LLVMBuildOr(builder, col[i], a[i], ""); |
| 1537 |
} |
| 1538 |
} |
| 1539 |
|
| 1540 |
|
| 1541 |
static LLVMValueRef |
| 1542 |
lp_build_lerpdxta_block(struct gallivm_state *gallivm, |
| 1543 |
LLVMValueRef alpha0, |
| 1544 |
LLVMValueRef alpha1, |
| 1545 |
LLVMValueRef code, |
| 1546 |
LLVMValueRef sel_mask) |
| 1547 |
{ |
| 1548 |
LLVMBuilderRef builder = gallivm->builder; |
| 1549 |
LLVMValueRef delta, ainterp; |
| 1550 |
LLVMValueRef weight5, weight7, weight; |
| 1551 |
struct lp_type type16; |
| 1552 |
struct lp_build_context bld; |
| 1553 |
|
| 1554 |
memset(&type16, 0, sizeof type16); |
| 1555 |
type16.width = 16; |
| 1556 |
type16.length = 8; |
| 1557 |
type16.sign = true; |
| 1558 |
|
| 1559 |
lp_build_context_init(&bld, gallivm, type16); |
| 1560 |
|
| 1561 |
|
| 1562 |
|
| 1563 |
|
| 1564 |
|
| 1565 |
|
| 1566 |
weight5 = lp_build_const_int_vec(gallivm, type16, 256*64/5); |
| 1567 |
weight7 = lp_build_const_int_vec(gallivm, type16, 256*64/7); |
| 1568 |
weight = lp_build_select(&bld, sel_mask, weight7, weight5); |
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
code = LLVMBuildSub(builder, code, bld.one, ""); |
| 1575 |
|
| 1576 |
weight = LLVMBuildMul(builder, weight, code, ""); |
| 1577 |
weight = LLVMBuildLShr(builder, weight, |
| 1578 |
lp_build_const_int_vec(gallivm, type16, 6), ""); |
| 1579 |
|
| 1580 |
delta = LLVMBuildSub(builder, alpha1, alpha0, ""); |
| 1581 |
|
| 1582 |
ainterp = LLVMBuildMul(builder, delta, weight, ""); |
| 1583 |
ainterp = LLVMBuildLShr(builder, ainterp, |
| 1584 |
lp_build_const_int_vec(gallivm, type16, 8), ""); |
| 1585 |
|
| 1586 |
|
| 1587 |
|
| 1588 |
return ainterp; |
| 1589 |
} |
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
|
| 1595 |
static void |
| 1596 |
s3tc_decode_block_dxt5(struct gallivm_state *gallivm, |
| 1597 |
enum pipe_format format, |
| 1598 |
LLVMValueRef dxt_block, |
| 1599 |
LLVMValueRef *col) |
| 1600 |
{ |
| 1601 |
LLVMBuilderRef builder = gallivm->builder; |
| 1602 |
LLVMValueRef alpha, alpha0, alpha1, ares; |
| 1603 |
LLVMValueRef ainterp, ainterp0, ainterp1, shuffle1, sel_mask, sel_mask2; |
| 1604 |
LLVMValueRef a[4], acode, tmp0, tmp1; |
| 1605 |
LLVMTypeRef i64t, i32t; |
| 1606 |
struct lp_type type32, type64, type8, type16; |
| 1607 |
struct lp_build_context bld16, bld8; |
| 1608 |
unsigned i; |
| 1609 |
|
| 1610 |
memset(&type32, 0, sizeof type32); |
| 1611 |
type32.width = 32; |
| 1612 |
type32.length = 4; |
| 1613 |
|
| 1614 |
memset(&type64, 0, sizeof type64); |
| 1615 |
type64.width = 64; |
| 1616 |
type64.length = 2; |
| 1617 |
|
| 1618 |
memset(&type8, 0, sizeof type8); |
| 1619 |
type8.width = 8; |
| 1620 |
type8.length = 16; |
| 1621 |
|
| 1622 |
memset(&type16, 0, sizeof type16); |
| 1623 |
type16.width = 16; |
| 1624 |
type16.length = 8; |
| 1625 |
|
| 1626 |
lp_build_context_init(&bld16, gallivm, type16); |
| 1627 |
lp_build_context_init(&bld8, gallivm, type8); |
| 1628 |
|
| 1629 |
i64t = lp_build_vec_type(gallivm, type64); |
| 1630 |
i32t = lp_build_vec_type(gallivm, type32); |
| 1631 |
|
| 1632 |
s3tc_decode_block_dxt1(gallivm, format, dxt_block, col); |
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
|
| 1650 |
|
| 1651 |
|
| 1652 |
|
| 1653 |
|
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
alpha = LLVMBuildBitCast(builder, dxt_block, i64t, ""); |
| 1665 |
alpha0 = LLVMBuildAnd(builder, alpha, |
| 1666 |
lp_build_const_int_vec(gallivm, type64, 0xff), ""); |
| 1667 |
alpha0 = LLVMBuildBitCast(builder, alpha0, bld16.vec_type, ""); |
| 1668 |
alpha = LLVMBuildBitCast(builder, alpha, bld16.vec_type, ""); |
| 1669 |
alpha1 = LLVMBuildLShr(builder, alpha, |
| 1670 |
lp_build_const_int_vec(gallivm, type16, 8), ""); |
| 1671 |
alpha = LLVMBuildBitCast(builder, alpha, i64t, ""); |
| 1672 |
shuffle1 = lp_build_const_shuffle1(gallivm, 0, 8); |
| 1673 |
alpha0 = LLVMBuildShuffleVector(builder, alpha0, alpha0, shuffle1, ""); |
| 1674 |
alpha1 = LLVMBuildShuffleVector(builder, alpha1, alpha1, shuffle1, ""); |
| 1675 |
|
| 1676 |
type16.sign = true; |
| 1677 |
sel_mask = lp_build_compare(gallivm, type16, PIPE_FUNC_GREATER, |
| 1678 |
alpha0, alpha1); |
| 1679 |
type16.sign = false; |
| 1680 |
sel_mask = LLVMBuildBitCast(builder, sel_mask, bld8.vec_type, ""); |
| 1681 |
|
| 1682 |
if (!util_get_cpu_caps()->has_ssse3) { |
| 1683 |
LLVMValueRef acodeg, mask1, acode0, acode1; |
| 1684 |
|
| 1685 |
|
| 1686 |
|
| 1687 |
acode = LLVMBuildLShr(builder, alpha, |
| 1688 |
lp_build_const_int_vec(gallivm, type64, 16), ""); |
| 1689 |
tmp0 = LLVMBuildAnd(builder, acode, |
| 1690 |
lp_build_const_int_vec(gallivm, type64, 0xffffff), ""); |
| 1691 |
tmp1 = LLVMBuildLShr(builder, acode, |
| 1692 |
lp_build_const_int_vec(gallivm, type64, 24), ""); |
| 1693 |
tmp0 = LLVMBuildBitCast(builder, tmp0, i32t, ""); |
| 1694 |
tmp1 = LLVMBuildBitCast(builder, tmp1, i32t, ""); |
| 1695 |
acode = lp_build_interleave2(gallivm, type32, tmp0, tmp1, 0); |
| 1696 |
|
| 1697 |
tmp0 = LLVMBuildAnd(builder, acode, |
| 1698 |
lp_build_const_int_vec(gallivm, type32, 0xfff), ""); |
| 1699 |
tmp1 = LLVMBuildLShr(builder, acode, |
| 1700 |
lp_build_const_int_vec(gallivm, type32, 12), ""); |
| 1701 |
acode = lp_build_interleave2(gallivm, type32, tmp0, tmp1, 0); |
| 1702 |
|
| 1703 |
tmp0 = LLVMBuildAnd(builder, acode, |
| 1704 |
lp_build_const_int_vec(gallivm, type32, 0x3f), ""); |
| 1705 |
tmp1 = LLVMBuildLShr(builder, acode, |
| 1706 |
lp_build_const_int_vec(gallivm, type32, 6), ""); |
| 1707 |
|
| 1708 |
type32.sign = type16.sign = true; |
| 1709 |
acode = lp_build_pack2(gallivm, type32, type16, tmp0, tmp1); |
| 1710 |
type32.sign = type16.sign = false; |
| 1711 |
|
| 1712 |
acode0 = LLVMBuildAnd(builder, acode, |
| 1713 |
lp_build_const_int_vec(gallivm, type16, 0x7), ""); |
| 1714 |
acode1 = LLVMBuildLShr(builder, acode, |
| 1715 |
lp_build_const_int_vec(gallivm, type16, 3), ""); |
| 1716 |
acode = lp_build_pack2(gallivm, type16, type8, acode0, acode1); |
| 1717 |
|
| 1718 |
|
| 1719 |
acodeg = LLVMBuildAnd(builder, acode, |
| 1720 |
LLVMBuildNot(builder, sel_mask, ""), ""); |
| 1721 |
mask1 = lp_build_compare(gallivm, type8, PIPE_FUNC_EQUAL, |
| 1722 |
acode, bld8.one); |
| 1723 |
|
| 1724 |
sel_mask = LLVMBuildBitCast(builder, sel_mask, bld16.vec_type, ""); |
| 1725 |
ainterp0 = lp_build_lerpdxta_block(gallivm, alpha0, alpha1, acode0, sel_mask); |
| 1726 |
ainterp1 = lp_build_lerpdxta_block(gallivm, alpha0, alpha1, acode1, sel_mask); |
| 1727 |
sel_mask = LLVMBuildBitCast(builder, sel_mask, bld8.vec_type, ""); |
| 1728 |
ainterp = lp_build_pack2(gallivm, type16, type8, ainterp0, ainterp1); |
| 1729 |
alpha0 = lp_build_pack2(gallivm, type16, type8, alpha0, alpha0); |
| 1730 |
alpha1 = lp_build_pack2(gallivm, type16, type8, alpha1, alpha1); |
| 1731 |
ainterp = LLVMBuildAdd(builder, ainterp, alpha0, ""); |
| 1732 |
|
| 1733 |
sel_mask2 = lp_build_compare(gallivm, type8, PIPE_FUNC_EQUAL, |
| 1734 |
acode, bld8.zero); |
| 1735 |
ainterp = lp_build_select(&bld8, sel_mask2, alpha0, ainterp); |
| 1736 |
ainterp = lp_build_select(&bld8, mask1, alpha1, ainterp); |
| 1737 |
|
| 1738 |
|
| 1739 |
sel_mask2 = lp_build_compare(gallivm, type8, PIPE_FUNC_EQUAL, |
| 1740 |
acodeg, lp_build_const_int_vec(gallivm, type8, 6)); |
| 1741 |
ares = LLVMBuildAnd(builder, ainterp, LLVMBuildNot(builder, sel_mask2, ""), ""); |
| 1742 |
sel_mask2 = lp_build_compare(gallivm, type8, PIPE_FUNC_EQUAL, |
| 1743 |
acodeg, lp_build_const_int_vec(gallivm, type8, 7)); |
| 1744 |
ares = LLVMBuildOr(builder, ares, sel_mask2, ""); |
| 1745 |
|
| 1746 |
|
| 1747 |
|
| 1748 |
tmp0 = lp_build_interleave2(gallivm, type8, bld8.zero, ares, 0); |
| 1749 |
tmp1 = lp_build_interleave2(gallivm, type8, bld8.zero, ares, 1); |
| 1750 |
tmp0 = LLVMBuildBitCast(builder, tmp0, bld16.vec_type, ""); |
| 1751 |
tmp1 = LLVMBuildBitCast(builder, tmp1, bld16.vec_type, ""); |
| 1752 |
|
| 1753 |
a[0] = lp_build_interleave2(gallivm, type16, bld16.zero, tmp0, 0); |
| 1754 |
a[1] = lp_build_interleave2(gallivm, type16, bld16.zero, tmp1, 0); |
| 1755 |
a[2] = lp_build_interleave2(gallivm, type16, bld16.zero, tmp0, 1); |
| 1756 |
a[3] = lp_build_interleave2(gallivm, type16, bld16.zero, tmp1, 1); |
| 1757 |
} |
| 1758 |
else { |
| 1759 |
LLVMValueRef elems[16], intrargs[2], shufa, mulclo, mulchi, mask8hi; |
| 1760 |
LLVMTypeRef type16s = LLVMInt16TypeInContext(gallivm->context); |
| 1761 |
LLVMTypeRef type8s = LLVMInt8TypeInContext(gallivm->context); |
| 1762 |
unsigned i, j; |
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
|
| 1767 |
|
| 1768 |
|
| 1769 |
|
| 1770 |
|
| 1771 |
|
| 1772 |
for (i = 0, j = 0; i < 16; i += 8, j += 3) { |
| 1773 |
elems[i+0] = elems[i+1] = elems[i+2] = lp_build_const_int32(gallivm, j+2); |
| 1774 |
elems[i+3] = elems[i+4] = lp_build_const_int32(gallivm, j+3); |
| 1775 |
elems[i+5] = elems[i+6] = elems[i+7] = lp_build_const_int32(gallivm, j+4); |
| 1776 |
} |
| 1777 |
shufa = LLVMConstVector(elems, 16); |
| 1778 |
alpha = LLVMBuildBitCast(builder, alpha, bld8.vec_type, ""); |
| 1779 |
acode = LLVMBuildShuffleVector(builder, alpha, bld8.undef, shufa, ""); |
| 1780 |
acode = LLVMBuildBitCast(builder, acode, bld16.vec_type, ""); |
| 1781 |
|
| 1782 |
|
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
for (i = 0; i < 8; i += 4) { |
| 1787 |
elems[i+0] = LLVMConstInt(type16s, 1 << (13-0), 0); |
| 1788 |
elems[i+1] = LLVMConstInt(type16s, 1 << (13-6), 0); |
| 1789 |
elems[i+2] = LLVMConstInt(type16s, 1 << (13-4), 0); |
| 1790 |
elems[i+3] = LLVMConstInt(type16s, 1 << (13-2), 0); |
| 1791 |
} |
| 1792 |
mulclo = LLVMConstVector(elems, 8); |
| 1793 |
for (i = 0; i < 8; i += 4) { |
| 1794 |
elems[i+0] = LLVMConstInt(type16s, 1 << (13-3), 0); |
| 1795 |
elems[i+1] = LLVMConstInt(type16s, 1 << (13-9), 0); |
| 1796 |
elems[i+2] = LLVMConstInt(type16s, 1 << (13-7), 0); |
| 1797 |
elems[i+3] = LLVMConstInt(type16s, 1 << (13-5), 0); |
| 1798 |
} |
| 1799 |
mulchi = LLVMConstVector(elems, 8); |
| 1800 |
|
| 1801 |
tmp0 = LLVMBuildMul(builder, acode, mulclo, ""); |
| 1802 |
tmp1 = LLVMBuildMul(builder, acode, mulchi, ""); |
| 1803 |
tmp0 = LLVMBuildLShr(builder, tmp0, |
| 1804 |
lp_build_const_int_vec(gallivm, type16, 13), ""); |
| 1805 |
tmp1 = LLVMBuildLShr(builder, tmp1, |
| 1806 |
lp_build_const_int_vec(gallivm, type16, 5), ""); |
| 1807 |
tmp1 = LLVMBuildAnd(builder, tmp1, |
| 1808 |
lp_build_const_int_vec(gallivm, type16, 0x700), ""); |
| 1809 |
acode = LLVMBuildOr(builder, tmp0, tmp1, ""); |
| 1810 |
acode = LLVMBuildBitCast(builder, acode, bld8.vec_type, ""); |
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
|
| 1817 |
LLVMValueRef weight0, weight1, weight, delta; |
| 1818 |
LLVMValueRef constff_elem7, const0_elem6; |
| 1819 |
|
| 1820 |
elems[0] = LLVMConstInt(type16s, 256, 0); |
| 1821 |
elems[1] = LLVMConstInt(type16s, 0, 0); |
| 1822 |
elems[2] = LLVMConstInt(type16s, 219, 0); |
| 1823 |
elems[3] = LLVMConstInt(type16s, 183, 0); |
| 1824 |
elems[4] = LLVMConstInt(type16s, 146, 0); |
| 1825 |
elems[5] = LLVMConstInt(type16s, 110, 0); |
| 1826 |
elems[6] = LLVMConstInt(type16s, 73, 0); |
| 1827 |
elems[7] = LLVMConstInt(type16s, 37, 0); |
| 1828 |
weight0 = LLVMConstVector(elems, 8); |
| 1829 |
|
| 1830 |
elems[0] = LLVMConstInt(type16s, 256, 0); |
| 1831 |
elems[1] = LLVMConstInt(type16s, 0, 0); |
| 1832 |
elems[2] = LLVMConstInt(type16s, 205, 0); |
| 1833 |
elems[3] = LLVMConstInt(type16s, 154, 0); |
| 1834 |
elems[4] = LLVMConstInt(type16s, 102, 0); |
| 1835 |
elems[5] = LLVMConstInt(type16s, 51, 0); |
| 1836 |
elems[6] = LLVMConstInt(type16s, 0, 0); |
| 1837 |
elems[7] = LLVMConstInt(type16s, 0, 0); |
| 1838 |
weight1 = LLVMConstVector(elems, 8); |
| 1839 |
|
| 1840 |
weight0 = LLVMBuildBitCast(builder, weight0, bld8.vec_type, ""); |
| 1841 |
weight1 = LLVMBuildBitCast(builder, weight1, bld8.vec_type, ""); |
| 1842 |
weight = lp_build_select(&bld8, sel_mask, weight0, weight1); |
| 1843 |
weight = LLVMBuildBitCast(builder, weight, bld16.vec_type, ""); |
| 1844 |
|
| 1845 |
for (i = 0; i < 16; i++) { |
| 1846 |
elems[i] = LLVMConstNull(type8s); |
| 1847 |
} |
| 1848 |
elems[7] = LLVMConstInt(type8s, 255, 0); |
| 1849 |
constff_elem7 = LLVMConstVector(elems, 16); |
| 1850 |
|
| 1851 |
for (i = 0; i < 16; i++) { |
| 1852 |
elems[i] = LLVMConstInt(type8s, 255, 0); |
| 1853 |
} |
| 1854 |
elems[6] = LLVMConstInt(type8s, 0, 0); |
| 1855 |
const0_elem6 = LLVMConstVector(elems, 16); |
| 1856 |
|
| 1857 |
|
| 1858 |
delta = LLVMBuildSub(builder, alpha0, alpha1, ""); |
| 1859 |
ainterp = LLVMBuildMul(builder, delta, weight, ""); |
| 1860 |
ainterp = LLVMBuildLShr(builder, ainterp, |
| 1861 |
lp_build_const_int_vec(gallivm, type16, 8), ""); |
| 1862 |
ainterp = LLVMBuildBitCast(builder, ainterp, bld8.vec_type, ""); |
| 1863 |
alpha1 = LLVMBuildBitCast(builder, alpha1, bld8.vec_type, ""); |
| 1864 |
ainterp = LLVMBuildAdd(builder, ainterp, alpha1, ""); |
| 1865 |
ainterp = LLVMBuildBitCast(builder, ainterp, bld16.vec_type, ""); |
| 1866 |
ainterp = lp_build_pack2(gallivm, type16, type8, ainterp, bld16.undef); |
| 1867 |
|
| 1868 |
|
| 1869 |
constff_elem7 = LLVMBuildAnd(builder, constff_elem7, |
| 1870 |
LLVMBuildNot(builder, sel_mask, ""), ""); |
| 1871 |
const0_elem6 = LLVMBuildOr(builder, const0_elem6, sel_mask, ""); |
| 1872 |
ainterp = LLVMBuildOr(builder, ainterp, constff_elem7, ""); |
| 1873 |
ainterp = LLVMBuildAnd(builder, ainterp, const0_elem6, ""); |
| 1874 |
|
| 1875 |
|
| 1876 |
intrargs[0] = ainterp; |
| 1877 |
intrargs[1] = acode; |
| 1878 |
ares = lp_build_intrinsic(builder, "llvm.x86.ssse3.pshuf.b.128", |
| 1879 |
bld8.vec_type, intrargs, 2, 0); |
| 1880 |
|
| 1881 |
ares = LLVMBuildBitCast(builder, ares, i32t, ""); |
| 1882 |
mask8hi = lp_build_const_int_vec(gallivm, type32, 0xff000000); |
| 1883 |
a[0] = LLVMBuildShl(builder, ares, |
| 1884 |
lp_build_const_int_vec(gallivm, type32, 24), ""); |
| 1885 |
a[1] = LLVMBuildShl(builder, ares, |
| 1886 |
lp_build_const_int_vec(gallivm, type32, 16), ""); |
| 1887 |
a[1] = LLVMBuildAnd(builder, a[1], mask8hi, ""); |
| 1888 |
a[2] = LLVMBuildShl(builder, ares, |
| 1889 |
lp_build_const_int_vec(gallivm, type32, 8), ""); |
| 1890 |
a[2] = LLVMBuildAnd(builder, a[2], mask8hi, ""); |
| 1891 |
a[3] = LLVMBuildAnd(builder, ares, mask8hi, ""); |
| 1892 |
} |
| 1893 |
|
| 1894 |
for (i = 0; i < 4; i++) { |
| 1895 |
a[i] = LLVMBuildBitCast(builder, a[i], i32t, ""); |
| 1896 |
col[i] = LLVMBuildOr(builder, col[i], a[i], ""); |
| 1897 |
} |
| 1898 |
} |
| 1899 |
|
| 1900 |
|
| 1901 |
static void |
| 1902 |
generate_update_cache_one_block(struct gallivm_state *gallivm, |
| 1903 |
LLVMValueRef function, |
| 1904 |
const struct util_format_description *format_desc) |
| 1905 |
{ |
| 1906 |
LLVMBasicBlockRef block; |
| 1907 |
LLVMBuilderRef old_builder; |
| 1908 |
LLVMValueRef ptr_addr; |
| 1909 |
LLVMValueRef hash_index; |
| 1910 |
LLVMValueRef cache; |
| 1911 |
LLVMValueRef dxt_block, tag_value; |
| 1912 |
LLVMValueRef col[LP_MAX_VECTOR_LENGTH]; |
| 1913 |
|
| 1914 |
ptr_addr = LLVMGetParam(function, 0); |
| 1915 |
hash_index = LLVMGetParam(function, 1); |
| 1916 |
cache = LLVMGetParam(function, 2); |
| 1917 |
|
| 1918 |
lp_build_name(ptr_addr, "ptr_addr" ); |
| 1919 |
lp_build_name(hash_index, "hash_index"); |
| 1920 |
lp_build_name(cache, "cache_addr"); |
| 1921 |
|
| 1922 |
|
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
old_builder = gallivm->builder; |
| 1927 |
block = LLVMAppendBasicBlockInContext(gallivm->context, function, "entry"); |
| 1928 |
gallivm->builder = LLVMCreateBuilderInContext(gallivm->context); |
| 1929 |
LLVMPositionBuilderAtEnd(gallivm->builder, block); |
| 1930 |
|
| 1931 |
lp_build_gather_s3tc_simple_scalar(gallivm, format_desc, &dxt_block, |
| 1932 |
ptr_addr); |
| 1933 |
|
| 1934 |
switch (format_desc->format) { |
| 1935 |
case PIPE_FORMAT_DXT1_RGB: |
| 1936 |
case PIPE_FORMAT_DXT1_RGBA: |
| 1937 |
case PIPE_FORMAT_DXT1_SRGB: |
| 1938 |
case PIPE_FORMAT_DXT1_SRGBA: |
| 1939 |
s3tc_decode_block_dxt1(gallivm, format_desc->format, dxt_block, col); |
| 1940 |
break; |
| 1941 |
case PIPE_FORMAT_DXT3_RGBA: |
| 1942 |
case PIPE_FORMAT_DXT3_SRGBA: |
| 1943 |
s3tc_decode_block_dxt3(gallivm, format_desc->format, dxt_block, col); |
| 1944 |
break; |
| 1945 |
case PIPE_FORMAT_DXT5_RGBA: |
| 1946 |
case PIPE_FORMAT_DXT5_SRGBA: |
| 1947 |
s3tc_decode_block_dxt5(gallivm, format_desc->format, dxt_block, col); |
| 1948 |
break; |
| 1949 |
default: |
| 1950 |
assert(0); |
| 1951 |
s3tc_decode_block_dxt1(gallivm, format_desc->format, dxt_block, col); |
| 1952 |
break; |
| 1953 |
} |
| 1954 |
|
| 1955 |
tag_value = LLVMBuildPtrToInt(gallivm->builder, ptr_addr, |
| 1956 |
LLVMInt64TypeInContext(gallivm->context), ""); |
| 1957 |
s3tc_store_cached_block(gallivm, col, tag_value, hash_index, cache); |
| 1958 |
|
| 1959 |
LLVMBuildRetVoid(gallivm->builder); |
| 1960 |
|
| 1961 |
LLVMDisposeBuilder(gallivm->builder); |
| 1962 |
gallivm->builder = old_builder; |
| 1963 |
|
| 1964 |
gallivm_verify_function(gallivm, function); |
| 1965 |
} |
| 1966 |
|
| 1967 |
|
| 1968 |
static void |
| 1969 |
update_cached_block(struct gallivm_state *gallivm, |
| 1970 |
const struct util_format_description *format_desc, |
| 1971 |
LLVMValueRef ptr_addr, |
| 1972 |
LLVMValueRef hash_index, |
| 1973 |
LLVMValueRef cache) |
| 1974 |
|
| 1975 |
{ |
| 1976 |
LLVMBuilderRef builder = gallivm->builder; |
| 1977 |
LLVMModuleRef module = gallivm->module; |
| 1978 |
char name[256]; |
| 1979 |
LLVMTypeRef i8t = LLVMInt8TypeInContext(gallivm->context); |
| 1980 |
LLVMTypeRef pi8t = LLVMPointerType(i8t, 0); |
| 1981 |
LLVMValueRef function, inst; |
| 1982 |
LLVMBasicBlockRef bb; |
| 1983 |
LLVMValueRef args[3]; |
| 1984 |
|
| 1985 |
snprintf(name, sizeof name, "%s_update_cache_one_block", |
| 1986 |
format_desc->short_name); |
| 1987 |
function = LLVMGetNamedFunction(module, name); |
| 1988 |
|
| 1989 |
LLVMTypeRef ret_type = LLVMVoidTypeInContext(gallivm->context); |
| 1990 |
LLVMTypeRef arg_types[3]; |
| 1991 |
arg_types[0] = pi8t; |
| 1992 |
arg_types[1] = LLVMInt32TypeInContext(gallivm->context); |
| 1993 |
arg_types[2] = LLVMTypeOf(cache); |
| 1994 |
LLVMTypeRef function_type = LLVMFunctionType(ret_type, arg_types, ARRAY_SIZE(arg_types), 0); |
| 1995 |
|
| 1996 |
if (!function) { |
| 1997 |
function = LLVMAddFunction(module, name, function_type); |
| 1998 |
|
| 1999 |
for (unsigned arg = 0; arg < ARRAY_SIZE(arg_types); ++arg) |
| 2000 |
if (LLVMGetTypeKind(arg_types[arg]) == LLVMPointerTypeKind) |
| 2001 |
lp_add_function_attr(function, arg + 1, LP_FUNC_ATTR_NOALIAS); |
| 2002 |
|
| 2003 |
LLVMSetFunctionCallConv(function, LLVMFastCallConv); |
| 2004 |
LLVMSetVisibility(function, LLVMHiddenVisibility); |
| 2005 |
generate_update_cache_one_block(gallivm, function, format_desc); |
| 2006 |
} |
| 2007 |
|
| 2008 |
args[0] = ptr_addr; |
| 2009 |
args[1] = hash_index; |
| 2010 |
args[2] = cache; |
| 2011 |
|
| 2012 |
LLVMBuildCall2(builder, function_type, function, args, ARRAY_SIZE(args), ""); |
| 2013 |
bb = LLVMGetInsertBlock(builder); |
| 2014 |
inst = LLVMGetLastInstruction(bb); |
| 2015 |
LLVMSetInstructionCallConv(inst, LLVMFastCallConv); |
| 2016 |
} |
| 2017 |
|
| 2018 |
|
| 2019 |
|
| 2020 |
|
| 2021 |
static LLVMValueRef |
| 2022 |
compressed_fetch_cached(struct gallivm_state *gallivm, |
| 2023 |
const struct util_format_description *format_desc, |
| 2024 |
unsigned n, |
| 2025 |
LLVMValueRef base_ptr, |
| 2026 |
LLVMValueRef offset, |
| 2027 |
LLVMValueRef i, |
| 2028 |
LLVMValueRef j, |
| 2029 |
LLVMValueRef cache) |
| 2030 |
|
| 2031 |
{ |
| 2032 |
LLVMBuilderRef builder = gallivm->builder; |
| 2033 |
unsigned count, low_bit, log2size; |
| 2034 |
LLVMValueRef color, offset_stored, addr, ptr_addrtrunc, tmp; |
| 2035 |
LLVMValueRef ij_index, hash_index, hash_mask, block_index; |
| 2036 |
LLVMTypeRef i8t = LLVMInt8TypeInContext(gallivm->context); |
| 2037 |
LLVMTypeRef i32t = LLVMInt32TypeInContext(gallivm->context); |
| 2038 |
LLVMTypeRef i64t = LLVMInt64TypeInContext(gallivm->context); |
| 2039 |
struct lp_type type; |
| 2040 |
struct lp_build_context bld32; |
| 2041 |
memset(&type, 0, sizeof type); |
| 2042 |
type.width = 32; |
| 2043 |
type.length = n; |
| 2044 |
|
| 2045 |
lp_build_context_init(&bld32, gallivm, type); |
| 2046 |
|
| 2047 |
|
| 2048 |
|
| 2049 |
|
| 2050 |
|
| 2051 |
|
| 2052 |
|
| 2053 |
|
| 2054 |
|
| 2055 |
|
| 2056 |
|
| 2057 |
low_bit = util_logbase2(format_desc->block.bits / 8); |
| 2058 |
log2size = util_logbase2(LP_BUILD_FORMAT_CACHE_SIZE); |
| 2059 |
addr = LLVMBuildPtrToInt(builder, base_ptr, i64t, ""); |
| 2060 |
ptr_addrtrunc = LLVMBuildPtrToInt(builder, base_ptr, i32t, ""); |
| 2061 |
ptr_addrtrunc = lp_build_broadcast_scalar(&bld32, ptr_addrtrunc); |
| 2062 |
|
| 2063 |
|
| 2064 |
ptr_addrtrunc = LLVMBuildAdd(builder, offset, ptr_addrtrunc, ""); |
| 2065 |
ptr_addrtrunc = LLVMBuildLShr(builder, ptr_addrtrunc, |
| 2066 |
lp_build_const_int_vec(gallivm, type, low_bit), ""); |
| 2067 |
|
| 2068 |
hash_index = ptr_addrtrunc; |
| 2069 |
ptr_addrtrunc = LLVMBuildLShr(builder, ptr_addrtrunc, |
| 2070 |
lp_build_const_int_vec(gallivm, type, 2*log2size), ""); |
| 2071 |
hash_index = LLVMBuildXor(builder, ptr_addrtrunc, hash_index, ""); |
| 2072 |
tmp = LLVMBuildLShr(builder, hash_index, |
| 2073 |
lp_build_const_int_vec(gallivm, type, log2size), ""); |
| 2074 |
hash_index = LLVMBuildXor(builder, hash_index, tmp, ""); |
| 2075 |
|
| 2076 |
hash_mask = lp_build_const_int_vec(gallivm, type, LP_BUILD_FORMAT_CACHE_SIZE - 1); |
| 2077 |
hash_index = LLVMBuildAnd(builder, hash_index, hash_mask, ""); |
| 2078 |
ij_index = LLVMBuildShl(builder, i, lp_build_const_int_vec(gallivm, type, 2), ""); |
| 2079 |
ij_index = LLVMBuildAdd(builder, ij_index, j, ""); |
| 2080 |
block_index = LLVMBuildShl(builder, hash_index, |
| 2081 |
lp_build_const_int_vec(gallivm, type, 4), ""); |
| 2082 |
block_index = LLVMBuildAdd(builder, ij_index, block_index, ""); |
| 2083 |
|
| 2084 |
if (n > 1) { |
| 2085 |
color = bld32.undef; |
| 2086 |
for (count = 0; count < n; count++) { |
| 2087 |
LLVMValueRef index, cond, colorx; |
| 2088 |
LLVMValueRef block_indexx, hash_indexx, addrx, offsetx, ptr_addrx; |
| 2089 |
struct lp_build_if_state if_ctx; |
| 2090 |
|
| 2091 |
index = lp_build_const_int32(gallivm, count); |
| 2092 |
offsetx = LLVMBuildExtractElement(builder, offset, index, ""); |
| 2093 |
addrx = LLVMBuildZExt(builder, offsetx, i64t, ""); |
| 2094 |
addrx = LLVMBuildAdd(builder, addrx, addr, ""); |
| 2095 |
block_indexx = LLVMBuildExtractElement(builder, block_index, index, ""); |
| 2096 |
hash_indexx = LLVMBuildLShr(builder, block_indexx, |
| 2097 |
lp_build_const_int32(gallivm, 4), ""); |
| 2098 |
offset_stored = s3tc_lookup_tag_data(gallivm, cache, hash_indexx); |
| 2099 |
cond = LLVMBuildICmp(builder, LLVMIntNE, offset_stored, addrx, ""); |
| 2100 |
|
| 2101 |
lp_build_if(&if_ctx, gallivm, cond); |
| 2102 |
{ |
| 2103 |
ptr_addrx = LLVMBuildIntToPtr(builder, addrx, |
| 2104 |
LLVMPointerType(i8t, 0), ""); |
| 2105 |
update_cached_block(gallivm, format_desc, ptr_addrx, hash_indexx, cache); |
| 2106 |
#if LP_BUILD_FORMAT_CACHE_DEBUG |
| 2107 |
s3tc_update_cache_access(gallivm, cache, 1, |
| 2108 |
LP_BUILD_FORMAT_CACHE_MEMBER_ACCESS_MISS); |
| 2109 |
#endif |
| 2110 |
} |
| 2111 |
lp_build_endif(&if_ctx); |
| 2112 |
|
| 2113 |
colorx = s3tc_lookup_cached_pixel(gallivm, cache, block_indexx); |
| 2114 |
|
| 2115 |
color = LLVMBuildInsertElement(builder, color, colorx, |
| 2116 |
lp_build_const_int32(gallivm, count), ""); |
| 2117 |
} |
| 2118 |
} |
| 2119 |
else { |
| 2120 |
LLVMValueRef cond; |
| 2121 |
struct lp_build_if_state if_ctx; |
| 2122 |
|
| 2123 |
tmp = LLVMBuildZExt(builder, offset, i64t, ""); |
| 2124 |
addr = LLVMBuildAdd(builder, tmp, addr, ""); |
| 2125 |
offset_stored = s3tc_lookup_tag_data(gallivm, cache, hash_index); |
| 2126 |
cond = LLVMBuildICmp(builder, LLVMIntNE, offset_stored, addr, ""); |
| 2127 |
|
| 2128 |
lp_build_if(&if_ctx, gallivm, cond); |
| 2129 |
{ |
| 2130 |
tmp = LLVMBuildIntToPtr(builder, addr, LLVMPointerType(i8t, 0), ""); |
| 2131 |
update_cached_block(gallivm, format_desc, tmp, hash_index, cache); |
| 2132 |
#if LP_BUILD_FORMAT_CACHE_DEBUG |
| 2133 |
s3tc_update_cache_access(gallivm, cache, 1, |
| 2134 |
LP_BUILD_FORMAT_CACHE_MEMBER_ACCESS_MISS); |
| 2135 |
#endif |
| 2136 |
} |
| 2137 |
lp_build_endif(&if_ctx); |
| 2138 |
|
| 2139 |
color = s3tc_lookup_cached_pixel(gallivm, cache, block_index); |
| 2140 |
} |
| 2141 |
#if LP_BUILD_FORMAT_CACHE_DEBUG |
| 2142 |
s3tc_update_cache_access(gallivm, cache, n, |
| 2143 |
LP_BUILD_FORMAT_CACHE_MEMBER_ACCESS_TOTAL); |
| 2144 |
#endif |
| 2145 |
return LLVMBuildBitCast(builder, color, LLVMVectorType(i8t, n * 4), ""); |
| 2146 |
} |
| 2147 |
|
| 2148 |
|
| 2149 |
static LLVMValueRef |
| 2150 |
s3tc_dxt5_to_rgba_aos(struct gallivm_state *gallivm, |
| 2151 |
unsigned n, |
| 2152 |
enum pipe_format format, |
| 2153 |
LLVMValueRef colors, |
| 2154 |
LLVMValueRef codewords, |
| 2155 |
LLVMValueRef alpha_lo, |
| 2156 |
LLVMValueRef alpha_hi, |
| 2157 |
LLVMValueRef i, |
| 2158 |
LLVMValueRef j) |
| 2159 |
{ |
| 2160 |
return s3tc_dxt5_full_to_rgba_aos(gallivm, n, format, colors, |
| 2161 |
codewords, alpha_lo, alpha_hi, i, j); |
| 2162 |
} |
| 2163 |
|
| 2164 |
|
| 2165 |
|
| 2166 |
|
| 2167 |
|
| 2168 |
|
| 2169 |
|
| 2170 |
|
| 2171 |
|
| 2172 |
|
| 2173 |
|
| 2174 |
LLVMValueRef |
| 2175 |
lp_build_fetch_s3tc_rgba_aos(struct gallivm_state *gallivm, |
| 2176 |
const struct util_format_description *format_desc, |
| 2177 |
unsigned n, |
| 2178 |
LLVMValueRef base_ptr, |
| 2179 |
LLVMValueRef offset, |
| 2180 |
LLVMValueRef i, |
| 2181 |
LLVMValueRef j, |
| 2182 |
LLVMValueRef cache) |
| 2183 |
{ |
| 2184 |
LLVMValueRef rgba; |
| 2185 |
LLVMTypeRef i8t = LLVMInt8TypeInContext(gallivm->context); |
| 2186 |
LLVMBuilderRef builder = gallivm->builder; |
| 2187 |
|
| 2188 |
assert(format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC); |
| 2189 |
assert(format_desc->block.width == 4); |
| 2190 |
assert(format_desc->block.height == 4); |
| 2191 |
|
| 2192 |
assert((n == 1) || (n % 4 == 0)); |
| 2193 |
|
| 2194 |
|
| 2195 |
if (cache) { |
| 2196 |
rgba = compressed_fetch_cached(gallivm, format_desc, n, |
| 2197 |
base_ptr, offset, i, j, cache); |
| 2198 |
return rgba; |
| 2199 |
} |
| 2200 |
|
| 2201 |
|
| 2202 |
|
| 2203 |
|
| 2204 |
if (n > 4) { |
| 2205 |
unsigned count; |
| 2206 |
LLVMTypeRef i8_vectype = LLVMVectorType(i8t, 4 * n); |
| 2207 |
LLVMTypeRef i128_type = LLVMIntTypeInContext(gallivm->context, 128); |
| 2208 |
LLVMTypeRef i128_vectype = LLVMVectorType(i128_type, n / 4); |
| 2209 |
LLVMTypeRef i324_vectype = LLVMVectorType(LLVMInt32TypeInContext( |
| 2210 |
gallivm->context), 4); |
| 2211 |
LLVMValueRef offset4, i4, j4, rgba4[LP_MAX_VECTOR_LENGTH/16]; |
| 2212 |
struct lp_type lp_324_vectype = lp_type_uint_vec(32, 128); |
| 2213 |
|
| 2214 |
assert(n / 4 <= ARRAY_SIZE(rgba4)); |
| 2215 |
|
| 2216 |
rgba = LLVMGetUndef(i128_vectype); |
| 2217 |
|
| 2218 |
for (count = 0; count < n / 4; count++) { |
| 2219 |
LLVMValueRef colors, codewords, alpha_lo = NULL, alpha_hi = NULL; |
| 2220 |
|
| 2221 |
i4 = lp_build_extract_range(gallivm, i, count * 4, 4); |
| 2222 |
j4 = lp_build_extract_range(gallivm, j, count * 4, 4); |
| 2223 |
offset4 = lp_build_extract_range(gallivm, offset, count * 4, 4); |
| 2224 |
|
| 2225 |
lp_build_gather_s3tc(gallivm, 4, format_desc, &colors, &codewords, |
| 2226 |
&alpha_lo, &alpha_hi, base_ptr, offset4); |
| 2227 |
|
| 2228 |
switch (format_desc->format) { |
| 2229 |
case PIPE_FORMAT_DXT1_RGB: |
| 2230 |
case PIPE_FORMAT_DXT1_RGBA: |
| 2231 |
case PIPE_FORMAT_DXT1_SRGB: |
| 2232 |
case PIPE_FORMAT_DXT1_SRGBA: |
| 2233 |
rgba4[count] = s3tc_dxt1_to_rgba_aos(gallivm, 4, format_desc->format, |
| 2234 |
colors, codewords, i4, j4); |
| 2235 |
break; |
| 2236 |
case PIPE_FORMAT_DXT3_RGBA: |
| 2237 |
case PIPE_FORMAT_DXT3_SRGBA: |
| 2238 |
rgba4[count] = s3tc_dxt3_to_rgba_aos(gallivm, 4, format_desc->format, colors, |
| 2239 |
codewords, alpha_lo, alpha_hi, i4, j4); |
| 2240 |
break; |
| 2241 |
case PIPE_FORMAT_DXT5_RGBA: |
| 2242 |
case PIPE_FORMAT_DXT5_SRGBA: |
| 2243 |
rgba4[count] = s3tc_dxt5_to_rgba_aos(gallivm, 4, format_desc->format, colors, |
| 2244 |
codewords, alpha_lo, alpha_hi, i4, j4); |
| 2245 |
break; |
| 2246 |
default: |
| 2247 |
assert(0); |
| 2248 |
rgba4[count] = LLVMGetUndef(LLVMVectorType(i8t, 4)); |
| 2249 |
break; |
| 2250 |
} |
| 2251 |
|
| 2252 |
rgba4[count] = LLVMBuildBitCast(builder, rgba4[count], i324_vectype, ""); |
| 2253 |
} |
| 2254 |
rgba = lp_build_concat(gallivm, rgba4, lp_324_vectype, n / 4); |
| 2255 |
rgba = LLVMBuildBitCast(builder, rgba, i8_vectype, ""); |
| 2256 |
} |
| 2257 |
else { |
| 2258 |
LLVMValueRef colors, codewords, alpha_lo = NULL, alpha_hi = NULL; |
| 2259 |
|
| 2260 |
lp_build_gather_s3tc(gallivm, n, format_desc, &colors, &codewords, |
| 2261 |
&alpha_lo, &alpha_hi, base_ptr, offset); |
| 2262 |
|
| 2263 |
switch (format_desc->format) { |
| 2264 |
case PIPE_FORMAT_DXT1_RGB: |
| 2265 |
case PIPE_FORMAT_DXT1_RGBA: |
| 2266 |
case PIPE_FORMAT_DXT1_SRGB: |
| 2267 |
case PIPE_FORMAT_DXT1_SRGBA: |
| 2268 |
rgba = s3tc_dxt1_to_rgba_aos(gallivm, n, format_desc->format, |
| 2269 |
colors, codewords, i, j); |
| 2270 |
break; |
| 2271 |
case PIPE_FORMAT_DXT3_RGBA: |
| 2272 |
case PIPE_FORMAT_DXT3_SRGBA: |
| 2273 |
rgba = s3tc_dxt3_to_rgba_aos(gallivm, n, format_desc->format, colors, |
| 2274 |
codewords, alpha_lo, alpha_hi, i, j); |
| 2275 |
break; |
| 2276 |
case PIPE_FORMAT_DXT5_RGBA: |
| 2277 |
case PIPE_FORMAT_DXT5_SRGBA: |
| 2278 |
rgba = s3tc_dxt5_to_rgba_aos(gallivm, n, format_desc->format, colors, |
| 2279 |
codewords, alpha_lo, alpha_hi, i, j); |
| 2280 |
break; |
| 2281 |
default: |
| 2282 |
assert(0); |
| 2283 |
rgba = LLVMGetUndef(LLVMVectorType(i8t, 4*n)); |
| 2284 |
break; |
| 2285 |
} |
| 2286 |
} |
| 2287 |
|
| 2288 |
|
| 2289 |
|
| 2290 |
return rgba; |
| 2291 |
} |
| 2292 |
|
| 2293 |
|
| 2294 |
|
| 2295 |
|
| 2296 |
|
| 2297 |
|
| 2298 |
|
| 2299 |
|
| 2300 |
|
| 2301 |
|
| 2302 |
|
| 2303 |
|
| 2304 |
|
| 2305 |
|
| 2306 |
static void |
| 2307 |
lp_build_gather_rgtc(struct gallivm_state *gallivm, |
| 2308 |
unsigned length, |
| 2309 |
const struct util_format_description *format_desc, |
| 2310 |
LLVMValueRef *red_lo, LLVMValueRef *red_hi, |
| 2311 |
LLVMValueRef *green_lo, LLVMValueRef *green_hi, |
| 2312 |
LLVMValueRef base_ptr, |
| 2313 |
LLVMValueRef offsets) |
| 2314 |
{ |
| 2315 |
LLVMBuilderRef builder = gallivm->builder; |
| 2316 |
unsigned block_bits = format_desc->block.bits; |
| 2317 |
unsigned i; |
| 2318 |
LLVMValueRef elems[8]; |
| 2319 |
LLVMTypeRef type32 = LLVMInt32TypeInContext(gallivm->context); |
| 2320 |
LLVMTypeRef type64 = LLVMInt64TypeInContext(gallivm->context); |
| 2321 |
LLVMTypeRef type32dxt; |
| 2322 |
struct lp_type lp_type32dxt; |
| 2323 |
|
| 2324 |
memset(&lp_type32dxt, 0, sizeof lp_type32dxt); |
| 2325 |
lp_type32dxt.width = 32; |
| 2326 |
lp_type32dxt.length = block_bits / 32; |
| 2327 |
type32dxt = lp_build_vec_type(gallivm, lp_type32dxt); |
| 2328 |
|
| 2329 |
assert(block_bits == 64 || block_bits == 128); |
| 2330 |
assert(length == 1 || length == 4 || length == 8); |
| 2331 |
|
| 2332 |
for (i = 0; i < length; ++i) { |
| 2333 |
elems[i] = lp_build_gather_elem(gallivm, length, |
| 2334 |
block_bits, block_bits, true, |
| 2335 |
base_ptr, offsets, i, false); |
| 2336 |
elems[i] = LLVMBuildBitCast(builder, elems[i], type32dxt, ""); |
| 2337 |
} |
| 2338 |
if (length == 1) { |
| 2339 |
LLVMValueRef elem = elems[0]; |
| 2340 |
|
| 2341 |
*red_lo = LLVMBuildExtractElement(builder, elem, |
| 2342 |
lp_build_const_int32(gallivm, 0), ""); |
| 2343 |
*red_hi = LLVMBuildExtractElement(builder, elem, |
| 2344 |
lp_build_const_int32(gallivm, 1), ""); |
| 2345 |
|
| 2346 |
if (block_bits == 128) { |
| 2347 |
*green_lo = LLVMBuildExtractElement(builder, elem, |
| 2348 |
lp_build_const_int32(gallivm, 2), ""); |
| 2349 |
*green_hi = LLVMBuildExtractElement(builder, elem, |
| 2350 |
lp_build_const_int32(gallivm, 3), ""); |
| 2351 |
} else { |
| 2352 |
*green_lo = NULL; |
| 2353 |
*green_hi = NULL; |
| 2354 |
} |
| 2355 |
} else { |
| 2356 |
LLVMValueRef tmp[4]; |
| 2357 |
struct lp_type lp_type32, lp_type64; |
| 2358 |
memset(&lp_type32, 0, sizeof lp_type32); |
| 2359 |
lp_type32.width = 32; |
| 2360 |
lp_type32.length = length; |
| 2361 |
lp_type32.sign = lp_type32dxt.sign; |
| 2362 |
memset(&lp_type64, 0, sizeof lp_type64); |
| 2363 |
lp_type64.width = 64; |
| 2364 |
lp_type64.length = length/2; |
| 2365 |
if (block_bits == 128) { |
| 2366 |
if (length == 8) { |
| 2367 |
for (i = 0; i < 4; ++i) { |
| 2368 |
tmp[0] = elems[i]; |
| 2369 |
tmp[1] = elems[i+4]; |
| 2370 |
elems[i] = lp_build_concat(gallivm, tmp, lp_type32dxt, 2); |
| 2371 |
} |
| 2372 |
} |
| 2373 |
lp_build_transpose_aos(gallivm, lp_type32, elems, tmp); |
| 2374 |
*green_lo = tmp[2]; |
| 2375 |
*green_hi = tmp[3]; |
| 2376 |
*red_lo = tmp[0]; |
| 2377 |
*red_hi = tmp[1]; |
| 2378 |
} else { |
| 2379 |
LLVMValueRef red01, red23; |
| 2380 |
LLVMTypeRef type64_vec = LLVMVectorType(type64, length/2); |
| 2381 |
LLVMTypeRef type32_vec = LLVMVectorType(type32, length); |
| 2382 |
|
| 2383 |
for (i = 0; i < length; ++i) { |
| 2384 |
|
| 2385 |
elems[i] = LLVMBuildShuffleVector(builder, elems[i], |
| 2386 |
LLVMGetUndef(type32dxt), |
| 2387 |
lp_build_const_extend_shuffle(gallivm, 2, 4), ""); |
| 2388 |
} |
| 2389 |
if (length == 8) { |
| 2390 |
struct lp_type lp_type32_4 = {0}; |
| 2391 |
lp_type32_4.width = 32; |
| 2392 |
lp_type32_4.length = 4; |
| 2393 |
for (i = 0; i < 4; ++i) { |
| 2394 |
tmp[0] = elems[i]; |
| 2395 |
tmp[1] = elems[i+4]; |
| 2396 |
elems[i] = lp_build_concat(gallivm, tmp, lp_type32_4, 2); |
| 2397 |
} |
| 2398 |
} |
| 2399 |
red01 = lp_build_interleave2_half(gallivm, lp_type32, elems[0], elems[1], 0); |
| 2400 |
red23 = lp_build_interleave2_half(gallivm, lp_type32, elems[2], elems[3], 0); |
| 2401 |
red01 = LLVMBuildBitCast(builder, red01, type64_vec, ""); |
| 2402 |
red23 = LLVMBuildBitCast(builder, red23, type64_vec, ""); |
| 2403 |
*red_lo = lp_build_interleave2_half(gallivm, lp_type64, red01, red23, 0); |
| 2404 |
*red_hi = lp_build_interleave2_half(gallivm, lp_type64, red01, red23, 1); |
| 2405 |
*red_lo = LLVMBuildBitCast(builder, *red_lo, type32_vec, ""); |
| 2406 |
*red_hi = LLVMBuildBitCast(builder, *red_hi, type32_vec, ""); |
| 2407 |
*green_lo = NULL; |
| 2408 |
*green_hi = NULL; |
| 2409 |
} |
| 2410 |
} |
| 2411 |
} |
| 2412 |
|
| 2413 |
static LLVMValueRef |
| 2414 |
rgtc1_to_rgba_aos(struct gallivm_state *gallivm, |
| 2415 |
unsigned n, |
| 2416 |
enum pipe_format format, |
| 2417 |
LLVMValueRef red_lo, |
| 2418 |
LLVMValueRef red_hi, |
| 2419 |
LLVMValueRef i, |
| 2420 |
LLVMValueRef j) |
| 2421 |
{ |
| 2422 |
LLVMBuilderRef builder = gallivm->builder; |
| 2423 |
bool is_signed = (format == PIPE_FORMAT_RGTC1_SNORM); |
| 2424 |
LLVMValueRef red = s3tc_dxt5_alpha_channel(gallivm, is_signed, n, red_hi, red_lo, i, j); |
| 2425 |
LLVMValueRef rgba; |
| 2426 |
struct lp_type type, type8; |
| 2427 |
memset(&type, 0, sizeof type); |
| 2428 |
type.width = 32; |
| 2429 |
type.length = n; |
| 2430 |
memset(&type8, 0, sizeof type8); |
| 2431 |
type8.width = 8; |
| 2432 |
type8.length = n*4; |
| 2433 |
rgba = lp_build_const_int_vec(gallivm, type, is_signed ? (0x7f << 24) : (0xffu << 24)); |
| 2434 |
rgba = LLVMBuildOr(builder, rgba, red, ""); |
| 2435 |
return LLVMBuildBitCast(builder, rgba, lp_build_vec_type(gallivm, type8), ""); |
| 2436 |
} |
| 2437 |
|
| 2438 |
static LLVMValueRef |
| 2439 |
rgtc2_to_rgba_aos(struct gallivm_state *gallivm, |
| 2440 |
unsigned n, |
| 2441 |
enum pipe_format format, |
| 2442 |
LLVMValueRef red_lo, |
| 2443 |
LLVMValueRef red_hi, |
| 2444 |
LLVMValueRef green_lo, |
| 2445 |
LLVMValueRef green_hi, |
| 2446 |
LLVMValueRef i, |
| 2447 |
LLVMValueRef j) |
| 2448 |
{ |
| 2449 |
LLVMBuilderRef builder = gallivm->builder; |
| 2450 |
bool is_signed = (format == PIPE_FORMAT_RGTC2_SNORM); |
| 2451 |
LLVMValueRef red = s3tc_dxt5_alpha_channel(gallivm, is_signed, n, red_hi, red_lo, i, j); |
| 2452 |
LLVMValueRef green = s3tc_dxt5_alpha_channel(gallivm, is_signed, n, green_hi, green_lo, i, j); |
| 2453 |
LLVMValueRef rgba; |
| 2454 |
struct lp_type type, type8; |
| 2455 |
memset(&type, 0, sizeof type); |
| 2456 |
type.width = 32; |
| 2457 |
type.length = n; |
| 2458 |
memset(&type8, 0, sizeof type8); |
| 2459 |
type8.width = 8; |
| 2460 |
type8.length = n*4; |
| 2461 |
rgba = lp_build_const_int_vec(gallivm, type, is_signed ? (0x7f << 24) : (0xffu << 24)); |
| 2462 |
rgba = LLVMBuildOr(builder, rgba, red, ""); |
| 2463 |
green = LLVMBuildShl(builder, green, lp_build_const_int_vec(gallivm, type, 8), ""); |
| 2464 |
rgba = LLVMBuildOr(builder, rgba, green, ""); |
| 2465 |
return LLVMBuildBitCast(builder, rgba, lp_build_vec_type(gallivm, type8), ""); |
| 2466 |
} |
| 2467 |
|
| 2468 |
static LLVMValueRef |
| 2469 |
latc1_to_rgba_aos(struct gallivm_state *gallivm, |
| 2470 |
unsigned n, |
| 2471 |
enum pipe_format format, |
| 2472 |
LLVMValueRef red_lo, |
| 2473 |
LLVMValueRef red_hi, |
| 2474 |
LLVMValueRef i, |
| 2475 |
LLVMValueRef j) |
| 2476 |
{ |
| 2477 |
LLVMBuilderRef builder = gallivm->builder; |
| 2478 |
bool is_signed = (format == PIPE_FORMAT_LATC1_SNORM); |
| 2479 |
LLVMValueRef red = s3tc_dxt5_alpha_channel(gallivm, is_signed, n, red_hi, red_lo, i, j); |
| 2480 |
LLVMValueRef rgba, temp; |
| 2481 |
struct lp_type type, type8; |
| 2482 |
memset(&type, 0, sizeof type); |
| 2483 |
type.width = 32; |
| 2484 |
type.length = n; |
| 2485 |
memset(&type8, 0, sizeof type8); |
| 2486 |
type8.width = 8; |
| 2487 |
type8.length = n*4; |
| 2488 |
rgba = lp_build_const_int_vec(gallivm, type, is_signed ? (0x7f << 24) : (0xffu << 24)); |
| 2489 |
rgba = LLVMBuildOr(builder, rgba, red, ""); |
| 2490 |
temp = LLVMBuildShl(builder, red, lp_build_const_int_vec(gallivm, type, 8), ""); |
| 2491 |
rgba = LLVMBuildOr(builder, rgba, temp, ""); |
| 2492 |
temp = LLVMBuildShl(builder, red, lp_build_const_int_vec(gallivm, type, 16), ""); |
| 2493 |
rgba = LLVMBuildOr(builder, rgba, temp, ""); |
| 2494 |
return LLVMBuildBitCast(builder, rgba, lp_build_vec_type(gallivm, type8), ""); |
| 2495 |
} |
| 2496 |
|
| 2497 |
static LLVMValueRef |
| 2498 |
latc2_to_rgba_aos(struct gallivm_state *gallivm, |
| 2499 |
unsigned n, |
| 2500 |
enum pipe_format format, |
| 2501 |
LLVMValueRef red_lo, |
| 2502 |
LLVMValueRef red_hi, |
| 2503 |
LLVMValueRef green_lo, |
| 2504 |
LLVMValueRef green_hi, |
| 2505 |
LLVMValueRef i, |
| 2506 |
LLVMValueRef j) |
| 2507 |
{ |
| 2508 |
LLVMBuilderRef builder = gallivm->builder; |
| 2509 |
bool is_signed = (format == PIPE_FORMAT_LATC2_SNORM); |
| 2510 |
LLVMValueRef red = s3tc_dxt5_alpha_channel(gallivm, is_signed, n, red_hi, red_lo, i, j); |
| 2511 |
LLVMValueRef green = s3tc_dxt5_alpha_channel(gallivm, is_signed, n, green_hi, green_lo, i, j); |
| 2512 |
LLVMValueRef rgba, temp; |
| 2513 |
struct lp_type type, type8; |
| 2514 |
memset(&type, 0, sizeof type); |
| 2515 |
type.width = 32; |
| 2516 |
type.length = n; |
| 2517 |
memset(&type8, 0, sizeof type8); |
| 2518 |
type8.width = 8; |
| 2519 |
type8.length = n*4; |
| 2520 |
|
| 2521 |
temp = LLVMBuildShl(builder, red, lp_build_const_int_vec(gallivm, type, 8), ""); |
| 2522 |
rgba = LLVMBuildOr(builder, red, temp, ""); |
| 2523 |
temp = LLVMBuildShl(builder, red, lp_build_const_int_vec(gallivm, type, 16), ""); |
| 2524 |
rgba = LLVMBuildOr(builder, rgba, temp, ""); |
| 2525 |
temp = LLVMBuildShl(builder, green, lp_build_const_int_vec(gallivm, type, 24), ""); |
| 2526 |
rgba = LLVMBuildOr(builder, rgba, temp, ""); |
| 2527 |
return LLVMBuildBitCast(builder, rgba, lp_build_vec_type(gallivm, type8), ""); |
| 2528 |
} |
| 2529 |
|
| 2530 |
|
| 2531 |
|
| 2532 |
|
| 2533 |
|
| 2534 |
|
| 2535 |
|
| 2536 |
|
| 2537 |
|
| 2538 |
|
| 2539 |
LLVMValueRef |
| 2540 |
lp_build_fetch_rgtc_rgba_aos(struct gallivm_state *gallivm, |
| 2541 |
const struct util_format_description *format_desc, |
| 2542 |
unsigned n, |
| 2543 |
LLVMValueRef base_ptr, |
| 2544 |
LLVMValueRef offset, |
| 2545 |
LLVMValueRef i, |
| 2546 |
LLVMValueRef j, |
| 2547 |
LLVMValueRef cache) |
| 2548 |
{ |
| 2549 |
LLVMValueRef rgba; |
| 2550 |
LLVMTypeRef i8t = LLVMInt8TypeInContext(gallivm->context); |
| 2551 |
LLVMBuilderRef builder = gallivm->builder; |
| 2552 |
LLVMValueRef red_lo, red_hi, green_lo, green_hi; |
| 2553 |
assert(format_desc->layout == UTIL_FORMAT_LAYOUT_RGTC); |
| 2554 |
assert(format_desc->block.width == 4); |
| 2555 |
assert(format_desc->block.height == 4); |
| 2556 |
|
| 2557 |
assert((n == 1) || (n % 4 == 0)); |
| 2558 |
|
| 2559 |
if (n > 4) { |
| 2560 |
unsigned count; |
| 2561 |
LLVMTypeRef i128_type = LLVMIntTypeInContext(gallivm->context, 128); |
| 2562 |
LLVMTypeRef i128_vectype = LLVMVectorType(i128_type, n / 4); |
| 2563 |
LLVMTypeRef i8_vectype = LLVMVectorType(i8t, 4 * n); |
| 2564 |
LLVMTypeRef i324_vectype = LLVMVectorType(LLVMInt32TypeInContext( |
| 2565 |
gallivm->context), 4); |
| 2566 |
LLVMValueRef offset4, i4, j4, rgba4[LP_MAX_VECTOR_LENGTH/16]; |
| 2567 |
struct lp_type lp_324_vectype = lp_type_uint_vec(32, 128); |
| 2568 |
|
| 2569 |
rgba = LLVMGetUndef(i128_vectype); |
| 2570 |
|
| 2571 |
for (count = 0; count < n / 4; count++) { |
| 2572 |
|
| 2573 |
i4 = lp_build_extract_range(gallivm, i, count * 4, 4); |
| 2574 |
j4 = lp_build_extract_range(gallivm, j, count * 4, 4); |
| 2575 |
offset4 = lp_build_extract_range(gallivm, offset, count * 4, 4); |
| 2576 |
|
| 2577 |
lp_build_gather_rgtc(gallivm, 4, format_desc, &red_lo, &red_hi, |
| 2578 |
&green_lo, &green_hi, base_ptr, offset4); |
| 2579 |
|
| 2580 |
switch (format_desc->format) { |
| 2581 |
case PIPE_FORMAT_RGTC1_UNORM: |
| 2582 |
case PIPE_FORMAT_RGTC1_SNORM: |
| 2583 |
rgba4[count] = rgtc1_to_rgba_aos(gallivm, 4, format_desc->format, |
| 2584 |
red_lo, red_hi, i4, j4); |
| 2585 |
break; |
| 2586 |
case PIPE_FORMAT_RGTC2_UNORM: |
| 2587 |
case PIPE_FORMAT_RGTC2_SNORM: |
| 2588 |
rgba4[count] = rgtc2_to_rgba_aos(gallivm, 4, format_desc->format, |
| 2589 |
red_lo, red_hi, green_lo, green_hi, i4, j4); |
| 2590 |
break; |
| 2591 |
case PIPE_FORMAT_LATC1_UNORM: |
| 2592 |
case PIPE_FORMAT_LATC1_SNORM: |
| 2593 |
rgba4[count] = latc1_to_rgba_aos(gallivm, 4, format_desc->format, |
| 2594 |
red_lo, red_hi, i4, j4); |
| 2595 |
break; |
| 2596 |
case PIPE_FORMAT_LATC2_UNORM: |
| 2597 |
case PIPE_FORMAT_LATC2_SNORM: |
| 2598 |
rgba4[count] = latc2_to_rgba_aos(gallivm, 4, format_desc->format, |
| 2599 |
red_lo, red_hi, green_lo, green_hi, i4, j4); |
| 2600 |
break; |
| 2601 |
default: |
| 2602 |
assert(0); |
| 2603 |
rgba4[count] = LLVMGetUndef(LLVMVectorType(i8t, 4)); |
| 2604 |
break; |
| 2605 |
} |
| 2606 |
|
| 2607 |
rgba4[count] = LLVMBuildBitCast(builder, rgba4[count], i324_vectype, ""); |
| 2608 |
} |
| 2609 |
rgba = lp_build_concat(gallivm, rgba4, lp_324_vectype, n / 4); |
| 2610 |
rgba = LLVMBuildBitCast(builder, rgba, i8_vectype, ""); |
| 2611 |
} else { |
| 2612 |
LLVMValueRef red_lo, red_hi, green_lo, green_hi; |
| 2613 |
|
| 2614 |
lp_build_gather_rgtc(gallivm, n, format_desc, &red_lo, &red_hi, |
| 2615 |
&green_lo, &green_hi, base_ptr, offset); |
| 2616 |
|
| 2617 |
switch (format_desc->format) { |
| 2618 |
case PIPE_FORMAT_RGTC1_UNORM: |
| 2619 |
case PIPE_FORMAT_RGTC1_SNORM: |
| 2620 |
rgba = rgtc1_to_rgba_aos(gallivm, n, format_desc->format, |
| 2621 |
red_lo, red_hi, i, j); |
| 2622 |
break; |
| 2623 |
case PIPE_FORMAT_RGTC2_UNORM: |
| 2624 |
case PIPE_FORMAT_RGTC2_SNORM: |
| 2625 |
rgba = rgtc2_to_rgba_aos(gallivm, n, format_desc->format, |
| 2626 |
red_lo, red_hi, green_lo, green_hi, i, j); |
| 2627 |
break; |
| 2628 |
case PIPE_FORMAT_LATC1_UNORM: |
| 2629 |
case PIPE_FORMAT_LATC1_SNORM: |
| 2630 |
rgba = latc1_to_rgba_aos(gallivm, n, format_desc->format, |
| 2631 |
red_lo, red_hi, i, j); |
| 2632 |
break; |
| 2633 |
case PIPE_FORMAT_LATC2_UNORM: |
| 2634 |
case PIPE_FORMAT_LATC2_SNORM: |
| 2635 |
rgba = latc2_to_rgba_aos(gallivm, n, format_desc->format, |
| 2636 |
red_lo, red_hi, green_lo, green_hi, i, j); |
| 2637 |
break; |
| 2638 |
default: |
| 2639 |
assert(0); |
| 2640 |
rgba = LLVMGetUndef(LLVMVectorType(i8t, 4*n)); |
| 2641 |
break; |
| 2642 |
} |
| 2643 |
} |
| 2644 |
return rgba; |
| 2645 |
} |