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

Feature Request: Allow shaderc to specify output type #3001

Open
cykoder opened this issue Dec 23, 2022 · 3 comments
Open

Feature Request: Allow shaderc to specify output type #3001

cykoder opened this issue Dec 23, 2022 · 3 comments

Comments

@cykoder
Copy link
Contributor

cykoder commented Dec 23, 2022

Currenly the output type is just hardcoded to vec4, I have a use case where I want to write to uint textures. In GLSL its possible to do like:

#if BGFX_SHADER_LANGUAGE_GLSL >= 400
out uvec2 visibility;
#endif

But theres no way to do this for SPIRV/HLSL this way. It also does not allow overriding of void main() for HLSL shaders, which could also be a solution to this issue. Example:

#if BGFX_SHADER_LANGUAGE_SPIRV > 0
void main(float4 gl_FragCoord : SV_POSITION , nointerpolation int2 v_bufferIDs : TEXCOORD6 , out uvec2 bgfx_FragData0 : SV_TARGET0 , uint gl_PrimitiveID : SV_PrimitiveID ) {
  uint instanceID = uint(v_bufferIDs.x);
  uint triangleID = uint(gl_PrimitiveID);
  bgfx_FragData0 = uvec2(triangleID, (instanceID + 1));
}
#else
// glsl code
#endif
@bkaradzic
Copy link
Owner

Why solution is multiple mains and #ifdefery when it could be just providing ability to set FragData type?

@cykoder
Copy link
Contributor Author

cykoder commented Dec 23, 2022

I would prefer the ability to set the FragData type of course, just mentioning that can also be another solution + it may be helpful in other scenarios whereby user wishes to define more inputs that BGFX doesnt generate. Could be seen as two separate issues but one also helps fix the other, albeit with hacky ifdefs

@bkaradzic
Copy link
Owner

You could already have this hacky shader with GLSL if you use --raw argument.

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

2 participants