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/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"