KhronosGroup / KhronosGroup/SPIRV-Cross

HLSL -> MSL: raster_order_group annotation

Open
#2,419 1 comment 0 reactions 0 assignees View on GitHub
question
Dominant language
GLSL
Stars
2.5k
Forks
713
Avg merge
2d 18h
Merged PRs (30d)
16

Description

Hi there!

We're trying to add support for raster order groups while translating from HLSL to MSL, which is currently missing in SPIRV-Cross apparently.

We compilie HLSL -> SPIRV, then use SPIRV-Cross to generate SPIRV -> MSL, so ideally, we think it would be convenient to annotate HLSL in a way similar to this:

```
// 5635 is the number for DecorationUserSemantic / DecorationHlslSemanticGOOGLE
struct GBuffer
{
[[vk::location(0), vk::ext_decorate_string(5635, "raster_order_group(0)")]] float4 rt0 : SV_TARGET0;
[[vk::location(1), vk::ext_decorate_string(5635, "raster_order_group(0)")]] float4 rt1 : SV_TARGET1;
[[vk::location(2), vk::ext_decorate_string(5635, "raster_order_group(0)")]] float4 rt2 : SV_TARGET2;
[[vk::location(3), vk::ext_decorate_string(5635, "raster_order_group(1)")]] float4 rt3 : SV_TARGET3;
};
```

so an `OpMemberDecorate` with the user semantic is embedded into the SPIRV. Having this, we could introduce some changes into SPIRV-Cross to finally produce some MSL like this:

```
struct ps_main_out
{
float4 out_var_SV_TARGET0 [[color(0), raster_order_group(0)]];
float4 out_var_SV_TARGET1 [[color(1), raster_order_group(0)]];
float4 out_var_SV_TARGET2 [[color(2), raster_order_group(0)]];
float4 out_var_SV_TARGET3 [[color(3), raster_order_group(1)]];
};
```

I am not sure this is the better approach to achieve this. Is it possible there's a better approach rather than introducing this kind of hacky annotation in the SPIRV code?

Cheers!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing how SPIRV-Cross represents member decorations and how its SPIR-V-to-MSL path emits output attributes. Compare the proposed HLSL-to-SPIR-V user semantic with the desired raster_order_group annotations in MSL, then determine and document the supported representation. Done means the approach is agreed and the generated MSL preserves the requested raster order groups.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.