1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-16 18:01:40 +00:00

Add more texture size limit checks

closes #16014
This commit is contained in:
sfan5 2025-08-11 15:29:58 +02:00
parent fd3588d49c
commit 6da927a548
3 changed files with 15 additions and 3 deletions

View file

@ -163,7 +163,7 @@ public:
OriginalSize = size; OriginalSize = size;
Size = OriginalSize; Size = OriginalSize;
if (Size.Width == 0 || Size.Height == 0) { if (core::min_(Size.Width, Size.Height) == 0 || core::max_(Size.Width, Size.Height) > Driver->MaxTextureSize) {
char buf[64]; char buf[64];
snprintf_irr(buf, sizeof(buf), "%dx%d", Size.Width, Size.Height); snprintf_irr(buf, sizeof(buf), "%dx%d", Size.Width, Size.Height);
os::Printer::log("Invalid size for render target", buf, ELL_ERROR); os::Printer::log("Invalid size for render target", buf, ELL_ERROR);

View file

@ -136,6 +136,14 @@ bool TextureBuffer::ensureTexture(video::ITexture **texture, const TextureDefini
return false; return false;
} }
const core::dimension2du max_size = m_driver->getMaxTextureSize();
if (size.Width > max_size.Width || size.Height > max_size.Height) {
errorstream << "Failed to create texture \"" << definition.name
<< "\": exceeds limit " << size.Width << "x" << size.Height
<< std::endl;
return false;
}
if (definition.clear) { if (definition.clear) {
// We're not able to clear a render target texture // We're not able to clear a render target texture
// We're not able to create a normal texture with MSAA // We're not able to create a normal texture with MSAA

View file

@ -93,8 +93,8 @@ RenderStep *addPostProcessing(RenderPipeline *pipeline, RenderStep *previousStep
video::ECOLOR_FORMAT depth_format = selectDepthFormat(driver); video::ECOLOR_FORMAT depth_format = selectDepthFormat(driver);
verbosestream << "addPostProcessing(): color = " verbosestream << "addPostProcessing(): color = "
<< video::ColorFormatNames[color_format] << " depth = " << video::ColorFormatName(color_format) << " depth = "
<< video::ColorFormatNames[depth_format] << std::endl; << video::ColorFormatName(depth_format) << std::endl;
// init post-processing buffer // init post-processing buffer
static const u8 TEXTURE_COLOR = 0; static const u8 TEXTURE_COLOR = 0;
@ -134,6 +134,10 @@ RenderStep *addPostProcessing(RenderPipeline *pipeline, RenderStep *previousStep
const bool enable_ssaa = antialiasing == "ssaa"; const bool enable_ssaa = antialiasing == "ssaa";
const bool enable_fxaa = antialiasing == "fxaa"; const bool enable_fxaa = antialiasing == "fxaa";
verbosestream << "addPostProcessing(): AA = "
<< (enable_msaa ? "msaa" : enable_ssaa ? "ssaa" : enable_fxaa ? "fxaa" : "none")
<< " " << antialiasing_scale << "x" << std::endl;
// Super-sampling is simply rendering into a larger texture. // Super-sampling is simply rendering into a larger texture.
// Downscaling is done by the final step when rendering to the screen. // Downscaling is done by the final step when rendering to the screen.
if (enable_ssaa) { if (enable_ssaa) {