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:
@@ -755,6 +755,7 @@
|
|||||||
<ClInclude Include="VideoCommon\Present.h" />
|
<ClInclude Include="VideoCommon\Present.h" />
|
||||||
<ClInclude Include="VideoCommon\RenderState.h" />
|
<ClInclude Include="VideoCommon\RenderState.h" />
|
||||||
<ClInclude Include="VideoCommon\Resources\CustomResourceManager.h" />
|
<ClInclude Include="VideoCommon\Resources\CustomResourceManager.h" />
|
||||||
|
<ClInclude Include="VideoCommon\Resources\InvalidTextures.h" />
|
||||||
<ClInclude Include="VideoCommon\Resources\Resource.h" />
|
<ClInclude Include="VideoCommon\Resources\Resource.h" />
|
||||||
<ClInclude Include="VideoCommon\Resources\TextureDataResource.h" />
|
<ClInclude Include="VideoCommon\Resources\TextureDataResource.h" />
|
||||||
<ClInclude Include="VideoCommon\Resources\TexturePool.h" />
|
<ClInclude Include="VideoCommon\Resources\TexturePool.h" />
|
||||||
@@ -1410,6 +1411,7 @@
|
|||||||
<ClCompile Include="VideoCommon\Present.cpp" />
|
<ClCompile Include="VideoCommon\Present.cpp" />
|
||||||
<ClCompile Include="VideoCommon\RenderState.cpp" />
|
<ClCompile Include="VideoCommon\RenderState.cpp" />
|
||||||
<ClCompile Include="VideoCommon\Resources\CustomResourceManager.cpp" />
|
<ClCompile Include="VideoCommon\Resources\CustomResourceManager.cpp" />
|
||||||
|
<ClCompile Include="VideoCommon\Resources\InvalidTextures.cpp" />
|
||||||
<ClCompile Include="VideoCommon\Resources\Resource.cpp" />
|
<ClCompile Include="VideoCommon\Resources\Resource.cpp" />
|
||||||
<ClCompile Include="VideoCommon\Resources\TextureDataResource.cpp" />
|
<ClCompile Include="VideoCommon\Resources\TextureDataResource.cpp" />
|
||||||
<ClCompile Include="VideoCommon\Resources\TexturePool.cpp" />
|
<ClCompile Include="VideoCommon\Resources\TexturePool.cpp" />
|
||||||
|
|||||||
@@ -150,6 +150,8 @@ add_library(videocommon
|
|||||||
RenderState.h
|
RenderState.h
|
||||||
Resources/CustomResourceManager.cpp
|
Resources/CustomResourceManager.cpp
|
||||||
Resources/CustomResourceManager.h
|
Resources/CustomResourceManager.h
|
||||||
|
Resources/InvalidTextures.cpp
|
||||||
|
Resources/InvalidTextures.h
|
||||||
Resources/Resource.cpp
|
Resources/Resource.cpp
|
||||||
Resources/Resource.h
|
Resources/Resource.h
|
||||||
Resources/TextureDataResource.cpp
|
Resources/TextureDataResource.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<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
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// Copyright 2025 Dolphin Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "VideoCommon/AbstractTexture.h"
|
||||||
|
|
||||||
|
namespace VideoCommon
|
||||||
|
{
|
||||||
|
std::unique_ptr<AbstractTexture> CreateInvalidTransparentTexture();
|
||||||
|
std::unique_ptr<AbstractTexture> CreateInvalidColorTexture();
|
||||||
|
std::unique_ptr<AbstractTexture> CreateInvalidCubemapTexture();
|
||||||
|
std::unique_ptr<AbstractTexture> CreateInvalidArrayTexture();
|
||||||
|
} // namespace VideoCommon
|
||||||
Reference in New Issue
Block a user