mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-27 09:32:30 -06:00
video_core: Run clang format
This commit is contained in:
parent
f478e3093f
commit
31e6b553dc
24 changed files with 147 additions and 150 deletions
|
@ -3,15 +3,15 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "common/microprofile.h"
|
#include "common/microprofile.h"
|
||||||
#include "common/texture.h"
|
|
||||||
#include "common/scope_exit.h"
|
#include "common/scope_exit.h"
|
||||||
|
#include "common/texture.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "video_core/rasterizer_cache/cached_surface.h"
|
#include "video_core/rasterizer_cache/cached_surface.h"
|
||||||
#include "video_core/rasterizer_cache/morton_swizzle.h"
|
#include "video_core/rasterizer_cache/morton_swizzle.h"
|
||||||
#include "video_core/rasterizer_cache/rasterizer_cache.h"
|
#include "video_core/rasterizer_cache/rasterizer_cache.h"
|
||||||
#include "video_core/renderer_opengl/texture_filters/texture_filterer.h"
|
|
||||||
#include "video_core/renderer_opengl/gl_state.h"
|
#include "video_core/renderer_opengl/gl_state.h"
|
||||||
#include "video_core/renderer_opengl/texture_downloader_es.h"
|
#include "video_core/renderer_opengl/texture_downloader_es.h"
|
||||||
|
#include "video_core/renderer_opengl/texture_filters/texture_filterer.h"
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
|
|
||||||
|
@ -306,8 +306,8 @@ void CachedSurface::UploadGLTexture(Common::Rectangle<u32> rect) {
|
||||||
|
|
||||||
if (is_custom) {
|
if (is_custom) {
|
||||||
const auto& tuple = GetFormatTuple(PixelFormat::RGBA8);
|
const auto& tuple = GetFormatTuple(PixelFormat::RGBA8);
|
||||||
unscaled_tex = owner.AllocateSurfaceTexture(tuple, custom_tex_info.width,
|
unscaled_tex =
|
||||||
custom_tex_info.height);
|
owner.AllocateSurfaceTexture(tuple, custom_tex_info.width, custom_tex_info.height);
|
||||||
} else {
|
} else {
|
||||||
unscaled_tex = owner.AllocateSurfaceTexture(tuple, rect.GetWidth(), rect.GetHeight());
|
unscaled_tex = owner.AllocateSurfaceTexture(tuple, rect.GetWidth(), rect.GetHeight());
|
||||||
}
|
}
|
||||||
|
@ -367,8 +367,7 @@ void CachedSurface::UploadGLTexture(Common::Rectangle<u32> rect) {
|
||||||
|
|
||||||
if (!owner.texture_filterer->Filter(unscaled_tex, from_rect, texture, scaled_rect, type)) {
|
if (!owner.texture_filterer->Filter(unscaled_tex, from_rect, texture, scaled_rect, type)) {
|
||||||
const Aspect aspect = ToAspect(type);
|
const Aspect aspect = ToAspect(type);
|
||||||
runtime.BlitTextures(unscaled_tex, {aspect, from_rect},
|
runtime.BlitTextures(unscaled_tex, {aspect, from_rect}, texture, {aspect, scaled_rect});
|
||||||
texture, {aspect, scaled_rect});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,7 +395,8 @@ void CachedSurface::DownloadGLTexture(const Common::Rectangle<u32>& rect) {
|
||||||
// Ensure no bad interactions with GL_PACK_ALIGNMENT
|
// Ensure no bad interactions with GL_PACK_ALIGNMENT
|
||||||
ASSERT(stride * GetBytesPerPixel(pixel_format) % 4 == 0);
|
ASSERT(stride * GetBytesPerPixel(pixel_format) % 4 == 0);
|
||||||
glPixelStorei(GL_PACK_ROW_LENGTH, static_cast<GLint>(stride));
|
glPixelStorei(GL_PACK_ROW_LENGTH, static_cast<GLint>(stride));
|
||||||
const std::size_t buffer_offset = (rect.bottom * stride + rect.left) * GetBytesPerPixel(pixel_format);
|
const std::size_t buffer_offset =
|
||||||
|
(rect.bottom * stride + rect.left) * GetBytesPerPixel(pixel_format);
|
||||||
|
|
||||||
// If not 1x scale, blit scaled texture to a new 1x texture and use that to flush
|
// If not 1x scale, blit scaled texture to a new 1x texture and use that to flush
|
||||||
const Aspect aspect = ToAspect(type);
|
const Aspect aspect = ToAspect(type);
|
||||||
|
@ -408,11 +408,10 @@ void CachedSurface::DownloadGLTexture(const Common::Rectangle<u32>& rect) {
|
||||||
scaled_rect.bottom *= res_scale;
|
scaled_rect.bottom *= res_scale;
|
||||||
|
|
||||||
const Common::Rectangle<u32> unscaled_tex_rect{0, rect.GetHeight(), rect.GetWidth(), 0};
|
const Common::Rectangle<u32> unscaled_tex_rect{0, rect.GetHeight(), rect.GetWidth(), 0};
|
||||||
auto unscaled_tex = owner.AllocateSurfaceTexture(tuple, rect.GetWidth(),
|
auto unscaled_tex = owner.AllocateSurfaceTexture(tuple, rect.GetWidth(), rect.GetHeight());
|
||||||
rect.GetHeight());
|
|
||||||
// Blit scaled texture to the unscaled one
|
// Blit scaled texture to the unscaled one
|
||||||
runtime.BlitTextures(texture, {aspect, scaled_rect},
|
runtime.BlitTextures(texture, {aspect, scaled_rect}, unscaled_tex,
|
||||||
unscaled_tex, {aspect, unscaled_tex_rect});
|
{aspect, unscaled_tex_rect});
|
||||||
|
|
||||||
state.texture_units[0].texture_2d = unscaled_tex.handle;
|
state.texture_units[0].texture_2d = unscaled_tex.handle;
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
@ -432,7 +431,8 @@ void CachedSurface::DownloadGLTexture(const Common::Rectangle<u32>& rect) {
|
||||||
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CachedSurface::CanFill(const SurfaceParams& dest_surface, SurfaceInterval fill_interval) const {
|
bool CachedSurface::CanFill(const SurfaceParams& dest_surface,
|
||||||
|
SurfaceInterval fill_interval) const {
|
||||||
if (type == SurfaceType::Fill && IsRegionValid(fill_interval) &&
|
if (type == SurfaceType::Fill && IsRegionValid(fill_interval) &&
|
||||||
boost::icl::first(fill_interval) >= addr &&
|
boost::icl::first(fill_interval) >= addr &&
|
||||||
boost::icl::last_next(fill_interval) <= end && // dest_surface is within our fill range
|
boost::icl::last_next(fill_interval) <= end && // dest_surface is within our fill range
|
||||||
|
@ -459,7 +459,8 @@ bool CachedSurface::CanFill(const SurfaceParams& dest_surface, SurfaceInterval f
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CachedSurface::CanCopy(const SurfaceParams& dest_surface, SurfaceInterval copy_interval) const {
|
bool CachedSurface::CanCopy(const SurfaceParams& dest_surface,
|
||||||
|
SurfaceInterval copy_interval) const {
|
||||||
SurfaceParams subrect_params = dest_surface.FromInterval(copy_interval);
|
SurfaceParams subrect_params = dest_surface.FromInterval(copy_interval);
|
||||||
ASSERT(subrect_params.GetInterval() == copy_interval);
|
ASSERT(subrect_params.GetInterval() == copy_interval);
|
||||||
if (CanSubRect(subrect_params))
|
if (CanSubRect(subrect_params))
|
||||||
|
|
|
@ -17,9 +17,9 @@ namespace OpenGL {
|
||||||
*/
|
*/
|
||||||
class SurfaceWatcher {
|
class SurfaceWatcher {
|
||||||
friend class CachedSurface;
|
friend class CachedSurface;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SurfaceWatcher(std::weak_ptr<CachedSurface>&& surface) :
|
explicit SurfaceWatcher(std::weak_ptr<CachedSurface>&& surface) : surface(std::move(surface)) {}
|
||||||
surface(std::move(surface)) {}
|
|
||||||
|
|
||||||
/// Checks whether the surface has been changed.
|
/// Checks whether the surface has been changed.
|
||||||
bool IsValid() const {
|
bool IsValid() const {
|
||||||
|
@ -46,8 +46,8 @@ class RasterizerCacheOpenGL;
|
||||||
|
|
||||||
class CachedSurface : public SurfaceParams, public std::enable_shared_from_this<CachedSurface> {
|
class CachedSurface : public SurfaceParams, public std::enable_shared_from_this<CachedSurface> {
|
||||||
public:
|
public:
|
||||||
CachedSurface(SurfaceParams params, RasterizerCacheOpenGL& owner,TextureRuntime& runtime) :
|
CachedSurface(SurfaceParams params, RasterizerCacheOpenGL& owner, TextureRuntime& runtime)
|
||||||
SurfaceParams(params), owner(owner), runtime(runtime) {}
|
: SurfaceParams(params), owner(owner), runtime(runtime) {}
|
||||||
~CachedSurface();
|
~CachedSurface();
|
||||||
|
|
||||||
/// Read/Write data in 3DS memory to/from gl_buffer
|
/// Read/Write data in 3DS memory to/from gl_buffer
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include "core/hw/gpu.h"
|
#include "core/hw/gpu.h"
|
||||||
#include "video_core/regs_texturing.h"
|
|
||||||
#include "video_core/regs_framebuffer.h"
|
#include "video_core/regs_framebuffer.h"
|
||||||
|
#include "video_core/regs_texturing.h"
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
|
|
||||||
|
@ -98,8 +98,7 @@ constexpr PixelFormat PixelFormatFromColorFormat(Pica::FramebufferRegs::ColorFor
|
||||||
|
|
||||||
constexpr PixelFormat PixelFormatFromDepthFormat(Pica::FramebufferRegs::DepthFormat format) {
|
constexpr PixelFormat PixelFormatFromDepthFormat(Pica::FramebufferRegs::DepthFormat format) {
|
||||||
const u32 format_index = static_cast<u32>(format);
|
const u32 format_index = static_cast<u32>(format);
|
||||||
return (format_index < 4) ? static_cast<PixelFormat>(format_index + 14)
|
return (format_index < 4) ? static_cast<PixelFormat>(format_index + 14) : PixelFormat::Invalid;
|
||||||
: PixelFormat::Invalid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr PixelFormat PixelFormatFromGPUPixelFormat(GPU::Regs::PixelFormat format) {
|
constexpr PixelFormat PixelFormatFromGPUPixelFormat(GPU::Regs::PixelFormat format) {
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
#include "common/microprofile.h"
|
#include "common/microprofile.h"
|
||||||
#include "video_core/pica_state.h"
|
#include "video_core/pica_state.h"
|
||||||
#include "video_core/rasterizer_cache/rasterizer_cache.h"
|
#include "video_core/rasterizer_cache/rasterizer_cache.h"
|
||||||
#include "video_core/renderer_opengl/texture_filters/texture_filterer.h"
|
|
||||||
#include "video_core/renderer_opengl/texture_downloader_es.h"
|
|
||||||
#include "video_core/renderer_opengl/gl_format_reinterpreter.h"
|
#include "video_core/renderer_opengl/gl_format_reinterpreter.h"
|
||||||
|
#include "video_core/renderer_opengl/texture_downloader_es.h"
|
||||||
|
#include "video_core/renderer_opengl/texture_filters/texture_filterer.h"
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ static constexpr auto RangeFromInterval(Map& map, const Interval& interval) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate an uninitialized texture of appropriate size and format for the surface
|
// Allocate an uninitialized texture of appropriate size and format for the surface
|
||||||
OGLTexture RasterizerCacheOpenGL::AllocateSurfaceTexture(const FormatTuple& tuple,
|
OGLTexture RasterizerCacheOpenGL::AllocateSurfaceTexture(const FormatTuple& tuple, u32 width,
|
||||||
u32 width, u32 height) {
|
u32 height) {
|
||||||
auto recycled_tex = host_texture_recycler.find({tuple, width, height});
|
auto recycled_tex = host_texture_recycler.find({tuple, width, height});
|
||||||
if (recycled_tex != host_texture_recycler.end()) {
|
if (recycled_tex != host_texture_recycler.end()) {
|
||||||
OGLTexture texture = std::move(recycled_tex->second);
|
OGLTexture texture = std::move(recycled_tex->second);
|
||||||
|
@ -116,8 +116,8 @@ void RasterizerCacheOpenGL::CopySurface(const Surface& src_surface, const Surfac
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto clear_rect = dst_surface->GetScaledSubRect(subrect_params);
|
const auto clear_rect = dst_surface->GetScaledSubRect(subrect_params);
|
||||||
const ClearValue clear_value = ToClearValue(aspect, dst_surface->pixel_format,
|
const ClearValue clear_value =
|
||||||
fill_buffer.data());
|
ToClearValue(aspect, dst_surface->pixel_format, fill_buffer.data());
|
||||||
|
|
||||||
runtime.ClearTexture(dst_surface->texture, {aspect, clear_rect}, clear_value);
|
runtime.ClearTexture(dst_surface->texture, {aspect, clear_rect}, clear_value);
|
||||||
return;
|
return;
|
||||||
|
@ -127,8 +127,8 @@ void RasterizerCacheOpenGL::CopySurface(const Surface& src_surface, const Surfac
|
||||||
const auto src_rect = src_surface->GetScaledSubRect(subrect_params);
|
const auto src_rect = src_surface->GetScaledSubRect(subrect_params);
|
||||||
const auto dst_rect = dst_surface->GetScaledSubRect(subrect_params);
|
const auto dst_rect = dst_surface->GetScaledSubRect(subrect_params);
|
||||||
|
|
||||||
runtime.BlitTextures(src_surface->texture, {aspect, src_rect},
|
runtime.BlitTextures(src_surface->texture, {aspect, src_rect}, dst_surface->texture,
|
||||||
dst_surface->texture, {aspect, dst_rect});
|
{aspect, dst_rect});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,8 +264,8 @@ bool RasterizerCacheOpenGL::BlitSurfaces(const Surface& src_surface,
|
||||||
dst_surface->InvalidateAllWatcher();
|
dst_surface->InvalidateAllWatcher();
|
||||||
|
|
||||||
const Aspect aspect = ToAspect(src_surface->type);
|
const Aspect aspect = ToAspect(src_surface->type);
|
||||||
return runtime.BlitTextures(src_surface->texture, {aspect, src_rect},
|
return runtime.BlitTextures(src_surface->texture, {aspect, src_rect}, dst_surface->texture,
|
||||||
dst_surface->texture, {aspect, dst_rect});
|
{aspect, dst_rect});
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -569,8 +569,8 @@ const CachedTextureCube& RasterizerCacheOpenGL::GetTextureCube(const TextureCube
|
||||||
const auto src_rect = surface->GetScaledRect();
|
const auto src_rect = surface->GetScaledRect();
|
||||||
const auto dst_rect = Common::Rectangle<u32>{0, scaled_size, scaled_size, 0};
|
const auto dst_rect = Common::Rectangle<u32>{0, scaled_size, scaled_size, 0};
|
||||||
const Aspect aspect = ToAspect(surface->type);
|
const Aspect aspect = ToAspect(surface->type);
|
||||||
runtime.BlitTextures(surface->texture, {aspect, src_rect},
|
runtime.BlitTextures(surface->texture, {aspect, src_rect}, cube.texture,
|
||||||
cube.texture, {aspect, dst_rect});
|
{aspect, dst_rect});
|
||||||
|
|
||||||
face.watcher->Validate();
|
face.watcher->Validate();
|
||||||
}
|
}
|
||||||
|
@ -585,10 +585,13 @@ SurfaceSurfaceRect_Tuple RasterizerCacheOpenGL::GetFramebufferSurfaces(
|
||||||
const auto& config = regs.framebuffer.framebuffer;
|
const auto& config = regs.framebuffer.framebuffer;
|
||||||
|
|
||||||
// Update resolution_scale_factor and reset cache if changed
|
// Update resolution_scale_factor and reset cache if changed
|
||||||
const bool resolution_scale_changed = resolution_scale_factor != VideoCore::GetResolutionScaleFactor();
|
const bool resolution_scale_changed =
|
||||||
const bool texture_filter_changed = VideoCore::g_texture_filter_update_requested.exchange(false)
|
resolution_scale_factor != VideoCore::GetResolutionScaleFactor();
|
||||||
&& texture_filterer->Reset(Settings::values.texture_filter_name, VideoCore::GetResolutionScaleFactor());
|
const bool texture_filter_changed =
|
||||||
|
VideoCore::g_texture_filter_update_requested.exchange(false) &&
|
||||||
|
texture_filterer->Reset(Settings::values.texture_filter_name,
|
||||||
|
VideoCore::GetResolutionScaleFactor());
|
||||||
|
|
||||||
if (resolution_scale_changed || texture_filter_changed) {
|
if (resolution_scale_changed || texture_filter_changed) {
|
||||||
resolution_scale_factor = VideoCore::GetResolutionScaleFactor();
|
resolution_scale_factor = VideoCore::GetResolutionScaleFactor();
|
||||||
FlushAll();
|
FlushAll();
|
||||||
|
@ -843,8 +846,10 @@ bool RasterizerCacheOpenGL::IntervalHasInvalidPixelFormat(SurfaceParams& params,
|
||||||
params.pixel_format = PixelFormat::Invalid;
|
params.pixel_format = PixelFormat::Invalid;
|
||||||
for (const auto& set : RangeFromInterval(surface_cache, interval))
|
for (const auto& set : RangeFromInterval(surface_cache, interval))
|
||||||
for (const auto& surface : set.second)
|
for (const auto& surface : set.second)
|
||||||
if (surface->pixel_format == PixelFormat::Invalid && surface->type != SurfaceType::Fill) {
|
if (surface->pixel_format == PixelFormat::Invalid &&
|
||||||
LOG_DEBUG(Render_OpenGL, "Surface {:#x} found with invalid pixel format", surface->addr);
|
surface->type != SurfaceType::Fill) {
|
||||||
|
LOG_DEBUG(Render_OpenGL, "Surface {:#x} found with invalid pixel format",
|
||||||
|
surface->addr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -880,19 +885,19 @@ bool RasterizerCacheOpenGL::ValidateByReinterpretation(const Surface& surface,
|
||||||
const Common::Rectangle<u32> tmp_rect{0, width, height, 0};
|
const Common::Rectangle<u32> tmp_rect{0, width, height, 0};
|
||||||
|
|
||||||
OGLTexture tmp_tex = AllocateSurfaceTexture(tuple, height, width);
|
OGLTexture tmp_tex = AllocateSurfaceTexture(tuple, height, width);
|
||||||
reinterpreter->Reinterpret(reinterpret_surface->texture, src_rect,
|
reinterpreter->Reinterpret(reinterpret_surface->texture, src_rect, tmp_tex,
|
||||||
tmp_tex, tmp_rect);
|
tmp_rect);
|
||||||
|
|
||||||
if (!texture_filterer->Filter(tmp_tex, tmp_rect,
|
if (!texture_filterer->Filter(tmp_tex, tmp_rect, surface->texture, dest_rect,
|
||||||
surface->texture, dest_rect, type)) {
|
type)) {
|
||||||
|
|
||||||
const Aspect aspect = ToAspect(type);
|
const Aspect aspect = ToAspect(type);
|
||||||
runtime.BlitTextures(tmp_tex, {aspect, tmp_rect},
|
runtime.BlitTextures(tmp_tex, {aspect, tmp_rect}, surface->texture,
|
||||||
surface->texture, {aspect, dest_rect});
|
{aspect, dest_rect});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
reinterpreter->Reinterpret(reinterpret_surface->texture, src_rect,
|
reinterpreter->Reinterpret(reinterpret_surface->texture, src_rect, surface->texture,
|
||||||
surface->texture, dest_rect);
|
dest_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1034,8 +1039,8 @@ Surface RasterizerCacheOpenGL::CreateSurface(const SurfaceParams& params) {
|
||||||
|
|
||||||
// Allocate surface texture
|
// Allocate surface texture
|
||||||
const FormatTuple& tuple = GetFormatTuple(surface->pixel_format);
|
const FormatTuple& tuple = GetFormatTuple(surface->pixel_format);
|
||||||
surface->texture = AllocateSurfaceTexture(tuple, surface->GetScaledWidth(),
|
surface->texture =
|
||||||
surface->GetScaledHeight());
|
AllocateSurfaceTexture(tuple, surface->GetScaledWidth(), surface->GetScaledHeight());
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,20 +20,19 @@ using Surface = std::shared_ptr<CachedSurface>;
|
||||||
using SurfaceInterval = boost::icl::right_open_interval<PAddr>;
|
using SurfaceInterval = boost::icl::right_open_interval<PAddr>;
|
||||||
using SurfaceSet = std::set<Surface>;
|
using SurfaceSet = std::set<Surface>;
|
||||||
using SurfaceRegions = boost::icl::interval_set<PAddr, std::less, SurfaceInterval>;
|
using SurfaceRegions = boost::icl::interval_set<PAddr, std::less, SurfaceInterval>;
|
||||||
using SurfaceMap = boost::icl::interval_map<PAddr, Surface, boost::icl::partial_absorber,
|
using SurfaceMap =
|
||||||
std::less, boost::icl::inplace_plus,
|
boost::icl::interval_map<PAddr, Surface, boost::icl::partial_absorber, std::less,
|
||||||
boost::icl::inter_section, SurfaceInterval>;
|
boost::icl::inplace_plus, boost::icl::inter_section, SurfaceInterval>;
|
||||||
using SurfaceCache = boost::icl::interval_map<PAddr, SurfaceSet, boost::icl::partial_absorber,
|
using SurfaceCache =
|
||||||
std::less, boost::icl::inplace_plus,
|
boost::icl::interval_map<PAddr, SurfaceSet, boost::icl::partial_absorber, std::less,
|
||||||
boost::icl::inter_section, SurfaceInterval>;
|
boost::icl::inplace_plus, boost::icl::inter_section, SurfaceInterval>;
|
||||||
|
|
||||||
static_assert(std::is_same<SurfaceRegions::interval_type, SurfaceCache::interval_type>() &&
|
static_assert(std::is_same<SurfaceRegions::interval_type, SurfaceCache::interval_type>() &&
|
||||||
std::is_same<SurfaceMap::interval_type, SurfaceCache::interval_type>(),
|
std::is_same<SurfaceMap::interval_type, SurfaceCache::interval_type>(),
|
||||||
"Incorrect interval types");
|
"Incorrect interval types");
|
||||||
|
|
||||||
using SurfaceRect_Tuple = std::tuple<Surface, Common::Rectangle<u32>>;
|
using SurfaceRect_Tuple = std::tuple<Surface, Common::Rectangle<u32>>;
|
||||||
using SurfaceSurfaceRect_Tuple = std::tuple<Surface, Surface, Common::Rectangle<u32>>;
|
using SurfaceSurfaceRect_Tuple = std::tuple<Surface, Surface, Common::Rectangle<u32>>;
|
||||||
using PageMap = boost::icl::interval_map<u32, int>;
|
using PageMap = boost::icl::interval_map<u32, int>;
|
||||||
|
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace OpenGL
|
||||||
|
|
|
@ -14,9 +14,9 @@ SurfaceParams SurfaceParams::FromInterval(SurfaceInterval interval) const {
|
||||||
const u32 stride_tiled_bytes = BytesInPixels(stride * tiled_size);
|
const u32 stride_tiled_bytes = BytesInPixels(stride * tiled_size);
|
||||||
|
|
||||||
PAddr aligned_start =
|
PAddr aligned_start =
|
||||||
addr + Common::AlignDown(boost::icl::first(interval) - addr, stride_tiled_bytes);
|
addr + Common::AlignDown(boost::icl::first(interval) - addr, stride_tiled_bytes);
|
||||||
PAddr aligned_end =
|
PAddr aligned_end =
|
||||||
addr + Common::AlignUp(boost::icl::last_next(interval) - addr, stride_tiled_bytes);
|
addr + Common::AlignUp(boost::icl::last_next(interval) - addr, stride_tiled_bytes);
|
||||||
|
|
||||||
if (aligned_end - aligned_start > stride_tiled_bytes) {
|
if (aligned_end - aligned_start > stride_tiled_bytes) {
|
||||||
params.addr = aligned_start;
|
params.addr = aligned_start;
|
||||||
|
@ -27,9 +27,9 @@ SurfaceParams SurfaceParams::FromInterval(SurfaceInterval interval) const {
|
||||||
const u32 tiled_alignment = BytesInPixels(is_tiled ? 8 * 8 : 1);
|
const u32 tiled_alignment = BytesInPixels(is_tiled ? 8 * 8 : 1);
|
||||||
|
|
||||||
aligned_start =
|
aligned_start =
|
||||||
addr + Common::AlignDown(boost::icl::first(interval) - addr, tiled_alignment);
|
addr + Common::AlignDown(boost::icl::first(interval) - addr, tiled_alignment);
|
||||||
aligned_end =
|
aligned_end =
|
||||||
addr + Common::AlignUp(boost::icl::last_next(interval) - addr, tiled_alignment);
|
addr + Common::AlignUp(boost::icl::last_next(interval) - addr, tiled_alignment);
|
||||||
|
|
||||||
params.addr = aligned_start;
|
params.addr = aligned_start;
|
||||||
params.width = PixelsInBytes(aligned_end - aligned_start) / tiled_size;
|
params.width = PixelsInBytes(aligned_end - aligned_start) / tiled_size;
|
||||||
|
|
|
@ -39,15 +39,15 @@ void TextureRuntime::ReadTexture(const OGLTexture& tex, Subresource subresource,
|
||||||
const u32 level = subresource.level;
|
const u32 level = subresource.level;
|
||||||
switch (subresource.aspect) {
|
switch (subresource.aspect) {
|
||||||
case Aspect::Color:
|
case Aspect::Color:
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex.handle,
|
||||||
tex.handle, level);
|
level);
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
|
||||||
0, 0);
|
0);
|
||||||
break;
|
break;
|
||||||
case Aspect::Depth:
|
case Aspect::Depth:
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex.handle,
|
||||||
tex.handle, level);
|
level);
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
||||||
break;
|
break;
|
||||||
case Aspect::DepthStencil:
|
case Aspect::DepthStencil:
|
||||||
|
@ -58,8 +58,8 @@ void TextureRuntime::ReadTexture(const OGLTexture& tex, Subresource subresource,
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& rect = subresource.region;
|
const auto& rect = subresource.region;
|
||||||
glReadPixels(rect.left, rect.bottom, rect.GetWidth(), rect.GetHeight(),
|
glReadPixels(rect.left, rect.bottom, rect.GetWidth(), rect.GetHeight(), tuple.format,
|
||||||
tuple.format, tuple.type, pixels);
|
tuple.type, pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextureRuntime::ClearTexture(const OGLTexture& tex, Subresource subresource,
|
bool TextureRuntime::ClearTexture(const OGLTexture& tex, Subresource subresource,
|
||||||
|
@ -81,10 +81,10 @@ bool TextureRuntime::ClearTexture(const OGLTexture& tex, Subresource subresource
|
||||||
const u32 level = subresource.level;
|
const u32 level = subresource.level;
|
||||||
switch (subresource.aspect) {
|
switch (subresource.aspect) {
|
||||||
case Aspect::Color:
|
case Aspect::Color:
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex.handle,
|
||||||
tex.handle, level);
|
level);
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
|
||||||
0, 0);
|
0);
|
||||||
|
|
||||||
state.color_mask.red_enabled = true;
|
state.color_mask.red_enabled = true;
|
||||||
state.color_mask.green_enabled = true;
|
state.color_mask.green_enabled = true;
|
||||||
|
@ -96,8 +96,8 @@ bool TextureRuntime::ClearTexture(const OGLTexture& tex, Subresource subresource
|
||||||
break;
|
break;
|
||||||
case Aspect::Depth:
|
case Aspect::Depth:
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex.handle,
|
||||||
tex.handle, level);
|
level);
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
||||||
|
|
||||||
state.depth.write_mask = GL_TRUE;
|
state.depth.write_mask = GL_TRUE;
|
||||||
|
@ -136,9 +136,8 @@ bool TextureRuntime::BlitTextures(const OGLTexture& src_tex, Subresource src_sub
|
||||||
state.draw.draw_framebuffer = draw_fbo.handle;
|
state.draw.draw_framebuffer = draw_fbo.handle;
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
|
||||||
auto BindAttachment = [src_level = src_subresource.level,
|
auto BindAttachment = [src_level = src_subresource.level, dst_level = dst_subresource.level](
|
||||||
dst_level = dst_subresource.level](GLenum target, u32 src_tex,
|
GLenum target, u32 src_tex, u32 dst_tex) -> void {
|
||||||
u32 dst_tex) -> void {
|
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, target, GL_TEXTURE_2D, src_tex, src_level);
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, target, GL_TEXTURE_2D, src_tex, src_level);
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, target, GL_TEXTURE_2D, dst_tex, dst_level);
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, target, GL_TEXTURE_2D, dst_tex, dst_level);
|
||||||
};
|
};
|
||||||
|
@ -172,8 +171,8 @@ bool TextureRuntime::BlitTextures(const OGLTexture& src_tex, Subresource src_sub
|
||||||
const GLenum filter = src_subresource.aspect == Aspect::Color ? GL_LINEAR : GL_NEAREST;
|
const GLenum filter = src_subresource.aspect == Aspect::Color ? GL_LINEAR : GL_NEAREST;
|
||||||
const auto& src_rect = src_subresource.region;
|
const auto& src_rect = src_subresource.region;
|
||||||
const auto& dst_rect = dst_subresource.region;
|
const auto& dst_rect = dst_subresource.region;
|
||||||
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.left, dst_rect.bottom, dst_rect.right, dst_rect.top,
|
dst_rect.bottom, dst_rect.right, dst_rect.top,
|
||||||
ToBufferMask(src_subresource.aspect), filter);
|
ToBufferMask(src_subresource.aspect), filter);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -10,11 +10,7 @@
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
|
|
||||||
// Describes the type of data a texture holds
|
// Describes the type of data a texture holds
|
||||||
enum class Aspect {
|
enum class Aspect { Color = 0, Depth = 1, DepthStencil = 2 };
|
||||||
Color = 0,
|
|
||||||
Depth = 1,
|
|
||||||
DepthStencil = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
// A union for both color and depth/stencil clear values
|
// A union for both color and depth/stencil clear values
|
||||||
union ClearValue {
|
union ClearValue {
|
||||||
|
@ -26,8 +22,8 @@ union ClearValue {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Subresource {
|
struct Subresource {
|
||||||
Subresource(Aspect aspect, Common::Rectangle<u32> region, u32 level = 0, u32 layer = 0) :
|
Subresource(Aspect aspect, Common::Rectangle<u32> region, u32 level = 0, u32 layer = 0)
|
||||||
aspect(aspect), region(region), level(level), layer(layer) {}
|
: aspect(aspect), region(region), level(level), layer(layer) {}
|
||||||
|
|
||||||
Aspect aspect;
|
Aspect aspect;
|
||||||
Common::Rectangle<u32> region;
|
Common::Rectangle<u32> region;
|
||||||
|
@ -47,8 +43,8 @@ public:
|
||||||
~TextureRuntime() = default;
|
~TextureRuntime() = default;
|
||||||
|
|
||||||
// Copies the GPU pixel data to the provided pixels buffer
|
// Copies the GPU pixel data to the provided pixels buffer
|
||||||
void ReadTexture(const OGLTexture& tex, Subresource subresource,
|
void ReadTexture(const OGLTexture& tex, Subresource subresource, const FormatTuple& tuple,
|
||||||
const FormatTuple& tuple, u8* pixels);
|
u8* pixels);
|
||||||
|
|
||||||
// Fills the rectangle of the texture with the clear value provided
|
// Fills the rectangle of the texture with the clear value provided
|
||||||
bool ClearTexture(const OGLTexture& texture, Subresource subresource, ClearValue value);
|
bool ClearTexture(const OGLTexture& texture, Subresource subresource, ClearValue value);
|
||||||
|
|
|
@ -81,8 +81,8 @@ void main() {
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||||
dst_tex.handle, 0);
|
dst_tex.handle, 0);
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
|
||||||
0, 0);
|
0);
|
||||||
|
|
||||||
glUniform2i(dst_size_loc, dst_rect.GetWidth(), dst_rect.GetHeight());
|
glUniform2i(dst_size_loc, dst_rect.GetWidth(), dst_rect.GetHeight());
|
||||||
glUniform2i(src_size_loc, src_rect.GetWidth(), src_rect.GetHeight());
|
glUniform2i(src_size_loc, src_rect.GetWidth(), src_rect.GetHeight());
|
||||||
|
@ -96,7 +96,6 @@ private:
|
||||||
OGLVertexArray vao;
|
OGLVertexArray vao;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ShaderD24S8toRGBA8 final : public FormatReinterpreterBase {
|
class ShaderD24S8toRGBA8 final : public FormatReinterpreterBase {
|
||||||
public:
|
public:
|
||||||
ShaderD24S8toRGBA8() {
|
ShaderD24S8toRGBA8() {
|
||||||
|
@ -186,7 +185,8 @@ void main() {
|
||||||
if (use_texture_view) {
|
if (use_texture_view) {
|
||||||
temp_tex.Create();
|
temp_tex.Create();
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glTextureView(temp_tex.handle, GL_TEXTURE_2D, src_tex.handle, GL_DEPTH24_STENCIL8, 0, 1, 0, 1);
|
glTextureView(temp_tex.handle, GL_TEXTURE_2D, src_tex.handle, GL_DEPTH24_STENCIL8, 0, 1,
|
||||||
|
0, 1);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
} else if (src_rect.top > temp_rect.top || src_rect.right > temp_rect.right) {
|
} else if (src_rect.top > temp_rect.top || src_rect.right > temp_rect.right) {
|
||||||
|
@ -220,8 +220,8 @@ void main() {
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||||
dst_tex.handle, 0);
|
dst_tex.handle, 0);
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
|
||||||
0, 0);
|
0);
|
||||||
|
|
||||||
glUniform2i(dst_size_loc, dst_rect.GetWidth(), dst_rect.GetHeight());
|
glUniform2i(dst_size_loc, dst_rect.GetWidth(), dst_rect.GetHeight());
|
||||||
glUniform2i(src_size_loc, src_rect.GetWidth(), src_rect.GetHeight());
|
glUniform2i(src_size_loc, src_rect.GetWidth(), src_rect.GetHeight());
|
||||||
|
|
|
@ -148,8 +148,8 @@ RasterizerOpenGL::RasterizerOpenGL(Frontend::EmuWindow& emu_window)
|
||||||
emu_window,
|
emu_window,
|
||||||
VideoCore::g_separable_shader_enabled ? GLAD_GL_ARB_separate_shader_objects : false);
|
VideoCore::g_separable_shader_enabled ? GLAD_GL_ARB_separate_shader_objects : false);
|
||||||
} else {
|
} else {
|
||||||
shader_program_manager = std::make_unique<ShaderProgramManager>(
|
shader_program_manager =
|
||||||
emu_window, GLAD_GL_ARB_separate_shader_objects);
|
std::make_unique<ShaderProgramManager>(emu_window, GLAD_GL_ARB_separate_shader_objects);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
shader_program_manager = std::make_unique<ShaderProgramManager>(emu_window, true);
|
shader_program_manager = std::make_unique<ShaderProgramManager>(emu_window, true);
|
||||||
|
@ -726,12 +726,10 @@ bool RasterizerOpenGL::Draw(bool accelerate, bool is_indexed) {
|
||||||
// Making a copy to sample from eliminates this issue and seems to be fairly cheap.
|
// Making a copy to sample from eliminates this issue and seems to be fairly cheap.
|
||||||
temp_tex.Create();
|
temp_tex.Create();
|
||||||
temp_tex.Allocate(GL_TEXTURE_2D, levels, tuple.internal_format,
|
temp_tex.Allocate(GL_TEXTURE_2D, levels, tuple.internal_format,
|
||||||
color_surface->GetScaledWidth(),
|
color_surface->GetScaledWidth(), color_surface->GetScaledHeight());
|
||||||
color_surface->GetScaledHeight());
|
|
||||||
|
|
||||||
temp_tex.CopyFrom(color_surface->texture, GL_TEXTURE_2D, levels,
|
temp_tex.CopyFrom(color_surface->texture, GL_TEXTURE_2D, levels,
|
||||||
color_surface->GetScaledWidth(),
|
color_surface->GetScaledWidth(), color_surface->GetScaledHeight());
|
||||||
color_surface->GetScaledHeight());
|
|
||||||
|
|
||||||
for (auto& unit : state.texture_units) {
|
for (auto& unit : state.texture_units) {
|
||||||
if (unit.texture_2d == color_surface->texture.handle) {
|
if (unit.texture_2d == color_surface->texture.handle) {
|
||||||
|
@ -1902,11 +1900,9 @@ void RasterizerOpenGL::SyncLightAmbient(int light_index) {
|
||||||
|
|
||||||
void RasterizerOpenGL::SyncLightPosition(int light_index) {
|
void RasterizerOpenGL::SyncLightPosition(int light_index) {
|
||||||
const auto& light = Pica::g_state.regs.lighting.light[light_index];
|
const auto& light = Pica::g_state.regs.lighting.light[light_index];
|
||||||
const Common::Vec3f position = {
|
const Common::Vec3f position = {Pica::float16::FromRaw(light.x).ToFloat32(),
|
||||||
Pica::float16::FromRaw(light.x).ToFloat32(),
|
Pica::float16::FromRaw(light.y).ToFloat32(),
|
||||||
Pica::float16::FromRaw(light.y).ToFloat32(),
|
Pica::float16::FromRaw(light.z).ToFloat32()};
|
||||||
Pica::float16::FromRaw(light.z).ToFloat32()
|
|
||||||
};
|
|
||||||
|
|
||||||
if (position != uniform_block_data.data.light_src[light_index].position) {
|
if (position != uniform_block_data.data.light_src[light_index].position) {
|
||||||
uniform_block_data.data.light_src[light_index].position = position;
|
uniform_block_data.data.light_src[light_index].position = position;
|
||||||
|
@ -1916,8 +1912,7 @@ void RasterizerOpenGL::SyncLightPosition(int light_index) {
|
||||||
|
|
||||||
void RasterizerOpenGL::SyncLightSpotDirection(int light_index) {
|
void RasterizerOpenGL::SyncLightSpotDirection(int light_index) {
|
||||||
const auto& light = Pica::g_state.regs.lighting.light[light_index];
|
const auto& light = Pica::g_state.regs.lighting.light[light_index];
|
||||||
const auto spot_direction = Common::Vec3u{light.spot_x, light.spot_y, light.spot_z}
|
const auto spot_direction = Common::Vec3u{light.spot_x, light.spot_y, light.spot_z} / 2047.0f;
|
||||||
/ 2047.0f;
|
|
||||||
|
|
||||||
if (spot_direction != uniform_block_data.data.light_src[light_index].spot_direction) {
|
if (spot_direction != uniform_block_data.data.light_src[light_index].spot_direction) {
|
||||||
uniform_block_data.data.light_src[light_index].spot_direction = spot_direction;
|
uniform_block_data.data.light_src[light_index].spot_direction = spot_direction;
|
||||||
|
@ -2019,7 +2014,8 @@ void RasterizerOpenGL::SyncAndUploadLUTsLF() {
|
||||||
|
|
||||||
if (new_data != fog_lut_data || invalidate) {
|
if (new_data != fog_lut_data || invalidate) {
|
||||||
fog_lut_data = new_data;
|
fog_lut_data = new_data;
|
||||||
std::memcpy(buffer + bytes_used, new_data.data(), new_data.size() * sizeof(Common::Vec2f));
|
std::memcpy(buffer + bytes_used, new_data.data(),
|
||||||
|
new_data.size() * sizeof(Common::Vec2f));
|
||||||
uniform_block_data.data.fog_lut_offset =
|
uniform_block_data.data.fog_lut_offset =
|
||||||
static_cast<int>((offset + bytes_used) / sizeof(Common::Vec2f));
|
static_cast<int>((offset + bytes_used) / sizeof(Common::Vec2f));
|
||||||
uniform_block_data.dirty = true;
|
uniform_block_data.dirty = true;
|
||||||
|
@ -2032,9 +2028,10 @@ void RasterizerOpenGL::SyncAndUploadLUTsLF() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::SyncAndUploadLUTs() {
|
void RasterizerOpenGL::SyncAndUploadLUTs() {
|
||||||
constexpr std::size_t max_size = sizeof(Common::Vec2f) * 128 * 3 + // proctex: noise + color + alpha
|
constexpr std::size_t max_size =
|
||||||
sizeof(Common::Vec4f) * 256 + // proctex
|
sizeof(Common::Vec2f) * 128 * 3 + // proctex: noise + color + alpha
|
||||||
sizeof(Common::Vec4f) * 256; // proctex diff
|
sizeof(Common::Vec4f) * 256 + // proctex
|
||||||
|
sizeof(Common::Vec4f) * 256; // proctex diff
|
||||||
|
|
||||||
if (!uniform_block_data.proctex_noise_lut_dirty &&
|
if (!uniform_block_data.proctex_noise_lut_dirty &&
|
||||||
!uniform_block_data.proctex_color_map_dirty &&
|
!uniform_block_data.proctex_color_map_dirty &&
|
||||||
|
@ -2061,7 +2058,8 @@ void RasterizerOpenGL::SyncAndUploadLUTs() {
|
||||||
|
|
||||||
if (new_data != lut_data || invalidate) {
|
if (new_data != lut_data || invalidate) {
|
||||||
lut_data = new_data;
|
lut_data = new_data;
|
||||||
std::memcpy(buffer + bytes_used, new_data.data(), new_data.size() * sizeof(Common::Vec2f));
|
std::memcpy(buffer + bytes_used, new_data.data(),
|
||||||
|
new_data.size() * sizeof(Common::Vec2f));
|
||||||
lut_offset = static_cast<GLint>((offset + bytes_used) / sizeof(Common::Vec2f));
|
lut_offset = static_cast<GLint>((offset + bytes_used) / sizeof(Common::Vec2f));
|
||||||
uniform_block_data.dirty = true;
|
uniform_block_data.dirty = true;
|
||||||
bytes_used += new_data.size() * sizeof(Common::Vec2f);
|
bytes_used += new_data.size() * sizeof(Common::Vec2f);
|
||||||
|
@ -2102,7 +2100,8 @@ void RasterizerOpenGL::SyncAndUploadLUTs() {
|
||||||
|
|
||||||
if (new_data != proctex_lut_data || invalidate) {
|
if (new_data != proctex_lut_data || invalidate) {
|
||||||
proctex_lut_data = new_data;
|
proctex_lut_data = new_data;
|
||||||
std::memcpy(buffer + bytes_used, new_data.data(), new_data.size() * sizeof(Common::Vec4f));
|
std::memcpy(buffer + bytes_used, new_data.data(),
|
||||||
|
new_data.size() * sizeof(Common::Vec4f));
|
||||||
uniform_block_data.data.proctex_lut_offset =
|
uniform_block_data.data.proctex_lut_offset =
|
||||||
static_cast<GLint>((offset + bytes_used) / sizeof(Common::Vec4f));
|
static_cast<GLint>((offset + bytes_used) / sizeof(Common::Vec4f));
|
||||||
uniform_block_data.dirty = true;
|
uniform_block_data.dirty = true;
|
||||||
|
@ -2124,7 +2123,8 @@ void RasterizerOpenGL::SyncAndUploadLUTs() {
|
||||||
|
|
||||||
if (new_data != proctex_diff_lut_data || invalidate) {
|
if (new_data != proctex_diff_lut_data || invalidate) {
|
||||||
proctex_diff_lut_data = new_data;
|
proctex_diff_lut_data = new_data;
|
||||||
std::memcpy(buffer + bytes_used, new_data.data(), new_data.size() * sizeof(Common::Vec4f));
|
std::memcpy(buffer + bytes_used, new_data.data(),
|
||||||
|
new_data.size() * sizeof(Common::Vec4f));
|
||||||
uniform_block_data.data.proctex_diff_lut_offset =
|
uniform_block_data.data.proctex_diff_lut_offset =
|
||||||
static_cast<GLint>((offset + bytes_used) / sizeof(Common::Vec4f));
|
static_cast<GLint>((offset + bytes_used) / sizeof(Common::Vec4f));
|
||||||
uniform_block_data.dirty = true;
|
uniform_block_data.dirty = true;
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
#include "common/vector_math.h"
|
#include "common/vector_math.h"
|
||||||
#include "core/hw/gpu.h"
|
#include "core/hw/gpu.h"
|
||||||
#include "video_core/pica_types.h"
|
#include "video_core/pica_types.h"
|
||||||
|
#include "video_core/rasterizer_cache/rasterizer_cache.h"
|
||||||
#include "video_core/rasterizer_interface.h"
|
#include "video_core/rasterizer_interface.h"
|
||||||
#include "video_core/regs_lighting.h"
|
#include "video_core/regs_lighting.h"
|
||||||
#include "video_core/regs_texturing.h"
|
#include "video_core/regs_texturing.h"
|
||||||
#include "video_core/rasterizer_cache/rasterizer_cache.h"
|
|
||||||
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
||||||
#include "video_core/renderer_opengl/gl_state.h"
|
#include "video_core/renderer_opengl/gl_state.h"
|
||||||
#include "video_core/renderer_opengl/gl_stream_buffer.h"
|
#include "video_core/renderer_opengl/gl_stream_buffer.h"
|
||||||
|
@ -298,7 +298,8 @@ private:
|
||||||
OGLTexture texture_buffer_lut_rg;
|
OGLTexture texture_buffer_lut_rg;
|
||||||
OGLTexture texture_buffer_lut_rgba;
|
OGLTexture texture_buffer_lut_rgba;
|
||||||
|
|
||||||
std::array<std::array<Common::Vec2f, 256>, Pica::LightingRegs::NumLightingSampler> lighting_lut_data{};
|
std::array<std::array<Common::Vec2f, 256>, Pica::LightingRegs::NumLightingSampler>
|
||||||
|
lighting_lut_data{};
|
||||||
std::array<Common::Vec2f, 128> fog_lut_data{};
|
std::array<Common::Vec2f, 128> fog_lut_data{};
|
||||||
std::array<Common::Vec2f, 128> proctex_noise_lut_data{};
|
std::array<Common::Vec2f, 128> proctex_noise_lut_data{};
|
||||||
std::array<Common::Vec2f, 128> proctex_color_map_data{};
|
std::array<Common::Vec2f, 128> proctex_color_map_data{};
|
||||||
|
|
|
@ -52,8 +52,8 @@ void OGLTexture::Release() {
|
||||||
handle = 0;
|
handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OGLTexture::Allocate(GLenum target, GLsizei levels, GLenum internalformat,
|
void OGLTexture::Allocate(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width,
|
||||||
GLsizei width, GLsizei height, GLsizei depth) {
|
GLsizei height, GLsizei depth) {
|
||||||
GLuint old_tex = OpenGLState::GetCurState().texture_units[0].texture_2d;
|
GLuint old_tex = OpenGLState::GetCurState().texture_units[0].texture_2d;
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, handle);
|
glBindTexture(GL_TEXTURE_2D, handle);
|
||||||
|
@ -83,17 +83,15 @@ void OGLTexture::Allocate(GLenum target, GLsizei levels, GLenum internalformat,
|
||||||
glBindTexture(GL_TEXTURE_2D, old_tex);
|
glBindTexture(GL_TEXTURE_2D, old_tex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OGLTexture::CopyFrom(const OGLTexture& other, GLenum target, GLsizei levels,
|
void OGLTexture::CopyFrom(const OGLTexture& other, GLenum target, GLsizei levels, GLsizei width,
|
||||||
GLsizei width, GLsizei height) {
|
GLsizei height) {
|
||||||
GLuint old_tex = OpenGLState::GetCurState().texture_units[0].texture_2d;
|
GLuint old_tex = OpenGLState::GetCurState().texture_units[0].texture_2d;
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, handle);
|
glBindTexture(GL_TEXTURE_2D, handle);
|
||||||
|
|
||||||
for (u32 level = 0; level < levels; level++) {
|
for (u32 level = 0; level < levels; level++) {
|
||||||
glCopyImageSubData(other.handle, target, level, 0, 0, 0,
|
glCopyImageSubData(other.handle, target, level, 0, 0, 0, handle, target, level, 0, 0, 0,
|
||||||
handle, target, level, 0, 0, 0,
|
width >> level, height >> level, 1);
|
||||||
width >> level,
|
|
||||||
height >> level, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, old_tex);
|
glBindTexture(GL_TEXTURE_2D, old_tex);
|
||||||
|
|
|
@ -58,11 +58,11 @@ public:
|
||||||
/// Deletes the internal OpenGL resource
|
/// Deletes the internal OpenGL resource
|
||||||
void Release();
|
void Release();
|
||||||
|
|
||||||
void Allocate(GLenum target, GLsizei levels, GLenum internalformat,
|
void Allocate(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width,
|
||||||
GLsizei width, GLsizei height = 1, GLsizei depth = 1);
|
GLsizei height = 1, GLsizei depth = 1);
|
||||||
|
|
||||||
void CopyFrom(const OGLTexture& other, GLenum target, GLsizei levels,
|
void CopyFrom(const OGLTexture& other, GLenum target, GLsizei levels, GLsizei width,
|
||||||
GLsizei width, GLsizei height);
|
GLsizei height);
|
||||||
|
|
||||||
GLuint handle = 0;
|
GLuint handle = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <thread>
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <thread>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <boost/variant.hpp>
|
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
|
#include <boost/variant.hpp>
|
||||||
#include "core/frontend/scope_acquire_context.h"
|
#include "core/frontend/scope_acquire_context.h"
|
||||||
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
#include "video_core/renderer_opengl/gl_resource_manager.h"
|
||||||
#include "video_core/renderer_opengl/gl_shader_disk_cache.h"
|
#include "video_core/renderer_opengl/gl_shader_disk_cache.h"
|
||||||
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
#include "video_core/renderer_opengl/gl_shader_manager.h"
|
||||||
#include "video_core/renderer_opengl/gl_vars.h"
|
|
||||||
#include "video_core/renderer_opengl/gl_state.h"
|
#include "video_core/renderer_opengl/gl_state.h"
|
||||||
|
#include "video_core/renderer_opengl/gl_vars.h"
|
||||||
#include "video_core/video_core.h"
|
#include "video_core/video_core.h"
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
|
|
|
@ -20,7 +20,7 @@ class EmuWindow;
|
||||||
namespace Pica {
|
namespace Pica {
|
||||||
struct Regs;
|
struct Regs;
|
||||||
struct ShaderRegs;
|
struct ShaderRegs;
|
||||||
}
|
} // namespace Pica
|
||||||
|
|
||||||
namespace Pica::Shader {
|
namespace Pica::Shader {
|
||||||
struct ShaderSetup;
|
struct ShaderSetup;
|
||||||
|
|
|
@ -232,8 +232,8 @@ inline GLenum StencilOp(Pica::FramebufferRegs::StencilAction action) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Common::Vec4f ColorRGBA8(const u32 color) {
|
inline Common::Vec4f ColorRGBA8(const u32 color) {
|
||||||
const auto rgba = Common::Vec4u{color >> 0 & 0xFF, color >> 8 & 0xFF,
|
const auto rgba =
|
||||||
color >> 16 & 0xFF, color >> 24 & 0xFF};
|
Common::Vec4u{color >> 0 & 0xFF, color >> 8 & 0xFF, color >> 16 & 0xFF, color >> 24 & 0xFF};
|
||||||
return rgba / 255.0f;
|
return rgba / 255.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
#include "core/tracer/recorder.h"
|
#include "core/tracer/recorder.h"
|
||||||
#include "video_core/debug_utils/debug_utils.h"
|
#include "video_core/debug_utils/debug_utils.h"
|
||||||
#include "video_core/rasterizer_interface.h"
|
#include "video_core/rasterizer_interface.h"
|
||||||
#include "video_core/renderer_opengl/gl_state.h"
|
|
||||||
#include "video_core/renderer_opengl/gl_shader_util.h"
|
#include "video_core/renderer_opengl/gl_shader_util.h"
|
||||||
|
#include "video_core/renderer_opengl/gl_state.h"
|
||||||
#include "video_core/renderer_opengl/gl_vars.h"
|
#include "video_core/renderer_opengl/gl_vars.h"
|
||||||
#include "video_core/renderer_opengl/post_processing_opengl.h"
|
#include "video_core/renderer_opengl/post_processing_opengl.h"
|
||||||
#include "video_core/renderer_opengl/renderer_opengl.h"
|
#include "video_core/renderer_opengl/renderer_opengl.h"
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <fmt/chrono.h>
|
#include <fmt/chrono.h>
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "video_core/rasterizer_cache/rasterizer_cache_utils.h"
|
|
||||||
#include "video_core/renderer_opengl/gl_state.h"
|
|
||||||
#include "video_core/renderer_opengl/texture_downloader_es.h"
|
|
||||||
#include "shaders/depth_to_color.frag"
|
#include "shaders/depth_to_color.frag"
|
||||||
#include "shaders/depth_to_color.vert"
|
#include "shaders/depth_to_color.vert"
|
||||||
#include "shaders/ds_to_color.frag"
|
#include "shaders/ds_to_color.frag"
|
||||||
|
#include "video_core/rasterizer_cache/rasterizer_cache_utils.h"
|
||||||
|
#include "video_core/renderer_opengl/gl_state.h"
|
||||||
|
#include "video_core/renderer_opengl/texture_downloader_es.h"
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
|
|
||||||
|
|
|
@ -133,8 +133,8 @@ void Anime4kUltrafast::Filter(const OGLTexture& src_tex, Common::Rectangle<u32>
|
||||||
state.draw.shader_program = refine_program.handle;
|
state.draw.shader_program = refine_program.handle;
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_tex.handle,
|
||||||
dst_tex.handle, 0);
|
0);
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ void Bicubic::Filter(const OGLTexture& src_tex, Common::Rectangle<u32> src_rect,
|
||||||
static_cast<GLsizei>(dst_rect.GetHeight())};
|
static_cast<GLsizei>(dst_rect.GetHeight())};
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_tex.handle,
|
||||||
dst_tex.handle, 0);
|
0);
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ void ScaleForce::Filter(const OGLTexture& src_tex, Common::Rectangle<u32> src_re
|
||||||
static_cast<GLsizei>(dst_rect.GetHeight())};
|
static_cast<GLsizei>(dst_rect.GetHeight())};
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_tex.handle,
|
||||||
dst_tex.handle, 0);
|
0);
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ class OGLTexture;
|
||||||
|
|
||||||
class TextureFilterBase {
|
class TextureFilterBase {
|
||||||
friend class TextureFilterer;
|
friend class TextureFilterer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TextureFilterBase(u16 scale_factor) : scale_factor(scale_factor) {
|
explicit TextureFilterBase(u16 scale_factor) : scale_factor(scale_factor) {
|
||||||
draw_fbo.Create();
|
draw_fbo.Create();
|
||||||
|
|
|
@ -27,8 +27,7 @@ public:
|
||||||
|
|
||||||
// Returns true if the texture was able to be filtered
|
// Returns true if the texture was able to be filtered
|
||||||
bool Filter(const OGLTexture& src_tex, Common::Rectangle<u32> src_rect,
|
bool Filter(const OGLTexture& src_tex, Common::Rectangle<u32> src_rect,
|
||||||
const OGLTexture& dst_tex, Common::Rectangle<u32> dst_rect,
|
const OGLTexture& dst_tex, Common::Rectangle<u32> dst_rect, SurfaceType type);
|
||||||
SurfaceType type);
|
|
||||||
|
|
||||||
static std::vector<std::string_view> GetFilterNames();
|
static std::vector<std::string_view> GetFilterNames();
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,7 @@
|
||||||
|
|
||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
|
|
||||||
XbrzFreescale::XbrzFreescale(u16 scale_factor) :
|
XbrzFreescale::XbrzFreescale(u16 scale_factor) : TextureFilterBase(scale_factor) {
|
||||||
TextureFilterBase(scale_factor) {
|
|
||||||
|
|
||||||
const OpenGLState cur_state = OpenGLState::GetCurState();
|
const OpenGLState cur_state = OpenGLState::GetCurState();
|
||||||
|
|
||||||
|
@ -84,8 +83,8 @@ void XbrzFreescale::Filter(const OGLTexture& src_tex, Common::Rectangle<u32> src
|
||||||
static_cast<GLsizei>(dst_rect.GetHeight())};
|
static_cast<GLsizei>(dst_rect.GetHeight())};
|
||||||
state.Apply();
|
state.Apply();
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dst_tex.handle,
|
||||||
dst_tex.handle, 0);
|
0);
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue