#GrubStomper29's OpenGL Sandbox

1 messages · Page 4 of 1

gilded shell
#

thats fine, I can work on getting the sphere bounds for now

#

these are always cool to look at

#

probably has something to do with padding

#

I HATE PADDING

kind sparrow
#

You can derive frustum culling yourself

gilded shell
night shoal
#

its a simple math problem

gilded shell
#

im good

kind sparrow
#

It's a good bite-sized math problem for a budding graphics programmer

#

And there are many valid ways to solve it

gilded shell
#

i suppose

#

regardless

#

i think I have found my problem

#
   uint transformIndex;
   int materialIndex;

   uint indexCount;
   uint firstIndex;
   int vertexOffset;

   vec3 boundingCenter;
   float boundingRadius;```
#

I think this is a bad memory layout

#
    uint transformIndex;
    int materialIndex;

    uint indexCount;
    uint firstIndex;
    int vertexOffset;

    int padding0;
    int padding1;

    vec3 boundingCenter;
    float boundingRadius;
#

I added some padding and it looks a little less munted

#

but still munted nonetheless, so I imagine theres more layout issues

#

this is an array of structs, let me check struct/array alignment

#

or because I'm doing my math wrong 💀

#

i shouldnt need padding1, only padding0

#

"If the member is a structure, the base alignment of the structure is N, where
N is the largest base alignment value of any of its members, and rounded
up to the base alignment of a vec4. The individual members of this substructure are then assigned offsets by applying this set of rules recursively,
where the base offset of the first member of the sub-structure is equal to the
aligned offset of the structure. The structure may have padding at the end;
the base offset of the member following the sub-structure is rounded up to
the next multiple of the base alignment of the structure."

junior sparrow
#

scalar layout my beloved

#

or you could reorder the variables

gilded shell
#

well id like to understand first

#

I believe the padding for an individual struct is fine, but it falls apart in an array of structs

#

this is what I have so far

#
{
    uint transformIndex;
    int materialIndex;

    uint indexCount;
    uint firstIndex;
    int vertexOffset;

    int padding0;

    vec3 boundingCenter;
    float boundingRadius;
};```
junior sparrow
#

this should work

{
    vec3 boundingCenter;
    float boundingRadius;

    uint transformIndex;
    int materialIndex;

    uint indexCount;
    uint firstIndex;
    int vertexOffset;
};```
gilded shell
#

but why

junior sparrow
#

just because

#

you could put padding between boundingCenter and boundingRadius it would work

#

try it and see

gilded shell
#

Haven't you heard the saying, "give a man a fish and he'll eat for a day. Teach a man to fish and he'll eat for life?"

junior sparrow
#

last time I touched alignment is 3 years

#

basically you want order types by their size so vec4 is first and vec3s is pain you need to put int/float in between so it can satisfy the vec4 alignment

#

and vec2s are fine

#

and scalars too

gilded shell
#

I see

junior sparrow
#

and matricies are fun too

gilded shell
#

heres a tree of clocks

junior sparrow
#

💀

gilded shell
#

it did in fact not work

junior sparrow
#

so switching to vulkan for scalar layout when?

gilded shell
#

after the suicide

west trail
gilded shell
#

this is std430 btw

west trail
#

Do vec4 + two uvec4 and stop having problems

junior sparrow
#

wait

junior sparrow
#

god I love scalar layout

gilded shell
#

but not vec3s!

#

on second thought, the array part is fine, something else must be wrong

#

@kind sparrow how cooked am I

west trail
gilded shell
#

I would imagine that

#

plus the additional 5 scalars

#

something still isnt adding up

west trail
#

Dumb people gamble on money, smart people gamble on memory layout

#

Shuffle until it works

junior sparrow
gilded shell
#

NOT something I want to see

#

weird

#

with/without the extra components shows the same data in nsight

#

however with the data in, I get this result

#

I wonder what's wrong

west trail
#

Looks like fucked up indices idk

gilded shell
#

obviously but I need to figure out why

junior sparrow
#

this spaghetti could be anything

#

previously it worked?

gilded shell
#

yeah, the only real difference now is the size of the cluster struct

#

could C++ have some implicit padding we havent thought of?

junior sparrow
#

wouldnt say so

#

issue is going to be 100% shaders

#

do you have same struct def in c++ and glsl

gilded shell
#

yes

junior sparrow
#

🫡

gilded shell
junior sparrow
#

then some indexing stuff

gilded shell
#

I AM giving up in the face of problems

#

this is cooked so Ill figure it out later

night shoal
#

try a simpler mesh

kind sparrow
#

Alignment is easy you just look at the buffer in renderdoc and if RD misinterprets the data then so will GL

#

Oh I see it looks ok

#

Idk then

#

Is this Vulkan or GL

#

std430 everything is aligned to a vec4 basically

#

I wouldn't trust vec3s at all

#

I would put the scalar into the 4th component of a vec4

#

And then pad the whole struct to a multiple of 16B

#

I'm pretty sure GL will implicitly pad a vec3 to a vec4 so you can't rely on fitting a scalar into that hole

gilded shell
#

ill have to try that

#

maybe nsight buffer readings are misleading

#

if representing a sphere with a vec4, it makes most sense for the radius to be the last component, correct?

kind sparrow
#

Yeah

gilded shell
kind sparrow
#

Lmao

#

What inspired this character

gilded shell
#

I have no idea

#

my pal moochoie12 drew it

#

its clearly not GrubStomper29, so ig it would be his son GrubStomper30

gilded shell
#

per vertex lighting is so cool

#

maybe my next project should be a ps2 styled game

gilded shell
#

its all coming together now

fervent lantern
#

HOA Invasion Stomper

gilded shell
kind sparrow
#

Call it "untitled game project (2025)"

gilded shell
#

“2week box”

gilded shell
#

NSight buffer view matches the C++ side

#

and the struct is a multiple of 16b

gilded shell
#

The bug is fixed, I was only updating the cluster struct in the compute shader and not the other shaders that use it

#

I should really look into glsl header file equivelants

#

anyways the bug is fixed

#

now I have to figure out frustum culling, and demon has unfortunately inspired me to do it on my own

night shoal
#

"stb include"

gilded shell
#

I've been using string_cast for quite some time and am just now getting this error?

night shoal
#
target_compile_definitions(HowToScript
    PRIVATE GLM_FORCE_CXX2A
    PRIVATE GLM_FORCE_RADIANS
    PRIVATE GLM_FORCE_DEPTH_ZERO_TO_ONE
    PRIVATE GLM_FORCE_RIGHT_HANDED
    PRIVATE GLM_FORCE_SILENT_WARNINGS
    PRIVATE GLM_FORCE_SWIZZLE
    PRIVATE GLM_FORCE_XYZW_ONLY
    PRIVATE GLM_ENABLE_EXPERIMENTAL
)
``` 😛
gilded shell
#

I wonder why I'm able to map and write to buffers without GL_DYNAMIC_STORAGE_BIT

gilded shell
#

Slightly working frustum culling (viewFrustum is paused here)

#

It does have issues

west trail
gilded shell
#

I see

#

I wonder what in the world could be causing this bug

gilded shell
gilded shell
#

todo: test first cluster skip

west trail
gilded shell
#

im just testing for each meshlet for now

gilded shell
#

The batcher has no problem omitting meshlets, so its not an offset or indexing problem

#

it must be a calculation error

#

All the plane distances become positive when everything disappears

gilded shell
#

I still haven't found the issue

#

all my calculations align with logl

gilded shell
#

it only seems to happen to the top plane

#

SOS

gilded shell
gilded shell
#

there must be a better way

west trail
#

Abstract away like bindssbo to make it shorter

kind sparrow
#

Good work

night shoal
#

shame that bindless buffers is not vendor agnostic

kind sparrow
#

#general message

gilded shell
kind sparrow
gilded shell
#

i see

gilded shell
#

Alright its time for occlusion culling

gilded shell
#

lemme write out a little plan

#
FIRST BATCH PASS
Using the visibility bitmask, batch meshlets that were visible last frame
generate depth pyramid from these
SECOND BATCH PASS
if meshlet was visible last frame, update its visibility and return
otherwise, update visibility and batch if visible
#

bevy used a different method for knowing if a meshlet was visible last frame, because a bitmask "does not play well with LODs." I'm not doing LODs

spring kelp
junior sparrow
#

I just keep the list of visible stuff

gilded shell
#

but I imagine without LOD trees, I should be fine

spring kelp
#

Yeah, besides it not working with LODs, it used a decent amount of memory. It's not a ton though, 1 bit/meshlet is fine really.

gilded shell
#

Yeah

#

and I believe someone we know wrote a nice hiz generator?

#

I forget who

junior sparrow
#

lpotrick

gilded shell
#

richer or potrick maybe

#

yeah

#

are hiz tests only possible with AABBs?

#

i wouldn't mind using spheres, but iirc projecting spheres sucks

junior sparrow
#

You can make bounding spheres into AABB

#

I have both

gilded shell
spring kelp
gilded shell
#

i see

spring kelp
#
#

Just keep in mind for occlusion culling you want to convert from UV to pixel coordinates

gilded shell
#

I hate coordinate systems

#

so I imagine that bitmask buffer is gonna be like ceil(meshletCount / 8.0f)

junior sparrow
#

32 if you got for integer

#

idk if you use u8 in shaders

gilded shell
#

well I'm talking about the size in bytes

junior sparrow
#

👍

gilded shell
gilded shell
gilded shell
#

I seek advice, oh wise ones

#

version control

#

purpose of multiple repo branches?

#

consistency of pushes?

#

strategies?

#

feel free to info dump

kind sparrow
#

I'm shit at VCing assets

#

I don't have a good answer there

#

I make branches just to organize work into named segments, even if you're developing them in serial

west trail
kind sparrow
#

I push relatively infrequently (once I have a feature working, or at least compiling), maybe once a day or sometimes less often

#

Typically you want a commit to be a working version of the program, although that's a flexible standard

gilded shell
#

i push about once every other month

kind sparrow
#

Lmao

#

Don't do that

gilded shell
#

yeah

#

ig i should have a beta branch for those near-daily pushes?

kind sparrow
#

I always work on a branch

#

And then I just merge to master when that feature is done before making my next branch

#

The biggest benefit of VC is being unafraid to rip shit up and rewrite it

#

If you ever find yourself worrying that you might break something and have trouble fixing it you should commit

#

That's how I can just tear up 1000 loc and rewrite 3/4 of it without fear

gilded shell
#

that’s smart

#

i also want everything to compile on other peoples systems and need a good way to test this

kind sparrow
#

Buy a beater laptop on craigslist and put ubuntu on it

west trail
#

dual boot

gilded shell
#

im probably sticking with visual c++ for builds, so it must be windows

kind sparrow
#

Nah you want different HW

gilded shell
#

well…

#

I have a pi zero

kind sparrow
#

I was replying to lumberjack, if you're targeting windows only I wouldn't worry too much

#

But it would still be worthwhile to have a machine with a different GPU vendor

gilded shell
west trail
gilded shell
#

i might duel boot windows on a separate hard drive

#

even a crappy laptop is gonna be expensive if im just using it to test builds

#

i can probably crowdsource my testing

night shoal
#

i would suggest a dedicated separate hard drive yeah, be it hdd or ssd or nvme doesnt matter

#

and then you use the boot menu of your bios to select the drive to boot from

#

that way you keep both drives separated and neither windows nor lunix will install any shit on the other drive

kind sparrow
#

Many here have done so with great success

night shoal
#

that too 🙂

#

and im also willing to help out

kind sparrow
#

Same

gilded shell
#

that would be awesome

night shoal
#

if you make it cmake compliant we can figure out other platforms too as well

gilded shell
#

perhaps

#

I didnt know Defend Your Home from the HOA would have such a wide playerbase : )

kind sparrow
#

Ofc

junior sparrow
# gilded shell feel free to info dump

I push every change that I do. In middle of the change I do git stash. Also I am planning to have branch from which I will cherry pick commits to master.

night shoal
#

