KhronosGroup / KhronosGroup/SPIRV-Cross
[MSL] remap_variable_type_name is largely absent from MSL code emission.
- Dominant language
- GLSL
- Stars
- 2.5k
- Forks
- 713
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 16
Description
`set_variable_type_remap_callback` does not work on a MSL compiler because `remap_variable_type_name` is largely absent in spriv_msl.cpp.
Two examples of where it's absent:
In `void CompilerMSL::entry_point_args_discrete_descriptors(string &ep_args)`
The image type emission should look more like this:
```
case SPIRType::Image:
{
if (!ep_args.empty())
ep_args += ", ";
// Use Metal's native frame-buffer fetch API for subpass inputs.
const auto &basetype = get(var.basetype);
if (!type_is_msl_framebuffer_fetch(basetype))
{
auto theTypeName = image_type_glsl(type, var_id);
remap_variable_type_name(type, r.name, theTypeName);
ep_args += theTypeName + " " + r.name;
if (r.plane > 0)
ep_args += join(plane_name_suffix, r.plane);
ep_args += " [[texture(" + convert_to_string(r.index) + ")";
if (interlocked_resources.count(var_id))
ep_args += ", raster_order_group(0)";
ep_args += "]]";
}
```
In `string CompilerMSL::to_struct_member(const SPIRType &type, uint32_t member_type_id, uint32_t index, const string &qualifier)`
The last few lines of that method should look more like this:
```
string typeString = type_to_glsl(*declared_type, orig_id);
string memberName = to_member_name(type, index);
remap_variable_type_name(*declared_type, memberName, typeString);
auto result = join(pack_pfx,typeString, " ", qualifier, memberName,
member_attribute_qualifier(type, index), array_type, ";");
is_using_builtin_array = false;
return result;
```
The call to the remap callback is largely absent from whenever CompilerMSL overrides CompilerGLSL.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in spriv_msl.cpp with CompilerMSL::entry_point_args_discrete_descriptors and CompilerMSL::to_struct_member, then compare the corresponding CompilerGLSL implementations and inspect set_variable_type_remap_callback. Done means the remap_variable_type_name callback is applied in the identified MSL emission paths and the resulting code matches the issue's examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100