Bug 1248580 - strip the uploading element num according to the uniform array size. r=jgilbert

This commit is contained in:
JerryShih 2016-05-25 16:27:41 +02:00
Родитель ce5b229c18
Коммит fc10d03978
4 изменённых файлов: 19 добавлений и 7 удалений

Просмотреть файл

@ -495,9 +495,10 @@ WebGLContext::ValidateUniformArraySetter(WebGLUniformLocation* loc,
if (!loc->ValidateArrayLength(setterElemSize, setterArraySize, this, funcName))
return false;
MOZ_ASSERT((size_t)loc->mActiveInfo->mElemCount > loc->mArrayIndex);
size_t uniformElemCount = loc->mActiveInfo->mElemCount - loc->mArrayIndex;
*out_rawLoc = loc->mLoc;
*out_numElementsToUpload = std::min((size_t)loc->mActiveInfo->mElemCount,
setterArraySize / setterElemSize);
*out_numElementsToUpload = std::min(uniformElemCount, setterArraySize / setterElemSize);
return true;
}

Просмотреть файл

@ -786,8 +786,14 @@ WebGLProgram::GetUniformLocation(const nsAString& userName_wide) const
const NS_LossyConvertUTF16toASCII userName(userName_wide);
nsDependentCString baseUserName;
bool isArray;
size_t arrayIndex;
bool isArray = false;
// GLES 2.0.25, Section 2.10, p35
// If the the uniform location is an array, then the location of the first
// element of that array can be retrieved by either using the name of the
// uniform array, or the name of the uniform array appended with "[0]".
// The ParseName() can't recognize this rule. So always initialize
// arrayIndex with 0.
size_t arrayIndex = 0;
if (!ParseName(userName, &baseUserName, &isArray, &arrayIndex))
return nullptr;
@ -812,7 +818,8 @@ WebGLProgram::GetUniformLocation(const nsAString& userName_wide) const
return nullptr;
RefPtr<WebGLUniformLocation> locObj = new WebGLUniformLocation(mContext, LinkInfo(),
loc, activeInfo);
loc, arrayIndex,
activeInfo);
return locObj.forget();
}

Просмотреть файл

@ -16,10 +16,13 @@ namespace mozilla {
WebGLUniformLocation::WebGLUniformLocation(WebGLContext* webgl,
const webgl::LinkedProgramInfo* linkInfo,
GLuint loc, const WebGLActiveInfo* activeInfo)
GLuint loc,
size_t arrayIndex,
const WebGLActiveInfo* activeInfo)
: WebGLContextBoundObject(webgl)
, mLinkInfo(linkInfo)
, mLoc(loc)
, mArrayIndex(arrayIndex)
, mActiveInfo(activeInfo)
{ }

Просмотреть файл

@ -41,10 +41,11 @@ public:
const WeakPtr<const webgl::LinkedProgramInfo> mLinkInfo;
const GLuint mLoc;
const size_t mArrayIndex;
const WebGLActiveInfo* const mActiveInfo;
WebGLUniformLocation(WebGLContext* webgl, const webgl::LinkedProgramInfo* linkInfo,
GLuint loc, const WebGLActiveInfo* activeInfo);
GLuint loc, size_t arrayIndex, const WebGLActiveInfo* activeInfo);
bool ValidateForProgram(WebGLProgram* prog, WebGLContext* webgl,
const char* funcName) const;