as long as you commit things you will be fine

#

keep them small and commit often if possible

#

that makes cherry picking or cleaning up even merge conflicts easier to deal with by a lot

spring kelp
# gilded shell I seek advice, oh wise ones

I use one branch per feature/thing I'm working on, forking off of whatever the latest bevy main commit is. I push either once at the end of my programming session when prototyping stuff, or once per set of changes for more incremental stuff where I have stuff I want to save before moving onto the next part of the change.

#

But no hard rules, I often branch off of my branches and make random commits as I feel like it

#

My only real advice is don't use a single branch to develop every change, especially if you're working with multiple people and not just yourself

gilded shell
#

biggest problem i forsee is finding people for facial scans

#

maybe i can get hi res ones online and modify them a bit for the game artstyle

night shoal
#

i also wouldnt mind a game in that hand drawn pencil style like that piece of art from the other day

gilded shell
#

but that is something to consider for future projects

#

Stomping Grubs Simulator (SGS) will be my magnum opus and thus I cannot begin work on it until I master my craft

gilded shell
#

I might write my own depth buffer downsampler

gilded shell
#

ill have to round it up to the nearest multiple of 32

gilded shell
#

im good

#

so my bitmask is an array of 32 bit uints

#
uint n = clusterId - i * 32; // get index within the 32 bit data
uint bits = 1 << n; // get bitmask for this cluster
if (!(visibilityBitmask[i] & bits)) // do bitwise AND against this cluster's bitmask 
{
    // cluster is not visible
}```
This is the code I have for testing the visibility
#

this is really the first code ive written alone for bitwise operations, so I am a little unsure if it works

junior sparrow
#

it should work I think

gilded shell
#

i also think

gilded shell
#

Failed a shoulder roll one too many times

#

I think ill buy a rubber saa replica to keep the weight up but withstand more impacts

night shoal
#

i was picturing you participating at those quick draw competitions with that old revolver thingy

gilded shell
night shoal
#

Donald McDualWield

gilded shell
#

Hes from the metal gear games

#

you should play them

night shoal
#

i tried mg1 once, for 10mins or so, i think mg is utterly boring

gilded shell
#

uhh

#

mg or mgs

night shoal
#

all of them

#

mgs

gilded shell
#

oh

#

quite lame of you deccer

night shoal
#

yeah, i am quite lame

gilded shell
#

you gotta have the patience to sneak around

night shoal
#

i did in The Thief 🙂 and Hitman, that was enough

gilded shell
#

mgs has great plot though

#

and awesome 90s action music

night shoal
#

yeah the music is neat

#

idk im weird

gilded shell
#

give it another shot

#

the first hour of any metal gear game is admittedly hard to choke down

night shoal
#

that jungle scene annoyed me

gilded shell
#

it sounds like you were playing the third one?

#

that one probably has the longest intro

#

start with mgs1

night shoal
#

nah

gilded shell
#

: (

night shoal
#

the top downyness and switching to weird camera angles is not mine

gilded shell
#

@night shoal maybe youll like Cave Story

#

free 2004 Indie game by Diasuke Amaya who also made the game engine, music creation software, and even a rudimentary scripting language for the cutscenes

gilded shell
#

The bitmask batching works

#

I can do cool stuff like clearing it to 01010101 to omit every other cluster

#

right now im focused on just getting culling working, but later down the line im probably going to have to do some sync work

#

or at the very least giving batches some of their own buffers so im not dispatching, clearing, dispatching, clearing, etc.

#

in other news its snowing really hard here but burger king is NOT closing so ill still be going to work tonight

#

guarauntee you we'll make less than 20 sales tonight

gilded shell
#

😬

#

sync error?

#

time to spam glFinish

#

that worked

junior sparrow
#

Vulkán when

gilded shell
#

2 years ago

gilded shell
#

hi-z time 😦

#

@spring kelp you seem to be online right now. Would it be correct to assume I need the full mip chain for occlusion culling?

spring kelp
#

I mean you don't have to, but there's no reason not to

#

Just make sure to clamp your calculated mip level to the actual range of mips your hiz texture has

gilded shell
#

also, what aproach do you use for the power of two problem?

spring kelp
#

so that -1 or 11 become 0 and 10

spring kelp
gilded shell
#

I took a quick glance at AMD's SPD and it only support's vk/dx12

#

are SPDs using newer API features or do they just skip GL because no one uses it anymore?

spring kelp
#

Uhh does GL have subgroup support?

gilded shell
#

Not sure

#

Now that I think about it, I have no idea how SPDs work

#

it may benefit me to create a working prototype with one pass per mip

#

But I'm scared that any ^2 solution will make sampling the mip chain super complex

gilded shell
#

My app is now properly synced. I'd like to take a moment to talk about how weird fences are on OpenGL

#

you can't reuse them, yet still are responsible for handling their deletion

#

glClientWaitSync has a timeout parameter detailing how long the client can wait before moving on

#

glWaitSync also has this parameter, but it must be set to GL_TIMEOUT_IGNORED

kind sparrow
#

Idk it kinda makes sense

#

The fence is just an event in the GPU timeline, it could be waited on at any time without being signaled so it can't be automatically deleted

#

The API needs to keep track of some pool of flags to check so having them be explicitly managed isn't too surprising

gilded shell
#

I suppose

gilded shell
#

A sailor’s worst enemy is himself when the siren sings

gilded shell
#

depth texture should probably be clamp to edge

gilded shell
#

idk why what is essentially mipmap generation is such a hard problem for me

gilded shell
#

heres a plan:

Create texture with appropriate storage for mip levels
Copy depth buffer to base mip level

For each mip level:
Bind appropriate mip level for writing
Dispatch compute to write (using imageStore) maximum depth values of last level to current level; handle edges and corner for NPOT last level
gilded shell
gilded shell
#

My first thought is to use a separate FBO output texture and copy its contents into each respective level, but that sounds very slow

#

or I could use imageStore I was not aware this function existed

gilded shell
#

I have read the word "depth" too much

gilded shell
#

The down sampler compiles and runs for a single mip level

#

I still need to test its functionality before going down the full mip chain

gilded shell
#

I wonder if its worth it to try and slam in multiple shader invocations per workgroup for something like this

gilded shell
#

only time will tell

gilded shell
#

hiZ gen is wrong

#

as you can see from this depth buffer visualization

#

imageStore is doing nothing

gilded shell
#

perhaps because I was using GL_DEPTH_COMPONENT32F as my image format? I wonder why that would stop it from working

gilded shell
#

Now it's working just fine

#

this hi Z is so hot

#

@junior sparrow

junior sparrow
#

now the culling code fun

gilded shell
#

most of it is in place

#

I just need to perform the actual AABB test

#

saving for later

gilded shell
#

Numbers 12:3 “Now Moses was a very humble man , more humble than anyone else on the face of the earth.”

#

This is really funny lol

kind sparrow
gilded shell
#

As does this

gilded shell
#

bc apparently vkguide has occlusion culling

gilded shell
#

There's no textureGatherLod() in GLSL 😞

gilded shell
#

anyways the occlusion culling is completely failing

#

it's my sphere projection that's failing frog_think

gilded shell
#

maybe my view space is -Z forward somehow?

#

but that doesnt make sense

gilded shell
#

or does it

#

as far as i can tell, viewspace is -Z forward and glm::perspective flips the Z coordinate

gilded shell
#

alright for my sanity I need to linearize my hzb

#

i think

#

im stuck in coordinate system hell

#

@junior sparrow a few questions: do you linearize your hzb?

#

do you have any tips for debugging occlusion culling?

junior sparrow
#

I dont linearize hzb or depth

#

I am using infinite reverse depth

#

and about debugging I can from gpu create AABB for debugging

junior sparrow
#

I can visualize the meshlets bounds which are not getting culled, etc..

gilded shell
#

i see

#

i think i just need to write my own hzb sampling code

#

im pretty my viewspace is -Z forward, +X right, +Y up

#

the hzb is in texel space with (0,0) being the bottom left

#

depth is non-linearized

#

my plan is: get the projected AABB bounds of the bounding sphere use it to figure out where I need to sample on the hzb get the nonlinearized min depth of the sphere compare that against the hzb depths

gilded shell
#

occlusion culling is ALMOST functioning!

gilded shell
#

i imagine the flickering issue is related to texelFetching the hzb without any bounds checks

#

that or my texel coord calculation sucks

gilded shell
#

The dough is rising

#

I am baking my masterpiece today

gilded shell
#
vec4 depths;
depths.x = texelFetch(hiZ, coords, level).x;
depths.y = texelFetchOffset(hiZ, coords, level, ivec2(1, 0)).x;
depths.z = texelFetchOffset(hiZ, coords, level, ivec2(1, 1)).x;
depths.w = texelFetchOffset(hiZ, coords, level, ivec2(0, 1)).x;
#

this is what I'm doing

#

i wonder if implementing bounds checks here could cause performance issues

#

ill worry about that later

#

bounds checking did resolve most issues

#

I wonder what the issue is this time

junior sparrow
#

I have some issues too

#

I am not happy about it

junior sparrow
#

I assume that hardware does some bound checks

gilded shell
#

not for texelFetch

#

I'm not using texture() because I don't think ogl has that min sampler extension and if it does I was too lazy to check

#

so here I just clamp it to the edge

junior sparrow
#

huh intersting

gilded shell
#

Do you add any sort of padding to your bounding geometry to resolve floating point errors?

#

its really bad when I fly under the map

junior sparrow
#

I do lpotrick trick where hiz is in image which is power of 2

#

which type of perspective matrix do you use?

#

normal one or some infinite reverse

gilded shell
#

normal

#

float sphereDepth = (1.0f / -(sphere.z + sphere.w) - 1.0f / zNear) / (1.0f / 10000.0f - 1.0f / zNear);

junior sparrow
#

I recommend you switching

gilded shell
#

why

junior sparrow
#

better precission

gilded shell
junior sparrow
#

I think so but I have my own

gilded shell
#

there's infinite

#

would negative near plane mess with my handedness?

night shoal
#

GLM_FORCE_DEPTH_ZERO_TO_ONE

#

and glm::infiniteXXX

#

or without the define and glm::infiniteXXX_ZO

gilded shell
#

todo: remove far plane from frustum culling

gilded shell
#

vec4 depths;
depths.x = sampleHiZ(coords, level);
depths.y = sampleHiZ(coords + ivec2(1, 0), level);
depths.z = sampleHiZ(coords + ivec2(1, 1), level);
depths.w = sampleHiZ(coords + ivec2(0, 1), level);
float depth = min(min(depths.x, depths.y), min(depths.z, depths.w));```
#

