Commit Graph

229 Commits

Author SHA1 Message Date
Rémi Verschelde adb7774a61
RenderingDevice: Add null checks when retrieving uniform sets
This may mitigate a crash seen in the wild in Rift Riff on Android, most
likely trading it for a single-frame rendering bug (which is better than
crashing on user devices).

It doesn't solve the underlying issue which seems to be a race condition
where a uniform set RID gets has been freed while still being reported as
owned by the RID_Owner.
2025-12-16 10:15:02 +01:00
Skyth ba556ebe03 Implement point size emulation in the forward shader for D3D12. 2025-12-02 17:36:31 +03:00
Skyth bfdf86370f Check for pending clears in every RD texture function. 2025-11-27 17:26:26 +03:00
Rémi Verschelde b1de0364bf
Merge pull request #111954 from blueskythlikesclouds/copy-api-refactor
Refactor rendering driver copy APIs to fix D3D12 issues.
2025-11-27 09:55:31 +01:00
Alexander Hartmann d97496a99e Fix `SHADER_UNIFORM_NAMES` 2025-11-26 16:02:38 +01:00
Skyth 56db3aed47 Refactor rendering driver copy APIs to fix D3D12 issues.
Co-authored-by: Stuart Carnie <stuart.carnie@gmail.com>
2025-11-26 12:00:02 +03:00
Dario d17ea061bc Move D3D12's automatic texture clears to RenderingDevice. 2025-11-25 09:34:38 -03:00
Thaddeus Crews 9a8b9e5c24
Merge pull request #113010 from blueskythlikesclouds/persistent-map-staging-buffers
Persistently map staging buffers.
2025-11-24 16:00:04 -06:00
Thaddeus Crews 2edc43df8e
Merge pull request #78598 from BastiaanOlij/resolve_depth_buffer_mobile
Resolve depth buffer in mobile renderer when required
2025-11-20 11:10:48 -06:00
Skyth f5bbd71dfc Persistently map staging buffers. 2025-11-20 14:32:55 +03:00
Pāvels Nadtočajevs 90f2026c0f
Fix D3D12 renderer crash on Wine. 2025-11-18 12:38:22 +02:00
Bastiaan Olij 21ffbecfa9 Resolve depth buffer in pass if supported by driver 2025-11-17 17:29:38 +11:00
Stuart Carnie 90c0e6acca 2D: Switch to VBOs for instance data
- Add support for vertex bindings and UMA vertex buffers in D3D12.
- Simplify 2D instance params and move more into per-batch data to save
  bandwidth

Co-authored-by: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com>
Co-authored-by: Clay John <claynjohn@gmail.com>
Co-authored-by: A Thousand Ships <96648715+athousandships@users.noreply.github.com>
2025-11-15 06:25:49 +11:00
Lukas Tenbrink c3747884da Add some important profiling hooks. 2025-11-08 00:08:48 +01:00
Thaddeus Crews edbfb7a6ec
Merge pull request #111183 from stuartcarnie/matias-uma-pc-pr
Add Persistent Buffers utilizing UMA
2025-10-24 11:23:11 -05:00
Stuart Carnie 230adb7511 Add Persistent Buffers
This work is a heavily refactored and rewritten from TheForge's initial
code.

TheForge's original code had too many race conditions and was
fundamentally flawed as it was too easy to incur into those data races
by accident.

However they identified the proper places that needed changes, and the
idea was sound. I used their work as a blueprint to design this work.

This PR implements:

 - Introduction of UMA buffers used by a few buffers
(most notably the ones filled by _fill_instance_data).

Ironically this change seems to positively affect PC more than it does
on Mobile.

Updates D3D12 Memory Allocator to get GPU_UPLOAD heap support.

Metal implementation by Stuart Carnie.

Co-authored-by: Stuart Carnie <stuart.carnie@gmail.com>
Co-authored-by: TheForge team
2025-10-24 08:16:19 +11:00
Clay John bad8f531a8 Sync final frame after finalizing RD to ensure that nothing is in use on the GPU when we free the RD 2025-10-23 08:20:54 -07:00
Erik Ritschl 44451e6988 Fix incorrect failure code in screen_get_framebuffer_format
RenderingDevice::screen_get_framebuffer_format should return a value of
type RenderingDevice::FramebufferFormatID which is an alias of int64_t
but it returns Error::FAILED with a value of 1. The compiler does not
complain because both types are integers but 1 corresponds to a valid
FramebufferFormatID, meaning a certain failure condition is missed.

This commit changes it to the correct value, INVALID_ID.
2025-10-21 15:26:26 +02:00
Dario af584b1ba8 Do not begin a new frame during RenderingDevice's shutdown. 2025-10-16 13:47:18 -03:00
Stuart Carnie a281e91c5a Metal: Fix `texture_get_data` other linear formats
Introduce a specialised `texture_get_data` for `RenderDeviceDriver`,
which can retrieve the texture data from the GPU driver for shared
textures (`TEXTURE_USAGE_CPU_READ_BIT`).

Closes #108115
2025-10-16 06:46:51 +11:00
chocola-mint ead282ff13 Remove `file_access.h` and `script_backtrace.h` includes from `logger.h`. 2025-10-05 17:49:23 +09:00
Stuart Carnie 3ffcae66a8 Renderer: Fix missing shader_name; use forward declarations
* Moving over to RenderingShaderContainer, missed setting shader_name
* Use forward declaration reduces compile time when modifying
  rendering_shader_container.h from over 950s to about 10-15
2025-10-02 10:02:18 +10:00
Thaddeus Crews 4594de69fd
Merge pull request #111013 from stuartcarnie/shader_container_ext
Renderer: Move `reflect_spirv` to `RenderingShaderContainer`
2025-10-01 17:54:09 -05:00
Aaron Franke 9fbf5808a0
Rename server "free" functions to "free_rid" to match exposed API 2025-09-30 16:52:25 -07:00
Stuart Carnie 65e8b0951b Renderer: Move reflect_spirv to RenderingShaderContainer
This change introduces a new protected type, `ReflectedShaderStage` to
`RenderingShaderContainer` that derived types use to access SPIR-V and
the reflected module, `SpvReflectShaderModule` allowing implementations
to use the reflection information to compile their platform-specific
module.

* Fixes memory leak in `reflect_spirv` that would not deallocate the
  `SpvReflectShaderModule` if an error occurred.
* Removes unnecessary allocation when creating `SpvReflectShaderModule`
  by passing `NO_COPY` flag to `spvReflectCreateShaderModule2`
  constructor function.
* Replaces `VectorView` with `Span` for consistency
* Fixes unnecessary allocations in D3D12 shader container in
  `_convert_spirv_to_nir` and `_convert_spirv_to_dxil` which implicitly
  converted the old `VectorView` to a `Vector`
2025-09-30 06:40:14 +10:00
Dario 8c4180adf4 Add GENERAL resource usage to the render graph. Fixes texture initialization in D3D12. 2025-09-02 15:18:47 -03:00
Thaddeus Crews 87bb5ab681
Merge pull request #108919 from KeyboardDanni/d3d12_init_shader_model_check
D3D12: Fix shader model check, initialization error handling
2025-08-01 11:45:19 -05:00
Danni bf6629a005 D3D12: Fix shader model check, initialization error handling 2025-07-28 20:35:45 -04:00
Dario 4af0734a77 Compute texture alignment for transfers using the LCM instead. 2025-07-24 14:08:45 -03:00
LuoZhihao 8ad3072a6a RenderingDevice: Add `uniform_type` check to avoid crash 2025-07-13 10:27:16 +08:00
Stuart Carnie 5230f6c60c Apple: Use image atomic operations on supported Apple hardware
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
2025-07-05 05:59:00 +10:00
Lukas Tenbrink 2b36c79f7b Use `Span<uint8_t>` in `RenderingDevice` allocation APIs to avoid intermediary arrays on calls. 2025-06-18 12:31:48 +02:00
NetroScript 66d68707d3
Fix the VRS attachment being incorrectly added to color_attachments 2025-06-12 13:38:18 +02:00
clayjohn cc9aedd898 Avoid crash when texture layers is greater than 1 and format is not an ARRAY type 2025-06-05 10:21:19 -07:00
Thaddeus Crews de37627404
Merge pull request #102552 from DarioSamo/shader-baker
Add shader baker to project exporter.
2025-05-28 17:09:38 -05:00
Thaddeus Crews 90c75d02dd
Merge pull request #106732 from stuartcarnie/rd_reduce_allocations
Renderer: Eliminate `String` allocations for all labels in the renderer
2025-05-28 09:47:43 -05:00
Stuart Carnie 7d93119353 Renderer: Eliminates `String` allocations for all labels in the renderer
Uses `Span<char>` to avoid additional allocations in the graph.
2025-05-28 06:01:35 +10:00
Dario 5a30a7e7cd Add shader baker to project exporter.
Metal Support contributed by Migeran (https://migeran.com) and Stuart Carnie.

Co-authored-by: Stuart Carnie <stuart.carnie@gmail.com>
Co-authored-by: Gergely Kis <gergely.kis@migeran.com>
2025-05-27 12:45:27 -03:00
Lukas Tenbrink 4cb8a0c77e Add `resize_initialized` and `resize_uninitialized` to `Vector`. These functions serve as replacements for `resize`, to make sure the caller understands whether elements need to be initialized 'by hand' after the call. 2025-05-26 18:35:41 +02:00
Sander 6ae50cad17 RenderingDevice: introduce parameter 'mipmaps' for texture_create_from_extension() 2025-05-07 15:15:55 +03:00
lawnjelly f8f350a32a Add `GLOBAL_GET` cached macros.
GLOBAL_GET is an expensive operation which should not be used each frame / tick.
This PR adds macros which do a cheaper revision check, and only call the expensive GLOBAL_GET when project settings have changed.

Co-authored-by: Lukas Tenbrink <lukas.tenbrink@gmail.com>
2025-04-30 15:08:50 +01:00
Lukas Tenbrink bfdb0f0ecf Fix various sanitizer issues. 2025-04-28 15:23:35 +02:00
Yyf2333 1a70a06a43 Change RID_Owner::get_owned_list. 2025-04-21 01:04:27 +08:00
Thaddeus Crews b743eb96e3
Merge pull request #98760 from ze2j/optimize_texture_create_shared_from_slice
Optimize shared texture creations
2025-04-18 12:21:25 -05:00
Thaddeus Crews 98aced4e65
Merge pull request #99768 from dsnopek/openxr-vulkan-foveated-rendering
OpenXR: Use the `XR_FB_foveation_vulkan` extension to get the density map for VRS
2025-04-17 09:14:23 -05:00
Thaddeus Crews 0d267e7b1e
Core: Add dedicated `BitField` template 2025-04-11 11:53:26 -05:00
A Thousand Ships 889410dcda
Add `String::replace_char(s)` methods for performance and convenience 2025-04-10 13:08:45 +02:00
Yufeng Ying 4f4031a675 Replace size() == 0 with is_empty(). 2025-04-02 19:18:43 +08:00
David Snopek 79f5a4d9fe OpenXR: Use the `XR_FB_foveation_vulkan` extension to get the density map for VRS 2025-03-31 07:21:58 -05:00
Rémi Verschelde 408d07109b
Merge pull request #99551 from DarioSamo/fragment-density-map
Implement Fragment density map support.
2025-03-28 14:31:19 +01:00