Fix checking dimensions of surfaces. We were only checking depth stencil surface height against OUTLINE_RESOLUTION. Instead both color buffers and depth stencil buffers should be checked against the GL implementation's limits. Change-Id: I3784f80df4ea950760db7273185fb9312802bdd3 Reviewed-on: https://swiftshader-review.googlesource.com/10410 Reviewed-by: Alexis Hétu <sugoi@google.com> Reviewed-by: Nicolas Capens <capn@google.com> Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/libEGL/Surface.cpp b/src/OpenGL/libEGL/Surface.cpp index d195b46..8cb3b39 100644 --- a/src/OpenGL/libEGL/Surface.cpp +++ b/src/OpenGL/libEGL/Surface.cpp
@@ -78,11 +78,11 @@ if(libGLES_CM) { - backBuffer = libGLES_CM->createBackBuffer(width, height, config); + backBuffer = libGLES_CM->createBackBuffer(width, height, config->mRenderTargetFormat, config->mSamples); } else if(libGLESv2) { - backBuffer = libGLESv2->createBackBuffer(width, height, config); + backBuffer = libGLESv2->createBackBuffer(width, height, config->mRenderTargetFormat, config->mSamples); } if(!backBuffer) @@ -96,11 +96,11 @@ { if(libGLES_CM) { - depthStencil = libGLES_CM->createDepthStencil(width, height, config->mDepthStencilFormat, config->mSamples, false); + depthStencil = libGLES_CM->createDepthStencil(width, height, config->mDepthStencilFormat, config->mSamples); } else if(libGLESv2) { - depthStencil = libGLESv2->createDepthStencil(width, height, config->mDepthStencilFormat, config->mSamples, false); + depthStencil = libGLESv2->createDepthStencil(width, height, config->mDepthStencilFormat, config->mSamples); } if(!depthStencil)
diff --git a/src/OpenGL/libGLES_CM/Texture.cpp b/src/OpenGL/libGLES_CM/Texture.cpp index 494439a..58b80d0 100644 --- a/src/OpenGL/libGLES_CM/Texture.cpp +++ b/src/OpenGL/libGLES_CM/Texture.cpp
@@ -804,22 +804,23 @@ } -egl::Image *createBackBuffer(int width, int height, const egl::Config *config) +egl::Image *createBackBuffer(int width, int height, sw::Format format, int multiSampleDepth) { - if(config) - { - return egl::Image::create(width, height, config->mRenderTargetFormat, config->mSamples, false); - } - - return nullptr; -} - -egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard) -{ - if(height > sw::OUTLINE_RESOLUTION) + if(width > es1::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE || height > es1::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE) { ERR("Invalid parameters: %dx%d", width, height); - return 0; + return nullptr; + } + + return egl::Image::create(width, height, format, multiSampleDepth, false); +} + +egl::Image *createDepthStencil(int width, int height, sw::Format format, int multiSampleDepth) +{ + if(width > es1::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE || height > es1::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE) + { + ERR("Invalid parameters: %dx%d", width, height); + return nullptr; } bool lockable = true;
diff --git a/src/OpenGL/libGLES_CM/Texture.h b/src/OpenGL/libGLES_CM/Texture.h index 0c7efc8..c99c1dc 100644 --- a/src/OpenGL/libGLES_CM/Texture.h +++ b/src/OpenGL/libGLES_CM/Texture.h
@@ -30,7 +30,6 @@ #include <vector> namespace gl { class Surface; } -namespace egl { class Config; } namespace es1 {
diff --git a/src/OpenGL/libGLES_CM/libGLES_CM.hpp b/src/OpenGL/libGLES_CM/libGLES_CM.hpp index 1c66f18..5a3a289 100644 --- a/src/OpenGL/libGLES_CM/libGLES_CM.hpp +++ b/src/OpenGL/libGLES_CM/libGLES_CM.hpp
@@ -221,8 +221,8 @@ egl::Context *(*es1CreateContext)(egl::Display *display, const egl::Context *shareContext, const egl::Config *config); __eglMustCastToProperFunctionPointerType (*es1GetProcAddress)(const char *procname); - egl::Image *(*createBackBuffer)(int width, int height, const egl::Config *config); - egl::Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard); + egl::Image *(*createBackBuffer)(int width, int height, sw::Format format, int multiSampleDepth); + egl::Image *(*createDepthStencil)(int width, int height, sw::Format format, int multiSampleDepth); sw::FrameBuffer *(*createFrameBuffer)(void *nativeDisplay, EGLNativeWindowType window, int width, int height); };
diff --git a/src/OpenGL/libGLES_CM/main.cpp b/src/OpenGL/libGLES_CM/main.cpp index 6a2ddc9..f2bd0b7 100644 --- a/src/OpenGL/libGLES_CM/main.cpp +++ b/src/OpenGL/libGLES_CM/main.cpp
@@ -332,8 +332,8 @@ egl::Context *es1CreateContext(egl::Display *display, const egl::Context *shareContext, const egl::Config *config); extern "C" __eglMustCastToProperFunctionPointerType es1GetProcAddress(const char *procname); -egl::Image *createBackBuffer(int width, int height, const egl::Config *config); -egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard); +egl::Image *createBackBuffer(int width, int height, sw::Format format, int multiSampleDepth); +egl::Image *createDepthStencil(int width, int height, sw::Format format, int multiSampleDepth); sw::FrameBuffer *createFrameBuffer(void *nativeDisplay, EGLNativeWindowType window, int width, int height); extern "C"
diff --git a/src/OpenGL/libGLESv2/Texture.cpp b/src/OpenGL/libGLESv2/Texture.cpp index 95cb8db..bf83472 100644 --- a/src/OpenGL/libGLESv2/Texture.cpp +++ b/src/OpenGL/libGLESv2/Texture.cpp
@@ -1975,19 +1975,20 @@ } -egl::Image *createBackBuffer(int width, int height, const egl::Config *config) +egl::Image *createBackBuffer(int width, int height, sw::Format format, int multiSampleDepth) { - if(config) + if(width > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE || height > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE) { - return egl::Image::create(width, height, config->mRenderTargetFormat, config->mSamples, false); + ERR("Invalid parameters: %dx%d", width, height); + return nullptr; } - return nullptr; + return egl::Image::create(width, height, format, multiSampleDepth, false); } -egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard) +egl::Image *createDepthStencil(int width, int height, sw::Format format, int multiSampleDepth) { - if(width == 0 || height == 0 || height > sw::OUTLINE_RESOLUTION) + if(width > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE || height > es2::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE) { ERR("Invalid parameters: %dx%d", width, height); return nullptr;
diff --git a/src/OpenGL/libGLESv2/Texture.h b/src/OpenGL/libGLESv2/Texture.h index 1b90f25..143c51e 100644 --- a/src/OpenGL/libGLESv2/Texture.h +++ b/src/OpenGL/libGLESv2/Texture.h
@@ -30,7 +30,6 @@ #include <vector> namespace gl { class Surface; } -namespace egl { class Config; } namespace es2 {
diff --git a/src/OpenGL/libGLESv2/libGLESv2.hpp b/src/OpenGL/libGLESv2/libGLESv2.hpp index 15ae813..42febd8 100644 --- a/src/OpenGL/libGLESv2/libGLESv2.hpp +++ b/src/OpenGL/libGLESv2/libGLESv2.hpp
@@ -244,8 +244,8 @@ egl::Context *(*es2CreateContext)(egl::Display *display, const egl::Context *shareContext, int clientVersion, const egl::Config *config); __eglMustCastToProperFunctionPointerType (*es2GetProcAddress)(const char *procname); - egl::Image *(*createBackBuffer)(int width, int height, const egl::Config *config); - egl::Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard); + egl::Image *(*createBackBuffer)(int width, int height, sw::Format format, int multiSampleDepth); + egl::Image *(*createDepthStencil)(int width, int height, sw::Format format, int multiSampleDepth); sw::FrameBuffer *(*createFrameBuffer)(void *nativeDisplay, EGLNativeWindowType window, int width, int height); };
diff --git a/src/OpenGL/libGLESv2/main.cpp b/src/OpenGL/libGLESv2/main.cpp index 3e6021c..81b1689 100644 --- a/src/OpenGL/libGLESv2/main.cpp +++ b/src/OpenGL/libGLESv2/main.cpp
@@ -1340,8 +1340,8 @@ egl::Context *es2CreateContext(egl::Display *display, const egl::Context *shareContext, int clientVersion, const egl::Config *config); extern "C" __eglMustCastToProperFunctionPointerType es2GetProcAddress(const char *procname); -egl::Image *createBackBuffer(int width, int height, const egl::Config *config); -egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard); +egl::Image *createBackBuffer(int width, int height, sw::Format format, int multiSampleDepth); +egl::Image *createDepthStencil(int width, int height, sw::Format format, int multiSampleDepth); sw::FrameBuffer *createFrameBuffer(void *nativeDisplay, EGLNativeWindowType window, int width, int height); LibGLESv2exports::LibGLESv2exports()