[PATCH 0/1] MR140: vkd3d-shader/hlsl: Handle SV_IsFrontFace semantic.
From: Nikolay Sivov <nsivov(a)codeweavers.com> --- libs/vkd3d-shader/hlsl_sm4.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index f81be3e9..3fa18c53 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -115,6 +115,7 @@ bool hlsl_sm4_usage_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semant {"position", false, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_POSITION}, {"sv_position", false, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_POSITION}, + {"sv_isfrontface", false, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_IS_FRONT_FACE}, {"color", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_TARGET}, {"depth", true, VKD3D_SHADER_TYPE_PIXEL, D3D_NAME_DEPTH}, -- GitLab https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/140
This should be simple to test; we already have support in the shader runner for manual vertex buffers. -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/140#note_28785
I think I found an example in hlsl-struct-semantics.shader_test of what you're talking about regarding manually filled vertex buffers. I couldn't make it work for purposes of this semantic, because I don't fully understand how it works. I did try to specify 3 vertices, and use draw triangle strip 3. With SV_IsFrontFace I was going to switch between returned target colors. Flipping vertices order did not make any difference in shader output. I'm sure I screwed up something. Is there a good tutorial for this front face flag? For the patch itself, I'm sure having a test would be better and I'm going to look at adding one, but the change is very straightforward and generates what it should, according to disassembly. -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/140#note_28844
I think I found an example in hlsl-struct-semantics.shader_test of what you're talking about regarding manually filled vertex buffers. I couldn't make it work for purposes of this semantic, because I don't fully understand how it works. I did try to specify 3 vertices, and use draw triangle strip 3. With SV_IsFrontFace I was going to switch between returned target colors. Flipping vertices order did not make any difference in shader output. I'm sure I screwed up something.
Changing the vertex order doesn't change anything at all? I do realize now that the shader runners all have default (i.e. back face) culling, so it won't render anything at all if the triangle is back-facing. We can probably just disable culling unconditionally. That doesn't explain why you're getting the same face by changing the order, though. -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/140#note_29038
Test shader I used returned different color depending on this flag. Changing order gave me zeroes I believe, that shader never returns. I'll need to try again. -- https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/140#note_29276
participants (3)
-
Nikolay Sivov -
Nikolay Sivov (@nsivov) -
Zebediah Figura (@zfigura)