mirror of
https://github.com/citra-mirror/citra.git
synced 2024-09-03 18:17:24 +02:00
gl_rasterizer_cache: Trivial minor cleanups (#5295)
* gl_rasterizer_cache: Mark file-scope functions as static where applicable Prevents -Wmissing-declaration warnings from occurring and also makes these functions internally linked. * gl_rasterizer_cache: Remove unused local std::string variable Despite being unused, compilers are unable to completely remove any code gen related to the construction and destruction of this variable, since the destructor of std::string is non-trivial. Thus, we can remove it to reduce a minor amount of unnecessary code generation * gl_rasterizer_cache: Mark hash implementation as noexcept This shouldn't throw. * gl_rasterizer_cache: Remove unused variable in ClearAll() * gl_rasterizer_cache: Make use of const on references explicit While declared as auto&, these actually behave as const auto& variables, due to the constness of the container being iterated. We can make this explicit for readability sake. * gl_rasterizer_cache: Resolve truncation warnings The size is forwarded to a std::memset call, which takes a std::size_t as its size parameter, so we can just make this change to silence the warnings. * gl_rasterizer_cache: Resolve variable shadowing warnings Prevents a -Wshadow warning from occurring.
This commit is contained in:
parent
213c956b7c
commit
51dfc46d3f
@ -92,9 +92,8 @@ const FormatTuple& GetFormatTuple(PixelFormat pixel_format) {
|
||||
* texture to a framebuffer.
|
||||
* Originally from https://github.com/apitrace/apitrace/blob/master/retrace/glstate_images.cpp
|
||||
*/
|
||||
static inline void GetTexImageOES(GLenum target, GLint level, GLenum format, GLenum type,
|
||||
GLint height, GLint width, GLint depth, GLubyte* pixels,
|
||||
GLuint size) {
|
||||
static void GetTexImageOES(GLenum target, GLint level, GLenum format, GLenum type, GLint height,
|
||||
GLint width, GLint depth, GLubyte* pixels, std::size_t size) {
|
||||
memset(pixels, 0x80, size);
|
||||
|
||||
OpenGLState cur_state = OpenGLState::GetCurState();
|
||||
@ -162,7 +161,7 @@ static inline void GetTexImageOES(GLenum target, GLint level, GLenum format, GLe
|
||||
}
|
||||
|
||||
template <typename Map, typename Interval>
|
||||
constexpr auto RangeFromInterval(Map& map, const Interval& interval) {
|
||||
static constexpr auto RangeFromInterval(Map& map, const Interval& interval) {
|
||||
return boost::make_iterator_range(map.equal_range(interval));
|
||||
}
|
||||
|
||||
@ -789,7 +788,6 @@ void CachedSurface::UploadGLTexture(Common::Rectangle<u32> rect, GLuint read_fb_
|
||||
|
||||
ASSERT(gl_buffer.size() == width * height * GetGLBytesPerPixel(pixel_format));
|
||||
|
||||
std::string dump_path; // Has to be declared here for logging later
|
||||
u64 tex_hash = 0;
|
||||
|
||||
if (Settings::values.dump_textures || Settings::values.custom_textures) {
|
||||
@ -970,25 +968,25 @@ enum MatchFlags {
|
||||
TexCopy = 1 << 5 // Surface that will match a display transfer "texture copy" parameters
|
||||
};
|
||||
|
||||
constexpr MatchFlags operator|(MatchFlags lhs, MatchFlags rhs) {
|
||||
static constexpr MatchFlags operator|(MatchFlags lhs, MatchFlags rhs) {
|
||||
return static_cast<MatchFlags>(static_cast<int>(lhs) | static_cast<int>(rhs));
|
||||
}
|
||||
|
||||
/// Get the best surface match (and its match type) for the given flags
|
||||
template <MatchFlags find_flags>
|
||||
Surface FindMatch(const SurfaceCache& surface_cache, const SurfaceParams& params,
|
||||
ScaleMatch match_scale_type,
|
||||
std::optional<SurfaceInterval> validate_interval = {}) {
|
||||
static Surface FindMatch(const SurfaceCache& surface_cache, const SurfaceParams& params,
|
||||
ScaleMatch match_scale_type,
|
||||
std::optional<SurfaceInterval> validate_interval = std::nullopt) {
|
||||
Surface match_surface = nullptr;
|
||||
bool match_valid = false;
|
||||
u32 match_scale = 0;
|
||||
SurfaceInterval match_interval{};
|
||||
|
||||
for (auto& pair : RangeFromInterval(surface_cache, params.GetInterval())) {
|
||||
for (auto& surface : pair.second) {
|
||||
bool res_scale_matched = match_scale_type == ScaleMatch::Exact
|
||||
? (params.res_scale == surface->res_scale)
|
||||
: (params.res_scale <= surface->res_scale);
|
||||
for (const auto& pair : RangeFromInterval(surface_cache, params.GetInterval())) {
|
||||
for (const auto& surface : pair.second) {
|
||||
const bool res_scale_matched = match_scale_type == ScaleMatch::Exact
|
||||
? (params.res_scale == surface->res_scale)
|
||||
: (params.res_scale <= surface->res_scale);
|
||||
// validity will be checked in GetCopyableInterval
|
||||
bool is_valid =
|
||||
find_flags & MatchFlags::Copy
|
||||
@ -1304,17 +1302,18 @@ Surface RasterizerCacheOpenGL::GetTextureSurface(const Pica::Texture::TextureInf
|
||||
state.draw.read_framebuffer = read_framebuffer.handle;
|
||||
state.draw.draw_framebuffer = draw_framebuffer.handle;
|
||||
state.ResetTexture(surface->texture.handle);
|
||||
SurfaceParams params = *surface;
|
||||
SurfaceParams surface_params = *surface;
|
||||
for (u32 level = 1; level <= max_level; ++level) {
|
||||
// In PICA all mipmap levels are stored next to each other
|
||||
params.addr += params.width * params.height * params.GetFormatBpp() / 8;
|
||||
params.width /= 2;
|
||||
params.height /= 2;
|
||||
params.stride = 0; // reset stride and let UpdateParams re-initialize it
|
||||
params.UpdateParams();
|
||||
surface_params.addr +=
|
||||
surface_params.width * surface_params.height * surface_params.GetFormatBpp() / 8;
|
||||
surface_params.width /= 2;
|
||||
surface_params.height /= 2;
|
||||
surface_params.stride = 0; // reset stride and let UpdateParams re-initialize it
|
||||
surface_params.UpdateParams();
|
||||
auto& watcher = surface->level_watchers[level - 1];
|
||||
if (!watcher || !watcher->Get()) {
|
||||
auto level_surface = GetSurface(params, ScaleMatch::Ignore, true);
|
||||
auto level_surface = GetSurface(surface_params, ScaleMatch::Ignore, true);
|
||||
if (level_surface) {
|
||||
watcher = level_surface->CreateWatcher();
|
||||
} else {
|
||||
@ -1341,7 +1340,7 @@ Surface RasterizerCacheOpenGL::GetTextureSurface(const Pica::Texture::TextureInf
|
||||
GL_TEXTURE_2D, 0, 0);
|
||||
|
||||
auto src_rect = level_surface->GetScaledRect();
|
||||
auto dst_rect = params.GetScaledRect();
|
||||
auto dst_rect = surface_params.GetScaledRect();
|
||||
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,
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
@ -1599,12 +1598,12 @@ void RasterizerCacheOpenGL::DuplicateSurface(const Surface& src_surface,
|
||||
dest_surface->invalid_regions += src_surface->invalid_regions;
|
||||
|
||||
SurfaceRegions regions;
|
||||
for (auto& pair : RangeFromInterval(dirty_regions, src_surface->GetInterval())) {
|
||||
for (const auto& pair : RangeFromInterval(dirty_regions, src_surface->GetInterval())) {
|
||||
if (pair.second == src_surface) {
|
||||
regions += pair.first;
|
||||
}
|
||||
}
|
||||
for (auto& interval : regions) {
|
||||
for (const auto& interval : regions) {
|
||||
dirty_regions.set({interval, dest_surface});
|
||||
}
|
||||
}
|
||||
@ -1777,7 +1776,6 @@ void RasterizerCacheOpenGL::ClearAll(bool flush) {
|
||||
// Unmark all of the marked pages
|
||||
for (auto& pair : RangeFromInterval(cached_pages, flush_interval)) {
|
||||
const auto interval = pair.first & flush_interval;
|
||||
const int count = pair.second;
|
||||
|
||||
const PAddr interval_start_addr = boost::icl::first(interval) << Memory::PAGE_BITS;
|
||||
const PAddr interval_end_addr = boost::icl::last_next(interval) << Memory::PAGE_BITS;
|
||||
@ -1843,8 +1841,8 @@ void RasterizerCacheOpenGL::InvalidateRegion(PAddr addr, u32 size, const Surface
|
||||
region_owner->invalid_regions.erase(invalid_interval);
|
||||
}
|
||||
|
||||
for (auto& pair : RangeFromInterval(surface_cache, invalid_interval)) {
|
||||
for (auto& cached_surface : pair.second) {
|
||||
for (const auto& pair : RangeFromInterval(surface_cache, invalid_interval)) {
|
||||
for (const auto& cached_surface : pair.second) {
|
||||
if (cached_surface == region_owner)
|
||||
continue;
|
||||
|
||||
@ -1873,7 +1871,7 @@ void RasterizerCacheOpenGL::InvalidateRegion(PAddr addr, u32 size, const Surface
|
||||
else
|
||||
dirty_regions.erase(invalid_interval);
|
||||
|
||||
for (auto& remove_surface : remove_surfaces) {
|
||||
for (const auto& remove_surface : remove_surfaces) {
|
||||
if (remove_surface == region_owner) {
|
||||
Surface expanded_surface = FindMatch<MatchFlags::SubRect | MatchFlags::Invalid>(
|
||||
surface_cache, *region_owner, ScaleMatch::Ignore);
|
||||
@ -1935,7 +1933,7 @@ void RasterizerCacheOpenGL::UpdatePagesCachedCount(PAddr addr, u32 size, int del
|
||||
if (delta > 0)
|
||||
cached_pages.add({pages_interval, delta});
|
||||
|
||||
for (auto& pair : RangeFromInterval(cached_pages, pages_interval)) {
|
||||
for (const auto& pair : RangeFromInterval(cached_pages, pages_interval)) {
|
||||
const auto interval = pair.first & pages_interval;
|
||||
const int count = pair.second;
|
||||
|
||||
|
@ -61,7 +61,7 @@ struct TextureCubeConfig {
|
||||
namespace std {
|
||||
template <>
|
||||
struct hash<OpenGL::TextureCubeConfig> {
|
||||
std::size_t operator()(const OpenGL::TextureCubeConfig& config) const {
|
||||
std::size_t operator()(const OpenGL::TextureCubeConfig& config) const noexcept {
|
||||
std::size_t hash = 0;
|
||||
boost::hash_combine(hash, config.px);
|
||||
boost::hash_combine(hash, config.nx);
|
||||
|
Loading…
Reference in New Issue
Block a user