I wonder if my texel reading is bad again

#

i just take the bottom left of the sphere's projected AABB, and read a square of texels there

gilded shell
#

@junior sparrow it's fully functional

#
vec2 coords = ivec2(((aabb.xy + aabb.zw) * 0.5f) * vec2(textureSize(hiZ, level)));

vec4 depths;
depths.x = sampleHiZ(ivec2(coords), level);
depths.y = sampleHiZ(ivec2(coords + vec2(1.0f, 0.0f)), level);
depths.z = sampleHiZ(ivec2(coords + vec2(1.0f, 1.0f)), level);
depths.w = sampleHiZ(ivec2(coords + vec2(0.0f, 1.0f)), level);```
I changed my coord calc to this, I believe it's similar to what vkguide does
#

I also ceil my mip level calc

#

bistro now mostly renders at 2-3ms but peaks at 5 with busier frames

#

I think I can shave this down given the unoptimized state of my code

#

all of my compute shaders have a 1x1x1 local size

junior sparrow
#

💀

junior sparrow
gilded shell
#

I wonder why I need to ceil the level calc

#

regardless, now that it works i must never lay a finger on it again

junior sparrow
#

That's my understanding

gilded shell
#

probably

gilded shell
gilded shell
#

Silly me! I'm running perf tests in debug!

junior sparrow
#

that shouldnt change that much

gilded shell
junior sparrow
#

what gpu are you running?

junior sparrow
#

I dont see anything wrong

gilded shell
gilded shell
#

simondev if you can hear this please save us

gilded shell
#

@kind sparrow you were right; i shouldve tried occlusion culling on cpu first

#

debugging the compute shader is 30% guesswork

gilded shell
#

and as you might’ve seen, the bugs are driving me insane

junior sparrow
#

you dont have hot reloading of shaders?

gilded shell
#

i do but its still not as good as break points and reading data memory

junior sparrow
#

in vulkan land we have printf

#

I have debug draw from gpu as well

kind sparrow
#

I am trying to figure out the ideal methodology

#

I've been stalling on my foliage stuff which is similar all month

gilded shell
#

yeah

#

i feel as if im so close

#

i just need a solid hi z sampling method

#

i highly doubt this is floating point error and im 99% sure my sphere projection and hzb gen is sound

#

i just realized i call it hiZ in my code and not hzb lol

kind sparrow
#

The reason mine is so impossible is because the intermediates are all stochastic

#

Every frame the data is a different order in the buffers

gilded shell
#

yikes

#

have you read the bevy blog?

kind sparrow
#

No

#

What about it

gilded shell
kind sparrow
#

It's not culling but it's also a complex compute algorithm

#

It's like a 5-stage pipeline full of atomic buffer filling so there are a lot of potential points of failure

junior sparrow
gilded shell
#

good luck lol

kind sparrow
#

If I come up with any good methodology for debugging I'll let you know

#

Mine probably requires a different approach to yours though

#

Isn't yours just basically building a mip chain but with maximal instead of mean values

#

Mine struggle is looking for off-by-one errors in hundreds of megabytes worth of partially filled allocations

gilded shell
#

what im struggling with is actually testing against this

kind sparrow
#

Ah

gilded shell
#

my cs teacher just dropped the biggest project on us with one day to complete it

#

these projects usually take 3-4 days to complete

junior sparrow
#

what is it? bleakekw

gilded shell
#

some cybersecurity forensic stuff

gilded shell
#

worst part is no one else has uploaded a guide online 😭 (aside from paid sites)

#

and this project counts as the final, being worth 20% of the grade

west trail
#

What's it about?

gilded shell
#

nvm i think shes canceling this

west trail
#

Save it

#

She will probably give it to you later with minor changes, you will have more time to prepare

gilded shell
#

nah the semester practically ends today

gilded shell
#

i wonder why its this specific meshlet having trouble with the culling

gilded shell
#

and this one

gilded shell
#

okay

#

@junior sparrow

#

i THINK its fixed

#

but the fix makes absolutely no sense to me

#

I just +1 my mip level calc

#

int level = int(ceil(log2(max(width, height)))) + 1;

gilded shell
#

ig it doesnt matter if it works 100%; as long as it does a good amount of culling and has no visible artifacts then its good enough for this project

#

once i get past optimizing the unoptimized, I will finally get to do what ive been meaning to do for a few years at this point: physics based lighting

#

and shadows and gi and hdr and such and so forth

#

cascade shadows + some brdf + indirect light maps + retinal based post = grubstomper photorealism

#

we’ll make it

gilded shell
#

Interesting observation

#

local size (64, 1, 1) occluder batching compute shader is about 2-3 times faster than (4, 4, 4)

#

and there seems to be little gain using (64, 1, 1) compared to (1, 1, 1)

#

this might be related to branching

#

depth downsampling showed significant improvements when local size was increased, and its branching is uniform across all invocations

#

it could also be all the atomic writes

gilded shell
#

i believe this screenshot is from rednote, an app that i do not use

gilded shell
#

gotta save this here too

gilded shell
night shoal
#

it looks fresher indeed

gilded shell
#

the old lambertian diffuse I used stretched the dot product over the sphere and NOT the hemisphere

#

the idea was for more lighting depth, but it's not physically accurate so it had to go

gilded shell
#

I think for shadow mapping I'll need that "multiview" thing mentioned in the nanite talk

#

rather than batch for shadows then batch for the camera, I should batch for both simultaneously

#

This doesn't seem trivial for shadow cascades since I'll have like 5 different views to batch for

#

perhaps i perform the batching without culling first and figure it out later

gilded shell
#

todo: commit changes

gilded shell
#

developments probably gonna slow down since i made a minecraft world

gilded shell
#

todo: zorp my flongle

plain mantle
#

Any progress on the guitar learning?

gilded shell
#

havent picked it up yet

#

i do have free time, but it must be budgeted and that’s a little low on the list

plain mantle
#

Just pick it up and learn 3 chords. You can do alot with that

gilded shell
#

a lot of garbage

#

i have my eyes set on the songs i want to learn

#

i just need to get around to it

#

which is the hardest part froge_sad

plain mantle
gilded shell
#

so ive heard

#

it would be kinda like what i did with drums

#

i got a lot better by just picking a really hard song (#41 from under the table and dreaming) and learning that on drums

#

granted, it took about 2 years to do

plain mantle
#

I mean you might wanna learn some basics before jumping right in to the hard shit but it's up to you

gilded shell
#

probably

plain mantle
#

Did you ever learn any Rush songs when you were doing drums

gilded shell
#

nah i dont like rush

plain mantle
#

That's my favorite band KEKW

#

Also they're from my city

gilded shell
#

filthy closed hand drumming

#

idk if its unhealthy, but im really only interested in the drumming of Carter Beauford

plain mantle
#

Probably unhealthy to try to mimic one person only yeah

#

Up to you though

gilded shell
#

i just havent found any other drummer i like

#

somethings just different about him

plain mantle
#

Ever listen to phish?

gilded shell
#

i dont think so

#

i heard Steve Lillywhite worked with them

plain mantle
gilded shell
#

i also need to give the police a listen

#

but part of the reason i like dmb so much is because of how much they solo

#

some of my favorite songs are them going nuts for 15-30 minutes

plain mantle
gilded shell
plain mantle
#

Provided to YouTube by Rhino

You Enjoy Myself (Live at Madison Square Garden, New Year's Eve 1995) · Phish

Live at Madison Square Garden New Year's Eve 1995

℗ 2005 Phish Associates

Drums: Jon Fishman
Producer: Jon Fishman
Backing Vocals: Jon Fishman
Bass Guitar: Mike Gordon
Producer: Mike Gordon
Backing Vocals: Mike Gordon
Keyboards: Page...

▶ Play video
#

25 minutes of jam

gilded shell
#

the greatest bangers are always dropped in msg

#

take a listen to this

plain mantle
#

Will do

gilded shell
#

i also really love the instrumentation of dmb

#

guitar, bass, violin, sax, and piano

plain mantle
#

Pretty good yeah

gilded shell
#

i also need to look at the flecktones

plain mantle
#

Bela Fleck?

gilded shell
#

yeah

#
  • coffin and wooten
#

and some other guys

#

wooten is phenomenal

plain mantle
#

Wooten is goated yeah

echo token
#

if you ever get tired of those you should learn shedding fundamentals and just play fast riffs

#

that's about all I know how to do on a guitar

kind sparrow
#

For the first 3 years of my guitar career I basically just played tremolo picking power cords on black/death metal stuff

plain mantle
#

Yeah theres many different approaches you can take

kind sparrow
#

That was the easy path for me since I played the drums so I already had the rhythm and muscle control for trem picking but didn't know shit about chords

gilded shell
#

except for the chanting at the end

gilded shell
#

man i’m lazy

#

i’m starting to notice a pattern

#

if i’m in the middle of implementing a feature, i won’t procrastinate

#

but if i haven’t started any feature, i will procrastinate

gilded shell
#

i think i’ll just spawn one thread per cluster per view

#

then its just simple csm from there

#

I thought i would finally be able to write some lighting code but it’s back to this cluster batching shader 😔

plain mantle
spring kelp
#

I haven't figured out how to do multiview for the hardware raster pass, yet

gilded shell
#

meshlet instances times number of views

#

number of views does include each frustum

#

if thats what youre asking

gilded shell
gilded shell
#

sounds like hell!

gilded shell
#

is there a reason this is so vague???

kind sparrow
#

With synchronous debug output it'll trap right when the bad call happens

#

Once you know what API call triggered the error, you can look it up in the spec and it'll tell you what that error means for that call

#

Probably mixed up the enums passed for texture creation

gilded shell
#

ah I can't use GL_DEPTH_COMPONENT for my shadow map?

#

but GL_DEPTH_COMPONENT32F works fine

night shoal
#
auto OnOpenGLDebugMessage(
    [[maybe_unused]] uint32_t source,
    uint32_t type,
    [[maybe_unused]] uint32_t id,
    [[maybe_unused]] uint32_t severity,
    [[maybe_unused]] int32_t length,
    const char* message,
    [[maybe_unused]] const void* userParam) -> void {

    if (type == GL_DEBUG_TYPE_ERROR) {
        spdlog::error(message); // or std::print or std::cout or whatever
        debug_break(); // or just put a bp in the line above
    }
}

glDebugMessageCallback(OnOpenGLDebugMessage, nullptr);
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
gilded shell
#

oh 💀

gilded shell
night shoal
#

🙂

gilded shell
#

ill see if i can work this into a compiling state so you all can try this technological masterpiece

gilded shell
#

windows only btw

gilded shell
#

do you all keep a “common” includes header for, of course, common includes you need?

#

also for when you #define something you’ll need everywhere

kind sparrow
#

Not really

#

But you could

#

Nothing intrinsically wrong with it

#

Usually you don't need anything absolutely everywhere though except for defines, which you can handle in your cmake script

gilded shell
#

assuming i use cmake lol

#

i definitely should in my next project

plain mantle
#

What are you using now?

gilded shell
#

raw visual studio

#

hence the windows exclusivity

plain mantle
#

Yeah me, bjorn & anicator are raw dogging msbuild too KEKW

#

You can cross compile with msbuild for some platforms though

#

I remember I made an android app using msbuild once

gilded shell
#

i see

#

there’s something cleaner about cmake though

plain mantle
#

Oh yeah it is

gilded shell
#

my code feels more portable

plain mantle
#

I don't like having to regenerate the solution all the time though

gilded shell
#

huh?

plain mantle
#

I wonder if there's some way to create cmake from a visual studio project though

gilded shell
#

if it does exist

plain mantle
#

Yeah likely

gilded shell
#

i still have to figure out working directories

#

the working directory people use when they launch my executable will affect the paths to assets

#

ive wondered how other applications handle that

plain mantle
#

They just start in their install dir

gilded shell
#

the application itself sets it?

plain mantle
#

Usually you launch an app from a shortcut or something

#

Unless you intend people to launch your thing from the command line

gilded shell
#

true

#

hey where’s the morgan freeman saying “true” emoji

kind sparrow
#

You can put your global defines in your VS just the same

#

I just used cmake as an example

gilded shell
#

I need to consider manual backface culling

#

i completely forgot about individual triangle culling

#

@spring kelp do you do this in your batching?

#

i imagine I would need to perform the culling before the atomicadd and index buffer writes, which sounds nasty

junior sparrow
#

pretty sure triangle culling is done in mesh shaders

spring kelp
gilded shell
#

Alright. I’m not doing that.

gilded shell
#

or do they just kinda suck for the meshlet cull batching

junior sparrow
#

they might suck for culling but you can do culling in compute shader and then use mesh shaders

gilded shell
#

visual studio randomly decides to start building "OpenGL-Sandbox/Debug/x64" instead of "Debug/x64"? huh?

#

quite some time ago apparently

#

thats not something i understand!

plain mantle
#

You can change all those paths to whatever you want

#

its all in the project settings

west trail
#

move to cmake for God's sake

gilded shell
night shoal
#

perhaps you switched to "Release"

#

and forgot to config "Release" at the start, its output is still default

gilded shell
#

nah i was on debug when it happened

night shoal
#

ah

gilded shell
#

its all tlog stuff

night shoal
#

yeah vs shit

gilded shell
#

it doesnt make sense to have OpenGL-Sandbox/OpenGL-Sandbox in my opinion

#

i must put a stop to this

night shoal
#

close vs, delete it, open vs again see if its still there

gilded shell
#

yeah it is

#

its probably some setting i cant find

#

actually theres a ton of objs too

#

definitely some build output residue

#

yep im smart

#

alright we MIGHT be golden

night shoal
#

back when i used vs exclusively with cpopo i set it out to Build\Bin and imtermediateisms to Build\Temp for both configs from le start

gilded shell
#

perchance

night shoal
#

$(SolutionDir)Build/$(ProjectDir)Bin/
$(SolutionDir)Build/$(ProjectDir)Temp/

gilded shell
#

yeah

night shoal
#

platform is 64bit at all times anyway and if you want you can add $(Configuration) in there too for "Debug" and "Release" in the path/name

gilded shell
#

all my third parties seem to be inside the project dir, so I don't need to deal with external linkage junk

#

I think you guys can finally play this

night shoal
#

SecretPasswordStealer.exe

gilded shell
#

deccer, are you on binbows

night shoal
#

not in this moment

gilded shell
#

oh okay

#

well if any windows user would like to give it a quick go, have at it

#

github desktop is elite

night shoal
#

it used to be quite dogshit

#

and i never tried it again, fork, sourcetree even, and builtin git clients in all jetbrains tools are superior already next to git cli

plain mantle
#

Not that I do, but you technically can

night shoal
#

then you could reintroduce $(Platform) 🙂

#

or you keep using that from the start

#

what always pissed me off in vs' configuration editor, i removed Win32 from the start, but as soon as you added a new project it was reintroduced back into the solution file, because the new project had it by default

#

the only true solution (when using vs only) are props files, but they are messy for c++ imho

#

cmake makes this much less painfullier

#

lol i hated cmake back then so much because it would always destroy my neat folder/solution structure for projects XD

spring kelp
#

Languages not having a standardized build tool is insane to me

plain mantle
#

C++ & C are languages I think it makes sense for

#

There are 3 different major C++ compilers (which is a good thing)

gilded shell
#

yeah

#

competition

plain mantle
#

I'm cloning your thing btw

#

have you considered using submodules for your third party libs?

#
1>(compiling source file 'src/main.cpp')```
#

first issue

#

you should make this relative to $(SolutionDir)

#

I changed to

gilded shell
#

dang!

#

I knew I probably left an absolute path somewhere

plain mantle
#

this is in GLM

gilded shell
#

I have no explanation for that

plain mantle
#

mPos += getRotationMatrix() * glm::vec4{ displacement, 0.0f };

#

its this

#

pos is a vec3

gilded shell
#

thats weird that it compiles fine for me

plain mantle
#

mPos += glm::vec3(getRotationMatrix() * glm::vec4{ displacement, 0.0f });

#

this fixes that

gilded shell
#

it might have something to do with visual studio C++ extensions or something

plain mantle
#

I got the thing compiled, now I'm getting a crash on launch

#

looks like in asset loading

night shoal
#

no aasets are checked in in case there are any

plain mantle
#

Maybe I can make a PR with the things I fixed

#

this is probably another path issue

gilded shell
#

let me see

gilded shell
plain mantle
#

Yeah the path is wrong

gilded shell
#

its because of a gitignore in the assets folder

#

its hardcoded to load bistro.glb and cubes.glb lol

plain mantle
#

The path also looks wrong though

#

it looks two folders up from the debugging dir

#

Do I need to download those myself?

gilded shell
#

probably

gilded shell
#

so to get back to the solution dir, I use ../../

