gl_state: Remove image tracking
This commit is contained in:
parent
9677db03da
commit
17a7fa751b
5 changed files with 12 additions and 24 deletions
|
@ -633,7 +633,6 @@ void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) {
|
||||||
bind_ubo_pushbuffer.Bind();
|
bind_ubo_pushbuffer.Bind();
|
||||||
bind_ssbo_pushbuffer.Bind();
|
bind_ssbo_pushbuffer.Bind();
|
||||||
|
|
||||||
state.ApplyImages();
|
|
||||||
state.ApplyShaderProgram();
|
state.ApplyShaderProgram();
|
||||||
state.ApplyProgramPipeline();
|
state.ApplyProgramPipeline();
|
||||||
|
|
||||||
|
@ -899,7 +898,7 @@ void RasterizerOpenGL::SetupImage(u32 binding, const Tegra::Texture::TICEntry& t
|
||||||
const GLShader::ImageEntry& entry) {
|
const GLShader::ImageEntry& entry) {
|
||||||
const auto view = texture_cache.GetImageSurface(tic, entry);
|
const auto view = texture_cache.GetImageSurface(tic, entry);
|
||||||
if (!view) {
|
if (!view) {
|
||||||
state.images[binding] = 0;
|
glBindImageTexture(binding, 0, 0, GL_FALSE, 0, GL_READ_ONLY, GL_R8);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!tic.IsBuffer()) {
|
if (!tic.IsBuffer()) {
|
||||||
|
@ -908,7 +907,8 @@ void RasterizerOpenGL::SetupImage(u32 binding, const Tegra::Texture::TICEntry& t
|
||||||
if (entry.IsWritten()) {
|
if (entry.IsWritten()) {
|
||||||
view->MarkAsModified(texture_cache.Tick());
|
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() {
|
void RasterizerOpenGL::SyncViewport() {
|
||||||
|
|
|
@ -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() {
|
void OpenGLState::Apply() {
|
||||||
MICROPROFILE_SCOPE(OpenGL_State);
|
MICROPROFILE_SCOPE(OpenGL_State);
|
||||||
ApplyFramebufferState();
|
ApplyFramebufferState();
|
||||||
ApplyShaderProgram();
|
ApplyShaderProgram();
|
||||||
ApplyProgramPipeline();
|
ApplyProgramPipeline();
|
||||||
ApplyImages();
|
|
||||||
ApplyRenderBuffer();
|
ApplyRenderBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,6 @@ namespace OpenGL {
|
||||||
|
|
||||||
class OpenGLState {
|
class OpenGLState {
|
||||||
public:
|
public:
|
||||||
static constexpr std::size_t NumImages = 8 * 5;
|
|
||||||
std::array<GLuint, NumImages> images = {};
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
GLuint read_framebuffer = 0; // GL_READ_FRAMEBUFFER_BINDING
|
GLuint read_framebuffer = 0; // GL_READ_FRAMEBUFFER_BINDING
|
||||||
GLuint draw_framebuffer = 0; // GL_DRAW_FRAMEBUFFER_BINDING
|
GLuint draw_framebuffer = 0; // GL_DRAW_FRAMEBUFFER_BINDING
|
||||||
|
@ -38,7 +35,6 @@ public:
|
||||||
void ApplyFramebufferState();
|
void ApplyFramebufferState();
|
||||||
void ApplyShaderProgram();
|
void ApplyShaderProgram();
|
||||||
void ApplyProgramPipeline();
|
void ApplyProgramPipeline();
|
||||||
void ApplyImages();
|
|
||||||
void ApplyRenderBuffer();
|
void ApplyRenderBuffer();
|
||||||
|
|
||||||
/// Resets any references to the given resource
|
/// Resets any references to the given resource
|
||||||
|
|
|
@ -397,6 +397,7 @@ CachedSurfaceView::CachedSurfaceView(CachedSurface& surface, const ViewParams& p
|
||||||
const bool is_proxy)
|
const bool is_proxy)
|
||||||
: VideoCommon::ViewBase(params), surface{surface}, is_proxy{is_proxy} {
|
: VideoCommon::ViewBase(params), surface{surface}, is_proxy{is_proxy} {
|
||||||
target = GetTextureTarget(params.target);
|
target = GetTextureTarget(params.target);
|
||||||
|
format = GetFormatTuple(surface.GetSurfaceParams().pixel_format).internal_format;
|
||||||
if (!is_proxy) {
|
if (!is_proxy) {
|
||||||
texture_view = CreateTextureView();
|
texture_view = CreateTextureView();
|
||||||
}
|
}
|
||||||
|
@ -467,17 +468,12 @@ void CachedSurfaceView::ApplySwizzle(SwizzleSource x_source, SwizzleSource y_sou
|
||||||
}
|
}
|
||||||
|
|
||||||
OGLTextureView CachedSurfaceView::CreateTextureView() const {
|
OGLTextureView CachedSurfaceView::CreateTextureView() const {
|
||||||
const auto& owner_params = surface.GetSurfaceParams();
|
|
||||||
OGLTextureView texture_view;
|
OGLTextureView texture_view;
|
||||||
texture_view.Create();
|
texture_view.Create();
|
||||||
|
|
||||||
const GLuint handle{texture_view.handle};
|
glTextureView(texture_view.handle, target, surface.texture.handle, format, params.base_level,
|
||||||
const FormatTuple& tuple{GetFormatTuple(owner_params.pixel_format)};
|
|
||||||
|
|
||||||
glTextureView(handle, target, surface.texture.handle, tuple.internal_format, params.base_level,
|
|
||||||
params.num_levels, params.base_layer, params.num_layers);
|
params.num_levels, params.base_layer, params.num_layers);
|
||||||
|
ApplyTextureDefaults(surface.GetSurfaceParams(), texture_view.handle);
|
||||||
ApplyTextureDefaults(owner_params, handle);
|
|
||||||
|
|
||||||
return texture_view;
|
return texture_view;
|
||||||
}
|
}
|
||||||
|
@ -521,9 +517,7 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
|
||||||
const auto& dst_params{dst_view->GetSurfaceParams()};
|
const auto& dst_params{dst_view->GetSurfaceParams()};
|
||||||
|
|
||||||
OpenGLState prev_state{OpenGLState::GetCurState()};
|
OpenGLState prev_state{OpenGLState::GetCurState()};
|
||||||
SCOPE_EXIT({
|
SCOPE_EXIT({ prev_state.Apply(); });
|
||||||
prev_state.Apply();
|
|
||||||
});
|
|
||||||
|
|
||||||
OpenGLState state;
|
OpenGLState state;
|
||||||
state.draw.read_framebuffer = src_framebuffer.handle;
|
state.draw.read_framebuffer = src_framebuffer.handle;
|
||||||
|
|
|
@ -96,6 +96,10 @@ public:
|
||||||
return texture_view.handle;
|
return texture_view.handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GLenum GetFormat() const {
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
const SurfaceParams& GetSurfaceParams() const {
|
const SurfaceParams& GetSurfaceParams() const {
|
||||||
return surface.GetSurfaceParams();
|
return surface.GetSurfaceParams();
|
||||||
}
|
}
|
||||||
|
@ -113,6 +117,7 @@ private:
|
||||||
|
|
||||||
CachedSurface& surface;
|
CachedSurface& surface;
|
||||||
GLenum target{};
|
GLenum target{};
|
||||||
|
GLenum format{};
|
||||||
|
|
||||||
OGLTextureView texture_view;
|
OGLTextureView texture_view;
|
||||||
u32 swizzle{};
|
u32 swizzle{};
|
||||||
|
|
Loading…
Reference in a new issue