mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
Fix MSAA crash by deferring change to between frames, fix M2 GO orientation
MSAA change was called mid-frame from settings UI, destroying the render pass and framebuffers while the command buffer was still recording. Now deferred via pendingMsaaSamples_ flag, applied in beginFrame() before any GPU state. Also add +180° to M2 game object orientation to fix facing direction.
This commit is contained in:
parent
325254dfcb
commit
ebd0084c22
3 changed files with 21 additions and 1 deletions
|
|
@ -244,6 +244,9 @@ public:
|
|||
void setMsaaSamples(VkSampleCountFlagBits samples);
|
||||
|
||||
private:
|
||||
void applyMsaaChange();
|
||||
VkSampleCountFlagBits pendingMsaaSamples_ = VK_SAMPLE_COUNT_1_BIT;
|
||||
bool msaaChangePending_ = false;
|
||||
void renderShadowPass();
|
||||
glm::mat4 computeLightSpaceMatrix();
|
||||
|
||||
|
|
|
|||
|
|
@ -5505,6 +5505,7 @@ void Application::spawnOnlineGameObject(uint64_t guid, uint32_t entry, uint32_t
|
|||
|
||||
glm::vec3 renderPos = core::coords::canonicalToRender(glm::vec3(x, y, z));
|
||||
const float renderYawWmo = orientation;
|
||||
const float renderYawM2go = orientation + glm::radians(180.0f);
|
||||
|
||||
bool loadedAsWmo = false;
|
||||
if (isWmo) {
|
||||
|
|
@ -5670,7 +5671,7 @@ void Application::spawnOnlineGameObject(uint64_t guid, uint32_t entry, uint32_t
|
|||
}
|
||||
|
||||
uint32_t instanceId = m2Renderer->createInstance(modelId, renderPos,
|
||||
glm::vec3(0.0f, 0.0f, renderYawWmo), 1.0f);
|
||||
glm::vec3(0.0f, 0.0f, renderYawM2go), 1.0f);
|
||||
if (instanceId == 0) {
|
||||
LOG_WARNING("Failed to create gameobject instance for guid 0x", std::hex, guid, std::dec);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -730,6 +730,17 @@ void Renderer::setMsaaSamples(VkSampleCountFlagBits samples) {
|
|||
VkSampleCountFlagBits maxSamples = vkCtx->getMaxUsableSampleCount();
|
||||
if (samples > maxSamples) samples = maxSamples;
|
||||
|
||||
if (samples == vkCtx->getMsaaSamples()) return;
|
||||
|
||||
// Defer to between frames — cannot destroy render pass/framebuffers mid-frame
|
||||
pendingMsaaSamples_ = samples;
|
||||
msaaChangePending_ = true;
|
||||
}
|
||||
|
||||
void Renderer::applyMsaaChange() {
|
||||
VkSampleCountFlagBits samples = pendingMsaaSamples_;
|
||||
msaaChangePending_ = false;
|
||||
|
||||
VkSampleCountFlagBits current = vkCtx->getMsaaSamples();
|
||||
if (samples == current) return;
|
||||
|
||||
|
|
@ -794,6 +805,11 @@ void Renderer::setMsaaSamples(VkSampleCountFlagBits samples) {
|
|||
void Renderer::beginFrame() {
|
||||
if (!vkCtx) return;
|
||||
|
||||
// Apply deferred MSAA change between frames (before any rendering state is used)
|
||||
if (msaaChangePending_) {
|
||||
applyMsaaChange();
|
||||
}
|
||||
|
||||
// Handle swapchain recreation if needed
|
||||
if (vkCtx->isSwapchainDirty()) {
|
||||
vkCtx->recreateSwapchain(window->getWidth(), window->getHeight());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue