ir3/compiler: Enable lower_io_offsets pass and handle new SSBO intrinsics
[mesa.git] / src / compiler / spirv / vtn_private.h
index cba2bd665fa5673fff4d80f4fa40f04f48904efc..bdf326c26f73018b119b56645f87a3189a9aff2e 100644 (file)
@@ -475,6 +475,12 @@ struct vtn_variable {
 
    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;
 
    /**
@@ -594,8 +600,7 @@ struct vtn_builder {
    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;
@@ -608,6 +613,9 @@ struct vtn_builder {
 
    /* 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 *
@@ -667,10 +675,22 @@ bool
 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);
@@ -748,6 +768,9 @@ void vtn_handle_subgroup(struct vtn_builder *b, SpvOp opcode,
 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);