return pointer;
}
+/* Returns an atomic_uint type based on the original uint type. The returned
+ * type will be equivalent to the original one but will have an atomic_uint
+ * type as leaf instead of an uint.
+ *
+ * Manages uint scalars, arrays, and arrays of arrays of any nested depth.
+ */
+static const struct glsl_type *
+repair_atomic_type(const struct glsl_type *type)
+{
+ assert(glsl_get_base_type(glsl_without_array(type)) == GLSL_TYPE_UINT);
+ assert(glsl_type_is_scalar(glsl_without_array(type)));
+
+ if (glsl_type_is_array(type)) {
+ const struct glsl_type *atomic =
+ repair_atomic_type(glsl_get_array_element(type));
+
+ return glsl_array_type(atomic, glsl_get_length(type));
+ } else {
+ return glsl_atomic_uint_type();
+ }
+}
+
nir_deref_instr *
vtn_pointer_to_deref(struct vtn_builder *b, struct vtn_pointer *ptr)
{
return tail;
}
-nir_deref_var *
-vtn_pointer_to_deref_var(struct vtn_builder *b, struct vtn_pointer *ptr)
-{
- return nir_deref_instr_to_deref(vtn_pointer_to_deref(b, ptr), b);
-}
-
static void
_vtn_local_load_store(struct vtn_builder *b, bool load, nir_deref_instr *deref,
struct vtn_ssa_value *inout)
*location = FRAG_RESULT_STENCIL;
vtn_assert(*mode == nir_var_shader_out);
break;
+ case SpvBuiltInWorkDim:
+ *location = SYSTEM_VALUE_WORK_DIM;
+ set_mode_system_value(b, mode);
+ break;
+ case SpvBuiltInGlobalSize:
+ *location = SYSTEM_VALUE_GLOBAL_GROUP_SIZE;
+ set_mode_system_value(b, mode);
+ break;
default:
- vtn_fail("unsupported builtin");
+ vtn_fail("unsupported builtin: %u", builtin);
}
}
case SpvDecorationAliased:
case SpvDecorationUniform:
case SpvDecorationStream:
- case SpvDecorationOffset:
case SpvDecorationLinkageAttributes:
break; /* Do nothing with these here */
break;
case SpvDecorationXfbBuffer:
+ var_data->explicit_xfb_buffer = true;
+ var_data->xfb_buffer = dec->literals[0];
+ break;
case SpvDecorationXfbStride:
- vtn_warn("Vulkan does not have transform feedback: %s",
- spirv_decoration_to_string(dec->decoration));
+ var_data->explicit_xfb_stride = true;
+ var_data->xfb_stride = dec->literals[0];
+ break;
+ case SpvDecorationOffset:
+ var_data->explicit_offset = true;
+ var_data->offset = dec->literals[0];
break;
case SpvDecorationCPacked:
case SpvDecorationPatch:
vtn_var->patch = true;
break;
+ case SpvDecorationOffset:
+ vtn_var->offset = dec->literals[0];
+ break;
default:
break;
}
*/
if (dec->decoration == SpvDecorationLocation) {
unsigned location = dec->literals[0];
- bool is_vertex_input;
+ bool is_vertex_input = false;
if (b->shader->info.stage == MESA_SHADER_FRAGMENT &&
vtn_var->mode == vtn_variable_mode_output) {
- is_vertex_input = false;
location += FRAG_RESULT_DATA0;
} else if (b->shader->info.stage == MESA_SHADER_VERTEX &&
vtn_var->mode == vtn_variable_mode_input) {
location += VERT_ATTRIB_GENERIC0;
} else if (vtn_var->mode == vtn_variable_mode_input ||
vtn_var->mode == vtn_variable_mode_output) {
- is_vertex_input = false;
location += vtn_var->patch ? VARYING_SLOT_PATCH0 : VARYING_SLOT_VAR0;
} else if (vtn_var->mode != vtn_variable_mode_uniform) {
vtn_warn("Location must be on input, output, uniform, sampler or "
mode = vtn_variable_mode_workgroup;
nir_mode = nir_var_shared;
break;
+ case SpvStorageClassAtomicCounter:
+ mode = vtn_variable_mode_uniform;
+ nir_mode = nir_var_uniform;
+ break;
case SpvStorageClassCrossWorkgroup:
case SpvStorageClassGeneric:
- case SpvStorageClassAtomicCounter:
default:
vtn_fail("Unhandled variable storage class");
}
/* For these, we create the variable normally */
var->var = rzalloc(b->shader, nir_variable);
var->var->name = ralloc_strdup(var->var, val->name);
- var->var->type = var->type->type;
+
+ /* Need to tweak the nir type here as at vtn_handle_type we don't have
+ * the access to storage_class, that is the one that points us that is
+ * an atomic uint.
+ */
+ if (storage_class == SpvStorageClassAtomicCounter) {
+ var->var->type = repair_atomic_type(var->type->type);
+ } else {
+ var->var->type = var->type->type;
+ }
var->var->data.mode = nir_mode;
var->var->data.location = -1;
var->var->interface_type = NULL;
break;
}
- case vtn_variable_mode_param:
- vtn_fail("Not created through OpVariable");
-
case vtn_variable_mode_ubo:
case vtn_variable_mode_ssbo:
case vtn_variable_mode_push_constant:
var->var->data.explicit_binding = var->explicit_binding;
var->var->data.descriptor_set = var->descriptor_set;
var->var->data.index = var->input_attachment_index;
+ var->var->data.offset = var->offset;
if (glsl_type_is_image(without_array->type))
var->var->data.image.format = without_array->image_format;