yuzu-emu
/
yuzu
Archived
1
0
Fork 0

gl_rasterizer_cache: Fixes to how we do render to cubemap.

- Fixes issues with Splatoon 2.
This commit is contained in:
bunnei 2018-09-30 14:28:36 -04:00
parent 29782273ec
commit df3799a008
2 changed files with 5 additions and 32 deletions

View File

@ -1058,9 +1058,6 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface,
} }
break; break;
case SurfaceParams::SurfaceTarget::TextureCubemap: { case SurfaceParams::SurfaceTarget::TextureCubemap: {
const u32 byte_stride{old_params.rt.layer_stride *
(SurfaceParams::GetFormatBpp(old_params.pixel_format) / CHAR_BIT)};
if (old_params.rt.array_mode != 1) { if (old_params.rt.array_mode != 1) {
// TODO(bunnei): This is used by Breath of the Wild, I'm not sure how to implement this // TODO(bunnei): This is used by Breath of the Wild, I'm not sure how to implement this
// yet (array rendering used as a cubemap texture). // yet (array rendering used as a cubemap texture).
@ -1070,15 +1067,14 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface,
} }
// This seems to be used for render-to-cubemap texture // This seems to be used for render-to-cubemap texture
const std::size_t size_with_mipmaps{new_params.SizeInBytes2DWithMipmap()};
ASSERT_MSG(size_with_mipmaps == byte_stride, "Unexpected");
ASSERT_MSG(old_params.target == SurfaceParams::SurfaceTarget::Texture2D, "Unexpected"); ASSERT_MSG(old_params.target == SurfaceParams::SurfaceTarget::Texture2D, "Unexpected");
ASSERT_MSG(old_params.pixel_format == new_params.pixel_format, "Unexpected"); ASSERT_MSG(old_params.pixel_format == new_params.pixel_format, "Unexpected");
ASSERT_MSG(old_params.width == new_params.width, "Unexpected");
ASSERT_MSG(old_params.height == new_params.height, "Unexpected");
ASSERT_MSG(old_params.rt.array_mode == 1, "Unexpected");
ASSERT_MSG(old_params.rt.base_layer == 0, "Unimplemented"); ASSERT_MSG(old_params.rt.base_layer == 0, "Unimplemented");
// TODO(bunnei): Verify the below - this stride seems to be in 32-bit words, not pixels.
// Tested with Splatoon 2, Super Mario Odyssey, and Breath of the Wild.
const std::size_t byte_stride{old_params.rt.layer_stride * sizeof(u32)};
for (std::size_t index = 0; index < new_params.depth; ++index) { for (std::size_t index = 0; index < new_params.depth; ++index) {
Surface face_surface{TryGetReservedSurface(old_params)}; Surface face_surface{TryGetReservedSurface(old_params)};
ASSERT_MSG(face_surface, "Unexpected"); ASSERT_MSG(face_surface, "Unexpected");
@ -1092,7 +1088,7 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface,
face_surface->GetSurfaceParams().rt.index, new_params.rt.index, index); face_surface->GetSurfaceParams().rt.index, new_params.rt.index, index);
} }
old_params.addr += size_with_mipmaps; old_params.addr += byte_stride;
} }
break; break;
} }

View File

@ -707,29 +707,6 @@ struct SurfaceParams {
return SizeInBytes2D() * depth; return SizeInBytes2D() * depth;
} }
/**
* Returns the size in bytes of the 2D surface with mipmaps. Each mipmap level proceeds the
* previous with half the width and half the height. Once the size of the next mip reaches 0, we
* are done.
*/
std::size_t SizeInBytes2DWithMipmap() const {
std::size_t size_in_bytes{};
auto mip_params{*this};
for (std::size_t level = 0; level < max_mip_level; level++) {
size_in_bytes += mip_params.SizeInBytes2D();
mip_params.width /= 2;
mip_params.height /= 2;
if (!mip_params.width || !mip_params.height) {
break;
}
}
// TODO(bunnei): This alignup is unverified, but necessary in games tested (e.g. in SMO)
return Common::AlignUp(size_in_bytes, 0x1000);
}
/// Creates SurfaceParams from a texture configuration /// Creates SurfaceParams from a texture configuration
static SurfaceParams CreateForTexture(const Tegra::Texture::FullTextureInfo& config, static SurfaceParams CreateForTexture(const Tegra::Texture::FullTextureInfo& config,
const GLShader::SamplerEntry& entry); const GLShader::SamplerEntry& entry);