~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/gallium/drivers/r600/r600_shader.c

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
The compiler must issue the source argument to slots z, y, and x
58
58
*/
59
59
 
60
 
 
61
 
int r600_find_vs_semantic_index(struct r600_shader *vs,
62
 
                                struct r600_shader *ps, int id)
63
 
{
64
 
        struct r600_shader_io *input = &ps->input[id];
65
 
 
66
 
        for (int i = 0; i < vs->noutput; i++) {
67
 
                if (input->name == vs->output[i].name &&
68
 
                        input->sid == vs->output[i].sid) {
69
 
                        return i - 1;
70
 
                }
71
 
        }
72
 
        return 0;
73
 
}
74
 
 
75
60
static int r600_pipe_shader(struct pipe_context *ctx, struct r600_pipe_shader *shader)
76
61
{
77
62
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
81
66
 
82
67
        /* copy new shader */
83
68
        if (shader->bo == NULL) {
84
 
                /* use PIPE_BIND_VERTEX_BUFFER so we use the cache buffer manager */
85
 
                shader->bo = r600_bo(rctx->radeon, rshader->bc.ndw * 4, 4096, PIPE_BIND_VERTEX_BUFFER, PIPE_USAGE_IMMUTABLE);
 
69
                shader->bo = (struct r600_resource*)
 
70
                        pipe_buffer_create(ctx->screen, PIPE_BIND_CUSTOM, PIPE_USAGE_IMMUTABLE, rshader->bc.ndw * 4);
86
71
                if (shader->bo == NULL) {
87
72
                        return -ENOMEM;
88
73
                }
89
 
                ptr = (uint32_t*)r600_bo_map(rctx->radeon, shader->bo, 0, NULL);
 
74
                ptr = (uint32_t*)rctx->ws->buffer_map(shader->bo->buf, rctx->ctx.cs, PIPE_TRANSFER_WRITE);
90
75
                if (R600_BIG_ENDIAN) {
91
76
                        for (i = 0; i < rshader->bc.ndw; ++i) {
92
77
                                ptr[i] = bswap_32(rshader->bc.bytecode[i]);
94
79
                } else {
95
80
                        memcpy(ptr, rshader->bc.bytecode, rshader->bc.ndw * sizeof(*ptr));
96
81
                }
97
 
                r600_bo_unmap(rctx->radeon, shader->bo);
 
82
                rctx->ws->buffer_unmap(shader->bo->buf);
98
83
        }
99
84
        /* build state */
100
85
        switch (rshader->processor_type) {
101
86
        case TGSI_PROCESSOR_VERTEX:
102
 
                if (rshader->family >= CHIP_CEDAR) {
 
87
                if (rctx->chip_class >= EVERGREEN) {
103
88
                        evergreen_pipe_shader_vs(ctx, shader);
104
89
                } else {
105
90
                        r600_pipe_shader_vs(ctx, shader);
106
91
                }
107
92
                break;
108
93
        case TGSI_PROCESSOR_FRAGMENT:
109
 
                if (rshader->family >= CHIP_CEDAR) {
 
94
                if (rctx->chip_class >= EVERGREEN) {
110
95
                        evergreen_pipe_shader_ps(ctx, shader);
111
96
                } else {
112
97
                        r600_pipe_shader_ps(ctx, shader);
134
119
        if (dump_shaders) {
135
120
                fprintf(stderr, "--------------------------------------------------------------\n");
136
121
                tgsi_dump(shader->tokens, 0);
 
122
 
 
123
                if (shader->so.num_outputs) {
 
124
                        unsigned i;
 
125
                        fprintf(stderr, "STREAMOUT\n");
 
126
                        for (i = 0; i < shader->so.num_outputs; i++) {
 
127
                                fprintf(stderr, "  %i: MEM_STREAM0_BUF%i OUT[%i].%s%s%s%s\n", i,
 
128
                                        shader->so.output[i].output_buffer, shader->so.output[i].register_index,
 
129
                                        shader->so.output[i].register_mask & 1 ? "x" : "_",
 
130
                                        (shader->so.output[i].register_mask >> 1) & 1 ? "y" : "_",
 
131
                                        (shader->so.output[i].register_mask >> 2) & 1 ? "z" : "_",
 
132
                                        (shader->so.output[i].register_mask >> 3) & 1 ? "w" : "_");
 
133
                        }
 
134
                }
137
135
        }
138
 
        shader->shader.family = r600_get_family(rctx->radeon);
139
136
        r = r600_shader_from_tgsi(rctx, shader);
140
137
        if (r) {
141
138
                R600_ERR("translation from TGSI failed !\n");
142
139
                return r;
143
140
        }
144
 
        r = r600_bc_build(&shader->shader.bc);
 
141
        r = r600_bytecode_build(&shader->shader.bc);
145
142
        if (r) {
146
143
                R600_ERR("building bytecode failed !\n");
147
144
                return r;
148
145
        }
149
146
        if (dump_shaders) {
150
 
                r600_bc_dump(&shader->shader.bc);
 
147
                r600_bytecode_dump(&shader->shader.bc);
151
148
                fprintf(stderr, "______________________________________________________________\n");
152
149
        }
153
150
        return r600_pipe_shader(ctx, shader);
155
152
 
156
153
void r600_pipe_shader_destroy(struct pipe_context *ctx, struct r600_pipe_shader *shader)
157
154
{
158
 
        struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
159
 
 
160
 
        r600_bo_reference(rctx->radeon, &shader->bo, NULL);
161
 
        r600_bc_clear(&shader->shader.bc);
 
155
        pipe_resource_reference((struct pipe_resource**)&shader->bo, NULL);
 
156
        r600_bytecode_clear(&shader->shader.bc);
162
157
 
163
158
        memset(&shader->shader,0,sizeof(struct r600_shader));
164
159
}
184
179
        unsigned                                type;
185
180
        unsigned                                file_offset[TGSI_FILE_COUNT];
186
181
        unsigned                                temp_reg;
187
 
        unsigned                                ar_reg;
188
182
        struct r600_shader_tgsi_instruction     *inst_info;
189
 
        struct r600_bc                          *bc;
 
183
        struct r600_bytecode                            *bc;
190
184
        struct r600_shader                      *shader;
191
185
        struct r600_shader_src                  src[4];
192
186
        u32                                     *literals;
197
191
        boolean                                 input_linear;
198
192
        boolean                                 input_perspective;
199
193
        int                                     num_interp_gpr;
 
194
        int                                     face_gpr;
 
195
        int                                     colors_used;
 
196
        boolean                 clip_vertex_write;
 
197
        unsigned                cv_output;
200
198
};
201
199
 
202
200
struct r600_shader_tgsi_instruction {
247
245
static int evergreen_interp_alu(struct r600_shader_ctx *ctx, int input)
248
246
{
249
247
        int i, r;
250
 
        struct r600_bc_alu alu;
 
248
        struct r600_bytecode_alu alu;
251
249
        int gpr = 0, base_chan = 0;
252
250
        int ij_index = 0;
253
251
 
273
271
        base_chan = (2 * (ij_index % 2)) + 1;
274
272
 
275
273
        for (i = 0; i < 8; i++) {
276
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
274
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
277
275
 
278
276
                if (i < 4)
279
277
                        alu.inst = EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_ZW;
295
293
                alu.bank_swizzle_force = SQ_ALU_VEC_210;
296
294
                if ((i % 4) == 3)
297
295
                        alu.last = 1;
298
 
                r = r600_bc_add_alu(ctx->bc, &alu);
299
 
                if (r)
300
 
                        return r;
301
 
        }
302
 
        return 0;
303
 
}
304
 
 
 
296
                r = r600_bytecode_add_alu(ctx->bc, &alu);
 
297
                if (r)
 
298
                        return r;
 
299
        }
 
300
        return 0;
 
301
}
 
302
 
 
303
static int evergreen_interp_flat(struct r600_shader_ctx *ctx, int input)
 
304
{
 
305
        int i, r;
 
306
        struct r600_bytecode_alu alu;
 
307
 
 
308
        for (i = 0; i < 4; i++) {
 
309
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
 
310
 
 
311
                alu.inst = EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_LOAD_P0;
 
312
 
 
313
                alu.dst.sel = ctx->shader->input[input].gpr;
 
314
                alu.dst.write = 1;
 
315
 
 
316
                alu.dst.chan = i;
 
317
 
 
318
                alu.src[0].sel = V_SQ_ALU_SRC_PARAM_BASE + ctx->shader->input[input].lds_pos;
 
319
                alu.src[0].chan = i;
 
320
 
 
321
                if (i == 3)
 
322
                        alu.last = 1;
 
323
                r = r600_bytecode_add_alu(ctx->bc, &alu);
 
324
                if (r)
 
325
                        return r;
 
326
        }
 
327
        return 0;
 
328
}
 
329
 
 
330
/*
 
331
 * Special export handling in shaders
 
332
 *
 
333
 * shader export ARRAY_BASE for EXPORT_POS:
 
334
 * 60 is position
 
335
 * 61 is misc vector
 
336
 * 62, 63 are clip distance vectors
 
337
 *
 
338
 * The use of the values exported in 61-63 are controlled by PA_CL_VS_OUT_CNTL:
 
339
 * VS_OUT_MISC_VEC_ENA - enables the use of all fields in export 61
 
340
 * USE_VTX_POINT_SIZE - point size in the X channel of export 61
 
341
 * USE_VTX_EDGE_FLAG - edge flag in the Y channel of export 61
 
342
 * USE_VTX_RENDER_TARGET_INDX - render target index in the Z channel of export 61
 
343
 * USE_VTX_VIEWPORT_INDX - viewport index in the W channel of export 61
 
344
 * USE_VTX_KILL_FLAG - kill flag in the Z channel of export 61 (mutually
 
345
 * exclusive from render target index)
 
346
 * VS_OUT_CCDIST0_VEC_ENA/VS_OUT_CCDIST1_VEC_ENA - enable clip distance vectors
 
347
 *
 
348
 *
 
349
 * shader export ARRAY_BASE for EXPORT_PIXEL:
 
350
 * 0-7 CB targets
 
351
 * 61 computed Z vector
 
352
 *
 
353
 * The use of the values exported in the computed Z vector are controlled
 
354
 * by DB_SHADER_CONTROL:
 
355
 * Z_EXPORT_ENABLE - Z as a float in RED
 
356
 * STENCIL_REF_EXPORT_ENABLE - stencil ref as int in GREEN
 
357
 * COVERAGE_TO_MASK_ENABLE - alpha to mask in ALPHA
 
358
 * MASK_EXPORT_ENABLE - pixel sample mask in BLUE
 
359
 * DB_SOURCE_FORMAT - export control restrictions
 
360
 *
 
361
 */
 
362
 
 
363
 
 
364
/* Map name/sid pair from tgsi to the 8-bit semantic index for SPI setup */
 
365
static int r600_spi_sid(struct r600_shader_io * io)
 
366
{
 
367
        int index, name = io->name;
 
368
 
 
369
        /* These params are handled differently, they don't need
 
370
         * semantic indices, so we'll use 0 for them.
 
371
         */
 
372
        if (name == TGSI_SEMANTIC_POSITION ||
 
373
                name == TGSI_SEMANTIC_PSIZE ||
 
374
                name == TGSI_SEMANTIC_FACE)
 
375
                index = 0;
 
376
        else {
 
377
                if (name == TGSI_SEMANTIC_GENERIC) {
 
378
                        /* For generic params simply use sid from tgsi */
 
379
                        index = io->sid;
 
380
                } else {
 
381
                        /* For non-generic params - pack name and sid into 8 bits */
 
382
                        index = 0x80 | (name<<3) | (io->sid);
 
383
                }
 
384
 
 
385
                /* Make sure that all really used indices have nonzero value, so
 
386
                 * we can just compare it to 0 later instead of comparing the name
 
387
                 * with different values to detect special cases. */
 
388
                index++;
 
389
        }
 
390
 
 
391
        return index;
 
392
};
 
393
 
 
394
/* turn input into interpolate on EG */
 
395
static int evergreen_interp_input(struct r600_shader_ctx *ctx, int index)
 
396
{
 
397
        int r = 0;
 
398
 
 
399
        if (ctx->shader->input[index].spi_sid) {
 
400
                ctx->shader->input[index].lds_pos = ctx->shader->nlds++;
 
401
                if (ctx->shader->input[index].interpolate > 0) {
 
402
                        r = evergreen_interp_alu(ctx, index);
 
403
                } else {
 
404
                        r = evergreen_interp_flat(ctx, index);
 
405
                }
 
406
        }
 
407
        return r;
 
408
}
 
409
 
 
410
static int select_twoside_color(struct r600_shader_ctx *ctx, int front, int back)
 
411
{
 
412
        struct r600_bytecode_alu alu;
 
413
        int i, r;
 
414
        int gpr_front = ctx->shader->input[front].gpr;
 
415
        int gpr_back = ctx->shader->input[back].gpr;
 
416
 
 
417
        for (i = 0; i < 4; i++) {
 
418
                memset(&alu, 0, sizeof(alu));
 
419
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT);
 
420
                alu.is_op3 = 1;
 
421
                alu.dst.write = 1;
 
422
                alu.dst.sel = gpr_front;
 
423
                alu.src[0].sel = ctx->face_gpr;
 
424
                alu.src[1].sel = gpr_front;
 
425
                alu.src[2].sel = gpr_back;
 
426
 
 
427
                alu.dst.chan = i;
 
428
                alu.src[1].chan = i;
 
429
                alu.src[2].chan = i;
 
430
                alu.last = (i==3);
 
431
 
 
432
                if ((r = r600_bytecode_add_alu(ctx->bc, &alu)))
 
433
                        return r;
 
434
        }
 
435
 
 
436
        return 0;
 
437
}
305
438
 
306
439
static int tgsi_declaration(struct r600_shader_ctx *ctx)
307
440
{
314
447
                i = ctx->shader->ninput++;
315
448
                ctx->shader->input[i].name = d->Semantic.Name;
316
449
                ctx->shader->input[i].sid = d->Semantic.Index;
 
450
                ctx->shader->input[i].spi_sid = r600_spi_sid(&ctx->shader->input[i]);
317
451
                ctx->shader->input[i].interpolate = d->Declaration.Interpolate;
318
452
                ctx->shader->input[i].centroid = d->Declaration.Centroid;
319
 
                ctx->shader->input[i].gpr = ctx->file_offset[TGSI_FILE_INPUT] + i;
320
 
                if (ctx->type == TGSI_PROCESSOR_FRAGMENT && ctx->bc->chiprev >= CHIPREV_EVERGREEN) {
321
 
                        /* turn input into interpolate on EG */
322
 
                        if (ctx->shader->input[i].name != TGSI_SEMANTIC_POSITION) {
323
 
                                if (ctx->shader->input[i].interpolate > 0) {
324
 
                                        ctx->shader->input[i].lds_pos = ctx->shader->nlds++;
325
 
                                        evergreen_interp_alu(ctx, i);
326
 
                                }
 
453
                ctx->shader->input[i].gpr = ctx->file_offset[TGSI_FILE_INPUT] + d->Range.First;
 
454
                if (ctx->type == TGSI_PROCESSOR_FRAGMENT) {
 
455
                        if (ctx->shader->input[i].name == TGSI_SEMANTIC_FACE)
 
456
                                ctx->face_gpr = ctx->shader->input[i].gpr;
 
457
                        else if (ctx->shader->input[i].name == TGSI_SEMANTIC_COLOR)
 
458
                                ctx->colors_used++;
 
459
                        if (ctx->bc->chip_class >= EVERGREEN) {
 
460
                                r = evergreen_interp_input(ctx, i);
 
461
                                if (r)
 
462
                                        return r;
327
463
                        }
328
464
                }
329
465
                break;
331
467
                i = ctx->shader->noutput++;
332
468
                ctx->shader->output[i].name = d->Semantic.Name;
333
469
                ctx->shader->output[i].sid = d->Semantic.Index;
334
 
                ctx->shader->output[i].gpr = ctx->file_offset[TGSI_FILE_OUTPUT] + i;
 
470
                ctx->shader->output[i].spi_sid = r600_spi_sid(&ctx->shader->output[i]);
 
471
                ctx->shader->output[i].gpr = ctx->file_offset[TGSI_FILE_OUTPUT] + d->Range.First;
335
472
                ctx->shader->output[i].interpolate = d->Declaration.Interpolate;
 
473
                ctx->shader->output[i].write_mask = d->Declaration.UsageMask;
 
474
                if (ctx->type == TGSI_PROCESSOR_VERTEX) {
 
475
                        switch (d->Semantic.Name) {
 
476
                        case TGSI_SEMANTIC_CLIPDIST:
 
477
                                ctx->shader->clip_dist_write |= d->Declaration.UsageMask << (d->Semantic.Index << 2);
 
478
                                break;
 
479
                        case TGSI_SEMANTIC_PSIZE:
 
480
                                ctx->shader->vs_out_misc_write = 1;
 
481
                                break;
 
482
                        case TGSI_SEMANTIC_CLIPVERTEX:
 
483
                                ctx->clip_vertex_write = TRUE;
 
484
                                ctx->cv_output = i;
 
485
                                break;
 
486
                        }
 
487
                }
336
488
                break;
337
489
        case TGSI_FILE_CONSTANT:
338
490
        case TGSI_FILE_TEMPORARY:
342
494
 
343
495
        case TGSI_FILE_SYSTEM_VALUE:
344
496
                if (d->Semantic.Name == TGSI_SEMANTIC_INSTANCEID) {
345
 
                        struct r600_bc_alu alu;
346
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
497
                        struct r600_bytecode_alu alu;
 
498
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
347
499
 
348
500
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT);
349
501
                        alu.src[0].sel = 0;
354
506
                        alu.dst.write = 1;
355
507
                        alu.last = 1;
356
508
 
357
 
                        if ((r = r600_bc_add_alu(ctx->bc, &alu)))
 
509
                        if ((r = r600_bytecode_add_alu(ctx->bc, &alu)))
358
510
                                return r;
359
511
                        break;
360
512
                }
437
589
                        (tgsi_src->Register.SwizzleX == tgsi_src->Register.SwizzleW)) {
438
590
 
439
591
                        index = tgsi_src->Register.Index * 4 + tgsi_src->Register.SwizzleX;
440
 
                        r600_bc_special_constants(ctx->literals[index], &r600_src->sel, &r600_src->neg);
 
592
                        r600_bytecode_special_constants(ctx->literals[index], &r600_src->sel, &r600_src->neg);
441
593
                        if (r600_src->sel != V_SQ_ALU_SRC_LITERAL)
442
594
                                return;
443
595
                }
461
613
 
462
614
static int tgsi_fetch_rel_const(struct r600_shader_ctx *ctx, unsigned int offset, unsigned int dst_reg)
463
615
{
464
 
        struct r600_bc_vtx vtx;
 
616
        struct r600_bytecode_vtx vtx;
465
617
        unsigned int ar_reg;
466
618
        int r;
467
619
 
468
620
        if (offset) {
469
 
                struct r600_bc_alu alu;
 
621
                struct r600_bytecode_alu alu;
470
622
 
471
623
                memset(&alu, 0, sizeof(alu));
472
624
 
473
625
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT);
474
 
                alu.src[0].sel = ctx->ar_reg;
 
626
                alu.src[0].sel = ctx->bc->ar_reg;
475
627
 
476
628
                alu.src[1].sel = V_SQ_ALU_SRC_LITERAL;
477
629
                alu.src[1].value = offset;
480
632
                alu.dst.write = 1;
481
633
                alu.last = 1;
482
634
 
483
 
                if ((r = r600_bc_add_alu(ctx->bc, &alu)))
 
635
                if ((r = r600_bytecode_add_alu(ctx->bc, &alu)))
484
636
                        return r;
485
637
 
486
638
                ar_reg = dst_reg;
487
639
        } else {
488
 
                ar_reg = ctx->ar_reg;
 
640
                ar_reg = ctx->bc->ar_reg;
489
641
        }
490
642
 
491
643
        memset(&vtx, 0, sizeof(vtx));
503
655
        vtx.srf_mode_all = 1;           /* SRF_MODE_NO_ZERO */
504
656
        vtx.endian = r600_endian_swap(32);
505
657
 
506
 
        if ((r = r600_bc_add_vtx(ctx->bc, &vtx)))
 
658
        if ((r = r600_bytecode_add_vtx(ctx->bc, &vtx)))
507
659
                return r;
508
660
 
509
661
        return 0;
512
664
static int tgsi_split_constant(struct r600_shader_ctx *ctx)
513
665
{
514
666
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
515
 
        struct r600_bc_alu alu;
 
667
        struct r600_bytecode_alu alu;
516
668
        int i, j, k, nconst, r;
517
669
 
518
670
        for (i = 0, nconst = 0; i < inst->Instruction.NumSrcRegs; i++) {
537
689
                } else if (j > 0) {
538
690
                        int treg = r600_get_temp(ctx);
539
691
                        for (k = 0; k < 4; k++) {
540
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
692
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
541
693
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
542
694
                                alu.src[0].sel = ctx->src[i].sel;
543
695
                                alu.src[0].chan = k;
547
699
                                alu.dst.write = 1;
548
700
                                if (k == 3)
549
701
                                        alu.last = 1;
550
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
702
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
551
703
                                if (r)
552
704
                                        return r;
553
705
                        }
563
715
static int tgsi_split_literal_constant(struct r600_shader_ctx *ctx)
564
716
{
565
717
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
566
 
        struct r600_bc_alu alu;
 
718
        struct r600_bytecode_alu alu;
567
719
        int i, j, k, nliteral, r;
568
720
 
569
721
        for (i = 0, nliteral = 0; i < inst->Instruction.NumSrcRegs; i++) {
575
727
                if (j > 0 && ctx->src[i].sel == V_SQ_ALU_SRC_LITERAL) {
576
728
                        int treg = r600_get_temp(ctx);
577
729
                        for (k = 0; k < 4; k++) {
578
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
730
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
579
731
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
580
732
                                alu.src[0].sel = ctx->src[i].sel;
581
733
                                alu.src[0].chan = k;
585
737
                                alu.dst.write = 1;
586
738
                                if (k == 3)
587
739
                                        alu.last = 1;
588
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
740
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
589
741
                                if (r)
590
742
                                        return r;
591
743
                        }
596
748
        return 0;
597
749
}
598
750
 
 
751
static int process_twoside_color_inputs(struct r600_shader_ctx *ctx)
 
752
{
 
753
        int i, r, count = ctx->shader->ninput;
 
754
 
 
755
        /* additional inputs will be allocated right after the existing inputs,
 
756
         * we won't need them after the color selection, so we don't need to
 
757
         * reserve these gprs for the rest of the shader code and to adjust
 
758
         * output offsets etc. */
 
759
        int gpr = ctx->file_offset[TGSI_FILE_INPUT] +
 
760
                        ctx->info.file_max[TGSI_FILE_INPUT] + 1;
 
761
 
 
762
        if (ctx->face_gpr == -1) {
 
763
                i = ctx->shader->ninput++;
 
764
                ctx->shader->input[i].name = TGSI_SEMANTIC_FACE;
 
765
                ctx->shader->input[i].spi_sid = 0;
 
766
                ctx->shader->input[i].gpr = gpr++;
 
767
                ctx->face_gpr = ctx->shader->input[i].gpr;
 
768
        }
 
769
 
 
770
        for (i = 0; i < count; i++) {
 
771
                if (ctx->shader->input[i].name == TGSI_SEMANTIC_COLOR) {
 
772
                        int ni = ctx->shader->ninput++;
 
773
                        memcpy(&ctx->shader->input[ni],&ctx->shader->input[i], sizeof(struct r600_shader_io));
 
774
                        ctx->shader->input[ni].name = TGSI_SEMANTIC_BCOLOR;
 
775
                        ctx->shader->input[ni].spi_sid = r600_spi_sid(&ctx->shader->input[ni]);
 
776
                        ctx->shader->input[ni].gpr = gpr++;
 
777
 
 
778
                        if (ctx->bc->chip_class >= EVERGREEN) {
 
779
                                r = evergreen_interp_input(ctx, ni);
 
780
                                if (r)
 
781
                                        return r;
 
782
                        }
 
783
 
 
784
                        r = select_twoside_color(ctx, i, ni);
 
785
                        if (r)
 
786
                                return r;
 
787
                }
 
788
        }
 
789
        return 0;
 
790
}
 
791
 
599
792
static int r600_shader_from_tgsi(struct r600_pipe_context * rctx, struct r600_pipe_shader *pipeshader)
600
793
{
601
794
        struct r600_shader *shader = &pipeshader->shader;
602
795
        struct tgsi_token *tokens = pipeshader->tokens;
 
796
        struct pipe_stream_output_info so = pipeshader->so;
603
797
        struct tgsi_full_immediate *immediate;
604
798
        struct tgsi_full_property *property;
605
799
        struct r600_shader_ctx ctx;
606
 
        struct r600_bc_output output[32];
 
800
        struct r600_bytecode_output output[32];
607
801
        unsigned output_done, noutput;
608
802
        unsigned opcode;
609
 
        int i, j, r = 0, pos0;
 
803
        int i, j, k, r = 0;
 
804
        int next_pixel_base = 0, next_pos_base = 60, next_param_base = 0;
610
805
 
611
806
        ctx.bc = &shader->bc;
612
807
        ctx.shader = shader;
613
 
        r = r600_bc_init(ctx.bc, shader->family);
614
 
        if (r)
615
 
                return r;
 
808
        r600_bytecode_init(ctx.bc, rctx->chip_class, rctx->family);
616
809
        ctx.tokens = tokens;
617
810
        tgsi_scan_shader(tokens, &ctx.info);
618
811
        tgsi_parse_init(&ctx.parse, tokens);
620
813
        shader->processor_type = ctx.type;
621
814
        ctx.bc->type = shader->processor_type;
622
815
 
 
816
        ctx.face_gpr = -1;
 
817
        ctx.colors_used = 0;
 
818
        ctx.clip_vertex_write = 0;
 
819
 
 
820
        shader->two_side = (ctx.type == TGSI_PROCESSOR_FRAGMENT) && rctx->two_side;
 
821
 
623
822
        shader->clamp_color = (((ctx.type == TGSI_PROCESSOR_FRAGMENT) && rctx->clamp_fragment_color) ||
624
823
                ((ctx.type == TGSI_PROCESSOR_VERTEX) && rctx->clamp_vertex_color));
625
824
 
651
850
        }
652
851
        if (ctx.type == TGSI_PROCESSOR_VERTEX) {
653
852
                ctx.file_offset[TGSI_FILE_INPUT] = 1;
654
 
                if (ctx.bc->chiprev >= CHIPREV_EVERGREEN) {
655
 
                        r600_bc_add_cfinst(ctx.bc, EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS);
 
853
                if (ctx.bc->chip_class >= EVERGREEN) {
 
854
                        r600_bytecode_add_cfinst(ctx.bc, EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS);
656
855
                } else {
657
 
                        r600_bc_add_cfinst(ctx.bc, V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS);
 
856
                        r600_bytecode_add_cfinst(ctx.bc, V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS);
658
857
                }
659
858
        }
660
 
        if (ctx.type == TGSI_PROCESSOR_FRAGMENT && ctx.bc->chiprev >= CHIPREV_EVERGREEN) {
 
859
        if (ctx.type == TGSI_PROCESSOR_FRAGMENT && ctx.bc->chip_class >= EVERGREEN) {
661
860
                ctx.file_offset[TGSI_FILE_INPUT] = evergreen_gpr_count(&ctx);
662
861
        }
663
862
        ctx.file_offset[TGSI_FILE_OUTPUT] = ctx.file_offset[TGSI_FILE_INPUT] +
664
 
                                                ctx.info.file_count[TGSI_FILE_INPUT];
 
863
                                                ctx.info.file_max[TGSI_FILE_INPUT] + 1;
665
864
        ctx.file_offset[TGSI_FILE_TEMPORARY] = ctx.file_offset[TGSI_FILE_OUTPUT] +
666
 
                                                ctx.info.file_count[TGSI_FILE_OUTPUT];
 
865
                                                ctx.info.file_max[TGSI_FILE_OUTPUT] + 1;
667
866
 
668
867
        /* Outside the GPR range. This will be translated to one of the
669
868
         * kcache banks later. */
670
869
        ctx.file_offset[TGSI_FILE_CONSTANT] = 512;
671
870
 
672
871
        ctx.file_offset[TGSI_FILE_IMMEDIATE] = V_SQ_ALU_SRC_LITERAL;
673
 
        ctx.ar_reg = ctx.file_offset[TGSI_FILE_TEMPORARY] +
674
 
                        ctx.info.file_count[TGSI_FILE_TEMPORARY];
675
 
        ctx.temp_reg = ctx.ar_reg + 1;
 
872
        ctx.bc->ar_reg = ctx.file_offset[TGSI_FILE_TEMPORARY] +
 
873
                        ctx.info.file_max[TGSI_FILE_TEMPORARY] + 1;
 
874
        ctx.temp_reg = ctx.bc->ar_reg + 1;
676
875
 
677
876
        ctx.nliterals = 0;
678
877
        ctx.literals = NULL;
699
898
                                goto out_err;
700
899
                        break;
701
900
                case TGSI_TOKEN_TYPE_INSTRUCTION:
 
901
                        break;
 
902
                case TGSI_TOKEN_TYPE_PROPERTY:
 
903
                        property = &ctx.parse.FullToken.FullProperty;
 
904
                        switch (property->Property.PropertyName) {
 
905
                        case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS:
 
906
                                if (property->u[0].Data == 1)
 
907
                                        shader->fs_write_all = TRUE;
 
908
                                break;
 
909
                        case TGSI_PROPERTY_VS_PROHIBIT_UCPS:
 
910
                                if (property->u[0].Data == 1)
 
911
                                        shader->vs_prohibit_ucps = TRUE;
 
912
                                break;
 
913
                        }
 
914
                        break;
 
915
                default:
 
916
                        R600_ERR("unsupported token type %d\n", ctx.parse.FullToken.Token.Type);
 
917
                        r = -EINVAL;
 
918
                        goto out_err;
 
919
                }
 
920
        }
 
921
 
 
922
        if (shader->two_side && ctx.colors_used) {
 
923
                if ((r = process_twoside_color_inputs(&ctx)))
 
924
                        return r;
 
925
        }
 
926
 
 
927
        tgsi_parse_init(&ctx.parse, tokens);
 
928
        while (!tgsi_parse_end_of_tokens(&ctx.parse)) {
 
929
                tgsi_parse_token(&ctx.parse);
 
930
                switch (ctx.parse.FullToken.Token.Type) {
 
931
                case TGSI_TOKEN_TYPE_INSTRUCTION:
702
932
                        r = tgsi_is_supported(&ctx);
703
933
                        if (r)
704
934
                                goto out_err;
711
941
                                goto out_err;
712
942
                        if ((r = tgsi_split_literal_constant(&ctx)))
713
943
                                goto out_err;
714
 
                        if (ctx.bc->chiprev == CHIPREV_CAYMAN)
 
944
                        if (ctx.bc->chip_class == CAYMAN)
715
945
                                ctx.inst_info = &cm_shader_tgsi_instruction[opcode];
716
 
                        else if (ctx.bc->chiprev >= CHIPREV_EVERGREEN)
 
946
                        else if (ctx.bc->chip_class >= EVERGREEN)
717
947
                                ctx.inst_info = &eg_shader_tgsi_instruction[opcode];
718
948
                        else
719
949
                                ctx.inst_info = &r600_shader_tgsi_instruction[opcode];
721
951
                        if (r)
722
952
                                goto out_err;
723
953
                        break;
724
 
                case TGSI_TOKEN_TYPE_PROPERTY:
725
 
                        property = &ctx.parse.FullToken.FullProperty;
726
 
                        if (property->Property.PropertyName == TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS) {
727
 
                                if (property->u[0].Data == 1)
728
 
                                        shader->fs_write_all = TRUE;
729
 
                        }
730
 
                        break;
731
954
                default:
732
 
                        R600_ERR("unsupported token type %d\n", ctx.parse.FullToken.Token.Type);
733
 
                        r = -EINVAL;
734
 
                        goto out_err;
 
955
                        break;
735
956
                }
736
957
        }
737
958
 
738
959
        noutput = shader->noutput;
739
960
 
 
961
        if (ctx.clip_vertex_write) {
 
962
                /* need to convert a clipvertex write into clipdistance writes and not export
 
963
                   the clip vertex anymore */
 
964
 
 
965
                memset(&shader->output[noutput], 0, 2*sizeof(struct r600_shader_io));
 
966
                shader->output[noutput].name = TGSI_SEMANTIC_CLIPDIST;
 
967
                shader->output[noutput].gpr = ctx.temp_reg;
 
968
                noutput++;
 
969
                shader->output[noutput].name = TGSI_SEMANTIC_CLIPDIST;
 
970
                shader->output[noutput].gpr = ctx.temp_reg+1;
 
971
                noutput++;
 
972
 
 
973
                /* reset spi_sid for clipvertex output to avoid confusing spi */
 
974
                shader->output[ctx.cv_output].spi_sid = 0;
 
975
 
 
976
                shader->clip_dist_write = 0xFF;
 
977
 
 
978
                for (i = 0; i < 8; i++) {
 
979
                        int oreg = i >> 2;
 
980
                        int ochan = i & 3;
 
981
 
 
982
                        for (j = 0; j < 4; j++) {
 
983
                                struct r600_bytecode_alu alu;
 
984
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
 
985
                                alu.inst = BC_INST(ctx.bc, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4);
 
986
                                alu.src[0].sel = shader->output[ctx.cv_output].gpr;
 
987
                                alu.src[0].chan = j;
 
988
 
 
989
                                alu.src[1].sel = 512 + i;
 
990
                                alu.src[1].kc_bank = 1;
 
991
                                alu.src[1].chan = j;
 
992
 
 
993
                                alu.dst.sel = ctx.temp_reg + oreg;
 
994
                                alu.dst.chan = j;
 
995
                                alu.dst.write = (j == ochan);
 
996
                                if (j == 3)
 
997
                                        alu.last = 1;
 
998
                                r = r600_bytecode_add_alu(ctx.bc, &alu);
 
999
                                if (r)
 
1000
                                        return r;
 
1001
                        }
 
1002
                }
 
1003
        }
 
1004
 
740
1005
        /* clamp color outputs */
741
1006
        if (shader->clamp_color) {
742
1007
                for (i = 0; i < noutput; i++) {
745
1010
 
746
1011
                                int j;
747
1012
                                for (j = 0; j < 4; j++) {
748
 
                                        struct r600_bc_alu alu;
749
 
                                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1013
                                        struct r600_bytecode_alu alu;
 
1014
                                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
750
1015
 
751
1016
                                        /* MOV_SAT R, R */
752
1017
                                        alu.inst = BC_INST(ctx.bc, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
760
1025
                                        if (j == 3) {
761
1026
                                                alu.last = 1;
762
1027
                                        }
763
 
                                        r = r600_bc_add_alu(ctx.bc, &alu);
 
1028
                                        r = r600_bytecode_add_alu(ctx.bc, &alu);
764
1029
                                        if (r)
765
1030
                                                return r;
766
1031
                                }
768
1033
                }
769
1034
        }
770
1035
 
 
1036
        /* Add stream outputs. */
 
1037
        if (ctx.type == TGSI_PROCESSOR_VERTEX && so.num_outputs) {
 
1038
                unsigned buffer_offset[PIPE_MAX_SO_BUFFERS] = {0};
 
1039
 
 
1040
                for (i = 0; i < so.num_outputs; i++) {
 
1041
                        struct r600_bytecode_output output;
 
1042
                        unsigned comps;
 
1043
 
 
1044
                        if (so.output[i].output_buffer >= 4) {
 
1045
                                R600_ERR("exceeded the max number of stream output buffers, got: %d\n",
 
1046
                                         so.output[i].output_buffer);
 
1047
                                r = -EINVAL;
 
1048
                                goto out_err;
 
1049
                        }
 
1050
 
 
1051
                        switch (so.output[i].register_mask) {
 
1052
                        case TGSI_WRITEMASK_XYZW:
 
1053
                                comps = 4;
 
1054
                                break;
 
1055
                        case TGSI_WRITEMASK_XYZ:
 
1056
                                comps = 3;
 
1057
                                break;
 
1058
                        case TGSI_WRITEMASK_XY:
 
1059
                                comps = 2;
 
1060
                                break;
 
1061
                        case TGSI_WRITEMASK_X:
 
1062
                                comps = 1;
 
1063
                                break;
 
1064
                        default:
 
1065
                                R600_ERR("streamout: invalid register_mask, got: %x\n",
 
1066
                                         so.output[i].register_mask);
 
1067
                                r = -EINVAL;
 
1068
                                goto out_err;
 
1069
                        }
 
1070
 
 
1071
                        memset(&output, 0, sizeof(struct r600_bytecode_output));
 
1072
                        output.gpr = shader->output[so.output[i].register_index].gpr;
 
1073
                        output.elem_size = 0;
 
1074
                        output.array_base = buffer_offset[so.output[i].output_buffer];
 
1075
                        output.type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_WRITE;
 
1076
                        output.burst_count = 1;
 
1077
                        output.barrier = 1;
 
1078
                        output.array_size = 0;
 
1079
                        output.comp_mask = so.output[i].register_mask;
 
1080
                        if (ctx.bc->chip_class >= EVERGREEN) {
 
1081
                                switch (so.output[i].output_buffer) {
 
1082
                                case 0:
 
1083
                                        output.inst = EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF0;
 
1084
                                        break;
 
1085
                                case 1:
 
1086
                                        output.inst = EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF1;
 
1087
                                        break;
 
1088
                                case 2:
 
1089
                                        output.inst = EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF2;
 
1090
                                        break;
 
1091
                                case 3:
 
1092
                                        output.inst = EG_V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0_BUF3;
 
1093
                                        break;
 
1094
                                }
 
1095
                        } else {
 
1096
                                switch (so.output[i].output_buffer) {
 
1097
                                case 0:
 
1098
                                        output.inst = V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM0;
 
1099
                                        break;
 
1100
                                case 1:
 
1101
                                        output.inst = V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM1;
 
1102
                                        break;
 
1103
                                case 2:
 
1104
                                        output.inst = V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM2;
 
1105
                                        break;
 
1106
                                case 3:
 
1107
                                        output.inst = V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_MEM_STREAM3;
 
1108
                                        break;
 
1109
                                }
 
1110
                        }
 
1111
                        r = r600_bytecode_add_output(ctx.bc, &output);
 
1112
                        if (r)
 
1113
                                goto out_err;
 
1114
 
 
1115
                        buffer_offset[so.output[i].output_buffer] += comps;
 
1116
                }
 
1117
 
 
1118
                for (i = 0; i < PIPE_MAX_SO_BUFFERS; i++) {
 
1119
                        pipeshader->so_strides[i] = buffer_offset[i] * 4;
 
1120
                }
 
1121
        }
 
1122
 
771
1123
        /* export output */
772
 
        j = 0;
773
 
        for (i = 0, pos0 = 0; i < noutput; i++) {
774
 
                memset(&output[i], 0, sizeof(struct r600_bc_output));
775
 
                output[i + j].gpr = shader->output[i].gpr;
776
 
                output[i + j].elem_size = 3;
777
 
                output[i + j].swizzle_x = 0;
778
 
                output[i + j].swizzle_y = 1;
779
 
                output[i + j].swizzle_z = 2;
780
 
                output[i + j].swizzle_w = 3;
781
 
                output[i + j].burst_count = 1;
782
 
                output[i + j].barrier = 1;
783
 
                output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM;
784
 
                output[i + j].array_base = i - pos0;
785
 
                output[i + j].inst = BC_INST(ctx.bc, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT);
 
1124
        for (i = 0, j = 0; i < noutput; i++, j++) {
 
1125
                memset(&output[j], 0, sizeof(struct r600_bytecode_output));
 
1126
                output[j].gpr = shader->output[i].gpr;
 
1127
                output[j].elem_size = 3;
 
1128
                output[j].swizzle_x = 0;
 
1129
                output[j].swizzle_y = 1;
 
1130
                output[j].swizzle_z = 2;
 
1131
                output[j].swizzle_w = 3;
 
1132
                output[j].burst_count = 1;
 
1133
                output[j].barrier = 1;
 
1134
                output[j].type = -1;
 
1135
                output[j].inst = BC_INST(ctx.bc, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT);
786
1136
                switch (ctx.type) {
787
1137
                case TGSI_PROCESSOR_VERTEX:
788
 
                        if (shader->output[i].name == TGSI_SEMANTIC_POSITION) {
789
 
                                output[i + j].array_base = 60;
790
 
                                output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS;
791
 
                                /* position doesn't count in array_base */
792
 
                                pos0++;
793
 
                        }
794
 
                        if (shader->output[i].name == TGSI_SEMANTIC_PSIZE) {
795
 
                                output[i + j].array_base = 61;
796
 
                                output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS;
797
 
                                /* position doesn't count in array_base */
798
 
                                pos0++;
 
1138
                        switch (shader->output[i].name) {
 
1139
                        case TGSI_SEMANTIC_POSITION:
 
1140
                                output[j].array_base = next_pos_base++;
 
1141
                                output[j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS;
 
1142
                                break;
 
1143
 
 
1144
                        case TGSI_SEMANTIC_PSIZE:
 
1145
                                output[j].array_base = next_pos_base++;
 
1146
                                output[j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS;
 
1147
                                break;
 
1148
                        case TGSI_SEMANTIC_CLIPVERTEX:
 
1149
                                j--;
 
1150
                                break;
 
1151
                        case TGSI_SEMANTIC_CLIPDIST:
 
1152
                                output[j].array_base = next_pos_base++;
 
1153
                                output[j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS;
 
1154
                                /* spi_sid is 0 for clipdistance outputs that were generated
 
1155
                                 * for clipvertex - we don't need to pass them to PS */
 
1156
                                if (shader->output[i].spi_sid) {
 
1157
                                        j++;
 
1158
                                        /* duplicate it as PARAM to pass to the pixel shader */
 
1159
                                        memcpy(&output[j], &output[j-1], sizeof(struct r600_bytecode_output));
 
1160
                                        output[j].array_base = next_param_base++;
 
1161
                                        output[j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM;
 
1162
                                }
 
1163
                                break;
 
1164
                        case TGSI_SEMANTIC_FOG:
 
1165
                                output[j].swizzle_y = 4; /* 0 */
 
1166
                                output[j].swizzle_z = 4; /* 0 */
 
1167
                                output[j].swizzle_w = 5; /* 1 */
 
1168
                                break;
799
1169
                        }
800
1170
                        break;
801
1171
                case TGSI_PROCESSOR_FRAGMENT:
802
1172
                        if (shader->output[i].name == TGSI_SEMANTIC_COLOR) {
803
 
                                output[i + j].array_base = shader->output[i].sid;
804
 
                                output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
805
 
                                if (shader->fs_write_all && (shader->family >= CHIP_CEDAR)) {
806
 
                                        for (j = 1; j < shader->nr_cbufs; j++) {
807
 
                                                memset(&output[i + j], 0, sizeof(struct r600_bc_output));
808
 
                                                output[i + j].gpr = shader->output[i].gpr;
809
 
                                                output[i + j].elem_size = 3;
810
 
                                                output[i + j].swizzle_x = 0;
811
 
                                                output[i + j].swizzle_y = 1;
812
 
                                                output[i + j].swizzle_z = 2;
813
 
                                                output[i + j].swizzle_w = 3;
814
 
                                                output[i + j].burst_count = 1;
815
 
                                                output[i + j].barrier = 1;
816
 
                                                output[i + j].array_base = shader->output[i].sid + j;
817
 
                                                output[i + j].inst = BC_INST(ctx.bc, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT);
818
 
                                                output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
 
1173
                                output[j].array_base = next_pixel_base++;
 
1174
                                output[j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
 
1175
                                if (shader->fs_write_all && (rctx->chip_class >= EVERGREEN)) {
 
1176
                                        for (k = 1; k < shader->nr_cbufs; k++) {
 
1177
                                                j++;
 
1178
                                                memset(&output[j], 0, sizeof(struct r600_bytecode_output));
 
1179
                                                output[j].gpr = shader->output[i].gpr;
 
1180
                                                output[j].elem_size = 3;
 
1181
                                                output[j].swizzle_x = 0;
 
1182
                                                output[j].swizzle_y = 1;
 
1183
                                                output[j].swizzle_z = 2;
 
1184
                                                output[j].swizzle_w = 3;
 
1185
                                                output[j].burst_count = 1;
 
1186
                                                output[j].barrier = 1;
 
1187
                                                output[j].array_base = next_pixel_base++;
 
1188
                                                output[j].inst = BC_INST(ctx.bc, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT);
 
1189
                                                output[j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
819
1190
                                        }
820
 
                                        j--;
821
1191
                                }
822
1192
                        } else if (shader->output[i].name == TGSI_SEMANTIC_POSITION) {
823
 
                                output[i + j].array_base = 61;
824
 
                                output[i + j].swizzle_x = 2;
825
 
                                output[i + j].swizzle_y = 7;
826
 
                                output[i + j].swizzle_z = output[i + j].swizzle_w = 7;
827
 
                                output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
 
1193
                                output[j].array_base = 61;
 
1194
                                output[j].swizzle_x = 2;
 
1195
                                output[j].swizzle_y = 7;
 
1196
                                output[j].swizzle_z = output[j].swizzle_w = 7;
 
1197
                                output[j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
828
1198
                        } else if (shader->output[i].name == TGSI_SEMANTIC_STENCIL) {
829
 
                                output[i + j].array_base = 61;
830
 
                                output[i + j].swizzle_x = 7;
831
 
                                output[i + j].swizzle_y = 1;
832
 
                                output[i + j].swizzle_z = output[i + j].swizzle_w = 7;
833
 
                                output[i + j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
 
1199
                                output[j].array_base = 61;
 
1200
                                output[j].swizzle_x = 7;
 
1201
                                output[j].swizzle_y = 1;
 
1202
                                output[j].swizzle_z = output[j].swizzle_w = 7;
 
1203
                                output[j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
834
1204
                        } else {
835
1205
                                R600_ERR("unsupported fragment output name %d\n", shader->output[i].name);
836
1206
                                r = -EINVAL;
842
1212
                        r = -EINVAL;
843
1213
                        goto out_err;
844
1214
                }
 
1215
 
 
1216
                if (output[j].type==-1) {
 
1217
                        output[j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM;
 
1218
                        output[j].array_base = next_param_base++;
 
1219
                }
845
1220
        }
846
 
        noutput += j;
 
1221
 
847
1222
        /* add fake param output for vertex shader if no param is exported */
848
 
        if (ctx.type == TGSI_PROCESSOR_VERTEX) {
849
 
                for (i = 0, pos0 = 0; i < noutput; i++) {
850
 
                        if (output[i].type == V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM) {
851
 
                                pos0 = 1;
852
 
                                break;
853
 
                        }
854
 
                }
855
 
                if (!pos0) {
856
 
                        memset(&output[i], 0, sizeof(struct r600_bc_output));
857
 
                        output[i].gpr = 0;
858
 
                        output[i].elem_size = 3;
859
 
                        output[i].swizzle_x = 0;
860
 
                        output[i].swizzle_y = 1;
861
 
                        output[i].swizzle_z = 2;
862
 
                        output[i].swizzle_w = 3;
863
 
                        output[i].burst_count = 1;
864
 
                        output[i].barrier = 1;
865
 
                        output[i].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM;
866
 
                        output[i].array_base = 0;
867
 
                        output[i].inst = BC_INST(ctx.bc, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT);
868
 
                        noutput++;
869
 
                }
 
1223
        if (ctx.type == TGSI_PROCESSOR_VERTEX && next_param_base == 0) {
 
1224
                        memset(&output[j], 0, sizeof(struct r600_bytecode_output));
 
1225
                        output[j].gpr = 0;
 
1226
                        output[j].elem_size = 3;
 
1227
                        output[j].swizzle_x = 7;
 
1228
                        output[j].swizzle_y = 7;
 
1229
                        output[j].swizzle_z = 7;
 
1230
                        output[j].swizzle_w = 7;
 
1231
                        output[j].burst_count = 1;
 
1232
                        output[j].barrier = 1;
 
1233
                        output[j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM;
 
1234
                        output[j].array_base = 0;
 
1235
                        output[j].inst = BC_INST(ctx.bc, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT);
 
1236
                        j++;
870
1237
        }
 
1238
 
871
1239
        /* add fake pixel export */
872
 
        if (ctx.type == TGSI_PROCESSOR_FRAGMENT && !noutput) {
873
 
                memset(&output[0], 0, sizeof(struct r600_bc_output));
874
 
                output[0].gpr = 0;
875
 
                output[0].elem_size = 3;
876
 
                output[0].swizzle_x = 7;
877
 
                output[0].swizzle_y = 7;
878
 
                output[0].swizzle_z = 7;
879
 
                output[0].swizzle_w = 7;
880
 
                output[0].burst_count = 1;
881
 
                output[0].barrier = 1;
882
 
                output[0].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
883
 
                output[0].array_base = 0;
884
 
                output[0].inst = BC_INST(ctx.bc, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT);
885
 
                noutput++;
 
1240
        if (ctx.type == TGSI_PROCESSOR_FRAGMENT && j == 0) {
 
1241
                memset(&output[j], 0, sizeof(struct r600_bytecode_output));
 
1242
                output[j].gpr = 0;
 
1243
                output[j].elem_size = 3;
 
1244
                output[j].swizzle_x = 7;
 
1245
                output[j].swizzle_y = 7;
 
1246
                output[j].swizzle_z = 7;
 
1247
                output[j].swizzle_w = 7;
 
1248
                output[j].burst_count = 1;
 
1249
                output[j].barrier = 1;
 
1250
                output[j].type = V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL;
 
1251
                output[j].array_base = 0;
 
1252
                output[j].inst = BC_INST(ctx.bc, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT);
 
1253
                j++;
886
1254
        }
 
1255
 
 
1256
        noutput = j;
 
1257
 
887
1258
        /* set export done on last export of each type */
888
1259
        for (i = noutput - 1, output_done = 0; i >= 0; i--) {
889
 
                if (ctx.bc->chiprev < CHIPREV_CAYMAN) {
 
1260
                if (ctx.bc->chip_class < CAYMAN) {
890
1261
                        if (i == (noutput - 1)) {
891
1262
                                output[i].end_of_program = 1;
892
1263
                        }
898
1269
        }
899
1270
        /* add output to bytecode */
900
1271
        for (i = 0; i < noutput; i++) {
901
 
                r = r600_bc_add_output(ctx.bc, &output[i]);
 
1272
                r = r600_bytecode_add_output(ctx.bc, &output[i]);
902
1273
                if (r)
903
1274
                        goto out_err;
904
1275
        }
905
1276
        /* add program end */
906
 
        if (ctx.bc->chiprev == CHIPREV_CAYMAN)
907
 
                cm_bc_add_cf_end(ctx.bc);
 
1277
        if (ctx.bc->chip_class == CAYMAN)
 
1278
                cm_bytecode_add_cf_end(ctx.bc);
908
1279
 
909
1280
        free(ctx.literals);
910
1281
        tgsi_parse_free(&ctx.parse);
927
1298
        return 0;
928
1299
}
929
1300
 
930
 
static void r600_bc_src(struct r600_bc_alu_src *bc_src,
 
1301
static void r600_bytecode_src(struct r600_bytecode_alu_src *bc_src,
931
1302
                        const struct r600_shader_src *shader_src,
932
1303
                        unsigned chan)
933
1304
{
939
1310
        bc_src->value = shader_src->value[bc_src->chan];
940
1311
}
941
1312
 
942
 
static void r600_bc_src_set_abs(struct r600_bc_alu_src *bc_src)
 
1313
static void r600_bytecode_src_set_abs(struct r600_bytecode_alu_src *bc_src)
943
1314
{
944
1315
        bc_src->abs = 1;
945
1316
        bc_src->neg = 0;
946
1317
}
947
1318
 
948
 
static void r600_bc_src_toggle_neg(struct r600_bc_alu_src *bc_src)
 
1319
static void r600_bytecode_src_toggle_neg(struct r600_bytecode_alu_src *bc_src)
949
1320
{
950
1321
        bc_src->neg = !bc_src->neg;
951
1322
}
953
1324
static void tgsi_dst(struct r600_shader_ctx *ctx,
954
1325
                     const struct tgsi_full_dst_register *tgsi_dst,
955
1326
                     unsigned swizzle,
956
 
                     struct r600_bc_alu_dst *r600_dst)
 
1327
                     struct r600_bytecode_alu_dst *r600_dst)
957
1328
{
958
1329
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
959
1330
 
980
1351
        return lasti;
981
1352
}
982
1353
 
983
 
static int tgsi_op2_s(struct r600_shader_ctx *ctx, int swap)
 
1354
static int tgsi_op2_s(struct r600_shader_ctx *ctx, int swap, int trans_only)
984
1355
{
985
1356
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
986
 
        struct r600_bc_alu alu;
 
1357
        struct r600_bytecode_alu alu;
987
1358
        int i, j, r;
988
1359
        int lasti = tgsi_last_instruction(inst->Dst[0].Register.WriteMask);
989
1360
 
991
1362
                if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
992
1363
                        continue;
993
1364
 
994
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1365
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
995
1366
                tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
996
1367
 
997
1368
                alu.inst = ctx->inst_info->r600_opcode;
998
1369
                if (!swap) {
999
1370
                        for (j = 0; j < inst->Instruction.NumSrcRegs; j++) {
1000
 
                                r600_bc_src(&alu.src[j], &ctx->src[j], i);
 
1371
                                r600_bytecode_src(&alu.src[j], &ctx->src[j], i);
1001
1372
                        }
1002
1373
                } else {
1003
 
                        r600_bc_src(&alu.src[0], &ctx->src[1], i);
1004
 
                        r600_bc_src(&alu.src[1], &ctx->src[0], i);
 
1374
                        r600_bytecode_src(&alu.src[0], &ctx->src[1], i);
 
1375
                        r600_bytecode_src(&alu.src[1], &ctx->src[0], i);
1005
1376
                }
1006
1377
                /* handle some special cases */
1007
1378
                switch (ctx->inst_info->tgsi_opcode) {
1008
1379
                case TGSI_OPCODE_SUB:
1009
 
                        r600_bc_src_toggle_neg(&alu.src[1]);
 
1380
                        r600_bytecode_src_toggle_neg(&alu.src[1]);
1010
1381
                        break;
1011
1382
                case TGSI_OPCODE_ABS:
1012
 
                        r600_bc_src_set_abs(&alu.src[0]);
 
1383
                        r600_bytecode_src_set_abs(&alu.src[0]);
1013
1384
                        break;
1014
1385
                default:
1015
1386
                        break;
1016
1387
                }
1017
 
                if (i == lasti) {
 
1388
                if (i == lasti || trans_only) {
1018
1389
                        alu.last = 1;
1019
1390
                }
1020
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
1391
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1021
1392
                if (r)
1022
1393
                        return r;
1023
1394
        }
1026
1397
 
1027
1398
static int tgsi_op2(struct r600_shader_ctx *ctx)
1028
1399
{
1029
 
        return tgsi_op2_s(ctx, 0);
 
1400
        return tgsi_op2_s(ctx, 0, 0);
1030
1401
}
1031
1402
 
1032
1403
static int tgsi_op2_swap(struct r600_shader_ctx *ctx)
1033
1404
{
1034
 
        return tgsi_op2_s(ctx, 1);
 
1405
        return tgsi_op2_s(ctx, 1, 0);
 
1406
}
 
1407
 
 
1408
static int tgsi_op2_trans(struct r600_shader_ctx *ctx)
 
1409
{
 
1410
        return tgsi_op2_s(ctx, 0, 1);
 
1411
}
 
1412
 
 
1413
static int tgsi_ineg(struct r600_shader_ctx *ctx)
 
1414
{
 
1415
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
 
1416
        struct r600_bytecode_alu alu;
 
1417
        int i, r;
 
1418
        int lasti = tgsi_last_instruction(inst->Dst[0].Register.WriteMask);
 
1419
 
 
1420
        for (i = 0; i < lasti + 1; i++) {
 
1421
 
 
1422
                if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
 
1423
                        continue;
 
1424
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
 
1425
                alu.inst = ctx->inst_info->r600_opcode;
 
1426
 
 
1427
                alu.src[0].sel = V_SQ_ALU_SRC_0;
 
1428
 
 
1429
                r600_bytecode_src(&alu.src[1], &ctx->src[0], i);
 
1430
 
 
1431
                tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
 
1432
 
 
1433
                if (i == lasti) {
 
1434
                        alu.last = 1;
 
1435
                }
 
1436
                r = r600_bytecode_add_alu(ctx->bc, &alu);
 
1437
                if (r)
 
1438
                        return r;
 
1439
        }
 
1440
        return 0;
 
1441
 
1035
1442
}
1036
1443
 
1037
1444
static int cayman_emit_float_instr(struct r600_shader_ctx *ctx)
1038
1445
{
1039
1446
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1040
1447
        int i, j, r;
1041
 
        struct r600_bc_alu alu;
 
1448
        struct r600_bytecode_alu alu;
1042
1449
        int last_slot = (inst->Dst[0].Register.WriteMask & 0x8) ? 4 : 3;
1043
1450
        
1044
1451
        for (i = 0 ; i < last_slot; i++) {
1045
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1452
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1046
1453
                alu.inst = ctx->inst_info->r600_opcode;
1047
1454
                for (j = 0; j < inst->Instruction.NumSrcRegs; j++) {
1048
 
                        r600_bc_src(&alu.src[j], &ctx->src[j], 0);
 
1455
                        r600_bytecode_src(&alu.src[j], &ctx->src[j], 0);
1049
1456
                }
1050
1457
                tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
1051
1458
                alu.dst.write = (inst->Dst[0].Register.WriteMask >> i) & 1;
1052
1459
 
1053
1460
                if (i == last_slot - 1)
1054
1461
                        alu.last = 1;
1055
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
1462
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1056
1463
                if (r)
1057
1464
                        return r;
1058
1465
        }
1071
1478
        static float neg_pi = -3.1415926535;
1072
1479
 
1073
1480
        int r;
1074
 
        struct r600_bc_alu alu;
 
1481
        struct r600_bytecode_alu alu;
1075
1482
 
1076
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1483
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1077
1484
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD);
1078
1485
        alu.is_op3 = 1;
1079
1486
 
1081
1488
        alu.dst.sel = ctx->temp_reg;
1082
1489
        alu.dst.write = 1;
1083
1490
 
1084
 
        r600_bc_src(&alu.src[0], &ctx->src[0], 0);
 
1491
        r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
1085
1492
 
1086
1493
        alu.src[1].sel = V_SQ_ALU_SRC_LITERAL;
1087
1494
        alu.src[1].chan = 0;
1089
1496
        alu.src[2].sel = V_SQ_ALU_SRC_0_5;
1090
1497
        alu.src[2].chan = 0;
1091
1498
        alu.last = 1;
1092
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
1499
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1093
1500
        if (r)
1094
1501
                return r;
1095
1502
 
1096
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1503
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1097
1504
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT);
1098
1505
 
1099
1506
        alu.dst.chan = 0;
1103
1510
        alu.src[0].sel = ctx->temp_reg;
1104
1511
        alu.src[0].chan = 0;
1105
1512
        alu.last = 1;
1106
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
1513
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1107
1514
        if (r)
1108
1515
                return r;
1109
1516
 
1110
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1517
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1111
1518
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD);
1112
1519
        alu.is_op3 = 1;
1113
1520
 
1123
1530
        alu.src[2].sel = V_SQ_ALU_SRC_LITERAL;
1124
1531
        alu.src[2].chan = 0;
1125
1532
 
1126
 
        if (ctx->bc->chiprev == CHIPREV_R600) {
 
1533
        if (ctx->bc->chip_class == R600) {
1127
1534
                alu.src[1].value = *(uint32_t *)&double_pi;
1128
1535
                alu.src[2].value = *(uint32_t *)&neg_pi;
1129
1536
        } else {
1133
1540
        }
1134
1541
 
1135
1542
        alu.last = 1;
1136
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
1543
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1137
1544
        if (r)
1138
1545
                return r;
1139
1546
        return 0;
1142
1549
static int cayman_trig(struct r600_shader_ctx *ctx)
1143
1550
{
1144
1551
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1145
 
        struct r600_bc_alu alu;
 
1552
        struct r600_bytecode_alu alu;
1146
1553
        int last_slot = (inst->Dst[0].Register.WriteMask & 0x8) ? 4 : 3;
1147
1554
        int i, r;
1148
1555
 
1152
1559
 
1153
1560
 
1154
1561
        for (i = 0; i < last_slot; i++) {
1155
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1562
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1156
1563
                alu.inst = ctx->inst_info->r600_opcode;
1157
1564
                alu.dst.chan = i;
1158
1565
 
1163
1570
                alu.src[0].chan = 0;
1164
1571
                if (i == last_slot - 1)
1165
1572
                        alu.last = 1;
1166
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
1573
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1167
1574
                if (r)
1168
1575
                        return r;
1169
1576
        }
1173
1580
static int tgsi_trig(struct r600_shader_ctx *ctx)
1174
1581
{
1175
1582
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1176
 
        struct r600_bc_alu alu;
 
1583
        struct r600_bytecode_alu alu;
1177
1584
        int i, r;
1178
1585
        int lasti = tgsi_last_instruction(inst->Dst[0].Register.WriteMask);
1179
1586
 
1181
1588
        if (r)
1182
1589
                return r;
1183
1590
 
1184
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1591
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1185
1592
        alu.inst = ctx->inst_info->r600_opcode;
1186
1593
        alu.dst.chan = 0;
1187
1594
        alu.dst.sel = ctx->temp_reg;
1190
1597
        alu.src[0].sel = ctx->temp_reg;
1191
1598
        alu.src[0].chan = 0;
1192
1599
        alu.last = 1;
1193
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
1600
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1194
1601
        if (r)
1195
1602
                return r;
1196
1603
 
1199
1606
                if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
1200
1607
                        continue;
1201
1608
 
1202
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1609
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1203
1610
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
1204
1611
 
1205
1612
                alu.src[0].sel = ctx->temp_reg;
1206
1613
                tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
1207
1614
                if (i == lasti)
1208
1615
                        alu.last = 1;
1209
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
1616
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1210
1617
                if (r)
1211
1618
                        return r;
1212
1619
        }
1216
1623
static int tgsi_scs(struct r600_shader_ctx *ctx)
1217
1624
{
1218
1625
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1219
 
        struct r600_bc_alu alu;
 
1626
        struct r600_bytecode_alu alu;
1220
1627
        int i, r;
1221
1628
 
1222
1629
        /* We'll only need the trig stuff if we are going to write to the
1230
1637
 
1231
1638
        /* dst.x = COS */
1232
1639
        if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_X) {
1233
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
1640
                if (ctx->bc->chip_class == CAYMAN) {
1234
1641
                        for (i = 0 ; i < 3; i++) {
1235
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1642
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1236
1643
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS);
1237
1644
                                tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
1238
1645
 
1244
1651
                                alu.src[0].chan = 0;
1245
1652
                                if (i == 2)
1246
1653
                                        alu.last = 1;
1247
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
1654
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
1248
1655
                                if (r)
1249
1656
                                        return r;
1250
1657
                        }
1251
1658
                } else {
1252
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1659
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1253
1660
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS);
1254
1661
                        tgsi_dst(ctx, &inst->Dst[0], 0, &alu.dst);
1255
1662
 
1256
1663
                        alu.src[0].sel = ctx->temp_reg;
1257
1664
                        alu.src[0].chan = 0;
1258
1665
                        alu.last = 1;
1259
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
1666
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
1260
1667
                        if (r)
1261
1668
                                return r;
1262
1669
                }
1264
1671
 
1265
1672
        /* dst.y = SIN */
1266
1673
        if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Y) {
1267
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
1674
                if (ctx->bc->chip_class == CAYMAN) {
1268
1675
                        for (i = 0 ; i < 3; i++) {
1269
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1676
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1270
1677
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN);
1271
1678
                                tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
1272
1679
                                if (i == 1)
1277
1684
                                alu.src[0].chan = 0;
1278
1685
                                if (i == 2)
1279
1686
                                        alu.last = 1;
1280
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
1687
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
1281
1688
                                if (r)
1282
1689
                                        return r;
1283
1690
                        }
1284
1691
                } else {
1285
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1692
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1286
1693
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN);
1287
1694
                        tgsi_dst(ctx, &inst->Dst[0], 1, &alu.dst);
1288
1695
 
1289
1696
                        alu.src[0].sel = ctx->temp_reg;
1290
1697
                        alu.src[0].chan = 0;
1291
1698
                        alu.last = 1;
1292
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
1699
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
1293
1700
                        if (r)
1294
1701
                                return r;
1295
1702
                }
1297
1704
 
1298
1705
        /* dst.z = 0.0; */
1299
1706
        if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_Z) {
1300
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1707
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1301
1708
 
1302
1709
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
1303
1710
 
1308
1715
 
1309
1716
                alu.last = 1;
1310
1717
 
1311
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
1718
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1312
1719
                if (r)
1313
1720
                        return r;
1314
1721
        }
1315
1722
 
1316
1723
        /* dst.w = 1.0; */
1317
1724
        if (inst->Dst[0].Register.WriteMask & TGSI_WRITEMASK_W) {
1318
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1725
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1319
1726
 
1320
1727
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
1321
1728
 
1326
1733
 
1327
1734
                alu.last = 1;
1328
1735
 
1329
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
1736
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1330
1737
                if (r)
1331
1738
                        return r;
1332
1739
        }
1336
1743
 
1337
1744
static int tgsi_kill(struct r600_shader_ctx *ctx)
1338
1745
{
1339
 
        struct r600_bc_alu alu;
 
1746
        struct r600_bytecode_alu alu;
1340
1747
        int i, r;
1341
1748
 
1342
1749
        for (i = 0; i < 4; i++) {
1343
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1750
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1344
1751
                alu.inst = ctx->inst_info->r600_opcode;
1345
1752
 
1346
1753
                alu.dst.chan = i;
1351
1758
                        alu.src[1].sel = V_SQ_ALU_SRC_1;
1352
1759
                        alu.src[1].neg = 1;
1353
1760
                } else {
1354
 
                        r600_bc_src(&alu.src[1], &ctx->src[0], i);
 
1761
                        r600_bytecode_src(&alu.src[1], &ctx->src[0], i);
1355
1762
                }
1356
1763
                if (i == 3) {
1357
1764
                        alu.last = 1;
1358
1765
                }
1359
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
1766
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1360
1767
                if (r)
1361
1768
                        return r;
1362
1769
        }
1370
1777
static int tgsi_lit(struct r600_shader_ctx *ctx)
1371
1778
{
1372
1779
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1373
 
        struct r600_bc_alu alu;
 
1780
        struct r600_bytecode_alu alu;
1374
1781
        int r;
1375
1782
 
1376
1783
        /* tmp.x = max(src.y, 0.0) */
1377
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1784
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1378
1785
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX);
1379
 
        r600_bc_src(&alu.src[0], &ctx->src[0], 1);
 
1786
        r600_bytecode_src(&alu.src[0], &ctx->src[0], 1);
1380
1787
        alu.src[1].sel  = V_SQ_ALU_SRC_0; /*0.0*/
1381
1788
        alu.src[1].chan = 1;
1382
1789
 
1385
1792
        alu.dst.write = 1;
1386
1793
 
1387
1794
        alu.last = 1;
1388
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
1795
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1389
1796
        if (r)
1390
1797
                return r;
1391
1798
 
1395
1802
                int sel;
1396
1803
                int i;
1397
1804
 
1398
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
1805
                if (ctx->bc->chip_class == CAYMAN) {
1399
1806
                        for (i = 0; i < 3; i++) {
1400
1807
                                /* tmp.z = log(tmp.x) */
1401
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1808
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1402
1809
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED);
1403
1810
                                alu.src[0].sel = ctx->temp_reg;
1404
1811
                                alu.src[0].chan = 0;
1410
1817
                                } else
1411
1818
                                        alu.dst.write = 0;
1412
1819
                                
1413
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
1820
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
1414
1821
                                if (r)
1415
1822
                                        return r;
1416
1823
                        }
1417
1824
                } else {
1418
1825
                        /* tmp.z = log(tmp.x) */
1419
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1826
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1420
1827
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED);
1421
1828
                        alu.src[0].sel = ctx->temp_reg;
1422
1829
                        alu.src[0].chan = 0;
1424
1831
                        alu.dst.chan = 2;
1425
1832
                        alu.dst.write = 1;
1426
1833
                        alu.last = 1;
1427
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
1834
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
1428
1835
                        if (r)
1429
1836
                                return r;
1430
1837
                }
1433
1840
                sel = alu.dst.sel;
1434
1841
 
1435
1842
                /* tmp.x = amd MUL_LIT(tmp.z, src.w, src.x ) */
1436
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1843
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1437
1844
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT);
1438
1845
                alu.src[0].sel  = sel;
1439
1846
                alu.src[0].chan = chan;
1440
 
                r600_bc_src(&alu.src[1], &ctx->src[0], 3);
1441
 
                r600_bc_src(&alu.src[2], &ctx->src[0], 0);
 
1847
                r600_bytecode_src(&alu.src[1], &ctx->src[0], 3);
 
1848
                r600_bytecode_src(&alu.src[2], &ctx->src[0], 0);
1442
1849
                alu.dst.sel = ctx->temp_reg;
1443
1850
                alu.dst.chan = 0;
1444
1851
                alu.dst.write = 1;
1445
1852
                alu.is_op3 = 1;
1446
1853
                alu.last = 1;
1447
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
1854
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1448
1855
                if (r)
1449
1856
                        return r;
1450
1857
 
1451
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
1858
                if (ctx->bc->chip_class == CAYMAN) {
1452
1859
                        for (i = 0; i < 3; i++) {
1453
1860
                                /* dst.z = exp(tmp.x) */
1454
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1861
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1455
1862
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE);
1456
1863
                                alu.src[0].sel = ctx->temp_reg;
1457
1864
                                alu.src[0].chan = 0;
1461
1868
                                        alu.last = 1;
1462
1869
                                } else
1463
1870
                                        alu.dst.write = 0;
1464
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
1871
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
1465
1872
                                if (r)
1466
1873
                                        return r;
1467
1874
                        }
1468
1875
                } else {
1469
1876
                        /* dst.z = exp(tmp.x) */
1470
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1877
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1471
1878
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE);
1472
1879
                        alu.src[0].sel = ctx->temp_reg;
1473
1880
                        alu.src[0].chan = 0;
1474
1881
                        tgsi_dst(ctx, &inst->Dst[0], 2, &alu.dst);
1475
1882
                        alu.last = 1;
1476
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
1883
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
1477
1884
                        if (r)
1478
1885
                                return r;
1479
1886
                }
1480
1887
        }
1481
1888
 
1482
1889
        /* dst.x, <- 1.0  */
1483
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1890
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1484
1891
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
1485
1892
        alu.src[0].sel  = V_SQ_ALU_SRC_1; /*1.0*/
1486
1893
        alu.src[0].chan = 0;
1487
1894
        tgsi_dst(ctx, &inst->Dst[0], 0, &alu.dst);
1488
1895
        alu.dst.write = (inst->Dst[0].Register.WriteMask >> 0) & 1;
1489
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
1896
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1490
1897
        if (r)
1491
1898
                return r;
1492
1899
 
1493
1900
        /* dst.y = max(src.x, 0.0) */
1494
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1901
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1495
1902
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX);
1496
 
        r600_bc_src(&alu.src[0], &ctx->src[0], 0);
 
1903
        r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
1497
1904
        alu.src[1].sel  = V_SQ_ALU_SRC_0; /*0.0*/
1498
1905
        alu.src[1].chan = 0;
1499
1906
        tgsi_dst(ctx, &inst->Dst[0], 1, &alu.dst);
1500
1907
        alu.dst.write = (inst->Dst[0].Register.WriteMask >> 1) & 1;
1501
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
1908
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1502
1909
        if (r)
1503
1910
                return r;
1504
1911
 
1505
1912
        /* dst.w, <- 1.0  */
1506
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1913
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1507
1914
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
1508
1915
        alu.src[0].sel  = V_SQ_ALU_SRC_1;
1509
1916
        alu.src[0].chan = 0;
1510
1917
        tgsi_dst(ctx, &inst->Dst[0], 3, &alu.dst);
1511
1918
        alu.dst.write = (inst->Dst[0].Register.WriteMask >> 3) & 1;
1512
1919
        alu.last = 1;
1513
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
1920
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1514
1921
        if (r)
1515
1922
                return r;
1516
1923
 
1520
1927
static int tgsi_rsq(struct r600_shader_ctx *ctx)
1521
1928
{
1522
1929
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1523
 
        struct r600_bc_alu alu;
 
1930
        struct r600_bytecode_alu alu;
1524
1931
        int i, r;
1525
1932
 
1526
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1933
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1527
1934
 
1528
1935
        /* FIXME:
1529
1936
         * For state trackers other than OpenGL, we'll want to use
1532
1939
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED);
1533
1940
 
1534
1941
        for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
1535
 
                r600_bc_src(&alu.src[i], &ctx->src[i], 0);
1536
 
                r600_bc_src_set_abs(&alu.src[i]);
 
1942
                r600_bytecode_src(&alu.src[i], &ctx->src[i], 0);
 
1943
                r600_bytecode_src_set_abs(&alu.src[i]);
1537
1944
        }
1538
1945
        alu.dst.sel = ctx->temp_reg;
1539
1946
        alu.dst.write = 1;
1540
1947
        alu.last = 1;
1541
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
1948
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1542
1949
        if (r)
1543
1950
                return r;
1544
1951
        /* replicate result */
1548
1955
static int tgsi_helper_tempx_replicate(struct r600_shader_ctx *ctx)
1549
1956
{
1550
1957
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1551
 
        struct r600_bc_alu alu;
 
1958
        struct r600_bytecode_alu alu;
1552
1959
        int i, r;
1553
1960
 
1554
1961
        for (i = 0; i < 4; i++) {
1555
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1962
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1556
1963
                alu.src[0].sel = ctx->temp_reg;
1557
1964
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
1558
1965
                alu.dst.chan = i;
1560
1967
                alu.dst.write = (inst->Dst[0].Register.WriteMask >> i) & 1;
1561
1968
                if (i == 3)
1562
1969
                        alu.last = 1;
1563
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
1970
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1564
1971
                if (r)
1565
1972
                        return r;
1566
1973
        }
1570
1977
static int tgsi_trans_srcx_replicate(struct r600_shader_ctx *ctx)
1571
1978
{
1572
1979
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1573
 
        struct r600_bc_alu alu;
 
1980
        struct r600_bytecode_alu alu;
1574
1981
        int i, r;
1575
1982
 
1576
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
1983
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1577
1984
        alu.inst = ctx->inst_info->r600_opcode;
1578
1985
        for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
1579
 
                r600_bc_src(&alu.src[i], &ctx->src[i], 0);
 
1986
                r600_bytecode_src(&alu.src[i], &ctx->src[i], 0);
1580
1987
        }
1581
1988
        alu.dst.sel = ctx->temp_reg;
1582
1989
        alu.dst.write = 1;
1583
1990
        alu.last = 1;
1584
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
1991
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1585
1992
        if (r)
1586
1993
                return r;
1587
1994
        /* replicate result */
1592
1999
{
1593
2000
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1594
2001
        int i, r;
1595
 
        struct r600_bc_alu alu;
 
2002
        struct r600_bytecode_alu alu;
1596
2003
        int last_slot = (inst->Dst[0].Register.WriteMask & 0x8) ? 4 : 3;
1597
2004
 
1598
2005
        for (i = 0; i < 3; i++) {
1599
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2006
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1600
2007
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
1601
 
                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
 
2008
                r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
1602
2009
                alu.dst.sel = ctx->temp_reg;
1603
2010
                alu.dst.chan = i;
1604
2011
                alu.dst.write = 1;
1605
2012
                if (i == 2)
1606
2013
                        alu.last = 1;
1607
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2014
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1608
2015
                if (r)
1609
2016
                        return r;
1610
2017
        }
1611
2018
 
1612
2019
        /* b * LOG2(a) */
1613
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2020
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1614
2021
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL);
1615
 
        r600_bc_src(&alu.src[0], &ctx->src[1], 0);
 
2022
        r600_bytecode_src(&alu.src[0], &ctx->src[1], 0);
1616
2023
        alu.src[1].sel = ctx->temp_reg;
1617
2024
        alu.dst.sel = ctx->temp_reg;
1618
2025
        alu.dst.write = 1;
1619
2026
        alu.last = 1;
1620
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
2027
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1621
2028
        if (r)
1622
2029
                return r;
1623
2030
 
1624
2031
        for (i = 0; i < last_slot; i++) {
1625
2032
                /* POW(a,b) = EXP2(b * LOG2(a))*/
1626
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2033
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1627
2034
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE);
1628
2035
                alu.src[0].sel = ctx->temp_reg;
1629
2036
 
1631
2038
                alu.dst.write = (inst->Dst[0].Register.WriteMask >> i) & 1;
1632
2039
                if (i == last_slot - 1)
1633
2040
                        alu.last = 1;
1634
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2041
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1635
2042
                if (r)
1636
2043
                        return r;
1637
2044
        }
1640
2047
 
1641
2048
static int tgsi_pow(struct r600_shader_ctx *ctx)
1642
2049
{
1643
 
        struct r600_bc_alu alu;
 
2050
        struct r600_bytecode_alu alu;
1644
2051
        int r;
1645
2052
 
1646
2053
        /* LOG2(a) */
1647
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2054
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1648
2055
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
1649
 
        r600_bc_src(&alu.src[0], &ctx->src[0], 0);
 
2056
        r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
1650
2057
        alu.dst.sel = ctx->temp_reg;
1651
2058
        alu.dst.write = 1;
1652
2059
        alu.last = 1;
1653
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
2060
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1654
2061
        if (r)
1655
2062
                return r;
1656
2063
        /* b * LOG2(a) */
1657
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2064
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1658
2065
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL);
1659
 
        r600_bc_src(&alu.src[0], &ctx->src[1], 0);
 
2066
        r600_bytecode_src(&alu.src[0], &ctx->src[1], 0);
1660
2067
        alu.src[1].sel = ctx->temp_reg;
1661
2068
        alu.dst.sel = ctx->temp_reg;
1662
2069
        alu.dst.write = 1;
1663
2070
        alu.last = 1;
1664
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
2071
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1665
2072
        if (r)
1666
2073
                return r;
1667
2074
        /* POW(a,b) = EXP2(b * LOG2(a))*/
1668
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2075
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1669
2076
        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE);
1670
2077
        alu.src[0].sel = ctx->temp_reg;
1671
2078
        alu.dst.sel = ctx->temp_reg;
1672
2079
        alu.dst.write = 1;
1673
2080
        alu.last = 1;
1674
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
2081
        r = r600_bytecode_add_alu(ctx->bc, &alu);
1675
2082
        if (r)
1676
2083
                return r;
1677
2084
        return tgsi_helper_tempx_replicate(ctx);
1680
2087
static int tgsi_ssg(struct r600_shader_ctx *ctx)
1681
2088
{
1682
2089
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1683
 
        struct r600_bc_alu alu;
 
2090
        struct r600_bytecode_alu alu;
1684
2091
        int i, r;
1685
2092
 
1686
2093
        /* tmp = (src > 0 ? 1 : src) */
1687
2094
        for (i = 0; i < 4; i++) {
1688
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2095
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1689
2096
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT);
1690
2097
                alu.is_op3 = 1;
1691
2098
 
1692
2099
                alu.dst.sel = ctx->temp_reg;
1693
2100
                alu.dst.chan = i;
1694
2101
 
1695
 
                r600_bc_src(&alu.src[0], &ctx->src[0], i);
 
2102
                r600_bytecode_src(&alu.src[0], &ctx->src[0], i);
1696
2103
                alu.src[1].sel = V_SQ_ALU_SRC_1;
1697
 
                r600_bc_src(&alu.src[2], &ctx->src[0], i);
 
2104
                r600_bytecode_src(&alu.src[2], &ctx->src[0], i);
1698
2105
 
1699
2106
                if (i == 3)
1700
2107
                        alu.last = 1;
1701
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2108
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1702
2109
                if (r)
1703
2110
                        return r;
1704
2111
        }
1705
2112
 
1706
2113
        /* dst = (-tmp > 0 ? -1 : tmp) */
1707
2114
        for (i = 0; i < 4; i++) {
1708
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2115
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1709
2116
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT);
1710
2117
                alu.is_op3 = 1;
1711
2118
                tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
1722
2129
 
1723
2130
                if (i == 3)
1724
2131
                        alu.last = 1;
1725
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2132
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1726
2133
                if (r)
1727
2134
                        return r;
1728
2135
        }
1731
2138
 
1732
2139
static int tgsi_helper_copy(struct r600_shader_ctx *ctx, struct tgsi_full_instruction *inst)
1733
2140
{
1734
 
        struct r600_bc_alu alu;
 
2141
        struct r600_bytecode_alu alu;
1735
2142
        int i, r;
1736
2143
 
1737
2144
        for (i = 0; i < 4; i++) {
1738
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2145
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1739
2146
                if (!(inst->Dst[0].Register.WriteMask & (1 << i))) {
1740
2147
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP);
1741
2148
                        alu.dst.chan = i;
1748
2155
                if (i == 3) {
1749
2156
                        alu.last = 1;
1750
2157
                }
1751
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2158
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1752
2159
                if (r)
1753
2160
                        return r;
1754
2161
        }
1758
2165
static int tgsi_op3(struct r600_shader_ctx *ctx)
1759
2166
{
1760
2167
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1761
 
        struct r600_bc_alu alu;
 
2168
        struct r600_bytecode_alu alu;
1762
2169
        int i, j, r;
1763
2170
        int lasti = tgsi_last_instruction(inst->Dst[0].Register.WriteMask);
1764
2171
 
1766
2173
                if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
1767
2174
                        continue;
1768
2175
 
1769
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2176
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1770
2177
                alu.inst = ctx->inst_info->r600_opcode;
1771
2178
                for (j = 0; j < inst->Instruction.NumSrcRegs; j++) {
1772
 
                        r600_bc_src(&alu.src[j], &ctx->src[j], i);
 
2179
                        r600_bytecode_src(&alu.src[j], &ctx->src[j], i);
1773
2180
                }
1774
2181
 
1775
2182
                tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
1779
2186
                if (i == lasti) {
1780
2187
                        alu.last = 1;
1781
2188
                }
1782
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2189
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1783
2190
                if (r)
1784
2191
                        return r;
1785
2192
        }
1789
2196
static int tgsi_dp(struct r600_shader_ctx *ctx)
1790
2197
{
1791
2198
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1792
 
        struct r600_bc_alu alu;
 
2199
        struct r600_bytecode_alu alu;
1793
2200
        int i, j, r;
1794
2201
 
1795
2202
        for (i = 0; i < 4; i++) {
1796
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2203
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1797
2204
                alu.inst = ctx->inst_info->r600_opcode;
1798
2205
                for (j = 0; j < inst->Instruction.NumSrcRegs; j++) {
1799
 
                        r600_bc_src(&alu.src[j], &ctx->src[j], i);
 
2206
                        r600_bytecode_src(&alu.src[j], &ctx->src[j], i);
1800
2207
                }
1801
2208
 
1802
2209
                tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
1829
2236
                if (i == 3) {
1830
2237
                        alu.last = 1;
1831
2238
                }
1832
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2239
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1833
2240
                if (r)
1834
2241
                        return r;
1835
2242
        }
1856
2263
{
1857
2264
        static float one_point_five = 1.5f;
1858
2265
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
1859
 
        struct r600_bc_tex tex;
1860
 
        struct r600_bc_alu alu;
 
2266
        struct r600_bytecode_tex tex;
 
2267
        struct r600_bytecode_alu alu;
1861
2268
        unsigned src_gpr;
1862
2269
        int r, i, j;
1863
2270
        int opcode;
1866
2273
        const boolean src_requires_loading = tgsi_tex_src_requires_loading(ctx, 0);
1867
2274
        boolean src_loaded = FALSE;
1868
2275
        unsigned sampler_src_reg = 1;
 
2276
        u8 offset_x = 0, offset_y = 0, offset_z = 0;
1869
2277
 
1870
2278
        src_gpr = tgsi_tex_get_src_gpr(ctx, 0);
1871
2279
 
1872
 
        if (inst->Instruction.Opcode == TGSI_OPCODE_TXD) {
 
2280
        if (inst->Instruction.Opcode == TGSI_OPCODE_TXF) {
 
2281
                /* get offset values */
 
2282
                if (inst->Texture.NumOffsets) {
 
2283
                        assert(inst->Texture.NumOffsets == 1);
 
2284
 
 
2285
                        offset_x = ctx->literals[inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleX] << 1;
 
2286
                        offset_y = ctx->literals[inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleY] << 1;
 
2287
                        offset_z = ctx->literals[inst->TexOffsets[0].Index + inst->TexOffsets[0].SwizzleZ] << 1;
 
2288
                }
 
2289
        } else if (inst->Instruction.Opcode == TGSI_OPCODE_TXD) {
1873
2290
                /* TGSI moves the sampler to src reg 3 for TXD */
1874
2291
                sampler_src_reg = 3;
1875
2292
 
1876
2293
                for (i = 1; i < 3; i++) {
1877
2294
                        /* set gradients h/v */
1878
 
                        memset(&tex, 0, sizeof(struct r600_bc_tex));
 
2295
                        memset(&tex, 0, sizeof(struct r600_bytecode_tex));
1879
2296
                        tex.inst = (i == 1) ? SQ_TEX_INST_SET_GRADIENTS_H :
1880
2297
                                SQ_TEX_INST_SET_GRADIENTS_V;
1881
2298
                        tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
1889
2306
                                tex.src_sel_w = 3;
1890
2307
 
1891
2308
                                for (j = 0; j < 4; j++) {
1892
 
                                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2309
                                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1893
2310
                                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
1894
 
                                        r600_bc_src(&alu.src[0], &ctx->src[i], j);
 
2311
                                        r600_bytecode_src(&alu.src[0], &ctx->src[i], j);
1895
2312
                                        alu.dst.sel = tex.src_gpr;
1896
2313
                                        alu.dst.chan = j;
1897
2314
                                        if (j == 3)
1898
2315
                                                alu.last = 1;
1899
2316
                                        alu.dst.write = 1;
1900
 
                                        r = r600_bc_add_alu(ctx->bc, &alu);
 
2317
                                        r = r600_bytecode_add_alu(ctx->bc, &alu);
1901
2318
                                        if (r)
1902
2319
                                                return r;
1903
2320
                                }
1918
2335
                                tex.coord_type_z = 1;
1919
2336
                                tex.coord_type_w = 1;
1920
2337
                        }
1921
 
                        r = r600_bc_add_tex(ctx->bc, &tex);
 
2338
                        r = r600_bytecode_add_tex(ctx->bc, &tex);
1922
2339
                        if (r)
1923
2340
                                return r;
1924
2341
                }
1925
2342
        } else if (inst->Instruction.Opcode == TGSI_OPCODE_TXP) {
1926
2343
                int out_chan;
1927
2344
                /* Add perspective divide */
1928
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
2345
                if (ctx->bc->chip_class == CAYMAN) {
1929
2346
                        out_chan = 2;
1930
2347
                        for (i = 0; i < 3; i++) {
1931
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2348
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1932
2349
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE);
1933
 
                                r600_bc_src(&alu.src[0], &ctx->src[0], 3);
 
2350
                                r600_bytecode_src(&alu.src[0], &ctx->src[0], 3);
1934
2351
 
1935
2352
                                alu.dst.sel = ctx->temp_reg;
1936
2353
                                alu.dst.chan = i;
1938
2355
                                        alu.last = 1;
1939
2356
                                if (out_chan == i)
1940
2357
                                        alu.dst.write = 1;
1941
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
2358
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
1942
2359
                                if (r)
1943
2360
                                        return r;
1944
2361
                        }
1945
2362
 
1946
2363
                } else {
1947
2364
                        out_chan = 3;
1948
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2365
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1949
2366
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE);
1950
 
                        r600_bc_src(&alu.src[0], &ctx->src[0], 3);
 
2367
                        r600_bytecode_src(&alu.src[0], &ctx->src[0], 3);
1951
2368
 
1952
2369
                        alu.dst.sel = ctx->temp_reg;
1953
2370
                        alu.dst.chan = out_chan;
1954
2371
                        alu.last = 1;
1955
2372
                        alu.dst.write = 1;
1956
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
2373
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
1957
2374
                        if (r)
1958
2375
                                return r;
1959
2376
                }
1960
2377
 
1961
2378
                for (i = 0; i < 3; i++) {
1962
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2379
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1963
2380
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL);
1964
2381
                        alu.src[0].sel = ctx->temp_reg;
1965
2382
                        alu.src[0].chan = out_chan;
1966
 
                        r600_bc_src(&alu.src[1], &ctx->src[0], i);
 
2383
                        r600_bytecode_src(&alu.src[1], &ctx->src[0], i);
1967
2384
                        alu.dst.sel = ctx->temp_reg;
1968
2385
                        alu.dst.chan = i;
1969
2386
                        alu.dst.write = 1;
1970
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
2387
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
1971
2388
                        if (r)
1972
2389
                                return r;
1973
2390
                }
1974
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2391
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1975
2392
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
1976
2393
                alu.src[0].sel = V_SQ_ALU_SRC_1;
1977
2394
                alu.src[0].chan = 0;
1979
2396
                alu.dst.chan = 3;
1980
2397
                alu.last = 1;
1981
2398
                alu.dst.write = 1;
1982
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2399
                r = r600_bytecode_add_alu(ctx->bc, &alu);
1983
2400
                if (r)
1984
2401
                        return r;
1985
2402
                src_loaded = TRUE;
1992
2409
 
1993
2410
                /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
1994
2411
                for (i = 0; i < 4; i++) {
1995
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2412
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
1996
2413
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE);
1997
 
                        r600_bc_src(&alu.src[0], &ctx->src[0], src0_swizzle[i]);
1998
 
                        r600_bc_src(&alu.src[1], &ctx->src[0], src1_swizzle[i]);
 
2414
                        r600_bytecode_src(&alu.src[0], &ctx->src[0], src0_swizzle[i]);
 
2415
                        r600_bytecode_src(&alu.src[1], &ctx->src[0], src1_swizzle[i]);
1999
2416
                        alu.dst.sel = ctx->temp_reg;
2000
2417
                        alu.dst.chan = i;
2001
2418
                        if (i == 3)
2002
2419
                                alu.last = 1;
2003
2420
                        alu.dst.write = 1;
2004
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
2421
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
2005
2422
                        if (r)
2006
2423
                                return r;
2007
2424
                }
2008
2425
 
2009
2426
                /* tmp1.z = RCP_e(|tmp1.z|) */
2010
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
2427
                if (ctx->bc->chip_class == CAYMAN) {
2011
2428
                        for (i = 0; i < 3; i++) {
2012
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2429
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2013
2430
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE);
2014
2431
                                alu.src[0].sel = ctx->temp_reg;
2015
2432
                                alu.src[0].chan = 2;
2020
2437
                                        alu.dst.write = 1;
2021
2438
                                if (i == 2)
2022
2439
                                        alu.last = 1;
2023
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
2440
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
2024
2441
                                if (r)
2025
2442
                                        return r;
2026
2443
                        }
2027
2444
                } else {
2028
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2445
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2029
2446
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE);
2030
2447
                        alu.src[0].sel = ctx->temp_reg;
2031
2448
                        alu.src[0].chan = 2;
2034
2451
                        alu.dst.chan = 2;
2035
2452
                        alu.dst.write = 1;
2036
2453
                        alu.last = 1;
2037
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
2454
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
2038
2455
                        if (r)
2039
2456
                                return r;
2040
2457
                }
2043
2460
                 * MULADD R0.y,  R0.y,  PS1,  (0x3FC00000, 1.5f).x
2044
2461
                 * muladd has no writemask, have to use another temp
2045
2462
                 */
2046
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2463
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2047
2464
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD);
2048
2465
                alu.is_op3 = 1;
2049
2466
 
2060
2477
                alu.dst.chan = 0;
2061
2478
                alu.dst.write = 1;
2062
2479
 
2063
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2480
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2064
2481
                if (r)
2065
2482
                        return r;
2066
2483
 
2067
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2484
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2068
2485
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD);
2069
2486
                alu.is_op3 = 1;
2070
2487
 
2082
2499
                alu.dst.write = 1;
2083
2500
 
2084
2501
                alu.last = 1;
2085
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2502
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2086
2503
                if (r)
2087
2504
                        return r;
2088
2505
 
2092
2509
 
2093
2510
        if (src_requires_loading && !src_loaded) {
2094
2511
                for (i = 0; i < 4; i++) {
2095
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2512
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2096
2513
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
2097
 
                        r600_bc_src(&alu.src[0], &ctx->src[0], i);
 
2514
                        r600_bytecode_src(&alu.src[0], &ctx->src[0], i);
2098
2515
                        alu.dst.sel = ctx->temp_reg;
2099
2516
                        alu.dst.chan = i;
2100
2517
                        if (i == 3)
2101
2518
                                alu.last = 1;
2102
2519
                        alu.dst.write = 1;
2103
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
2520
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
2104
2521
                        if (r)
2105
2522
                                return r;
2106
2523
                }
2109
2526
        }
2110
2527
 
2111
2528
        opcode = ctx->inst_info->r600_opcode;
2112
 
        if (inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D || inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D) {
 
2529
        if (inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D ||
 
2530
            inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D ||
 
2531
            inst->Texture.Texture == TGSI_TEXTURE_SHADOWRECT ||
 
2532
            inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D_ARRAY ||
 
2533
            inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D_ARRAY) {
2113
2534
                switch (opcode) {
2114
2535
                case SQ_TEX_INST_SAMPLE:
2115
2536
                        opcode = SQ_TEX_INST_SAMPLE_C;
2117
2538
                case SQ_TEX_INST_SAMPLE_L:
2118
2539
                        opcode = SQ_TEX_INST_SAMPLE_C_L;
2119
2540
                        break;
 
2541
                case SQ_TEX_INST_SAMPLE_LB:
 
2542
                        opcode = SQ_TEX_INST_SAMPLE_C_LB;
 
2543
                        break;
2120
2544
                case SQ_TEX_INST_SAMPLE_G:
2121
2545
                        opcode = SQ_TEX_INST_SAMPLE_C_G;
2122
2546
                        break;
2123
2547
                }
2124
2548
        }
2125
2549
 
2126
 
        memset(&tex, 0, sizeof(struct r600_bc_tex));
 
2550
        memset(&tex, 0, sizeof(struct r600_bytecode_tex));
2127
2551
        tex.inst = opcode;
2128
2552
 
2129
2553
        tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
2154
2578
                tex.src_sel_w = 1;
2155
2579
        }
2156
2580
 
2157
 
        if (inst->Texture.Texture != TGSI_TEXTURE_RECT) {
 
2581
        if (inst->Texture.Texture != TGSI_TEXTURE_RECT &&
 
2582
            inst->Texture.Texture != TGSI_TEXTURE_SHADOWRECT) {
2158
2583
                tex.coord_type_x = 1;
2159
2584
                tex.coord_type_y = 1;
2160
 
                tex.coord_type_z = 1;
2161
 
                tex.coord_type_w = 1;
2162
2585
        }
2163
 
 
2164
 
        if (inst->Texture.Texture == TGSI_TEXTURE_1D_ARRAY) {
2165
 
                tex.coord_type_z = 0;
2166
 
                tex.src_sel_z = tex.src_sel_y;
2167
 
        } else if (inst->Texture.Texture == TGSI_TEXTURE_2D_ARRAY)
2168
 
                tex.coord_type_z = 0;
2169
 
 
2170
 
        if (inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D || inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D)
 
2586
        tex.coord_type_z = 1;
 
2587
        tex.coord_type_w = 1;
 
2588
 
 
2589
        tex.offset_x = offset_x;
 
2590
        tex.offset_y = offset_y;
 
2591
        tex.offset_z = offset_z;
 
2592
 
 
2593
        /* Put the depth for comparison in W.
 
2594
         * TGSI_TEXTURE_SHADOW2D_ARRAY already has the depth in W.
 
2595
         * Some instructions expect the depth in Z. */
 
2596
        if ((inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D ||
 
2597
             inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D ||
 
2598
             inst->Texture.Texture == TGSI_TEXTURE_SHADOWRECT ||
 
2599
             inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D_ARRAY) &&
 
2600
            opcode != SQ_TEX_INST_SAMPLE_C_L &&
 
2601
            opcode != SQ_TEX_INST_SAMPLE_C_LB) {
2171
2602
                tex.src_sel_w = tex.src_sel_z;
2172
 
 
2173
 
        r = r600_bc_add_tex(ctx->bc, &tex);
 
2603
        }
 
2604
 
 
2605
        if (inst->Texture.Texture == TGSI_TEXTURE_1D_ARRAY ||
 
2606
            inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D_ARRAY) {
 
2607
                if (opcode == SQ_TEX_INST_SAMPLE_C_L ||
 
2608
                    opcode == SQ_TEX_INST_SAMPLE_C_LB) {
 
2609
                        /* the array index is read from Y */
 
2610
                        tex.coord_type_y = 0;
 
2611
                } else {
 
2612
                        /* the array index is read from Z */
 
2613
                        tex.coord_type_z = 0;
 
2614
                        tex.src_sel_z = tex.src_sel_y;
 
2615
                }
 
2616
        } else if (inst->Texture.Texture == TGSI_TEXTURE_2D_ARRAY ||
 
2617
                   inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D_ARRAY)
 
2618
                /* the array index is read from Z */
 
2619
                tex.coord_type_z = 0;
 
2620
 
 
2621
        r = r600_bytecode_add_tex(ctx->bc, &tex);
2174
2622
        if (r)
2175
2623
                return r;
2176
2624
 
2181
2629
static int tgsi_lrp(struct r600_shader_ctx *ctx)
2182
2630
{
2183
2631
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
2184
 
        struct r600_bc_alu alu;
 
2632
        struct r600_bytecode_alu alu;
2185
2633
        int lasti = tgsi_last_instruction(inst->Dst[0].Register.WriteMask);
2186
2634
        unsigned i;
2187
2635
        int r;
2192
2640
                        if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
2193
2641
                                continue;
2194
2642
 
2195
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2643
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2196
2644
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD);
2197
 
                        r600_bc_src(&alu.src[0], &ctx->src[1], i);
2198
 
                        r600_bc_src(&alu.src[1], &ctx->src[2], i);
 
2645
                        r600_bytecode_src(&alu.src[0], &ctx->src[1], i);
 
2646
                        r600_bytecode_src(&alu.src[1], &ctx->src[2], i);
2199
2647
                        alu.omod = 3;
2200
2648
                        tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
2201
2649
                        alu.dst.chan = i;
2202
2650
                        if (i == lasti) {
2203
2651
                                alu.last = 1;
2204
2652
                        }
2205
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
2653
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
2206
2654
                        if (r)
2207
2655
                                return r;
2208
2656
                }
2214
2662
                if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
2215
2663
                        continue;
2216
2664
 
2217
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2665
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2218
2666
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD);
2219
2667
                alu.src[0].sel = V_SQ_ALU_SRC_1;
2220
2668
                alu.src[0].chan = 0;
2221
 
                r600_bc_src(&alu.src[1], &ctx->src[0], i);
2222
 
                r600_bc_src_toggle_neg(&alu.src[1]);
 
2669
                r600_bytecode_src(&alu.src[1], &ctx->src[0], i);
 
2670
                r600_bytecode_src_toggle_neg(&alu.src[1]);
2223
2671
                alu.dst.sel = ctx->temp_reg;
2224
2672
                alu.dst.chan = i;
2225
2673
                if (i == lasti) {
2226
2674
                        alu.last = 1;
2227
2675
                }
2228
2676
                alu.dst.write = 1;
2229
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2677
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2230
2678
                if (r)
2231
2679
                        return r;
2232
2680
        }
2236
2684
                if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
2237
2685
                        continue;
2238
2686
 
2239
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2687
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2240
2688
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL);
2241
2689
                alu.src[0].sel = ctx->temp_reg;
2242
2690
                alu.src[0].chan = i;
2243
 
                r600_bc_src(&alu.src[1], &ctx->src[2], i);
 
2691
                r600_bytecode_src(&alu.src[1], &ctx->src[2], i);
2244
2692
                alu.dst.sel = ctx->temp_reg;
2245
2693
                alu.dst.chan = i;
2246
2694
                if (i == lasti) {
2247
2695
                        alu.last = 1;
2248
2696
                }
2249
2697
                alu.dst.write = 1;
2250
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2698
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2251
2699
                if (r)
2252
2700
                        return r;
2253
2701
        }
2257
2705
                if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
2258
2706
                        continue;
2259
2707
 
2260
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2708
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2261
2709
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD);
2262
2710
                alu.is_op3 = 1;
2263
 
                r600_bc_src(&alu.src[0], &ctx->src[0], i);
2264
 
                r600_bc_src(&alu.src[1], &ctx->src[1], i);
 
2711
                r600_bytecode_src(&alu.src[0], &ctx->src[0], i);
 
2712
                r600_bytecode_src(&alu.src[1], &ctx->src[1], i);
2265
2713
                alu.src[2].sel = ctx->temp_reg;
2266
2714
                alu.src[2].chan = i;
2267
2715
 
2270
2718
                if (i == lasti) {
2271
2719
                        alu.last = 1;
2272
2720
                }
2273
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2721
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2274
2722
                if (r)
2275
2723
                        return r;
2276
2724
        }
2280
2728
static int tgsi_cmp(struct r600_shader_ctx *ctx)
2281
2729
{
2282
2730
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
2283
 
        struct r600_bc_alu alu;
 
2731
        struct r600_bytecode_alu alu;
2284
2732
        int i, r;
2285
2733
        int lasti = tgsi_last_instruction(inst->Dst[0].Register.WriteMask);
2286
2734
 
2288
2736
                if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
2289
2737
                        continue;
2290
2738
 
2291
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2739
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2292
2740
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE);
2293
 
                r600_bc_src(&alu.src[0], &ctx->src[0], i);
2294
 
                r600_bc_src(&alu.src[1], &ctx->src[2], i);
2295
 
                r600_bc_src(&alu.src[2], &ctx->src[1], i);
 
2741
                r600_bytecode_src(&alu.src[0], &ctx->src[0], i);
 
2742
                r600_bytecode_src(&alu.src[1], &ctx->src[2], i);
 
2743
                r600_bytecode_src(&alu.src[2], &ctx->src[1], i);
2296
2744
                tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
2297
2745
                alu.dst.chan = i;
2298
2746
                alu.dst.write = 1;
2299
2747
                alu.is_op3 = 1;
2300
2748
                if (i == lasti)
2301
2749
                        alu.last = 1;
2302
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2750
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2303
2751
                if (r)
2304
2752
                        return r;
2305
2753
        }
2311
2759
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
2312
2760
        static const unsigned int src0_swizzle[] = {2, 0, 1};
2313
2761
        static const unsigned int src1_swizzle[] = {1, 2, 0};
2314
 
        struct r600_bc_alu alu;
 
2762
        struct r600_bytecode_alu alu;
2315
2763
        uint32_t use_temp = 0;
2316
2764
        int i, r;
2317
2765
 
2319
2767
                use_temp = 1;
2320
2768
 
2321
2769
        for (i = 0; i < 4; i++) {
2322
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2770
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2323
2771
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL);
2324
2772
                if (i < 3) {
2325
 
                        r600_bc_src(&alu.src[0], &ctx->src[0], src0_swizzle[i]);
2326
 
                        r600_bc_src(&alu.src[1], &ctx->src[1], src1_swizzle[i]);
 
2773
                        r600_bytecode_src(&alu.src[0], &ctx->src[0], src0_swizzle[i]);
 
2774
                        r600_bytecode_src(&alu.src[1], &ctx->src[1], src1_swizzle[i]);
2327
2775
                } else {
2328
2776
                        alu.src[0].sel = V_SQ_ALU_SRC_0;
2329
2777
                        alu.src[0].chan = i;
2337
2785
 
2338
2786
                if (i == 3)
2339
2787
                        alu.last = 1;
2340
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2788
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2341
2789
                if (r)
2342
2790
                        return r;
2343
2791
        }
2344
2792
 
2345
2793
        for (i = 0; i < 4; i++) {
2346
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2794
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2347
2795
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD);
2348
2796
 
2349
2797
                if (i < 3) {
2350
 
                        r600_bc_src(&alu.src[0], &ctx->src[0], src1_swizzle[i]);
2351
 
                        r600_bc_src(&alu.src[1], &ctx->src[1], src0_swizzle[i]);
 
2798
                        r600_bytecode_src(&alu.src[0], &ctx->src[0], src1_swizzle[i]);
 
2799
                        r600_bytecode_src(&alu.src[1], &ctx->src[1], src0_swizzle[i]);
2352
2800
                } else {
2353
2801
                        alu.src[0].sel = V_SQ_ALU_SRC_0;
2354
2802
                        alu.src[0].chan = i;
2369
2817
                alu.is_op3 = 1;
2370
2818
                if (i == 3)
2371
2819
                        alu.last = 1;
2372
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2820
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2373
2821
                if (r)
2374
2822
                        return r;
2375
2823
        }
2381
2829
static int tgsi_exp(struct r600_shader_ctx *ctx)
2382
2830
{
2383
2831
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
2384
 
        struct r600_bc_alu alu;
 
2832
        struct r600_bytecode_alu alu;
2385
2833
        int r;
2386
2834
        int i;
2387
2835
 
2388
2836
        /* result.x = 2^floor(src); */
2389
2837
        if (inst->Dst[0].Register.WriteMask & 1) {
2390
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2838
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2391
2839
 
2392
2840
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR);
2393
 
                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
 
2841
                r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
2394
2842
 
2395
2843
                alu.dst.sel = ctx->temp_reg;
2396
2844
                alu.dst.chan = 0;
2397
2845
                alu.dst.write = 1;
2398
2846
                alu.last = 1;
2399
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2847
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2400
2848
                if (r)
2401
2849
                        return r;
2402
2850
 
2403
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
2851
                if (ctx->bc->chip_class == CAYMAN) {
2404
2852
                        for (i = 0; i < 3; i++) {
2405
2853
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE);
2406
2854
                                alu.src[0].sel = ctx->temp_reg;
2412
2860
                                        alu.dst.write = 1;
2413
2861
                                if (i == 2)
2414
2862
                                        alu.last = 1;
2415
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
2863
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
2416
2864
                                if (r)
2417
2865
                                        return r;
2418
2866
                        }
2425
2873
                        alu.dst.chan = 0;
2426
2874
                        alu.dst.write = 1;
2427
2875
                        alu.last = 1;
2428
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
2876
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
2429
2877
                        if (r)
2430
2878
                                return r;
2431
2879
                }
2433
2881
 
2434
2882
        /* result.y = tmp - floor(tmp); */
2435
2883
        if ((inst->Dst[0].Register.WriteMask >> 1) & 1) {
2436
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2884
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2437
2885
 
2438
2886
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT);
2439
 
                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
 
2887
                r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
2440
2888
 
2441
2889
                alu.dst.sel = ctx->temp_reg;
2442
2890
#if 0
2449
2897
 
2450
2898
                alu.last = 1;
2451
2899
 
2452
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2900
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2453
2901
                if (r)
2454
2902
                        return r;
2455
2903
        }
2456
2904
 
2457
2905
        /* result.z = RoughApprox2ToX(tmp);*/
2458
2906
        if ((inst->Dst[0].Register.WriteMask >> 2) & 0x1) {
2459
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
2907
                if (ctx->bc->chip_class == CAYMAN) {
2460
2908
                        for (i = 0; i < 3; i++) {
2461
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2909
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2462
2910
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE);
2463
 
                                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
 
2911
                                r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
2464
2912
 
2465
2913
                                alu.dst.sel = ctx->temp_reg;
2466
2914
                                alu.dst.chan = i;
2469
2917
                                        alu.last = 1;
2470
2918
                                }
2471
2919
 
2472
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
2920
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
2473
2921
                                if (r)
2474
2922
                                        return r;
2475
2923
                        }
2476
2924
                } else {
2477
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2925
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2478
2926
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE);
2479
 
                        r600_bc_src(&alu.src[0], &ctx->src[0], 0);
 
2927
                        r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
2480
2928
 
2481
2929
                        alu.dst.sel = ctx->temp_reg;
2482
2930
                        alu.dst.write = 1;
2484
2932
 
2485
2933
                        alu.last = 1;
2486
2934
 
2487
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
2935
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
2488
2936
                        if (r)
2489
2937
                                return r;
2490
2938
                }
2492
2940
 
2493
2941
        /* result.w = 1.0;*/
2494
2942
        if ((inst->Dst[0].Register.WriteMask >> 3) & 0x1) {
2495
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2943
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2496
2944
 
2497
2945
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
2498
2946
                alu.src[0].sel = V_SQ_ALU_SRC_1;
2502
2950
                alu.dst.chan = 3;
2503
2951
                alu.dst.write = 1;
2504
2952
                alu.last = 1;
2505
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
2953
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2506
2954
                if (r)
2507
2955
                        return r;
2508
2956
        }
2512
2960
static int tgsi_log(struct r600_shader_ctx *ctx)
2513
2961
{
2514
2962
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
2515
 
        struct r600_bc_alu alu;
 
2963
        struct r600_bytecode_alu alu;
2516
2964
        int r;
2517
2965
        int i;
2518
2966
 
2519
2967
        /* result.x = floor(log2(|src|)); */
2520
2968
        if (inst->Dst[0].Register.WriteMask & 1) {
2521
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
2969
                if (ctx->bc->chip_class == CAYMAN) {
2522
2970
                        for (i = 0; i < 3; i++) {
2523
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2971
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2524
2972
 
2525
2973
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
2526
 
                                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
2527
 
                                r600_bc_src_set_abs(&alu.src[0]);
 
2974
                                r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
 
2975
                                r600_bytecode_src_set_abs(&alu.src[0]);
2528
2976
                        
2529
2977
                                alu.dst.sel = ctx->temp_reg;
2530
2978
                                alu.dst.chan = i;
2532
2980
                                        alu.dst.write = 1;
2533
2981
                                if (i == 2)
2534
2982
                                        alu.last = 1;
2535
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
2983
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
2536
2984
                                if (r)
2537
2985
                                        return r;
2538
2986
                        }
2539
2987
 
2540
2988
                } else {
2541
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
2989
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2542
2990
 
2543
2991
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
2544
 
                        r600_bc_src(&alu.src[0], &ctx->src[0], 0);
2545
 
                        r600_bc_src_set_abs(&alu.src[0]);
 
2992
                        r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
 
2993
                        r600_bytecode_src_set_abs(&alu.src[0]);
2546
2994
                        
2547
2995
                        alu.dst.sel = ctx->temp_reg;
2548
2996
                        alu.dst.chan = 0;
2549
2997
                        alu.dst.write = 1;
2550
2998
                        alu.last = 1;
2551
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
2999
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
2552
3000
                        if (r)
2553
3001
                                return r;
2554
3002
                }
2562
3010
                alu.dst.write = 1;
2563
3011
                alu.last = 1;
2564
3012
 
2565
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
3013
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2566
3014
                if (r)
2567
3015
                        return r;
2568
3016
        }
2570
3018
        /* result.y = |src.x| / (2 ^ floor(log2(|src.x|))); */
2571
3019
        if ((inst->Dst[0].Register.WriteMask >> 1) & 1) {
2572
3020
 
2573
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
3021
                if (ctx->bc->chip_class == CAYMAN) {
2574
3022
                        for (i = 0; i < 3; i++) {
2575
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3023
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2576
3024
 
2577
3025
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
2578
 
                                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
2579
 
                                r600_bc_src_set_abs(&alu.src[0]);
 
3026
                                r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
 
3027
                                r600_bytecode_src_set_abs(&alu.src[0]);
2580
3028
 
2581
3029
                                alu.dst.sel = ctx->temp_reg;
2582
3030
                                alu.dst.chan = i;
2585
3033
                                if (i == 2)
2586
3034
                                        alu.last = 1;
2587
3035
                                
2588
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
3036
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
2589
3037
                                if (r)
2590
3038
                                        return r;       
2591
3039
                        }
2592
3040
                } else {
2593
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3041
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2594
3042
 
2595
3043
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
2596
 
                        r600_bc_src(&alu.src[0], &ctx->src[0], 0);
2597
 
                        r600_bc_src_set_abs(&alu.src[0]);
 
3044
                        r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
 
3045
                        r600_bytecode_src_set_abs(&alu.src[0]);
2598
3046
 
2599
3047
                        alu.dst.sel = ctx->temp_reg;
2600
3048
                        alu.dst.chan = 1;
2601
3049
                        alu.dst.write = 1;
2602
3050
                        alu.last = 1;
2603
3051
 
2604
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
3052
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
2605
3053
                        if (r)
2606
3054
                                return r;
2607
3055
                }
2608
3056
 
2609
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3057
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2610
3058
 
2611
3059
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR);
2612
3060
                alu.src[0].sel = ctx->temp_reg;
2617
3065
                alu.dst.write = 1;
2618
3066
                alu.last = 1;
2619
3067
 
2620
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
3068
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2621
3069
                if (r)
2622
3070
                        return r;
2623
3071
 
2624
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
3072
                if (ctx->bc->chip_class == CAYMAN) {
2625
3073
                        for (i = 0; i < 3; i++) {
2626
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3074
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2627
3075
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE);
2628
3076
                                alu.src[0].sel = ctx->temp_reg;
2629
3077
                                alu.src[0].chan = 1;
2635
3083
                                if (i == 2)
2636
3084
                                        alu.last = 1;
2637
3085
 
2638
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
3086
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
2639
3087
                                if (r)
2640
3088
                                        return r;
2641
3089
                        }
2642
3090
                } else {
2643
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3091
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2644
3092
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE);
2645
3093
                        alu.src[0].sel = ctx->temp_reg;
2646
3094
                        alu.src[0].chan = 1;
2650
3098
                        alu.dst.write = 1;
2651
3099
                        alu.last = 1;
2652
3100
 
2653
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
3101
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
2654
3102
                        if (r)
2655
3103
                                return r;
2656
3104
                }
2657
3105
 
2658
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
3106
                if (ctx->bc->chip_class == CAYMAN) {
2659
3107
                        for (i = 0; i < 3; i++) {
2660
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3108
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2661
3109
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE);
2662
3110
                                alu.src[0].sel = ctx->temp_reg;
2663
3111
                                alu.src[0].chan = 1;
2669
3117
                                if (i == 2)
2670
3118
                                        alu.last = 1;
2671
3119
                                
2672
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
3120
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
2673
3121
                                if (r)
2674
3122
                                        return r;
2675
3123
                        }
2676
3124
                } else {
2677
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3125
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2678
3126
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE);
2679
3127
                        alu.src[0].sel = ctx->temp_reg;
2680
3128
                        alu.src[0].chan = 1;
2684
3132
                        alu.dst.write = 1;
2685
3133
                        alu.last = 1;
2686
3134
 
2687
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
3135
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
2688
3136
                        if (r)
2689
3137
                                return r;
2690
3138
                }
2691
3139
 
2692
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3140
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2693
3141
 
2694
3142
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL);
2695
3143
 
2696
 
                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
2697
 
                r600_bc_src_set_abs(&alu.src[0]);
 
3144
                r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
 
3145
                r600_bytecode_src_set_abs(&alu.src[0]);
2698
3146
 
2699
3147
                alu.src[1].sel = ctx->temp_reg;
2700
3148
                alu.src[1].chan = 1;
2704
3152
                alu.dst.write = 1;
2705
3153
                alu.last = 1;
2706
3154
 
2707
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
3155
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2708
3156
                if (r)
2709
3157
                        return r;
2710
3158
        }
2711
3159
 
2712
3160
        /* result.z = log2(|src|);*/
2713
3161
        if ((inst->Dst[0].Register.WriteMask >> 2) & 1) {
2714
 
                if (ctx->bc->chiprev == CHIPREV_CAYMAN) {
 
3162
                if (ctx->bc->chip_class == CAYMAN) {
2715
3163
                        for (i = 0; i < 3; i++) {
2716
 
                                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3164
                                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2717
3165
 
2718
3166
                                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
2719
 
                                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
2720
 
                                r600_bc_src_set_abs(&alu.src[0]);
 
3167
                                r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
 
3168
                                r600_bytecode_src_set_abs(&alu.src[0]);
2721
3169
 
2722
3170
                                alu.dst.sel = ctx->temp_reg;
2723
3171
                                if (i == 2)
2726
3174
                                if (i == 2)
2727
3175
                                        alu.last = 1;
2728
3176
 
2729
 
                                r = r600_bc_add_alu(ctx->bc, &alu);
 
3177
                                r = r600_bytecode_add_alu(ctx->bc, &alu);
2730
3178
                                if (r)
2731
3179
                                        return r;
2732
3180
                        }
2733
3181
                } else {
2734
 
                        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3182
                        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2735
3183
 
2736
3184
                        alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE);
2737
 
                        r600_bc_src(&alu.src[0], &ctx->src[0], 0);
2738
 
                        r600_bc_src_set_abs(&alu.src[0]);
 
3185
                        r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
 
3186
                        r600_bytecode_src_set_abs(&alu.src[0]);
2739
3187
 
2740
3188
                        alu.dst.sel = ctx->temp_reg;
2741
3189
                        alu.dst.write = 1;
2742
3190
                        alu.dst.chan = 2;
2743
3191
                        alu.last = 1;
2744
3192
 
2745
 
                        r = r600_bc_add_alu(ctx->bc, &alu);
 
3193
                        r = r600_bytecode_add_alu(ctx->bc, &alu);
2746
3194
                        if (r)
2747
3195
                                return r;
2748
3196
                }
2750
3198
 
2751
3199
        /* result.w = 1.0; */
2752
3200
        if ((inst->Dst[0].Register.WriteMask >> 3) & 1) {
2753
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3201
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2754
3202
 
2755
3203
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV);
2756
3204
                alu.src[0].sel = V_SQ_ALU_SRC_1;
2761
3209
                alu.dst.write = 1;
2762
3210
                alu.last = 1;
2763
3211
 
2764
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
3212
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2765
3213
                if (r)
2766
3214
                        return r;
2767
3215
        }
