mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-11-01 04:47:53 +00:00
gl_texture_cache: Make main views be proxy textures instead of a full view.
This commit is contained in:
parent
07cc7e0c12
commit
41b4674458
2 changed files with 25 additions and 11 deletions
|
@ -228,10 +228,9 @@ CachedSurface::CachedSurface(const GPUVAddr gpu_addr, const SurfaceParams& param
|
|||
target = GetTextureTarget(params.target);
|
||||
texture = CreateTexture(params, target, internal_format);
|
||||
DecorateSurfaceName();
|
||||
main_view = CreateView(
|
||||
ViewParams(params.target, 0, params.is_layered ? params.depth : 1, 0, params.num_levels));
|
||||
main_view->DecorateViewName(gpu_addr,
|
||||
params.TargetName() + "V:" + std::to_string(view_count++));
|
||||
main_view = CreateViewInner(
|
||||
ViewParams(params.target, 0, params.is_layered ? params.depth : 1, 0, params.num_levels),
|
||||
true);
|
||||
}
|
||||
|
||||
CachedSurface::~CachedSurface() {
|
||||
|
@ -351,16 +350,24 @@ void CachedSurfaceView::DecorateViewName(GPUVAddr gpu_addr, std::string prefix)
|
|||
}
|
||||
|
||||
View CachedSurface::CreateView(const ViewParams& view_key) {
|
||||
auto view = std::make_shared<CachedSurfaceView>(*this, view_key);
|
||||
return CreateViewInner(view_key, false);
|
||||
}
|
||||
|
||||
View CachedSurface::CreateViewInner(const ViewParams& view_key, const bool is_proxy) {
|
||||
auto view = std::make_shared<CachedSurfaceView>(*this, view_key, is_proxy);
|
||||
views[view_key] = view;
|
||||
if (!is_proxy)
|
||||
view->DecorateViewName(gpu_addr, params.TargetName() + "V:" + std::to_string(view_count++));
|
||||
return view;
|
||||
}
|
||||
|
||||
CachedSurfaceView::CachedSurfaceView(CachedSurface& surface, const ViewParams& params)
|
||||
: VideoCommon::ViewBase(params), surface{surface} {
|
||||
CachedSurfaceView::CachedSurfaceView(CachedSurface& surface, const ViewParams& params,
|
||||
const bool is_proxy)
|
||||
: VideoCommon::ViewBase(params), surface{surface}, is_proxy{is_proxy} {
|
||||
target = GetTextureTarget(params.target);
|
||||
if (!is_proxy) {
|
||||
texture_view = CreateTextureView();
|
||||
}
|
||||
swizzle = EncodeSwizzle(SwizzleSource::R, SwizzleSource::G, SwizzleSource::B, SwizzleSource::A);
|
||||
}
|
||||
|
||||
|
@ -401,7 +408,8 @@ void CachedSurfaceView::ApplySwizzle(SwizzleSource x_source, SwizzleSource y_sou
|
|||
const std::array<GLint, 4> gl_swizzle = {GetSwizzleSource(x_source), GetSwizzleSource(y_source),
|
||||
GetSwizzleSource(z_source),
|
||||
GetSwizzleSource(w_source)};
|
||||
glTextureParameteriv(texture_view.handle, GL_TEXTURE_SWIZZLE_RGBA, gl_swizzle.data());
|
||||
const GLuint handle = GetTexture();
|
||||
glTextureParameteriv(handle, GL_TEXTURE_SWIZZLE_RGBA, gl_swizzle.data());
|
||||
}
|
||||
|
||||
OGLTextureView CachedSurfaceView::CreateTextureView() const {
|
||||
|
|
|
@ -51,6 +51,7 @@ protected:
|
|||
void DecorateSurfaceName();
|
||||
|
||||
View CreateView(const ViewParams& view_key) override;
|
||||
View CreateViewInner(const ViewParams& view_key, const bool is_proxy);
|
||||
|
||||
private:
|
||||
void UploadTextureMipmap(u32 level, std::vector<u8>& staging_buffer);
|
||||
|
@ -67,13 +68,17 @@ private:
|
|||
|
||||
class CachedSurfaceView final : public VideoCommon::ViewBase {
|
||||
public:
|
||||
explicit CachedSurfaceView(CachedSurface& surface, const ViewParams& params);
|
||||
explicit CachedSurfaceView(CachedSurface& surface, const ViewParams& params,
|
||||
const bool is_proxy);
|
||||
~CachedSurfaceView();
|
||||
|
||||
/// Attaches this texture view to the current bound GL_DRAW_FRAMEBUFFER
|
||||
void Attach(GLenum attachment) const;
|
||||
|
||||
GLuint GetTexture() {
|
||||
if (is_proxy) {
|
||||
return surface.GetTexture();
|
||||
}
|
||||
return texture_view.handle;
|
||||
}
|
||||
|
||||
|
@ -119,6 +124,7 @@ private:
|
|||
|
||||
OGLTextureView texture_view;
|
||||
u32 swizzle;
|
||||
bool is_proxy;
|
||||
};
|
||||
|
||||
class TextureCacheOpenGL final : public TextureCacheBase {
|
||||
|
|
Loading…
Reference in a new issue