spirv: handle SpvOpMemberName
Now we can see field names in structs instead of generic "fieldN" with NIR_PRINT=1. Reviewed-by: Caio Oliveira <caio.oliveira@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13941>
This commit is contained in:
parent
8e568d3f00
commit
4f58cc82e2
|
@ -1272,11 +1272,11 @@ Test:SpvParserTest_Impl_GenericVulkanShader_GLSL450MemoryModel.spvasm:main|GLCom
|
|||
Test:SpvParserTest_Impl_GenericVulkanShader_SimpleMemoryModel.spvasm:main|GLCompute: Pass
|
||||
Test:SpvParserTest_Impl_GenericVulkanShader_VulkanMemoryModel.spvasm:main|GLCompute: Fail
|
||||
SPIR-V WARNING:
|
||||
In file ../src/compiler/spirv/spirv_to_nir.c:4663
|
||||
In file ../src/compiler/spirv/spirv_to_nir.c:4687
|
||||
Unsupported SPIR-V capability: SpvCapabilityVulkanMemoryModel (5345)
|
||||
28 bytes into the SPIR-V binary
|
||||
SPIR-V parsing FAILED:
|
||||
In file ../src/compiler/spirv/spirv_to_nir.c:4817
|
||||
In file ../src/compiler/spirv/spirv_to_nir.c:4841
|
||||
Vulkan memory model is unsupported by this driver
|
||||
68 bytes into the SPIR-V binary
|
||||
Compilation failed
|
||||
|
|
|
@ -597,7 +597,8 @@ _foreach_decoration_helper(struct vtn_builder *b,
|
|||
member, base_value->type->length);
|
||||
} else {
|
||||
/* Not a decoration */
|
||||
assert(dec->scope == VTN_DEC_EXECUTION_MODE);
|
||||
assert(dec->scope == VTN_DEC_EXECUTION_MODE ||
|
||||
dec->scope <= VTN_DEC_STRUCT_MEMBER_NAME0);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -688,6 +689,19 @@ vtn_handle_decoration(struct vtn_builder *b, SpvOp opcode,
|
|||
break;
|
||||
}
|
||||
|
||||
case SpvOpMemberName: {
|
||||
struct vtn_value *val = vtn_untyped_value(b, target);
|
||||
struct vtn_decoration *dec = rzalloc(b, struct vtn_decoration);
|
||||
|
||||
dec->scope = VTN_DEC_STRUCT_MEMBER_NAME0 - *(w++);
|
||||
|
||||
dec->member_name = vtn_string_literal(b, w, w_end - w, NULL);
|
||||
|
||||
dec->next = val->decoration;
|
||||
val->decoration = dec;
|
||||
break;
|
||||
}
|
||||
|
||||
case SpvOpGroupMemberDecorate:
|
||||
case SpvOpGroupDecorate: {
|
||||
struct vtn_value *group =
|
||||
|
@ -1510,9 +1524,19 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
|
|||
NIR_VLA(struct glsl_struct_field, fields, count);
|
||||
for (unsigned i = 0; i < num_fields; i++) {
|
||||
val->type->members[i] = vtn_get_type(b, w[i + 2]);
|
||||
const char *name = NULL;
|
||||
for (struct vtn_decoration *dec = val->decoration; dec; dec = dec->next) {
|
||||
if (dec->scope == VTN_DEC_STRUCT_MEMBER_NAME0 - i) {
|
||||
name = dec->member_name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!name)
|
||||
name = ralloc_asprintf(b, "field%d", i);
|
||||
|
||||
fields[i] = (struct glsl_struct_field) {
|
||||
.type = val->type->members[i]->type,
|
||||
.name = ralloc_asprintf(b, "field%d", i),
|
||||
.name = name,
|
||||
.location = -1,
|
||||
.offset = -1,
|
||||
};
|
||||
|
@ -4837,9 +4861,6 @@ vtn_handle_preamble_instruction(struct vtn_builder *b, SpvOp opcode,
|
|||
break;
|
||||
|
||||
case SpvOpMemberName:
|
||||
/* TODO */
|
||||
break;
|
||||
|
||||
case SpvOpExecutionMode:
|
||||
case SpvOpExecutionModeId:
|
||||
case SpvOpDecorationGroup:
|
||||
|
|
|
@ -624,14 +624,23 @@ struct vtn_value {
|
|||
|
||||
#define VTN_DEC_DECORATION -1
|
||||
#define VTN_DEC_EXECUTION_MODE -2
|
||||
#define VTN_DEC_STRUCT_MEMBER_NAME0 -3
|
||||
#define VTN_DEC_STRUCT_MEMBER0 0
|
||||
|
||||
struct vtn_decoration {
|
||||
struct vtn_decoration *next;
|
||||
|
||||
/* Specifies how to apply this decoration. Negative values represent a
|
||||
* decoration or execution mode. (See the VTN_DEC_ #defines above.)
|
||||
* Non-negative values specify that it applies to a structure member.
|
||||
/* Different kinds of decorations are stored in a value,
|
||||
the scope defines what decoration it refers to:
|
||||
|
||||
- VTN_DEC_DECORATION:
|
||||
decoration associated with the value
|
||||
- VTN_DEC_EXECUTION_MODE:
|
||||
an execution mode associated with an entrypoint value
|
||||
- VTN_DEC_STRUCT_MEMBER0 + m:
|
||||
decoration associated with member m of a struct value
|
||||
- VTN_DEC_STRUCT_MEMBER_NAME0 - m:
|
||||
name of m'th member of a struct value
|
||||
*/
|
||||
int scope;
|
||||
|
||||
|
@ -641,6 +650,7 @@ struct vtn_decoration {
|
|||
union {
|
||||
SpvDecoration decoration;
|
||||
SpvExecutionMode exec_mode;
|
||||
const char *member_name;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue