summaryrefslogtreecommitdiffstats
path: root/src/compiler/spirv
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <[email protected]>2019-04-22 16:17:58 -0700
committerCaio Marcelo de Oliveira Filho <[email protected]>2019-04-23 14:58:01 -0700
commit7b66d584a3c685bf70893fe5cda2432cf4fbfdfb (patch)
treeab690d14069f6e1cc030084130d93aec79c03454 /src/compiler/spirv
parent0fb0058f18b24674583770c0c95600675ce8336e (diff)
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 <[email protected]>
Diffstat (limited to 'src/compiler/spirv')
-rw-r--r--src/compiler/spirv/gl_spirv.c2
-rw-r--r--src/compiler/spirv/spirv_to_nir.c48
-rw-r--r--src/compiler/spirv/vtn_alu.c2
-rw-r--r--src/compiler/spirv/vtn_private.h2
-rw-r--r--src/compiler/spirv/vtn_variables.c24
5 files changed, 39 insertions, 39 deletions
diff --git a/src/compiler/spirv/gl_spirv.c b/src/compiler/spirv/gl_spirv.c
index edb635a09d9..55b4437cb13 100644
--- a/src/compiler/spirv/gl_spirv.c
+++ b/src/compiler/spirv/gl_spirv.c
@@ -75,7 +75,7 @@ spec_constant_decoration_cb(struct vtn_builder *b, struct vtn_value *v,
return;
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;
return;
}
diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index 50847bb76a7..103efad22cc 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -527,7 +527,7 @@ vtn_handle_decoration(struct vtn_builder *b, SpvOp opcode,
unreachable("Invalid decoration opcode");
}
dec->decoration = *(w++);
- dec->literals = w;
+ dec->operands = w;
/* Link into the list */
dec->next = val->decoration;
@@ -721,8 +721,8 @@ array_stride_decoration_cb(struct vtn_builder *b,
struct vtn_type *type = val->type;
if (dec->decoration == SpvDecorationArrayStride) {
- vtn_fail_if(dec->literals[0] == 0, "ArrayStride must be non-zero");
- type->stride = dec->literals[0];
+ vtn_fail_if(dec->operands[0] == 0, "ArrayStride must be non-zero");
+ type->stride = dec->operands[0];
}
}
@@ -768,22 +768,22 @@ struct_member_decoration_cb(struct vtn_builder *b,
break;
case SpvDecorationStream:
/* Vulkan only allows one GS stream */
- vtn_assert(dec->literals[0] == 0);
+ vtn_assert(dec->operands[0] == 0);
break;
case SpvDecorationLocation:
- ctx->fields[member].location = dec->literals[0];
+ ctx->fields[member].location = dec->operands[0];
break;
case SpvDecorationComponent:
break; /* FIXME: What should we do with these? */
case SpvDecorationBuiltIn:
ctx->type->members[member] = vtn_type_copy(b, ctx->type->members[member]);
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;
break;
case SpvDecorationOffset:
- ctx->type->offsets[member] = dec->literals[0];
- ctx->fields[member].offset = dec->literals[0];
+ ctx->type->offsets[member] = dec->operands[0];
+ ctx->fields[member].offset = dec->operands[0];
break;
case SpvDecorationMatrixStride:
/* Handled as a second pass */
@@ -880,7 +880,7 @@ struct_member_matrix_stride_cb(struct vtn_builder *b,
vtn_fail_if(member < 0,
"The MatrixStride decoration is only allowed on members "
"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;
@@ -888,17 +888,17 @@ struct_member_matrix_stride_cb(struct vtn_builder *b,
if (mat_type->row_major) {
mat_type->array_element = vtn_type_copy(b, mat_type->array_element);
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,
- dec->literals[0], true);
+ dec->operands[0], true);
mat_type->array_element->type = glsl_get_column_type(mat_type->type);
} else {
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,
- dec->literals[0], false);
+ dec->operands[0], false);
}
/* 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;
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)
const_value->data64 = b->specializations[i].data64;
else
@@ -1643,7 +1643,7 @@ handle_workgroup_size_decoration_cb(struct vtn_builder *b,
{
vtn_assert(member == -1);
if (dec->decoration != SpvDecorationBuiltIn ||
- dec->literals[0] != SpvBuiltInWorkgroupSize)
+ dec->operands[0] != SpvBuiltInWorkgroupSize)
return;
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:
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;
case SpvExecutionModeDepthReplacing:
@@ -3875,15 +3875,15 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point,
case SpvExecutionModeLocalSize:
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[1] = mode->literals[1];
- b->shader->info.cs.local_size[2] = mode->literals[2];
+ b->shader->info.cs.local_size[0] = mode->operands[0];
+ b->shader->info.cs.local_size[1] = mode->operands[1];
+ b->shader->info.cs.local_size[2] = mode->operands[2];
break;
case SpvExecutionModeLocalSizeId:
- b->shader->info.cs.local_size[0] = vtn_constant_uint(b, mode->literals[0]);
- b->shader->info.cs.local_size[1] = vtn_constant_uint(b, mode->literals[1]);
- b->shader->info.cs.local_size[2] = vtn_constant_uint(b, mode->literals[2]);
+ 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->operands[1]);
+ b->shader->info.cs.local_size[2] = vtn_constant_uint(b, mode->operands[2]);
break;
case SpvExecutionModeLocalSizeHint:
@@ -3893,10 +3893,10 @@ vtn_handle_execution_mode(struct vtn_builder *b, struct vtn_value *entry_point,
case SpvExecutionModeOutputVertices:
if (b->shader->info.stage == MESA_SHADER_TESS_CTRL ||
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 {
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;
diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c
index 0c0e87e0e6f..d8ffc18d495 100644
--- a/src/compiler/spirv/vtn_alu.c
+++ b/src/compiler/spirv/vtn_alu.c
@@ -364,7 +364,7 @@ handle_rounding_mode(struct vtn_builder *b, struct vtn_value *val, int member,
assert(dec->scope == VTN_DEC_DECORATION);
if (dec->decoration != SpvDecorationFPRoundingMode)
return;
- switch (dec->literals[0]) {
+ switch (dec->operands[0]) {
case SpvFPRoundingModeRTE:
*out_rounding_mode = nir_rounding_mode_rtne;
break;
diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h
index f21bb5bd10c..0fc2bc4da7b 100644
--- a/src/compiler/spirv/vtn_private.h
+++ b/src/compiler/spirv/vtn_private.h
@@ -558,7 +558,7 @@ struct vtn_decoration {
*/
int scope;
- const uint32_t *literals;
+ const uint32_t *operands;
struct vtn_value *group;
union {
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index ad6c3789573..6fbe6900e48 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1470,13 +1470,13 @@ apply_var_decoration(struct vtn_builder *b,
var_data->image.access |= ACCESS_COHERENT;
break;
case SpvDecorationComponent:
- var_data->location_frac = dec->literals[0];
+ var_data->location_frac = dec->operands[0];
break;
case SpvDecorationIndex:
- var_data->index = dec->literals[0];
+ var_data->index = dec->operands[0];
break;
case SpvDecorationBuiltIn: {
- SpvBuiltIn builtin = dec->literals[0];
+ SpvBuiltIn builtin = dec->operands[0];
nir_variable_mode mode = var_data->mode;
vtn_get_builtin_location(b, builtin, &var_data->location, &mode);
@@ -1527,20 +1527,20 @@ apply_var_decoration(struct vtn_builder *b,
case SpvDecorationXfbBuffer:
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;
break;
case SpvDecorationXfbStride:
var_data->explicit_xfb_stride = true;
- var_data->xfb_stride = dec->literals[0];
+ var_data->xfb_stride = dec->operands[0];
break;
case SpvDecorationOffset:
var_data->explicit_offset = true;
- var_data->offset = dec->literals[0];
+ var_data->offset = dec->operands[0];
break;
case SpvDecorationStream:
- var_data->stream = dec->literals[0];
+ var_data->stream = dec->operands[0];
break;
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 */
switch (dec->decoration) {
case SpvDecorationBinding:
- vtn_var->binding = dec->literals[0];
+ vtn_var->binding = dec->operands[0];
vtn_var->explicit_binding = true;
return;
case SpvDecorationDescriptorSet:
- vtn_var->descriptor_set = dec->literals[0];
+ vtn_var->descriptor_set = dec->operands[0];
return;
case SpvDecorationInputAttachmentIndex:
- vtn_var->input_attachment_index = dec->literals[0];
+ vtn_var->input_attachment_index = dec->operands[0];
return;
case SpvDecorationPatch:
vtn_var->patch = true;
break;
case SpvDecorationOffset:
- vtn_var->offset = dec->literals[0];
+ vtn_var->offset = dec->operands[0];
break;
case SpvDecorationNonWritable:
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.
*/
if (dec->decoration == SpvDecorationLocation) {
- unsigned location = dec->literals[0];
+ unsigned location = dec->operands[0];
if (b->shader->info.stage == MESA_SHADER_FRAGMENT &&
vtn_var->mode == vtn_variable_mode_output) {
location += FRAG_RESULT_DATA0;