plain mantle
#

yeah but the working dir is set to $(ProjectDir)

gilded shell
#

no?

plain mantle
#

did you maybe forget to commit that?

gilded shell
#

it should be commmitted

gilded shell
night shoal
#

those dont sit in the project file

#

but are stored in .vs\xxx.user something iirc

gilded shell
#

alright, I just fixed those and the glm type thing

plain mantle
#

where do I get the glb files?

gilded shell
#

maybe im remembering wrong

gilded shell
#

to the repo

plain mantle
#

As long as you include the license info I got no problem with that

gilded shell
#

yup bistro.glb is too big

#

as I thought

plain mantle
#

I think I might have it somewhere

gilded shell
#

I believe it's SOMEWHERE out there

#

i dont remember where I got it though

plain mantle
#

Damn the one I have is FBX

gilded shell
#

I just pushed the bug fixes, all should work in theory

#

you just need that glb

night shoal
#

yeah because it usually contains user related settings for your environment, jake or me might have different "preferences" but working dir should be part of the ordinary settings if you ask me

#

but again, prop sheets could solve that too

plain mantle
#

I never realized it wasn't

gilded shell
#

you might be able to just drop any glb file in called bistro.glb lol

plain mantle
#

Ok lets see how it likes sponza

gilded shell
#

