mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +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
|
@ -228,10 +228,9 @@ CachedSurface::CachedSurface(const GPUVAddr gpu_addr, const SurfaceParams& param
|
||||||
target = GetTextureTarget(params.target);
|
target = GetTextureTarget(params.target);
|
||||||
texture = CreateTexture(params, target, internal_format);
|
texture = CreateTexture(params, target, internal_format);
|
||||||
DecorateSurfaceName();
|
DecorateSurfaceName();
|
||||||
main_view = CreateView(
|
main_view = CreateViewInner(
|
||||||
ViewParams(params.target, 0, params.is_layered ? params.depth : 1, 0, params.num_levels));
|
ViewParams(params.target, 0, params.is_layered ? params.depth : 1, 0, params.num_levels),
|
||||||
main_view->DecorateViewName(gpu_addr,
|
true);
|
||||||
params.TargetName() + "V:" + std::to_string(view_count++));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedSurface::~CachedSurface() {
|
CachedSurface::~CachedSurface() {
|
||||||
|
@ -351,16 +350,24 @@ void CachedSurfaceView::DecorateViewName(GPUVAddr gpu_addr, std::string prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
View CachedSurface::CreateView(const ViewParams& view_key) {
|
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;
|
views[view_key] = view;
|
||||||
view->DecorateViewName(gpu_addr, params.TargetName() + "V:" + std::to_string(view_count++));
|
if (!is_proxy)
|
||||||
|
view->DecorateViewName(gpu_addr, params.TargetName() + "V:" + std::to_string(view_count++));
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
CachedSurfaceView::CachedSurfaceView(CachedSurface& surface, const ViewParams& params)
|
CachedSurfaceView::CachedSurfaceView(CachedSurface& surface, const ViewParams& params,
|
||||||
: VideoCommon::ViewBase(params), surface{surface} {
|
const bool is_proxy)
|
||||||
|
: VideoCommon::ViewBase(params), surface{surface}, is_proxy{is_proxy} {
|
||||||
target = GetTextureTarget(params.target);
|
target = GetTextureTarget(params.target);
|
||||||
texture_view = CreateTextureView();
|
if (!is_proxy) {
|
||||||
|
texture_view = CreateTextureView();
|
||||||
|
}
|
||||||
swizzle = EncodeSwizzle(SwizzleSource::R, SwizzleSource::G, SwizzleSource::B, SwizzleSource::A);
|
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),
|
const std::array<GLint, 4> gl_swizzle = {GetSwizzleSource(x_source), GetSwizzleSource(y_source),
|
||||||
GetSwizzleSource(z_source),
|
GetSwizzleSource(z_source),
|
||||||
GetSwizzleSource(w_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 {
|
OGLTextureView CachedSurfaceView::CreateTextureView() const {
|
||||||
|
|
|
@ -51,6 +51,7 @@ protected:
|
||||||
void DecorateSurfaceName();
|
void DecorateSurfaceName();
|
||||||
|
|
||||||
View CreateView(const ViewParams& view_key) override;
|
View CreateView(const ViewParams& view_key) override;
|
||||||
|
View CreateViewInner(const ViewParams& view_key, const bool is_proxy);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UploadTextureMipmap(u32 level, std::vector<u8>& staging_buffer);
|
void UploadTextureMipmap(u32 level, std::vector<u8>& staging_buffer);
|
||||||
|
@ -67,13 +68,17 @@ private:
|
||||||
|
|
||||||
class CachedSurfaceView final : public VideoCommon::ViewBase {
|
class CachedSurfaceView final : public VideoCommon::ViewBase {
|
||||||
public:
|
public:
|
||||||
explicit CachedSurfaceView(CachedSurface& surface, const ViewParams& params);
|
explicit CachedSurfaceView(CachedSurface& surface, const ViewParams& params,
|
||||||
|
const bool is_proxy);
|
||||||
~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) const;
|
||||||
|
|
||||||
GLuint GetTexture() {
|
GLuint GetTexture() {
|
||||||
|
if (is_proxy) {
|
||||||
|
return surface.GetTexture();
|
||||||
|
}
|
||||||
return texture_view.handle;
|
return texture_view.handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +124,7 @@ private:
|
||||||
|
|
||||||
OGLTextureView texture_view;
|
OGLTextureView texture_view;
|
||||||
u32 swizzle;
|
u32 swizzle;
|
||||||
|
bool is_proxy;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextureCacheOpenGL final : public TextureCacheBase {
|
class TextureCacheOpenGL final : public TextureCacheBase {
|
||||||
|
|
Loading…
Reference in a new issue