| 1 |
|
| 2 |
#include "../sfn_instr_alugroup.h" |
| 3 |
#include "../sfn_instr_export.h" |
| 4 |
#include "../sfn_instr_fetch.h" |
| 5 |
#include "../sfn_instr_lds.h" |
| 6 |
#include "../sfn_instr_tex.h" |
| 7 |
|
| 8 |
#include "gtest/gtest.h" |
| 9 |
|
| 10 |
using namespace r600; |
| 11 |
|
| 12 |
using std::vector; |
| 13 |
|
| 14 |
class InstrTest : public ::testing::Test { |
| 15 |
void SetUp() override { init_pool(); } |
| 16 |
|
| 17 |
void TearDown() override { release_pool(); } |
| 18 |
|
| 19 |
protected: |
| 20 |
void check(const Instr& lhs, const Instr& rhs) const { EXPECT_EQ(lhs, rhs); } |
| 21 |
}; |
| 22 |
|
| 23 |
TEST_F(InstrTest, test_alu_barrier) |
| 24 |
{ |
| 25 |
AluInstr alu(op0_group_barrier); |
| 26 |
|
| 27 |
EXPECT_FALSE(alu.has_alu_flag(alu_write)); |
| 28 |
EXPECT_EQ(alu.opcode(), op0_group_barrier); |
| 29 |
|
| 30 |
EXPECT_EQ(alu.dest_chan(), 0); |
| 31 |
|
| 32 |
EXPECT_EQ(alu, alu); |
| 33 |
} |
| 34 |
|
| 35 |
TEST_F(InstrTest, test_alu_uni_op_mov) |
| 36 |
{ |
| 37 |
AluInstr alu(op1_mov, |
| 38 |
new Register(128, 2, pin_none), |
| 39 |
new Register(129, 0, pin_chan), |
| 40 |
AluInstr::write); |
| 41 |
|
| 42 |
EXPECT_TRUE(alu.has_alu_flag(alu_write)); |
| 43 |
|
| 44 |
EXPECT_FALSE(alu.has_alu_flag(alu_last_instr)); |
| 45 |
EXPECT_FALSE(alu.end_group()); |
| 46 |
EXPECT_FALSE(alu.has_alu_flag(alu_op3)); |
| 47 |
EXPECT_FALSE(alu.has_source_mod(0, AluInstr::mod_abs)); |
| 48 |
EXPECT_FALSE(alu.has_source_mod(0, AluInstr::mod_neg)); |
| 49 |
|
| 50 |
EXPECT_EQ(alu.opcode(), op1_mov); |
| 51 |
|
| 52 |
EXPECT_EQ(alu.dest_chan(), 2); |
| 53 |
auto dest = alu.dest(); |
| 54 |
|
| 55 |
ASSERT_TRUE(dest); |
| 56 |
EXPECT_EQ(dest->sel(), 128); |
| 57 |
EXPECT_EQ(dest->chan(), 2); |
| 58 |
EXPECT_EQ(dest->pin(), pin_none); |
| 59 |
|
| 60 |
auto src0 = alu.psrc(0); |
| 61 |
ASSERT_TRUE(src0); |
| 62 |
|
| 63 |
EXPECT_EQ(src0->sel(), 129); |
| 64 |
EXPECT_EQ(src0->chan(), 0); |
| 65 |
EXPECT_EQ(src0->pin(), pin_chan); |
| 66 |
|
| 67 |
EXPECT_EQ(alu.n_sources(), 1); |
| 68 |
|
| 69 |
EXPECT_FALSE(alu.psrc(1)); |
| 70 |
EXPECT_FALSE(alu.psrc(2)); |
| 71 |
|
| 72 |
alu.set_source_mod(0, AluInstr::mod_abs);; |
| 73 |
EXPECT_TRUE(alu.has_source_mod(0, AluInstr::mod_abs)); |
| 74 |
|
| 75 |
alu.set_source_mod(0, AluInstr::mod_neg); |
| 76 |
EXPECT_TRUE(alu.has_source_mod(0, AluInstr::mod_neg)); |
| 77 |
} |
| 78 |
|
| 79 |
TEST_F(InstrTest, test_alu_op2) |
| 80 |
{ |
| 81 |
AluInstr alu(op2_add, |
| 82 |
new Register(130, 1, pin_none), |
| 83 |
new Register(129, 2, pin_chan), |
| 84 |
new Register(129, 3, pin_none), |
| 85 |
{alu_write, alu_last_instr}); |
| 86 |
|
| 87 |
EXPECT_TRUE(alu.has_alu_flag(alu_write)); |
| 88 |
|
| 89 |
EXPECT_TRUE(alu.has_alu_flag(alu_last_instr)); |
| 90 |
EXPECT_FALSE(alu.has_alu_flag(alu_op3)); |
| 91 |
|
| 92 |
EXPECT_FALSE(alu.has_source_mod(0, AluInstr::mod_neg)); |
| 93 |
EXPECT_FALSE(alu.has_source_mod(1, AluInstr::mod_neg)); |
| 94 |
EXPECT_FALSE(alu.has_source_mod(2, AluInstr::mod_neg)); |
| 95 |
|
| 96 |
EXPECT_FALSE(alu.has_alu_flag(alu_src0_rel)); |
| 97 |
EXPECT_FALSE(alu.has_alu_flag(alu_src1_rel)); |
| 98 |
EXPECT_FALSE(alu.has_alu_flag(alu_src2_rel)); |
| 99 |
|
| 100 |
EXPECT_EQ(alu.opcode(), op2_add); |
| 101 |
|
| 102 |
EXPECT_EQ(alu.dest_chan(), 1); |
| 103 |
auto dest = alu.dest(); |
| 104 |
|
| 105 |
ASSERT_TRUE(dest); |
| 106 |
EXPECT_EQ(dest->sel(), 130); |
| 107 |
EXPECT_EQ(dest->chan(), 1); |
| 108 |
EXPECT_EQ(dest->pin(), pin_none); |
| 109 |
|
| 110 |
EXPECT_EQ(alu.n_sources(), 2); |
| 111 |
|
| 112 |
auto src0 = alu.psrc(0); |
| 113 |
ASSERT_TRUE(src0); |
| 114 |
|
| 115 |
EXPECT_EQ(src0->sel(), 129); |
| 116 |
EXPECT_EQ(src0->chan(), 2); |
| 117 |
EXPECT_EQ(src0->pin(), pin_chan); |
| 118 |
|
| 119 |
auto src1 = alu.psrc(1); |
| 120 |
ASSERT_TRUE(src1); |
| 121 |
|
| 122 |
EXPECT_EQ(src1->sel(), 129); |
| 123 |
EXPECT_EQ(src1->chan(), 3); |
| 124 |
EXPECT_EQ(src1->pin(), pin_none); |
| 125 |
|
| 126 |
EXPECT_FALSE(alu.psrc(2)); |
| 127 |
EXPECT_EQ(alu, alu); |
| 128 |
} |
| 129 |
|
| 130 |
TEST_F(InstrTest, test_alu_op3) |
| 131 |
{ |
| 132 |
AluInstr alu(op3_cnde, |
| 133 |
new Register(130, 1, pin_none), |
| 134 |
new Register(129, 2, pin_chan), |
| 135 |
new Register(129, 3, pin_none), |
| 136 |
new Register(131, 1, pin_none), |
| 137 |
{alu_write, alu_last_instr}); |
| 138 |
|
| 139 |
EXPECT_TRUE(alu.has_alu_flag(alu_write)); |
| 140 |
EXPECT_TRUE(alu.has_alu_flag(alu_last_instr)); |
| 141 |
EXPECT_TRUE(alu.end_group()); |
| 142 |
EXPECT_TRUE(alu.has_alu_flag(alu_op3)); |
| 143 |
|
| 144 |
EXPECT_EQ(alu.opcode(), op3_cnde); |
| 145 |
|
| 146 |
EXPECT_EQ(alu.dest_chan(), 1); |
| 147 |
auto dest = alu.dest(); |
| 148 |
|
| 149 |
ASSERT_TRUE(dest); |
| 150 |
EXPECT_EQ(dest->sel(), 130); |
| 151 |
EXPECT_EQ(dest->chan(), 1); |
| 152 |
EXPECT_EQ(dest->pin(), pin_none); |
| 153 |
|
| 154 |
EXPECT_EQ(alu.n_sources(), 3); |
| 155 |
|
| 156 |
auto src0 = alu.psrc(0); |
| 157 |
ASSERT_TRUE(src0); |
| 158 |
|
| 159 |
EXPECT_EQ(src0->sel(), 129); |
| 160 |
EXPECT_EQ(src0->chan(), 2); |
| 161 |
EXPECT_EQ(src0->pin(), pin_chan); |
| 162 |
|
| 163 |
auto src1 = alu.psrc(1); |
| 164 |
ASSERT_TRUE(src1); |
| 165 |
|
| 166 |
EXPECT_EQ(src1->sel(), 129); |
| 167 |
EXPECT_EQ(src1->chan(), 3); |
| 168 |
EXPECT_EQ(src1->pin(), pin_none); |
| 169 |
|
| 170 |
auto src2 = alu.psrc(2); |
| 171 |
ASSERT_TRUE(src2); |
| 172 |
|
| 173 |
EXPECT_EQ(src2->sel(), 131); |
| 174 |
EXPECT_EQ(src2->chan(), 1); |
| 175 |
EXPECT_EQ(src2->pin(), pin_none); |
| 176 |
|
| 177 |
EXPECT_EQ(alu, alu); |
| 178 |
} |
| 179 |
|
| 180 |
TEST_F(InstrTest, test_alu_op1_comp) |
| 181 |
{ |
| 182 |
auto r128z = new Register(128, 2, pin_none); |
| 183 |
auto r128zc = new Register(128, 2, pin_chan); |
| 184 |
auto r128y = new Register(128, 1, pin_none); |
| 185 |
auto r129x = new Register(129, 0, pin_none); |
| 186 |
auto r129xc = new Register(129, 0, pin_chan); |
| 187 |
auto r129y = new Register(129, 1, pin_none); |
| 188 |
auto r130x = new Register(130, 0, pin_none); |
| 189 |
|
| 190 |
AluInstr alu1(op1_mov, r128z, r129x, AluInstr::write); |
| 191 |
EXPECT_NE(alu1, AluInstr(op1_mov, r128y, r129x, AluInstr::write)); |
| 192 |
EXPECT_NE(alu1, AluInstr(op1_mov, r128z, r129xc, AluInstr::write)); |
| 193 |
EXPECT_NE(alu1, AluInstr(op1_mov, r128z, r129y, AluInstr::write)); |
| 194 |
EXPECT_NE(alu1, AluInstr(op1_mov, r128z, r130x, AluInstr::write)); |
| 195 |
EXPECT_NE(alu1, AluInstr(op1_mov, r128z, r129x, {alu_write, alu_last_instr})); |
| 196 |
EXPECT_NE(alu1, AluInstr(op1_flt_to_int, r128z, r129x, AluInstr::write)); |
| 197 |
EXPECT_NE(alu1, AluInstr(op1_mov, r128zc, r129x, AluInstr::write)); |
| 198 |
|
| 199 |
EXPECT_EQ(alu1, alu1); |
| 200 |
} |
| 201 |
|
| 202 |
TEST_F(InstrTest, test_alu_op2_comp) |
| 203 |
{ |
| 204 |
auto r128x = new Register(128, 0, pin_none); |
| 205 |
auto r128y = new Register(128, 1, pin_none); |
| 206 |
auto r128z = new Register(128, 2, pin_none); |
| 207 |
|
| 208 |
AluInstr alu1(op2_add, r128z, r128x, r128y, AluInstr::write); |
| 209 |
|
| 210 |
EXPECT_NE( |
| 211 |
alu1, |
| 212 |
AluInstr(op2_add, r128z, r128x, new Register(129, 2, pin_none), AluInstr::write)); |
| 213 |
EXPECT_NE( |
| 214 |
alu1, |
| 215 |
AluInstr(op2_add, r128z, r128x, new Register(128, 0, pin_none), AluInstr::write)); |
| 216 |
EXPECT_NE( |
| 217 |
alu1, |
| 218 |
AluInstr(op2_add, r128z, r128x, new Register(128, 1, pin_chan), AluInstr::write)); |
| 219 |
} |
| 220 |
|
| 221 |
TEST_F(InstrTest, test_alu_op3_comp) |
| 222 |
{ |
| 223 |
auto r128x = new Register(128, 0, pin_none); |
| 224 |
auto r128y = new Register(128, 1, pin_none); |
| 225 |
auto r128z = new Register(128, 2, pin_none); |
| 226 |
|
| 227 |
AluInstr alu1(op3_muladd, r128z, r128x, r128y, r128y, AluInstr::write); |
| 228 |
|
| 229 |
EXPECT_NE(alu1, |
| 230 |
AluInstr(op3_muladd, |
| 231 |
r128z, |
| 232 |
r128x, |
| 233 |
r128y, |
| 234 |
new Register(129, 2, pin_none), |
| 235 |
AluInstr::write)); |
| 236 |
EXPECT_NE(alu1, |
| 237 |
AluInstr(op3_muladd, |
| 238 |
r128z, |
| 239 |
r128x, |
| 240 |
r128y, |
| 241 |
new Register(128, 0, pin_none), |
| 242 |
AluInstr::write)); |
| 243 |
EXPECT_NE(alu1, |
| 244 |
AluInstr(op3_muladd, |
| 245 |
r128z, |
| 246 |
r128x, |
| 247 |
r128y, |
| 248 |
new Register(128, 1, pin_chan), |
| 249 |
AluInstr::write)); |
| 250 |
} |
| 251 |
|
| 252 |
TEST_F(InstrTest, test_alu_op3_ne) |
| 253 |
{ |
| 254 |
auto R130x = new Register(130, 0, pin_none); |
| 255 |
auto R130y = new Register(130, 1, pin_none); |
| 256 |
auto R130z = new Register(130, 2, pin_none); |
| 257 |
auto R131z = new Register(131, 2, pin_none); |
| 258 |
auto R131w = new Register(131, 3, pin_none); |
| 259 |
|
| 260 |
AluInstr alu(op3_cnde, R130x, R130y, R131z, R131w, {alu_write, alu_last_instr}); |
| 261 |
|
| 262 |
EXPECT_NE( |
| 263 |
alu, AluInstr(op3_muladd, R130x, R130y, R131z, R131w, {alu_write, alu_last_instr})); |
| 264 |
|
| 265 |
EXPECT_NE(alu, |
| 266 |
AluInstr(op3_cnde, R130z, R130y, R131z, R131w, {alu_write, alu_last_instr})); |
| 267 |
EXPECT_NE(alu, |
| 268 |
AluInstr(op3_cnde, R130x, R130z, R131z, R131w, {alu_write, alu_last_instr})); |
| 269 |
EXPECT_NE(alu, |
| 270 |
AluInstr(op3_cnde, R130x, R130y, R130z, R131w, {alu_write, alu_last_instr})); |
| 271 |
EXPECT_NE(alu, |
| 272 |
AluInstr(op3_cnde, R130x, R130y, R131z, R130z, {alu_write, alu_last_instr})); |
| 273 |
EXPECT_NE(alu, AluInstr(op3_cnde, R130x, R130y, R131z, R131w, AluInstr::write)); |
| 274 |
|
| 275 |
AluInstr alu_cf_changes = alu; |
| 276 |
alu_cf_changes.set_cf_type(cf_alu_push_before); |
| 277 |
|
| 278 |
EXPECT_NE(alu, alu_cf_changes); |
| 279 |
|
| 280 |
AluInstr alu_bs_changes = alu; |
| 281 |
alu_bs_changes.set_bank_swizzle(alu_vec_021); |
| 282 |
|
| 283 |
EXPECT_NE(alu, alu_bs_changes); |
| 284 |
}; |
| 285 |
|
| 286 |
TEST_F(InstrTest, test_alu_op1_ne) |
| 287 |
{ |
| 288 |
auto R130x = new Register(130, 0, pin_none); |
| 289 |
auto R130y = new Register(130, 1, pin_none); |
| 290 |
auto R130z = new Register(130, 2, pin_none); |
| 291 |
|
| 292 |
AluInstr alu(op1_mov, R130x, R130y, {alu_write, alu_last_instr}); |
| 293 |
|
| 294 |
EXPECT_NE(alu, AluInstr(op1_cos, R130x, R130y, {alu_write, alu_last_instr})); |
| 295 |
|
| 296 |
EXPECT_NE(alu, AluInstr(op1_mov, R130z, R130y, {alu_write, alu_last_instr})); |
| 297 |
EXPECT_NE(alu, AluInstr(op1_mov, R130x, R130z, {alu_write, alu_last_instr})); |
| 298 |
EXPECT_NE(alu, AluInstr(op1_mov, R130x, R130y, {alu_last_instr})); |
| 299 |
|
| 300 |
AluInstr alu_cf_changes = alu; |
| 301 |
alu_cf_changes.set_cf_type(cf_alu_push_before); |
| 302 |
|
| 303 |
EXPECT_NE(alu, alu_cf_changes); |
| 304 |
|
| 305 |
AluInstr alu_bs_changes = alu; |
| 306 |
alu_bs_changes.set_bank_swizzle(alu_vec_021); |
| 307 |
|
| 308 |
EXPECT_NE(alu, alu_bs_changes); |
| 309 |
}; |
| 310 |
|
| 311 |
TEST_F(InstrTest, test_alu_dot4_grouped) |
| 312 |
{ |
| 313 |
auto R130x = new Register(130, 0, pin_none); |
| 314 |
auto R130y = new Register(130, 1, pin_none); |
| 315 |
auto R130z = new Register(130, 2, pin_none); |
| 316 |
auto R130w = new Register(130, 3, pin_none); |
| 317 |
|
| 318 |
auto R131x = new Register(131, 0, pin_none); |
| 319 |
auto R131y = new Register(131, 1, pin_none); |
| 320 |
auto R131z = new Register(131, 2, pin_none); |
| 321 |
auto R131w = new Register(131, 3, pin_none); |
| 322 |
|
| 323 |
auto R132x = new Register(132, 0, pin_chan); |
| 324 |
|
| 325 |
AluInstr::SrcValues src({R130x, R130y, R130z, R130w, R131x, R131y, R131z, R131w}); |
| 326 |
|
| 327 |
AluInstr alu(op2_dot4_ieee, R132x, src, {alu_write, alu_last_instr}, 4); |
| 328 |
|
| 329 |
EXPECT_NE(alu, AluInstr(op1_cos, R130x, R130y, {alu_write, alu_last_instr})); |
| 330 |
EXPECT_EQ(alu, alu); |
| 331 |
|
| 332 |
ValueFactory vf; |
| 333 |
auto group = new AluGroup(); |
| 334 |
bool result = alu.split(*group); |
| 335 |
group->fix_last_flag(); |
| 336 |
ASSERT_TRUE(result); |
| 337 |
|
| 338 |
auto i = group->begin(); |
| 339 |
EXPECT_NE(i, group->end()); |
| 340 |
ASSERT_TRUE(*i); |
| 341 |
check(**i, AluInstr(op2_dot4_ieee, R132x, R130x, R130y, AluInstr::write)); |
| 342 |
++i; |
| 343 |
EXPECT_NE(i, group->end()); |
| 344 |
ASSERT_TRUE(*i); |
| 345 |
check(**i, AluInstr(op2_dot4_ieee, 1, {R130z, R130w}, AluInstr::empty)); |
| 346 |
++i; |
| 347 |
EXPECT_NE(i, group->end()); |
| 348 |
ASSERT_TRUE(*i); |
| 349 |
check(**i, AluInstr(op2_dot4_ieee, 2, {R131x, R131y}, AluInstr::empty)); |
| 350 |
++i; |
| 351 |
EXPECT_NE(i, group->end()); |
| 352 |
ASSERT_TRUE(*i); |
| 353 |
check(**i, AluInstr(op2_dot4_ieee, 3, {R131z, R131w}, {alu_last_instr})); |
| 354 |
++i; |
| 355 |
EXPECT_NE(i, group->end()); |
| 356 |
ASSERT_FALSE(*i); |
| 357 |
++i; |
| 358 |
EXPECT_EQ(i, group->end()); |
| 359 |
}; |
| 360 |
|
| 361 |
#ifdef __cpp_exceptions |
| 362 |
TEST_F(InstrTest, test_alu_wrong_source_count) |
| 363 |
{ |
| 364 |
EXPECT_THROW(AluInstr(op3_cnde, |
| 365 |
new Register(130, 1, pin_none), |
| 366 |
new Register(129, 2, pin_chan), |
| 367 |
new Register(129, 3, pin_none), |
| 368 |
{alu_write, alu_last_instr}), |
| 369 |
std::invalid_argument); |
| 370 |
|
| 371 |
EXPECT_THROW(AluInstr(op3_cnde, |
| 372 |
new Register(130, 1, pin_none), |
| 373 |
new Register(129, 2, pin_chan), |
| 374 |
{alu_write, alu_last_instr}), |
| 375 |
std::invalid_argument); |
| 376 |
|
| 377 |
EXPECT_THROW(AluInstr(op1_mov, |
| 378 |
new Register(130, 1, pin_none), |
| 379 |
new Register(129, 2, pin_chan), |
| 380 |
new Register(129, 2, pin_chan), |
| 381 |
{alu_write, alu_last_instr}), |
| 382 |
std::invalid_argument); |
| 383 |
|
| 384 |
EXPECT_THROW(AluInstr(op2_add, |
| 385 |
new Register(130, 1, pin_none), |
| 386 |
new Register(129, 2, pin_chan), |
| 387 |
{alu_write, alu_last_instr}), |
| 388 |
std::invalid_argument); |
| 389 |
|
| 390 |
EXPECT_THROW(AluInstr(op2_add, |
| 391 |
new Register(130, 1, pin_none), |
| 392 |
new Register(129, 2, pin_chan), |
| 393 |
new Register(129, 2, pin_chan), |
| 394 |
new Register(129, 2, pin_chan), |
| 395 |
{alu_write, alu_last_instr}), |
| 396 |
std::invalid_argument); |
| 397 |
} |
| 398 |
|
| 399 |
TEST_F(InstrTest, test_alu_write_no_dest) |
| 400 |
{ |
| 401 |
EXPECT_THROW(AluInstr(op2_add, |
| 402 |
nullptr, |
| 403 |
new Register(129, 2, pin_chan), |
| 404 |
new Register(129, 2, pin_chan), |
| 405 |
{alu_write, alu_last_instr}), |
| 406 |
std::invalid_argument); |
| 407 |
} |
| 408 |
|
| 409 |
#endif |
| 410 |
|
| 411 |
TEST_F(InstrTest, test_tex_basic) |
| 412 |
{ |
| 413 |
TexInstr tex( |
| 414 |
TexInstr::sample, RegisterVec4(129), {0, 1, 2, 3}, RegisterVec4(130), 17, nullptr, 1); |
| 415 |
|
| 416 |
EXPECT_EQ(tex.opcode(), TexInstr::sample); |
| 417 |
|
| 418 |
auto& dst = tex.dst(); |
| 419 |
auto& src = tex.src(); |
| 420 |
|
| 421 |
for (int i = 0; i < 4; ++i) { |
| 422 |
EXPECT_EQ(*dst[i], Register(129, i, pin_group)); |
| 423 |
EXPECT_EQ(*src[i], Register(130, i, pin_group)); |
| 424 |
EXPECT_EQ(tex.dest_swizzle(i), i); |
| 425 |
} |
| 426 |
|
| 427 |
EXPECT_EQ(tex.resource_id(), 17); |
| 428 |
EXPECT_EQ(tex.sampler_id(), 1); |
| 429 |
|
| 430 |
EXPECT_TRUE(tex.end_group()); |
| 431 |
|
| 432 |
for (int i = 0; i < 3; ++i) |
| 433 |
EXPECT_EQ(tex.get_offset(i), 0); |
| 434 |
|
| 435 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::x_unnormalized)); |
| 436 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::y_unnormalized)); |
| 437 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::z_unnormalized)); |
| 438 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::w_unnormalized)); |
| 439 |
|
| 440 |
tex.set_tex_flag(TexInstr::x_unnormalized); |
| 441 |
EXPECT_TRUE(tex.has_tex_flag(TexInstr::x_unnormalized)); |
| 442 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::y_unnormalized)); |
| 443 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::z_unnormalized)); |
| 444 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::w_unnormalized)); |
| 445 |
|
| 446 |
tex.set_tex_flag(TexInstr::y_unnormalized); |
| 447 |
EXPECT_TRUE(tex.has_tex_flag(TexInstr::x_unnormalized)); |
| 448 |
EXPECT_TRUE(tex.has_tex_flag(TexInstr::y_unnormalized)); |
| 449 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::z_unnormalized)); |
| 450 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::w_unnormalized)); |
| 451 |
|
| 452 |
tex.set_tex_flag(TexInstr::z_unnormalized); |
| 453 |
tex.set_tex_flag(TexInstr::w_unnormalized); |
| 454 |
EXPECT_TRUE(tex.has_tex_flag(TexInstr::x_unnormalized)); |
| 455 |
EXPECT_TRUE(tex.has_tex_flag(TexInstr::y_unnormalized)); |
| 456 |
EXPECT_TRUE(tex.has_tex_flag(TexInstr::z_unnormalized)); |
| 457 |
EXPECT_TRUE(tex.has_tex_flag(TexInstr::w_unnormalized)); |
| 458 |
|
| 459 |
EXPECT_EQ(tex.inst_mode(), 0); |
| 460 |
|
| 461 |
EXPECT_FALSE(tex.resource_offset()); |
| 462 |
|
| 463 |
tex.set_dest_swizzle({4, 7, 0, 1}); |
| 464 |
EXPECT_EQ(tex.dest_swizzle(0), 4); |
| 465 |
EXPECT_EQ(tex.dest_swizzle(1), 7); |
| 466 |
EXPECT_EQ(tex.dest_swizzle(2), 0); |
| 467 |
EXPECT_EQ(tex.dest_swizzle(3), 1); |
| 468 |
|
| 469 |
tex.set_dest_swizzle({7, 2, 5, 0}); |
| 470 |
EXPECT_EQ(tex.dest_swizzle(0), 7); |
| 471 |
EXPECT_EQ(tex.dest_swizzle(1), 2); |
| 472 |
EXPECT_EQ(tex.dest_swizzle(2), 5); |
| 473 |
EXPECT_EQ(tex.dest_swizzle(3), 0); |
| 474 |
|
| 475 |
tex.set_offset(0, 2); |
| 476 |
tex.set_offset(1, -1); |
| 477 |
tex.set_offset(2, 3); |
| 478 |
|
| 479 |
EXPECT_EQ(tex.get_offset(0), 4); |
| 480 |
EXPECT_EQ(tex.get_offset(1), -2); |
| 481 |
EXPECT_EQ(tex.get_offset(2), 6); |
| 482 |
} |
| 483 |
|
| 484 |
TEST_F(InstrTest, test_tex_gather4) |
| 485 |
{ |
| 486 |
TexInstr tex( |
| 487 |
TexInstr::gather4, RegisterVec4(131), {0, 1, 2, 3}, RegisterVec4(132), 2, nullptr, 19); |
| 488 |
|
| 489 |
EXPECT_EQ(tex.opcode(), TexInstr::gather4); |
| 490 |
|
| 491 |
auto& dst = tex.dst(); |
| 492 |
auto& src = tex.src(); |
| 493 |
|
| 494 |
for (int i = 0; i < 4; ++i) { |
| 495 |
EXPECT_EQ(*dst[i], Register(131, i, pin_group)); |
| 496 |
EXPECT_EQ(*src[i], Register(132, i, pin_group)); |
| 497 |
EXPECT_EQ(tex.dest_swizzle(i), i); |
| 498 |
} |
| 499 |
|
| 500 |
EXPECT_EQ(tex.resource_id(), 2); |
| 501 |
EXPECT_EQ(tex.sampler_id(), 19); |
| 502 |
|
| 503 |
for (int i = 0; i < 3; ++i) |
| 504 |
EXPECT_EQ(tex.get_offset(i), 0); |
| 505 |
|
| 506 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::x_unnormalized)); |
| 507 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::y_unnormalized)); |
| 508 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::z_unnormalized)); |
| 509 |
EXPECT_FALSE(tex.has_tex_flag(TexInstr::w_unnormalized)); |
| 510 |
|
| 511 |
tex.set_gather_comp(2); |
| 512 |
EXPECT_EQ(tex.inst_mode(), 2); |
| 513 |
} |
| 514 |
|
| 515 |
TEST_F(InstrTest, test_tex_neq) |
| 516 |
{ |
| 517 |
TexInstr tex_ref( |
| 518 |
TexInstr::sample, RegisterVec4(129), {0, 1, 2, 3}, RegisterVec4(130), 1, nullptr, 17); |
| 519 |
EXPECT_EQ(tex_ref, tex_ref); |
| 520 |
|
| 521 |
EXPECT_NE( |
| 522 |
tex_ref, |
| 523 |
TexInstr( |
| 524 |
TexInstr::sample_c, RegisterVec4(129), {0, 1, 2, 3}, RegisterVec4(130), 1, nullptr, 17)); |
| 525 |
EXPECT_NE( |
| 526 |
tex_ref, |
| 527 |
TexInstr( |
| 528 |
TexInstr::sample, RegisterVec4(130), {0, 1, 2, 3}, RegisterVec4(130), 1, nullptr, 17)); |
| 529 |
EXPECT_NE( |
| 530 |
tex_ref, |
| 531 |
TexInstr( |
| 532 |
TexInstr::sample, RegisterVec4(130), {0, 1, 2, 3}, RegisterVec4(130), 1, nullptr, 17)); |
| 533 |
|
| 534 |
EXPECT_NE( |
| 535 |
tex_ref, |
| 536 |
TexInstr( |
| 537 |
TexInstr::sample, RegisterVec4(129), {7, 1, 2, 3}, RegisterVec4(130), 1, nullptr, 17)); |
| 538 |
EXPECT_NE( |
| 539 |
tex_ref, |
| 540 |
TexInstr( |
| 541 |
TexInstr::sample, RegisterVec4(129), {0, 7, 2, 3}, RegisterVec4(130), 1, nullptr, 17)); |
| 542 |
EXPECT_NE( |
| 543 |
tex_ref, |
| 544 |
TexInstr( |
| 545 |
TexInstr::sample, RegisterVec4(129), {0, 1, 7, 3}, RegisterVec4(130), 1, nullptr, 17)); |
| 546 |
EXPECT_NE( |
| 547 |
tex_ref, |
| 548 |
TexInstr( |
| 549 |
TexInstr::sample, RegisterVec4(129), {0, 1, 2, 7}, RegisterVec4(130), 1, nullptr, 17)); |
| 550 |
|
| 551 |
EXPECT_NE(tex_ref, |
| 552 |
TexInstr(TexInstr::sample, |
| 553 |
RegisterVec4(129), |
| 554 |
{0, 1, 2, 3}, |
| 555 |
RegisterVec4(130, false, {7, 1, 2, 3}), |
| 556 |
1, |
| 557 |
nullptr, |
| 558 |
17)); |
| 559 |
EXPECT_NE(tex_ref, |
| 560 |
TexInstr(TexInstr::sample, |
| 561 |
RegisterVec4(129), |
| 562 |
{0, 1, 2, 3}, |
| 563 |
RegisterVec4(130, false, {0, 7, 2, 3}), |
| 564 |
1, |
| 565 |
nullptr, |
| 566 |
17)); |
| 567 |
EXPECT_NE(tex_ref, |
| 568 |
TexInstr(TexInstr::sample, |
| 569 |
RegisterVec4(129), |
| 570 |
{0, 1, 2, 3}, |
| 571 |
RegisterVec4(130, false, {0, 1, 7, 3}), |
| 572 |
1, |
| 573 |
nullptr, |
| 574 |
17)); |
| 575 |
EXPECT_NE(tex_ref, |
| 576 |
TexInstr(TexInstr::sample, |
| 577 |
RegisterVec4(129), |
| 578 |
{0, 1, 2, 3}, |
| 579 |
RegisterVec4(130, false, {0, 1, 2, 7}), |
| 580 |
1, |
| 581 |
nullptr, |
| 582 |
17)); |
| 583 |
|
| 584 |
EXPECT_NE( |
| 585 |
tex_ref, |
| 586 |
TexInstr( |
| 587 |
TexInstr::sample, RegisterVec4(129), {0, 1, 2, 3}, RegisterVec4(130), 2, nullptr, 17)); |
| 588 |
EXPECT_NE( |
| 589 |
tex_ref, |
| 590 |
TexInstr( |
| 591 |
TexInstr::sample, RegisterVec4(129), {0, 1, 2, 3}, RegisterVec4(130), 1, nullptr, 18)); |
| 592 |
|
| 593 |
/* |
| 594 |
auto tex_with_sampler_offset = tex_ref; |
| 595 |
tex_with_sampler_offset.set_sampler_offset(new LiteralConstant( 2)); |
| 596 |
EXPECT_NE(tex_ref, tex_with_sampler_offset); |
| 597 |
|
| 598 |
auto tex_cmp1 = tex_ref; |
| 599 |
EXPECT_EQ(tex_ref, tex_cmp1); |
| 600 |
|
| 601 |
tex_cmp1.set_tex_flag(TexInstr::x_unnormalized); EXPECT_NE(tex_ref, tex_cmp1); |
| 602 |
auto tex_cmp2 = tex_ref; tex_cmp2.set_tex_flag(TexInstr::y_unnormalized); |
| 603 |
EXPECT_NE(tex_ref, tex_cmp2); auto tex_cmp3 = tex_ref; |
| 604 |
tex_cmp3.set_tex_flag(TexInstr::z_unnormalized); EXPECT_NE(tex_ref, tex_cmp3); auto |
| 605 |
tex_cmp4 = tex_ref; tex_cmp4.set_tex_flag(TexInstr::w_unnormalized); EXPECT_NE(tex_ref, |
| 606 |
tex_cmp4); |
| 607 |
|
| 608 |
for (int i = 0; i < 3; ++i) { |
| 609 |
auto tex_ofs = tex_ref; |
| 610 |
tex_ofs.set_offset(i, 1); |
| 611 |
EXPECT_NE(tex_ref, tex_ofs); |
| 612 |
} |
| 613 |
|
| 614 |
for (int i = 0; i < 4; ++i) { |
| 615 |
auto tex_swz = tex_ref; |
| 616 |
RegisterVec4::Swizzle dst_swz = {0,1,2,3}; |
| 617 |
dst_swz[i] = 7; |
| 618 |
tex_swz.set_dest_swizzle(dst_swz); |
| 619 |
EXPECT_NE(tex_ref, tex_swz); |
| 620 |
} |
| 621 |
|
| 622 |
auto tex_cmp_mode = tex_ref; |
| 623 |
tex_cmp_mode.set_inst_mode(1); |
| 624 |
EXPECT_NE(tex_ref, tex_cmp_mode);*/ |
| 625 |
} |
| 626 |
|
| 627 |
TEST_F(InstrTest, test_export_basic) |
| 628 |
{ |
| 629 |
ExportInstr exp0(ExportInstr::param, 60, RegisterVec4(200)); |
| 630 |
|
| 631 |
EXPECT_EQ(exp0.export_type(), ExportInstr::param); |
| 632 |
EXPECT_EQ(exp0.location(), 60); |
| 633 |
EXPECT_EQ(exp0.value(), RegisterVec4(200)); |
| 634 |
EXPECT_FALSE(exp0.is_last_export()); |
| 635 |
|
| 636 |
ExportInstr exp1(ExportInstr::param, 60, RegisterVec4(200)); |
| 637 |
exp1.set_is_last_export(true); |
| 638 |
EXPECT_TRUE(exp1.is_last_export()); |
| 639 |
|
| 640 |
EXPECT_EQ(exp0, exp0); |
| 641 |
EXPECT_NE(exp0, exp1); |
| 642 |
|
| 643 |
ExportInstr exp2(ExportInstr::pos, 60, RegisterVec4(200)); |
| 644 |
EXPECT_EQ(exp2.export_type(), ExportInstr::pos); |
| 645 |
EXPECT_NE(exp0, exp2); |
| 646 |
|
| 647 |
ExportInstr exp3(ExportInstr::param, 61, RegisterVec4(200)); |
| 648 |
EXPECT_EQ(exp3.location(), 61); |
| 649 |
EXPECT_NE(exp0, exp3); |
| 650 |
|
| 651 |
ExportInstr exp4(ExportInstr::param, 60, RegisterVec4(201)); |
| 652 |
EXPECT_EQ(exp4.value(), RegisterVec4(201)); |
| 653 |
EXPECT_NE(exp0, exp4); |
| 654 |
|
| 655 |
EXPECT_NE(exp0, |
| 656 |
ExportInstr(ExportInstr::param, 60, RegisterVec4(200, false, {7, 1, 2, 3}))); |
| 657 |
EXPECT_NE(exp0, |
| 658 |
ExportInstr(ExportInstr::param, 60, RegisterVec4(200, false, {0, 7, 2, 3}))); |
| 659 |
EXPECT_NE(exp0, |
| 660 |
ExportInstr(ExportInstr::param, 60, RegisterVec4(200, false, {0, 1, 7, 3}))); |
| 661 |
EXPECT_NE(exp0, |
| 662 |
ExportInstr(ExportInstr::param, 60, RegisterVec4(200, false, {0, 1, 2, 7}))); |
| 663 |
} |
| 664 |
|
| 665 |
TEST_F(InstrTest, test_fetch_basic) |
| 666 |
{ |
| 667 |
FetchInstr fetch(vc_fetch, |
| 668 |
RegisterVec4(200), |
| 669 |
{0, 2, 1, 3}, |
| 670 |
new Register(201, 2, pin_none), |
| 671 |
0, |
| 672 |
vertex_data, |
| 673 |
fmt_8, |
| 674 |
vtx_nf_norm, |
| 675 |
vtx_es_none, |
| 676 |
1, |
| 677 |
nullptr); |
| 678 |
|
| 679 |
EXPECT_EQ(fetch.opcode(), vc_fetch); |
| 680 |
EXPECT_EQ(fetch.dst(), RegisterVec4(200)); |
| 681 |
EXPECT_EQ(fetch.dest_swizzle(0), 0); |
| 682 |
EXPECT_EQ(fetch.dest_swizzle(1), 2); |
| 683 |
EXPECT_EQ(fetch.dest_swizzle(2), 1); |
| 684 |
EXPECT_EQ(fetch.dest_swizzle(3), 3); |
| 685 |
|
| 686 |
EXPECT_EQ(fetch.src(), Register(201, 2, pin_none)); |
| 687 |
EXPECT_EQ(fetch.src_offset(), 0); |
| 688 |
|
| 689 |
EXPECT_EQ(fetch.resource_id(), 1); |
| 690 |
EXPECT_FALSE(fetch.resource_offset()); |
| 691 |
|
| 692 |
EXPECT_EQ(fetch.fetch_type(), vertex_data); |
| 693 |
EXPECT_EQ(fetch.data_format(), fmt_8); |
| 694 |
EXPECT_EQ(fetch.num_format(), vtx_nf_norm); |
| 695 |
EXPECT_EQ(fetch.endian_swap(), vtx_es_none); |
| 696 |
|
| 697 |
EXPECT_EQ(fetch.mega_fetch_count(), 0); |
| 698 |
EXPECT_EQ(fetch.array_base(), 0); |
| 699 |
EXPECT_EQ(fetch.array_size(), 0); |
| 700 |
EXPECT_EQ(fetch.elm_size(), 0); |
| 701 |
|
| 702 |
for (int i = 0; i < FetchInstr::unknown; ++i) { |
| 703 |
EXPECT_FALSE(fetch.has_fetch_flag(static_cast<FetchInstr::EFlags>(i))); |
| 704 |
} |
| 705 |
|
| 706 |
EXPECT_NE(fetch, |
| 707 |
FetchInstr(vc_get_buf_resinfo, |
| 708 |
RegisterVec4(200), |
| 709 |
{0, 2, 1, 3}, |
| 710 |
new Register(201, 2, pin_none), |
| 711 |
0, |
| 712 |
vertex_data, |
| 713 |
fmt_8, |
| 714 |
vtx_nf_norm, |
| 715 |
vtx_es_none, |
| 716 |
1, |
| 717 |
nullptr)); |
| 718 |
|
| 719 |
EXPECT_NE(fetch, |
| 720 |
FetchInstr(vc_fetch, |
| 721 |
RegisterVec4(201), |
| 722 |
{0, 2, 1, 3}, |
| 723 |
new Register(201, 2, pin_none), |
| 724 |
0, |
| 725 |
vertex_data, |
| 726 |
fmt_8, |
| 727 |
vtx_nf_norm, |
| 728 |
vtx_es_none, |
| 729 |
1, |
| 730 |
nullptr)); |
| 731 |
|
| 732 |
EXPECT_NE(fetch, |
| 733 |
FetchInstr(vc_fetch, |
| 734 |
RegisterVec4(200), |
| 735 |
{1, 2, 0, 3}, |
| 736 |
new Register(201, 2, pin_none), |
| 737 |
0, |
| 738 |
vertex_data, |
| 739 |
fmt_8, |
| 740 |
vtx_nf_norm, |
| 741 |
vtx_es_none, |
| 742 |
1, |
| 743 |
nullptr)); |
| 744 |
|
| 745 |
EXPECT_NE(fetch, |
| 746 |
FetchInstr(vc_fetch, |
| 747 |
RegisterVec4(200), |
| 748 |
{0, 2, 1, 3}, |
| 749 |
new Register(200, 2, pin_none), |
| 750 |
0, |
| 751 |
vertex_data, |
| 752 |
fmt_8, |
| 753 |
vtx_nf_norm, |
| 754 |
vtx_es_none, |
| 755 |
1, |
| 756 |
nullptr)); |
| 757 |
|
| 758 |
EXPECT_NE(fetch, |
| 759 |
FetchInstr(vc_fetch, |
| 760 |
RegisterVec4(200), |
| 761 |
{0, 2, 1, 3}, |
| 762 |
new Register(201, 2, pin_none), |
| 763 |
8, |
| 764 |
vertex_data, |
| 765 |
fmt_8, |
| 766 |
vtx_nf_norm, |
| 767 |
vtx_es_none, |
| 768 |
1, |
| 769 |
nullptr)); |
| 770 |
|
| 771 |
EXPECT_NE(fetch, |
| 772 |
FetchInstr(vc_fetch, |
| 773 |
RegisterVec4(200), |
| 774 |
{0, 2, 1, 3}, |
| 775 |
new Register(201, 2, pin_none), |
| 776 |
0, |
| 777 |
instance_data, |
| 778 |
fmt_8, |
| 779 |
vtx_nf_norm, |
| 780 |
vtx_es_none, |
| 781 |
1, |
| 782 |
nullptr)); |
| 783 |
|
| 784 |
EXPECT_NE(fetch, |
| 785 |
FetchInstr(vc_fetch, |
| 786 |
RegisterVec4(200), |
| 787 |
{0, 2, 1, 3}, |
| 788 |
new Register(201, 2, pin_none), |
| 789 |
0, |
| 790 |
vertex_data, |
| 791 |
fmt_8_8, |
| 792 |
vtx_nf_norm, |
| 793 |
vtx_es_none, |
| 794 |
1, |
| 795 |
nullptr)); |
| 796 |
|
| 797 |
EXPECT_NE(fetch, |
| 798 |
FetchInstr(vc_fetch, |
| 799 |
RegisterVec4(200), |
| 800 |
{0, 2, 1, 3}, |
| 801 |
new Register(201, 2, pin_none), |
| 802 |
0, |
| 803 |
vertex_data, |
| 804 |
fmt_8, |
| 805 |
vtx_nf_int, |
| 806 |
vtx_es_none, |
| 807 |
1, |
| 808 |
nullptr)); |
| 809 |
|
| 810 |
EXPECT_NE(fetch, |
| 811 |
FetchInstr(vc_fetch, |
| 812 |
RegisterVec4(200), |
| 813 |
{0, 2, 1, 3}, |
| 814 |
new Register(201, 2, pin_none), |
| 815 |
0, |
| 816 |
vertex_data, |
| 817 |
fmt_8, |
| 818 |
vtx_nf_norm, |
| 819 |
vtx_es_8in16, |
| 820 |
1, |
| 821 |
nullptr)); |
| 822 |
|
| 823 |
EXPECT_NE(fetch, |
| 824 |
FetchInstr(vc_fetch, |
| 825 |
RegisterVec4(200), |
| 826 |
{0, 2, 1, 3}, |
| 827 |
new Register(201, 2, pin_none), |
| 828 |
0, |
| 829 |
vertex_data, |
| 830 |
fmt_8, |
| 831 |
vtx_nf_norm, |
| 832 |
vtx_es_none, |
| 833 |
2, |
| 834 |
nullptr)); |
| 835 |
|
| 836 |
EXPECT_NE(fetch, |
| 837 |
FetchInstr(vc_fetch, |
| 838 |
RegisterVec4(200), |
| 839 |
{0, 2, 1, 3}, |
| 840 |
new Register(201, 2, pin_none), |
| 841 |
0, |
| 842 |
vertex_data, |
| 843 |
fmt_8, |
| 844 |
vtx_nf_norm, |
| 845 |
vtx_es_none, |
| 846 |
1, |
| 847 |
new Register(1000, 0, pin_none))); |
| 848 |
|
| 849 |
auto fetch1 = fetch; |
| 850 |
fetch1.set_mfc(31); |
| 851 |
EXPECT_NE(fetch1, fetch); |
| 852 |
EXPECT_EQ(fetch1.mega_fetch_count(), 31); |
| 853 |
EXPECT_TRUE( |
| 854 |
fetch1.has_fetch_flag(static_cast<FetchInstr::EFlags>(FetchInstr::is_mega_fetch))); |
| 855 |
|
| 856 |
auto fetch2 = fetch; |
| 857 |
fetch2.set_array_base(32); |
| 858 |
EXPECT_NE(fetch, fetch2); |
| 859 |
EXPECT_EQ(fetch2.array_base(), 32); |
| 860 |
|
| 861 |
auto fetch3 = fetch; |
| 862 |
fetch3.set_array_size(16); |
| 863 |
EXPECT_NE(fetch, fetch3); |
| 864 |
EXPECT_EQ(fetch3.array_size(), 16); |
| 865 |
|
| 866 |
auto fetch4 = fetch; |
| 867 |
fetch4.set_element_size(3); |
| 868 |
EXPECT_NE(fetch, fetch4); |
| 869 |
EXPECT_EQ(fetch4.elm_size(), 3); |
| 870 |
} |
| 871 |
|
| 872 |
TEST_F(InstrTest, test_fetch_basic2) |
| 873 |
{ |
| 874 |
FetchInstr fetch(vc_get_buf_resinfo, |
| 875 |
RegisterVec4(201), |
| 876 |
{0, 1, 3, 4}, |
| 877 |
new Register(202, 3, pin_none), |
| 878 |
1, |
| 879 |
no_index_offset, |
| 880 |
fmt_32_32, |
| 881 |
vtx_nf_int, |
| 882 |
vtx_es_8in16, |
| 883 |
3, |
| 884 |
new Register(300, 1, pin_none)); |
| 885 |
|
| 886 |
EXPECT_EQ(fetch.opcode(), vc_get_buf_resinfo); |
| 887 |
EXPECT_EQ(fetch.dst(), RegisterVec4(201)); |
| 888 |
EXPECT_EQ(fetch.dest_swizzle(0), 0); |
| 889 |
EXPECT_EQ(fetch.dest_swizzle(1), 1); |
| 890 |
EXPECT_EQ(fetch.dest_swizzle(2), 3); |
| 891 |
EXPECT_EQ(fetch.dest_swizzle(3), 4); |
| 892 |
|
| 893 |
EXPECT_EQ(fetch.src(), Register(202, 3, pin_none)); |
| 894 |
EXPECT_EQ(fetch.src_offset(), 1); |
| 895 |
|
| 896 |
EXPECT_EQ(fetch.resource_id(), 3); |
| 897 |
EXPECT_EQ(*fetch.resource_offset(), Register(300, 1, pin_none)); |
| 898 |
|
| 899 |
EXPECT_EQ(fetch.fetch_type(), no_index_offset); |
| 900 |
EXPECT_EQ(fetch.data_format(), fmt_32_32); |
| 901 |
EXPECT_EQ(fetch.num_format(), vtx_nf_int); |
| 902 |
EXPECT_EQ(fetch.endian_swap(), vtx_es_8in16); |
| 903 |
|
| 904 |
EXPECT_EQ(fetch.mega_fetch_count(), 0); |
| 905 |
EXPECT_EQ(fetch.array_base(), 0); |
| 906 |
EXPECT_EQ(fetch.array_size(), 0); |
| 907 |
EXPECT_EQ(fetch.elm_size(), 0); |
| 908 |
|
| 909 |
for (int i = 0; i < FetchInstr::unknown; ++i) { |
| 910 |
EXPECT_FALSE(fetch.has_fetch_flag(static_cast<FetchInstr::EFlags>(i))); |
| 911 |
} |
| 912 |
|
| 913 |
auto fetch1 = fetch; |
| 914 |
fetch1.set_mfc(15); |
| 915 |
EXPECT_NE(fetch1, fetch); |
| 916 |
EXPECT_EQ(fetch1.mega_fetch_count(), 15); |
| 917 |
EXPECT_TRUE( |
| 918 |
fetch1.has_fetch_flag(static_cast<FetchInstr::EFlags>(FetchInstr::is_mega_fetch))); |
| 919 |
|
| 920 |
auto fetch2 = fetch; |
| 921 |
fetch2.set_array_base(128); |
| 922 |
EXPECT_NE(fetch, fetch2); |
| 923 |
EXPECT_EQ(fetch2.array_base(), 128); |
| 924 |
|
| 925 |
auto fetch3 = fetch; |
| 926 |
fetch3.set_array_size(8); |
| 927 |
EXPECT_NE(fetch, fetch3); |
| 928 |
EXPECT_EQ(fetch3.array_size(), 8); |
| 929 |
|
| 930 |
auto fetch4 = fetch; |
| 931 |
fetch4.set_element_size(1); |
| 932 |
EXPECT_NE(fetch, fetch4); |
| 933 |
EXPECT_EQ(fetch4.elm_size(), 1); |
| 934 |
} |