mirror of
https://github.com/yuzu-emu/yuzu-mainline.git
synced 2024-12-24 14:05:27 +00:00
gl_rasterizer_cache: Add support for SurfaceTarget::TextureCubemap.
This commit is contained in:
parent
871580dcd8
commit
ed2e0e85c9
|
@ -60,6 +60,9 @@ static VAddr TryGetCpuAddr(Tegra::GPUVAddr gpu_addr) {
|
||||||
case SurfaceTarget::Texture2D:
|
case SurfaceTarget::Texture2D:
|
||||||
params.depth = 1;
|
params.depth = 1;
|
||||||
break;
|
break;
|
||||||
|
case SurfaceTarget::TextureCubemap:
|
||||||
|
params.depth = config.tic.Depth() * 6;
|
||||||
|
break;
|
||||||
case SurfaceTarget::Texture3D:
|
case SurfaceTarget::Texture3D:
|
||||||
params.depth = config.tic.Depth();
|
params.depth = config.tic.Depth();
|
||||||
break;
|
break;
|
||||||
|
@ -562,6 +565,7 @@ CachedSurface::CachedSurface(const SurfaceParams& params)
|
||||||
rect.GetWidth());
|
rect.GetWidth());
|
||||||
break;
|
break;
|
||||||
case SurfaceParams::SurfaceTarget::Texture2D:
|
case SurfaceParams::SurfaceTarget::Texture2D:
|
||||||
|
case SurfaceParams::SurfaceTarget::TextureCubemap:
|
||||||
glTexStorage2D(SurfaceTargetToGL(params.target), 1, format_tuple.internal_format,
|
glTexStorage2D(SurfaceTargetToGL(params.target), 1, format_tuple.internal_format,
|
||||||
rect.GetWidth(), rect.GetHeight());
|
rect.GetWidth(), rect.GetHeight());
|
||||||
break;
|
break;
|
||||||
|
@ -680,6 +684,7 @@ void CachedSurface::LoadGLBuffer() {
|
||||||
// Pass impl. to the fallback code below
|
// Pass impl. to the fallback code below
|
||||||
break;
|
break;
|
||||||
case SurfaceParams::SurfaceTarget::Texture2DArray:
|
case SurfaceParams::SurfaceTarget::Texture2DArray:
|
||||||
|
case SurfaceParams::SurfaceTarget::TextureCubemap:
|
||||||
for (std::size_t index = 0; index < params.depth; ++index) {
|
for (std::size_t index = 0; index < params.depth; ++index) {
|
||||||
const std::size_t offset{index * copy_size};
|
const std::size_t offset{index * copy_size};
|
||||||
morton_to_gl_fns[static_cast<std::size_t>(params.pixel_format)](
|
morton_to_gl_fns[static_cast<std::size_t>(params.pixel_format)](
|
||||||
|
@ -724,7 +729,7 @@ void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle
|
||||||
// Load data from memory to the surface
|
// Load data from memory to the surface
|
||||||
const GLint x0 = static_cast<GLint>(rect.left);
|
const GLint x0 = static_cast<GLint>(rect.left);
|
||||||
const GLint y0 = static_cast<GLint>(rect.bottom);
|
const GLint y0 = static_cast<GLint>(rect.bottom);
|
||||||
const std::size_t buffer_offset =
|
std::size_t buffer_offset =
|
||||||
static_cast<std::size_t>(static_cast<std::size_t>(y0) * params.width +
|
static_cast<std::size_t>(static_cast<std::size_t>(y0) * params.width +
|
||||||
static_cast<std::size_t>(x0)) *
|
static_cast<std::size_t>(x0)) *
|
||||||
GetGLBytesPerPixel(params.pixel_format);
|
GetGLBytesPerPixel(params.pixel_format);
|
||||||
|
@ -763,6 +768,16 @@ void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle
|
||||||
static_cast<GLsizei>(params.depth), 0,
|
static_cast<GLsizei>(params.depth), 0,
|
||||||
static_cast<GLsizei>(params.size_in_bytes_total), &gl_buffer[buffer_offset]);
|
static_cast<GLsizei>(params.size_in_bytes_total), &gl_buffer[buffer_offset]);
|
||||||
break;
|
break;
|
||||||
|
case SurfaceParams::SurfaceTarget::TextureCubemap:
|
||||||
|
for (std::size_t face = 0; face < params.depth; ++face) {
|
||||||
|
glCompressedTexImage2D(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face),
|
||||||
|
0, tuple.internal_format, static_cast<GLsizei>(params.width),
|
||||||
|
static_cast<GLsizei>(params.height), 0,
|
||||||
|
static_cast<GLsizei>(params.size_in_bytes_2d),
|
||||||
|
&gl_buffer[buffer_offset]);
|
||||||
|
buffer_offset += params.size_in_bytes_2d;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}",
|
LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}",
|
||||||
static_cast<u32>(params.target));
|
static_cast<u32>(params.target));
|
||||||
|
@ -793,6 +808,15 @@ void CachedSurface::UploadGLTexture(GLuint read_fb_handle, GLuint draw_fb_handle
|
||||||
static_cast<GLsizei>(rect.GetHeight()), params.depth, tuple.format,
|
static_cast<GLsizei>(rect.GetHeight()), params.depth, tuple.format,
|
||||||
tuple.type, &gl_buffer[buffer_offset]);
|
tuple.type, &gl_buffer[buffer_offset]);
|
||||||
break;
|
break;
|
||||||
|
case SurfaceParams::SurfaceTarget::TextureCubemap:
|
||||||
|
for (std::size_t face = 0; face < params.depth; ++face) {
|
||||||
|
glTexSubImage2D(static_cast<GLenum>(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face), 0, x0,
|
||||||
|
y0, static_cast<GLsizei>(rect.GetWidth()),
|
||||||
|
static_cast<GLsizei>(rect.GetHeight()), tuple.format, tuple.type,
|
||||||
|
&gl_buffer[buffer_offset]);
|
||||||
|
buffer_offset += params.size_in_bytes_2d;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}",
|
LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}",
|
||||||
static_cast<u32>(params.target));
|
static_cast<u32>(params.target));
|
||||||
|
@ -989,6 +1013,15 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface,
|
||||||
static_cast<GLsizei>(new_params.depth), dest_format.format,
|
static_cast<GLsizei>(new_params.depth), dest_format.format,
|
||||||
dest_format.type, nullptr);
|
dest_format.type, nullptr);
|
||||||
break;
|
break;
|
||||||
|
case SurfaceParams::SurfaceTarget::TextureCubemap:
|
||||||
|
for (std::size_t face = 0; face < new_params.depth; ++face) {
|
||||||
|
glTextureSubImage3D(
|
||||||
|
new_surface->Texture().handle, 0, 0, 0, static_cast<GLint>(face),
|
||||||
|
static_cast<GLsizei>(dest_rect.GetWidth()),
|
||||||
|
static_cast<GLsizei>(dest_rect.GetHeight()), static_cast<GLsizei>(1),
|
||||||
|
dest_format.format, dest_format.type, nullptr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}",
|
LOG_CRITICAL(Render_OpenGL, "Unimplemented surface target={}",
|
||||||
static_cast<u32>(new_params.target));
|
static_cast<u32>(new_params.target));
|
||||||
|
|
|
@ -127,6 +127,8 @@ struct SurfaceParams {
|
||||||
case Tegra::Texture::TextureType::Texture2D:
|
case Tegra::Texture::TextureType::Texture2D:
|
||||||
case Tegra::Texture::TextureType::Texture2DNoMipmap:
|
case Tegra::Texture::TextureType::Texture2DNoMipmap:
|
||||||
return SurfaceTarget::Texture2D;
|
return SurfaceTarget::Texture2D;
|
||||||
|
case Tegra::Texture::TextureType::TextureCubemap:
|
||||||
|
return SurfaceTarget::TextureCubemap;
|
||||||
case Tegra::Texture::TextureType::Texture1DArray:
|
case Tegra::Texture::TextureType::Texture1DArray:
|
||||||
return SurfaceTarget::Texture1DArray;
|
return SurfaceTarget::Texture1DArray;
|
||||||
case Tegra::Texture::TextureType::Texture2DArray:
|
case Tegra::Texture::TextureType::Texture2DArray:
|
||||||
|
|
Loading…
Reference in a new issue