2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

gl_state: Remove image tracking

This commit is contained in:
ReinUsesLisp 2019-12-26 04:17:02 -03:00
parent 9677db03da
commit 17a7fa751b
5 changed files with 12 additions and 24 deletions

View file

@ -633,7 +633,6 @@ void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) {
bind_ubo_pushbuffer.Bind();
bind_ssbo_pushbuffer.Bind();
state.ApplyImages();
state.ApplyShaderProgram();
state.ApplyProgramPipeline();
@ -899,7 +898,7 @@ void RasterizerOpenGL::SetupImage(u32 binding, const Tegra::Texture::TICEntry& t
const GLShader::ImageEntry& entry) {
const auto view = texture_cache.GetImageSurface(tic, entry);
if (!view) {
state.images[binding] = 0;
glBindImageTexture(binding, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R8);
return;
}
if (!tic.IsBuffer()) {
@ -908,7 +907,8 @@ void RasterizerOpenGL::SetupImage(u32 binding, const Tegra::Texture::TICEntry& t
if (entry.IsWritten()) {
view->MarkAsModified(texture_cache.Tick());
}
state.images[binding] = view->GetTexture();
glBindImageTexture(binding, view->GetTexture(), 0, GL_TRUE, 0, GL_READ_WRITE,
view->GetFormat());
}
void RasterizerOpenGL::SyncViewport() {

View file

@ -113,18 +113,11 @@ void OpenGLState::ApplyRenderBuffer() {
}
}
void OpenGLState::ApplyImages() {
if (const auto update = UpdateArray(cur_state.images, images)) {
glBindImageTextures(update->first, update->second, images.data() + update->first);
}
}
void OpenGLState::Apply() {
MICROPROFILE_SCOPE(OpenGL_State);
ApplyFramebufferState();
ApplyShaderProgram();
ApplyProgramPipeline();
ApplyImages();
ApplyRenderBuffer();
}

View file

@ -13,9 +13,6 @@ namespace OpenGL {
class OpenGLState {
public:
static constexpr std::size_t NumImages = 8 * 5;
std::array<GLuint, NumImages> images = {};
struct {
GLuint read_framebuffer = 0; // GL_READ_FRAMEBUFFER_BINDING
GLuint draw_framebuffer = 0; // GL_DRAW_FRAMEBUFFER_BINDING
@ -38,7 +35,6 @@ public:
void ApplyFramebufferState();
void ApplyShaderProgram();
void ApplyProgramPipeline();
void ApplyImages();
void ApplyRenderBuffer();
/// Resets any references to the given resource

View file

@ -397,6 +397,7 @@ CachedSurfaceView::CachedSurfaceView(CachedSurface& surface, const ViewParams& p
const bool is_proxy)
: VideoCommon::ViewBase(params), surface{surface}, is_proxy{is_proxy} {
target = GetTextureTarget(params.target);
format = GetFormatTuple(surface.GetSurfaceParams().pixel_format).internal_format;
if (!is_proxy) {
texture_view = CreateTextureView();
}
@ -467,17 +468,12 @@ void CachedSurfaceView::ApplySwizzle(SwizzleSource x_source, SwizzleSource y_sou
}
OGLTextureView CachedSurfaceView::CreateTextureView() const {
const auto& owner_params = surface.GetSurfaceParams();
OGLTextureView texture_view;
texture_view.Create();
const GLuint handle{texture_view.handle};
const FormatTuple& tuple{GetFormatTuple(owner_params.pixel_format)};
glTextureView(handle, target, surface.texture.handle, tuple.internal_format, params.base_level,
glTextureView(texture_view.handle, target, surface.texture.handle, format, params.base_level,
params.num_levels, params.base_layer, params.num_layers);
ApplyTextureDefaults(owner_params, handle);
ApplyTextureDefaults(surface.GetSurfaceParams(), texture_view.handle);
return texture_view;
}
@ -521,9 +517,7 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
const auto& dst_params{dst_view->GetSurfaceParams()};
OpenGLState prev_state{OpenGLState::GetCurState()};
SCOPE_EXIT({
prev_state.Apply();
});
SCOPE_EXIT({ prev_state.Apply(); });
OpenGLState state;
state.draw.read_framebuffer = src_framebuffer.handle;

View file

@ -96,6 +96,10 @@ public:
return texture_view.handle;
}
GLenum GetFormat() const {
return format;
}
const SurfaceParams& GetSurfaceParams() const {
return surface.GetSurfaceParams();
}
@ -113,6 +117,7 @@ private:
CachedSurface& surface;
GLenum target{};
GLenum format{};
OGLTextureView texture_view;
u32 swizzle{};