mirror of
https://github.com/love2d/love.git
synced 2026-08-18 03:34:23 +02:00
Fix hash map collisions when setting canvases.
This commit is contained in:
@@ -40,6 +40,8 @@
|
||||
#include "Canvas.h"
|
||||
#include "Shader.h"
|
||||
|
||||
#include "libraries/xxHash/xxhash.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
|
||||
@@ -110,8 +112,30 @@ public:
|
||||
|
||||
Shader::Language getShaderLanguageTarget() const override;
|
||||
|
||||
// Internal use.
|
||||
void cleanupCanvas(Canvas *canvas);
|
||||
|
||||
private:
|
||||
|
||||
struct CachedFBOHasher
|
||||
{
|
||||
size_t operator() (const RenderTargets &rts) const
|
||||
{
|
||||
RenderTarget hashtargets[MAX_COLOR_RENDER_TARGETS + 1];
|
||||
int hashcount = 0;
|
||||
|
||||
for (size_t i = 0; i < rts.colors.size(); i++)
|
||||
hashtargets[hashcount++] = rts.colors[i];
|
||||
|
||||
if (rts.depthStencil.canvas != nullptr)
|
||||
hashtargets[hashcount++] = rts.depthStencil;
|
||||
else if (rts.temporaryRTFlags != 0)
|
||||
hashtargets[hashcount++] = RenderTarget(nullptr, -1, rts.temporaryRTFlags);
|
||||
|
||||
return XXH32(hashtargets, sizeof(RenderTarget) * hashcount, 0);
|
||||
}
|
||||
};
|
||||
|
||||
love::graphics::ShaderStage *newShaderStageInternal(ShaderStage::StageType stage, const std::string &cachekey, const std::string &source, bool gles) override;
|
||||
love::graphics::Shader *newShaderInternal(love::graphics::ShaderStage *vertex, love::graphics::ShaderStage *pixel) override;
|
||||
love::graphics::StreamBuffer *newStreamBuffer(BufferType type, size_t size) override;
|
||||
@@ -125,7 +149,7 @@ private:
|
||||
|
||||
void setDebug(bool enable);
|
||||
|
||||
std::unordered_map<uint32, GLuint> framebufferObjects;
|
||||
std::unordered_map<RenderTargets, GLuint, CachedFBOHasher> framebufferObjects;
|
||||
bool windowHasStencil;
|
||||
GLuint mainVAO;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user