nir/tex_instr: Rename sampler to texture
We're about to separate the two concepts. When we do, the sampler will become optional. Doing a rename first makes the separation a bit more safe because drivers that depend on GLSL or TGSI behaviour will be fine to just use the texture index all the time. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -1852,7 +1852,7 @@ nir_visitor::visit(ir_texture *ir)
|
||||
unreachable("not reached");
|
||||
}
|
||||
|
||||
instr->sampler = evaluate_deref(&instr->instr, ir->sampler);
|
||||
instr->texture = evaluate_deref(&instr->instr, ir->sampler);
|
||||
|
||||
unsigned src_number = 0;
|
||||
|
||||
|
@@ -486,9 +486,9 @@ nir_tex_instr_create(nir_shader *shader, unsigned num_srcs)
|
||||
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;
|
||||
}
|
||||
@@ -1007,8 +1007,8 @@ visit_tex_src(nir_tex_instr *instr, nir_foreach_src_cb cb, void *state)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@@ -965,7 +965,7 @@ typedef enum {
|
||||
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;
|
||||
|
||||
@@ -1015,17 +1015,17 @@ typedef struct {
|
||||
/* 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
|
||||
@@ -2091,15 +2091,15 @@ typedef struct nir_lower_tex_options {
|
||||
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];
|
||||
|
@@ -357,10 +357,10 @@ clone_tex(clone_state *state, const nir_tex_instr *tex)
|
||||
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;
|
||||
}
|
||||
|
@@ -155,10 +155,10 @@ hash_tex(uint32_t hash, const nir_tex_instr *instr)
|
||||
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;
|
||||
}
|
||||
@@ -305,13 +305,13 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2)
|
||||
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;
|
||||
}
|
||||
@@ -421,8 +421,8 @@ instr_can_rewrite(nir_instr *instr)
|
||||
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;
|
||||
|
@@ -52,7 +52,7 @@ calc_sampler_offsets(nir_deref *tail, nir_tex_instr *instr,
|
||||
|
||||
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 =
|
||||
@@ -91,16 +91,16 @@ static void
|
||||
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) {
|
||||
@@ -120,13 +120,13 @@ lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_progr
|
||||
/* 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 ||
|
||||
@@ -135,10 +135,10 @@ lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_progr
|
||||
return;
|
||||
}
|
||||
|
||||
instr->sampler_index +=
|
||||
instr->texture_index +=
|
||||
shader_program->UniformStorage[location].opaque[stage].index;
|
||||
|
||||
instr->sampler = NULL;
|
||||
instr->texture = NULL;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@@ -133,7 +133,7 @@ get_texture_size(nir_builder *b, nir_tex_instr *tex)
|
||||
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: */
|
||||
@@ -291,11 +291,11 @@ nir_lower_tex_block(nir_block *block, void *void_state)
|
||||
/* 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
|
||||
@@ -317,10 +317,10 @@ nir_lower_tex_block(nir_block *block, void *void_state)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -136,8 +136,8 @@ constant_fold_intrinsic_instr(nir_intrinsic_instr *instr)
|
||||
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;
|
||||
}
|
||||
|
@@ -622,8 +622,8 @@ print_tex_instr(nir_tex_instr *instr, print_state *state)
|
||||
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:
|
||||
@@ -652,13 +652,13 @@ print_tex_instr(nir_tex_instr *instr, print_state *state)
|
||||
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
|
||||
|
@@ -54,8 +54,8 @@ add_var_use_call(nir_call_instr *instr, struct set *live)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -445,8 +445,8 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state)
|
||||
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);
|
||||
}
|
||||
|
@@ -1309,13 +1309,13 @@ ttn_tex(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src)
|
||||
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;
|
||||
@@ -1456,8 +1456,8 @@ ttn_txq(struct ttn_compile *c, nir_alu_dest dest, nir_ssa_def **src)
|
||||
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));
|
||||
|
@@ -1548,7 +1548,7 @@ emit_tex(struct ir3_compile *ctx, nir_tex_instr *tex)
|
||||
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));
|
||||
|
||||
@@ -1575,7 +1575,7 @@ emit_tex_query_levels(struct ir3_compile *ctx, nir_tex_instr *tex)
|
||||
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()
|
||||
@@ -1612,7 +1612,7 @@ emit_tex_txs(struct ir3_compile *ctx, nir_tex_instr *tex)
|
||||
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);
|
||||
|
||||
|
@@ -47,8 +47,8 @@ vc4_nir_lower_txf_ms_instr(struct vc4_compile *c, nir_builder *b,
|
||||
|
||||
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;
|
||||
@@ -80,7 +80,7 @@ vc4_nir_lower_txf_ms_instr(struct vc4_compile *c, nir_builder *b,
|
||||
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;
|
||||
|
||||
|
@@ -296,7 +296,7 @@ ntq_emit_txf(struct vc4_compile *c, nir_tex_instr *instr)
|
||||
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);
|
||||
@@ -339,7 +339,7 @@ ntq_emit_tex(struct vc4_compile *c, nir_tex_instr *instr)
|
||||
{
|
||||
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);
|
||||
|
@@ -2940,8 +2940,8 @@ fs_visitor::nir_emit_shared_atomic(const fs_builder &bld,
|
||||
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;
|
||||
|
||||
@@ -3007,9 +3007,9 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
|
||||
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 {
|
||||
@@ -3018,9 +3018,9 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -3032,8 +3032,8 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
|
||||
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);
|
||||
}
|
||||
@@ -3070,7 +3070,7 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
|
||||
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;
|
||||
@@ -3084,7 +3084,7 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)
|
||||
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;
|
||||
|
@@ -1639,8 +1639,8 @@ glsl_type_for_nir_alu_type(nir_alu_type alu_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;
|
||||
@@ -1715,13 +1715,13 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
|
||||
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 {
|
||||
@@ -1733,8 +1733,8 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
|
||||
/* 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;
|
||||
}
|
||||
|
||||
@@ -1753,8 +1753,8 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
|
||||
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);
|
||||
}
|
||||
@@ -1771,7 +1771,7 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
|
||||
/* 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.
|
||||
*/
|
||||
@@ -1792,7 +1792,7 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
|
||||
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
|
||||
|
@@ -609,7 +609,7 @@ ptn_tex(nir_builder *b, nir_alu_dest dest, nir_ssa_def **src,
|
||||
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:
|
||||
|
Reference in New Issue
Block a user