mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
graphics: handle default textures in high level code.
Previously each backend had to set up default textures with its own code, which needs some care for it to be robust.
This commit is contained in:
@@ -524,7 +524,7 @@ void Shader::addImage(const spirv_cross::CompilerMSL &msl, const spirv_cross::Re
|
||||
|
||||
if (u.baseType == UNIFORM_SAMPLER)
|
||||
{
|
||||
auto tex = Graphics::getInstance()->getDefaultTexture(u.textureType);
|
||||
auto tex = Graphics::getInstance()->getDefaultTexture(u.textureType, u.dataBaseType);
|
||||
for (int i = 0; i < u.count; i++)
|
||||
{
|
||||
tex->retain();
|
||||
@@ -538,8 +538,15 @@ void Shader::addImage(const spirv_cross::CompilerMSL &msl, const spirv_cross::Re
|
||||
}
|
||||
else if (u.baseType == UNIFORM_STORAGETEXTURE)
|
||||
{
|
||||
Texture *tex = nullptr;
|
||||
if ((u.access & ACCESS_WRITE) == 0)
|
||||
tex = Graphics::getInstance()->getDefaultTexture(u.textureType, u.dataBaseType);
|
||||
for (int i = 0; i < u.count; i++)
|
||||
u.textures[i] = nullptr;
|
||||
{
|
||||
if (tex)
|
||||
tex->retain();
|
||||
u.textures[i] = tex;
|
||||
}
|
||||
}
|
||||
|
||||
uniforms[u.name] = u;
|
||||
@@ -983,7 +990,7 @@ void Shader::sendTextures(const UniformInfo *info, love::graphics::Texture **tex
|
||||
else
|
||||
{
|
||||
auto gfx = Graphics::getInstance();
|
||||
tex = gfx->getDefaultTexture(info->textureType);
|
||||
tex = gfx->getDefaultTexture(info->textureType, info->dataBaseType);
|
||||
}
|
||||
|
||||
tex->retain();
|
||||
|
||||
Reference in New Issue
Block a user