unreachable("not reached");
}
- instr->sampler = evaluate_deref(&instr->instr, ir->sampler);
+ instr->texture = evaluate_deref(&instr->instr, ir->sampler);
unsigned src_number = 0;
for (unsigned i = 0; i < num_srcs; i++)
src_init(&instr->src[i].src);
- instr->sampler_index = 0;
- instr->sampler_array_size = 0;
- instr->sampler = NULL;
+ instr->texture_index = 0;
+ instr->texture_array_size = 0;
+ instr->texture = NULL;
return instr;
}
return false;
}
- if (instr->sampler != NULL) {
- if (!visit_deref_src(instr->sampler, cb, state))
+ if (instr->texture != NULL) {
+ if (!visit_deref_src(instr->texture, cb, state))
return false;
}
nir_tex_src_ms_index, /* MSAA sample index */
nir_tex_src_ddx,
nir_tex_src_ddy,
- nir_tex_src_sampler_offset, /* < dynamically uniform indirect offset */
+ nir_tex_src_texture_offset, /* < dynamically uniform indirect offset */
nir_num_tex_src_types
} nir_tex_src_type;
/* gather component selector */
unsigned component : 2;
- /** The sampler index
+ /** The texture index
*
- * If this texture instruction has a nir_tex_src_sampler_offset source,
- * then the sampler index is given by sampler_index + sampler_offset.
+ * If this texture instruction has a nir_tex_src_texture_offset source,
+ * then the texture index is given by texture_index + texture_offset.
*/
- unsigned sampler_index;
+ unsigned texture_index;
- /** The size of the sampler array or 0 if it's not an array */
- unsigned sampler_array_size;
+ /** The size of the texture array or 0 if it's not an array */
+ unsigned texture_array_size;
- nir_deref_var *sampler; /* if this is NULL, use sampler_index instead */
+ nir_deref_var *texture; /* if this is NULL, use texture_index instead */
} nir_tex_instr;
static inline unsigned
unsigned saturate_t;
unsigned saturate_r;
- /* Bitmask of samplers that need swizzling.
+ /* Bitmask of textures that need swizzling.
*
- * If (swizzle_result & (1 << sampler_index)), then the swizzle in
- * swizzles[sampler_index] is applied to the result of the texturing
+ * If (swizzle_result & (1 << texture_index)), then the swizzle in
+ * swizzles[texture_index] is applied to the result of the texturing
* operation.
*/
unsigned swizzle_result;
- /* A swizzle for each sampler. Values 0-3 represent x, y, z, or w swizzles
+ /* A swizzle for each texture. Values 0-3 represent x, y, z, or w swizzles
* while 4 and 5 represent 0 and 1 respectively.
*/
uint8_t swizzles[32][4];
ntex->is_new_style_shadow = tex->is_new_style_shadow;
memcpy(ntex->const_offset, tex->const_offset, sizeof(ntex->const_offset));
ntex->component = tex->component;
- ntex->sampler_index = tex->sampler_index;
- ntex->sampler_array_size = tex->sampler_array_size;
- if (tex->sampler)
- ntex->sampler = clone_deref_var(state, tex->sampler, &ntex->instr);
+ ntex->texture_index = tex->texture_index;
+ ntex->texture_array_size = tex->texture_array_size;
+ if (tex->texture)
+ ntex->texture = clone_deref_var(state, tex->texture, &ntex->instr);
return ntex;
}
hash = HASH(hash, instr->const_offset);
unsigned component = instr->component;
hash = HASH(hash, component);
- hash = HASH(hash, instr->sampler_index);
- hash = HASH(hash, instr->sampler_array_size);
+ hash = HASH(hash, instr->texture_index);
+ hash = HASH(hash, instr->texture_array_size);
- assert(!instr->sampler);
+ assert(!instr->texture);
return hash;
}
memcmp(tex1->const_offset, tex2->const_offset,
sizeof(tex1->const_offset)) != 0 ||
tex1->component != tex2->component ||
- tex1->sampler_index != tex2->sampler_index ||
- tex1->sampler_array_size != tex2->sampler_array_size) {
+ tex1->texture_index != tex2->texture_index ||
+ tex1->texture_array_size != tex2->texture_array_size) {
return false;
}
- /* Don't support un-lowered sampler derefs currently. */
- assert(!tex1->sampler && !tex2->sampler);
+ /* Don't support un-lowered texture derefs currently. */
+ assert(!tex1->texture && !tex2->texture);
return true;
}
case nir_instr_type_tex: {
nir_tex_instr *tex = nir_instr_as_tex(instr);
- /* Don't support un-lowered sampler derefs currently. */
- if (tex->sampler)
+ /* Don't support un-lowered texture derefs currently. */
+ if (tex->texture)
return false;
return true;
calc_sampler_offsets(tail->child, instr, array_elements,
indirect, b, location);
- instr->sampler_index += deref_array->base_offset * *array_elements;
+ instr->texture_index += deref_array->base_offset * *array_elements;
if (deref_array->deref_array_type == nir_deref_array_type_indirect) {
nir_ssa_def *mul =
lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_program,
gl_shader_stage stage, nir_builder *builder)
{
- if (instr->sampler == NULL)
+ if (instr->texture == NULL)
return;
- instr->sampler_index = 0;
- unsigned location = instr->sampler->var->data.location;
+ instr->texture_index = 0;
+ unsigned location = instr->texture->var->data.location;
unsigned array_elements = 1;
nir_ssa_def *indirect = NULL;
builder->cursor = nir_before_instr(&instr->instr);
- calc_sampler_offsets(&instr->sampler->deref, instr, &array_elements,
+ calc_sampler_offsets(&instr->texture->deref, instr, &array_elements,
&indirect, builder, &location);
if (indirect) {
/* Now we can go ahead and move the source over to being a
* first-class texture source.
*/
- instr->src[instr->num_srcs].src_type = nir_tex_src_sampler_offset;
+ instr->src[instr->num_srcs].src_type = nir_tex_src_texture_offset;
instr->num_srcs++;
nir_instr_rewrite_src(&instr->instr,
&instr->src[instr->num_srcs - 1].src,
nir_src_for_ssa(indirect));
- instr->sampler_array_size = array_elements;
+ instr->texture_array_size = array_elements;
}
if (location > shader_program->NumUniformStorage - 1 ||
return;
}
- instr->sampler_index +=
+ instr->texture_index +=
shader_program->UniformStorage[location].opaque[stage].index;
- instr->sampler = NULL;
+ instr->texture = NULL;
}
typedef struct {
txs = nir_tex_instr_create(b->shader, 1);
txs->op = nir_texop_txs;
txs->sampler_dim = GLSL_SAMPLER_DIM_RECT;
- txs->sampler_index = tex->sampler_index;
+ txs->texture_index = tex->texture_index;
txs->dest_type = nir_type_int;
/* only single src, the lod: */
/* mask of src coords to saturate (clamp): */
unsigned sat_mask = 0;
- if ((1 << tex->sampler_index) & state->options->saturate_r)
+ if ((1 << tex->texture_index) & state->options->saturate_r)
sat_mask |= (1 << 2); /* .z */
- if ((1 << tex->sampler_index) & state->options->saturate_t)
+ if ((1 << tex->texture_index) & state->options->saturate_t)
sat_mask |= (1 << 1); /* .y */
- if ((1 << tex->sampler_index) & state->options->saturate_s)
+ if ((1 << tex->texture_index) & state->options->saturate_s)
sat_mask |= (1 << 0); /* .x */
/* If we are clamping any coords, we must lower projector first
state->progress = true;
}
- if (((1 << tex->sampler_index) & state->options->swizzle_result) &&
+ if (((1 << tex->texture_index) & state->options->swizzle_result) &&
!nir_tex_instr_is_query(tex) &&
!(tex->is_shadow && tex->is_new_style_shadow)) {
- swizzle_result(b, tex, state->options->swizzles[tex->sampler_index]);
+ swizzle_result(b, tex, state->options->swizzles[tex->texture_index]);
state->progress = true;
}
}
static bool
constant_fold_tex_instr(nir_tex_instr *instr)
{
- if (instr->sampler)
- return constant_fold_deref(&instr->instr, instr->sampler);
+ if (instr->texture)
+ return constant_fold_deref(&instr->instr, instr->texture);
else
return false;
}
case nir_tex_src_ddy:
fprintf(fp, "(ddy)");
break;
- case nir_tex_src_sampler_offset:
- fprintf(fp, "(sampler_offset)");
+ case nir_tex_src_texture_offset:
+ fprintf(fp, "(texture_offset)");
break;
default:
fprintf(fp, "%u (gather_component), ", instr->component);
}
- if (instr->sampler) {
- print_deref(instr->sampler, state);
+ if (instr->texture) {
+ print_deref(instr->texture, state);
} else {
- fprintf(fp, "%u", instr->sampler_index);
+ fprintf(fp, "%u", instr->texture_index);
}
- fprintf(fp, " (sampler)");
+ fprintf(fp, " (texture)");
}
static void
static void
add_var_use_tex(nir_tex_instr *instr, struct set *live)
{
- if (instr->sampler != NULL) {
- nir_variable *var = instr->sampler->var;
+ if (instr->texture != NULL) {
+ nir_variable *var = instr->texture->var;
_mesa_set_add(live, var);
}
}
validate_src(&instr->src[i].src, state);
}
- if (instr->sampler != NULL)
- validate_deref_var(instr, instr->sampler, state);
+ if (instr->texture != NULL)
+ validate_deref_var(instr, instr->texture, state);
validate_dest(&instr->dest, state);
}
instr->coord_components++;
assert(tgsi_inst->Src[samp].Register.File == TGSI_FILE_SAMPLER);
- instr->sampler_index = tgsi_inst->Src[samp].Register.Index;
+ instr->texture_index = tgsi_inst->Src[samp].Register.Index;
/* TODO if we supported any opc's which take an explicit SVIEW
* src, we would use that here instead. But for the "legacy"
* texture opc's the SVIEW index is same as SAMP index:
*/
- sview = instr->sampler_index;
+ sview = instr->texture_index;
if (op == nir_texop_lod) {
instr->dest_type = nir_type_float;
setup_texture_info(qlv, tgsi_inst->Texture.Texture);
assert(tgsi_inst->Src[1].Register.File == TGSI_FILE_SAMPLER);
- txs->sampler_index = tgsi_inst->Src[1].Register.Index;
- qlv->sampler_index = tgsi_inst->Src[1].Register.Index;
+ txs->texture_index = tgsi_inst->Src[1].Register.Index;
+ qlv->texture_index = tgsi_inst->Src[1].Register.Index;
/* only single src, the lod: */
txs->src[0].src = nir_src_for_ssa(ttn_channel(b, src[0], X));
type = TYPE_U32;
sam = ir3_SAM(b, opc, type, TGSI_WRITEMASK_XYZW,
- flags, tex->sampler_index, tex->sampler_index,
+ flags, tex->texture_index, tex->texture_index,
create_collect(b, src0, nsrc0),
create_collect(b, src1, nsrc1));
dst = get_dst(ctx, &tex->dest, 1);
sam = ir3_SAM(b, OPC_GETINFO, TYPE_U32, TGSI_WRITEMASK_Z, 0,
- tex->sampler_index, tex->sampler_index, NULL, NULL);
+ tex->texture_index, tex->texture_index, NULL, NULL);
/* even though there is only one component, since it ends
* up in .z rather than .x, we need a split_dest()
lod = get_src(ctx, &tex->src[0].src)[0];
sam = ir3_SAM(b, OPC_GETSIZE, TYPE_U32, TGSI_WRITEMASK_XYZW, flags,
- tex->sampler_index, tex->sampler_index, lod, NULL);
+ tex->texture_index, tex->texture_index, lod, NULL);
split_dest(b, dst, sam, 4);
nir_tex_instr *txf = nir_tex_instr_create(c->s, 1);
txf->op = nir_texop_txf;
- txf->sampler = txf_ms->sampler;
- txf->sampler_index = txf_ms->sampler_index;
+ txf->texture = txf_ms->texture;
+ txf->texture_index = txf_ms->texture_index;
txf->coord_components = txf_ms->coord_components;
txf->is_shadow = txf_ms->is_shadow;
txf->is_new_style_shadow = txf_ms->is_new_style_shadow;
uint32_t tile_h_shift = 5;
uint32_t tile_size = (tile_h * tile_w *
VC4_MAX_SAMPLES * sizeof(uint32_t));
- unsigned unit = txf_ms->sampler_index;
+ unsigned unit = txf_ms->texture_index;
uint32_t w = align(c->key->tex[unit].msaa_width, tile_w);
uint32_t w_tiles = w / tile_w;
uint32_t tile_size = (tile_height * tile_width *
VC4_MAX_SAMPLES * sizeof(uint32_t));
- unsigned unit = instr->sampler_index;
+ unsigned unit = instr->texture_index;
uint32_t w = align(c->key->tex[unit].msaa_width, tile_width);
uint32_t w_tiles = w / tile_width;
uint32_t h = align(c->key->tex[unit].msaa_height, tile_height);
{
struct qreg s, t, r, lod, proj, compare;
bool is_txb = false, is_txl = false, has_proj = false;
- unsigned unit = instr->sampler_index;
+ unsigned unit = instr->texture_index;
if (instr->op == nir_texop_txf) {
ntq_emit_txf(c, instr);
void
fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
{
- unsigned sampler = instr->sampler_index;
- fs_reg sampler_reg(brw_imm_ud(sampler));
+ unsigned texture = instr->texture_index;
+ fs_reg texture_reg(brw_imm_ud(texture));
int gather_component = instr->component;
case nir_tex_src_projector:
unreachable("should be lowered");
- case nir_tex_src_sampler_offset: {
- /* Figure out the highest possible sampler index and mark it as used */
- uint32_t max_used = sampler + instr->sampler_array_size - 1;
+ case nir_tex_src_texture_offset: {
+ /* Figure out the highest possible texture index and mark it as used */
+ uint32_t max_used = texture + instr->texture_array_size - 1;
if (instr->op == nir_texop_tg4 && devinfo->gen < 8) {
max_used += stage_prog_data->binding_table.gather_texture_start;
} else {
brw_mark_surface_used(prog_data, max_used);
/* Emit code to evaluate the actual indexing expression */
- sampler_reg = vgrf(glsl_type::uint_type);
- bld.ADD(sampler_reg, src, brw_imm_ud(sampler));
- sampler_reg = bld.emit_uniformize(sampler_reg);
+ texture_reg = vgrf(glsl_type::uint_type);
+ bld.ADD(texture_reg, src, brw_imm_ud(texture));
+ texture_reg = bld.emit_uniformize(texture_reg);
break;
}
if (instr->op == nir_texop_txf_ms ||
instr->op == nir_texop_samples_identical) {
if (devinfo->gen >= 7 &&
- key_tex->compressed_multisample_layout_mask & (1 << sampler)) {
- mcs = emit_mcs_fetch(coordinate, instr->coord_components, sampler_reg);
+ key_tex->compressed_multisample_layout_mask & (1 << texture)) {
+ mcs = emit_mcs_fetch(coordinate, instr->coord_components, texture_reg);
} else {
mcs = brw_imm_ud(0u);
}
fs_reg dst = retype(get_nir_dest(instr->dest), BRW_REGISTER_TYPE_D);
fs_inst *inst = bld.emit(SHADER_OPCODE_SAMPLEINFO, dst,
bld.vgrf(BRW_REGISTER_TYPE_D, 1),
- sampler_reg);
+ texture_reg);
inst->mlen = 1;
inst->header_size = 1;
inst->base_mrf = -1;
emit_texture(op, dest_type, coordinate, instr->coord_components,
shadow_comparitor, lod, lod2, lod_components, sample_index,
tex_offset, mcs, gather_component,
- is_cube_array, sampler, sampler_reg);
+ is_cube_array, texture, texture_reg);
fs_reg dest = get_nir_dest(instr->dest);
dest.type = this->result.type;
void
vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
{
- unsigned sampler = instr->sampler_index;
- src_reg sampler_reg = brw_imm_ud(sampler);
+ unsigned texture = instr->texture_index;
+ src_reg texture_reg = brw_imm_ud(texture);
src_reg coordinate;
const glsl_type *coord_type = NULL;
src_reg shadow_comparitor;
offset_value = get_nir_src(instr->src[i].src, BRW_REGISTER_TYPE_D, 2);
break;
- case nir_tex_src_sampler_offset: {
- /* The highest sampler which may be used by this operation is
+ case nir_tex_src_texture_offset: {
+ /* The highest texture which may be used by this operation is
* the last element of the array. Mark it here, because the generator
* doesn't have enough information to determine the bound.
*/
- uint32_t array_size = instr->sampler_array_size;
- uint32_t max_used = sampler + array_size - 1;
+ uint32_t array_size = instr->texture_array_size;
+ uint32_t max_used = texture + array_size - 1;
if (instr->op == nir_texop_tg4) {
max_used += prog_data->base.binding_table.gather_texture_start;
} else {
/* Emit code to evaluate the actual indexing expression */
src_reg src = get_nir_src(instr->src[i].src, 1);
src_reg temp(this, glsl_type::uint_type);
- emit(ADD(dst_reg(temp), src, brw_imm_ud(sampler)));
- sampler_reg = emit_uniformize(temp);
+ emit(ADD(dst_reg(temp), src, brw_imm_ud(texture)));
+ texture_reg = emit_uniformize(temp);
break;
}
instr->op == nir_texop_samples_identical) {
assert(coord_type != NULL);
if (devinfo->gen >= 7 &&
- key_tex->compressed_multisample_layout_mask & (1 << sampler)) {
- mcs = emit_mcs_fetch(coord_type, coordinate, sampler_reg);
+ key_tex->compressed_multisample_layout_mask & (1 << texture)) {
+ mcs = emit_mcs_fetch(coord_type, coordinate, texture_reg);
} else {
mcs = brw_imm_ud(0u);
}
/* Stuff the channel select bits in the top of the texture offset */
if (instr->op == nir_texop_tg4) {
if (instr->component == 1 &&
- (key_tex->gather_channel_quirk_mask & (1 << sampler))) {
+ (key_tex->gather_channel_quirk_mask & (1 << texture))) {
/* gather4 sampler is broken for green channel on RG32F --
* we must ask for blue instead.
*/
shadow_comparitor,
lod, lod2, sample_index,
constant_offset, offset_value,
- mcs, is_cube_array, sampler, sampler_reg);
+ mcs, is_cube_array, texture, texture_reg);
}
void
instr->op = op;
instr->dest_type = nir_type_float;
instr->is_shadow = prog_inst->TexShadow;
- instr->sampler_index = prog_inst->TexSrcUnit;
+ instr->texture_index = prog_inst->TexSrcUnit;
switch (prog_inst->TexSrcTarget) {
case TEXTURE_1D_INDEX: