mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-08-13 12:54:04 -05:00
VideoCommon: add some helper functions for resource logic that generates invalid textures for when a texture isn't provided for a custom asset
This commit is contained in:
58
Source/Core/VideoCommon/Resources/InvalidTextures.cpp
Normal file
58
Source/Core/VideoCommon/Resources/InvalidTextures.cpp
Normal file
@@ -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<AbstractTexture> 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<u8, 4> pixel{0, 0, 0, 0};
|
||||
texture->Load(0, 1, 1, 1, pixel.data(), pixel.size());
|
||||
return texture;
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractTexture> 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<u8, 4> pixel{255, 0, 255, 255};
|
||||
texture->Load(0, 1, 1, 1, pixel.data(), pixel.size());
|
||||
return texture;
|
||||
}
|
||||
|
||||
std::unique_ptr<AbstractTexture> 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<u8, 4> 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<AbstractTexture> 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<u8, 4> pixel{255, 0, 255, 255};
|
||||
texture->Load(0, 1, 1, 1, pixel.data(), pixel.size());
|
||||
return texture;
|
||||
}
|
||||
} // namespace VideoCommon
|
||||
Reference in New Issue
Block a user