u/NoEmergency1252

AI Sidebar in Firefox

Why is it not integrated with the tab?
What is the purpose is it doesn't do that?

I like to read on my PC. I recently switched from Win11 to Linux Mint. I like how light it is and everything feels under control.
I don't really want chrome, but there does not seem to be a good extension for AI Sidebars.I like to keep one while reading books and more technical programming articles.
Is there no alternative?

reddit.com
u/NoEmergency1252 — 3 days ago
▲ 29 r/C_Programming+1 crossposts

Why don't we manually map our own memory buffers more often? (DOD vs. Standard Segments)

I am reading data oriented design (book). The author mentions branches/vtables and their impact on cache. It seems like the "natural" memory segments we are taught (Stack, Heap, Static/Globals) actually create a lot of "hopping" around in RAM, which kills cache locality and messes with branch prediction. What if I just allocate one massive buffer at the start of the program and map it myself? For

EXAMPLE:

Start with defining a pointer Buffer. Then mark segment at indices. 0-10 is the list of constants, like window dimensions, scale etc 11-80 Player data 81-400 Monsters Etc This is a simple example; i will never store monsters as objects but SoA after normalising the data, the offset are similarly merely exemplary

This way, the data which is processed together works is kept together, very cache friendly and eliminates pointers.I bypass the "Spiderweb" of pointers and Vtables that usually live in different segments. No jumping around, so if you are looping through, say a group of entities 'Monster', the cache loads the next 64kb worth of data after the first entity. Given these kinds of entities are often transformed together, isn't it better?

Questions

1.Why isn't this the standard way of doing memory management? It seems much more hardware-friendly.

I have an intrinsic feeling it's somehow related to 'safety'

2.For those of you in AAA or high-performance fields: is this basically how your engines work under the hood? Am I just reinventing the "Arena Allocator" or "Memory Mapping" concept? I have seen this kind of Memory Schema being used in old consoles, nes, gameboy etc( I know a little since it was of some interest to me). They also have this sort of memory buffer, which forms homogenous partitions. 3.Does anyone uses this? What has been your experience?

Note:

I am mostly focused on rendering, physics simulation and other processes which deal with a huge amount of data. Thus, i believe that the choice of this layout might be heavily based on use case. I can see that this paradigm may not be as useful for,say, a GUI implementation among programs of a similar nature ( though I don't see why one can't use it)

reddit.com
u/NoEmergency1252 — 6 days ago

Memory buffers and alternative to Muted locks for multithreading

Let's say to product 500vertices of a triangle

Is it not better to store them in a buffer, then divide it between the threads.

Say 0—250 is read by thread 1

And 251—499 is read by thread 2

If this can be done, what's is the need for mutex, which are slower than this since thread 2 would have to wait for thread 1 before completing the task?

reddit.com
u/NoEmergency1252 — 7 days ago

AoS, Memory Buffer and cache friendliness

Is it true that creating an array of objects doens't guarantee that those objects are next to each other in memory?

I have found that one can allocate a buffer, say for a vec3 of xyz cooridnates.

The advantage is that if you want to only update the y co-ordinates, you can simply loop over the items at a fixed offset, and the cpu will recognise that it's a fixed stream of data with no breaks and this will pre-fetch the entirity of y cooridnates into the cache

This will look like yyyyyyyyyy

But in the case of objects, it will be xyzxyzxyzxyz

X and z waste the catche space since you don't need them, that's a 66.66% waste.

reddit.com
u/NoEmergency1252 — 7 days ago

AoS, Memory Buffer and cache friendliness

Is it true that creating an array of objects doens't guarantee that those objects are next to each other in memory?

I have found that one can allocate a buffer, say for a vec3 of xyz cooridnates.

The advantage is that if you want to only update the y co-ordinates, you can simply loop over the items at a fixed offset, and the cpu will recognise that it's a fixed stream of data with no breaks and this will pre-fetch the entirity of y cooridnates into the cache

This will look like yyyyyyyyyy

But in the case of objects, it will be xyzxyzxyzxyz

X and z waste the catche space since you don't need them, that's a 66.66% waste.

reddit.com
u/NoEmergency1252 — 7 days ago
▲ 2 r/raytracing+1 crossposts

Spacial Bitset Grid and Raytracing

I recently started reading the book 'Data Oriented Design' by Mr. Richard Fabian.

I nowadays maintain a chrome tab for resolving my queries with Gemini.

In the book, there is discussion about the fact that many programmers store theirs tiles as objects with vectors in world space and how cache un-friendly this is, and storing them as decoupled objects, ids in array is way better.

This reminded me of the visibility problem which is one of the reasons why raytracing is slow slow.

I tried asking Gemini, my reading assistant about it, and it said that this is perfect use case for ' Spacial Bitset Grid (SBG)'

>The below is the received response on what SGB are. I have only heard of BVH, how is it like to use SBG?What are the merits and cons? What has been your experience with them?

**A spatial bitset grid is a 3D acceleration structure that maps physical space into a flat array of bits. You divide your world into a uniform grid of cubes, or voxels. Each voxel is represented by a single bit in memory: a 1 means the voxel contains part of an object, while a 0 means it is empty. To check any point in space, you use a mathematical formula to convert its X, Y, and Z coordinates into a specificindex in the bit array.

In your raytracer, this allows the ray to march through the world using fast bitwise checks. Instead of calculating complex triangle intersections for every pixel, the ray calculates which voxel it is in and checks the bitset. If it hits a 0, it moves to the next voxel using simple integer math. If it hits a 1, it only then retrieves the list of triangles assigned to that specific voxel to perform a full intersection test. This effectively acts as a high-speed filter that eliminates the need to process empty space.**

reddit.com
u/NoEmergency1252 — 7 days ago

3d Vectors , Matrices and Transformation

Hello, I had a query while reviewing my understanding of some concepts.

If all points on the Cartesian Plane are just vectors originating from the origin and vice versa. Then for vectors which seem to originate not from the origin(the origin does not lie on the line) due to rotation, have they actually been transformed by matrix multiplication?

reddit.com
u/NoEmergency1252 — 8 days ago

Low resolution ray tracing

Hello, I am a former hobbyist game dev.

Due to unforeseen circumstances, I had to stop programming and have decided to start again.

The forthcoming query is merely out of curiosity, my understanding of graphics programming is as good as non-existent.

I have seen that ray tracing is computationally intensive. This is true for rasterisation as well, thus GPUs are used on account of their ability to run instructions in parallel.

I found this demo by Mr. Binji.

https://binji.github.io/raw-wasm/raytrace/

I am planning to create an FPS LAN multiplayer on Wifi in the style of the demo in the link (Pixelated outlines, may be low poly but soft bodies and sphere too,) I am hoping for low resolution, something around 640x480 or 320x240 or even less.

I am curious about the viability of ray tracing at these resolutions. More so when software rendered.

Thanks!

reddit.com
u/NoEmergency1252 — 11 days ago

Low resolution real-time ray tracing

Hello, I am a former hobbyist game dev.

Due to unforeseen circumstances, I had to stop programming and have decided to start again.

The forthcoming query is merely out of curiosity, my understanding of graphics programming is as good as non-existent.

I have seen that ray tracing is computationally intensive. This is true for rasterisation as well, thus GPUs are used on account of their ability to run instructions in parallel.

I found this demo by Mr. Binji.

https://binji.github.io/raw-wasm/raytrace/

I am planning to create an FPS LAN multiplayer on Wifi in the style of the image attached in the post and the demo in the link (Pixelated outlines, may be low poly but soft bodies and sphere too,) I am hoping for low resolution, something around 640x480 or 320x240 or even less.

I am curious about the viability of ray tracing at these resolutions. More so when software rendered.

Thanks!

Update 1:

I have learned linear algebra these past few days. I am now able to understand all the concepts in Mr. Binji's code. I am also able to keep up with 'raytracing in a weekend'.

I conclusion, i have found that graphics programming becomes much simpler, atleast conceptually,once you understand all the mathematical transformation which are undergoing to obtain the final image. Partly because the entire process becomes incredibly compact.

I meant, for raytracing, the process is just his simple:

1.Take a ray from camera through pixel on screen to the world.

Problem: pixel is screen space,

Sol:transform it to camera's relative space.

How first normalise the coordinates

x/w,y/h

Then shift the origin to the center

x/w-0.5,y/h-0.5( since x and y are now in 0 to 1 range, 0.5 is exactly half)

But!

The y axis is inverted

So we mul by -1

X'= x/w-0.5,Y'= 0.5-y/h

Now just solve intersection of C+t(X',Y') with the scene geometry, get the point of intersection, take dot product of normal and ray from point to light source, this gives a scalar value, 'brightness'

Take another ray from this point to light source, if it is intersected, point is in shadow, so don't light or up.

Then from this point shoot a ray again, reflection of the primary ray and repeats to the no. Of bounces you need while reducing the colour contribution each time

----------------------------------------------------------------------------------------

-- do after you have done step 1 above

ray=vec3(0,0,0)

scale=1.0

--calc hit, light & shadow, shoot ray n times

for i in 3:

hitpoint=hit(ray,objects)

if not hitpoint:

color=bg*scale,break¹

light

shadow

ray=reflect(ray,normal)

scale*=0.2

----------------------------------------------------------------------------------------

u/NoEmergency1252 — 11 days ago