rasterizer_cache: Handle null surface cubes properly

This commit is contained in:
GPUCode
2023-03-05 14:05:22 +02:00
parent b9021ea469
commit d054eea0c4
2 changed files with 17 additions and 3 deletions

View File

@@ -42,9 +42,17 @@ RasterizerCache<T>::RasterizerCache(Memory::MemorySystem& memory_,
.width = 1,
.height = 1,
.stride = 1,
.texture_type = VideoCore::TextureType::Texture2D,
.pixel_format = VideoCore::PixelFormat::RGBA8,
.type = VideoCore::SurfaceType::Color,
.texture_type = TextureType::Texture2D,
.pixel_format = PixelFormat::RGBA8,
.type = SurfaceType::Color,
}));
void(slot_surfaces.insert(runtime, SurfaceParams{
.width = 1,
.height = 1,
.stride = 1,
.texture_type = TextureType::CubeMap,
.pixel_format = PixelFormat::RGBA8,
.type = SurfaceType::Color,
}));
void(slot_samplers.insert(runtime, SamplerParams{
.mag_filter = TextureConfig::TextureFilter::Linear,
@@ -614,6 +622,10 @@ auto RasterizerCache<T>::GetTextureSurface(const Pica::Texture::TextureInfo& inf
template <class T>
auto RasterizerCache<T>::GetTextureCube(const TextureCubeConfig& config) -> Surface& {
if (config.px == 0) [[unlikely]] {
return slot_surfaces[NULL_SURFACE_CUBE_ID];
}
auto [it, new_surface] = texture_cube_cache.try_emplace(config);
if (new_surface) {
const SurfaceParams cube_params = {

View File

@@ -22,6 +22,8 @@ using SamplerId = SlotId;
/// Fake surface ID for null surfaces
constexpr SurfaceId NULL_SURFACE_ID{0};
/// Fake surface Id for null surface cubes
constexpr SurfaceId NULL_SURFACE_CUBE_ID{1};
/// Fake sampler ID for null samplers
constexpr SamplerId NULL_SAMPLER_ID{0};