generate mipmaps (for now)
This commit is contained in:
parent
f09489475a
commit
650fe6447d
|
@ -948,7 +948,6 @@ void CachedSurface::UploadGLTexture(const Common::Rectangle<u32>& rect, GLuint r
|
||||||
bool dump_tex = false;
|
bool dump_tex = false;
|
||||||
bool use_custom_tex = false;
|
bool use_custom_tex = false;
|
||||||
std::string dump_path; // Has to be declared here for logging later
|
std::string dump_path; // Has to be declared here for logging later
|
||||||
Core::CustomTexInfo custom_tex_info;
|
|
||||||
u64 tex_hash = 0;
|
u64 tex_hash = 0;
|
||||||
Common::Rectangle custom_rect =
|
Common::Rectangle custom_rect =
|
||||||
rect; // Required for rect to function properly with custom textures
|
rect; // Required for rect to function properly with custom textures
|
||||||
|
@ -957,7 +956,7 @@ void CachedSurface::UploadGLTexture(const Common::Rectangle<u32>& rect, GLuint r
|
||||||
tex_hash = Common::ComputeHash64(gl_buffer.get(), gl_buffer_size);
|
tex_hash = Common::ComputeHash64(gl_buffer.get(), gl_buffer_size);
|
||||||
|
|
||||||
if (Settings::values.custom_textures)
|
if (Settings::values.custom_textures)
|
||||||
use_custom_tex = LoadCustomTexture(tex_hash, custom_tex_info, custom_rect);
|
is_custom = use_custom_tex = LoadCustomTexture(tex_hash, custom_tex_info, custom_rect);
|
||||||
|
|
||||||
if (Settings::values.dump_textures && !use_custom_tex) {
|
if (Settings::values.dump_textures && !use_custom_tex) {
|
||||||
auto temp_dump_path = GetDumpPath(tex_hash);
|
auto temp_dump_path = GetDumpPath(tex_hash);
|
||||||
|
@ -1541,12 +1540,23 @@ Surface RasterizerCacheOpenGL::GetTextureSurface(const Pica::Texture::TextureInf
|
||||||
state.Apply();
|
state.Apply();
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, max_level);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, max_level);
|
||||||
u32 width = surface->width * surface->res_scale;
|
u32 width;
|
||||||
u32 height = surface->height * surface->res_scale;
|
u32 height;
|
||||||
|
if (surface->is_custom) {
|
||||||
|
width = surface->custom_tex_info.width;
|
||||||
|
height = surface->custom_tex_info.height;
|
||||||
|
} else {
|
||||||
|
width = surface->width * surface->res_scale;
|
||||||
|
height = surface->height * surface->res_scale;
|
||||||
|
}
|
||||||
for (u32 level = surface->max_level + 1; level <= max_level; ++level) {
|
for (u32 level = surface->max_level + 1; level <= max_level; ++level) {
|
||||||
glTexImage2D(GL_TEXTURE_2D, level, format_tuple.internal_format, width >> level,
|
glTexImage2D(GL_TEXTURE_2D, level, format_tuple.internal_format, width >> level,
|
||||||
height >> level, 0, format_tuple.format, format_tuple.type, nullptr);
|
height >> level, 0, format_tuple.format, format_tuple.type, nullptr);
|
||||||
}
|
}
|
||||||
|
if (surface->is_custom) {
|
||||||
|
// TODO: proper mipmap support for custom textures
|
||||||
|
glGenerateMipmap(GL_TEXTURE_2D);
|
||||||
|
}
|
||||||
surface->max_level = max_level;
|
surface->max_level = max_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1579,21 +1589,23 @@ Surface RasterizerCacheOpenGL::GetTextureSurface(const Pica::Texture::TextureInf
|
||||||
}
|
}
|
||||||
state.ResetTexture(level_surface->texture.handle);
|
state.ResetTexture(level_surface->texture.handle);
|
||||||
state.Apply();
|
state.Apply();
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
if (!surface->is_custom) {
|
||||||
level_surface->texture.handle, 0);
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
|
level_surface->texture.handle, 0);
|
||||||
GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
|
||||||
|
GL_TEXTURE_2D, 0, 0);
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||||
surface->texture.handle, level);
|
surface->texture.handle, level);
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
|
||||||
GL_TEXTURE_2D, 0, 0);
|
GL_TEXTURE_2D, 0, 0);
|
||||||
|
|
||||||
auto src_rect = level_surface->GetScaledRect();
|
auto src_rect = level_surface->GetScaledRect();
|
||||||
auto dst_rect = params.GetScaledRect();
|
auto dst_rect = params.GetScaledRect();
|
||||||
glBlitFramebuffer(src_rect.left, src_rect.bottom, src_rect.right, src_rect.top,
|
glBlitFramebuffer(src_rect.left, src_rect.bottom, src_rect.right, src_rect.top,
|
||||||
dst_rect.left, dst_rect.bottom, dst_rect.right, dst_rect.top,
|
dst_rect.left, dst_rect.bottom, dst_rect.right, dst_rect.top,
|
||||||
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||||
|
}
|
||||||
watcher->Validate();
|
watcher->Validate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,6 +362,9 @@ struct CachedSurface : SurfaceParams, std::enable_shared_from_this<CachedSurface
|
||||||
/// level_watchers[i] watches the (i+1)-th level mipmap source surface
|
/// level_watchers[i] watches the (i+1)-th level mipmap source surface
|
||||||
std::array<std::shared_ptr<SurfaceWatcher>, 7> level_watchers;
|
std::array<std::shared_ptr<SurfaceWatcher>, 7> level_watchers;
|
||||||
|
|
||||||
|
bool is_custom = false;
|
||||||
|
Core::CustomTexInfo custom_tex_info;
|
||||||
|
|
||||||
static constexpr unsigned int GetGLBytesPerPixel(PixelFormat format) {
|
static constexpr unsigned int GetGLBytesPerPixel(PixelFormat format) {
|
||||||
// OpenGL needs 4 bpp alignment for D24 since using GL_UNSIGNED_INT as type
|
// OpenGL needs 4 bpp alignment for D24 since using GL_UNSIGNED_INT as type
|
||||||
return format == PixelFormat::Invalid
|
return format == PixelFormat::Invalid
|
||||||
|
|
Loading…
Reference in New Issue