#What to do when one release mode doesn't work?

1 messages · Page 1 of 1 (latest)

true sentinel
#

releaseSafe is broken for me, but the other three work

Here's more context, my project is a 3D game i'm creating for fun, using releaseSafe nothing is rendered to the screen, but every other release mode works. so i'm quite puzzled as what's going on.

No error, no nothing. this have happened to me before, But, i was able to undo my work as i caught the issue very early on and so it was quickly fixed.

But that option is unfortunately not possible 28 files changed, 831 insertions(+), 894 deletions(-)
it was working for me the whole time with debug and fast so i thought it was fine.

smoky hull
#

that's very odd. do you remember what caused it last time?

#

my gut instinct says it's likely to be a stack uaf or something like that, since that's a type of illegal behaviour zig doesn't yet check for

true sentinel
#

Unsure, i was thinking it could be a vulkan issue, but how could vulkan break in one release mode and not the others

smoky hull
#

use after free

true sentinel
#

ahh

#

Why would releaseFast work then?

#

wouldn't it crash or something

smoky hull
#

not necessarily

#

it's not necessarily a stack uaf, but you're probably hitting some kind of unchecked illegal behaviour

#

that's the only real thing that can cause unintended differences between build modes

#

excluding a miscompilation, which is possible, but unlikely

true sentinel
#

hmm

#

That is going to be quite difficult to track down

smoky hull
#

yep

#

does vulkan give you any validation errors?

true sentinel
#

Oh i wish, i would've solved this issue a long time ago if it did

smoky hull
#

figures

#

well, you have two main approaches:

  • you can do a sort of "bottom up" approach where you step through in a debugger and check variables to see where it goes wrong
  • or you can do a "top down" approach where you start by looking at the frame in renderdoc to check why things aren't rendering, and then narrow down the cause from there
#

i recommend the latter

true sentinel
#

i don't know much about renderdoc, but i do know that through using it, the meshes are constructed properly and their data has the right values.

But i did notice something weird, in the depth test filter, the mesh pixels are colored red instead of the usual green.

smoky hull
#

interesting. can you try comparing the releasesafe and releasefast renderdoc captures side by side?

finite talon
#

Are all your structs that you are sending to the shaders marked correctly? Idk if extern or packed is correct for vulkan.

smoky hull
#

if they're not marked extern you would have some serious issues in any build mode

true sentinel
#

It's not a shader problem.

#

Anyway, the mesh being colored red, one of the reasons is the triangle is rejected because it's facing away from the camera

temporarily flipping the front face makes the result even stranger.
it's not like what you'd expect, you'd see the inside faces only, creating this weird 3D effect.
but kind of normal. like you flipped it to the correct face and it's only working for that build mode.

but that's definitely not the issue, face orientation and vertex order has been the same since forever.

#

i think that's just a red herring but it's worth a note

smoky hull
#

wait so it works in ReleaseSafe if you flip the face directions?

true sentinel
#

Kind of. it's weird and hard to describe.

#

and it's inconsistent

#

you'd think all triangles that face away from the camera would be drawn, but nope. only a specific type

smoky hull
#

can you send screenshots?

true sentinel
#

Wait, sorry i think i found the problem.

#

the meshes are only being constructed halfway on releaseSafe for whatever reason.

smoky hull
#

wdym by "halfway"?

#

like the buffer is the wrong size? or it's the right size but half of it is uninitialized?

true sentinel
#

i discovered the problem, i know i ignored your questions, but, Thank you for your help, you saved me from a lot of headache.

#

tldr the problem was in terrain generation. i switched back to old generation and now it works

smoky hull
#

interesting. do you know what actually caused it?

true sentinel
#

The only thing i changed is i stopped calling this short function
the game is a voxel game, i wanted to create a superflat world because its great for testing. but something here breaks.

it's probably world_y, as the mesh was being constructed properly, just that the blocks were not set properly, and this function seems to be the culprit.

pub fn generateSuperflatChunkAtmos(chunk: *Chunk) void {
    for (0..Util.chunk_size) |x| {
        for (0..Util.chunk_size) |z| {
            for (0..11) |y| {
                const world_y: u16 = @as(u16, @intCast(y)) + @as(u16, @intCast(chunk.world_pos.y));
                const index_3D = Util.localToIndex(x, y, z);
                const index_2D = Util.getIndex2D(x, z);

                switch (world_y) {
                    0...10 => chunk.chunk_atmos.solid[index_3D] = world_y,
                    else => {},
                }
                chunk.chunk_atmos.moisture[index_2D] = 150;
                chunk.chunk_atmos.temperature[index_2D] = 150;
            }
        }
    }
}
smoky hull
#

hmm, strange. nothing in there seems obviously wrong