mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 11:08:03 +02:00
zink: use actual const for const offset
When we emit constants, we don't know what type they'll be used as, so
we just emit them as uint, and then bitcast them to whatever we need.
But this isn't a good idea for ConstOffset, which needs to actually be a
const value, and not a const value bitcasted. So we sadly have to
open-code the const emitting here to avoid the problem.
Fixes: e963d35efe ("zink: use ConstOffset for nir_tex_src_offset")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4831
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11032>
This commit is contained in:
parent
3179daf613
commit
7613837206
1 changed files with 20 additions and 3 deletions
|
|
@ -2896,9 +2896,26 @@ emit_tex(struct ntv_context *ctx, nir_tex_instr *tex)
|
|||
break;
|
||||
|
||||
case nir_tex_src_offset:
|
||||
if (nir_src_is_const(tex->src[i].src))
|
||||
const_offset = get_src_int(ctx, &tex->src[i].src);
|
||||
else
|
||||
if (nir_src_is_const(tex->src[i].src)) {
|
||||
nir_const_value *v = nir_src_as_const_value(tex->src[i].src);
|
||||
unsigned bit_size = nir_src_bit_size(tex->src[i].src);
|
||||
unsigned num_components = nir_src_num_components(tex->src[i].src);
|
||||
|
||||
SpvId components[NIR_MAX_VEC_COMPONENTS];
|
||||
for (int i = 0; i < num_components; ++i) {
|
||||
int64_t tmp = nir_const_value_as_int(v[i], bit_size);
|
||||
components[i] = emit_int_const(ctx, bit_size, tmp);
|
||||
}
|
||||
|
||||
if (num_components > 1) {
|
||||
SpvId type = get_ivec_type(ctx, bit_size, num_components);
|
||||
const_offset = spirv_builder_const_composite(&ctx->builder,
|
||||
type,
|
||||
components,
|
||||
num_components);
|
||||
} else
|
||||
const_offset = components[0];
|
||||
} else
|
||||
offset = get_src_int(ctx, &tex->src[i].src);
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue