fix(rendering): defer model buffer destruction and per-frame FXAA descriptors

CharacterRenderer::destroyModelGPU now defers vertex/index buffer
destruction when replacing models mid-stream, preventing use-after-free
on AMD RADV. FXAA descriptor sets are now per-frame to eliminate
write-read races between in-flight command buffers. Water reflection
descriptor update narrowed to current frame only.
This commit is contained in:
Kelsi 2026-04-03 19:17:55 -07:00
parent e19bf76d88
commit 40e72d535e
5 changed files with 71 additions and 43 deletions

View file

@ -208,7 +208,7 @@ private:
void calculateBoneMatrices(CharacterInstance& instance);
glm::mat4 getBoneTransform(const pipeline::M2Bone& bone, float time, int sequenceIndex);
glm::mat4 getModelMatrix(const CharacterInstance& instance) const;
void destroyModelGPU(M2ModelGPU& gpuModel);
void destroyModelGPU(M2ModelGPU& gpuModel, bool defer = false);
void destroyInstanceBones(CharacterInstance& inst, bool defer = false);
// Keyframe interpolation helpers

View file

@ -182,7 +182,9 @@ private:
VkPipelineLayout pipelineLayout = VK_NULL_HANDLE;
VkDescriptorSetLayout descSetLayout = VK_NULL_HANDLE;
VkDescriptorPool descPool = VK_NULL_HANDLE;
VkDescriptorSet descSet = VK_NULL_HANDLE;
// Per-frame descriptor sets to avoid race with in-flight command buffers
static constexpr uint32_t DESC_SET_COUNT = 2; // matches MAX_FRAMES_IN_FLIGHT
VkDescriptorSet descSet[DESC_SET_COUNT] = {};
};
FXAAState fxaa_;
bool initFXAAResources();