forked from suyu/suyu
texture_cache: Fermi2D reform and implement View Mirage
This also does some fixes on compressed textures reinterpret and on the Fermi2D engine in general.
This commit is contained in:
parent
1bf4154e7d
commit
175aa343ff
11 changed files with 125 additions and 77 deletions
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/math_util.h"
|
|
||||||
#include "video_core/engines/fermi_2d.h"
|
#include "video_core/engines/fermi_2d.h"
|
||||||
#include "video_core/memory_manager.h"
|
#include "video_core/memory_manager.h"
|
||||||
#include "video_core/rasterizer_interface.h"
|
#include "video_core/rasterizer_interface.h"
|
||||||
|
@ -35,7 +34,7 @@ void Fermi2D::HandleSurfaceCopy() {
|
||||||
static_cast<u32>(regs.operation));
|
static_cast<u32>(regs.operation));
|
||||||
|
|
||||||
// TODO(Subv): Only raw copies are implemented.
|
// TODO(Subv): Only raw copies are implemented.
|
||||||
ASSERT(regs.operation == Regs::Operation::SrcCopy);
|
ASSERT(regs.operation == Operation::SrcCopy);
|
||||||
|
|
||||||
const u32 src_blit_x1{static_cast<u32>(regs.blit_src_x >> 32)};
|
const u32 src_blit_x1{static_cast<u32>(regs.blit_src_x >> 32)};
|
||||||
const u32 src_blit_y1{static_cast<u32>(regs.blit_src_y >> 32)};
|
const u32 src_blit_y1{static_cast<u32>(regs.blit_src_y >> 32)};
|
||||||
|
@ -48,8 +47,13 @@ void Fermi2D::HandleSurfaceCopy() {
|
||||||
const Common::Rectangle<u32> dst_rect{regs.blit_dst_x, regs.blit_dst_y,
|
const Common::Rectangle<u32> dst_rect{regs.blit_dst_x, regs.blit_dst_y,
|
||||||
regs.blit_dst_x + regs.blit_dst_width,
|
regs.blit_dst_x + regs.blit_dst_width,
|
||||||
regs.blit_dst_y + regs.blit_dst_height};
|
regs.blit_dst_y + regs.blit_dst_height};
|
||||||
|
Config copy_config;
|
||||||
|
copy_config.operation = regs.operation;
|
||||||
|
copy_config.filter = regs.blit_control.filter;
|
||||||
|
copy_config.src_rect = src_rect;
|
||||||
|
copy_config.dst_rect = dst_rect;
|
||||||
|
|
||||||
if (!rasterizer.AccelerateSurfaceCopy(regs.src, regs.dst, src_rect, dst_rect)) {
|
if (!rasterizer.AccelerateSurfaceCopy(regs.src, regs.dst, copy_config)) {
|
||||||
UNIMPLEMENTED();
|
UNIMPLEMENTED();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "common/bit_field.h"
|
#include "common/bit_field.h"
|
||||||
#include "common/common_funcs.h"
|
#include "common/common_funcs.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/math_util.h"
|
||||||
#include "video_core/gpu.h"
|
#include "video_core/gpu.h"
|
||||||
|
|
||||||
namespace Tegra {
|
namespace Tegra {
|
||||||
|
@ -38,6 +39,26 @@ public:
|
||||||
/// Write the value to the register identified by method.
|
/// Write the value to the register identified by method.
|
||||||
void CallMethod(const GPU::MethodCall& method_call);
|
void CallMethod(const GPU::MethodCall& method_call);
|
||||||
|
|
||||||
|
enum class Origin : u32 {
|
||||||
|
Center = 0,
|
||||||
|
Corner = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class Filter : u32 {
|
||||||
|
PointSample = 0, // Nearest
|
||||||
|
Linear = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class Operation : u32 {
|
||||||
|
SrcCopyAnd = 0,
|
||||||
|
ROPAnd = 1,
|
||||||
|
Blend = 2,
|
||||||
|
SrcCopy = 3,
|
||||||
|
ROP = 4,
|
||||||
|
SrcCopyPremult = 5,
|
||||||
|
BlendPremult = 6,
|
||||||
|
};
|
||||||
|
|
||||||
struct Regs {
|
struct Regs {
|
||||||
static constexpr std::size_t NUM_REGS = 0x258;
|
static constexpr std::size_t NUM_REGS = 0x258;
|
||||||
|
|
||||||
|
@ -76,16 +97,6 @@ public:
|
||||||
};
|
};
|
||||||
static_assert(sizeof(Surface) == 0x28, "Surface has incorrect size");
|
static_assert(sizeof(Surface) == 0x28, "Surface has incorrect size");
|
||||||
|
|
||||||
enum class Operation : u32 {
|
|
||||||
SrcCopyAnd = 0,
|
|
||||||
ROPAnd = 1,
|
|
||||||
Blend = 2,
|
|
||||||
SrcCopy = 3,
|
|
||||||
ROP = 4,
|
|
||||||
SrcCopyPremult = 5,
|
|
||||||
BlendPremult = 6,
|
|
||||||
};
|
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
INSERT_PADDING_WORDS(0x80);
|
INSERT_PADDING_WORDS(0x80);
|
||||||
|
@ -102,7 +113,11 @@ public:
|
||||||
|
|
||||||
INSERT_PADDING_WORDS(0x177);
|
INSERT_PADDING_WORDS(0x177);
|
||||||
|
|
||||||
u32 blit_control;
|
union {
|
||||||
|
u32 raw;
|
||||||
|
BitField<0, 1, Origin> origin;
|
||||||
|
BitField<4, 1, Filter> filter;
|
||||||
|
} blit_control;
|
||||||
|
|
||||||
INSERT_PADDING_WORDS(0x8);
|
INSERT_PADDING_WORDS(0x8);
|
||||||
|
|
||||||
|
@ -121,6 +136,13 @@ public:
|
||||||
};
|
};
|
||||||
} regs{};
|
} regs{};
|
||||||
|
|
||||||
|
struct Config {
|
||||||
|
Operation operation;
|
||||||
|
Filter filter;
|
||||||
|
Common::Rectangle<u32> src_rect;
|
||||||
|
Common::Rectangle<u32> dst_rect;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VideoCore::RasterizerInterface& rasterizer;
|
VideoCore::RasterizerInterface& rasterizer;
|
||||||
MemoryManager& memory_manager;
|
MemoryManager& memory_manager;
|
||||||
|
|
|
@ -52,8 +52,7 @@ public:
|
||||||
/// Attempt to use a faster method to perform a surface copy
|
/// Attempt to use a faster method to perform a surface copy
|
||||||
virtual bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src,
|
virtual bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src,
|
||||||
const Tegra::Engines::Fermi2D::Regs::Surface& dst,
|
const Tegra::Engines::Fermi2D::Regs::Surface& dst,
|
||||||
const Common::Rectangle<u32>& src_rect,
|
const Tegra::Engines::Fermi2D::Config& copy_config) {
|
||||||
const Common::Rectangle<u32>& dst_rect) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ OGLFramebuffer FramebufferCacheOpenGL::CreateFramebuffer(const FramebufferCacheK
|
||||||
|
|
||||||
if (key.is_single_buffer) {
|
if (key.is_single_buffer) {
|
||||||
if (key.color_attachments[0] != GL_NONE && key.colors[0]) {
|
if (key.color_attachments[0] != GL_NONE && key.colors[0]) {
|
||||||
key.colors[0]->Attach(key.color_attachments[0]);
|
key.colors[0]->Attach(key.color_attachments[0], GL_DRAW_FRAMEBUFFER);
|
||||||
glDrawBuffer(key.color_attachments[0]);
|
glDrawBuffer(key.color_attachments[0]);
|
||||||
} else {
|
} else {
|
||||||
glDrawBuffer(GL_NONE);
|
glDrawBuffer(GL_NONE);
|
||||||
|
@ -45,14 +45,16 @@ OGLFramebuffer FramebufferCacheOpenGL::CreateFramebuffer(const FramebufferCacheK
|
||||||
} else {
|
} else {
|
||||||
for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) {
|
for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) {
|
||||||
if (key.colors[index]) {
|
if (key.colors[index]) {
|
||||||
key.colors[index]->Attach(GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(index));
|
key.colors[index]->Attach(GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(index),
|
||||||
|
GL_DRAW_FRAMEBUFFER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glDrawBuffers(key.colors_count, key.color_attachments.data());
|
glDrawBuffers(key.colors_count, key.color_attachments.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key.zeta) {
|
if (key.zeta) {
|
||||||
key.zeta->Attach(key.stencil_enable ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT);
|
key.zeta->Attach(key.stencil_enable ? GL_DEPTH_STENCIL_ATTACHMENT : GL_DEPTH_ATTACHMENT,
|
||||||
|
GL_DRAW_FRAMEBUFFER);
|
||||||
}
|
}
|
||||||
|
|
||||||
return framebuffer;
|
return framebuffer;
|
||||||
|
|
|
@ -696,10 +696,9 @@ void RasterizerOpenGL::FlushAndInvalidateRegion(CacheAddr addr, u64 size) {
|
||||||
|
|
||||||
bool RasterizerOpenGL::AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src,
|
bool RasterizerOpenGL::AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src,
|
||||||
const Tegra::Engines::Fermi2D::Regs::Surface& dst,
|
const Tegra::Engines::Fermi2D::Regs::Surface& dst,
|
||||||
const Common::Rectangle<u32>& src_rect,
|
const Tegra::Engines::Fermi2D::Config& copy_config) {
|
||||||
const Common::Rectangle<u32>& dst_rect) {
|
|
||||||
MICROPROFILE_SCOPE(OpenGL_Blits);
|
MICROPROFILE_SCOPE(OpenGL_Blits);
|
||||||
texture_cache.DoFermiCopy(src, dst, src_rect, dst_rect);
|
texture_cache.DoFermiCopy(src, dst, copy_config);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,7 @@ public:
|
||||||
void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override;
|
void FlushAndInvalidateRegion(CacheAddr addr, u64 size) override;
|
||||||
bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src,
|
bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src,
|
||||||
const Tegra::Engines::Fermi2D::Regs::Surface& dst,
|
const Tegra::Engines::Fermi2D::Regs::Surface& dst,
|
||||||
const Common::Rectangle<u32>& src_rect,
|
const Tegra::Engines::Fermi2D::Config& copy_config) override;
|
||||||
const Common::Rectangle<u32>& dst_rect) override;
|
|
||||||
bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr,
|
bool AccelerateDisplay(const Tegra::FramebufferConfig& config, VAddr framebuffer_addr,
|
||||||
u32 pixel_stride) override;
|
u32 pixel_stride) override;
|
||||||
bool AccelerateDrawBatch(bool is_indexed) override;
|
bool AccelerateDrawBatch(bool is_indexed) override;
|
||||||
|
|
|
@ -378,26 +378,26 @@ CachedSurfaceView::CachedSurfaceView(CachedSurface& surface, const ViewParams& p
|
||||||
|
|
||||||
CachedSurfaceView::~CachedSurfaceView() = default;
|
CachedSurfaceView::~CachedSurfaceView() = default;
|
||||||
|
|
||||||
void CachedSurfaceView::Attach(GLenum attachment) const {
|
void CachedSurfaceView::Attach(GLenum attachment, GLenum target) const {
|
||||||
ASSERT(params.num_layers == 1 && params.num_levels == 1);
|
ASSERT(params.num_layers == 1 && params.num_levels == 1);
|
||||||
|
|
||||||
const auto& owner_params = surface.GetSurfaceParams();
|
const auto& owner_params = surface.GetSurfaceParams();
|
||||||
|
|
||||||
switch (owner_params.target) {
|
switch (owner_params.target) {
|
||||||
case SurfaceTarget::Texture1D:
|
case SurfaceTarget::Texture1D:
|
||||||
glFramebufferTexture1D(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTarget(),
|
glFramebufferTexture1D(target, attachment, surface.GetTarget(), surface.GetTexture(),
|
||||||
surface.GetTexture(), params.base_level);
|
params.base_level);
|
||||||
break;
|
break;
|
||||||
case SurfaceTarget::Texture2D:
|
case SurfaceTarget::Texture2D:
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTarget(),
|
glFramebufferTexture2D(target, attachment, surface.GetTarget(), surface.GetTexture(),
|
||||||
surface.GetTexture(), params.base_level);
|
params.base_level);
|
||||||
break;
|
break;
|
||||||
case SurfaceTarget::Texture1DArray:
|
case SurfaceTarget::Texture1DArray:
|
||||||
case SurfaceTarget::Texture2DArray:
|
case SurfaceTarget::Texture2DArray:
|
||||||
case SurfaceTarget::TextureCubemap:
|
case SurfaceTarget::TextureCubemap:
|
||||||
case SurfaceTarget::TextureCubeArray:
|
case SurfaceTarget::TextureCubeArray:
|
||||||
glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, attachment, surface.GetTexture(),
|
glFramebufferTextureLayer(target, attachment, surface.GetTexture(), params.base_level,
|
||||||
params.base_level, params.base_layer);
|
params.base_layer);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
UNIMPLEMENTED();
|
UNIMPLEMENTED();
|
||||||
|
@ -460,11 +460,10 @@ void TextureCacheOpenGL::ImageCopy(Surface src_surface, Surface dst_surface,
|
||||||
copy_params.depth);
|
copy_params.depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheOpenGL::ImageBlit(Surface src_surface, Surface dst_surface,
|
void TextureCacheOpenGL::ImageBlit(View src_view, View dst_view,
|
||||||
const Common::Rectangle<u32>& src_rect,
|
const Tegra::Engines::Fermi2D::Config& copy_config) {
|
||||||
const Common::Rectangle<u32>& dst_rect) {
|
const auto& src_params{src_view->GetSurfaceParams()};
|
||||||
const auto& src_params{src_surface->GetSurfaceParams()};
|
const auto& dst_params{dst_view->GetSurfaceParams()};
|
||||||
const auto& dst_params{dst_surface->GetSurfaceParams()};
|
|
||||||
|
|
||||||
OpenGLState prev_state{OpenGLState::GetCurState()};
|
OpenGLState prev_state{OpenGLState::GetCurState()};
|
||||||
SCOPE_EXIT({ prev_state.Apply(); });
|
SCOPE_EXIT({ prev_state.Apply(); });
|
||||||
|
@ -476,51 +475,46 @@ void TextureCacheOpenGL::ImageBlit(Surface src_surface, Surface dst_surface,
|
||||||
|
|
||||||
u32 buffers{};
|
u32 buffers{};
|
||||||
|
|
||||||
UNIMPLEMENTED_IF(src_params.target != SurfaceTarget::Texture2D);
|
UNIMPLEMENTED_IF(src_params.target == SurfaceTarget::Texture3D);
|
||||||
UNIMPLEMENTED_IF(dst_params.target != SurfaceTarget::Texture2D);
|
UNIMPLEMENTED_IF(dst_params.target == SurfaceTarget::Texture3D);
|
||||||
|
|
||||||
const GLuint src_texture{src_surface->GetTexture()};
|
|
||||||
const GLuint dst_texture{dst_surface->GetTexture()};
|
|
||||||
|
|
||||||
if (src_params.type == SurfaceType::ColorTexture) {
|
if (src_params.type == SurfaceType::ColorTexture) {
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
src_view->Attach(GL_COLOR_ATTACHMENT0, GL_READ_FRAMEBUFFER);
|
||||||
src_texture, 0);
|
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
dst_view->Attach(GL_COLOR_ATTACHMENT0, GL_DRAW_FRAMEBUFFER);
|
||||||
dst_texture, 0);
|
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
buffers = GL_COLOR_BUFFER_BIT;
|
buffers = GL_COLOR_BUFFER_BIT;
|
||||||
} else if (src_params.type == SurfaceType::Depth) {
|
} else if (src_params.type == SurfaceType::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, src_texture,
|
src_view->Attach(GL_DEPTH_ATTACHMENT, GL_READ_FRAMEBUFFER);
|
||||||
0);
|
|
||||||
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
||||||
|
|
||||||
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, dst_texture,
|
dst_view->Attach(GL_DEPTH_ATTACHMENT, GL_DRAW_FRAMEBUFFER);
|
||||||
0);
|
|
||||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
||||||
|
|
||||||
buffers = GL_DEPTH_BUFFER_BIT;
|
buffers = GL_DEPTH_BUFFER_BIT;
|
||||||
} else if (src_params.type == SurfaceType::DepthStencil) {
|
} else if (src_params.type == SurfaceType::DepthStencil) {
|
||||||
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_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
|
src_view->Attach(GL_DEPTH_STENCIL_ATTACHMENT, GL_READ_FRAMEBUFFER);
|
||||||
src_texture, 0);
|
|
||||||
|
|
||||||
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_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
|
dst_view->Attach(GL_DEPTH_STENCIL_ATTACHMENT, GL_DRAW_FRAMEBUFFER);
|
||||||
dst_texture, 0);
|
|
||||||
|
|
||||||
buffers = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
|
buffers = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Common::Rectangle<u32>& src_rect = copy_config.src_rect;
|
||||||
|
const Common::Rectangle<u32>& dst_rect = copy_config.dst_rect;
|
||||||
|
const bool is_linear = copy_config.filter == Tegra::Engines::Fermi2D::Filter::Linear;
|
||||||
|
|
||||||
glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom, dst_rect.left,
|
glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom, dst_rect.left,
|
||||||
dst_rect.top, dst_rect.right, dst_rect.bottom, buffers,
|
dst_rect.top, dst_rect.right, dst_rect.bottom, buffers,
|
||||||
buffers == GL_COLOR_BUFFER_BIT ? GL_LINEAR : GL_NEAREST);
|
is_linear ? GL_LINEAR : GL_NEAREST);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace OpenGL
|
||||||
|
|
|
@ -73,7 +73,7 @@ public:
|
||||||
~CachedSurfaceView();
|
~CachedSurfaceView();
|
||||||
|
|
||||||
/// Attaches this texture view to the current bound GL_DRAW_FRAMEBUFFER
|
/// Attaches this texture view to the current bound GL_DRAW_FRAMEBUFFER
|
||||||
void Attach(GLenum attachment) const;
|
void Attach(GLenum attachment, GLenum target) const;
|
||||||
|
|
||||||
GLuint GetTexture() {
|
GLuint GetTexture() {
|
||||||
if (is_proxy) {
|
if (is_proxy) {
|
||||||
|
@ -138,8 +138,8 @@ protected:
|
||||||
void ImageCopy(Surface src_surface, Surface dst_surface,
|
void ImageCopy(Surface src_surface, Surface dst_surface,
|
||||||
const VideoCommon::CopyParams& copy_params) override;
|
const VideoCommon::CopyParams& copy_params) override;
|
||||||
|
|
||||||
void ImageBlit(Surface src_surface, Surface dst_surface, const Common::Rectangle<u32>& src_rect,
|
void ImageBlit(View src_view, View dst_view,
|
||||||
const Common::Rectangle<u32>& dst_rect) override;
|
const Tegra::Engines::Fermi2D::Config& copy_config) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OGLFramebuffer src_framebuffer;
|
OGLFramebuffer src_framebuffer;
|
||||||
|
|
|
@ -126,14 +126,19 @@ public:
|
||||||
return MatchStructureResult::None;
|
return MatchStructureResult::None;
|
||||||
}
|
}
|
||||||
// Tiled surface
|
// Tiled surface
|
||||||
if (std::tie(params.height, params.depth, params.block_width, params.block_height,
|
if (std::tie(params.depth, params.block_width, params.block_height, params.block_depth,
|
||||||
params.block_depth, params.tile_width_spacing, params.num_levels) ==
|
params.tile_width_spacing, params.num_levels) ==
|
||||||
std::tie(rhs.height, rhs.depth, rhs.block_width, rhs.block_height, rhs.block_depth,
|
std::tie(rhs.depth, rhs.block_width, rhs.block_height, rhs.block_depth,
|
||||||
rhs.tile_width_spacing, rhs.num_levels)) {
|
rhs.tile_width_spacing, rhs.num_levels)) {
|
||||||
if (params.width == rhs.width) {
|
if (std::tie(params.width, params.height) == std::tie(rhs.width, rhs.height)) {
|
||||||
return MatchStructureResult::FullMatch;
|
return MatchStructureResult::FullMatch;
|
||||||
}
|
}
|
||||||
if (params.GetBlockAlignedWidth() == rhs.GetBlockAlignedWidth()) {
|
const u32 ws = SurfaceParams::ConvertWidth(rhs.GetBlockAlignedWidth(),
|
||||||
|
params.pixel_format, rhs.pixel_format);
|
||||||
|
const u32 hs =
|
||||||
|
SurfaceParams::ConvertHeight(rhs.height, params.pixel_format, rhs.pixel_format);
|
||||||
|
const u32 w1 = params.GetBlockAlignedWidth();
|
||||||
|
if (std::tie(w1, params.height) == std::tie(ws, hs)) {
|
||||||
return MatchStructureResult::SemiMatch;
|
return MatchStructureResult::SemiMatch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,6 +126,20 @@ public:
|
||||||
/// Returns the size of a layer in bytes in host memory for a given mipmap level.
|
/// Returns the size of a layer in bytes in host memory for a given mipmap level.
|
||||||
std::size_t GetHostLayerSize(u32 level) const;
|
std::size_t GetHostLayerSize(u32 level) const;
|
||||||
|
|
||||||
|
static u32 ConvertWidth(u32 width, VideoCore::Surface::PixelFormat pixel_format_from,
|
||||||
|
VideoCore::Surface::PixelFormat pixel_format_to) {
|
||||||
|
const u32 bw1 = VideoCore::Surface::GetDefaultBlockWidth(pixel_format_from);
|
||||||
|
const u32 bw2 = VideoCore::Surface::GetDefaultBlockWidth(pixel_format_to);
|
||||||
|
return (width * bw2 + bw1 - 1) / bw1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static u32 ConvertHeight(u32 height, VideoCore::Surface::PixelFormat pixel_format_from,
|
||||||
|
VideoCore::Surface::PixelFormat pixel_format_to) {
|
||||||
|
const u32 bh1 = VideoCore::Surface::GetDefaultBlockHeight(pixel_format_from);
|
||||||
|
const u32 bh2 = VideoCore::Surface::GetDefaultBlockHeight(pixel_format_to);
|
||||||
|
return (height * bh2 + bh1 - 1) / bh1;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the default block width.
|
/// Returns the default block width.
|
||||||
u32 GetDefaultBlockWidth() const {
|
u32 GetDefaultBlockWidth() const {
|
||||||
return VideoCore::Surface::GetDefaultBlockWidth(pixel_format);
|
return VideoCore::Surface::GetDefaultBlockWidth(pixel_format);
|
||||||
|
|
|
@ -141,11 +141,6 @@ public:
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (regs.color_mask[index].raw == 0) {
|
|
||||||
SetEmptyColorBuffer(index);
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto& config{regs.rt[index]};
|
const auto& config{regs.rt[index]};
|
||||||
const auto gpu_addr{config.Address()};
|
const auto gpu_addr{config.Address()};
|
||||||
if (!gpu_addr) {
|
if (!gpu_addr) {
|
||||||
|
@ -192,11 +187,11 @@ public:
|
||||||
|
|
||||||
void DoFermiCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src_config,
|
void DoFermiCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src_config,
|
||||||
const Tegra::Engines::Fermi2D::Regs::Surface& dst_config,
|
const Tegra::Engines::Fermi2D::Regs::Surface& dst_config,
|
||||||
const Common::Rectangle<u32>& src_rect,
|
const Tegra::Engines::Fermi2D::Config& copy_config) {
|
||||||
const Common::Rectangle<u32>& dst_rect) {
|
std::pair<TSurface, TView> dst_surface = GetFermiSurface(dst_config);
|
||||||
TSurface dst_surface = GetFermiSurface(dst_config);
|
std::pair<TSurface, TView> src_surface = GetFermiSurface(src_config);
|
||||||
ImageBlit(GetFermiSurface(src_config), dst_surface, src_rect, dst_rect);
|
ImageBlit(src_surface.second, dst_surface.second, copy_config);
|
||||||
dst_surface->MarkAsModified(true, Tick());
|
dst_surface.first->MarkAsModified(true, Tick());
|
||||||
}
|
}
|
||||||
|
|
||||||
TSurface TryFindFramebufferSurface(const u8* host_ptr) {
|
TSurface TryFindFramebufferSurface(const u8* host_ptr) {
|
||||||
|
@ -234,8 +229,8 @@ protected:
|
||||||
virtual void ImageCopy(TSurface src_surface, TSurface dst_surface,
|
virtual void ImageCopy(TSurface src_surface, TSurface dst_surface,
|
||||||
const CopyParams& copy_params) = 0;
|
const CopyParams& copy_params) = 0;
|
||||||
|
|
||||||
virtual void ImageBlit(TSurface src, TSurface dst, const Common::Rectangle<u32>& src_rect,
|
virtual void ImageBlit(TView src_view, TView dst_view,
|
||||||
const Common::Rectangle<u32>& dst_rect) = 0;
|
const Tegra::Engines::Fermi2D::Config& copy_config) = 0;
|
||||||
|
|
||||||
void Register(TSurface surface) {
|
void Register(TSurface surface) {
|
||||||
std::lock_guard lock{mutex};
|
std::lock_guard lock{mutex};
|
||||||
|
@ -282,10 +277,11 @@ protected:
|
||||||
return new_surface;
|
return new_surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
TSurface GetFermiSurface(const Tegra::Engines::Fermi2D::Regs::Surface& config) {
|
std::pair<TSurface, TView> GetFermiSurface(
|
||||||
|
const Tegra::Engines::Fermi2D::Regs::Surface& config) {
|
||||||
SurfaceParams params = SurfaceParams::CreateForFermiCopySurface(config);
|
SurfaceParams params = SurfaceParams::CreateForFermiCopySurface(config);
|
||||||
const GPUVAddr gpu_addr = config.Address();
|
const GPUVAddr gpu_addr = config.Address();
|
||||||
return GetSurface(gpu_addr, params, true).first;
|
return GetSurface(gpu_addr, params, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
|
@ -551,7 +547,21 @@ private:
|
||||||
if (view.has_value()) {
|
if (view.has_value()) {
|
||||||
const bool is_mirage = !current_surface->MatchFormat(params.pixel_format);
|
const bool is_mirage = !current_surface->MatchFormat(params.pixel_format);
|
||||||
if (is_mirage) {
|
if (is_mirage) {
|
||||||
LOG_CRITICAL(HW_GPU, "Mirage View Unsupported");
|
// On a mirage view, we need to recreate the surface under this new view
|
||||||
|
// and then obtain a view again.
|
||||||
|
SurfaceParams new_params = current_surface->GetSurfaceParams();
|
||||||
|
const u32 wh = SurfaceParams::ConvertWidth(
|
||||||
|
new_params.width, new_params.pixel_format, params.pixel_format);
|
||||||
|
const u32 hh = SurfaceParams::ConvertHeight(
|
||||||
|
new_params.height, new_params.pixel_format, params.pixel_format);
|
||||||
|
new_params.width = wh;
|
||||||
|
new_params.height = hh;
|
||||||
|
new_params.pixel_format = params.pixel_format;
|
||||||
|
std::pair<TSurface, TView> pair = RebuildSurface(current_surface, new_params);
|
||||||
|
std::optional<TView> mirage_view =
|
||||||
|
pair.first->EmplaceView(params, gpu_addr, candidate_size);
|
||||||
|
if (mirage_view)
|
||||||
|
return {pair.first, *mirage_view};
|
||||||
return RecycleSurface(overlaps, params, gpu_addr, preserve_contents, false);
|
return RecycleSurface(overlaps, params, gpu_addr, preserve_contents, false);
|
||||||
}
|
}
|
||||||
return {current_surface, *view};
|
return {current_surface, *view};
|
||||||
|
|
Loading…
Reference in a new issue