2772
3220
static int tgsi_eg_arl(struct r600_shader_ctx *ctx)
2773
3221
{
2774
3222
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
2775
 
        struct r600_bc_alu alu;
 
3223
        struct r600_bytecode_alu alu;
2776
3224
        int r;
2777
3225
 
2778
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3226
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2779
3227
 
2780
3228
        switch (inst->Instruction.Opcode) {
2781
3229
        case TGSI_OPCODE_ARL:
2784
3232
        case TGSI_OPCODE_ARR:
2785
3233
                alu.inst = EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT;
2786
3234
                break;
 
3235
        case TGSI_OPCODE_UARL:
 
3236
                alu.inst = EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV;
 
3237
                break;
2787
3238
        default:
2788
3239
                assert(0);
2789
3240
                return -1;
2790
3241
        }
2791
3242
 
2792
 
        r600_bc_src(&alu.src[0], &ctx->src[0], 0);
 
3243
        r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
2793
3244
        alu.last = 1;
2794
 
        alu.dst.sel = ctx->ar_reg;
 
3245
        alu.dst.sel = ctx->bc->ar_reg;
2795
3246
        alu.dst.write = 1;
2796
 
        r = r600_bc_add_alu(ctx->bc, &alu);
 
3247
        r = r600_bytecode_add_alu(ctx->bc, &alu);
2797
3248
        if (r)
2798
3249
                return r;
2799
3250
 
2800
 
        /* TODO: Note that the MOVA can be avoided if we never use AR for
2801
 
         * indexing non-CB registers in the current ALU clause. Similarly, we
2802
 
         * need to load AR from ar_reg again if we started a new clause
2803
 
         * between ARL and AR usage. The easy way to do that is to remove
2804
 
         * the MOVA here, and load it for the first AR access after ar_reg
2805
 
         * has been modified in each clause. */
2806
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
2807
 
        alu.inst = EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT;
2808
 
        alu.src[0].sel = ctx->ar_reg;
2809
 
        alu.src[0].chan = 0;
2810
 
        alu.last = 1;
2811
 
        r = r600_bc_add_alu(ctx->bc, &alu);
2812
 
        if (r)
2813
 
                return r;
 
3251
        ctx->bc->ar_loaded = 0;
2814
3252
        return 0;
2815
3253
}
2816
3254
static int tgsi_r600_arl(struct r600_shader_ctx *ctx)
2817
3255
{
2818
 
        /* TODO from r600c, ar values don't persist between clauses */
2819
3256
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
2820
 
        struct r600_bc_alu alu;
 
3257
        struct r600_bytecode_alu alu;
2821
3258
        int r;
2822
3259
 
2823
3260
        switch (inst->Instruction.Opcode) {
2824
3261
        case TGSI_OPCODE_ARL:
2825
3262
                memset(&alu, 0, sizeof(alu));
2826
3263
                alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR;
2827
 
                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
2828
 
                alu.dst.sel = ctx->ar_reg;
 
3264
                r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
 
3265
                alu.dst.sel = ctx->bc->ar_reg;
2829
3266
                alu.dst.write = 1;
2830
3267
                alu.last = 1;
2831
3268
 
2832
 
                if ((r = r600_bc_add_alu(ctx->bc, &alu)))
 
3269
                if ((r = r600_bytecode_add_alu(ctx->bc, &alu)))
2833
3270
                        return r;
2834
3271
 
2835
3272
                memset(&alu, 0, sizeof(alu));
2836
3273
                alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT;
2837
 
                alu.src[0].sel = ctx->ar_reg;
2838
 
                alu.dst.sel = ctx->ar_reg;
 
3274
                alu.src[0].sel = ctx->bc->ar_reg;
 
3275
                alu.dst.sel = ctx->bc->ar_reg;
2839
3276
                alu.dst.write = 1;
2840
3277
                alu.last = 1;
2841
3278
 
2842
 
                if ((r = r600_bc_add_alu(ctx->bc, &alu)))
 
3279
                if ((r = r600_bytecode_add_alu(ctx->bc, &alu)))
2843
3280
                        return r;
2844
3281
                break;
2845
3282
        case TGSI_OPCODE_ARR:
2846
3283
                memset(&alu, 0, sizeof(alu));
2847
3284
                alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT;
2848
 
                r600_bc_src(&alu.src[0], &ctx->src[0], 0);
2849
 
                alu.dst.sel = ctx->ar_reg;
2850
 
                alu.dst.write = 1;
2851
 
                alu.last = 1;
2852
 
 
2853
 
                if ((r = r600_bc_add_alu(ctx->bc, &alu)))
 
3285
                r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
 
3286
                alu.dst.sel = ctx->bc->ar_reg;
 
3287
                alu.dst.write = 1;
 
3288
                alu.last = 1;
 
3289
 
 
3290
                if ((r = r600_bytecode_add_alu(ctx->bc, &alu)))
 
3291
                        return r;
 
3292
                break;
 
3293
        case TGSI_OPCODE_UARL:
 
3294
                memset(&alu, 0, sizeof(alu));
 
3295
                alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV;
 
3296
                r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
 
3297
                alu.dst.sel = ctx->bc->ar_reg;
 
3298
                alu.dst.write = 1;
 
3299
                alu.last = 1;
 
3300
 
 
3301
                if ((r = r600_bytecode_add_alu(ctx->bc, &alu)))
2854
3302
                        return r;
2855
3303
                break;
2856
3304
        default:
2858
3306
                return -1;
2859
3307
        }
2860
3308
 
2861
 
        memset(&alu, 0, sizeof(alu));
2862
 
        alu.inst = V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT;
2863
 
        alu.src[0].sel = ctx->ar_reg;
2864
 
        alu.last = 1;
2865
 
 
2866
 
        r = r600_bc_add_alu(ctx->bc, &alu);
2867
 
        if (r)
2868
 
                return r;
2869
 
        ctx->bc->cf_last->r6xx_uses_waterfall = 1;
 
3309
        ctx->bc->ar_loaded = 0;
2870
3310
        return 0;
2871
3311
}
2872
3312
 
