fix: prevent selection outline crash on first selection

This commit is contained in:
2026-04-02 20:45:51 +08:00
parent 9ce779da43
commit 84e1ba3600
2 changed files with 55 additions and 13 deletions

View File

@@ -17,6 +17,7 @@
#include <array>
#include <cstdint>
#include <optional>
#include <vector>
namespace XCEngine {
@@ -31,7 +32,12 @@ struct ObjectIdOutlineStyle {
class BuiltinObjectIdOutlinePass {
public:
BuiltinObjectIdOutlinePass();
~BuiltinObjectIdOutlinePass() = default;
BuiltinObjectIdOutlinePass(const BuiltinObjectIdOutlinePass&) = delete;
BuiltinObjectIdOutlinePass& operator=(const BuiltinObjectIdOutlinePass&) = delete;
BuiltinObjectIdOutlinePass(BuiltinObjectIdOutlinePass&&) = delete;
BuiltinObjectIdOutlinePass& operator=(BuiltinObjectIdOutlinePass&&) = delete;
static constexpr uint32_t kMaxSelectedObjectCount = 256u;
@@ -55,6 +61,8 @@ private:
bool EnsureInitialized(const RenderContext& renderContext);
bool CreateResources(const RenderContext& renderContext);
void DestroyResources();
bool HasCreatedResources() const;
void ResetState();
RHI::RHIDevice* m_device = nullptr;
RHI::RHIType m_backendType = RHI::RHIType::D3D12;
@@ -64,7 +72,7 @@ private:
RHI::RHIDescriptorSet* m_constantSet = nullptr;
RHI::RHIDescriptorPool* m_texturePool = nullptr;
RHI::RHIDescriptorSet* m_textureSet = nullptr;
Resources::ResourceHandle<Resources::Shader> m_builtinObjectIdOutlineShader;
std::optional<Resources::ResourceHandle<Resources::Shader>> m_builtinObjectIdOutlineShader;
};
} // namespace Passes