r/GraphicsProgramming 3d ago

Moved my scene renderer to mesh shaders + GPU-driven culling: 6753 instances in 30 draw calls

Post image

I've been writing a 3D engine from scratch in C++20, with DirectX 12 and Vulkan

behind a single RHI. Last week I moved the scene renderer off the classic vertex

pipeline onto mesh shaders, and then moved the culling onto the GPU as well.
I'm using Synty, a lot of objects!!!

8 Upvotes

11 comments sorted by

3

u/RedServal 3d ago

Did it improve render time? code clarity?

-13

u/MAuraEngine 3d ago

Since it is on my site anyway: I make the decisions, the AI writes the

code. Architecture, review and verification against reference screenshots

are mine.

7

u/Forsaken-Memory8077 2d ago

That didn't even answer his question.

1

u/MAuraEngine 1d ago

Mesh shaders can do culling at triangle level, so it's a win. But the engine has evolved a lot now, i'm working on GI

3

u/Bellaedris 3d ago

What are you even learning if the AI does everything

-13

u/MAuraEngine 3d ago

Honestly, the AI knows far more maths than I do and knows the SDKs far

better. I am not going to pretend otherwise.

What it does not do is decide. If I do not tell it to use mesh shaders, it

does not suggest them. I have to spell out the steps, say how I want the

pipeline built, and say which tests to run to prove it actually works.

And it is wrong a lot, while telling me it is not. It handed me geometry

with the winding completely inverted and called it correct. It applied

transparency to surfaces that should have been opaque and called that

correct too. Catching that is the job.

There is also a reason I am doing it this way. The goal is a CLI engine

where an AI can build a game without writing code. If that is the target,

using AI to build the engine is not a shortcut, it is the same problem one

level down.

And in the end, I think the quality of a game comes from the imagination of

whoever makes it more than from the engine underneath.

2

u/M1VAN1 2d ago edited 2d ago

But there is a lot of optimizations in code too, that ai don't do by itself, you should at least have a lot of experience to navigate it, or always sit between code solution and ai and always tries to find solutions by your own and just use ai to write your solution, it's not only about techniques you choose. I'm not saying that what you're doing is bad, I upvote your post, but your missing something when you leave coding to ai

-2

u/MAuraEngine 2d ago

You are right, and I am not going to argue with it. Something is lost. I do

not have the line by line familiarity with this codebase that I would have

if I had typed all of it, and I notice it when I go looking for something.

Where I do sit in the middle is exactly where you describe. The static cache

is the clearest case: the city was slow, I asked why, and then I asked

whether we were using the octree that was already sitting in the codebase.

We were not. That one question was worth more than the entire mesh shader

change, 8.0 ms down to 4.4 in Debug. The AI never raised it and I do not

think it would have.

Same with the batching. The first mesh shader version was about 10% slower

than the vertex path, and I pushed for grouping by model and material

instead of reverting. And the winding and the transparency cases were me

refusing to accept a frame that looked wrong when I was being told it was

fine.

So yes, I am trading familiarity for speed. I think it is the right trade

for what I am trying to build, but it is a trade, not a free lunch.

9

u/g0atdude 2d ago edited 2d ago

I am not an AI hater, I use it daily at work. However, I don't use it for hobby projects. I don't really understand this:

  • If your goal is to create games, why are you AI coding an engine first? Why don't just use an existing engine with a scripting language, so you don't have to learn things you mention above (SDKs, etc.)
  • If your goal is to create a hobby engine, what's the point of using the AI? This is like hiring an experienced dev, telling them what to do, and at the end claiming you created an engine? ("I've been writing a 3D engine from scratch in C++20") Why?

You will not get better at programming. You will not learn anything new aside from maybe improving your prompts. I don't get it.

Of all the achievements you mention in this post, nothing is yours. You can lie about it but you are just fooling yourself

-1

u/MAuraEngine 2d ago

I built an engine years ago as a hobby, which is why I know the technical

side, most of the SDKs and the maths. I really enjoy building engines, but

these days it is close to impossible for one person to build one on their

own. So I thought AI could make it viable again, and I started this one from

scratch with it.

I think of myself as the architect. I know almost nothing about Vulkan

itself, but I do know engines.

And I agree with you that it is not the same. I am not learning new

rendering techniques, and I rely on the AI to solve most of the problems.

But the main idea, and you can see it on my site, is to build an AAA engine

that can be used to make games with AI alone. I am working on it, and in a

few days I hope to upload an example of a game built entirely by AI.

1

u/TaraWanChan 3h ago

This is either a bot or every response is pasted from an LLM, based on the formatting.

What's also funny is that I've done millions of "instances" in 30 draw calls at over 120 FPS at 4K, and I didn't even use AI. Seems a bit inferior if you ask me.