2873
3313
static int tgsi_opdst(struct r600_shader_ctx *ctx)
2874
3314
{
2875
3315
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
2876
 
        struct r600_bc_alu alu;
 
3316
        struct r600_bytecode_alu alu;
2877
3317
        int i, r = 0;
2878
3318
 
2879
3319
        for (i = 0; i < 4; i++) {
2880
 
                memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3320
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2881
3321
 
2882
3322
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL);
2883
3323
                tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
2885
3325
                if (i == 0 || i == 3) {
2886
3326
                        alu.src[0].sel = V_SQ_ALU_SRC_1;
2887
3327
                } else {
2888
 
                        r600_bc_src(&alu.src[0], &ctx->src[0], i);
 
3328
                        r600_bytecode_src(&alu.src[0], &ctx->src[0], i);
2889
3329
                }
2890
3330
 
2891
3331
                if (i == 0 || i == 2) {
2892
3332
                        alu.src[1].sel = V_SQ_ALU_SRC_1;
2893
3333
                } else {
2894
 
                        r600_bc_src(&alu.src[1], &ctx->src[1], i);
 
3334
                        r600_bytecode_src(&alu.src[1], &ctx->src[1], i);
2895
3335
                }
2896
3336
                if (i == 3)
2897
3337
                        alu.last = 1;
2898
 
                r = r600_bc_add_alu(ctx->bc, &alu);
 
3338
                r = r600_bytecode_add_alu(ctx->bc, &alu);
2899
3339
                if (r)
2900
3340
                        return r;
2901
3341
        }
