nir/vtn: Convert constant samplers to variables with data

Reviewd-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5242>
This commit is contained in:
Jesse Natalie
2020-05-01 10:47:58 -07:00
committed by Marge Bot
parent 397730edd5
commit b778e7bd6c
6 changed files with 88 additions and 6 deletions

View File

@@ -2486,6 +2486,32 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
break;
}
case SpvOpConstantSampler: {
/* Synthesize a pointer-to-sampler type, create a variable of that type,
* and give the variable a constant initializer with the sampler params */
struct vtn_type *sampler_type = vtn_value(b, w[1], vtn_value_type_type)->type;
struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_pointer);
struct vtn_type *ptr_type = rzalloc(b, struct vtn_type);
ptr_type = rzalloc(b, struct vtn_type);
ptr_type->base_type = vtn_base_type_pointer;
ptr_type->deref = sampler_type;
ptr_type->storage_class = SpvStorageClassUniform;
ptr_type->type = nir_address_format_to_glsl_type(
vtn_mode_to_address_format(b, vtn_variable_mode_function));
vtn_create_variable(b, val, ptr_type, ptr_type->storage_class, NULL, NULL);
nir_variable *nir_var = val->pointer->var->var;
nir_var->data.sampler.is_inline_sampler = true;
nir_var->data.sampler.addressing_mode = w[3];
nir_var->data.sampler.normalized_coordinates = w[4];
nir_var->data.sampler.filter_mode = w[5];
break;
}
case SpvOpAccessChain:
case SpvOpPtrAccessChain:
case SpvOpInBoundsAccessChain: