mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-13 06:21:29 -10:00
* chore: vendor ImPlot library
Adds ImPlot as a build dependency, to be used for the upcoming ImGui
frame profiler overlay's frametime graph and pie chart.
* feat: add ImGui frame profiler overlay
Replaces the old text-dump frame profile display (-profile_frame_time)
with a runtime-toggleable ImGui/ImPlot overlay showing average/median
frametime, a scrolling frametime graph, and a pie chart of the top
contributors to frame time. Toggled via a new "Frame Profiler Overlay"
option, which also seeds from -profile_frame_time for backward
compatibility and now drives frame profiling collection at runtime
instead of only at startup.
* Add graphics and Vulkan debug stats to ImGui profiler overlay
- Integrated per-backend diagnostic counters into the ImGui frame profiler overlay, triggered by `-gr_debug`.
- Consolidated and cleaned up Vulkan rendering state and descriptor management for compatibility with ImGui's Vulkan pipeline.
- Enabled uniform buffer and draw statistics reporting for enhanced performance insights during debugging.
* Update ImPlot to v1.1 WIP and improve internal consistency
- Adjust copyright notices for extended license coverage (2025-2026).
- Modernize constants with `constexpr` replacements, improving type safety and clarity.
- Enforce `nullptr` usage over `NULL` throughout, aligning with modern C++ practices.
- Add various enhancements to ImPlot legends, markers, and axes behavior.
- Introduce additional helper methods for time handling and timestamp calculations.
- Address UI and typo improvements in comments and documentation, refining accuracy.
* Refactor frame profiler to use per-category self-time accumulation
- Introduced `accumulate_self_times` for single-pass exclusive time computation, improving performance and accuracy.
- Updated `FrameProfiler` and overlay snapshot logic to leverage `Category`'s stable `getId` and `getCount`.
- Replaced pie chart with a stacked bar for frame budget visualization, optimizing rendering cost.
- Cached `get_tid` and `get_pid` with thread-local storage to minimize syscall overhead.
- Added support for unit testing frame profiling functionality and included new test cases.
- Improved code comments and clarified documentation.
* Use dynamic uniform buffers to stop per-draw descriptor set churn in Vulkan
The Material and PerDraw descriptor sets were reallocated and fully rewritten on
essentially every draw call. model_draw_list::render_buffer rebinds ModelData with
a fresh uniform buffer offset for each queued draw, and that offset was part of the
Material set's memoization key, so the cache in VulkanDrawManager::applyMaterial
missed every time - taking a frame-pool allocation, a full template write, the
16-entry material texture resolution and a vkUpdateDescriptorSets with it.
GenericData/Matrices did the same to the PerDraw set. renderShadowDraw was worse
still: all three sets allocated and rewritten per shadow draw, with no memoization
at all.
A large asteroid field (Solaris m21) measured 2566 descriptor sets and 19107
descriptor writes per frame at 1606 model draws, and grew an extra descriptor pool
chunk every frame.
Declare the bindings whose offset moves per draw - MaterialBinding::ModelData,
MaterialBinding::ShadowMapData, PerDrawBinding::GenericData and
PerDrawBinding::Matrices - as eUniformBufferDynamic. DescriptorWriter::setBuffer
now splits a dynamic binding's offset out of the descriptor, writing
{buffer, 0, range} and stashing the offset for vkCmdBindDescriptorSets'
pDynamicOffsets, so an offset-only change leaves the set's contents identical and
the memoization caches start hitting. Shader sources are unchanged.
VulkanStateTracker::bindDescriptorSet now compares the dynamic offsets as well as
the set handle. This is required, not an optimization: the common case is now the
same set rebound with a new offset, and the old handle-only redundancy check would
have skipped that bind and fed every draw the previous draw's uniforms.
renderShadowDraw memoizes its three sets the way applyMaterial does. It does not
invalidate applyMaterial's caches - those record what a set contains, the shadow
pass allocates its own sets rather than overwriting theirs, and it binds through
the state tracker, so the next material cache hit still rebinds correctly.
Also switch allocateFrameSet to the non-allocating allocateDescriptorSets overload;
the vector-returning one heap-allocated once per set, thousands of times a frame.
MAX_SETS_PER_POOL stays at 1024 - the per-frame pool growth it used to log was a
symptom of the churn, and one chunk now covers the scene outright.
Measured on that mission in a Debug build, A/B on the same tree with and without
this change:
descriptor sets/frame @ ~1370 draws 2566 -> 250-345
descriptor writes/frame 19107 -> ~1700-2300
median frametime 92.9/83.6 ms -> 72.0/66.5 ms
Render Buffer (profiler overlay) 24.68 ms (30.8%) -> 12.73 ms (18.4%)
Build Shadow Map 5.44 ms -> off the top-5 entirely
Release builds already inlined most of this away and are unchanged, as expected.
Verified with the validation layers (sync validation enabled): no new VUIDs versus
the same build without the change.
Co-Authored-By: Claude Opus 5 <[email protected]>
* Refactor Vulkan descriptor set binding to reduce dynamic offset churn
- Consolidated dynamic descriptor offset logic into `DescriptorWriter::bindSets`, replacing repetitive `vkCmdBindDescriptorSets` patterns across Vulkan modules.
- Eliminated redundant descriptor binding operations for Material and PerDraw sets by centralizing logic in `bindSets`.
- Simplified descriptors by directly splitting offset changes from descriptor contents, avoiding unnecessary updates.
- Updated comments and documentation to align with the new approach while maintaining reference consistency.
- Applied optimizations across Vulkan modules (`VulkanPostProcessing`, `VulkanDescriptorManager`, etc.) to reduce per-draw overhead and improve readability.
* Enable primitive restart for supported topologies in Vulkan pipeline
- Added `topologySupportsPrimitiveRestart` to determine restart eligibility for each topology.
- Updated `primitiveRestartEnable` to be conditionally set based on topology, addressing compatibility issues with Metal/MoltenVK.
- Prevented crash scenarios on macOS by ensuring pipelines are valid for strip/fan topologies requiring primitive restart.
* Enable VK_KHR_portability_subset for compatibility
* Replace exception with sentinel for non-dynamic Vulkan descriptor bindings
- Introduced `DYNAMIC_SLOT_INVALID` sentinel to replace the throw in `dynamic_offset_slot` for MSVC compatibility.
- Added `static_assert` checks to validate binding constants, ensuring compile-time validation for dynamic offsets.
- Updated comments to clarify design rationale and avoid potential misuse.
* Add memory statistics and tracking to profiler overlay
* fix ci issues
* Add OpenGL memory statistics to the profiler overlay
The memory panel showed no texture bytes and no geometry bytes under
OpenGL. Only the depth renderbuffers went into the render target group.
All three groups now give a value.
Textures: GL_texture_bytes_used holds the bytes of every live texture
cache slot. opengl_texture_release_bytes() removes the bytes of a slot at
each site that drops its texture data. The bitmap render targets record
the bytes of their color texture.
Geometry: the unused GL_vertex_data_in global becomes
GL_geometry_bytes_used, which counts only vertex and index buffers. This
matches the geometry group of the Vulkan backend.
gr_opengl_delete_buffer() sets the size of the buffer to 0, because
opengl_destroy_all_buffers() calls it a second time for a buffer that the
game already deleted.
Render targets: three new functions add the scene textures, the
post-processing textures, and the shadow map to the group. They sum the
bytes at the moment of the call from the textures that exist, thus they
need no bookkeeping at the create and delete sites.
Co-Authored-By: Claude Opus 5 <[email protected]>
* Fix profiler overlay crash on a category that is not a static
The category registry kept a Category pointer for each id. The comment said that all categories
are global statics, but that is not correct. The Lua API tracing_category constructs a Category
and copies it into a script-owned object. The registry then kept a pointer to the dead temporary.
build_overlay_snapshot called getName() on that pointer, made an SCP_string from the garbage
char*, and the process stopped with SIGABRT.
The registry now keeps the name by value and never keeps a Category pointer. getById() becomes
getNameById(), which is all that build_overlay_snapshot needs. A copy of a Category keeps the id
of the original, which stays correct because the id only selects a name.
Add two tests: one shows that the name stays available after the Category object is dead, and one
drives the full path that failed, from processEvent to the overlay snapshot.
Co-Authored-By: Claude Opus 5 <[email protected]>
* Replace category pointers with IDs to prevent use-after-free
- Updated `trace_event` to store `category_id` instead of a pointer to prevent dangling references to category objects that may already be destroyed.
- Modified all references to category names to use `Category::getNameById()` instead of dereferencing pointers.
- Expanded memory statistics in the profiler overlay with new sound, Lua, and OS-level memory usage tracking.
- Added new tests to verify proper use of category IDs in frame profiling and event tracing.
- Improved memory safety and stability across tracing, profiling, and overlay systems.
* Refactor profiler overlay to use snapshot-based frame timing
* Address review feedback on the profiler overlay
Skip complete::end for a scope that did not start. This fixes a crash
when Lua turns the overlay on while a scope is open. Track the GPU begin
event so that turning the overlay off mid-scope still closes it.
Use XSTR 1936 and 1937 for the overlay option. Master now uses 1932
and 1933.
Remove the default value of dynamicOffsets in bindDescriptorSet. Use the
PerDraw binding constants in the PerDraw key.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Use wall-clock frame time and read the history without a copy
The Avg and FPS line used traced self-time, which reads too high.
Measure the time between overlay frames instead. Draw the graph with
PlotLineG so the history deque needs no per-frame copy.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
* Address second round of review feedback on the profiler overlay
- Make the category registry thread-safe and give categories with the
same name one id, so the registry does not grow without limit.
- Add tests that toggle the profiler inside an open trace scope.
- Correct the next free XSTR id note to 1938.
- Use the existing Windows include block for psapi.h in osapi.cpp.
- Use list_range in ship_get_num_ships() and shorten some comments.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* Return size_t from Category::getCount() and tidy the registry code
- Use structured bindings and std::scoped_lock in the category registry.
- Return size_t from getCount() and update its callers and tests.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* Address third round of review feedback on the profiler overlay
- Move the overlay option strings to XSTR 1940 and 1941. The touch
overlay on master uses 1936 to 1939.
- Give FrameProfiler the main thread ID when it is made. Before, it
used the thread of the first event, which was a race.
- Let mouse motion go to the game while the pointer is over the
overlay, so that mouse flight does not stop there.
- Find the dynamic bindings of the PerDraw key with
dynamic_offset_slot(), as the other call sites do.
- Make disable_inside_open_scope count the GPU timestamp queries, so
that it fails if end() does not close the GPU event.
- Make the copy test copy the category, not bind a reference.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* apply review suggestions
---------
Co-authored-by: Claude Opus 5 <[email protected]>
822 lines
28 KiB
C++
822 lines
28 KiB
C++
#include "VulkanDraw.h"
|
|
|
|
#include <algorithm>
|
|
#include <array>
|
|
|
|
#include "VulkanState.h"
|
|
#include "VulkanBarrier.h"
|
|
#include "VulkanBuffer.h"
|
|
#include "VulkanPipeline.h"
|
|
#include "VulkanShader.h"
|
|
#include "VulkanTexture.h"
|
|
#include "VulkanRenderer.h"
|
|
#include "VulkanPostProcessing.h"
|
|
#include "VulkanDescriptorManager.h"
|
|
#include "VulkanDeletionQueue.h"
|
|
#include "VulkanMemory.h"
|
|
#include "VulkanConstants.h"
|
|
#include "gr_vulkan.h"
|
|
#include "VulkanVertexFormat.h"
|
|
#include "bmpman/bmpman.h"
|
|
#include "ddsutils/ddsutils.h"
|
|
#include "graphics/grinternal.h"
|
|
#include "graphics/material.h"
|
|
#include "graphics/matrix.h"
|
|
#include "graphics/util/primitives.h"
|
|
#include "graphics/util/uniform_structs.h"
|
|
#include "graphics/shadows.h"
|
|
#include "lighting/lighting.h"
|
|
#include "graphics/util/UniformBuffer.h"
|
|
|
|
#define MODEL_SDR_FLAG_MODE_CPP
|
|
#include "def_files/data/effects/model_shader_flags.h"
|
|
|
|
// PostProcessing_override is defined in globalincs/systemvars.cpp
|
|
|
|
namespace graphics::vulkan {
|
|
|
|
// ========== gr_screen function pointer implementations ==========
|
|
// These free functions are assigned to gr_screen.gf_* in gr_vulkan.cpp.
|
|
|
|
namespace {
|
|
|
|
// Helper to set up GenericData uniform for default material shader
|
|
// Similar to opengl_shader_set_default_material() in gropenglshader.cpp
|
|
void vulkan_set_default_material_uniforms(material* material_info)
|
|
{
|
|
if (!material_info) {
|
|
return;
|
|
}
|
|
|
|
// Get uniform buffer for GenericData
|
|
auto buffer = gr_get_uniform_buffer(uniform_block_type::GenericData, 1, sizeof(genericData_default_material_v_sdr));
|
|
auto* data = buffer.aligner().addTypedElement<genericData_default_material_v_sdr>();
|
|
|
|
// Get base map from material
|
|
int base_map = material_info->get_texture_map(TM_BASE_TYPE);
|
|
bool textured = (base_map >= 0);
|
|
bool alpha = (material_info->get_texture_type() == TCACHE_TYPE_AABITMAP);
|
|
|
|
// Texturing flags
|
|
if (textured) {
|
|
data->noTexturing = 0;
|
|
// Get array index for animated texture arrays
|
|
auto* texSlot = getTextureManager()->getTextureSlot(base_map);
|
|
data->baseMapIndex = texSlot ? static_cast<int>(texSlot->arrayIndex) : 0;
|
|
} else {
|
|
data->noTexturing = 1;
|
|
data->baseMapIndex = 0;
|
|
}
|
|
|
|
// Alpha texture flag
|
|
data->alphaTexture = alpha ? 1 : 0;
|
|
|
|
// HDR / intensity settings
|
|
data->srgb = High_dynamic_range ? 1 : 0;
|
|
data->intensity = material_info->get_color_scale();
|
|
|
|
// Alpha threshold
|
|
data->alphaThreshold = getStateTracker()->getAlphaThreshold();
|
|
|
|
// Color from material
|
|
vec4 clr = material_info->get_color();
|
|
data->color.a1d[0] = clr.xyzw.x;
|
|
data->color.a1d[1] = clr.xyzw.y;
|
|
data->color.a1d[2] = clr.xyzw.z;
|
|
data->color.a1d[3] = clr.xyzw.w;
|
|
|
|
// Clip plane
|
|
const auto& clip_plane = material_info->get_clip_plane();
|
|
if (clip_plane.enabled) {
|
|
data->clipEnabled = 1;
|
|
|
|
data->clipEquation.a1d[0] = clip_plane.normal.xyz.x;
|
|
data->clipEquation.a1d[1] = clip_plane.normal.xyz.y;
|
|
data->clipEquation.a1d[2] = clip_plane.normal.xyz.z;
|
|
// Calculate 'd' value: d = -dot(normal, position)
|
|
data->clipEquation.a1d[3] = -((clip_plane.normal.xyz.x * clip_plane.position.xyz.x) +
|
|
(clip_plane.normal.xyz.y * clip_plane.position.xyz.y) +
|
|
(clip_plane.normal.xyz.z * clip_plane.position.xyz.z));
|
|
|
|
data->modelMatrix = gr_model_matrix_stack.get_transform();
|
|
} else {
|
|
data->clipEnabled = 0;
|
|
vm_matrix4_set_identity(&data->modelMatrix);
|
|
data->clipEquation.a1d[0] = 0.0f;
|
|
data->clipEquation.a1d[1] = 0.0f;
|
|
data->clipEquation.a1d[2] = 0.0f;
|
|
data->clipEquation.a1d[3] = 0.0f;
|
|
}
|
|
|
|
buffer.submitData();
|
|
gr_bind_uniform_buffer(uniform_block_type::GenericData, buffer.getBufferOffset(0),
|
|
sizeof(genericData_default_material_v_sdr), buffer.bufferHandle());
|
|
}
|
|
|
|
} // anonymous namespace
|
|
|
|
int vulkan_zbuffer_get()
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
return drawManager->zbufferGet();
|
|
}
|
|
|
|
int vulkan_zbuffer_set(int mode)
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
return drawManager->zbufferSet(mode);
|
|
}
|
|
|
|
void vulkan_zbuffer_clear(int mode)
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->zbufferClear(mode);
|
|
}
|
|
|
|
int vulkan_stencil_set(int mode)
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
return drawManager->stencilSet(mode);
|
|
}
|
|
|
|
void vulkan_stencil_clear()
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->stencilClear();
|
|
}
|
|
|
|
void vulkan_set_fill_mode(int mode)
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
// GR_FILL_MODE_WIRE = 1, GR_FILL_MODE_SOLID = 2
|
|
drawManager->setFillMode(mode);
|
|
}
|
|
|
|
void vulkan_clear()
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->clear();
|
|
}
|
|
|
|
void vulkan_reset_clip()
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->resetClip();
|
|
}
|
|
|
|
void vulkan_set_clear_color(int r, int g, int b)
|
|
{
|
|
graphics::vulkan::VulkanDrawManager::setClearColor(r, g, b);
|
|
}
|
|
|
|
void vulkan_set_clip(int x, int y, int w, int h, int resize_mode)
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->setClip(x, y, w, h, resize_mode);
|
|
}
|
|
|
|
int vulkan_set_cull(int cull)
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
return drawManager->setCull(cull);
|
|
}
|
|
|
|
int vulkan_set_color_buffer(int mode)
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
return drawManager->setColorBuffer(mode);
|
|
}
|
|
|
|
void vulkan_set_texture_addressing(int mode)
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->setTextureAddressing(mode);
|
|
}
|
|
|
|
void vulkan_set_line_width(float width)
|
|
{
|
|
auto* stateTracker = getStateTracker();
|
|
if (width <= 1.0f) {
|
|
stateTracker->setLineWidth(width);
|
|
}
|
|
gr_screen.line_width = width;
|
|
}
|
|
|
|
void vulkan_clear_states()
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->clearStates();
|
|
}
|
|
|
|
void vulkan_scene_texture_begin()
|
|
{
|
|
GR_DEBUG_SCOPE("Begin scene texture");
|
|
|
|
auto* renderer = getRendererInstance();
|
|
|
|
// Switch to HDR scene render pass when post-processing is enabled
|
|
auto* pp = getPostProcessor();
|
|
if (pp && pp->isInitialized() && Gr_post_processing_enabled && !PostProcessing_override) {
|
|
renderer->beginSceneRendering();
|
|
High_dynamic_range = true;
|
|
} else {
|
|
// Fallback: just clear within the current swap chain pass
|
|
auto* stateTracker = getStateTracker();
|
|
auto cmdBuffer = stateTracker->getCommandBuffer();
|
|
|
|
std::array<vk::ClearAttachment, 2> clearAttachments;
|
|
clearAttachments[0].aspectMask = vk::ImageAspectFlagBits::eColor;
|
|
clearAttachments[0].colorAttachment = 0;
|
|
clearAttachments[0].clearValue.color.setFloat32({0.0f, 0.0f, 0.0f, 1.0f});
|
|
|
|
clearAttachments[1].aspectMask = vk::ImageAspectFlagBits::eDepth;
|
|
clearAttachments[1].clearValue.depthStencil = vk::ClearDepthStencilValue(1.0f, 0);
|
|
|
|
vk::ClearRect clearRect;
|
|
clearRect.rect.offset = vk::Offset2D(0, 0);
|
|
clearRect.rect.extent = vk::Extent2D(static_cast<uint32_t>(gr_screen.max_w),
|
|
static_cast<uint32_t>(gr_screen.max_h));
|
|
clearRect.rect = stateTracker->clampToRenderArea(clearRect.rect);
|
|
clearRect.baseArrayLayer = 0;
|
|
clearRect.layerCount = 1;
|
|
|
|
if (clearRect.rect.extent.width > 0 && clearRect.rect.extent.height > 0) {
|
|
cmdBuffer.clearAttachments(clearAttachments, clearRect);
|
|
}
|
|
}
|
|
}
|
|
|
|
void vulkan_scene_texture_end()
|
|
{
|
|
GR_DEBUG_SCOPE("End scene texture");
|
|
|
|
auto* renderer = getRendererInstance();
|
|
|
|
// If we were rendering to the HDR scene target, switch back to swap chain
|
|
if (renderer->isSceneRendering()) {
|
|
renderer->endSceneRendering();
|
|
}
|
|
|
|
High_dynamic_range = false;
|
|
}
|
|
|
|
void vulkan_copy_effect_texture()
|
|
{
|
|
GR_DEBUG_SCOPE("Copy effect texture");
|
|
|
|
auto* renderer = getRendererInstance();
|
|
|
|
// Only copy if we're actively rendering the HDR scene
|
|
if (!renderer->isSceneRendering()) {
|
|
return;
|
|
}
|
|
|
|
renderer->copyEffectTexture();
|
|
}
|
|
|
|
void vulkan_draw_sphere(material* material_def, float /*rad*/)
|
|
{
|
|
// Set up uniform buffers before rendering (like OpenGL does)
|
|
gr_matrix_set_uniforms();
|
|
vulkan_set_default_material_uniforms(material_def);
|
|
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->drawSphere(material_def);
|
|
}
|
|
|
|
void vulkan_render_shield_impact(shield_material* material_info,
|
|
primitive_type prim_type,
|
|
vertex_layout* layout,
|
|
gr_buffer_handle buffer_handle,
|
|
int n_verts)
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
|
|
// Compute impact projection matrices
|
|
float radius = material_info->get_impact_radius();
|
|
vec3d min_v, max_v;
|
|
min_v.xyz.x = min_v.xyz.y = min_v.xyz.z = -radius;
|
|
max_v.xyz.x = max_v.xyz.y = max_v.xyz.z = radius;
|
|
|
|
matrix4 impact_projection;
|
|
vm_matrix4_set_orthographic(&impact_projection, &max_v, &min_v);
|
|
|
|
matrix impact_orient = material_info->get_impact_orient();
|
|
vec3d impact_pos = material_info->get_impact_pos();
|
|
|
|
matrix4 impact_transform;
|
|
vm_matrix4_set_inverse_transform(&impact_transform, &impact_orient, &impact_pos);
|
|
|
|
// Set shield impact uniform data (GenericData UBO)
|
|
auto buffer = gr_get_uniform_buffer(uniform_block_type::GenericData, 1,
|
|
sizeof(graphics::generic_data::shield_impact_data));
|
|
auto* data = buffer.aligner().addTypedElement<graphics::generic_data::shield_impact_data>();
|
|
data->hitNormal = impact_orient.vec.fvec;
|
|
data->shieldProjMatrix = impact_projection;
|
|
data->shieldModelViewMatrix = impact_transform;
|
|
|
|
// Get array index for the animated shield hit texture, same as the default material path.
|
|
int shield_map = material_info->get_texture_map(TM_BASE_TYPE);
|
|
auto* texSlot = getTextureManager()->getTextureSlot(shield_map);
|
|
data->shieldMapIndex = texSlot ? static_cast<int>(texSlot->arrayIndex) : 0;
|
|
|
|
data->srgb = High_dynamic_range ? 1 : 0;
|
|
data->color = material_info->get_color();
|
|
buffer.submitData();
|
|
gr_bind_uniform_buffer(uniform_block_type::GenericData, buffer.getBufferOffset(0),
|
|
sizeof(graphics::generic_data::shield_impact_data), buffer.bufferHandle());
|
|
|
|
// Set matrix uniforms
|
|
gr_matrix_set_uniforms();
|
|
|
|
// Draw the shield mesh
|
|
drawManager->renderPrimitives(material_info, prim_type, layout, 0, n_verts, buffer_handle, 0);
|
|
}
|
|
|
|
void vulkan_render_model(model_material* material_info,
|
|
indexed_vertex_source* vert_source,
|
|
vertex_buffer* bufferp,
|
|
size_t texi)
|
|
{
|
|
// ModelData UBO (matrices, lights, material params) is already bound by the model
|
|
// rendering pipeline (model_draw_list::render_buffer) before this function is called.
|
|
// Do NOT call vulkan_set_default_material_uniforms here - that would set GenericData
|
|
// uniforms for SDR_TYPE_DEFAULT_MATERIAL, but models use SDR_TYPE_MODEL with ModelData.
|
|
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->renderModel(material_info, vert_source, bufferp, texi);
|
|
}
|
|
|
|
void vulkan_render_shadow_draw(gr_buffer_handle ubo_handle, size_t ubo_offset, size_t ubo_size,
|
|
vertex_buffer* buffer, indexed_vertex_source* vert_src, size_t texi)
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->renderShadowDraw(ubo_handle, ubo_offset, ubo_size, buffer, vert_src, texi);
|
|
}
|
|
|
|
void vulkan_render_primitives(material* material_info,
|
|
primitive_type prim_type,
|
|
vertex_layout* layout,
|
|
int offset,
|
|
int n_verts,
|
|
gr_buffer_handle buffer_handle,
|
|
size_t buffer_offset)
|
|
{
|
|
// Set up uniform buffers before rendering (like OpenGL does)
|
|
gr_matrix_set_uniforms();
|
|
vulkan_set_default_material_uniforms(material_info);
|
|
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->renderPrimitives(material_info, prim_type, layout, offset, n_verts, buffer_handle, buffer_offset);
|
|
}
|
|
|
|
void vulkan_render_primitives_particle(particle_material* material_info,
|
|
primitive_type prim_type,
|
|
vertex_layout* layout,
|
|
int offset,
|
|
int n_verts,
|
|
gr_buffer_handle buffer_handle)
|
|
{
|
|
auto* renderer = getRendererInstance();
|
|
auto* drawManager = getDrawManager();
|
|
auto* pp = getPostProcessor();
|
|
|
|
// In deferred mode, once the G-buffer pass has ended the position texture
|
|
// (view-space XYZ) is in eShaderReadOnlyOptimal and free to sample.
|
|
bool usePosTexture = light_deferred_enabled()
|
|
&& !renderer->isUsingGbufRenderPass()
|
|
&& pp && pp->deferred().isInitialized();
|
|
|
|
if (!usePosTexture) {
|
|
// Non-deferred path: copy hardware depth buffer
|
|
renderer->copySceneDepthForParticles();
|
|
}
|
|
|
|
// Set up matrices
|
|
gr_matrix_set_uniforms();
|
|
|
|
// Set effect_data GenericData UBO (matching OpenGL's opengl_tnl_set_material_particle)
|
|
{
|
|
auto buffer = gr_get_uniform_buffer(uniform_block_type::GenericData, 1,
|
|
sizeof(graphics::generic_data::effect_data));
|
|
auto* data = buffer.aligner().addTypedElement<graphics::generic_data::effect_data>();
|
|
|
|
data->window_width = static_cast<float>(gr_screen.max_w);
|
|
data->window_height = static_cast<float>(gr_screen.max_h);
|
|
data->nearZ = Min_draw_distance;
|
|
data->farZ = Max_draw_distance;
|
|
data->srgb = High_dynamic_range ? 1 : 0;
|
|
data->blend_alpha = material_info->get_blend_mode() != ALPHA_BLEND_ADDITIVE ? 1 : 0;
|
|
// In deferred mode, bind the G-buffer position texture (view-space XYZ)
|
|
// so linear_depth=1 reads .z directly (matches OpenGL behavior).
|
|
// Otherwise use the NDC conversion path with the hardware depth copy.
|
|
data->linear_depth = usePosTexture ? 1 : 0;
|
|
|
|
buffer.submitData();
|
|
gr_bind_uniform_buffer(uniform_block_type::GenericData, buffer.getBufferOffset(0),
|
|
sizeof(graphics::generic_data::effect_data), buffer.bufferHandle());
|
|
}
|
|
|
|
// Set depth texture override
|
|
if (usePosTexture) {
|
|
// Deferred path: bind G-buffer position texture directly
|
|
auto* texMgr = getTextureManager();
|
|
auto nearestSampler = texMgr->getSampler(vk::Filter::eNearest, vk::Filter::eNearest,
|
|
vk::SamplerAddressMode::eClampToEdge, false, 0.0f, false);
|
|
drawManager->setDepthTextureOverride(
|
|
{nearestSampler, pp->deferred().positionView(), vk::ImageLayout::eShaderReadOnlyOptimal});
|
|
} else if (renderer->isSceneDepthCopied() && pp) {
|
|
// Non-deferred path: bind the hardware depth copy
|
|
auto* texMgr = getTextureManager();
|
|
auto nearestSampler = texMgr->getSampler(vk::Filter::eNearest, vk::Filter::eNearest,
|
|
vk::SamplerAddressMode::eClampToEdge, false, 0.0f, false);
|
|
drawManager->setDepthTextureOverride(
|
|
{nearestSampler, pp->getSceneDepthCopyView(), vk::ImageLayout::eShaderReadOnlyOptimal});
|
|
}
|
|
|
|
drawManager->renderPrimitivesParticle(material_info, prim_type, layout, offset, n_verts, buffer_handle);
|
|
|
|
// Clear the override
|
|
drawManager->clearDepthTextureOverride();
|
|
}
|
|
|
|
void vulkan_render_primitives_distortion(distortion_material* material_info,
|
|
primitive_type prim_type,
|
|
vertex_layout* layout,
|
|
int offset,
|
|
int n_verts,
|
|
gr_buffer_handle buffer_handle)
|
|
{
|
|
auto* drawManager = getDrawManager();
|
|
auto* pp = getPostProcessor();
|
|
|
|
// Set up matrices
|
|
gr_matrix_set_uniforms();
|
|
|
|
// Set effect_distort_data GenericData UBO (16 bytes)
|
|
{
|
|
auto buffer = gr_get_uniform_buffer(uniform_block_type::GenericData, 1,
|
|
sizeof(graphics::generic_data::effect_distort_data));
|
|
auto* data = buffer.aligner().addTypedElement<graphics::generic_data::effect_distort_data>();
|
|
|
|
data->window_width = static_cast<float>(gr_screen.max_w);
|
|
data->window_height = static_cast<float>(gr_screen.max_h);
|
|
data->use_offset = material_info->get_thruster_rendering() ? 1.0f : 0.0f;
|
|
|
|
buffer.submitData();
|
|
gr_bind_uniform_buffer(uniform_block_type::GenericData, buffer.getBufferOffset(0),
|
|
sizeof(graphics::generic_data::effect_distort_data), buffer.bufferHandle());
|
|
}
|
|
|
|
// Set scene color override (binding 5) — snapshot of scene color for distortion sampling
|
|
if (pp) drawManager->setSceneColorOverride(pp->getSceneEffectTextureInfo());
|
|
|
|
// Set distortion map override (binding 6) — ping-pong noise texture for thrusters
|
|
if (material_info->get_thruster_rendering() && pp)
|
|
drawManager->setDistMapOverride(pp->getDistortionTextureInfo());
|
|
|
|
drawManager->renderPrimitivesDistortion(material_info, prim_type, layout, offset, n_verts, buffer_handle);
|
|
|
|
// Clear overrides so subsequent draws use fallback textures
|
|
drawManager->clearDistortionOverrides();
|
|
}
|
|
|
|
void vulkan_render_movie(movie_material* material_info,
|
|
primitive_type prim_type,
|
|
vertex_layout* layout,
|
|
int n_verts,
|
|
gr_buffer_handle buffer,
|
|
size_t buffer_offset)
|
|
{
|
|
gr_matrix_set_uniforms();
|
|
vulkan_set_default_material_uniforms(material_info);
|
|
|
|
// Movie shader reads alpha from the MovieData UBO (set 2, binding 4), not from
|
|
// GenericData - matches opengl_tnl_set_material_movie in gropengltnl.cpp.
|
|
auto uniform_buffer = gr_get_uniform_buffer(uniform_block_type::MovieData, 1);
|
|
auto& aligner = uniform_buffer.aligner();
|
|
auto movie_data = aligner.addTypedElement<movie_uniforms>();
|
|
movie_data->alpha = material_info->get_color().xyzw.w;
|
|
uniform_buffer.submitData();
|
|
gr_bind_uniform_buffer(uniform_block_type::MovieData,
|
|
uniform_buffer.getBufferOffset(0),
|
|
sizeof(movie_uniforms),
|
|
uniform_buffer.bufferHandle());
|
|
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->renderMovie(material_info, prim_type, layout, n_verts, buffer, buffer_offset);
|
|
}
|
|
|
|
void vulkan_render_nanovg(nanovg_material* material_info,
|
|
primitive_type prim_type,
|
|
vertex_layout* layout,
|
|
int offset,
|
|
int n_verts,
|
|
gr_buffer_handle buffer_handle)
|
|
{
|
|
// NanoVG shader reads from NanoVGData UBO (set 2 binding 2), not GenericData.
|
|
// The NanoVGRenderer binds NanoVGData before calling gr_render_nanovg().
|
|
|
|
// NanoVG uses its own software scissor (scissorMat/scissorExt in the fragment shader).
|
|
// Disable hardware scissor to match nanovg_gl.h which calls glDisable(GL_SCISSOR_TEST).
|
|
// Without this, NanoVG draws get clipped by gr_set_clip's hardware scissor.
|
|
auto* stateTracker = getStateTracker();
|
|
bool savedScissorEnabled = stateTracker->isScissorEnabled();
|
|
stateTracker->setScissorEnabled(false);
|
|
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->renderNanoVG(material_info, prim_type, layout, offset, n_verts, buffer_handle);
|
|
|
|
// Restore scissor state
|
|
stateTracker->setScissorEnabled(savedScissorEnabled);
|
|
}
|
|
|
|
void vulkan_render_primitives_batched(batched_bitmap_material* material_info,
|
|
primitive_type prim_type,
|
|
vertex_layout* layout,
|
|
int offset,
|
|
int n_verts,
|
|
gr_buffer_handle buffer_handle)
|
|
{
|
|
gr_matrix_set_uniforms();
|
|
|
|
// Set batched_data GenericData UBO (matching OpenGL's opengl_tnl_set_material_batched)
|
|
auto buffer = gr_get_uniform_buffer(uniform_block_type::GenericData, 1,
|
|
sizeof(graphics::generic_data::batched_data));
|
|
auto* data = buffer.aligner().addTypedElement<graphics::generic_data::batched_data>();
|
|
data->intensity = material_info->get_color_scale();
|
|
data->color = material_info->get_color();
|
|
buffer.submitData();
|
|
gr_bind_uniform_buffer(uniform_block_type::GenericData, buffer.getBufferOffset(0),
|
|
sizeof(graphics::generic_data::batched_data), buffer.bufferHandle());
|
|
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->renderPrimitivesBatched(material_info, prim_type, layout, offset, n_verts, buffer_handle);
|
|
}
|
|
|
|
void vulkan_render_rocket_primitives(interface_material* material_info,
|
|
primitive_type prim_type,
|
|
vertex_layout* layout,
|
|
int n_indices,
|
|
gr_buffer_handle vertex_buffer,
|
|
gr_buffer_handle index_buffer)
|
|
{
|
|
// Set up 2D orthographic projection (matches OpenGL's gr_opengl_render_rocket_primitives)
|
|
gr_set_2d_matrix();
|
|
|
|
// Fill GenericData UBO with rocketui_data layout (NOT default material layout).
|
|
// The rocketui shader reads projMatrix, offset, textured, baseMapIndex, and
|
|
// horizontalSwipeOffset from GenericData — a completely different layout than
|
|
// the default material shader's genericData.
|
|
{
|
|
auto buffer = gr_get_uniform_buffer(uniform_block_type::GenericData, 1,
|
|
sizeof(graphics::generic_data::rocketui_data));
|
|
auto* data = buffer.aligner().addTypedElement<graphics::generic_data::rocketui_data>();
|
|
|
|
data->projMatrix = gr_projection_matrix;
|
|
|
|
const vec2d& offset = material_info->get_offset();
|
|
data->offset = offset;
|
|
data->textured = material_info->is_textured() ? 1 : 0;
|
|
data->baseMapIndex = 0; // Vulkan texture array: always layer 0
|
|
data->horizontalSwipeOffset = material_info->get_horizontal_swipe();
|
|
|
|
buffer.submitData();
|
|
gr_bind_uniform_buffer(uniform_block_type::GenericData, buffer.getBufferOffset(0),
|
|
sizeof(graphics::generic_data::rocketui_data), buffer.bufferHandle());
|
|
}
|
|
|
|
// Matrices UBO is still needed for descriptor set completeness
|
|
gr_matrix_set_uniforms();
|
|
|
|
auto* drawManager = getDrawManager();
|
|
drawManager->renderRocketPrimitives(material_info, prim_type, layout, n_indices, vertex_buffer, index_buffer);
|
|
|
|
gr_end_2d_matrix();
|
|
}
|
|
|
|
void vulkan_calculate_irrmap()
|
|
{
|
|
if (ENVMAP < 0 || gr_screen.irrmap_render_target < 0) {
|
|
return;
|
|
}
|
|
|
|
auto* renderer = getRendererInstance();
|
|
auto* stateTracker = getStateTracker();
|
|
auto* texManager = getTextureManager();
|
|
auto* descManager = getDescriptorManager();
|
|
auto* bufferManager = getBufferManager();
|
|
auto* pipelineManager = getPipelineManager();
|
|
if (!renderer || !stateTracker || !texManager || !descManager || !bufferManager || !pipelineManager) {
|
|
return;
|
|
}
|
|
|
|
// Get envmap cubemap view
|
|
if (!texManager->ensureCubemapUploaded(ENVMAP)) {
|
|
return;
|
|
}
|
|
auto* envSlot = bm_get_slot(ENVMAP, true);
|
|
if (!envSlot || !envSlot->gr_info) {
|
|
return;
|
|
}
|
|
auto* envTs = static_cast<tcache_slot_vulkan*>(envSlot->gr_info);
|
|
// Both the render-target and static-file cubemap upload paths store the
|
|
// cube-sampling view in imageView, so that's what must be used here regardless
|
|
// of isCubemap.
|
|
vk::ImageView envmapView = envTs->imageView;
|
|
if (!envmapView) {
|
|
return;
|
|
}
|
|
|
|
// Get irrmap render target (cubemap with per-face framebuffers)
|
|
auto* irrSlot = bm_get_slot(gr_screen.irrmap_render_target, true);
|
|
if (!irrSlot || !irrSlot->gr_info) {
|
|
return;
|
|
}
|
|
auto* irrTs = static_cast<tcache_slot_vulkan*>(irrSlot->gr_info);
|
|
if (!irrTs->isCubemap || !irrTs->renderPass) {
|
|
return;
|
|
}
|
|
|
|
vk::CommandBuffer cmd = stateTracker->getCommandBuffer();
|
|
|
|
// Create pipeline for irradiance map generation
|
|
PipelineConfig config;
|
|
config.shaderType = SDR_TYPE_IRRADIANCE_MAP_GEN;
|
|
config.vertexLayoutHash = 0;
|
|
config.primitiveType = PRIM_TYPE_TRIS;
|
|
config.depthMode = ZBUFFER_TYPE_NONE;
|
|
config.blendMode = ALPHA_BLEND_NONE;
|
|
config.cullEnabled = false;
|
|
config.depthWriteEnabled = false;
|
|
config.renderPass = irrTs->renderPass;
|
|
|
|
vertex_layout emptyLayout;
|
|
vk::Pipeline pipeline = pipelineManager->getPipeline(config, emptyLayout);
|
|
if (!pipeline) {
|
|
nprintf(("vulkan", "vulkan_calculate_irrmap: Failed to get pipeline!\n"));
|
|
return;
|
|
}
|
|
|
|
vk::PipelineLayout pipelineLayout = pipelineManager->getPipelineLayout();
|
|
|
|
// Create a small host-visible UBO for the 6 face indices
|
|
// minUniformBufferOffsetAlignment is typically 256 bytes
|
|
const uint32_t UBO_SLOT_SIZE = 256; // Safe alignment for all GPUs
|
|
const uint32_t UBO_TOTAL_SIZE = 6 * UBO_SLOT_SIZE;
|
|
|
|
vk::Device device = bufferManager->getDevice();
|
|
auto* memManager = getMemoryManager();
|
|
|
|
vk::BufferCreateInfo uboBufInfo;
|
|
uboBufInfo.size = UBO_TOTAL_SIZE;
|
|
uboBufInfo.usage = vk::BufferUsageFlagBits::eUniformBuffer;
|
|
uboBufInfo.sharingMode = vk::SharingMode::eExclusive;
|
|
|
|
vk::Buffer faceUBO;
|
|
VulkanAllocation faceUBOAlloc;
|
|
try {
|
|
faceUBO = device.createBuffer(uboBufInfo);
|
|
} catch (const vk::SystemError& e) {
|
|
nprintf(("vulkan", "vulkan_calculate_irrmap: Failed to create face UBO: %s\n", e.what()));
|
|
return;
|
|
}
|
|
|
|
if (!memManager->allocateBufferMemory(faceUBO, MemoryUsage::CpuToGpu, faceUBOAlloc)) {
|
|
device.destroyBuffer(faceUBO);
|
|
return;
|
|
}
|
|
|
|
// Map and write face indices
|
|
auto* mapped = static_cast<uint8_t*>(memManager->mapMemory(faceUBOAlloc));
|
|
if (!mapped) {
|
|
device.destroyBuffer(faceUBO);
|
|
memManager->freeAllocation(faceUBOAlloc);
|
|
return;
|
|
}
|
|
memset(mapped, 0, UBO_TOTAL_SIZE);
|
|
for (int i = 0; i < 6; i++) {
|
|
*reinterpret_cast<int*>(mapped + (i * UBO_SLOT_SIZE)) = i;
|
|
}
|
|
// Flush before unmap — CpuToGpu memory is not guaranteed coherent, so without
|
|
// this the GPU could sample stale face indices. (No-op on coherent memory.)
|
|
memManager->flushMemory(faceUBOAlloc, 0, UBO_TOTAL_SIZE);
|
|
memManager->unmapMemory(faceUBOAlloc);
|
|
|
|
// This buffer is recreated per call (and queued for deletion at the end).
|
|
// vulkan_calculate_irrmap runs only on env-map (re)generation, not per frame,
|
|
// so the cold allocation isn't worth caching as renderer-lifetime state — and a
|
|
// function-lifetime static VkBuffer would dangle past device destruction.
|
|
|
|
vk::Extent2D irrExtent(irrTs->width, irrTs->height);
|
|
|
|
// End the swap chain pass only after the early returns above, which never resume it
|
|
cmd.endRenderPass();
|
|
|
|
for (size_t face = 0; face < irrTs->cubeFaceFramebuffers.size(); face++) {
|
|
vk::Framebuffer fb = irrTs->cubeFaceFramebuffers[face];
|
|
if (!fb) {
|
|
continue;
|
|
}
|
|
|
|
// Begin render pass for this face (loadOp=eClear, finalLayout=eShaderReadOnlyOptimal)
|
|
vk::RenderPassBeginInfo rpBegin;
|
|
rpBegin.renderPass = irrTs->renderPass;
|
|
rpBegin.framebuffer = fb;
|
|
rpBegin.renderArea.offset = vk::Offset2D(0, 0);
|
|
rpBegin.renderArea.extent = irrExtent;
|
|
|
|
vk::ClearValue clearValue;
|
|
clearValue.color.setFloat32({0.0f, 0.0f, 0.0f, 1.0f});
|
|
rpBegin.clearValueCount = 1;
|
|
rpBegin.pClearValues = &clearValue;
|
|
|
|
cmd.beginRenderPass(rpBegin, vk::SubpassContents::eInline);
|
|
cmd.bindPipeline(vk::PipelineBindPoint::eGraphics, pipeline);
|
|
|
|
// Set viewport and scissor
|
|
vk::Viewport viewport;
|
|
viewport.x = 0.0f;
|
|
viewport.y = 0.0f;
|
|
viewport.width = static_cast<float>(irrExtent.width);
|
|
viewport.height = static_cast<float>(irrExtent.height);
|
|
viewport.minDepth = 0.0f;
|
|
viewport.maxDepth = 1.0f;
|
|
cmd.setViewport(0, viewport);
|
|
|
|
vk::Rect2D scissor;
|
|
scissor.offset = vk::Offset2D(0, 0);
|
|
scissor.extent = irrExtent;
|
|
cmd.setScissor(0, scissor);
|
|
|
|
DescriptorWriter writer;
|
|
writer.reset(device, descManager->getFallbacks());
|
|
|
|
// Set 0: Global (all fallback)
|
|
vk::DescriptorSet globalSet = descManager->allocateFrameSet(DescriptorSetIndex::Global);
|
|
Assert(globalSet);
|
|
writer.writeSet(DescriptorSetIndex::Global, globalSet);
|
|
|
|
// Set 1: Material (envmap cubemap at element 0 of texture array)
|
|
vk::DescriptorSet materialSet = descManager->allocateFrameSet(DescriptorSetIndex::Material);
|
|
Assert(materialSet);
|
|
writer.writeSet(DescriptorSetIndex::Material, materialSet);
|
|
{
|
|
std::array<vk::DescriptorImageInfo, VulkanDescriptorManager::MAX_TEXTURE_BINDINGS> texImages;
|
|
// irrmap-f.sdr declares this binding as samplerCube, so every element needs a cube view
|
|
texImages.fill(descManager->getFallbacks().textureCube);
|
|
texImages[0].imageView = envmapView;
|
|
writer.setImageArray(MaterialBinding::TextureArray, texImages);
|
|
}
|
|
|
|
// Set 2: PerDraw (face UBO at binding 0)
|
|
vk::DescriptorSet perDrawSet = descManager->allocateFrameSet(DescriptorSetIndex::PerDraw);
|
|
Assert(perDrawSet);
|
|
writer.writeSet(DescriptorSetIndex::PerDraw, perDrawSet);
|
|
writer.setBuffer(PerDrawBinding::GenericData, {faceUBO,
|
|
static_cast<vk::DeviceSize>(face) * UBO_SLOT_SIZE, UBO_SLOT_SIZE});
|
|
writer.flush();
|
|
|
|
// Bind all descriptor sets
|
|
const vk::DescriptorSet sets[] = {globalSet, materialSet, perDrawSet};
|
|
writer.bindSets(cmd, pipelineLayout, DescriptorSetIndex::Global, sets);
|
|
|
|
// Draw fullscreen triangle
|
|
cmd.draw(3, 1, 0, 0);
|
|
cmd.endRenderPass();
|
|
}
|
|
|
|
// Queue UBO for deferred destruction (safe to destroy after frame submission)
|
|
getDeletionQueue()->queueBuffer(faceUBO, faceUBOAlloc);
|
|
|
|
// This path renders each face directly rather than going through
|
|
// bm_set_render_target()/endRenderTarget(), so the mip chain that
|
|
// deferred-f.sdr's implicit-LOD `texture(sIrrmap, ...)` can reach
|
|
// (high-frequency normals/silhouettes push the derivative-based LOD up)
|
|
// would otherwise be left uninitialized above mip 0.
|
|
if (irrTs->mipLevels > 1) {
|
|
ImageBarrier2 barrier;
|
|
barrier.image = irrTs->image;
|
|
barrier.levelCount = 1;
|
|
barrier.layerCount = 6;
|
|
barrier.oldLayout = vk::ImageLayout::eShaderReadOnlyOptimal;
|
|
barrier.newLayout = vk::ImageLayout::eTransferSrcOptimal;
|
|
barrier.srcStage = vk::PipelineStageFlagBits2::eColorAttachmentOutput;
|
|
barrier.srcAccess = vk::AccessFlagBits2::eColorAttachmentWrite;
|
|
barrier.dstStage = vk::PipelineStageFlagBits2::eBlit;
|
|
barrier.dstAccess = vk::AccessFlagBits2::eTransferRead;
|
|
|
|
cmdImageBarrier(cmd, barrier);
|
|
|
|
vulkan_generate_mipmap_chain(cmd, irrTs->image, irrTs->width, irrTs->height, irrTs->mipLevels, 6);
|
|
}
|
|
|
|
// Resume the swap chain pass (irrmap is always called before scene rendering begins)
|
|
renderer->resumeSwapChainPass();
|
|
|
|
nprintf(("vulkan", "vulkan_calculate_irrmap: Generated irradiance cubemap (%ux%u)\n", irrTs->width, irrTs->height));
|
|
}
|
|
|
|
} // namespace graphics::vulkan
|
|
|