Skip to content

Commit

Permalink
GLES: Move some vendor bug checks to Draw.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Dec 24, 2018
1 parent 9a3de5c commit b420ca1
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion GPU/GLES/TextureCacheGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ void TextureCacheGLES::BuildTexture(TexCacheEntry *const entry) {
}
} else {
// Avoid PowerVR driver bug
if (canAutoGen && w > 1 && h > 1 && !(h > w && (gl_extensions.bugs & BUG_PVR_GENMIPMAP_HEIGHT_GREATER))) { // Really! only seems to fail if height > width
if (canAutoGen && w > 1 && h > 1 && !(h > w && draw_->GetBugs().Has(Draw::Bugs::PVR_GENMIPMAP_HEIGHT_GREATER))) { // Really! only seems to fail if height > width
// NOTICE_LOG(G3D, "Generating mipmap for texture sized %dx%d%d", w, h, (int)format);
genMips = true;
} else {
Expand Down
2 changes: 1 addition & 1 deletion Qt/QtMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class QtGLGraphicsContext : public GraphicsContext {
}

void ThreadStart() override {
renderManager_->ThreadStart();
renderManager_->ThreadStart(draw_);
}

bool ThreadFrame() override {
Expand Down
2 changes: 1 addition & 1 deletion Windows/GPU/WindowsGLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ void WindowsGLContext::Resize() {
}

void WindowsGLContext::ThreadStart() {
renderManager_->ThreadStart();
renderManager_->ThreadStart(draw_);
}

bool WindowsGLContext::ThreadFrame() {
Expand Down
2 changes: 1 addition & 1 deletion android/jni/AndroidEGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AndroidEGLGraphicsContext : public AndroidGraphicsContext {
}

void ThreadStart() override {
renderManager_->ThreadStart();
renderManager_->ThreadStart(draw_);
}

bool ThreadFrame() override {
Expand Down
2 changes: 1 addition & 1 deletion android/jni/AndroidJavaGLContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AndroidJavaEGLGraphicsContext : public AndroidGraphicsContext {
}

void ThreadStart() override {
renderManager_->ThreadStart();
renderManager_->ThreadStart(draw_);
}

bool ThreadFrame() override {
Expand Down
7 changes: 0 additions & 7 deletions ext/native/gfx_es2/gpu_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,6 @@ void ProcessGPUFeatures() {
WLOG("GL DRIVER BUG: PVR with bad precision");
gl_extensions.bugs |= BUG_PVR_SHADER_PRECISION_BAD;
}
gl_extensions.bugs |= BUG_PVR_GENMIPMAP_HEIGHT_GREATER;
}

// TODO: Make this check more lenient. Disabled for all right now
// because it murders performance on Mali.
if (gl_extensions.gpuVendor != GPU_VENDOR_NVIDIA) {
gl_extensions.bugs |= BUG_ANY_MAP_BUFFER_RANGE_SLOW;
}
}

Expand Down
2 changes: 0 additions & 2 deletions ext/native/gfx_es2/gpu_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ enum {
BUG_FBO_UNUSABLE = 1,
BUG_PVR_SHADER_PRECISION_BAD = 2,
BUG_PVR_SHADER_PRECISION_TERRIBLE = 4,
BUG_PVR_GENMIPMAP_HEIGHT_GREATER = 8,
BUG_ANY_MAP_BUFFER_RANGE_SLOW = 16,
};

// Extensions to look at using:
Expand Down
6 changes: 4 additions & 2 deletions ext/native/thin3d/GLRenderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "GLRenderManager.h"
#include "gfx_es2/gpu_features.h"
#include "thin3d/thin3d.h"
#include "thread/threadutil.h"
#include "base/logging.h"
#include "GPU/GPUState.h"
Expand Down Expand Up @@ -89,12 +90,13 @@ GLRenderManager::~GLRenderManager() {
_assert_(deleter_.IsEmpty());
}

void GLRenderManager::ThreadStart() {
void GLRenderManager::ThreadStart(Draw::DrawContext *draw) {
queueRunner_.CreateDeviceObjects();
threadFrame_ = threadInitFrame_;
renderThreadId = std::this_thread::get_id();

bool mapBuffers = (gl_extensions.bugs & BUG_ANY_MAP_BUFFER_RANGE_SLOW) == 0;
// Don't save draw, we don't want any thread safety confusion.
bool mapBuffers = draw->GetBugs().Has(Draw::Bugs::ANY_MAP_BUFFER_RANGE_SLOW);
bool hasBufferStorage = gl_extensions.ARB_buffer_storage || gl_extensions.EXT_buffer_storage;
if (!gl_extensions.VersionGEThan(3, 0, 0) && gl_extensions.IsGLES && !hasBufferStorage) {
// Force disable if it wouldn't work anyway.
Expand Down
6 changes: 5 additions & 1 deletion ext/native/thin3d/GLRenderManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
class GLRInputLayout;
class GLPushBuffer;

namespace Draw {
class DrawContext;
}

class GLRTexture {
public:
~GLRTexture() {
Expand Down Expand Up @@ -365,7 +369,7 @@ class GLRenderManager {
GLRenderManager();
~GLRenderManager();

void ThreadStart();
void ThreadStart(Draw::DrawContext *draw);
void ThreadEnd();
bool ThreadFrame(); // Returns false to request exiting the loop.

Expand Down
2 changes: 2 additions & 0 deletions ext/native/thin3d/thin3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ class Bugs {
enum : uint32_t {
NO_DEPTH_CANNOT_DISCARD_STENCIL = 0,
DUAL_SOURCE_BLENDING_BROKEN = 1,
ANY_MAP_BUFFER_RANGE_SLOW = 2,
PVR_GENMIPMAP_HEIGHT_GREATER = 3,
};

protected:
Expand Down
12 changes: 12 additions & 0 deletions ext/native/thin3d/thin3d_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,18 @@ OpenGLContext::OpenGLContext() {
}
}
}

// TODO: Make this check more lenient. Disabled for all right now
// because it murders performance on Mali.
if (caps_.vendor != GPUVendor::VENDOR_NVIDIA) {
bugs_.Infest(Bugs::ANY_MAP_BUFFER_RANGE_SLOW);
}

if (caps_.vendor == GPUVendor::VENDOR_IMGTEC) {
// See https://github.com/hrydgard/ppsspp/commit/8974cd675e538f4445955e3eac572a9347d84232
// TODO: Should this workaround be removed for newer devices/drivers?
bugs_.Infest(Bugs::PVR_GENMIPMAP_HEIGHT_GREATER);
}
}

OpenGLContext::~OpenGLContext() {
Expand Down
2 changes: 1 addition & 1 deletion headless/SDLHeadlessHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class GLDummyGraphicsContext : public DummyGraphicsContext {
}

void ThreadStart() override {
renderManager_->ThreadStart();
renderManager_->ThreadStart(draw_);
}

bool ThreadFrame() override {
Expand Down
2 changes: 1 addition & 1 deletion ios/ViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
return draw_;
}
void ThreadStart() override {
renderManager_->ThreadStart();
renderManager_->ThreadStart(draw_);
}

bool ThreadFrame() override {
Expand Down

0 comments on commit b420ca1

Please sign in to comment.