Commit 0d836853 authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

gpu: fix GetResultAs callsites

GetResultAs returns a pointer to the transfer buffer. Under some
conditions, the transfer buffer may be reallocated, so we need to make
sure a GetResultAs-returned pointer isn't used across such a
reallocation.

Bug: 905336
Change-Id: I1a9699d38149c56ee5430bff125a1168ca053696
Reviewed-on: https://chromium-review.googlesource.com/c/1336152
Commit-Queue: Antoine Labour <piman@chromium.org>
Reviewed-by: default avatarJames Darpinian <jdarpinian@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608145}
parent 4cda1d40
......@@ -1657,15 +1657,15 @@ bool GLES2Implementation::GetUniformIndicesHelper(GLuint program,
GLsizei count,
const char* const* names,
GLuint* indices) {
if (!PackStringsToBucket(count, names, nullptr, "glGetUniformIndices")) {
return false;
}
typedef cmds::GetUniformIndices::Result Result;
Result* result = GetResultAs<Result*>();
if (!result) {
return false;
}
result->SetNumResults(0);
if (!PackStringsToBucket(count, names, nullptr, "glGetUniformIndices")) {
return false;
}
helper_->GetUniformIndices(program, kResultBucketId, GetResultShmId(),
GetResultShmOffset());
WaitForCmd();
......@@ -3285,7 +3285,8 @@ bool GLES2Implementation::GetActiveAttribHelper(GLuint program,
helper_->GetActiveAttrib(program, index, kResultBucketId, GetResultShmId(),
GetResultShmOffset());
WaitForCmd();
if (result->success) {
bool success = !!result->success;
if (success) {
if (size) {
*size = result->size;
}
......@@ -3294,6 +3295,7 @@ bool GLES2Implementation::GetActiveAttribHelper(GLuint program,
}
if (length || name) {
std::vector<int8_t> str;
// Note: this can invalidate |result|.
GetBucketContents(kResultBucketId, &str);
GLsizei max_size =
std::min(static_cast<size_t>(bufsize) - 1,
......@@ -3307,7 +3309,7 @@ bool GLES2Implementation::GetActiveAttribHelper(GLuint program,
}
}
}
return result->success != 0;
return success;
}
void GLES2Implementation::GetActiveAttrib(GLuint program,
......@@ -3545,12 +3547,6 @@ bool GLES2Implementation::GetActiveUniformsivHelper(GLuint program,
const GLuint* indices,
GLenum pname,
GLint* params) {
typedef cmds::GetActiveUniformsiv::Result Result;
Result* result = GetResultAs<Result*>();
if (!result) {
return false;
}
result->SetNumResults(0);
base::CheckedNumeric<size_t> bytes = static_cast<size_t>(count);
bytes *= sizeof(GLuint);
if (!bytes.IsValid()) {
......@@ -3558,6 +3554,12 @@ bool GLES2Implementation::GetActiveUniformsivHelper(GLuint program,
return false;
}
SetBucketContents(kResultBucketId, indices, bytes.ValueOrDefault(0));
typedef cmds::GetActiveUniformsiv::Result Result;
Result* result = GetResultAs<Result*>();
if (!result) {
return false;
}
result->SetNumResults(0);
helper_->GetActiveUniformsiv(program, kResultBucketId, pname,
GetResultShmId(), GetResultShmOffset());
WaitForCmd();
......
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