i havent tested sponza in a minute

gilded shell
#

@plain mantle texture compression is disabled iirc, hope you have enough vram

plain mantle
#

I have 8gb

gilded shell
#

that should work

#

hopefully

plain mantle
#

You should enable compression lol

#

that would really improve performance

gilded shell
#

yeah but it like doubles loading times

#

and those are already unbearable

plain mantle
#

You can cache that shit

gilded shell
#

probably

plain mantle
#

Driver texture compression is pretty bad anyways

#

I use bc7enc and save the result on the first import

#

the subsequent loads are faster than without compression

gilded shell
#

yeah

#

idk if fastgltf supports glb writing though

plain mantle
#

No I mean the app caches the textures

#

in its own folder

gilded shell
#

oh okay

#

is it running?

plain mantle
#

one sec

#

How do I rotate the camera?

gilded shell
#

arrow keys

#

I don't like those errors

plain mantle
#

Those are peformance warnings I think

gilded shell
#

I see those

plain mantle
#

Oh there is an error yeah

#

missing wall lmao

gilded shell
#

What could it be

plain mantle
#

API, ERROR, HIGH, 1285: GL_OUT_OF_MEMORY error generated. Failed to allocate memory for buffer object.

gilded shell
#

welp that does it

#

sponza probably has too much stuff

plain mantle
#

This is crytek sponza though

#

GPU memory still got lots left

gilded shell
#

interesting

#

im no longer on my pc btw

plain mantle
#

Maybe you need to check the max buffer sizes

gilded shell
#

yeah not sure what i did there

#

are you able to use breakpoints?

#

synchronous debug should be on

#

I also really dont like the 6ms render time

plain mantle
#

I'm in debug mode so I wouldn't worry too much a bout the perf

#

but yeah I can set a breakpoint in the error callback

#

what file is that in ?

gilded shell
#

main probably

plain mantle
#

Demongod would be proud

gilded shell
#

lol

#

@kind sparrow arent you

kind sparrow
gilded shell
#

model loading stuff is either gonna be in model.cpp or scene.cpp

kind sparrow
#

What's going on

plain mantle
#

He put everything in main.cpp

kind sparrow
#

Ah

plain mantle
#

anti-bikeshed

gilded shell
#

thats an overexageration

#

my debug callback is in main

plain mantle
#

Raw opengl calls in main.cpp

kind sparrow
#

Tbh I don't really do that because my projects explode in size at the start since I am so productive with my anti-bikeshedding that it doesn't live in main for long

gilded shell
#

running though? probably not

plain mantle
#

Its running for me rn

gilded shell
#

missing walls though

plain mantle
gilded shell
#

uh oh

plain mantle
#

wait I don't know if thats an error

#

but we hit the callback

#

you formatted your switch weirdly

#

so the breakpoint was in the wrong place

gilded shell
plain mantle
#

Ok I am getting an error there GL_INVALID_VALUE error generated. <size> must be positive.

plain mantle
#

mBlendIndexCount == 0

gilded shell
#

oh

#

word

#

not really sure how to fix that lol

plain mantle
#

maybe it was my fake bistro

gilded shell
#

nah

plain mantle
gilded shell
#

it just always expects some alpha blended materials

#

i did push cubes.glb to the repo, those are blended. Try those

plain mantle
#

sponza has the plants

gilded shell
plain mantle
#

I had the deccer cubes in there

gilded shell
#

is that the only error?

gilded shell
plain mantle
#

I just put in your cube file now I'm getting a crash

gilded shell
#

oh wow

#

any message

plain mantle
#

crash in glMapNamedBuffer

gilded shell
#

might be a sync error

plain mantle
#

main.cpp line 475

#

I got an image for a bit before it crashed

gilded shell
plain mantle
#

Many frames

#

it appears to happen randomly

gilded shell
#

definitely sync

plain mantle
#

No errors any more though

plain mantle
#

It was probably just the blend ibo thing

#

also sponza walls intact

gilded shell
#

everything’s working?

plain mantle
#

It crashed before I could screenshot though

gilded shell
#

bruh

plain mantle
#

Ok got one

gilded shell
#

i like that perf quite a bit more

#

but the random crashes are weird

plain mantle
#

yeah not erroring proabably helps

gilded shell
#

im still not clear

#

theres no more errors, right?

plain mantle
#

empty console

gilded shell
#

epic

#

and crash free?

plain mantle
#

lmao just crashed again

#

sounds like sync

gilded shell
#

has to be

#

not sure where

#

what card are you using?

plain mantle
#

2060 Super

gilded shell
#

i see

#

your gpu probably chugs faster than mine, explaining why i dont have any

plain mantle
#

What do you have?

gilded shell
#

3050

plain mantle
#

I didn't even know there was a 3050

#

mobile?

gilded shell
#

nah its desktop

gilded shell
# plain mantle

anyways, both the occluder_batch and cluster_batch perform an atomicAdd to that buffer

#

just toss a glfinish in front ig

plain mantle
#

before glMapNamedBuffer?

gilded shell
#

probably

plain mantle
#

Nope

#

still doing it

#

Maybe you should test with my sponza

#

I gotta get back to my project

gilded shell
#

ill be back

#

yeah thanks for your help

plain mantle
#

No worries

gilded shell
plain mantle
#

I shared it before

#

#1234659747291201587 message

#

its the crytek one, I just converted it to glb

gilded shell
#

oh i didnt see that sorry

gilded shell
#

so it must be sync

#

or ub that crashes your gpu but not mine

#

I really wish the bug would happen for me so I could debug it

gilded shell
plain mantle
#

Do you have another gpu you can test on? Possibly there's an iGPU in your system?

#

If there's UB it can pop up anywhere

gilded shell
#

nah

#

something makes me think the actual error is happening before that loc

#

i dont see anything on that line that would throw

#

could this be it?

#

making a draw call, then copying that draw's depth buffer

#

@plain mantle if you get time, could you try adding this line to main

plain mantle
#

This did not fix it

gilded shell
#

darn

kind sparrow
#

If you run RD with "verify buffer access" enabled what happens

gilded shell
#

maybe i can somehow disable them

#

or if nsight has an equivalent

#

this project is only possible because of n sight

kind sparrow
#

The reason I suggested that option isn't because of the bounds checking but rather because it clears all your buffers to 0xDDDDDDDD

#

So if you access bad data it'll break your program

#

But you can just manually clear your buffers to that value

gilded shell
#

i dont ever remember opengl throwing exceptions though

kind sparrow
#

It doesn't

gilded shell
#

right

#

glMapBuffers doing that is weird

kind sparrow
#

With renderdoc you can attach a debugger and it'll trap on an OOB host access

#

And then with the debug clear value it'll just cause crazy UB that gives you some signal as to whether things are working

gilded shell
#

whats oob mean?

plain mantle
#

Out of bounds

gilded shell
#

i see

#

which could cause the throw?

gilded shell
#

also are your drivers up to date lol

#

@plain mantle

plain mantle
gilded shell
#

dont quote me on that

night shoal
#

there are a few newer ones, yeah

#

but the latest 572.. doesnt seem to be that stable yet

gilded shell
#

either way I doubt GrubStomper29’s OpenGL Sandbox found an rtx driver bug

kind sparrow
#

Probably not

gilded shell
kind sparrow
#

I have seen it

#

I don't like it though he takes my comment out of context

gilded shell
#

fair enough

#

still i dont see it as insulting