mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
vulkan: fix some crashes relating to memory mngmt
This commit is contained in:
@@ -424,8 +424,6 @@ void Graphics::drawQuads(int start, int count, const VertexAttributes& attribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::setColor(Colorf c) {
|
void Graphics::setColor(Colorf c) {
|
||||||
flushBatchedDraws();
|
|
||||||
|
|
||||||
c.r = std::min(std::max(c.r, 0.0f), 1.0f);
|
c.r = std::min(std::max(c.r, 0.0f), 1.0f);
|
||||||
c.g = std::min(std::max(c.g, 0.0f), 1.0f);
|
c.g = std::min(std::max(c.g, 0.0f), 1.0f);
|
||||||
c.b = std::min(std::max(c.b, 0.0f), 1.0f);
|
c.b = std::min(std::max(c.b, 0.0f), 1.0f);
|
||||||
|
|||||||
@@ -346,7 +346,10 @@ const Shader::UniformInfo* Shader::getUniformInfo(BuiltinUniform builtin) const
|
|||||||
|
|
||||||
void Shader::sendTextures(const UniformInfo* info, graphics::Texture** textures, int count) {
|
void Shader::sendTextures(const UniformInfo* info, graphics::Texture** textures, int count) {
|
||||||
for (unsigned i = 0; i < count; i++) {
|
for (unsigned i = 0; i < count; i++) {
|
||||||
|
auto oldTexture = info->textures[i];
|
||||||
info->textures[i] = textures[i];
|
info->textures[i] = textures[i];
|
||||||
|
info->textures[i]->retain();
|
||||||
|
oldTexture->release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,6 +619,7 @@ void Shader::compileShaders() {
|
|||||||
auto tex = vgfx->getDefaultTexture();
|
auto tex = vgfx->getDefaultTexture();
|
||||||
for (int i = 0; i < info.count; i++) {
|
for (int i = 0; i < info.count; i++) {
|
||||||
info.textures[i] = tex;
|
info.textures[i] = tex;
|
||||||
|
tex->retain();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fixme
|
// fixme
|
||||||
@@ -696,12 +700,22 @@ void Shader::setVideoTextures(graphics::Texture* ytexture, graphics::Texture* cb
|
|||||||
// if the shader doesn't actually use these textures they might get optimized out
|
// if the shader doesn't actually use these textures they might get optimized out
|
||||||
// in that case this function becomes a noop.
|
// in that case this function becomes a noop.
|
||||||
if (builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_Y] != nullptr) {
|
if (builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_Y] != nullptr) {
|
||||||
|
auto oldTexture = builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_Y]->textures[0];
|
||||||
|
ytexture->retain();
|
||||||
|
oldTexture->release();
|
||||||
builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_Y]->textures[0] = ytexture;
|
builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_Y]->textures[0] = ytexture;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_CB] != nullptr) {
|
if (builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_CB] != nullptr) {
|
||||||
|
auto oldTexture = builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_CB]->textures[0];
|
||||||
|
cbtexture->retain();
|
||||||
|
oldTexture->release();
|
||||||
builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_CB]->textures[0] = cbtexture;
|
builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_CB]->textures[0] = cbtexture;
|
||||||
}
|
}
|
||||||
if (builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_CR] != nullptr) {
|
if (builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_CR] != nullptr) {
|
||||||
|
auto oldTexture = builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_CR]->textures[0];
|
||||||
|
crtexture->retain();
|
||||||
|
oldTexture->release();
|
||||||
builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_CR]->textures[0] = crtexture;
|
builtinUniformInfo[BUILTIN_TEXTURE_VIDEO_CR]->textures[0] = crtexture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -719,6 +733,9 @@ void Shader::setMainTex(graphics::Texture* texture) {
|
|||||||
// if the shader doesn't actually use the texture it might get optimized out
|
// if the shader doesn't actually use the texture it might get optimized out
|
||||||
// in that case this function becomes a noop.
|
// in that case this function becomes a noop.
|
||||||
if (builtinUniformInfo[BUILTIN_TEXTURE_MAIN] != nullptr) {
|
if (builtinUniformInfo[BUILTIN_TEXTURE_MAIN] != nullptr) {
|
||||||
|
auto oldTexture = builtinUniformInfo[BUILTIN_TEXTURE_MAIN]->textures[0];
|
||||||
|
texture->retain();
|
||||||
|
oldTexture->release();
|
||||||
builtinUniformInfo[BUILTIN_TEXTURE_MAIN]->textures[0] = texture;
|
builtinUniformInfo[BUILTIN_TEXTURE_MAIN]->textures[0] = texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user