Commit 96699f1a by Nicolas Capens

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/10410Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 83a6bb93
......@@ -78,11 +78,11 @@ bool Surface::initialize()
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 @@ bool Surface::initialize()
{
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)
......
......@@ -804,22 +804,23 @@ GLenum TextureExternal::getTarget() const
}
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 > es1::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE || height > es1::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(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;
}
bool lockable = true;
......
......@@ -30,7 +30,6 @@
#include <vector>
namespace gl { class Surface; }
namespace egl { class Config; }
namespace es1
{
......
......@@ -221,8 +221,8 @@ public:
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);
};
......
......@@ -332,8 +332,8 @@ void DrawTexfvOES(const GLfloat *coords);
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"
......
......@@ -1975,19 +1975,20 @@ GLenum TextureExternal::getTarget() const
}
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;
......
......@@ -30,7 +30,6 @@
#include <vector>
namespace gl { class Surface; }
namespace egl { class Config; }
namespace es2
{
......
......@@ -244,8 +244,8 @@ public:
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);
};
......
......@@ -1340,8 +1340,8 @@ void GL_APIENTRY Register(const char *licenseKey)
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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment