aboutsummaryrefslogtreecommitdiffstats
path: root/emulator
diff options
context:
space:
mode:
authorbohu <bohu@google.com>2014-10-29 11:44:42 -0700
committerbohu <bohu@google.com>2014-11-25 12:31:49 -0800
commit64a5506fd2dc6e3b1adf17ddd928a66a4756c96f (patch)
tree9636c2a42c8a6de5d215a43b476124789947ead9 /emulator
parenta3a65b66357a72fb347fdb6ff155ca0aba47536b (diff)
downloadsdk-64a5506fd2dc6e3b1adf17ddd928a66a4756c96f.zip
sdk-64a5506fd2dc6e3b1adf17ddd928a66a4756c96f.tar.gz
sdk-64a5506fd2dc6e3b1adf17ddd928a66a4756c96f.tar.bz2
validate glBufferData's usage parameter
Only GL_STREAM_DRAW, GL_STATIC_DRAW and GL_DYNAMIC_DRAW usages are allowed. Change-Id: I2d6a425363c32330d25272d26884d32610d8dd19
Diffstat (limited to 'emulator')
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp1
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp10
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/GLESvalidate.h1
3 files changed, 12 insertions, 0 deletions
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index 71b29c2..0ee71ef 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -324,6 +324,7 @@ GL_APICALL void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, G
GL_APICALL void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage){
GET_CTX();
SET_ERROR_IF(!GLESv2Validate::bufferTarget(target),GL_INVALID_ENUM);
+ SET_ERROR_IF(!GLESv2Validate::bufferUsage(usage),GL_INVALID_ENUM);
SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
ctx->setBufferData(target,size,data,usage);
}
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp
index 882d95b..8e35978 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp
+++ b/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp
@@ -78,6 +78,16 @@ bool GLESvalidate::bufferTarget(GLenum target) {
return target == GL_ARRAY_BUFFER || target == GL_ELEMENT_ARRAY_BUFFER;
}
+bool GLESvalidate::bufferUsage(GLenum usage) {
+ switch(usage) {
+ case GL_STREAM_DRAW:
+ case GL_STATIC_DRAW:
+ case GL_DYNAMIC_DRAW:
+ return true;
+ }
+ return false;
+}
+
bool GLESvalidate::bufferParam(GLenum param) {
return (param == GL_BUFFER_SIZE) || (param == GL_BUFFER_USAGE);
}
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESvalidate.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLESvalidate.h
index 3daaa7c..92c1f33 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESvalidate.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/GLESvalidate.h
@@ -25,6 +25,7 @@ static bool pixelType(GLEScontext * ctx,GLenum type);
static bool pixelOp(GLenum format,GLenum type);
static bool pixelFrmt(GLEScontext* ctx , GLenum format);
static bool bufferTarget(GLenum target);
+static bool bufferUsage(GLenum usage);
static bool bufferParam(GLenum param);
static bool drawMode(GLenum mode);
static bool drawType(GLenum mode);