2904
3344
 
2905
3345
static int emit_logic_pred(struct r600_shader_ctx *ctx, int opcode)
2906
3346
{
2907
 
        struct r600_bc_alu alu;
 
3347
        struct r600_bytecode_alu alu;
2908
3348
        int r;
2909
3349
 
2910
 
        memset(&alu, 0, sizeof(struct r600_bc_alu));
 
3350
        memset(&alu, 0, sizeof(struct r600_bytecode_alu));
2911
3351
        alu.inst = opcode;
2912
3352
        alu.predicate = 1;
2913
3353
 
2915
3355
        alu.dst.write = 1;
2916
3356
        alu.dst.chan = 0;
2917
3357
 
2918
 
        r600_bc_src(&alu.src[0], &ctx->src[0], 0);
 
3358
        r600_bytecode_src(&alu.src[0], &ctx->src[0], 0);
2919
3359
        alu.src[1].sel = V_SQ_ALU_SRC_0;
2920
3360
        alu.src[1].chan = 0;
2921
3361
 
2922
3362
        alu.last = 1;
2923
3363
 
2924
 
        r = r600_bc_add_alu_type(ctx->bc, &alu, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE));
 
3364
        r = r600_bytecode_add_alu_type(ctx->bc, &alu, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE));
2925
3365
        if (r)
2926
3366
                return r;
2927
3367
        return 0;
2929
3369
 
2930
3370
static int pops(struct r600_shader_ctx *ctx, int pops)
2931
3371
{
2932
 
        int alu_pop = 3;
2933
 
        if (ctx->bc->cf_last) {
2934
 
                if (ctx->bc->cf_last->inst == CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU) << 3)
2935
 
                        alu_pop = 0;
2936
 
                else if (ctx->bc->cf_last->inst == CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER) << 3)
2937
 
                        alu_pop = 1;
 
3372
        unsigned force_pop = ctx->bc->force_add_cf;
 
3373
 
 
3374
        if (!force_pop) {
 
3375
                int alu_pop = 3;
 
3376
                if (ctx->bc->cf_last) {
 
3377
                        if (ctx->bc->cf_last->inst == CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU))
 
3378
                                alu_pop = 0;
 
3379
                        else if (ctx->bc->cf_last->inst == CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER))
 
3380
                                alu_pop = 1;
 
3381
                }
 
3382
                alu_pop += pops;
 
3383
                if (alu_pop == 1) {
 
3384
                        ctx->bc->cf_last->inst = CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER);
 
3385
                        ctx->bc->force_add_cf = 1;
 
3386
                } else if (alu_pop == 2) {
 
3387
                        ctx->bc->cf_last->inst = CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER);
 
3388
                        ctx->bc->force_add_cf = 1;
 
3389
                } else {
 
3390
                        force_pop = 1;
 
3391
                }
2938
3392
        }
2939
 
        alu_pop += pops;
2940
 
        if (alu_pop == 1) {
2941
 
                ctx->bc->cf_last->inst = CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER) << 3;
2942
 
                ctx->bc->force_add_cf = 1;
2943
 
        } else if (alu_pop == 2) {
2944
 
                ctx->bc->cf_last->inst = CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER) << 3;
2945
 
                ctx->bc->force_add_cf = 1;
2946
 
        } else {
2947
 
                r600_bc_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP));
 
3393
 
 
3394
        if (force_pop) {
 
3395
                r600_bytecode_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP));
2948
3396
                ctx->bc->cf_last->pop_count = pops;
2949
3397
                ctx->bc->cf_last->cf_addr = ctx->bc->cf_last->id + 2;
2950
3398
        }
 
3399
 
2951
3400
        return 0;
2952
3401
}
2953
3402
 
3014
3463
{
3015
3464
        struct r600_cf_stack_entry *sp = &ctx->bc->fc_stack[fc_sp];
3016
3465
 
3017
 
        sp->mid = (struct r600_bc_cf **)realloc((void *)sp->mid,
3018
 
                                                sizeof(struct r600_bc_cf *) * (sp->num_mid + 1));
 
3466
        sp->mid = (struct r600_bytecode_cf **)realloc((void *)sp->mid,
 
3467
                                                sizeof(struct r600_bytecode_cf *) * (sp->num_mid + 1));
3019
3468
        sp->mid[sp->num_mid] = ctx->bc->cf_last;
3020
3469
        sp->num_mid++;
3021
3470
}
3043
3492
#if 0
3044
3493
static int emit_return(struct r600_shader_ctx *ctx)
3045
3494
{
3046
 
        r600_bc_add_cfinst(ctx->bc, V_SQ_CF_WORD1_SQ_CF_INST_RETURN);
 
3495
        r600_bytecode_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_RETURN));
3047
3496
        return 0;
3048
3497
}
3049
3498
 
3050
3499
static int emit_jump_to_offset(struct r600_shader_ctx *ctx, int pops, int offset)
3051
3500
{
3052
3501
 
3053
 
        r600_bc_add_cfinst(ctx->bc, V_SQ_CF_WORD1_SQ_CF_INST_JUMP);
 
3502
        r600_bytecode_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP));
3054
3503
        ctx->bc->cf_last->pop_count = pops;
3055
3504
        /* TODO work out offset */
3056
3505
        return 0;
3079
3528
{
3080
3529
        emit_testflag(ctx);
3081
3530
 
3082
 
        r600_bc_add_cfinst(ctx->bc, ctx->inst_info->r600_opcode);
 
3531
        r600_bytecode_add_cfinst(ctx->bc, ctx->inst_info->r600_opcode);
3083
3532
        ctx->bc->cf_last->pop_count = 1;
3084
3533
 
3085
3534
        fc_set_mid(ctx, fc_sp);
3090
3539
 
3091
3540
static int tgsi_if(struct r600_shader_ctx *ctx)
3092
3541
{
3093
 
        emit_logic_pred(ctx, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE));
 
3542
        emit_logic_pred(ctx, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT));
3094
3543
 
3095
 
        r600_bc_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP));
 
3544
        r600_bytecode_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP));
3096
3545
 
3097
3546
        fc_pushlevel(ctx, FC_IF);
3098
3547
 
3102
3551
 
3103
3552
static int tgsi_else(struct r600_shader_ctx *ctx)
3104
3553
{
3105
 
        r600_bc_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE));
 
3554
        r600_bytecode_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE));
3106
3555
        ctx->bc->cf_last->pop_count = 1;
3107
3556
 
3108
3557
        fc_set_mid(ctx, ctx->bc->fc_sp);
3132
3581
 
3133
3582
static int tgsi_bgnloop(struct r600_shader_ctx *ctx)
3134
3583
{
3135
 
        r600_bc_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL));
 
3584
        r600_bytecode_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL));
3136
3585
 
3137
3586
        fc_pushlevel(ctx, FC_LOOP);
3138
3587
 
3145
3594
{
3146
3595
        int i;
3147
3596
 
3148
 
        r600_bc_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END));
 
3597
        r600_bytecode_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END));
3149
3598
 
3150
3599
        if (ctx->bc->fc_stack[ctx->bc->fc_sp].type != FC_LOOP) {
3151
3600
                R600_ERR("loop/endloop in shader code are not paired.\n");
3185
3634
                return -EINVAL;
3186
3635
        }
3187
3636
 
3188
 
        r600_bc_add_cfinst(ctx->bc, ctx->inst_info->r600_opcode);
 
3637
        r600_bytecode_add_cfinst(ctx->bc, ctx->inst_info->r600_opcode);
3189
3638
        ctx->bc->cf_last->pop_count = 1;
3190
3639
 
3191
3640
        fc_set_mid(ctx, fscp);
3195
3644
        return 0;
3196
3645
}
3197
3646
 
 
3647
static int tgsi_umad(struct r600_shader_ctx *ctx)
 
3648
{
 
3649
        struct tgsi_full_instruction *inst = &ctx->parse.FullToken.FullInstruction;
 
3650
        struct r600_bytecode_alu alu;
 
3651
        int i, j, r;
 
3652
        int lasti = tgsi_last_instruction(inst->Dst[0].Register.WriteMask);
 
3653
 
 
3654
        /* src0 * src1 */
 
3655
        for (i = 0; i < lasti + 1; i++) {
 
3656
                if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
 
3657
                        continue;
 
3658
 
 
3659
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
 
3660
 
 
3661
                alu.dst.chan = i;
 
3662
                alu.dst.sel = ctx->temp_reg;
 
3663
                alu.dst.write = 1;
 
3664
 
 
3665
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT);
 
3666
                for (j = 0; j < 2; j++) {
 
3667
                        r600_bytecode_src(&alu.src[j], &ctx->src[j], i);
 
3668
                }
 
3669
 
 
3670
                alu.last = 1;
 
3671
                r = r600_bytecode_add_alu(ctx->bc, &alu);
 
3672
                if (r)
 
3673
                        return r;
 
3674
        }
 
3675
 
 
3676
 
 
3677
        for (i = 0; i < lasti + 1; i++) {
 
3678
                if (!(inst->Dst[0].Register.WriteMask & (1 << i)))
 
3679
                        continue;
 
3680
 
 
3681
                memset(&alu, 0, sizeof(struct r600_bytecode_alu));
 
3682
                tgsi_dst(ctx, &inst->Dst[0], i, &alu.dst);
 
3683
 
 
3684
                alu.inst = CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT);
 
3685
 
 
3686
                alu.src[0].sel = ctx->temp_reg;
 
3687
                alu.src[0].chan = i;
 
3688
                
 
3689
                r600_bytecode_src(&alu.src[1], &ctx->src[2], i);
 
3690
                if (i == lasti) {
 
3691
                        alu.last = 1;
 
3692
                }
 
3693
                r = r600_bytecode_add_alu(ctx->bc, &alu);
 
3694
                if (r)
 
3695
                        return r;
 
3696
        }
 
3697
        return 0;
 
3698
}
 
3699
 
