- Add complete BgfxRenderer module structure (24 files) - RHI abstraction layer (no bgfx:: exposed outside BgfxDevice.cpp) - Frame system with lock-free allocator - RenderGraph with ClearPass, SpritePass, DebugPass - SceneCollector for IIO message parsing (render:* topics) - ResourceCache with thread-safe texture/shader caching - Full IModule integration (config via IDataNode, comm via IIO) - CMake with FetchContent for bgfx - Windows build script (build_renderer.bat) - Documentation (README.md, USER_GUIDE.md, PLAN_BGFX_RENDERER.md) - Updated .gitignore for Windows builds 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include "../RHI/RHITypes.h"
|
|
#include <unordered_map>
|
|
#include <string>
|
|
#include <shared_mutex>
|
|
|
|
namespace grove {
|
|
|
|
namespace rhi { class IRHIDevice; }
|
|
|
|
// ============================================================================
|
|
// Resource Cache - Thread-safe texture and shader cache
|
|
// ============================================================================
|
|
|
|
class ResourceCache {
|
|
public:
|
|
ResourceCache() = default;
|
|
|
|
// Thread-safe resource access (returns invalid handle if not found)
|
|
rhi::TextureHandle getTexture(const std::string& path) const;
|
|
rhi::ShaderHandle getShader(const std::string& name) const;
|
|
|
|
// Loading (called from main thread)
|
|
rhi::TextureHandle loadTexture(rhi::IRHIDevice& device, const std::string& path);
|
|
rhi::ShaderHandle loadShader(rhi::IRHIDevice& device, const std::string& name,
|
|
const void* vsData, uint32_t vsSize,
|
|
const void* fsData, uint32_t fsSize);
|
|
|
|
// Check if resource exists
|
|
bool hasTexture(const std::string& path) const;
|
|
bool hasShader(const std::string& name) const;
|
|
|
|
// Cleanup
|
|
void clear(rhi::IRHIDevice& device);
|
|
|
|
// Stats
|
|
size_t getTextureCount() const;
|
|
size_t getShaderCount() const;
|
|
|
|
private:
|
|
std::unordered_map<std::string, rhi::TextureHandle> m_textures;
|
|
std::unordered_map<std::string, rhi::ShaderHandle> m_shaders;
|
|
mutable std::shared_mutex m_mutex;
|
|
};
|
|
|
|
} // namespace grove
|