Commit f9a47960 authored by James Darpinian's avatar James Darpinian Committed by Commit Bot

Don't clobber results when GL_CLIENT_FAIL_GL_ERRORS is set

The ScopedResultPtr returned by GetResultAs<> needs to go out of scope before
CheckGLError can be called, when GL_CLIENT_FAIL_GL_ERRORS is set.

Bug: 1120712
Change-Id: I5f5c83ba9deb6cb161e875037a4269b67119ab4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391599Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: James Darpinian <jdarpinian@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804467}
parent 41e61b9b
...@@ -760,11 +760,14 @@ GLboolean GLES2Implementation::IsEnablediOES(GLenum target, GLuint index) { ...@@ -760,11 +760,14 @@ GLboolean GLES2Implementation::IsEnablediOES(GLenum target, GLuint index) {
<< ")"); << ")");
bool state = false; bool state = false;
typedef cmds::IsEnabled::Result Result; typedef cmds::IsEnabled::Result Result;
auto result = GetResultAs<Result>(); // Limit scope of result to avoid overlap with CheckGLError()
*result = 0; {
helper_->IsEnablediOES(target, index, GetResultShmId(), result.offset()); auto result = GetResultAs<Result>();
WaitForCmd(); *result = 0;
state = (*result) != 0; helper_->IsEnablediOES(target, index, GetResultShmId(), result.offset());
WaitForCmd();
state = (*result) != 0;
}
GPU_CLIENT_LOG("returned " << state); GPU_CLIENT_LOG("returned " << state);
CheckGLError(); CheckGLError();
...@@ -4420,35 +4423,38 @@ void GLES2Implementation::GetShaderPrecisionFormat(GLenum shadertype, ...@@ -4420,35 +4423,38 @@ void GLES2Implementation::GetShaderPrecisionFormat(GLenum shadertype,
<< static_cast<const void*>(precision) << ", "); << static_cast<const void*>(precision) << ", ");
TRACE_EVENT0("gpu", "GLES2::GetShaderPrecisionFormat"); TRACE_EVENT0("gpu", "GLES2::GetShaderPrecisionFormat");
typedef cmds::GetShaderPrecisionFormat::Result Result; typedef cmds::GetShaderPrecisionFormat::Result Result;
auto result = GetResultAs<Result>(); // Limit scope of result to avoid overlap with CheckGLError()
if (!result) { {
return; auto result = GetResultAs<Result>();
} if (!result) {
return;
GLStaticState::ShaderPrecisionKey key(shadertype, precisiontype);
GLStaticState::ShaderPrecisionMap::iterator i =
static_state_.shader_precisions.find(key);
if (i != static_state_.shader_precisions.end()) {
*result = i->second;
} else {
result->success = false;
helper_->GetShaderPrecisionFormat(shadertype, precisiontype,
GetResultShmId(), result.offset());
WaitForCmd();
if (result->success)
static_state_.shader_precisions[key] = *result;
}
if (result->success) {
if (range) {
range[0] = result->min_range;
range[1] = result->max_range;
GPU_CLIENT_LOG(" min_range: " << range[0]);
GPU_CLIENT_LOG(" min_range: " << range[1]);
} }
if (precision) {
precision[0] = result->precision; GLStaticState::ShaderPrecisionKey key(shadertype, precisiontype);
GPU_CLIENT_LOG(" min_range: " << precision[0]); GLStaticState::ShaderPrecisionMap::iterator i =
static_state_.shader_precisions.find(key);
if (i != static_state_.shader_precisions.end()) {
*result = i->second;
} else {
result->success = false;
helper_->GetShaderPrecisionFormat(shadertype, precisiontype,
GetResultShmId(), result.offset());
WaitForCmd();
if (result->success)
static_state_.shader_precisions[key] = *result;
}
if (result->success) {
if (range) {
range[0] = result->min_range;
range[1] = result->max_range;
GPU_CLIENT_LOG(" min_range: " << range[0]);
GPU_CLIENT_LOG(" min_range: " << range[1]);
}
if (precision) {
precision[0] = result->precision;
GPU_CLIENT_LOG(" min_range: " << precision[0]);
}
} }
} }
CheckGLError(); CheckGLError();
...@@ -4607,19 +4613,22 @@ void GLES2Implementation::GetUniformfv(GLuint program, ...@@ -4607,19 +4613,22 @@ void GLES2Implementation::GetUniformfv(GLuint program,
<< ")"); << ")");
TRACE_EVENT0("gpu", "GLES2::GetUniformfv"); TRACE_EVENT0("gpu", "GLES2::GetUniformfv");
typedef cmds::GetUniformfv::Result Result; typedef cmds::GetUniformfv::Result Result;
auto result = GetResultAs<Result>(); // Limit scope of result to avoid overlap with CheckGLError()
if (!result) { {
return; auto result = GetResultAs<Result>();
} if (!result) {
result->SetNumResults(0); return;
helper_->GetUniformfv(program, location, GetResultShmId(), result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
} }
}); result->SetNumResults(0);
helper_->GetUniformfv(program, location, GetResultShmId(), result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
}
});
}
CheckGLError(); CheckGLError();
} }
...@@ -4632,19 +4641,22 @@ void GLES2Implementation::GetUniformiv(GLuint program, ...@@ -4632,19 +4641,22 @@ void GLES2Implementation::GetUniformiv(GLuint program,
<< ")"); << ")");
TRACE_EVENT0("gpu", "GLES2::GetUniformiv"); TRACE_EVENT0("gpu", "GLES2::GetUniformiv");
typedef cmds::GetUniformiv::Result Result; typedef cmds::GetUniformiv::Result Result;
auto result = GetResultAs<Result>(); // Limit scope of result to avoid overlap with CheckGLError()
if (!result) { {
return; auto result = GetResultAs<Result>();
} if (!result) {
result->SetNumResults(0); return;
helper_->GetUniformiv(program, location, GetResultShmId(), result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
} }
}); result->SetNumResults(0);
helper_->GetUniformiv(program, location, GetResultShmId(), result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
}
});
}
CheckGLError(); CheckGLError();
} }
...@@ -4657,19 +4669,23 @@ void GLES2Implementation::GetUniformuiv(GLuint program, ...@@ -4657,19 +4669,23 @@ void GLES2Implementation::GetUniformuiv(GLuint program,
<< static_cast<const void*>(params) << ")"); << static_cast<const void*>(params) << ")");
TRACE_EVENT0("gpu", "GLES2::GetUniformuiv"); TRACE_EVENT0("gpu", "GLES2::GetUniformuiv");
typedef cmds::GetUniformuiv::Result Result; typedef cmds::GetUniformuiv::Result Result;
auto result = GetResultAs<Result>(); // Limit scope of result to avoid overlap with CheckGLError()
if (!result) { {
return; auto result = GetResultAs<Result>();
} if (!result) {
result->SetNumResults(0); return;
helper_->GetUniformuiv(program, location, GetResultShmId(), result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
} }
}); result->SetNumResults(0);
helper_->GetUniformuiv(program, location, GetResultShmId(),
result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
}
});
}
CheckGLError(); CheckGLError();
} }
...@@ -5510,19 +5526,22 @@ void GLES2Implementation::GetVertexAttribfv(GLuint index, ...@@ -5510,19 +5526,22 @@ void GLES2Implementation::GetVertexAttribfv(GLuint index,
} }
TRACE_EVENT0("gpu", "GLES2::GetVertexAttribfv"); TRACE_EVENT0("gpu", "GLES2::GetVertexAttribfv");
typedef cmds::GetVertexAttribfv::Result Result; typedef cmds::GetVertexAttribfv::Result Result;
auto result = GetResultAs<Result>(); // Limit scope of result to avoid overlap with CheckGLError()
if (!result) { {
return; auto result = GetResultAs<Result>();
} if (!result) {
result->SetNumResults(0); return;
helper_->GetVertexAttribfv(index, pname, GetResultShmId(), result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
} }
}); result->SetNumResults(0);
helper_->GetVertexAttribfv(index, pname, GetResultShmId(), result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
}
});
}
CheckGLError(); CheckGLError();
} }
...@@ -5540,19 +5559,22 @@ void GLES2Implementation::GetVertexAttribiv(GLuint index, ...@@ -5540,19 +5559,22 @@ void GLES2Implementation::GetVertexAttribiv(GLuint index,
} }
TRACE_EVENT0("gpu", "GLES2::GetVertexAttribiv"); TRACE_EVENT0("gpu", "GLES2::GetVertexAttribiv");
typedef cmds::GetVertexAttribiv::Result Result; typedef cmds::GetVertexAttribiv::Result Result;
auto result = GetResultAs<Result>(); // Limit scope of result to avoid overlap with CheckGLError()
if (!result) { {
return; auto result = GetResultAs<Result>();
} if (!result) {
result->SetNumResults(0); return;
helper_->GetVertexAttribiv(index, pname, GetResultShmId(), result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
} }
}); result->SetNumResults(0);
helper_->GetVertexAttribiv(index, pname, GetResultShmId(), result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
}
});
}
CheckGLError(); CheckGLError();
} }
...@@ -5570,19 +5592,23 @@ void GLES2Implementation::GetVertexAttribIiv(GLuint index, ...@@ -5570,19 +5592,23 @@ void GLES2Implementation::GetVertexAttribIiv(GLuint index,
} }
TRACE_EVENT0("gpu", "GLES2::GetVertexAttribIiv"); TRACE_EVENT0("gpu", "GLES2::GetVertexAttribIiv");
typedef cmds::GetVertexAttribiv::Result Result; typedef cmds::GetVertexAttribiv::Result Result;
auto result = GetResultAs<Result>(); // Limit scope of result to avoid overlap with CheckGLError()
if (!result) { {
return; auto result = GetResultAs<Result>();
} if (!result) {
result->SetNumResults(0); return;
helper_->GetVertexAttribIiv(index, pname, GetResultShmId(), result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
} }
}); result->SetNumResults(0);
helper_->GetVertexAttribIiv(index, pname, GetResultShmId(),
result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
}
});
}
CheckGLError(); CheckGLError();
} }
...@@ -5600,19 +5626,23 @@ void GLES2Implementation::GetVertexAttribIuiv(GLuint index, ...@@ -5600,19 +5626,23 @@ void GLES2Implementation::GetVertexAttribIuiv(GLuint index,
} }
TRACE_EVENT0("gpu", "GLES2::GetVertexAttribIuiv"); TRACE_EVENT0("gpu", "GLES2::GetVertexAttribIuiv");
typedef cmds::GetVertexAttribiv::Result Result; typedef cmds::GetVertexAttribiv::Result Result;
auto result = GetResultAs<Result>(); // Limit scope of result to avoid overlap with CheckGLError()
if (!result) { {
return; auto result = GetResultAs<Result>();
} if (!result) {
result->SetNumResults(0); return;
helper_->GetVertexAttribIuiv(index, pname, GetResultShmId(), result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
} }
}); result->SetNumResults(0);
helper_->GetVertexAttribIuiv(index, pname, GetResultShmId(),
result.offset());
WaitForCmd();
result->CopyResult(params);
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
}
});
}
CheckGLError(); CheckGLError();
} }
...@@ -7368,18 +7398,23 @@ GLenum GLES2Implementation::ClientWaitSync(GLsync sync, ...@@ -7368,18 +7398,23 @@ GLenum GLES2Implementation::ClientWaitSync(GLsync sync,
GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glClientWaitSync(" << sync << ", " GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glClientWaitSync(" << sync << ", "
<< flags << ", " << timeout << ")"); << flags << ", " << timeout << ")");
typedef cmds::ClientWaitSync::Result Result; typedef cmds::ClientWaitSync::Result Result;
auto result = GetResultAs<Result>(); // Limit scope of result to avoid overlap with CheckGLError()
if (!result) { Result localResult;
SetGLError(GL_OUT_OF_MEMORY, "ClientWaitSync", ""); {
return GL_WAIT_FAILED; auto result = GetResultAs<Result>();
if (!result) {
SetGLError(GL_OUT_OF_MEMORY, "ClientWaitSync", "");
return GL_WAIT_FAILED;
}
*result = GL_WAIT_FAILED;
helper_->ClientWaitSync(ToGLuint(sync), flags, timeout, GetResultShmId(),
result.offset());
WaitForCmd();
localResult = *result;
GPU_CLIENT_LOG("returned " << localResult);
} }
*result = GL_WAIT_FAILED;
helper_->ClientWaitSync(ToGLuint(sync), flags, timeout, GetResultShmId(),
result.offset());
WaitForCmd();
GPU_CLIENT_LOG("returned " << *result);
CheckGLError(); CheckGLError();
return *result; return localResult;
} }
void GLES2Implementation::CopyBufferSubData(GLenum readtarget, void GLES2Implementation::CopyBufferSubData(GLenum readtarget,
...@@ -7443,26 +7478,29 @@ void GLES2Implementation::GetInternalformativ(GLenum target, ...@@ -7443,26 +7478,29 @@ void GLES2Implementation::GetInternalformativ(GLenum target,
return; return;
} }
typedef cmds::GetInternalformativ::Result Result; typedef cmds::GetInternalformativ::Result Result;
auto result = GetResultAs<Result>(); // Limit scope of result to avoid overlap with CheckGLError()
if (!result) { {
return; auto result = GetResultAs<Result>();
} if (!result) {
result->SetNumResults(0); return;
helper_->GetInternalformativ(target, format, pname, GetResultShmId(),
result.offset());
WaitForCmd();
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
}
});
if (buf_size > 0 && params) {
GLint* data = result->GetData();
if (buf_size >= result->GetNumResults()) {
buf_size = result->GetNumResults();
} }
for (GLsizei ii = 0; ii < buf_size; ++ii) { result->SetNumResults(0);
params[ii] = data[ii]; helper_->GetInternalformativ(target, format, pname, GetResultShmId(),
result.offset());
WaitForCmd();
GPU_CLIENT_LOG_CODE_BLOCK({
for (int32_t i = 0; i < result->GetNumResults(); ++i) {
GPU_CLIENT_LOG(" " << i << ": " << result->GetData()[i]);
}
});
if (buf_size > 0 && params) {
GLint* data = result->GetData();
if (buf_size >= result->GetNumResults()) {
buf_size = result->GetNumResults();
}
for (GLsizei ii = 0; ii < buf_size; ++ii) {
params[ii] = data[ii];
}
} }
} }
CheckGLError(); CheckGLError();
......
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