Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLSL -> MSL: raster_order_group annotation #2419

Open
jesusdz opened this issue Nov 19, 2024 · 0 comments
Open

HLSL -> MSL: raster_order_group annotation #2419

jesusdz opened this issue Nov 19, 2024 · 0 comments

Comments

@jesusdz
Copy link

jesusdz commented Nov 19, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant