Merge commit '6bfa3dc402' into chore/split-mega-switch-to-map

This commit is contained in:
Paul 2026-03-25 07:27:03 +03:00
commit fa2e8ad0fe
17 changed files with 418 additions and 97 deletions

View file

@ -97,6 +97,7 @@ private:
void spawnPlayerCharacter();
std::string getPlayerModelPath() const;
static const char* mapIdToName(uint32_t mapId);
static const char* mapDisplayName(uint32_t mapId);
void loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float z);
void buildFactionHostilityMap(uint8_t playerRace);
pipeline::M2Model loadCreatureM2Sync(const std::string& m2Path);

View file

@ -668,6 +668,7 @@ private:
VkCommandBuffer secondaryCmds_[NUM_SECONDARIES][MAX_FRAMES] = {};
bool parallelRecordingEnabled_ = false; // set true after pools/buffers created
bool endFrameInlineMode_ = false; // true when endFrame switched to INLINE render pass
bool createSecondaryCommandResources();
void destroySecondaryCommandResources();
VkCommandBuffer beginSecondary(uint32_t secondaryIndex);

View file

@ -8,6 +8,8 @@
#include <vector>
#include <functional>
#include <cstdint>
#include <unordered_map>
#include <mutex>
namespace wowee {
namespace rendering {
@ -76,6 +78,7 @@ public:
bool isNvidiaGpu() const { return gpuVendorId_ == 0x10DE; }
VkQueue getGraphicsQueue() const { return graphicsQueue; }
uint32_t getGraphicsQueueFamily() const { return graphicsQueueFamily; }
bool hasDedicatedTransferQueue() const { return hasDedicatedTransfer_; }
VmaAllocator getAllocator() const { return allocator; }
VkSurfaceKHR getSurface() const { return surface; }
VkPipelineCache getPipelineCache() const { return pipelineCache_; }
@ -119,6 +122,18 @@ public:
VkImageView getDepthResolveImageView() const { return depthResolveImageView; }
VkImageView getDepthImageView() const { return depthImageView; }
// Sampler cache: returns a shared VkSampler matching the given create info.
// Callers must NOT destroy the returned sampler — it is owned by VkContext.
// Automatically clamps anisotropy if the device doesn't support it.
VkSampler getOrCreateSampler(const VkSamplerCreateInfo& info);
// Whether the physical device supports sampler anisotropy.
bool isSamplerAnisotropySupported() const { return samplerAnisotropySupported_; }
// Global sampler cache accessor (set during VkContext::initialize, cleared on shutdown).
// Used by VkTexture and other code that only has a VkDevice handle.
static VkContext* globalInstance() { return sInstance_; }
// UI texture upload: creates a Vulkan texture from RGBA data and returns
// a VkDescriptorSet suitable for use as ImTextureID.
// The caller does NOT need to free the result — resources are tracked and
@ -161,6 +176,12 @@ private:
uint32_t graphicsQueueFamily = 0;
uint32_t presentQueueFamily = 0;
// Dedicated transfer queue (second queue from same graphics family)
VkQueue transferQueue_ = VK_NULL_HANDLE;
VkCommandPool transferCommandPool_ = VK_NULL_HANDLE;
bool hasDedicatedTransfer_ = false;
uint32_t graphicsQueueFamilyQueueCount_ = 1; // queried in selectPhysicalDevice
// Swapchain
VkSwapchainKHR swapchain = VK_NULL_HANDLE;
VkFormat swapchainFormat = VK_FORMAT_UNDEFINED;
@ -239,6 +260,13 @@ private:
};
std::vector<UiTexture> uiTextures_;
// Sampler cache — deduplicates VkSamplers by configuration hash.
std::mutex samplerCacheMutex_;
std::unordered_map<uint64_t, VkSampler> samplerCache_;
bool samplerAnisotropySupported_ = false;
static VkContext* sInstance_;
#ifndef NDEBUG
bool enableValidation = true;
#else

View file

@ -73,6 +73,7 @@ private:
bool hasDepth_ = false;
VkSampleCountFlagBits msaaSamples_ = VK_SAMPLE_COUNT_1_BIT;
VkSampler sampler_ = VK_NULL_HANDLE;
bool ownsSampler_ = true;
VkRenderPass renderPass_ = VK_NULL_HANDLE;
VkFramebuffer framebuffer_ = VK_NULL_HANDLE;
};

View file

@ -72,6 +72,7 @@ private:
AllocatedImage image_{};
VkSampler sampler_ = VK_NULL_HANDLE;
uint32_t mipLevels_ = 1;
bool ownsSampler_ = true; // false when sampler comes from VkContext cache
};
} // namespace rendering