#Inconsistent rasterization/sampling (?) behavior between OpenGL and wgpu (D3D12/Vulkan)

26 messages · Page 1 of 1 (latest)

peak raft
#

I'm moving my game from OpenGL to WebGPU (using wgpu) and am noticing that there's something wrong with the way textures are sampled or rasterized on OpenGL and wgpu. wgpu is just kinda wobbly.

The weird thing is, RenderDoc says the vertex shader output is exactly the same between the two implementations. Yet for some reason the textures comes out wrong.

To pile on more weirdness: my game also supported ANGLE where it was fine. So were fundamental rasterization rules changed between D3D11 and D3D12? I'm trying to run wgpu on ANGLE to see if that sheds some light on things but figure I'm just gonna post this anyways.

Like I said, results are the same between OpenGL, wgpu Vulkan and wgpu D3D12 in RenderDoc. The only slight difference in the parameters I can discern is that wgpu Vulkan has the Y axis flipped by setting a negative-height viewport, but I don't think that's it (since D3D12 has it too?)

#

I mean there's a nonzero possibility my original renderer commits crimes against humanity by putting stuff on pixel edges but it never appeared I guess. I know when I was developing it I did have some sampling issues, but I solved those with a pixel snapper thing in the vertex shader (which I already re-implemented, and results are the same on both APIs for that, so...?)

renderdoc files attached

#

for reference, this is the pixel snapping code, before passing the vertex position out of the vertex shader:

    // View.screenPixelSize is 1/(size of render target in pixels)
    transformed += 1.0;
    transformed /= View.screenPixelSize * 2.0;
    transformed = floor(transformed + 0.5);
    transformed *= View.screenPixelSize * 2.0;
    transformed -= 1.0;

and in the screenshot the shader is just basic sample texture at UV. UVs go 0 to 1 (whole texture), just idk

#

Yeah ANGLE just doesn't wanna work so I'm gonna call that a dead end for a comparison test

oak vortex
#

Unfortunately, I can't open the wgpu.rdc, it gives me an error

#

Do you have a wgpu D3D12 capture?

peak raft
#

sure, two seconds

#

For reference in case it's relevant too: this is an RX 6900 XT

oak vortex
#

What difference should I be looking for between this and opengl? The sky background is upside down, but besides that, it looks similar to me

peak raft
#

it's most prominent on the logo, there's weird vertical stretches on the diagonal text where the sampling goes different, I guess?

#

should be really visible zoomed in on the screenshots I attached

oak vortex
#

The Y coordinates of the VS Output are subtly different

#

OpenGL

peak raft
#

bumped up the decimal places in renderdoc and they're actually exactly the same for me between OpenGL and D3D12. GPU difference?

oak vortex
#

possibly

peak raft
#

There's a bit more subtle of a difference with the 9-patch button backgrounds: they're rendered with bilinear filtering (unlike the logo) and bottom and top edges have a streak where the 9-patch isn't bounded correctly because I guess the coordinates are rasterized different?

I'm looking at it now with the pixel debugger thing (wish OpenGL had it) single it's a simpler example I guess

#

oh I guess another thing I should try is to just change the shader to dump the UVs as color

oak vortex
#

actually, I think the issue is the sampler

#

opengl uses a linear sampler, wgpu uses a point sampler

peak raft
#

oh my god am I that big of an idiot that I didn't chec that

#

well that still keeps me wondering what the hell is up with the 9-patches but frankly I'm looking at the vertex data and I'm more wondering why it doesn't do that on OpenGL so I guess that's fixable enough

peak raft
#

lesson learned: double check the enum definitions you wrote at 1 AM for your wrapper that should match the underlying API🤦‍♀️