diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index 13e9ff7a0c..9737ceeac8 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -755,6 +755,7 @@ + @@ -1410,6 +1411,7 @@ + diff --git a/Source/Core/VideoCommon/CMakeLists.txt b/Source/Core/VideoCommon/CMakeLists.txt index 1a81b1a5f7..d3b68ba95c 100644 --- a/Source/Core/VideoCommon/CMakeLists.txt +++ b/Source/Core/VideoCommon/CMakeLists.txt @@ -150,6 +150,8 @@ add_library(videocommon RenderState.h Resources/CustomResourceManager.cpp Resources/CustomResourceManager.h + Resources/InvalidTextures.cpp + Resources/InvalidTextures.h Resources/Resource.cpp Resources/Resource.h Resources/TextureDataResource.cpp diff --git a/Source/Core/VideoCommon/Resources/InvalidTextures.cpp b/Source/Core/VideoCommon/Resources/InvalidTextures.cpp new file mode 100644 index 0000000000..b27630660e --- /dev/null +++ b/Source/Core/VideoCommon/Resources/InvalidTextures.cpp @@ -0,0 +1,58 @@ +// Copyright 2025 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "VideoCommon/Resources/InvalidTextures.h" + +#include "VideoCommon/AbstractGfx.h" +#include "VideoCommon/TextureConfig.h" + +namespace VideoCommon +{ +std::unique_ptr CreateInvalidTransparentTexture() +{ + const TextureConfig tex_config{ + 1, 1, 1, 1, 1, AbstractTextureFormat::RGBA8, 0, AbstractTextureType::Texture_2D}; + auto texture = g_gfx->CreateTexture(tex_config, "Invalid Transparent Texture"); + const std::array pixel{0, 0, 0, 0}; + texture->Load(0, 1, 1, 1, pixel.data(), pixel.size()); + return texture; +} + +std::unique_ptr CreateInvalidColorTexture() +{ + const TextureConfig tex_config{ + 1, 1, 1, 1, 1, AbstractTextureFormat::RGBA8, 0, AbstractTextureType::Texture_2D}; + auto texture = g_gfx->CreateTexture(tex_config, "Invalid Color Texture"); + const std::array pixel{255, 0, 255, 255}; + texture->Load(0, 1, 1, 1, pixel.data(), pixel.size()); + return texture; +} + +std::unique_ptr CreateInvalidCubemapTexture() +{ +#ifdef __APPLE__ + // TODO: figure out cube map oddness on Apple (specifically Metal) + return nullptr; +#else + const TextureConfig tex_config{ + 1, 1, 1, 6, 1, AbstractTextureFormat::RGBA8, 0, AbstractTextureType::Texture_CubeMap}; + auto texture = g_gfx->CreateTexture(tex_config, "Invalid Cubemap Texture"); + const std::array pixel{255, 0, 255, 255}; + for (u32 i = 0; i < tex_config.layers; i++) + { + texture->Load(0, tex_config.width, tex_config.height, 1, pixel.data(), pixel.size(), i); + } + return texture; +#endif +} + +std::unique_ptr CreateInvalidArrayTexture() +{ + const TextureConfig tex_config{ + 1, 1, 1, 1, 1, AbstractTextureFormat::RGBA8, 0, AbstractTextureType::Texture_2DArray}; + auto texture = g_gfx->CreateTexture(tex_config, "Invalid Array Texture"); + const std::array pixel{255, 0, 255, 255}; + texture->Load(0, 1, 1, 1, pixel.data(), pixel.size()); + return texture; +} +} // namespace VideoCommon diff --git a/Source/Core/VideoCommon/Resources/InvalidTextures.h b/Source/Core/VideoCommon/Resources/InvalidTextures.h new file mode 100644 index 0000000000..532f7e0102 --- /dev/null +++ b/Source/Core/VideoCommon/Resources/InvalidTextures.h @@ -0,0 +1,16 @@ +// Copyright 2025 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include + +#include "VideoCommon/AbstractTexture.h" + +namespace VideoCommon +{ +std::unique_ptr CreateInvalidTransparentTexture(); +std::unique_ptr CreateInvalidColorTexture(); +std::unique_ptr CreateInvalidCubemapTexture(); +std::unique_ptr CreateInvalidArrayTexture(); +} // namespace VideoCommon