2011-05-24 16:34:27 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2010 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/** @file brw_fs_emit.cpp
|
|
|
|
|
*
|
|
|
|
|
* This file supports emitting code from the FS LIR to the actual
|
|
|
|
|
* native instructions.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
#include "main/macros.h"
|
|
|
|
|
#include "brw_context.h"
|
|
|
|
|
#include "brw_eu.h"
|
|
|
|
|
} /* extern "C" */
|
|
|
|
|
|
|
|
|
|
#include "brw_fs.h"
|
2012-10-03 13:03:12 -07:00
|
|
|
#include "brw_cfg.h"
|
2011-08-26 13:58:41 -07:00
|
|
|
#include "glsl/ir_print_visitor.h"
|
2011-05-24 16:34:27 -07:00
|
|
|
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::fs_generator(struct brw_context *brw,
|
|
|
|
|
struct brw_wm_compile *c,
|
|
|
|
|
struct gl_shader_program *prog,
|
|
|
|
|
struct gl_fragment_program *fp,
|
|
|
|
|
bool dual_source_output)
|
|
|
|
|
|
|
|
|
|
: brw(brw), c(c), prog(prog), fp(fp), dual_source_output(dual_source_output)
|
|
|
|
|
{
|
|
|
|
|
intel = &brw->intel;
|
|
|
|
|
ctx = &intel->ctx;
|
|
|
|
|
|
|
|
|
|
shader = prog ? prog->_LinkedShaders[MESA_SHADER_FRAGMENT] : NULL;
|
|
|
|
|
|
|
|
|
|
mem_ctx = c;
|
2012-11-20 19:26:52 -08:00
|
|
|
|
|
|
|
|
p = rzalloc(mem_ctx, struct brw_compile);
|
|
|
|
|
brw_init_compile(brw, p, mem_ctx);
|
2012-11-09 01:05:47 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fs_generator::~fs_generator()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-06 10:15:08 -08:00
|
|
|
void
|
|
|
|
|
fs_generator::patch_discard_jumps_to_fb_writes()
|
|
|
|
|
{
|
|
|
|
|
if (intel->gen < 6 || this->discard_halt_patches.is_empty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* There is a somewhat strange undocumented requirement of using
|
|
|
|
|
* HALT, according to the simulator. If some channel has HALTed to
|
|
|
|
|
* a particular UIP, then by the end of the program, every channel
|
|
|
|
|
* must have HALTed to that UIP. Furthermore, the tracking is a
|
|
|
|
|
* stack, so you can't do the final halt of a UIP after starting
|
|
|
|
|
* halting to a new UIP.
|
|
|
|
|
*
|
|
|
|
|
* Symptoms of not emitting this instruction on actual hardware
|
|
|
|
|
* included GPU hangs and sparkly rendering on the piglit discard
|
|
|
|
|
* tests.
|
|
|
|
|
*/
|
|
|
|
|
struct brw_instruction *last_halt = gen6_HALT(p);
|
|
|
|
|
last_halt->bits3.break_cont.uip = 2;
|
|
|
|
|
last_halt->bits3.break_cont.jip = 2;
|
|
|
|
|
|
|
|
|
|
int ip = p->nr_insn;
|
|
|
|
|
|
|
|
|
|
foreach_list(node, &this->discard_halt_patches) {
|
|
|
|
|
ip_record *patch_ip = (ip_record *)node;
|
|
|
|
|
struct brw_instruction *patch = &p->store[patch_ip->ip];
|
|
|
|
|
|
|
|
|
|
assert(patch->header.opcode == BRW_OPCODE_HALT);
|
|
|
|
|
/* HALT takes a half-instruction distance from the pre-incremented IP. */
|
|
|
|
|
patch->bits3.break_cont.uip = (ip - patch_ip->ip) * 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->discard_halt_patches.make_empty();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_fb_write(fs_inst *inst)
|
2011-05-24 16:34:27 -07:00
|
|
|
{
|
2011-10-07 12:26:50 -07:00
|
|
|
bool eot = inst->eot;
|
2011-05-24 16:34:27 -07:00
|
|
|
struct brw_reg implied_header;
|
2012-04-25 13:58:07 -07:00
|
|
|
uint32_t msg_control;
|
2011-05-24 16:34:27 -07:00
|
|
|
|
2012-12-06 10:15:08 -08:00
|
|
|
/* Note that the jumps emitted to this point mean that the g0 ->
|
|
|
|
|
* base_mrf setup must be inside of this function, so that we jump
|
|
|
|
|
* to a point containing it.
|
|
|
|
|
*/
|
|
|
|
|
patch_discard_jumps_to_fb_writes();
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
/* Header is 2 regs, g0 and g1 are the contents. g0 will be implied
|
|
|
|
|
* move, here's g1.
|
|
|
|
|
*/
|
|
|
|
|
brw_push_insn_state(p);
|
|
|
|
|
brw_set_mask_control(p, BRW_MASK_DISABLE);
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
|
|
|
|
|
2012-12-06 12:15:13 -08:00
|
|
|
if (fp->UsesKill) {
|
|
|
|
|
struct brw_reg pixel_mask;
|
|
|
|
|
|
|
|
|
|
if (intel->gen >= 6)
|
|
|
|
|
pixel_mask = retype(brw_vec1_grf(1, 7), BRW_REGISTER_TYPE_UW);
|
|
|
|
|
else
|
|
|
|
|
pixel_mask = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
|
|
|
|
|
|
|
|
|
|
brw_MOV(p, pixel_mask, brw_flag_reg(0, 1));
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
if (inst->header_present) {
|
|
|
|
|
if (intel->gen >= 6) {
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
|
|
|
|
|
brw_MOV(p,
|
|
|
|
|
retype(brw_message_reg(inst->base_mrf), BRW_REGISTER_TYPE_UD),
|
|
|
|
|
retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD));
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
|
|
|
|
|
2012-08-01 16:32:06 -07:00
|
|
|
if (inst->target > 0 &&
|
|
|
|
|
c->key.nr_color_regions > 1 &&
|
|
|
|
|
c->key.sample_alpha_to_coverage) {
|
|
|
|
|
/* Set "Source0 Alpha Present to RenderTarget" bit in message
|
|
|
|
|
* header.
|
|
|
|
|
*/
|
|
|
|
|
brw_OR(p,
|
|
|
|
|
vec1(retype(brw_message_reg(inst->base_mrf), BRW_REGISTER_TYPE_UD)),
|
|
|
|
|
vec1(retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD)),
|
|
|
|
|
brw_imm_ud(0x1 << 11));
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
if (inst->target > 0) {
|
|
|
|
|
/* Set the render target index for choosing BLEND_STATE. */
|
2011-07-25 15:39:03 -07:00
|
|
|
brw_MOV(p, retype(brw_vec1_reg(BRW_MESSAGE_REGISTER_FILE,
|
|
|
|
|
inst->base_mrf, 2),
|
2011-05-24 16:34:27 -07:00
|
|
|
BRW_REGISTER_TYPE_UD),
|
|
|
|
|
brw_imm_ud(inst->target));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
implied_header = brw_null_reg();
|
|
|
|
|
} else {
|
|
|
|
|
implied_header = retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW);
|
|
|
|
|
|
|
|
|
|
brw_MOV(p,
|
|
|
|
|
brw_message_reg(inst->base_mrf + 1),
|
|
|
|
|
brw_vec8_grf(1, 0));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
implied_header = brw_null_reg();
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-09 01:05:47 -08:00
|
|
|
if (this->dual_source_output)
|
2012-04-25 13:58:07 -07:00
|
|
|
msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01;
|
2012-11-20 13:50:52 -08:00
|
|
|
else if (dispatch_width == 16)
|
2012-04-25 13:58:07 -07:00
|
|
|
msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE;
|
|
|
|
|
else
|
|
|
|
|
msg_control = BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01;
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
brw_pop_insn_state(p);
|
|
|
|
|
|
|
|
|
|
brw_fb_WRITE(p,
|
2012-11-20 13:50:52 -08:00
|
|
|
dispatch_width,
|
2011-05-24 16:34:27 -07:00
|
|
|
inst->base_mrf,
|
|
|
|
|
implied_header,
|
2012-04-25 13:58:07 -07:00
|
|
|
msg_control,
|
2011-05-24 16:34:27 -07:00
|
|
|
inst->target,
|
|
|
|
|
inst->mlen,
|
|
|
|
|
0,
|
|
|
|
|
eot,
|
|
|
|
|
inst->header_present);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Computes the integer pixel x,y values from the origin.
|
|
|
|
|
*
|
|
|
|
|
* This is the basis of gl_FragCoord computation, but is also used
|
|
|
|
|
* pre-gen6 for computing the deltas from v0 for computing
|
|
|
|
|
* interpolation.
|
|
|
|
|
*/
|
|
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_pixel_xy(struct brw_reg dst, bool is_x)
|
2011-05-24 16:34:27 -07:00
|
|
|
{
|
|
|
|
|
struct brw_reg g1_uw = retype(brw_vec1_grf(1, 0), BRW_REGISTER_TYPE_UW);
|
|
|
|
|
struct brw_reg src;
|
|
|
|
|
struct brw_reg deltas;
|
|
|
|
|
|
|
|
|
|
if (is_x) {
|
|
|
|
|
src = stride(suboffset(g1_uw, 4), 2, 4, 0);
|
|
|
|
|
deltas = brw_imm_v(0x10101010);
|
|
|
|
|
} else {
|
|
|
|
|
src = stride(suboffset(g1_uw, 5), 2, 4, 0);
|
|
|
|
|
deltas = brw_imm_v(0x11001100);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-20 13:50:52 -08:00
|
|
|
if (dispatch_width == 16) {
|
2011-05-24 16:34:27 -07:00
|
|
|
dst = vec16(dst);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* We do this 8 or 16-wide, but since the destination is UW we
|
|
|
|
|
* don't do compression in the 16-wide case.
|
|
|
|
|
*/
|
|
|
|
|
brw_push_insn_state(p);
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
|
|
|
|
brw_ADD(p, dst, src, deltas);
|
|
|
|
|
brw_pop_insn_state(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_linterp(fs_inst *inst,
|
2011-05-24 16:34:27 -07:00
|
|
|
struct brw_reg dst, struct brw_reg *src)
|
|
|
|
|
{
|
|
|
|
|
struct brw_reg delta_x = src[0];
|
|
|
|
|
struct brw_reg delta_y = src[1];
|
|
|
|
|
struct brw_reg interp = src[2];
|
|
|
|
|
|
|
|
|
|
if (brw->has_pln &&
|
|
|
|
|
delta_y.nr == delta_x.nr + 1 &&
|
|
|
|
|
(intel->gen >= 6 || (delta_x.nr & 1) == 0)) {
|
|
|
|
|
brw_PLN(p, dst, interp, delta_x);
|
|
|
|
|
} else {
|
|
|
|
|
brw_LINE(p, brw_null_reg(), interp, delta_x);
|
|
|
|
|
brw_MAC(p, dst, suboffset(interp, 1), delta_y);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-18 12:24:47 -07:00
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_math1_gen7(fs_inst *inst,
|
2011-10-18 12:24:47 -07:00
|
|
|
struct brw_reg dst,
|
|
|
|
|
struct brw_reg src0)
|
|
|
|
|
{
|
|
|
|
|
assert(inst->mlen == 0);
|
|
|
|
|
brw_math(p, dst,
|
|
|
|
|
brw_math_function(inst->opcode),
|
|
|
|
|
0, src0,
|
|
|
|
|
BRW_MATH_DATA_VECTOR,
|
|
|
|
|
BRW_MATH_PRECISION_FULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_math2_gen7(fs_inst *inst,
|
2011-10-18 12:24:47 -07:00
|
|
|
struct brw_reg dst,
|
|
|
|
|
struct brw_reg src0,
|
|
|
|
|
struct brw_reg src1)
|
|
|
|
|
{
|
|
|
|
|
assert(inst->mlen == 0);
|
|
|
|
|
brw_math2(p, dst, brw_math_function(inst->opcode), src0, src1);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_math1_gen6(fs_inst *inst,
|
2011-08-18 11:55:42 -07:00
|
|
|
struct brw_reg dst,
|
|
|
|
|
struct brw_reg src0)
|
2011-05-24 16:34:27 -07:00
|
|
|
{
|
2011-05-02 09:45:40 -07:00
|
|
|
int op = brw_math_function(inst->opcode);
|
2011-05-24 16:34:27 -07:00
|
|
|
|
2011-08-18 11:55:42 -07:00
|
|
|
assert(inst->mlen == 0);
|
2011-05-24 16:34:27 -07:00
|
|
|
|
2011-08-18 11:55:42 -07:00
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
|
|
|
|
brw_math(p, dst,
|
|
|
|
|
op,
|
|
|
|
|
0, src0,
|
|
|
|
|
BRW_MATH_DATA_VECTOR,
|
|
|
|
|
BRW_MATH_PRECISION_FULL);
|
2011-05-24 16:34:27 -07:00
|
|
|
|
2012-11-20 13:50:52 -08:00
|
|
|
if (dispatch_width == 16) {
|
2011-08-18 11:55:42 -07:00
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
|
|
|
|
|
brw_math(p, sechalf(dst),
|
2011-05-24 16:34:27 -07:00
|
|
|
op,
|
2011-08-18 11:55:42 -07:00
|
|
|
0, sechalf(src0),
|
2011-05-24 16:34:27 -07:00
|
|
|
BRW_MATH_DATA_VECTOR,
|
|
|
|
|
BRW_MATH_PRECISION_FULL);
|
2011-08-18 11:55:42 -07:00
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-05-24 16:34:27 -07:00
|
|
|
|
2011-08-18 11:55:42 -07:00
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_math2_gen6(fs_inst *inst,
|
2011-08-18 11:55:42 -07:00
|
|
|
struct brw_reg dst,
|
|
|
|
|
struct brw_reg src0,
|
|
|
|
|
struct brw_reg src1)
|
|
|
|
|
{
|
|
|
|
|
int op = brw_math_function(inst->opcode);
|
2011-05-24 16:34:27 -07:00
|
|
|
|
2011-08-18 11:55:42 -07:00
|
|
|
assert(inst->mlen == 0);
|
|
|
|
|
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
|
|
|
|
brw_math2(p, dst, op, src0, src1);
|
|
|
|
|
|
2012-11-20 13:50:52 -08:00
|
|
|
if (dispatch_width == 16) {
|
2011-08-18 11:55:42 -07:00
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
|
|
|
|
|
brw_math2(p, sechalf(dst), op, sechalf(src0), sechalf(src1));
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_math_gen4(fs_inst *inst,
|
2011-08-18 11:55:42 -07:00
|
|
|
struct brw_reg dst,
|
|
|
|
|
struct brw_reg src)
|
|
|
|
|
{
|
|
|
|
|
int op = brw_math_function(inst->opcode);
|
|
|
|
|
|
|
|
|
|
assert(inst->mlen >= 1);
|
|
|
|
|
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
|
|
|
|
brw_math(p, dst,
|
|
|
|
|
op,
|
|
|
|
|
inst->base_mrf, src,
|
|
|
|
|
BRW_MATH_DATA_VECTOR,
|
|
|
|
|
BRW_MATH_PRECISION_FULL);
|
|
|
|
|
|
2012-11-20 13:50:52 -08:00
|
|
|
if (dispatch_width == 16) {
|
2011-08-18 11:55:42 -07:00
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
|
|
|
|
|
brw_math(p, sechalf(dst),
|
|
|
|
|
op,
|
|
|
|
|
inst->base_mrf + 1, sechalf(src),
|
|
|
|
|
BRW_MATH_DATA_VECTOR,
|
|
|
|
|
BRW_MATH_PRECISION_FULL);
|
|
|
|
|
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_tex(fs_inst *inst, struct brw_reg dst, struct brw_reg src)
|
2011-05-24 16:34:27 -07:00
|
|
|
{
|
|
|
|
|
int msg_type = -1;
|
|
|
|
|
int rlen = 4;
|
|
|
|
|
uint32_t simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD8;
|
2011-11-09 16:07:57 -08:00
|
|
|
uint32_t return_format;
|
|
|
|
|
|
|
|
|
|
switch (dst.type) {
|
|
|
|
|
case BRW_REGISTER_TYPE_D:
|
|
|
|
|
return_format = BRW_SAMPLER_RETURN_FORMAT_SINT32;
|
|
|
|
|
break;
|
|
|
|
|
case BRW_REGISTER_TYPE_UD:
|
|
|
|
|
return_format = BRW_SAMPLER_RETURN_FORMAT_UINT32;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return_format = BRW_SAMPLER_RETURN_FORMAT_FLOAT32;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-05-24 16:34:27 -07:00
|
|
|
|
2012-11-20 13:50:52 -08:00
|
|
|
if (dispatch_width == 16)
|
2011-05-24 16:34:27 -07:00
|
|
|
simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;
|
|
|
|
|
|
|
|
|
|
if (intel->gen >= 5) {
|
|
|
|
|
switch (inst->opcode) {
|
2011-10-26 12:58:37 -07:00
|
|
|
case SHADER_OPCODE_TEX:
|
2011-05-24 16:34:27 -07:00
|
|
|
if (inst->shadow_compare) {
|
|
|
|
|
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_COMPARE;
|
|
|
|
|
} else {
|
|
|
|
|
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case FS_OPCODE_TXB:
|
|
|
|
|
if (inst->shadow_compare) {
|
|
|
|
|
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS_COMPARE;
|
|
|
|
|
} else {
|
|
|
|
|
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2011-10-26 12:58:37 -07:00
|
|
|
case SHADER_OPCODE_TXL:
|
2011-05-24 16:34:27 -07:00
|
|
|
if (inst->shadow_compare) {
|
|
|
|
|
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_LOD_COMPARE;
|
|
|
|
|
} else {
|
|
|
|
|
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_LOD;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2011-10-26 12:58:37 -07:00
|
|
|
case SHADER_OPCODE_TXS:
|
2011-06-19 01:47:50 -07:00
|
|
|
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO;
|
|
|
|
|
break;
|
2011-10-26 12:58:37 -07:00
|
|
|
case SHADER_OPCODE_TXD:
|
2011-06-10 14:48:46 -07:00
|
|
|
/* There is no sample_d_c message; comparisons are done manually */
|
2011-06-08 16:08:07 -07:00
|
|
|
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS;
|
2011-05-24 16:34:27 -07:00
|
|
|
break;
|
2011-10-26 12:58:37 -07:00
|
|
|
case SHADER_OPCODE_TXF:
|
2011-08-25 17:13:37 -07:00
|
|
|
msg_type = GEN5_SAMPLER_MESSAGE_SAMPLE_LD;
|
|
|
|
|
break;
|
2011-05-03 10:55:50 -07:00
|
|
|
default:
|
|
|
|
|
assert(!"not reached");
|
|
|
|
|
break;
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
switch (inst->opcode) {
|
2011-10-26 12:58:37 -07:00
|
|
|
case SHADER_OPCODE_TEX:
|
2011-05-24 16:34:27 -07:00
|
|
|
/* Note that G45 and older determines shadow compare and dispatch width
|
|
|
|
|
* from message length for most messages.
|
|
|
|
|
*/
|
2012-11-20 13:50:52 -08:00
|
|
|
assert(dispatch_width == 8);
|
2011-05-24 16:34:27 -07:00
|
|
|
msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE;
|
|
|
|
|
if (inst->shadow_compare) {
|
|
|
|
|
assert(inst->mlen == 6);
|
|
|
|
|
} else {
|
|
|
|
|
assert(inst->mlen <= 4);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case FS_OPCODE_TXB:
|
|
|
|
|
if (inst->shadow_compare) {
|
|
|
|
|
assert(inst->mlen == 6);
|
|
|
|
|
msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_BIAS_COMPARE;
|
|
|
|
|
} else {
|
|
|
|
|
assert(inst->mlen == 9);
|
|
|
|
|
msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS;
|
|
|
|
|
simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2011-10-26 12:58:37 -07:00
|
|
|
case SHADER_OPCODE_TXL:
|
2011-05-24 16:34:27 -07:00
|
|
|
if (inst->shadow_compare) {
|
|
|
|
|
assert(inst->mlen == 6);
|
|
|
|
|
msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_LOD_COMPARE;
|
|
|
|
|
} else {
|
|
|
|
|
assert(inst->mlen == 9);
|
|
|
|
|
msg_type = BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD;
|
|
|
|
|
simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2011-10-26 12:58:37 -07:00
|
|
|
case SHADER_OPCODE_TXD:
|
2011-06-10 14:48:46 -07:00
|
|
|
/* There is no sample_d_c message; comparisons are done manually */
|
2011-06-08 16:05:34 -07:00
|
|
|
assert(inst->mlen == 7 || inst->mlen == 10);
|
|
|
|
|
msg_type = BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS;
|
2011-05-24 16:34:27 -07:00
|
|
|
break;
|
2011-10-26 12:58:37 -07:00
|
|
|
case SHADER_OPCODE_TXF:
|
2011-09-06 16:39:01 -07:00
|
|
|
assert(inst->mlen == 9);
|
|
|
|
|
msg_type = BRW_SAMPLER_MESSAGE_SIMD16_LD;
|
|
|
|
|
simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;
|
|
|
|
|
break;
|
2011-10-26 12:58:37 -07:00
|
|
|
case SHADER_OPCODE_TXS:
|
2011-08-17 10:45:47 -07:00
|
|
|
assert(inst->mlen == 3);
|
|
|
|
|
msg_type = BRW_SAMPLER_MESSAGE_SIMD16_RESINFO;
|
|
|
|
|
simd_mode = BRW_SAMPLER_SIMD_MODE_SIMD16;
|
|
|
|
|
break;
|
2011-05-03 10:55:50 -07:00
|
|
|
default:
|
|
|
|
|
assert(!"not reached");
|
|
|
|
|
break;
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
assert(msg_type != -1);
|
|
|
|
|
|
|
|
|
|
if (simd_mode == BRW_SAMPLER_SIMD_MODE_SIMD16) {
|
|
|
|
|
rlen = 8;
|
|
|
|
|
dst = vec16(dst);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-04 20:33:13 -07:00
|
|
|
/* Load the message header if present. If there's a texture offset,
|
|
|
|
|
* we need to set it up explicitly and load the offset bitfield.
|
|
|
|
|
* Otherwise, we can use an implied move from g0 to the first message reg.
|
|
|
|
|
*/
|
|
|
|
|
if (inst->texture_offset) {
|
|
|
|
|
brw_push_insn_state(p);
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
|
|
|
|
/* Explicitly set up the message header by copying g0 to the MRF. */
|
|
|
|
|
brw_MOV(p, retype(brw_message_reg(inst->base_mrf), BRW_REGISTER_TYPE_UD),
|
|
|
|
|
retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UD));
|
|
|
|
|
|
|
|
|
|
/* Then set the offset bits in DWord 2. */
|
|
|
|
|
brw_MOV(p, retype(brw_vec1_reg(BRW_MESSAGE_REGISTER_FILE,
|
|
|
|
|
inst->base_mrf, 2), BRW_REGISTER_TYPE_UD),
|
|
|
|
|
brw_imm_ud(inst->texture_offset));
|
|
|
|
|
brw_pop_insn_state(p);
|
|
|
|
|
} else if (inst->header_present) {
|
|
|
|
|
/* Set up an implied move from g0 to the MRF. */
|
|
|
|
|
src = retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
brw_SAMPLE(p,
|
|
|
|
|
retype(dst, BRW_REGISTER_TYPE_UW),
|
|
|
|
|
inst->base_mrf,
|
|
|
|
|
src,
|
|
|
|
|
SURF_INDEX_TEXTURE(inst->sampler),
|
|
|
|
|
inst->sampler,
|
|
|
|
|
WRITEMASK_XYZW,
|
|
|
|
|
msg_type,
|
|
|
|
|
rlen,
|
|
|
|
|
inst->mlen,
|
|
|
|
|
inst->header_present,
|
2011-11-09 16:07:57 -08:00
|
|
|
simd_mode,
|
|
|
|
|
return_format);
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* For OPCODE_DDX and OPCODE_DDY, per channel of output we've got input
|
|
|
|
|
* looking like:
|
|
|
|
|
*
|
|
|
|
|
* arg0: ss0.tl ss0.tr ss0.bl ss0.br ss1.tl ss1.tr ss1.bl ss1.br
|
|
|
|
|
*
|
|
|
|
|
* and we're trying to produce:
|
|
|
|
|
*
|
|
|
|
|
* DDX DDY
|
|
|
|
|
* dst: (ss0.tr - ss0.tl) (ss0.tl - ss0.bl)
|
|
|
|
|
* (ss0.tr - ss0.tl) (ss0.tr - ss0.br)
|
|
|
|
|
* (ss0.br - ss0.bl) (ss0.tl - ss0.bl)
|
|
|
|
|
* (ss0.br - ss0.bl) (ss0.tr - ss0.br)
|
|
|
|
|
* (ss1.tr - ss1.tl) (ss1.tl - ss1.bl)
|
|
|
|
|
* (ss1.tr - ss1.tl) (ss1.tr - ss1.br)
|
|
|
|
|
* (ss1.br - ss1.bl) (ss1.tl - ss1.bl)
|
|
|
|
|
* (ss1.br - ss1.bl) (ss1.tr - ss1.br)
|
|
|
|
|
*
|
|
|
|
|
* and add another set of two more subspans if in 16-pixel dispatch mode.
|
|
|
|
|
*
|
|
|
|
|
* For DDX, it ends up being easy: width = 2, horiz=0 gets us the same result
|
|
|
|
|
* for each pair, and vertstride = 2 jumps us 2 elements after processing a
|
|
|
|
|
* pair. But for DDY, it's harder, as we want to produce the pairs swizzled
|
|
|
|
|
* between each other. We could probably do it like ddx and swizzle the right
|
|
|
|
|
* order later, but bail for now and just produce
|
|
|
|
|
* ((ss0.tl - ss0.bl)x4 (ss1.tl - ss1.bl)x4)
|
|
|
|
|
*/
|
|
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_ddx(fs_inst *inst, struct brw_reg dst, struct brw_reg src)
|
2011-05-24 16:34:27 -07:00
|
|
|
{
|
|
|
|
|
struct brw_reg src0 = brw_reg(src.file, src.nr, 1,
|
|
|
|
|
BRW_REGISTER_TYPE_F,
|
|
|
|
|
BRW_VERTICAL_STRIDE_2,
|
|
|
|
|
BRW_WIDTH_2,
|
|
|
|
|
BRW_HORIZONTAL_STRIDE_0,
|
|
|
|
|
BRW_SWIZZLE_XYZW, WRITEMASK_XYZW);
|
|
|
|
|
struct brw_reg src1 = brw_reg(src.file, src.nr, 0,
|
|
|
|
|
BRW_REGISTER_TYPE_F,
|
|
|
|
|
BRW_VERTICAL_STRIDE_2,
|
|
|
|
|
BRW_WIDTH_2,
|
|
|
|
|
BRW_HORIZONTAL_STRIDE_0,
|
|
|
|
|
BRW_SWIZZLE_XYZW, WRITEMASK_XYZW);
|
|
|
|
|
brw_ADD(p, dst, src0, negate(src1));
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-20 13:40:45 -07:00
|
|
|
/* The negate_value boolean is used to negate the derivative computation for
|
|
|
|
|
* FBOs, since they place the origin at the upper left instead of the lower
|
|
|
|
|
* left.
|
|
|
|
|
*/
|
2011-05-24 16:34:27 -07:00
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_ddy(fs_inst *inst, struct brw_reg dst, struct brw_reg src,
|
2012-06-20 13:40:45 -07:00
|
|
|
bool negate_value)
|
2011-05-24 16:34:27 -07:00
|
|
|
{
|
|
|
|
|
struct brw_reg src0 = brw_reg(src.file, src.nr, 0,
|
|
|
|
|
BRW_REGISTER_TYPE_F,
|
|
|
|
|
BRW_VERTICAL_STRIDE_4,
|
|
|
|
|
BRW_WIDTH_4,
|
|
|
|
|
BRW_HORIZONTAL_STRIDE_0,
|
|
|
|
|
BRW_SWIZZLE_XYZW, WRITEMASK_XYZW);
|
|
|
|
|
struct brw_reg src1 = brw_reg(src.file, src.nr, 2,
|
|
|
|
|
BRW_REGISTER_TYPE_F,
|
|
|
|
|
BRW_VERTICAL_STRIDE_4,
|
|
|
|
|
BRW_WIDTH_4,
|
|
|
|
|
BRW_HORIZONTAL_STRIDE_0,
|
|
|
|
|
BRW_SWIZZLE_XYZW, WRITEMASK_XYZW);
|
2012-06-20 13:40:45 -07:00
|
|
|
if (negate_value)
|
|
|
|
|
brw_ADD(p, dst, src1, negate(src0));
|
|
|
|
|
else
|
|
|
|
|
brw_ADD(p, dst, src0, negate(src1));
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
|
2012-12-06 10:15:08 -08:00
|
|
|
void
|
|
|
|
|
fs_generator::generate_discard_jump(fs_inst *inst)
|
|
|
|
|
{
|
|
|
|
|
assert(intel->gen >= 6);
|
|
|
|
|
|
|
|
|
|
/* This HALT will be patched up at FB write time to point UIP at the end of
|
|
|
|
|
* the program, and at brw_uip_jip() JIP will be set to the end of the
|
|
|
|
|
* current block (or the program).
|
|
|
|
|
*/
|
|
|
|
|
this->discard_halt_patches.push_tail(new(mem_ctx) ip_record(p->nr_insn));
|
|
|
|
|
|
|
|
|
|
brw_push_insn_state(p);
|
|
|
|
|
brw_set_mask_control(p, BRW_MASK_DISABLE);
|
|
|
|
|
gen6_HALT(p);
|
|
|
|
|
brw_pop_insn_state(p);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_spill(fs_inst *inst, struct brw_reg src)
|
2011-05-24 16:34:27 -07:00
|
|
|
{
|
|
|
|
|
assert(inst->mlen != 0);
|
|
|
|
|
|
|
|
|
|
brw_MOV(p,
|
|
|
|
|
retype(brw_message_reg(inst->base_mrf + 1), BRW_REGISTER_TYPE_UD),
|
|
|
|
|
retype(src, BRW_REGISTER_TYPE_UD));
|
|
|
|
|
brw_oword_block_write_scratch(p, brw_message_reg(inst->base_mrf), 1,
|
|
|
|
|
inst->offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_unspill(fs_inst *inst, struct brw_reg dst)
|
2011-05-24 16:34:27 -07:00
|
|
|
{
|
|
|
|
|
assert(inst->mlen != 0);
|
|
|
|
|
|
|
|
|
|
/* Clear any post destination dependencies that would be ignored by
|
|
|
|
|
* the block read. See the B-Spec for pre-gen5 send instruction.
|
|
|
|
|
*
|
|
|
|
|
* This could use a better solution, since texture sampling and
|
|
|
|
|
* math reads could potentially run into it as well -- anywhere
|
|
|
|
|
* that we have a SEND with a destination that is a register that
|
|
|
|
|
* was written but not read within the last N instructions (what's
|
|
|
|
|
* N? unsure). This is rare because of dead code elimination, but
|
|
|
|
|
* not impossible.
|
|
|
|
|
*/
|
|
|
|
|
if (intel->gen == 4 && !intel->is_g4x)
|
|
|
|
|
brw_MOV(p, brw_null_reg(), dst);
|
|
|
|
|
|
|
|
|
|
brw_oword_block_read_scratch(p, dst, brw_message_reg(inst->base_mrf), 1,
|
|
|
|
|
inst->offset);
|
|
|
|
|
|
|
|
|
|
if (intel->gen == 4 && !intel->is_g4x) {
|
|
|
|
|
/* gen4 errata: destination from a send can't be used as a
|
|
|
|
|
* destination until it's been read. Just read it so we don't
|
|
|
|
|
* have to worry.
|
|
|
|
|
*/
|
|
|
|
|
brw_MOV(p, brw_null_reg(), dst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2012-11-07 10:42:34 -08:00
|
|
|
fs_generator::generate_uniform_pull_constant_load(fs_inst *inst,
|
|
|
|
|
struct brw_reg dst,
|
|
|
|
|
struct brw_reg index,
|
|
|
|
|
struct brw_reg offset)
|
2011-05-24 16:34:27 -07:00
|
|
|
{
|
|
|
|
|
assert(inst->mlen != 0);
|
|
|
|
|
|
|
|
|
|
/* Clear any post destination dependencies that would be ignored by
|
|
|
|
|
* the block read. See the B-Spec for pre-gen5 send instruction.
|
|
|
|
|
*
|
|
|
|
|
* This could use a better solution, since texture sampling and
|
|
|
|
|
* math reads could potentially run into it as well -- anywhere
|
|
|
|
|
* that we have a SEND with a destination that is a register that
|
|
|
|
|
* was written but not read within the last N instructions (what's
|
|
|
|
|
* N? unsure). This is rare because of dead code elimination, but
|
|
|
|
|
* not impossible.
|
|
|
|
|
*/
|
|
|
|
|
if (intel->gen == 4 && !intel->is_g4x)
|
|
|
|
|
brw_MOV(p, brw_null_reg(), dst);
|
|
|
|
|
|
2012-06-20 15:41:14 -07:00
|
|
|
assert(index.file == BRW_IMMEDIATE_VALUE &&
|
|
|
|
|
index.type == BRW_REGISTER_TYPE_UD);
|
|
|
|
|
uint32_t surf_index = index.dw1.ud;
|
|
|
|
|
|
|
|
|
|
assert(offset.file == BRW_IMMEDIATE_VALUE &&
|
|
|
|
|
offset.type == BRW_REGISTER_TYPE_UD);
|
|
|
|
|
uint32_t read_offset = offset.dw1.ud;
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
brw_oword_block_read(p, dst, brw_message_reg(inst->base_mrf),
|
2012-06-20 15:41:14 -07:00
|
|
|
read_offset, surf_index);
|
2011-05-24 16:34:27 -07:00
|
|
|
|
|
|
|
|
if (intel->gen == 4 && !intel->is_g4x) {
|
|
|
|
|
/* gen4 errata: destination from a send can't be used as a
|
|
|
|
|
* destination until it's been read. Just read it so we don't
|
|
|
|
|
* have to worry.
|
|
|
|
|
*/
|
|
|
|
|
brw_MOV(p, brw_null_reg(), dst);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-05 00:06:30 -08:00
|
|
|
void
|
|
|
|
|
fs_generator::generate_uniform_pull_constant_load_gen7(fs_inst *inst,
|
|
|
|
|
struct brw_reg dst,
|
|
|
|
|
struct brw_reg index,
|
|
|
|
|
struct brw_reg offset)
|
|
|
|
|
{
|
|
|
|
|
assert(inst->mlen == 0);
|
|
|
|
|
|
|
|
|
|
assert(index.file == BRW_IMMEDIATE_VALUE &&
|
|
|
|
|
index.type == BRW_REGISTER_TYPE_UD);
|
|
|
|
|
uint32_t surf_index = index.dw1.ud;
|
|
|
|
|
|
|
|
|
|
assert(offset.file == BRW_GENERAL_REGISTER_FILE);
|
|
|
|
|
|
|
|
|
|
brw_push_insn_state(p);
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
|
|
|
|
brw_set_mask_control(p, BRW_MASK_DISABLE);
|
|
|
|
|
struct brw_instruction *send = brw_next_insn(p, BRW_OPCODE_SEND);
|
|
|
|
|
brw_pop_insn_state(p);
|
|
|
|
|
|
|
|
|
|
brw_set_dest(p, send, dst);
|
|
|
|
|
brw_set_src0(p, send, offset);
|
|
|
|
|
|
|
|
|
|
uint32_t msg_control = BRW_DATAPORT_OWORD_BLOCK_2_OWORDS;
|
|
|
|
|
uint32_t msg_type = BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ;
|
|
|
|
|
bool header_present = true;
|
|
|
|
|
brw_set_dp_read_message(p, send,
|
|
|
|
|
surf_index,
|
|
|
|
|
msg_control,
|
|
|
|
|
msg_type,
|
|
|
|
|
BRW_DATAPORT_READ_TARGET_DATA_CACHE,
|
|
|
|
|
1,
|
|
|
|
|
header_present,
|
|
|
|
|
1);
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-07 11:18:34 -08:00
|
|
|
void
|
|
|
|
|
fs_generator::generate_varying_pull_constant_load(fs_inst *inst,
|
|
|
|
|
struct brw_reg dst,
|
|
|
|
|
struct brw_reg index)
|
|
|
|
|
{
|
|
|
|
|
assert(intel->gen < 7); /* Should use the gen7 variant. */
|
|
|
|
|
assert(inst->header_present);
|
|
|
|
|
|
|
|
|
|
assert(index.file == BRW_IMMEDIATE_VALUE &&
|
|
|
|
|
index.type == BRW_REGISTER_TYPE_UD);
|
|
|
|
|
uint32_t surf_index = index.dw1.ud;
|
|
|
|
|
|
|
|
|
|
uint32_t msg_type, msg_control, rlen;
|
|
|
|
|
if (intel->gen >= 6)
|
|
|
|
|
msg_type = GEN6_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ;
|
|
|
|
|
else if (intel->gen == 5 || intel->is_g4x)
|
|
|
|
|
msg_type = G45_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ;
|
|
|
|
|
else
|
|
|
|
|
msg_type = BRW_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ;
|
|
|
|
|
|
|
|
|
|
if (dispatch_width == 16) {
|
|
|
|
|
msg_control = BRW_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS;
|
|
|
|
|
rlen = 2;
|
|
|
|
|
} else {
|
|
|
|
|
msg_control = BRW_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS;
|
|
|
|
|
rlen = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct brw_reg header = brw_vec8_grf(0, 0);
|
|
|
|
|
gen6_resolve_implied_move(p, &header, inst->base_mrf);
|
|
|
|
|
|
|
|
|
|
struct brw_instruction *send = brw_next_insn(p, BRW_OPCODE_SEND);
|
|
|
|
|
brw_set_dest(p, send, dst);
|
|
|
|
|
brw_set_src0(p, send, header);
|
|
|
|
|
if (intel->gen < 6)
|
|
|
|
|
send->header.destreg__conditionalmod = inst->base_mrf;
|
|
|
|
|
brw_set_dp_read_message(p, send,
|
|
|
|
|
surf_index,
|
|
|
|
|
msg_control,
|
|
|
|
|
msg_type,
|
|
|
|
|
BRW_DATAPORT_READ_TARGET_DATA_CACHE,
|
|
|
|
|
inst->mlen,
|
|
|
|
|
inst->header_present,
|
|
|
|
|
rlen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
fs_generator::generate_varying_pull_constant_load_gen7(fs_inst *inst,
|
|
|
|
|
struct brw_reg dst,
|
|
|
|
|
struct brw_reg index,
|
|
|
|
|
struct brw_reg offset)
|
|
|
|
|
{
|
|
|
|
|
assert(intel->gen >= 7);
|
|
|
|
|
/* Varying-offset pull constant loads are treated as a normal expression on
|
|
|
|
|
* gen7, so the fact that it's a send message is hidden at the IR level.
|
|
|
|
|
*/
|
|
|
|
|
assert(!inst->header_present);
|
|
|
|
|
assert(!inst->mlen);
|
|
|
|
|
|
|
|
|
|
assert(index.file == BRW_IMMEDIATE_VALUE &&
|
|
|
|
|
index.type == BRW_REGISTER_TYPE_UD);
|
|
|
|
|
uint32_t surf_index = index.dw1.ud;
|
|
|
|
|
|
|
|
|
|
uint32_t msg_control, rlen, mlen;
|
|
|
|
|
if (dispatch_width == 16) {
|
|
|
|
|
msg_control = BRW_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS;
|
|
|
|
|
mlen = rlen = 2;
|
|
|
|
|
} else {
|
|
|
|
|
msg_control = BRW_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS;
|
|
|
|
|
mlen = rlen = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct brw_instruction *send = brw_next_insn(p, BRW_OPCODE_SEND);
|
|
|
|
|
brw_set_dest(p, send, dst);
|
|
|
|
|
brw_set_src0(p, send, offset);
|
|
|
|
|
if (intel->gen < 6)
|
|
|
|
|
send->header.destreg__conditionalmod = inst->base_mrf;
|
|
|
|
|
brw_set_dp_read_message(p, send,
|
|
|
|
|
surf_index,
|
|
|
|
|
msg_control,
|
|
|
|
|
GEN7_DATAPORT_DC_DWORD_SCATTERED_READ,
|
|
|
|
|
BRW_DATAPORT_READ_TARGET_DATA_CACHE,
|
|
|
|
|
mlen,
|
|
|
|
|
inst->header_present,
|
|
|
|
|
rlen);
|
|
|
|
|
}
|
2012-06-18 14:50:04 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cause the current pixel/sample mask (from R1.7 bits 15:0) to be transferred
|
|
|
|
|
* into the flags register (f0.0).
|
|
|
|
|
*
|
|
|
|
|
* Used only on Gen6 and above.
|
|
|
|
|
*/
|
|
|
|
|
void
|
2012-12-06 10:36:11 -08:00
|
|
|
fs_generator::generate_mov_dispatch_to_flags(fs_inst *inst)
|
2012-06-18 14:50:04 -07:00
|
|
|
{
|
2012-12-06 10:36:11 -08:00
|
|
|
struct brw_reg flags = brw_flag_reg(0, inst->flag_subreg);
|
2012-12-06 12:15:13 -08:00
|
|
|
struct brw_reg dispatch_mask;
|
|
|
|
|
|
|
|
|
|
if (intel->gen >= 6)
|
|
|
|
|
dispatch_mask = retype(brw_vec1_grf(1, 7), BRW_REGISTER_TYPE_UW);
|
|
|
|
|
else
|
|
|
|
|
dispatch_mask = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW);
|
2012-06-18 14:50:04 -07:00
|
|
|
|
|
|
|
|
brw_push_insn_state(p);
|
|
|
|
|
brw_set_mask_control(p, BRW_MASK_DISABLE);
|
2012-12-06 12:15:13 -08:00
|
|
|
brw_MOV(p, flags, dispatch_mask);
|
2012-06-18 14:50:04 -07:00
|
|
|
brw_pop_insn_state(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-11-23 10:13:39 -08:00
|
|
|
static uint32_t brw_file_from_reg(fs_reg *reg)
|
|
|
|
|
{
|
|
|
|
|
switch (reg->file) {
|
|
|
|
|
case ARF:
|
|
|
|
|
return BRW_ARCHITECTURE_REGISTER_FILE;
|
|
|
|
|
case GRF:
|
|
|
|
|
return BRW_GENERAL_REGISTER_FILE;
|
|
|
|
|
case MRF:
|
|
|
|
|
return BRW_MESSAGE_REGISTER_FILE;
|
|
|
|
|
case IMM:
|
|
|
|
|
return BRW_IMMEDIATE_VALUE;
|
|
|
|
|
default:
|
|
|
|
|
assert(!"not reached");
|
|
|
|
|
return BRW_GENERAL_REGISTER_FILE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
static struct brw_reg
|
|
|
|
|
brw_reg_from_fs_reg(fs_reg *reg)
|
|
|
|
|
{
|
|
|
|
|
struct brw_reg brw_reg;
|
|
|
|
|
|
|
|
|
|
switch (reg->file) {
|
|
|
|
|
case GRF:
|
|
|
|
|
case ARF:
|
|
|
|
|
case MRF:
|
|
|
|
|
if (reg->smear == -1) {
|
2011-11-23 10:13:39 -08:00
|
|
|
brw_reg = brw_vec8_reg(brw_file_from_reg(reg), reg->reg, 0);
|
2011-05-24 16:34:27 -07:00
|
|
|
} else {
|
2011-11-23 10:13:39 -08:00
|
|
|
brw_reg = brw_vec1_reg(brw_file_from_reg(reg), reg->reg, reg->smear);
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
brw_reg = retype(brw_reg, reg->type);
|
|
|
|
|
if (reg->sechalf)
|
|
|
|
|
brw_reg = sechalf(brw_reg);
|
|
|
|
|
break;
|
|
|
|
|
case IMM:
|
|
|
|
|
switch (reg->type) {
|
|
|
|
|
case BRW_REGISTER_TYPE_F:
|
|
|
|
|
brw_reg = brw_imm_f(reg->imm.f);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_REGISTER_TYPE_D:
|
|
|
|
|
brw_reg = brw_imm_d(reg->imm.i);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_REGISTER_TYPE_UD:
|
|
|
|
|
brw_reg = brw_imm_ud(reg->imm.u);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
assert(!"not reached");
|
|
|
|
|
brw_reg = brw_null_reg();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case FIXED_HW_REG:
|
|
|
|
|
brw_reg = reg->fixed_hw_reg;
|
|
|
|
|
break;
|
|
|
|
|
case BAD_FILE:
|
|
|
|
|
/* Probably unused. */
|
|
|
|
|
brw_reg = brw_null_reg();
|
|
|
|
|
break;
|
|
|
|
|
case UNIFORM:
|
|
|
|
|
assert(!"not reached");
|
|
|
|
|
brw_reg = brw_null_reg();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
assert(!"not reached");
|
|
|
|
|
brw_reg = brw_null_reg();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (reg->abs)
|
|
|
|
|
brw_reg = brw_abs(brw_reg);
|
|
|
|
|
if (reg->negate)
|
|
|
|
|
brw_reg = negate(brw_reg);
|
|
|
|
|
|
|
|
|
|
return brw_reg;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-05 00:06:30 -08:00
|
|
|
/**
|
|
|
|
|
* Sets the second dword of a vgrf for gen7+ message setup.
|
|
|
|
|
*
|
|
|
|
|
* For setting up gen7 messages in VGRFs, we need to be able to set the second
|
|
|
|
|
* dword for some payloads where in the MRF world we'd have just used
|
|
|
|
|
* brw_message_reg(). We don't want to bake it into the send message's code
|
|
|
|
|
* generation because that means we don't get a chance to schedule the
|
|
|
|
|
* instructions.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
fs_generator::generate_set_global_offset(fs_inst *inst,
|
|
|
|
|
struct brw_reg dst,
|
|
|
|
|
struct brw_reg src,
|
|
|
|
|
struct brw_reg value)
|
|
|
|
|
{
|
|
|
|
|
/* We use a matching src and dst to get the information on how this
|
|
|
|
|
* instruction works exposed to various optimization passes that would
|
|
|
|
|
* otherwise treat it as completely overwriting the dst.
|
|
|
|
|
*/
|
|
|
|
|
assert(src.file == dst.file && src.nr == dst.nr);
|
|
|
|
|
assert(value.file == BRW_IMMEDIATE_VALUE);
|
|
|
|
|
|
|
|
|
|
brw_push_insn_state(p);
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
|
|
|
|
brw_set_mask_control(p, BRW_MASK_DISABLE);
|
|
|
|
|
brw_MOV(p, retype(brw_vec1_reg(dst.file, dst.nr, 2), value.type), value);
|
|
|
|
|
brw_pop_insn_state(p);
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
void
|
2012-11-09 01:05:47 -08:00
|
|
|
fs_generator::generate_code(exec_list *instructions)
|
2011-05-24 16:34:27 -07:00
|
|
|
{
|
2012-02-03 11:50:42 +01:00
|
|
|
int last_native_insn_offset = p->next_insn_offset;
|
2011-05-24 16:34:27 -07:00
|
|
|
const char *last_annotation_string = NULL;
|
2012-08-27 14:35:01 -07:00
|
|
|
const void *last_annotation_ir = NULL;
|
2011-05-24 16:34:27 -07:00
|
|
|
|
|
|
|
|
if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
|
2012-08-27 14:35:01 -07:00
|
|
|
if (shader) {
|
|
|
|
|
printf("Native code for fragment shader %d (%d-wide dispatch):\n",
|
2012-11-20 13:50:52 -08:00
|
|
|
prog->Name, dispatch_width);
|
2012-08-27 14:35:01 -07:00
|
|
|
} else {
|
|
|
|
|
printf("Native code for fragment program %d (%d-wide dispatch):\n",
|
2012-11-20 14:41:21 -08:00
|
|
|
fp->Base.Id, dispatch_width);
|
2012-08-27 14:35:01 -07:00
|
|
|
}
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
|
2012-10-03 13:16:09 -07:00
|
|
|
cfg_t *cfg = NULL;
|
2012-04-10 12:01:50 -07:00
|
|
|
if (unlikely(INTEL_DEBUG & DEBUG_WM))
|
2012-11-09 01:05:47 -08:00
|
|
|
cfg = new(mem_ctx) cfg_t(mem_ctx, instructions);
|
2012-04-10 12:01:50 -07:00
|
|
|
|
2012-11-09 01:05:47 -08:00
|
|
|
foreach_list(node, instructions) {
|
2011-07-29 11:52:39 -07:00
|
|
|
fs_inst *inst = (fs_inst *)node;
|
2011-05-24 16:34:27 -07:00
|
|
|
struct brw_reg src[3], dst;
|
|
|
|
|
|
|
|
|
|
if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
|
2012-04-10 12:01:50 -07:00
|
|
|
foreach_list(node, &cfg->block_list) {
|
2012-10-03 13:16:09 -07:00
|
|
|
bblock_link *link = (bblock_link *)node;
|
|
|
|
|
bblock_t *block = link->block;
|
2012-04-10 12:01:50 -07:00
|
|
|
|
|
|
|
|
if (block->start == inst) {
|
|
|
|
|
printf(" START B%d", block->block_num);
|
|
|
|
|
foreach_list(predecessor_node, &block->parents) {
|
2012-10-03 13:16:09 -07:00
|
|
|
bblock_link *predecessor_link =
|
|
|
|
|
(bblock_link *)predecessor_node;
|
|
|
|
|
bblock_t *predecessor_block = predecessor_link->block;
|
2012-04-10 12:01:50 -07:00
|
|
|
printf(" <-B%d", predecessor_block->block_num);
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
if (last_annotation_ir != inst->ir) {
|
|
|
|
|
last_annotation_ir = inst->ir;
|
|
|
|
|
if (last_annotation_ir) {
|
|
|
|
|
printf(" ");
|
2012-08-27 14:35:01 -07:00
|
|
|
if (shader)
|
|
|
|
|
((ir_instruction *)inst->ir)->print();
|
|
|
|
|
else {
|
|
|
|
|
const prog_instruction *fpi;
|
|
|
|
|
fpi = (const prog_instruction *)inst->ir;
|
|
|
|
|
printf("%d: ", (int)(fpi - fp->Base.Instructions));
|
|
|
|
|
_mesa_fprint_instruction_opt(stdout,
|
|
|
|
|
fpi,
|
|
|
|
|
0, PROG_PRINT_DEBUG, NULL);
|
|
|
|
|
}
|
2011-05-24 16:34:27 -07:00
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (last_annotation_string != inst->annotation) {
|
|
|
|
|
last_annotation_string = inst->annotation;
|
|
|
|
|
if (last_annotation_string)
|
|
|
|
|
printf(" %s\n", last_annotation_string);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < 3; i++) {
|
|
|
|
|
src[i] = brw_reg_from_fs_reg(&inst->src[i]);
|
2011-10-03 15:12:10 -07:00
|
|
|
|
|
|
|
|
/* The accumulator result appears to get used for the
|
|
|
|
|
* conditional modifier generation. When negating a UD
|
|
|
|
|
* value, there is a 33rd bit generated for the sign in the
|
|
|
|
|
* accumulator value, so now you can't check, for example,
|
|
|
|
|
* equality with a 32-bit value. See piglit fs-op-neg-uvec4.
|
|
|
|
|
*/
|
|
|
|
|
assert(!inst->conditional_mod ||
|
|
|
|
|
inst->src[i].type != BRW_REGISTER_TYPE_UD ||
|
|
|
|
|
!inst->src[i].negate);
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
dst = brw_reg_from_fs_reg(&inst->dst);
|
|
|
|
|
|
|
|
|
|
brw_set_conditionalmod(p, inst->conditional_mod);
|
2012-10-03 13:23:05 -07:00
|
|
|
brw_set_predicate_control(p, inst->predicate);
|
2011-05-24 16:34:27 -07:00
|
|
|
brw_set_predicate_inverse(p, inst->predicate_inverse);
|
2012-12-06 10:36:11 -08:00
|
|
|
brw_set_flag_reg(p, 0, inst->flag_subreg);
|
2011-05-24 16:34:27 -07:00
|
|
|
brw_set_saturate(p, inst->saturate);
|
2012-11-28 14:16:03 -08:00
|
|
|
brw_set_mask_control(p, inst->force_writemask_all);
|
2011-05-24 16:34:27 -07:00
|
|
|
|
2012-11-20 13:50:52 -08:00
|
|
|
if (inst->force_uncompressed || dispatch_width == 8) {
|
2011-05-24 16:34:27 -07:00
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
|
|
|
|
} else if (inst->force_sechalf) {
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
|
|
|
|
|
} else {
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (inst->opcode) {
|
|
|
|
|
case BRW_OPCODE_MOV:
|
|
|
|
|
brw_MOV(p, dst, src[0]);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_ADD:
|
|
|
|
|
brw_ADD(p, dst, src[0], src[1]);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_MUL:
|
|
|
|
|
brw_MUL(p, dst, src[0], src[1]);
|
|
|
|
|
break;
|
2011-08-15 22:36:18 -07:00
|
|
|
case BRW_OPCODE_MACH:
|
|
|
|
|
brw_set_acc_write_control(p, 1);
|
|
|
|
|
brw_MACH(p, dst, src[0], src[1]);
|
|
|
|
|
brw_set_acc_write_control(p, 0);
|
|
|
|
|
break;
|
2011-05-24 16:34:27 -07:00
|
|
|
|
2012-02-07 00:59:11 +01:00
|
|
|
case BRW_OPCODE_MAD:
|
|
|
|
|
brw_set_access_mode(p, BRW_ALIGN_16);
|
2012-11-20 13:50:52 -08:00
|
|
|
if (dispatch_width == 16) {
|
2012-02-07 00:59:11 +01:00
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
|
|
|
|
brw_MAD(p, dst, src[0], src[1], src[2]);
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_2NDHALF);
|
|
|
|
|
brw_MAD(p, sechalf(dst), sechalf(src[0]), sechalf(src[1]), sechalf(src[2]));
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
|
|
|
|
|
} else {
|
|
|
|
|
brw_MAD(p, dst, src[0], src[1], src[2]);
|
|
|
|
|
}
|
|
|
|
|
brw_set_access_mode(p, BRW_ALIGN_1);
|
|
|
|
|
break;
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
case BRW_OPCODE_FRC:
|
|
|
|
|
brw_FRC(p, dst, src[0]);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_RNDD:
|
|
|
|
|
brw_RNDD(p, dst, src[0]);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_RNDE:
|
|
|
|
|
brw_RNDE(p, dst, src[0]);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_RNDZ:
|
|
|
|
|
brw_RNDZ(p, dst, src[0]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BRW_OPCODE_AND:
|
|
|
|
|
brw_AND(p, dst, src[0], src[1]);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_OR:
|
|
|
|
|
brw_OR(p, dst, src[0], src[1]);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_XOR:
|
|
|
|
|
brw_XOR(p, dst, src[0], src[1]);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_NOT:
|
|
|
|
|
brw_NOT(p, dst, src[0]);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_ASR:
|
|
|
|
|
brw_ASR(p, dst, src[0], src[1]);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_SHR:
|
|
|
|
|
brw_SHR(p, dst, src[0], src[1]);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_SHL:
|
|
|
|
|
brw_SHL(p, dst, src[0], src[1]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BRW_OPCODE_CMP:
|
|
|
|
|
brw_CMP(p, dst, inst->conditional_mod, src[0], src[1]);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_SEL:
|
|
|
|
|
brw_SEL(p, dst, src[0], src[1]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BRW_OPCODE_IF:
|
|
|
|
|
if (inst->src[0].file != BAD_FILE) {
|
|
|
|
|
/* The instruction has an embedded compare (only allowed on gen6) */
|
|
|
|
|
assert(intel->gen == 6);
|
|
|
|
|
gen6_IF(p, inst->conditional_mod, src[0], src[1]);
|
|
|
|
|
} else {
|
2012-11-20 13:50:52 -08:00
|
|
|
brw_IF(p, dispatch_width == 16 ? BRW_EXECUTE_16 : BRW_EXECUTE_8);
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BRW_OPCODE_ELSE:
|
|
|
|
|
brw_ELSE(p);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_ENDIF:
|
|
|
|
|
brw_ENDIF(p);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BRW_OPCODE_DO:
|
2011-12-06 12:30:03 -08:00
|
|
|
brw_DO(p, BRW_EXECUTE_8);
|
2011-05-24 16:34:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BRW_OPCODE_BREAK:
|
2011-12-06 12:44:41 -08:00
|
|
|
brw_BREAK(p);
|
2011-05-24 16:34:27 -07:00
|
|
|
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
|
|
|
|
break;
|
|
|
|
|
case BRW_OPCODE_CONTINUE:
|
|
|
|
|
/* FINISHME: We need to write the loop instruction support still. */
|
|
|
|
|
if (intel->gen >= 6)
|
2011-12-06 12:09:58 -08:00
|
|
|
gen6_CONT(p);
|
2011-05-24 16:34:27 -07:00
|
|
|
else
|
2011-12-06 12:44:41 -08:00
|
|
|
brw_CONT(p);
|
2011-05-24 16:34:27 -07:00
|
|
|
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
|
|
|
|
break;
|
|
|
|
|
|
2011-12-06 12:30:03 -08:00
|
|
|
case BRW_OPCODE_WHILE:
|
|
|
|
|
brw_WHILE(p);
|
2011-05-24 16:34:27 -07:00
|
|
|
break;
|
|
|
|
|
|
2011-08-05 12:38:58 -07:00
|
|
|
case SHADER_OPCODE_RCP:
|
|
|
|
|
case SHADER_OPCODE_RSQ:
|
|
|
|
|
case SHADER_OPCODE_SQRT:
|
|
|
|
|
case SHADER_OPCODE_EXP2:
|
|
|
|
|
case SHADER_OPCODE_LOG2:
|
|
|
|
|
case SHADER_OPCODE_SIN:
|
|
|
|
|
case SHADER_OPCODE_COS:
|
2011-10-18 12:24:47 -07:00
|
|
|
if (intel->gen >= 7) {
|
|
|
|
|
generate_math1_gen7(inst, dst, src[0]);
|
|
|
|
|
} else if (intel->gen == 6) {
|
2011-08-18 11:55:42 -07:00
|
|
|
generate_math1_gen6(inst, dst, src[0]);
|
|
|
|
|
} else {
|
|
|
|
|
generate_math_gen4(inst, dst, src[0]);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2011-09-28 17:37:54 -07:00
|
|
|
case SHADER_OPCODE_INT_QUOTIENT:
|
|
|
|
|
case SHADER_OPCODE_INT_REMAINDER:
|
2011-08-18 11:55:42 -07:00
|
|
|
case SHADER_OPCODE_POW:
|
2011-11-07 12:07:44 -08:00
|
|
|
if (intel->gen >= 7) {
|
2011-10-18 12:24:47 -07:00
|
|
|
generate_math2_gen7(inst, dst, src[0], src[1]);
|
|
|
|
|
} else if (intel->gen == 6) {
|
2011-08-18 11:55:42 -07:00
|
|
|
generate_math2_gen6(inst, dst, src[0], src[1]);
|
|
|
|
|
} else {
|
|
|
|
|
generate_math_gen4(inst, dst, src[0]);
|
|
|
|
|
}
|
2011-05-24 16:34:27 -07:00
|
|
|
break;
|
|
|
|
|
case FS_OPCODE_PIXEL_X:
|
|
|
|
|
generate_pixel_xy(dst, true);
|
|
|
|
|
break;
|
|
|
|
|
case FS_OPCODE_PIXEL_Y:
|
|
|
|
|
generate_pixel_xy(dst, false);
|
|
|
|
|
break;
|
|
|
|
|
case FS_OPCODE_CINTERP:
|
|
|
|
|
brw_MOV(p, dst, src[0]);
|
|
|
|
|
break;
|
|
|
|
|
case FS_OPCODE_LINTERP:
|
|
|
|
|
generate_linterp(inst, dst, src);
|
|
|
|
|
break;
|
2011-10-26 12:58:37 -07:00
|
|
|
case SHADER_OPCODE_TEX:
|
2011-05-24 16:34:27 -07:00
|
|
|
case FS_OPCODE_TXB:
|
2011-10-26 12:58:37 -07:00
|
|
|
case SHADER_OPCODE_TXD:
|
|
|
|
|
case SHADER_OPCODE_TXF:
|
|
|
|
|
case SHADER_OPCODE_TXL:
|
|
|
|
|
case SHADER_OPCODE_TXS:
|
2011-05-24 16:34:27 -07:00
|
|
|
generate_tex(inst, dst, src[0]);
|
|
|
|
|
break;
|
|
|
|
|
case FS_OPCODE_DDX:
|
|
|
|
|
generate_ddx(inst, dst, src[0]);
|
|
|
|
|
break;
|
|
|
|
|
case FS_OPCODE_DDY:
|
2012-06-20 13:40:45 -07:00
|
|
|
/* Make sure fp->UsesDFdy flag got set (otherwise there's no
|
|
|
|
|
* guarantee that c->key.render_to_fbo is set).
|
|
|
|
|
*/
|
|
|
|
|
assert(fp->UsesDFdy);
|
2012-06-20 13:40:45 -07:00
|
|
|
generate_ddy(inst, dst, src[0], c->key.render_to_fbo);
|
2011-05-24 16:34:27 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FS_OPCODE_SPILL:
|
|
|
|
|
generate_spill(inst, src[0]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FS_OPCODE_UNSPILL:
|
|
|
|
|
generate_unspill(inst, dst);
|
|
|
|
|
break;
|
|
|
|
|
|
2012-11-07 10:42:34 -08:00
|
|
|
case FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD:
|
|
|
|
|
generate_uniform_pull_constant_load(inst, dst, src[0], src[1]);
|
2011-05-24 16:34:27 -07:00
|
|
|
break;
|
|
|
|
|
|
2012-12-05 00:06:30 -08:00
|
|
|
case FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD_GEN7:
|
|
|
|
|
generate_uniform_pull_constant_load_gen7(inst, dst, src[0], src[1]);
|
|
|
|
|
break;
|
|
|
|
|
|
2012-11-07 11:18:34 -08:00
|
|
|
case FS_OPCODE_VARYING_PULL_CONSTANT_LOAD:
|
|
|
|
|
generate_varying_pull_constant_load(inst, dst, src[0]);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FS_OPCODE_VARYING_PULL_CONSTANT_LOAD_GEN7:
|
|
|
|
|
generate_varying_pull_constant_load_gen7(inst, dst, src[0], src[1]);
|
|
|
|
|
break;
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
case FS_OPCODE_FB_WRITE:
|
|
|
|
|
generate_fb_write(inst);
|
|
|
|
|
break;
|
2012-06-18 14:50:04 -07:00
|
|
|
|
|
|
|
|
case FS_OPCODE_MOV_DISPATCH_TO_FLAGS:
|
2012-12-06 10:36:11 -08:00
|
|
|
generate_mov_dispatch_to_flags(inst);
|
2012-06-18 14:50:04 -07:00
|
|
|
break;
|
|
|
|
|
|
2012-12-06 10:15:08 -08:00
|
|
|
case FS_OPCODE_DISCARD_JUMP:
|
|
|
|
|
generate_discard_jump(inst);
|
|
|
|
|
break;
|
|
|
|
|
|
2012-11-27 14:10:52 -08:00
|
|
|
case SHADER_OPCODE_SHADER_TIME_ADD:
|
|
|
|
|
brw_shader_time_add(p, inst->base_mrf, SURF_INDEX_WM_SHADER_TIME);
|
|
|
|
|
break;
|
|
|
|
|
|
2012-12-05 00:06:30 -08:00
|
|
|
case FS_OPCODE_SET_GLOBAL_OFFSET:
|
|
|
|
|
generate_set_global_offset(inst, dst, src[0], src[1]);
|
|
|
|
|
break;
|
|
|
|
|
|
2011-05-24 16:34:27 -07:00
|
|
|
default:
|
2012-11-14 14:24:31 -08:00
|
|
|
if (inst->opcode < (int) ARRAY_SIZE(opcode_descs)) {
|
2011-05-24 16:34:27 -07:00
|
|
|
_mesa_problem(ctx, "Unsupported opcode `%s' in FS",
|
2012-11-14 14:24:31 -08:00
|
|
|
opcode_descs[inst->opcode].name);
|
2011-05-24 16:34:27 -07:00
|
|
|
} else {
|
|
|
|
|
_mesa_problem(ctx, "Unsupported opcode %d in FS", inst->opcode);
|
|
|
|
|
}
|
2012-11-20 17:02:23 -08:00
|
|
|
abort();
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
|
2012-02-03 11:50:42 +01:00
|
|
|
brw_dump_compile(p, stdout,
|
|
|
|
|
last_native_insn_offset, p->next_insn_offset);
|
2012-04-10 12:01:50 -07:00
|
|
|
|
|
|
|
|
foreach_list(node, &cfg->block_list) {
|
2012-10-03 13:16:09 -07:00
|
|
|
bblock_link *link = (bblock_link *)node;
|
|
|
|
|
bblock_t *block = link->block;
|
2012-04-10 12:01:50 -07:00
|
|
|
|
|
|
|
|
if (block->end == inst) {
|
|
|
|
|
printf(" END B%d", block->block_num);
|
|
|
|
|
foreach_list(successor_node, &block->children) {
|
2012-10-03 13:16:09 -07:00
|
|
|
bblock_link *successor_link =
|
|
|
|
|
(bblock_link *)successor_node;
|
|
|
|
|
bblock_t *successor_block = successor_link->block;
|
2012-04-10 12:01:50 -07:00
|
|
|
printf(" ->B%d", successor_block->block_num);
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
|
2012-02-03 11:50:42 +01:00
|
|
|
last_native_insn_offset = p->next_insn_offset;
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (unlikely(INTEL_DEBUG & DEBUG_WM)) {
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
brw_set_uip_jip(p);
|
|
|
|
|
|
|
|
|
|
/* OK, while the INTEL_DEBUG=wm above is very nice for debugging FS
|
|
|
|
|
* emit issues, it doesn't get the jump distances into the output,
|
|
|
|
|
* which is often something we want to debug. So this is here in
|
|
|
|
|
* case you're doing that.
|
|
|
|
|
*/
|
|
|
|
|
if (0) {
|
2012-02-03 11:50:42 +01:00
|
|
|
brw_dump_compile(p, stdout, 0, p->next_insn_offset);
|
2011-05-24 16:34:27 -07:00
|
|
|
}
|
|
|
|
|
}
|
2012-11-09 01:05:47 -08:00
|
|
|
|
|
|
|
|
const unsigned *
|
|
|
|
|
fs_generator::generate_assembly(exec_list *simd8_instructions,
|
|
|
|
|
exec_list *simd16_instructions,
|
|
|
|
|
unsigned *assembly_size)
|
|
|
|
|
{
|
|
|
|
|
dispatch_width = 8;
|
|
|
|
|
generate_code(simd8_instructions);
|
|
|
|
|
|
|
|
|
|
if (simd16_instructions) {
|
|
|
|
|
/* We have to do a compaction pass now, or the one at the end of
|
|
|
|
|
* execution will squash down where our prog_offset start needs
|
|
|
|
|
* to be.
|
|
|
|
|
*/
|
|
|
|
|
brw_compact_instructions(p);
|
|
|
|
|
|
|
|
|
|
/* align to 64 byte boundary. */
|
|
|
|
|
while ((p->nr_insn * sizeof(struct brw_instruction)) % 64) {
|
|
|
|
|
brw_NOP(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Save off the start of this 16-wide program */
|
|
|
|
|
c->prog_data.prog_offset_16 = p->nr_insn * sizeof(struct brw_instruction);
|
|
|
|
|
|
|
|
|
|
brw_set_compression_control(p, BRW_COMPRESSION_COMPRESSED);
|
|
|
|
|
|
|
|
|
|
dispatch_width = 16;
|
|
|
|
|
generate_code(simd16_instructions);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return brw_get_program(p, assembly_size);
|
|
|
|
|
}
|