spirv: Rename vtn_decoration literals to operands
Decorations (and ExecutionModes) can have not only literals, but also Ids associated with them. So rename the field to the more general name "Operand" used by the spec. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
@@ -75,7 +75,7 @@ spec_constant_decoration_cb(struct vtn_builder *b, struct vtn_value *v,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (unsigned i = 0; i < b->num_specializations; i++) {
|
for (unsigned i = 0; i < b->num_specializations; i++) {
|
||||||
if (b->specializations[i].id == dec->literals[0]) {
|
if (b->specializations[i].id == dec->operands[0]) {
|
||||||
b->specializations[i].defined_on_module = true;
|
b->specializations[i].defined_on_module = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -527,7 +527,7 @@ vtn_handle_decoration(struct vtn_builder *b, SpvOp opcode,
|
|||||||
unreachable("Invalid decoration opcode");
|
unreachable("Invalid decoration opcode");
|
||||||
}
|
}
|
||||||
dec->decoration = *(w++);
|
dec->decoration = *(w++);
|
||||||
dec->literals = w;
|
dec->operands = w;
|
||||||
|
|
||||||
/* Link into the list */
|
/* Link into the list */
|
||||||
dec->next = val->decoration;
|
dec->next = val->decoration;
|
||||||
@@ -721,8 +721,8 @@ array_stride_decoration_cb(struct vtn_builder *b,
|
|||||||
struct vtn_type *type = val->type;
|
struct vtn_type *type = val->type;
|
||||||
|
|
||||||
if (dec->decoration == SpvDecorationArrayStride) {
|
if (dec->decoration == SpvDecorationArrayStride) {
|
||||||
vtn_fail_if(dec->literals[0] == 0, "ArrayStride must be non-zero");
|
vtn_fail_if(dec->operands[0] == 0, "ArrayStride must be non-zero");
|
||||||
type->stride = dec->literals[0];
|
type->stride = dec->operands[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -768,22 +768,22 @@ struct_member_decoration_cb(struct vtn_builder *b,
|
|||||||
break;
|
break;
|
||||||
case SpvDecorationStream:
|
case SpvDecorationStream:
|
||||||
/* Vulkan only allows one GS stream */
|
/* Vulkan only allows one GS stream */
|
||||||
vtn_assert(dec->literals[0] == 0);
|
vtn_assert(dec->operands[0] == 0);
|
||||||
break;
|
break;
|
||||||
case SpvDecorationLocation:
|
case SpvDecorationLocation:
|
||||||
ctx->fields[member].location = dec->literals[0];
|
ctx->fields[member].location = dec->operands[0];
|
||||||
break;
|
break;
|
||||||
case SpvDecorationComponent:
|
case SpvDecorationComponent:
|
||||||
break; /* FIXME: What should we do with these? */
|
break; /* FIXME: What should we do with these? */
|
||||||
case SpvDecorationBuiltIn:
|
case SpvDecorationBuiltIn:
|
||||||
ctx->type->members[member] = vtn_type_copy(b, ctx->type->members[member]);
|
ctx->type->members[member] = vtn_type_copy(b, ctx->type->members[member]);
|
||||||
ctx->type->members[member]->is_builtin = true;
|
ctx->type->members[member]->is_builtin = true;
|
||||||
ctx->type->members[member]->builtin = dec->literals[0];
|
ctx->type->members[member]->builtin = dec->operands[0];
|
||||||
ctx->type->builtin_block = true;
|
ctx->type->builtin_block = true;
|
||||||
break;
|
break;
|
||||||
case SpvDecorationOffset:
|
case SpvDecorationOffset:
|
||||||
ctx->type->offsets[member] = dec->literals[0];
|
ctx->type->offsets[member] = dec->operands[0];
|
||||||
ctx->fields[member].offset = dec->literals[0];
|
ctx->fields[member].offset = dec->operands[0];
|
||||||
break;
|
break;
|
||||||
case SpvDecorationMatrixStride:
|
case SpvDecorationMatrixStride:
|
||||||
/* Handled as a second pass */
|
/* Handled as a second pass */
|
||||||
@@ -880,7 +880,7 @@ struct_member_matrix_stride_cb(struct vtn_builder *b,
|
|||||||
vtn_fail_if(member < 0,
|
vtn_fail_if(member < 0,
|
||||||
"The MatrixStride decoration is only allowed on members "
|
"The MatrixStride decoration is only allowed on members "
|
||||||
"of OpTypeStruct");
|
"of OpTypeStruct");
|
||||||
vtn_fail_if(dec->literals[0] == 0, "MatrixStride must be non-zero");
|
vtn_fail_if(dec->operands[0] == 0, "MatrixStride must be non-zero");
|
||||||
|
|
||||||
struct member_decoration_ctx *ctx = void_ctx;
|
struct member_decoration_ctx *ctx = void_ctx;
|
||||||
|
|
||||||
@@ -888,17 +888,17 @@ struct_member_matrix_stride_cb(struct vtn_builder *b,
|
|||||||
if (mat_type->row_major) {
|
if (mat_type->row_major) {
|
||||||
mat_type->array_element = vtn_type_copy(b, mat_type->array_element);
|
mat_type->array_element = vtn_type_copy(b, mat_type->array_element);
|
||||||
mat_type->stride = mat_type->array_element->stride;
|
mat_type->stride = mat_type->array_element->stride;
|
||||||
mat_type->array_element->stride = dec->literals[0];
|
mat_type->array_element->stride = dec->operands[0];
|
||||||
|
|
||||||
mat_type->type = glsl_explicit_matrix_type(mat_type->type,
|
mat_type->type = glsl_explicit_matrix_type(mat_type->type,
|
||||||
dec->literals[0], true);
|
dec->operands[0], true);
|
||||||
mat_type->array_element->type = glsl_get_column_type(mat_type->type);
|
mat_type->array_element->type = glsl_get_column_type(mat_type->type);
|
||||||
} else {
|
} else {
|
||||||
vtn_assert(mat_type->array_element->stride > 0);
|
vtn_assert(mat_type->array_element->stride > 0);
|
||||||
mat_type->stride = dec->literals[0];
|
mat_type->stride = dec->operands[0];
|
||||||
|
|
||||||
mat_type->type = glsl_explicit_matrix_type(mat_type->type,
|
mat_type->type = glsl_explicit_matrix_type(mat_type->type,
|
||||||
dec->literals[0], false);
|
dec->operands[0], false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now that we've replaced the glsl_type with a properly strided matrix
|
/* Now that we've replaced the glsl_type with a properly strided matrix
|
||||||
@@ -1602,7 +1602,7 @@ spec_constant_decoration_cb(struct vtn_builder *b, struct vtn_value *v,
|
|||||||
struct spec_constant_value *const_value = data;
|
struct spec_constant_value *const_value = data;
|
||||||
|
|
||||||
for (unsigned i = 0; i < b->num_specializations; i++) {
|
for (unsigned i = 0; i < b->num_specializations; i++) {
|
||||||
if (b->specializations[i].id == dec->literals[0]) {
|
if (b->specializations[i].id == dec->operands[0]) {
|
||||||
if (const_value->is_double)
|
if (const_value->is_double)
|
||||||
const_value->data64 = b->specializations[i].data64;
|
const_value->data64 = b->specializations[i].data64;
|
||||||
else
|
else
|
||||||
@@ -1643,7 +1643,7 @@ handle_workgroup_size_decoration_cb(struct vtn_builder *b,
|
|||||||
{
|
{
|
||||||
vtn_assert(member == -1);
|
vtn_assert(member == -1);
|
||||||
if (dec->decoration != SpvDecorationBuiltIn ||
|
if (dec->decoration != SpvDecorationBuiltIn ||
|
||||||
dec->literals[0] != SpvBuiltInWorkgroupSize)
|
dec->operands[0] != SpvBuiltInWorkgroupSize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vtn_assert(val->type->type == glsl_vector_type(GLSL_TYPE_UINT, 3));
|
vtn_assert(val->type->type == glsl_vector_type(GLSL_TYPE_UINT, 3));
|
||||||
@@ -3853,7 +3853,7 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point,
|
|||||||
|
|
||||||
case SpvExecutionModeInvocations:
|
case SpvExecutionModeInvocations:
|
||||||
vtn_assert(b->shader->info.stage == MESA_SHADER_GEOMETRY);
|
vtn_assert(b->shader->info.stage == MESA_SHADER_GEOMETRY);
|
||||||
b->shader->info.gs.invocations = MAX2(1, mode->literals[0]);
|
b->shader->info.gs.invocations = MAX2(1, mode->operands[0]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SpvExecutionModeDepthReplacing:
|
case SpvExecutionModeDepthReplacing:
|
||||||
@@ -3875,15 +3875,15 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point,
|
|||||||
|
|
||||||
case SpvExecutionModeLocalSize:
|
case SpvExecutionModeLocalSize:
|
||||||
vtn_assert(gl_shader_stage_is_compute(b->shader->info.stage));
|
vtn_assert(gl_shader_stage_is_compute(b->shader->info.stage));
|
||||||
b->shader->info.cs.local_size[0] = mode->literals[0];
|
b->shader->info.cs.local_size[0] = mode->operands[0];
|
||||||
b->shader->info.cs.local_size[1] = mode->literals[1];
|
b->shader->info.cs.local_size[1] = mode->operands[1];
|
||||||
b->shader->info.cs.local_size[2] = mode->literals[2];
|
b->shader->info.cs.local_size[2] = mode->operands[2];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SpvExecutionModeLocalSizeId:
|
case SpvExecutionModeLocalSizeId:
|
||||||
b->shader->info.cs.local_size[0] = vtn_constant_uint(b, mode->literals[0]);
|
b->shader->info.cs.local_size[0] = vtn_constant_uint(b, mode->operands[0]);
|
||||||
b->shader->info.cs.local_size[1] = vtn_constant_uint(b, mode->literals[1]);
|
b->shader->info.cs.local_size[1] = vtn_constant_uint(b, mode->operands[1]);
|
||||||
b->shader->info.cs.local_size[2] = vtn_constant_uint(b, mode->literals[2]);
|
b->shader->info.cs.local_size[2] = vtn_constant_uint(b, mode->operands[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SpvExecutionModeLocalSizeHint:
|
case SpvExecutionModeLocalSizeHint:
|
||||||
@@ -3893,10 +3893,10 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point,
|
|||||||
case SpvExecutionModeOutputVertices:
|
case SpvExecutionModeOutputVertices:
|
||||||
if (b->shader->info.stage == MESA_SHADER_TESS_CTRL ||
|
if (b->shader->info.stage == MESA_SHADER_TESS_CTRL ||
|
||||||
b->shader->info.stage == MESA_SHADER_TESS_EVAL) {
|
b->shader->info.stage == MESA_SHADER_TESS_EVAL) {
|
||||||
b->shader->info.tess.tcs_vertices_out = mode->literals[0];
|
b->shader->info.tess.tcs_vertices_out = mode->operands[0];
|
||||||
} else {
|
} else {
|
||||||
vtn_assert(b->shader->info.stage == MESA_SHADER_GEOMETRY);
|
vtn_assert(b->shader->info.stage == MESA_SHADER_GEOMETRY);
|
||||||
b->shader->info.gs.vertices_out = mode->literals[0];
|
b->shader->info.gs.vertices_out = mode->operands[0];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -364,7 +364,7 @@ handle_rounding_mode(struct vtn_builder *b, struct vtn_value *val, int member,
|
|||||||
assert(dec->scope == VTN_DEC_DECORATION);
|
assert(dec->scope == VTN_DEC_DECORATION);
|
||||||
if (dec->decoration != SpvDecorationFPRoundingMode)
|
if (dec->decoration != SpvDecorationFPRoundingMode)
|
||||||
return;
|
return;
|
||||||
switch (dec->literals[0]) {
|
switch (dec->operands[0]) {
|
||||||
case SpvFPRoundingModeRTE:
|
case SpvFPRoundingModeRTE:
|
||||||
*out_rounding_mode = nir_rounding_mode_rtne;
|
*out_rounding_mode = nir_rounding_mode_rtne;
|
||||||
break;
|
break;
|
||||||
|
@@ -558,7 +558,7 @@ struct vtn_decoration {
|
|||||||
*/
|
*/
|
||||||
int scope;
|
int scope;
|
||||||
|
|
||||||
const uint32_t *literals;
|
const uint32_t *operands;
|
||||||
struct vtn_value *group;
|
struct vtn_value *group;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
|
@@ -1470,13 +1470,13 @@ apply_var_decoration(struct vtn_builder *b,
|
|||||||
var_data->image.access |= ACCESS_COHERENT;
|
var_data->image.access |= ACCESS_COHERENT;
|
||||||
break;
|
break;
|
||||||
case SpvDecorationComponent:
|
case SpvDecorationComponent:
|
||||||
var_data->location_frac = dec->literals[0];
|
var_data->location_frac = dec->operands[0];
|
||||||
break;
|
break;
|
||||||
case SpvDecorationIndex:
|
case SpvDecorationIndex:
|
||||||
var_data->index = dec->literals[0];
|
var_data->index = dec->operands[0];
|
||||||
break;
|
break;
|
||||||
case SpvDecorationBuiltIn: {
|
case SpvDecorationBuiltIn: {
|
||||||
SpvBuiltIn builtin = dec->literals[0];
|
SpvBuiltIn builtin = dec->operands[0];
|
||||||
|
|
||||||
nir_variable_mode mode = var_data->mode;
|
nir_variable_mode mode = var_data->mode;
|
||||||
vtn_get_builtin_location(b, builtin, &var_data->location, &mode);
|
vtn_get_builtin_location(b, builtin, &var_data->location, &mode);
|
||||||
@@ -1527,20 +1527,20 @@ apply_var_decoration(struct vtn_builder *b,
|
|||||||
|
|
||||||
case SpvDecorationXfbBuffer:
|
case SpvDecorationXfbBuffer:
|
||||||
var_data->explicit_xfb_buffer = true;
|
var_data->explicit_xfb_buffer = true;
|
||||||
var_data->xfb_buffer = dec->literals[0];
|
var_data->xfb_buffer = dec->operands[0];
|
||||||
var_data->always_active_io = true;
|
var_data->always_active_io = true;
|
||||||
break;
|
break;
|
||||||
case SpvDecorationXfbStride:
|
case SpvDecorationXfbStride:
|
||||||
var_data->explicit_xfb_stride = true;
|
var_data->explicit_xfb_stride = true;
|
||||||
var_data->xfb_stride = dec->literals[0];
|
var_data->xfb_stride = dec->operands[0];
|
||||||
break;
|
break;
|
||||||
case SpvDecorationOffset:
|
case SpvDecorationOffset:
|
||||||
var_data->explicit_offset = true;
|
var_data->explicit_offset = true;
|
||||||
var_data->offset = dec->literals[0];
|
var_data->offset = dec->operands[0];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SpvDecorationStream:
|
case SpvDecorationStream:
|
||||||
var_data->stream = dec->literals[0];
|
var_data->stream = dec->operands[0];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SpvDecorationCPacked:
|
case SpvDecorationCPacked:
|
||||||
@@ -1587,20 +1587,20 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
|
|||||||
/* Handle decorations that apply to a vtn_variable as a whole */
|
/* Handle decorations that apply to a vtn_variable as a whole */
|
||||||
switch (dec->decoration) {
|
switch (dec->decoration) {
|
||||||
case SpvDecorationBinding:
|
case SpvDecorationBinding:
|
||||||
vtn_var->binding = dec->literals[0];
|
vtn_var->binding = dec->operands[0];
|
||||||
vtn_var->explicit_binding = true;
|
vtn_var->explicit_binding = true;
|
||||||
return;
|
return;
|
||||||
case SpvDecorationDescriptorSet:
|
case SpvDecorationDescriptorSet:
|
||||||
vtn_var->descriptor_set = dec->literals[0];
|
vtn_var->descriptor_set = dec->operands[0];
|
||||||
return;
|
return;
|
||||||
case SpvDecorationInputAttachmentIndex:
|
case SpvDecorationInputAttachmentIndex:
|
||||||
vtn_var->input_attachment_index = dec->literals[0];
|
vtn_var->input_attachment_index = dec->operands[0];
|
||||||
return;
|
return;
|
||||||
case SpvDecorationPatch:
|
case SpvDecorationPatch:
|
||||||
vtn_var->patch = true;
|
vtn_var->patch = true;
|
||||||
break;
|
break;
|
||||||
case SpvDecorationOffset:
|
case SpvDecorationOffset:
|
||||||
vtn_var->offset = dec->literals[0];
|
vtn_var->offset = dec->operands[0];
|
||||||
break;
|
break;
|
||||||
case SpvDecorationNonWritable:
|
case SpvDecorationNonWritable:
|
||||||
vtn_var->access |= ACCESS_NON_WRITEABLE;
|
vtn_var->access |= ACCESS_NON_WRITEABLE;
|
||||||
@@ -1633,7 +1633,7 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member,
|
|||||||
* special case.
|
* special case.
|
||||||
*/
|
*/
|
||||||
if (dec->decoration == SpvDecorationLocation) {
|
if (dec->decoration == SpvDecorationLocation) {
|
||||||
unsigned location = dec->literals[0];
|
unsigned location = dec->operands[0];
|
||||||
if (b->shader->info.stage == MESA_SHADER_FRAGMENT &&
|
if (b->shader->info.stage == MESA_SHADER_FRAGMENT &&
|
||||||
vtn_var->mode == vtn_variable_mode_output) {
|
vtn_var->mode == vtn_variable_mode_output) {
|
||||||
location += FRAG_RESULT_DATA0;
|
location += FRAG_RESULT_DATA0;
|
||||||
|
Reference in New Issue
Block a user