Skip to content

Add vulkan+rtx renderer#9

Draft
w23 wants to merge 1795 commits intomasterfrom
vulkan
Draft

Add vulkan+rtx renderer#9
w23 wants to merge 1795 commits intomasterfrom
vulkan

Conversation

@w23
Copy link
Copy Markdown
Owner

@w23 w23 commented Jun 7, 2021

This is here for now only for tracking mergeability + CI purposes

w23 and others added 30 commits December 12, 2024 15:17
It compiles, but it's broken and doesn't pass validation yet. Resource part doesn't collect barriers correctly somehow, needs debugging.
Now it works!
Needs a bit of a cleanup, though.
This adds explicit staging user tracking, which allows:
- tracking whether there are any unclaimed items, and pushing them (or ignoring, if the user decides so, for transient stuff)
- having more granular stats for staging, i.e. which buffer/subsystem used staging in this frame, and how much (not implemented yet)

This commit also changes staging from using flip buffer to just ring buffer allocator.
`staging.<USER>.size` and `staging.<USER>.allocs` r_speeds metrics are now available for every staging user.
Move draw_instance into ray_accel module. Then, when building TLAS, go through all instances, and check whether their blases need to be (re)built. Enqueue those who need to be rebuilt before building TLAS.

Fixes crashing when doing changelevel w/o rt, and then enabling rt.
…rriers

Group by access/stage, not by src/dst. Makes logs a bit more readable.
Previously we forced src image layout to be UNDEFINED if the image was
to be written into. This lead to RADV driver to completely clear our so
painfully constructed ray traced frame.

The correct layout transition should probably be something like this: if
we're not to _read_ from image contents, only then we can be sure that
its contents are not needed anymore, and can be discarded by settind the
src layout to UNDEFINED.
This makes c0a0d toxic pool emissive again, but it still doesn't make all known toxic water objects emissive.
This does fix a bunch of emissive water surfaces missing, but not all. It also entangles the code even more.

Not sure if its worth it, maybe a better approach is possible.
This was a bug in validation layers, it's been fixed back in 2021.
Swapchain framebuffer image being in VK_IMAGE_LAYOUT_PRESENT_SRC_KHR layout has zero access flags, and is probably synced with bottom-of-pipe stage.

At least this does please validation layers.
w23 and others added 30 commits June 8, 2025 17:27
Not yet tested, due to apparent no overlap on this platform ;_;.
- Limit stack to 8.
- Use stack limit to position GPU scopes beneath.
- Tweak scope overlap code. Not tested -- currently no overlap produced.
- Tweak scope label color to be a bit more readable.
Speeds is Vulkan-unaware, so don't make it so. It just needs counter
name and its value units.
Add rad files for blueshift and friends
This allows them being displayed as graphs.
Metrics will be referenceable by indexes in the next commit.
Use `r_speeds_mlist <filter>` or `r_speeds_mtable <filter>` to find the
list of metrics with indexes.

Use `r_speeds_graph add <index1> <index2> ...` to add graphs by metric
index instead of lengthy name that is a pain to type.
Use `vk_speeds_counters` to list available counters.
Use `vk_speeds_counters_enable <C1> <C2> ...` to enable specified
counters by their index. If no counters are provided, disables perf
query completely.

KNOWN ISSUES:
- sometimes validation still complains about misaligned performance
  lock -- it should be active before any of the command buffers with
  perf query start recording commands.
This greatly simplifies profiling lock management, as now the lock can
be enabled at init time for the entire duration. Enabling it dynamically
is messy due to global command buffer requirements, which are difficult
to control in this code base.
Add detailed GPU performance counters based on VK_KHR_performance_query

- [x] #499
- [x] Query and log available performance counters
- [x] Create query pool with specified perf counters
- [x] Cover eligible scopes with perf queries
- [x] Control perf query using console commands
- [x] Display perf counters with r_speeds

Closes #499
Decals are added in the same way as in the other renderers and in vanilla xash3d: as a list of decals attached to a BSP surface. They are rendered as polygons, similarly to the GL renderer.

This makes the visuals as close to the original as possible and avoids the typical issues of deferred decals.

In ray tracing, a decal changes the surface material, allowing it to interact with lighting and modify the surface roughness/metalness without affecting normals (optional).

Changes:

- Adapted the decal file from the GL renderer for the VK renderer
- Added extra getters to existing files that are required for this feature
- Added TRI_POLYGON mode to TriApi, which is required for decals
- Added batching for decal geometry to reduce draw calls and improve memory storage efficiency Introduced the TRI_TRIANGLES geometry type specifically for batching
- Added a render mode, material, and pipeline for decals
- Added traceDecals, which applies material data from nearby decals to the ray's payload, allowing decals to be integrated into the ray tracing pipeline
- Changed the transparency calculation order so that the decal modifies the surface material before lighting is evaluated in bounce.comp
- Use r_speeds for decals stats: control total decals count and batched decal meshes count

<img width="2879" height="1745" alt="image" src="https://github.com/user-attachments/assets/a23fb18f-a816-470c-b8db-d17b4209856e" />

Closes #107
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

4 participants