3198
3700
static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction[] = {
3199
3701
        {TGSI_OPCODE_ARL,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_r600_arl},
3200
3702
        {TGSI_OPCODE_MOV,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV, tgsi_op2},
3231
3733
        {TGSI_OPCODE_FRC,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT, tgsi_op2},
3232
3734
        {TGSI_OPCODE_CLAMP,     0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3233
3735
        {TGSI_OPCODE_FLR,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR, tgsi_op2},
3234
 
        {TGSI_OPCODE_ROUND,     0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3736
        {TGSI_OPCODE_ROUND,     0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE, tgsi_op2},
3235
3737
        {TGSI_OPCODE_EX2,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE, tgsi_trans_srcx_replicate},
3236
3738
        {TGSI_OPCODE_LG2,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE, tgsi_trans_srcx_replicate},
3237
3739
        {TGSI_OPCODE_POW,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_pow},
3273
3775
        {TGSI_OPCODE_SSG,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_ssg},
3274
3776
        {TGSI_OPCODE_CMP,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_cmp},
3275
3777
        {TGSI_OPCODE_SCS,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_scs},
3276
 
        {TGSI_OPCODE_TXB,       0, SQ_TEX_INST_SAMPLE_L, tgsi_tex},
 
3778
        {TGSI_OPCODE_TXB,       0, SQ_TEX_INST_SAMPLE_LB, tgsi_tex},
3277
3779
        {TGSI_OPCODE_NRM,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3278
3780
        {TGSI_OPCODE_DIV,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3279
3781
        {TGSI_OPCODE_DP2,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4, tgsi_dp},
3291
3793
        {TGSI_OPCODE_PUSHA,     0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3292
3794
        {TGSI_OPCODE_POPA,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3293
3795
        {TGSI_OPCODE_CEIL,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3294
 
        {TGSI_OPCODE_I2F,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3295
 
        {TGSI_OPCODE_NOT,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3796
        {TGSI_OPCODE_I2F,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT, tgsi_op2_trans},
 
3797
        {TGSI_OPCODE_NOT,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT, tgsi_op2},
3296
3798
        {TGSI_OPCODE_TRUNC,     0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC, tgsi_op2},
3297
3799
        {TGSI_OPCODE_SHL,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3298
3800
        /* gap */
3299
3801
        {88,                    0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3300
 
        {TGSI_OPCODE_AND,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3301
 
        {TGSI_OPCODE_OR,        0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3802
        {TGSI_OPCODE_AND,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT, tgsi_op2},
 
3803
        {TGSI_OPCODE_OR,        0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_OR_INT, tgsi_op2},
3302
3804
        {TGSI_OPCODE_MOD,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3303
 
        {TGSI_OPCODE_XOR,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3805
        {TGSI_OPCODE_XOR,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT, tgsi_op2},
3304
3806
        {TGSI_OPCODE_SAD,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3305
 
        {TGSI_OPCODE_TXF,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3306
 
        {TGSI_OPCODE_TXQ,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3807
        {TGSI_OPCODE_TXF,       0, SQ_TEX_INST_LD, tgsi_tex},
 
3808
        {TGSI_OPCODE_TXQ,       0, SQ_TEX_INST_GET_TEXTURE_RESINFO, tgsi_tex},
3307
3809
        {TGSI_OPCODE_CONT,      0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE, tgsi_loop_brk_cont},
3308
3810
        {TGSI_OPCODE_EMIT,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3309
3811
        {TGSI_OPCODE_ENDPRIM,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3330
3832
        {TGSI_OPCODE_END,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_end},  /* aka HALT */
3331
3833
        /* gap */
3332
3834
        {118,                   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3333
 
        {TGSI_OPCODE_F2I,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3835
        {TGSI_OPCODE_F2I,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT, tgsi_op2},
3334
3836
        {TGSI_OPCODE_IDIV,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3335
 
        {TGSI_OPCODE_IMAX,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3336
 
        {TGSI_OPCODE_IMIN,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3337
 
        {TGSI_OPCODE_INEG,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3338
 
        {TGSI_OPCODE_ISGE,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3837
        {TGSI_OPCODE_IMAX,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT, tgsi_op2},
 
3838
        {TGSI_OPCODE_IMIN,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT, tgsi_op2},
 
3839
        {TGSI_OPCODE_INEG,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT, tgsi_op2},
 
3840
        {TGSI_OPCODE_ISGE,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT, tgsi_op2},
3339
3841
        {TGSI_OPCODE_ISHR,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3340
 
        {TGSI_OPCODE_ISLT,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3341
 
        {TGSI_OPCODE_F2U,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3342
 
        {TGSI_OPCODE_U2F,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3343
 
        {TGSI_OPCODE_UADD,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3842
        {TGSI_OPCODE_ISLT,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT, tgsi_op2},
 
3843
        {TGSI_OPCODE_F2U,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_UINT, tgsi_op2},
 
3844
        {TGSI_OPCODE_U2F,       0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT, tgsi_op2},
 
3845
        {TGSI_OPCODE_UADD,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT, tgsi_op2},
3344
3846
        {TGSI_OPCODE_UDIV,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3345
 
        {TGSI_OPCODE_UMAD,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3346
 
        {TGSI_OPCODE_UMAX,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3347
 
        {TGSI_OPCODE_UMIN,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3847
        {TGSI_OPCODE_UMAD,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_umad},
 
3848
        {TGSI_OPCODE_UMAX,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_UINT, tgsi_op2},
 
3849
        {TGSI_OPCODE_UMIN,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_UINT, tgsi_op2},
3348
3850
        {TGSI_OPCODE_UMOD,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3349
 
        {TGSI_OPCODE_UMUL,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3350
 
        {TGSI_OPCODE_USEQ,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3351
 
        {TGSI_OPCODE_USGE,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3851
        {TGSI_OPCODE_UMUL,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT, tgsi_op2},
 
3852
        {TGSI_OPCODE_USEQ,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE_INT, tgsi_op2},
 
3853
        {TGSI_OPCODE_USGE,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT, tgsi_op2},
3352
3854
        {TGSI_OPCODE_USHR,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3353
 
        {TGSI_OPCODE_USLT,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3354
 
        {TGSI_OPCODE_USNE,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3855
        {TGSI_OPCODE_USLT,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT, tgsi_op2_swap},
 
3856
        {TGSI_OPCODE_USNE,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE_INT, tgsi_op2_swap},
3355
3857
        {TGSI_OPCODE_SWITCH,    0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3356
3858
        {TGSI_OPCODE_CASE,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3357
3859
        {TGSI_OPCODE_DEFAULT,   0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3358
3860
        {TGSI_OPCODE_ENDSWITCH, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3861
        {TGSI_OPCODE_LOAD,      0, 0, tgsi_unsupported},
 
3862
        {TGSI_OPCODE_LOAD_MS,   0, 0, tgsi_unsupported},
 
3863
        {TGSI_OPCODE_SAMPLE,    0, 0, tgsi_unsupported},
 
3864
        {TGSI_OPCODE_SAMPLE_B,  0, 0, tgsi_unsupported},
 
3865
        {TGSI_OPCODE_SAMPLE_C,  0, 0, tgsi_unsupported},
 
3866
        {TGSI_OPCODE_SAMPLE_C_LZ, 0, 0, tgsi_unsupported},
 
3867
        {TGSI_OPCODE_SAMPLE_D,  0, 0, tgsi_unsupported},
 
3868
        {TGSI_OPCODE_SAMPLE_L,  0, 0, tgsi_unsupported},
 
3869
        {TGSI_OPCODE_GATHER4,   0, 0, tgsi_unsupported},
 
3870
        {TGSI_OPCODE_RESINFO,   0, 0, tgsi_unsupported},
 
3871
        {TGSI_OPCODE_SAMPLE_POS, 0, 0, tgsi_unsupported},
 
3872
        {TGSI_OPCODE_SAMPLE_INFO, 0, 0, tgsi_unsupported},
 
3873
        {TGSI_OPCODE_UARL,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT, tgsi_r600_arl},
 
3874
        {TGSI_OPCODE_UCMP,      0, 0, tgsi_unsupported},
3359
3875
        {TGSI_OPCODE_LAST,      0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3360
3876
};
3361
3877
 
3389
3905
        {TGSI_OPCODE_FRC,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT, tgsi_op2},
3390
3906
        {TGSI_OPCODE_CLAMP,     0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3391
3907
        {TGSI_OPCODE_FLR,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR, tgsi_op2},
3392
 
        {TGSI_OPCODE_ROUND,     0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3908
        {TGSI_OPCODE_ROUND,     0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE, tgsi_op2},
3393
3909
        {TGSI_OPCODE_EX2,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE, tgsi_trans_srcx_replicate},
3394
3910
        {TGSI_OPCODE_LG2,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE, tgsi_trans_srcx_replicate},
3395
3911
        {TGSI_OPCODE_POW,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_pow},
3431
3947
        {TGSI_OPCODE_SSG,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_ssg},
3432
3948
        {TGSI_OPCODE_CMP,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_cmp},
3433
3949
        {TGSI_OPCODE_SCS,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_scs},
3434
 
        {TGSI_OPCODE_TXB,       0, SQ_TEX_INST_SAMPLE_L, tgsi_tex},
 
3950
        {TGSI_OPCODE_TXB,       0, SQ_TEX_INST_SAMPLE_LB, tgsi_tex},
3435
3951
        {TGSI_OPCODE_NRM,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3436
3952
        {TGSI_OPCODE_DIV,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3437
3953
        {TGSI_OPCODE_DP2,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4, tgsi_dp},
3449
3965
        {TGSI_OPCODE_PUSHA,     0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3450
3966
        {TGSI_OPCODE_POPA,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3451
3967
        {TGSI_OPCODE_CEIL,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3452
 
        {TGSI_OPCODE_I2F,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3453
 
        {TGSI_OPCODE_NOT,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3968
        {TGSI_OPCODE_I2F,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT, tgsi_op2_trans},
 
3969
        {TGSI_OPCODE_NOT,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT, tgsi_op2},
3454
3970
        {TGSI_OPCODE_TRUNC,     0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC, tgsi_op2},
3455
3971
        {TGSI_OPCODE_SHL,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3456
3972
        /* gap */
3457
3973
        {88,                    0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3458
 
        {TGSI_OPCODE_AND,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3459
 
        {TGSI_OPCODE_OR,        0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3974
        {TGSI_OPCODE_AND,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_AND_INT, tgsi_op2},
 
3975
        {TGSI_OPCODE_OR,        0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_OR_INT, tgsi_op2},
3460
3976
        {TGSI_OPCODE_MOD,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3461
 
        {TGSI_OPCODE_XOR,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3977
        {TGSI_OPCODE_XOR,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT, tgsi_op2},
3462
3978
        {TGSI_OPCODE_SAD,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3463
 
        {TGSI_OPCODE_TXF,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3464
 
        {TGSI_OPCODE_TXQ,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
3979
        {TGSI_OPCODE_TXF,       0, SQ_TEX_INST_LD, tgsi_tex},
 
3980
        {TGSI_OPCODE_TXQ,       0, SQ_TEX_INST_GET_TEXTURE_RESINFO, tgsi_tex},
3465
3981
        {TGSI_OPCODE_CONT,      0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE, tgsi_loop_brk_cont},
3466
3982
        {TGSI_OPCODE_EMIT,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3467
3983
        {TGSI_OPCODE_ENDPRIM,   0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3488
4004
        {TGSI_OPCODE_END,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_end},  /* aka HALT */
3489
4005
        /* gap */
3490
4006
        {118,                   0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3491
 
        {TGSI_OPCODE_F2I,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4007
        {TGSI_OPCODE_F2I,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT, tgsi_op2},
3492
4008
        {TGSI_OPCODE_IDIV,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3493
 
        {TGSI_OPCODE_IMAX,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3494
 
        {TGSI_OPCODE_IMIN,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3495
 
        {TGSI_OPCODE_INEG,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3496
 
        {TGSI_OPCODE_ISGE,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4009
        {TGSI_OPCODE_IMAX,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT, tgsi_op2},
 
4010
        {TGSI_OPCODE_IMIN,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT, tgsi_op2},
 
4011
        {TGSI_OPCODE_INEG,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SUB_INT, tgsi_ineg},
 
4012
        {TGSI_OPCODE_ISGE,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_INT, tgsi_op2},
3497
4013
        {TGSI_OPCODE_ISHR,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3498
 
        {TGSI_OPCODE_ISLT,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4014
        {TGSI_OPCODE_ISLT,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT, tgsi_op2_swap},
3499
4015
        {TGSI_OPCODE_F2U,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3500
 
        {TGSI_OPCODE_U2F,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3501
 
        {TGSI_OPCODE_UADD,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4016
        {TGSI_OPCODE_U2F,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_UINT_TO_FLT, tgsi_op2},
 
4017
        {TGSI_OPCODE_UADD,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT, tgsi_op2},
3502
4018
        {TGSI_OPCODE_UDIV,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3503
 
        {TGSI_OPCODE_UMAD,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3504
 
        {TGSI_OPCODE_UMAX,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3505
 
        {TGSI_OPCODE_UMIN,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4019
        {TGSI_OPCODE_UMAD,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_umad},
 
4020
        {TGSI_OPCODE_UMAX,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_UINT, tgsi_op2},
 
4021
        {TGSI_OPCODE_UMIN,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_UINT, tgsi_op2},
3506
4022
        {TGSI_OPCODE_UMOD,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3507
 
        {TGSI_OPCODE_UMUL,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3508
 
        {TGSI_OPCODE_USEQ,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3509
 
        {TGSI_OPCODE_USGE,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4023
        {TGSI_OPCODE_UMUL,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MULLO_UINT, tgsi_op2_trans},
 
4024
        {TGSI_OPCODE_USEQ,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE_INT, tgsi_op2},
 
4025
        {TGSI_OPCODE_USGE,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE_UINT, tgsi_op2},
3510
4026
        {TGSI_OPCODE_USHR,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3511
 
        {TGSI_OPCODE_USLT,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3512
 
        {TGSI_OPCODE_USNE,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4027
        {TGSI_OPCODE_USLT,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT_INT, tgsi_op2_swap},
 
4028
        {TGSI_OPCODE_USNE,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE_INT, tgsi_op2},
3513
4029
        {TGSI_OPCODE_SWITCH,    0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3514
4030
        {TGSI_OPCODE_CASE,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3515
4031
        {TGSI_OPCODE_DEFAULT,   0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3516
4032
        {TGSI_OPCODE_ENDSWITCH, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4033
        {TGSI_OPCODE_LOAD,      0, 0, tgsi_unsupported},
 
4034
        {TGSI_OPCODE_LOAD_MS,   0, 0, tgsi_unsupported},
 
4035
        {TGSI_OPCODE_SAMPLE,    0, 0, tgsi_unsupported},
 
4036
        {TGSI_OPCODE_SAMPLE_B,  0, 0, tgsi_unsupported},
 
4037
        {TGSI_OPCODE_SAMPLE_C,  0, 0, tgsi_unsupported},
 
4038
        {TGSI_OPCODE_SAMPLE_C_LZ, 0, 0, tgsi_unsupported},
 
4039
        {TGSI_OPCODE_SAMPLE_D,  0, 0, tgsi_unsupported},
 
4040
        {TGSI_OPCODE_SAMPLE_L,  0, 0, tgsi_unsupported},
 
4041
        {TGSI_OPCODE_GATHER4,   0, 0, tgsi_unsupported},
 
4042
        {TGSI_OPCODE_RESINFO,   0, 0, tgsi_unsupported},
 
4043
        {TGSI_OPCODE_SAMPLE_POS, 0, 0, tgsi_unsupported},
 
4044
        {TGSI_OPCODE_SAMPLE_INFO, 0, 0, tgsi_unsupported},
 
4045
        {TGSI_OPCODE_UARL,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT, tgsi_eg_arl},
 
4046
        {TGSI_OPCODE_UCMP,      0, 0, tgsi_unsupported},
3517
4047
        {TGSI_OPCODE_LAST,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3518
4048
};
3519
4049
 
3547
4077
        {TGSI_OPCODE_FRC,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT, tgsi_op2},
3548
4078
        {TGSI_OPCODE_CLAMP,     0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3549
4079
        {TGSI_OPCODE_FLR,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR, tgsi_op2},
3550
 
        {TGSI_OPCODE_ROUND,     0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4080
        {TGSI_OPCODE_ROUND,     0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RNDNE, tgsi_op2},
3551
4081
        {TGSI_OPCODE_EX2,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE, cayman_emit_float_instr},
3552
4082
        {TGSI_OPCODE_LG2,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE, cayman_emit_float_instr},
3553
4083
        {TGSI_OPCODE_POW,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, cayman_pow},
3589
4119
        {TGSI_OPCODE_SSG,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_ssg},
3590
4120
        {TGSI_OPCODE_CMP,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_cmp},
3591
4121
        {TGSI_OPCODE_SCS,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_scs},
3592
 
        {TGSI_OPCODE_TXB,       0, SQ_TEX_INST_SAMPLE_L, tgsi_tex},
 
4122
        {TGSI_OPCODE_TXB,       0, SQ_TEX_INST_SAMPLE_LB, tgsi_tex},
3593
4123
        {TGSI_OPCODE_NRM,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3594
4124
        {TGSI_OPCODE_DIV,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3595
4125
        {TGSI_OPCODE_DP2,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4, tgsi_dp},
3608
4138
        {TGSI_OPCODE_POPA,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3609
4139
        {TGSI_OPCODE_CEIL,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3610
4140
        {TGSI_OPCODE_I2F,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3611
 
        {TGSI_OPCODE_NOT,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4141
        {TGSI_OPCODE_NOT,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOT_INT, tgsi_op2},
3612
4142
        {TGSI_OPCODE_TRUNC,     0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC, tgsi_op2},
3613
4143
        {TGSI_OPCODE_SHL,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3614
4144
        /* gap */
3616
4146
        {TGSI_OPCODE_AND,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3617
4147
        {TGSI_OPCODE_OR,        0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3618
4148
        {TGSI_OPCODE_MOD,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3619
 
        {TGSI_OPCODE_XOR,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4149
        {TGSI_OPCODE_XOR,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_XOR_INT, tgsi_op2},
3620
4150
        {TGSI_OPCODE_SAD,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3621
 
        {TGSI_OPCODE_TXF,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3622
 
        {TGSI_OPCODE_TXQ,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4151
        {TGSI_OPCODE_TXF,       0, SQ_TEX_INST_LD, tgsi_tex},
 
4152
        {TGSI_OPCODE_TXQ,       0, SQ_TEX_INST_GET_TEXTURE_RESINFO, tgsi_tex},
3623
4153
        {TGSI_OPCODE_CONT,      0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE, tgsi_loop_brk_cont},
3624
4154
        {TGSI_OPCODE_EMIT,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3625
4155
        {TGSI_OPCODE_ENDPRIM,   0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3648
4178
        {118,                   0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3649
4179
        {TGSI_OPCODE_F2I,       0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3650
4180
        {TGSI_OPCODE_IDIV,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3651
 
        {TGSI_OPCODE_IMAX,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3652
 
        {TGSI_OPCODE_IMIN,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4181
        {TGSI_OPCODE_IMAX,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX_INT, tgsi_op2},
 
4182
        {TGSI_OPCODE_IMIN,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN_INT, tgsi_op2},
3653
4183
        {TGSI_OPCODE_INEG,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3654
4184
        {TGSI_OPCODE_ISGE,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3655
4185
        {TGSI_OPCODE_ISHR,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3672
4202
        {TGSI_OPCODE_CASE,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3673
4203
        {TGSI_OPCODE_DEFAULT,   0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3674
4204
        {TGSI_OPCODE_ENDSWITCH, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
 
4205
        {TGSI_OPCODE_LOAD,      0, 0, tgsi_unsupported},
 
4206
        {TGSI_OPCODE_LOAD_MS,   0, 0, tgsi_unsupported},
 
4207
        {TGSI_OPCODE_SAMPLE,    0, 0, tgsi_unsupported},
 
4208
        {TGSI_OPCODE_SAMPLE_B,  0, 0, tgsi_unsupported},
 
4209
        {TGSI_OPCODE_SAMPLE_C,  0, 0, tgsi_unsupported},
 
4210
        {TGSI_OPCODE_SAMPLE_C_LZ, 0, 0, tgsi_unsupported},
 
4211
        {TGSI_OPCODE_SAMPLE_D,  0, 0, tgsi_unsupported},
 
4212
        {TGSI_OPCODE_SAMPLE_L,  0, 0, tgsi_unsupported},
 
4213
        {TGSI_OPCODE_GATHER4,   0, 0, tgsi_unsupported},
 
4214
        {TGSI_OPCODE_RESINFO,   0, 0, tgsi_unsupported},
 
4215
        {TGSI_OPCODE_SAMPLE_POS, 0, 0, tgsi_unsupported},
 
4216
        {TGSI_OPCODE_SAMPLE_INFO, 0, 0, tgsi_unsupported},
 
4217
        {TGSI_OPCODE_UARL,      0, 0, tgsi_unsupported},
 
4218
        {TGSI_OPCODE_UCMP,      0, 0, tgsi_unsupported},
3675
4219
        {TGSI_OPCODE_LAST,      0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP, tgsi_unsupported},
3676
4220
};