Fix OpenGL ES 3.0 support on iOS (#1803)
This commit is contained in:
committed by
Mathias Agopian
parent
35a0b045f8
commit
c8a0dbb59a
@@ -32,7 +32,7 @@ NoopDriver::NoopDriver() noexcept : DriverBase(new ConcreteDispatcher<NoopDriver
|
||||
NoopDriver::~NoopDriver() noexcept = default;
|
||||
|
||||
backend::ShaderModel NoopDriver::getShaderModel() const noexcept {
|
||||
#if defined(GLES31_HEADERS)
|
||||
#if GLES30_HEADERS
|
||||
return backend::ShaderModel::GL_ES_30;
|
||||
#else
|
||||
return backend::ShaderModel::GL_CORE_41;
|
||||
|
||||
@@ -75,7 +75,7 @@ void OpenGLBlitter::init() noexcept {
|
||||
GLint status;
|
||||
char const* vsource[2] = { s_vertexES, s_vertexGL };
|
||||
char const* fsource[2] = { s_fragmentES, s_fragmentGL };
|
||||
const size_t index = GLES31_HEADERS ? 0 : 1;
|
||||
const size_t index = GLES30_HEADERS ? 0 : 1;
|
||||
|
||||
mVertexShader = glCreateShader(GL_VERTEX_SHADER);
|
||||
glShaderSource(mVertexShader, 1, vsource + index, nullptr);
|
||||
|
||||
@@ -90,7 +90,7 @@ OpenGLContext::OpenGLContext() noexcept {
|
||||
}
|
||||
|
||||
ShaderModel shaderModel = ShaderModel::UNKNOWN;
|
||||
if (GLES31_HEADERS) {
|
||||
if (GLES30_HEADERS) {
|
||||
if (major == 3 && minor >= 0) {
|
||||
shaderModel = ShaderModel::GL_ES_30;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ Driver* OpenGLDriver::create(
|
||||
return {};
|
||||
}
|
||||
|
||||
if (GLES31_HEADERS) {
|
||||
if (GLES30_HEADERS) {
|
||||
// we require GLES 3.1 headers, but we support GLES 3.0
|
||||
if (UTILS_UNLIKELY(!(major >= 3 && minor >= 0))) {
|
||||
PANIC_LOG("OpenGL ES 3.0 minimum needed (current %d.%d)", major, minor);
|
||||
@@ -201,7 +201,7 @@ void OpenGLDriver::initClearProgram() noexcept {
|
||||
}
|
||||
)SHADER";
|
||||
|
||||
if (GLES31_HEADERS) {
|
||||
if (GLES30_HEADERS) {
|
||||
GLint status;
|
||||
char const* const vsource = clearVertexES;
|
||||
char const* const fsource = clearFragmentES;
|
||||
@@ -234,7 +234,7 @@ void OpenGLDriver::initClearProgram() noexcept {
|
||||
}
|
||||
|
||||
void OpenGLDriver::terminateClearProgram() noexcept {
|
||||
if (GLES31_HEADERS) {
|
||||
if (GLES30_HEADERS) {
|
||||
glDetachShader(mClearProgram, mClearVertexShader);
|
||||
glDetachShader(mClearProgram, mClearFragmentShader);
|
||||
glDeleteShader(mClearVertexShader);
|
||||
@@ -1810,7 +1810,7 @@ void OpenGLDriver::beginRenderPass(Handle<HwRenderTarget> rth,
|
||||
|
||||
// glInvalidateFramebuffer appeared on GLES 3.0 and GL4.3, for simplicity we just
|
||||
// ignore it on GL (rather than having to do a runtime check).
|
||||
if (GLES31_HEADERS) {
|
||||
if (GLES30_HEADERS) {
|
||||
if (!gl.bugs.disable_invalidate_framebuffer) {
|
||||
std::array<GLenum, 3> attachments; // NOLINT
|
||||
GLsizei attachmentCount = getAttachments(attachments, rt, discardFlags);
|
||||
@@ -1862,7 +1862,7 @@ void OpenGLDriver::beginRenderPass(Handle<HwRenderTarget> rth,
|
||||
} else {
|
||||
gl.disable(GL_SCISSOR_TEST);
|
||||
}
|
||||
if (respectScissor && GLES31_HEADERS && gl.bugs.clears_hurt_performance) {
|
||||
if (respectScissor && GLES30_HEADERS && gl.bugs.clears_hurt_performance) {
|
||||
// With OpenGL ES, we clear the viewport using geometry to improve performance on certain
|
||||
// OpenGL drivers. e.g. on Adreno this avoids needless loads from the GMEM.
|
||||
clearWithGeometryPipe(clearColor, params.clearColor,
|
||||
@@ -1898,7 +1898,7 @@ void OpenGLDriver::endRenderPass(int) {
|
||||
|
||||
// glInvalidateFramebuffer appeared on GLES 3.0 and GL4.3, for simplicity we just
|
||||
// ignore it on GL (rather than having to do a runtime check).
|
||||
if (GLES31_HEADERS) {
|
||||
if (GLES30_HEADERS) {
|
||||
if (!gl.bugs.disable_invalidate_framebuffer) {
|
||||
// we wouldn't have to bind the framebuffer if we had glInvalidateNamedFramebuffer()
|
||||
gl.bindFramebuffer(GL_FRAMEBUFFER, rt->gl.fbo);
|
||||
@@ -1950,7 +1950,7 @@ void OpenGLDriver::discardSubRenderTargetBuffers(Handle<HwRenderTarget> rth,
|
||||
|
||||
// glInvalidateSubFramebuffer appeared on GLES 3.0 and GL4.3, for simplicity we just
|
||||
// ignore it on GL (rather than having to do a runtime check).
|
||||
if (GLES31_HEADERS) {
|
||||
if (GLES30_HEADERS) {
|
||||
// we wouldn't have to bind the framebuffer if we had glInvalidateNamedFramebuffer()
|
||||
GLRenderTarget const* rt = handle_cast<GLRenderTarget const*>(rth);
|
||||
|
||||
@@ -2510,7 +2510,7 @@ void OpenGLDriver::clearWithGeometryPipe(
|
||||
auto& gl = mContext;
|
||||
|
||||
// GLES is required to use this method; see initClearProgram.
|
||||
assert(GLES31_HEADERS);
|
||||
assert(GLES30_HEADERS);
|
||||
|
||||
// TODO: handle stencil clear with geometry as well
|
||||
if (clearStencil) {
|
||||
|
||||
@@ -98,6 +98,12 @@
|
||||
#error "Minimum header version must be OpenGL ES 3.0 or OpenGL 4.1"
|
||||
#endif
|
||||
|
||||
#if defined(GL_ES_VERSION_3_0)
|
||||
#define GLES30_HEADERS true
|
||||
#else
|
||||
#define GLES30_HEADERS false
|
||||
#endif
|
||||
|
||||
#if defined(GL_ES_VERSION_3_1)
|
||||
#define GLES31_HEADERS true
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user