Merge pull request #1616 from FernandoS27/cube-array

Implement Cube Arrays
This commit is contained in:
bunnei 2018-11-05 15:28:48 -05:00 committed by GitHub
commit cdb19e71fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 0 deletions

View file

@ -126,6 +126,13 @@ std::size_t SurfaceParams::InnerMemorySize(bool force_gl, bool layer_only,
params.target = SurfaceTarget::Texture2D; params.target = SurfaceTarget::Texture2D;
} }
break; break;
case SurfaceTarget::TextureCubeArray:
params.depth = config.tic.Depth() * 6;
if (!entry.IsArray()) {
ASSERT(params.depth == 6);
params.target = SurfaceTarget::TextureCubemap;
}
break;
default: default:
LOG_CRITICAL(HW_GPU, "Unknown depth for target={}", static_cast<u32>(params.target)); LOG_CRITICAL(HW_GPU, "Unknown depth for target={}", static_cast<u32>(params.target));
UNREACHABLE(); UNREACHABLE();
@ -334,6 +341,8 @@ static GLenum SurfaceTargetToGL(SurfaceTarget target) {
return GL_TEXTURE_2D_ARRAY; return GL_TEXTURE_2D_ARRAY;
case SurfaceTarget::TextureCubemap: case SurfaceTarget::TextureCubemap:
return GL_TEXTURE_CUBE_MAP; return GL_TEXTURE_CUBE_MAP;
case SurfaceTarget::TextureCubeArray:
return GL_TEXTURE_CUBE_MAP_ARRAY_ARB;
} }
LOG_CRITICAL(Render_OpenGL, "Unimplemented texture target={}", static_cast<u32>(target)); LOG_CRITICAL(Render_OpenGL, "Unimplemented texture target={}", static_cast<u32>(target));
UNREACHABLE(); UNREACHABLE();
@ -761,6 +770,7 @@ static void CopySurface(const Surface& src_surface, const Surface& dst_surface,
break; break;
case SurfaceTarget::Texture3D: case SurfaceTarget::Texture3D:
case SurfaceTarget::Texture2DArray: case SurfaceTarget::Texture2DArray:
case SurfaceTarget::TextureCubeArray:
glTextureSubImage3D(dst_surface->Texture().handle, 0, 0, 0, 0, width, height, glTextureSubImage3D(dst_surface->Texture().handle, 0, 0, 0, 0, width, height,
static_cast<GLsizei>(dst_params.depth), dest_format.format, static_cast<GLsizei>(dst_params.depth), dest_format.format,
dest_format.type, nullptr); dest_format.type, nullptr);
@ -813,6 +823,7 @@ CachedSurface::CachedSurface(const SurfaceParams& params)
break; break;
case SurfaceTarget::Texture3D: case SurfaceTarget::Texture3D:
case SurfaceTarget::Texture2DArray: case SurfaceTarget::Texture2DArray:
case SurfaceTarget::TextureCubeArray:
glTexStorage3D(SurfaceTargetToGL(params.target), params.max_mip_level, glTexStorage3D(SurfaceTargetToGL(params.target), params.max_mip_level,
format_tuple.internal_format, rect.GetWidth(), rect.GetHeight(), format_tuple.internal_format, rect.GetWidth(), rect.GetHeight(),
params.depth); params.depth);
@ -1065,6 +1076,7 @@ void CachedSurface::UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle,
&gl_buffer[mip_map][buffer_offset]); &gl_buffer[mip_map][buffer_offset]);
break; break;
case SurfaceTarget::Texture2DArray: case SurfaceTarget::Texture2DArray:
case SurfaceTarget::TextureCubeArray:
glCompressedTexImage3D(SurfaceTargetToGL(params.target), mip_map, tuple.internal_format, glCompressedTexImage3D(SurfaceTargetToGL(params.target), mip_map, tuple.internal_format,
static_cast<GLsizei>(params.MipWidth(mip_map)), static_cast<GLsizei>(params.MipWidth(mip_map)),
static_cast<GLsizei>(params.MipHeight(mip_map)), static_cast<GLsizei>(params.MipHeight(mip_map)),
@ -1114,6 +1126,7 @@ void CachedSurface::UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle,
tuple.format, tuple.type, &gl_buffer[mip_map][buffer_offset]); tuple.format, tuple.type, &gl_buffer[mip_map][buffer_offset]);
break; break;
case SurfaceTarget::Texture2DArray: case SurfaceTarget::Texture2DArray:
case SurfaceTarget::TextureCubeArray:
glTexSubImage3D(SurfaceTargetToGL(params.target), mip_map, x0, y0, 0, glTexSubImage3D(SurfaceTargetToGL(params.target), mip_map, x0, y0, 0,
static_cast<GLsizei>(rect.GetWidth()), static_cast<GLsizei>(rect.GetWidth()),
static_cast<GLsizei>(rect.GetHeight()), params.depth, tuple.format, static_cast<GLsizei>(rect.GetHeight()), params.depth, tuple.format,
@ -1316,6 +1329,7 @@ Surface RasterizerCacheOpenGL::RecreateSurface(const Surface& old_surface,
break; break;
case SurfaceTarget::TextureCubemap: case SurfaceTarget::TextureCubemap:
case SurfaceTarget::Texture3D: case SurfaceTarget::Texture3D:
case SurfaceTarget::TextureCubeArray:
AccurateCopySurface(old_surface, new_surface); AccurateCopySurface(old_surface, new_surface);
break; break;
default: default:

View file

@ -49,6 +49,8 @@ struct SurfaceParams {
return "Texture2DArray"; return "Texture2DArray";
case SurfaceTarget::TextureCubemap: case SurfaceTarget::TextureCubemap:
return "TextureCubemap"; return "TextureCubemap";
case SurfaceTarget::TextureCubeArray:
return "TextureCubeArray";
default: default:
LOG_CRITICAL(HW_GPU, "Unimplemented surface_target={}", static_cast<u32>(target)); LOG_CRITICAL(HW_GPU, "Unimplemented surface_target={}", static_cast<u32>(target));
UNREACHABLE(); UNREACHABLE();

View file

@ -19,6 +19,8 @@ SurfaceTarget SurfaceTargetFromTextureType(Tegra::Texture::TextureType texture_t
return SurfaceTarget::Texture3D; return SurfaceTarget::Texture3D;
case Tegra::Texture::TextureType::TextureCubemap: case Tegra::Texture::TextureType::TextureCubemap:
return SurfaceTarget::TextureCubemap; return SurfaceTarget::TextureCubemap;
case Tegra::Texture::TextureType::TextureCubeArray:
return SurfaceTarget::TextureCubeArray;
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:
@ -39,6 +41,7 @@ bool SurfaceTargetIsLayered(SurfaceTarget target) {
case SurfaceTarget::Texture1DArray: case SurfaceTarget::Texture1DArray:
case SurfaceTarget::Texture2DArray: case SurfaceTarget::Texture2DArray:
case SurfaceTarget::TextureCubemap: case SurfaceTarget::TextureCubemap:
case SurfaceTarget::TextureCubeArray:
return true; return true;
default: default:
LOG_CRITICAL(HW_GPU, "Unimplemented surface_target={}", static_cast<u32>(target)); LOG_CRITICAL(HW_GPU, "Unimplemented surface_target={}", static_cast<u32>(target));

View file

@ -120,6 +120,7 @@ enum class SurfaceTarget {
Texture1DArray, Texture1DArray,
Texture2DArray, Texture2DArray,
TextureCubemap, TextureCubemap,
TextureCubeArray,
}; };
/** /**