Skip to content

HLSL -> MSL: raster_order_group annotation #2419

@jesusdz

Description

@jesusdz

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther progress depends on answer from issue creator.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions