Bug 1145501 - Extend validation of BufferData usage. r=jgilbert

This commit is contained in:
Dan Glastonbury 2015-02-03 12:06:20 +10:00
parent 2923eda99d
commit bf34887a19
5 changed files with 42 additions and 2 deletions

View File

@ -34,7 +34,8 @@ private:
virtual bool ValidateBufferTarget(GLenum target, const char* info) override;
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) override;
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) override;
virtual bool ValidateBufferUsageEnum(GLenum usage, const char* info) override;
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) override;
};

View File

@ -50,3 +50,19 @@ WebGL1Context::ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer,
return true;
}
bool
WebGL1Context::ValidateBufferUsageEnum(GLenum usage, const char* info)
{
switch (usage) {
case LOCAL_GL_STREAM_DRAW:
case LOCAL_GL_STATIC_DRAW:
case LOCAL_GL_DYNAMIC_DRAW:
return true;
default:
break;
}
ErrorInvalidEnumInfo(info, usage);
return false;
}

View File

@ -348,6 +348,7 @@ private:
virtual bool ValidateBufferTarget(GLenum target, const char* info) override;
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) override;
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) override;
virtual bool ValidateBufferUsageEnum(GLenum usage, const char* info) override;
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) override;
};

View File

@ -75,6 +75,28 @@ WebGL2Context::ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer,
return false;
}
bool
WebGL2Context::ValidateBufferUsageEnum(GLenum usage, const char* info)
{
switch (usage) {
case LOCAL_GL_DYNAMIC_COPY:
case LOCAL_GL_DYNAMIC_DRAW:
case LOCAL_GL_DYNAMIC_READ:
case LOCAL_GL_STATIC_COPY:
case LOCAL_GL_STATIC_DRAW:
case LOCAL_GL_STATIC_READ:
case LOCAL_GL_STREAM_COPY:
case LOCAL_GL_STREAM_DRAW:
case LOCAL_GL_STREAM_READ:
return true;
default:
break;
}
ErrorInvalidEnumInfo(info, usage);
return false;
}
// -------------------------------------------------------------------------
// Buffer objects

View File

@ -932,7 +932,6 @@ protected:
WebGLRefPtr<WebGLBuffer>& GetBufferSlotByTarget(GLenum target);
WebGLRefPtr<WebGLBuffer>& GetBufferSlotByTargetIndexed(GLenum target,
GLuint index);
bool ValidateBufferUsageEnum(GLenum target, const char* info);
// -----------------------------------------------------------------------------
// Queries (WebGL2ContextQueries.cpp)
@ -1389,6 +1388,7 @@ private:
virtual bool ValidateBufferTarget(GLenum target, const char* info) = 0;
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) = 0;
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) = 0;
virtual bool ValidateBufferUsageEnum(GLenum usage, const char* info) = 0;
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) = 0;
protected: