nir_variable *var;
+ /* If the variable is a struct with a location set on it then this will be
+ * stored here. This will be used to calculate locations for members that
+ * don’t have their own explicit location.
+ */
+ int base_location;
+
int shared_location;
/**
gl_shader_stage entry_point_stage;
const char *entry_point_name;
struct vtn_value *entry_point;
- bool origin_upper_left;
- bool pixel_center_integer;
+ struct vtn_value *workgroup_size_builtin;
bool variable_pointers;
struct vtn_function *func;
/* false by default, set to true by the ContractionOff execution mode */
bool exact;
+
+ /* when a physical memory model is choosen */
+ bool physical_ptrs;
};
nir_ssa_def *
vtn_set_instruction_result_type(struct vtn_builder *b, SpvOp opcode,
const uint32_t *w, unsigned count);
-static inline nir_constant *
-vtn_constant_value(struct vtn_builder *b, uint32_t value_id)
+static inline uint64_t
+vtn_constant_uint(struct vtn_builder *b, uint32_t value_id)
{
- return vtn_value(b, value_id, vtn_value_type_constant)->constant;
+ struct vtn_value *val = vtn_value(b, value_id, vtn_value_type_constant);
+
+ vtn_fail_if(val->type->base_type != vtn_base_type_scalar ||
+ !glsl_type_is_integer(val->type->type),
+ "Expected id %u to be an integer constant", value_id);
+
+ switch (glsl_get_bit_size(val->type->type)) {
+ case 8: return val->constant->values[0].u8[0];
+ case 16: return val->constant->values[0].u16[0];
+ case 32: return val->constant->values[0].u32[0];
+ case 64: return val->constant->values[0].u64[0];
+ default: unreachable("Invalid bit size");
+ }
}
struct vtn_ssa_value *vtn_ssa_value(struct vtn_builder *b, uint32_t value_id);
bool vtn_handle_glsl450_instruction(struct vtn_builder *b, SpvOp ext_opcode,
const uint32_t *words, unsigned count);
+bool vtn_handle_opencl_instruction(struct vtn_builder *b, uint32_t ext_opcode,
+ const uint32_t *words, unsigned count);
+
struct vtn_builder* vtn_create_builder(const uint32_t *words, size_t word_count,
gl_shader_stage stage, const char *entry_point_name,
const struct spirv_to_nir_options *options);