#Help porting GLSL to HLSL

15 messages · Page 1 of 1 (latest)

keen ravine
#

Hello! Out of curiosity I've been changing my GLSL shaders to HLSL, which I then compile to SPIR-V using Microsoft's dxc. However, while my GLSL shaders work, my HLSL shaders don't even render anything at all (and I've triple checked them, they're completely identical seemingly), nothing shows up in renderdoc and I'm left with a black screen. I've attached my vertex shaders, but I've also done the same for the fragment shaders.

Additionally, I'm wondering why the input struct (PSInput) into the pixel shader has to be exactly the same as the output struct of the vertex shader (VSOutput), is this just something that has to be true for Vulkan? I thought you could just keep the attributes you needed and it would work as long as the semantics are the same?

thorny light
#

Have you checked with RenderDoc to make sure that the uniform buffer data is matching what the shader expects?

#

I would double-check your matrices as well, and ensure the data your passing matches the layout that the shader expects (column-major vs. row-major, row vectors vs. column vectors, etc.)

keen ravine
strong plank
#

In HLSL, the type is float3x4. HLSL chooses to name it as floatRxC, as is traditional.
In GLSL, the type is mat4x3. GLSL unfortunately chooses to name it as matCxR which clashes with existing mathematical practice.
HLSL uses mul(A, B) for standard matrix multiplication, and A * B for the Hadamard product.
GLSL uses A * B for standard matrix multiplication, and matrixCompMult for the Hadamard product.
... worth reading it all

silent swan
#

@keen ravine are you with vulcan now or still doing opengl?

keen ravine
#

Hello, I fixed this, it turned out I was using the wrong order matrices, hlsl was loading them in in row-major form since I didn't ass the column_major keyword before each float4x4 matrix in the UBO

keen ravine
keen ravine
#

nevermind it works without the column_major keyword

silent swan
#

ah, i thought you were

keen ravine
#

i am beyond confused right now because i added it, then it worked

#

then removed it and it still works