}
static nir_ssa_def *
-sample_plane(nir_builder *b, nir_tex_instr *tex, int plane)
+sample_plane(nir_builder *b, nir_tex_instr *tex, int plane,
+ const nir_lower_tex_options *options)
{
assert(tex->dest.is_ssa);
assert(nir_tex_instr_dest_size(tex) == 4);
nir_builder_instr_insert(b, &plane_tex->instr);
+ /* If scaling_factor is set, return a scaled value. */
+ if (options->scale_factors[tex->texture_index])
+ return nir_fmul_imm(b, &plane_tex->dest.ssa,
+ options->scale_factors[tex->texture_index]);
+
return &plane_tex->dest.ssa;
}
}
static void
-lower_y_uv_external(nir_builder *b, nir_tex_instr *tex)
+lower_y_uv_external(nir_builder *b, nir_tex_instr *tex,
+ const nir_lower_tex_options *options)
{
b->cursor = nir_after_instr(&tex->instr);
- nir_ssa_def *y = sample_plane(b, tex, 0);
- nir_ssa_def *uv = sample_plane(b, tex, 1);
+ nir_ssa_def *y = sample_plane(b, tex, 0, options);
+ nir_ssa_def *uv = sample_plane(b, tex, 1, options);
convert_yuv_to_rgb(b, tex,
nir_channel(b, y, 0),
}
static void
-lower_y_u_v_external(nir_builder *b, nir_tex_instr *tex)
+lower_y_u_v_external(nir_builder *b, nir_tex_instr *tex,
+ const nir_lower_tex_options *options)
{
b->cursor = nir_after_instr(&tex->instr);
- nir_ssa_def *y = sample_plane(b, tex, 0);
- nir_ssa_def *u = sample_plane(b, tex, 1);
- nir_ssa_def *v = sample_plane(b, tex, 2);
+ nir_ssa_def *y = sample_plane(b, tex, 0, options);
+ nir_ssa_def *u = sample_plane(b, tex, 1, options);
+ nir_ssa_def *v = sample_plane(b, tex, 2, options);
convert_yuv_to_rgb(b, tex,
nir_channel(b, y, 0),
}
static void
-lower_yx_xuxv_external(nir_builder *b, nir_tex_instr *tex)
+lower_yx_xuxv_external(nir_builder *b, nir_tex_instr *tex,
+ const nir_lower_tex_options *options)
{
b->cursor = nir_after_instr(&tex->instr);
- nir_ssa_def *y = sample_plane(b, tex, 0);
- nir_ssa_def *xuxv = sample_plane(b, tex, 1);
+ nir_ssa_def *y = sample_plane(b, tex, 0, options);
+ nir_ssa_def *xuxv = sample_plane(b, tex, 1, options);
convert_yuv_to_rgb(b, tex,
nir_channel(b, y, 0),
}
static void
-lower_xy_uxvx_external(nir_builder *b, nir_tex_instr *tex)
+lower_xy_uxvx_external(nir_builder *b, nir_tex_instr *tex,
+ const nir_lower_tex_options *options)
{
b->cursor = nir_after_instr(&tex->instr);
- nir_ssa_def *y = sample_plane(b, tex, 0);
- nir_ssa_def *uxvx = sample_plane(b, tex, 1);
+ nir_ssa_def *y = sample_plane(b, tex, 0, options);
+ nir_ssa_def *uxvx = sample_plane(b, tex, 1, options);
convert_yuv_to_rgb(b, tex,
nir_channel(b, y, 1),
}
static void
-lower_ayuv_external(nir_builder *b, nir_tex_instr *tex)
+lower_ayuv_external(nir_builder *b, nir_tex_instr *tex,
+ const nir_lower_tex_options *options)
{
b->cursor = nir_after_instr(&tex->instr);
- nir_ssa_def *ayuv = sample_plane(b, tex, 0);
+ nir_ssa_def *ayuv = sample_plane(b, tex, 0, options);
convert_yuv_to_rgb(b, tex,
nir_channel(b, ayuv, 2),
}
if ((1 << tex->texture_index) & options->lower_y_uv_external) {
- lower_y_uv_external(b, tex);
+ lower_y_uv_external(b, tex, options);
progress = true;
}
if ((1 << tex->texture_index) & options->lower_y_u_v_external) {
- lower_y_u_v_external(b, tex);
+ lower_y_u_v_external(b, tex, options);
progress = true;
}
if ((1 << tex->texture_index) & options->lower_yx_xuxv_external) {
- lower_yx_xuxv_external(b, tex);
+ lower_yx_xuxv_external(b, tex, options);
progress = true;
}
if ((1 << tex->texture_index) & options->lower_xy_uxvx_external) {
- lower_xy_uxvx_external(b, tex);
+ lower_xy_uxvx_external(b, tex, options);
progress = true;
}
if ((1 << tex->texture_index) & options->lower_ayuv_external) {
- lower_ayuv_external(b, tex);
+ lower_ayuv_external(b, tex, options);
progress = true;
}