summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 22:26:48 +0000
committerandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 22:26:48 +0000
commitce383f32a1bfbe4ca33b88a0cbbb79c7f077428d (patch)
treeff8effb0f58e6f1b0395a0c98f7e385e43cc1f23 /gpu
parente667807890b931d41a4529165bedef5203382bbd (diff)
downloadchromium_src-ce383f32a1bfbe4ca33b88a0cbbb79c7f077428d.zip
chromium_src-ce383f32a1bfbe4ca33b88a0cbbb79c7f077428d.tar.gz
chromium_src-ce383f32a1bfbe4ca33b88a0cbbb79c7f077428d.tar.bz2
Revert 67293 BrowserTestCanLaunchWithOSMesa was consistently failing - Initialize destinations variables before calling GL functions
because if the context is lost those variables will be uninitialized. TEST=ran chrome, conformance tests, unit tests and hand edited gles2_demo to test BUG=none Review URL: http://codereview.chromium.org/5305005 TBR=gman@chromium.org Review URL: http://codereview.chromium.org/5383001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67328 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rwxr-xr-xgpu/command_buffer/build_gles2_cmd_buffer.py37
-rw-r--r--gpu/command_buffer/client/gles2_c_lib.cc28
-rw-r--r--gpu/command_buffer/client/gles2_c_lib_autogen.h22
-rw-r--r--gpu/command_buffer/client/gles2_demo_cc.cc4
-rw-r--r--gpu/command_buffer/service/common_decoder.cc11
-rw-r--r--gpu/command_buffer/service/common_decoder.h2
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc10
7 files changed, 11 insertions, 103 deletions
diff --git a/gpu/command_buffer/build_gles2_cmd_buffer.py b/gpu/command_buffer/build_gles2_cmd_buffer.py
index d610e5b..331159c 100755
--- a/gpu/command_buffer/build_gles2_cmd_buffer.py
+++ b/gpu/command_buffer/build_gles2_cmd_buffer.py
@@ -2125,11 +2125,6 @@ TEST_F(%(test_name)s, %(name)sInvalidArgs%(arg_index)d_%(value_index)d) {
else:
self.WriteGLES2ImplementationDeclaration(func, file)
- def WriteDestinationInitalizationValidation(self, func, file):
- """Writes the client side destintion initialization validation."""
- for arg in func.GetOriginalArgs():
- arg.WriteDestinationInitalizationValidation(file, func)
-
def WriteImmediateCmdComputeSize(self, func, file):
"""Writes the size computation code for the immediate version of a cmd."""
file.Write(" static uint32 ComputeSize(uint32 size_in_bytes) {\n")
@@ -3985,7 +3980,6 @@ class Argument(object):
'GLfloat': 'float',
'GLclampf': 'float',
}
- need_validation_ = ['GLsizei*', 'GLboolean*', 'GLenum*', 'GLint*']
def __init__(self, name, type):
self.name = name
@@ -4035,20 +4029,6 @@ class Argument(object):
"""Writes the validation code for an argument."""
pass
- def WriteDestinationInitalizationValidation(self, file, func):
- """Writes the client side destintion initialization validation."""
- pass
-
- def WriteDestinationInitalizationValidatationIfNeeded(self, file, func):
- """Writes the client side destintion initialization validation if needed."""
- parts = self.type.split(" ")
- if len(parts) > 1:
- return
- if parts[0] in self.need_validation_:
- file.Write(" GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(%s, %s);\n" %
- (self.type[:-1], self.name))
-
-
def WriteGetAddress(self, file):
"""Writes the code to get the address this argument refers to."""
pass
@@ -4233,10 +4213,6 @@ class ImmediatePointerArgument(Argument):
"""Overridden from Argument."""
return None
- def WriteDestinationInitalizationValidation(self, file, func):
- """Overridden from Argument."""
- self.WriteDestinationInitalizationValidatationIfNeeded(file, func)
-
class BucketPointerArgument(Argument):
"""A class that represents an bucket argument to a function."""
@@ -4262,10 +4238,6 @@ class BucketPointerArgument(Argument):
"""Overridden from Argument."""
return None
- def WriteDestinationInitalizationValidation(self, file, func):
- """Overridden from Argument."""
- self.WriteDestinationInitalizationValidatationIfNeeded(file, func)
-
class PointerArgument(Argument):
"""A class that represents a pointer argument to a function."""
@@ -4336,10 +4308,6 @@ class PointerArgument(Argument):
return InputStringBucketArgument(self.name, self.type)
return BucketPointerArgument(self.name, self.type)
- def WriteDestinationInitalizationValidation(self, file, func):
- """Overridden from Argument."""
- self.WriteDestinationInitalizationValidatationIfNeeded(file, func)
-
class InputStringBucketArgument(Argument):
"""An string input argument where the string is passed in a bucket."""
@@ -4661,10 +4629,6 @@ class Function(object):
"""Writes the GLES2 Implemention declaration."""
self.type_handler.WriteGLES2ImplementationHeader(self, file)
- def WriteDestinationInitalizationValidation(self, file):
- """Writes the client side destintion initialization validation."""
- self.type_handler.WriteDestinationInitalizationValidation(self, file)
-
def WriteFormatTest(self, file):
"""Writes the cmd's format test."""
self.type_handler.WriteFormatTest(self, file)
@@ -5149,7 +5113,6 @@ class GLGenerator(object):
file.Write("%s GLES2%s(%s) {\n" %
(func.return_type, func.name,
func.MakeTypedOriginalArgString("")))
- func.WriteDestinationInitalizationValidation(file)
comma = ""
if len(func.GetOriginalArgs()):
comma = " << "
diff --git a/gpu/command_buffer/client/gles2_c_lib.cc b/gpu/command_buffer/client/gles2_c_lib.cc
index f53067e..74cc431 100644
--- a/gpu/command_buffer/client/gles2_c_lib.cc
+++ b/gpu/command_buffer/client/gles2_c_lib.cc
@@ -4,36 +4,8 @@
// These functions emluate GLES2 over command buffers for C.
-#include <assert.h>
#include "../client/gles2_lib.h"
-// Check that destination pointers point to initialized memory.
-// When the context is lost, calling GL function has no effect so if destination
-// pointers point to initialized memory it can often lead to crash bugs. eg.
-//
-// GLsizei len;
-// glGetShaderSource(shader, max_size, &len, buffer);
-// std::string src(buffer, buffer + len); // len can be uninitialized here!!!
-//
-// Because this check is not official GL this check happens only on Chrome code,
-// not Pepper.
-//
-// If it was up to us we'd just always write to the destination but the OpenGL
-// spec defines the behavior of OpenGL function, not us. :-(
-#if defined(__native_client__)
- #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v)
-#elif defined(GPU_DCHECK)
- #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) GPU_DCHECK(v)
-#elif defined(DCHECK)
- #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) DCHECK(v)
-#else
- #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) ASSERT(v)
-#endif
-
-#define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(type, ptr) \
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(ptr && \
- (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1)));
-
extern "C" {
// Include the auto-generated part of this file. We split this because it means
// we can easily edit the non-auto generated parts right here in this file
diff --git a/gpu/command_buffer/client/gles2_c_lib_autogen.h b/gpu/command_buffer/client/gles2_c_lib_autogen.h
index 420b0e5..ab54997 100644
--- a/gpu/command_buffer/client/gles2_c_lib_autogen.h
+++ b/gpu/command_buffer/client/gles2_c_lib_autogen.h
@@ -279,9 +279,6 @@ void GLES2GenTextures(GLsizei n, GLuint* textures) {
void GLES2GetActiveAttrib(
GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
GLenum* type, char* name) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLsizei, length);
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, size);
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLenum, type);
GPU_CLIENT_LOG(
"GetActiveAttrib" << "(" << program << ", " << index << ", " << bufsize << ", " << length << ", " << size << ", " << type << ", " << name << ")"); // NOLINT
gles2::GetGLContext()->GetActiveAttrib(
@@ -290,9 +287,6 @@ void GLES2GetActiveAttrib(
void GLES2GetActiveUniform(
GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
GLenum* type, char* name) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLsizei, length);
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, size);
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLenum, type);
GPU_CLIENT_LOG(
"GetActiveUniform" << "(" << program << ", " << index << ", " << bufsize << ", " << length << ", " << size << ", " << type << ", " << name << ")"); // NOLINT
gles2::GetGLContext()->GetActiveUniform(
@@ -300,7 +294,6 @@ void GLES2GetActiveUniform(
}
void GLES2GetAttachedShaders(
GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLsizei, count);
GPU_CLIENT_LOG(
"GetAttachedShaders" << "(" << program << ", " << maxcount << ", " << count << ", " << shaders << ")"); // NOLINT
gles2::GetGLContext()->GetAttachedShaders(program, maxcount, count, shaders);
@@ -312,12 +305,10 @@ GLint GLES2GetAttribLocation(GLuint program, const char* name) {
return result;
}
void GLES2GetBooleanv(GLenum pname, GLboolean* params) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLboolean, params);
GPU_CLIENT_LOG("GetBooleanv" << "(" << pname << ", " << params << ")");
gles2::GetGLContext()->GetBooleanv(pname, params);
}
void GLES2GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
GPU_CLIENT_LOG(
"GetBufferParameteriv" << "(" << target << ", " << pname << ", " << params << ")"); // NOLINT
gles2::GetGLContext()->GetBufferParameteriv(target, pname, params);
@@ -334,54 +325,45 @@ void GLES2GetFloatv(GLenum pname, GLfloat* params) {
}
void GLES2GetFramebufferAttachmentParameteriv(
GLenum target, GLenum attachment, GLenum pname, GLint* params) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
GPU_CLIENT_LOG(
"GetFramebufferAttachmentParameteriv" << "(" << target << ", " << attachment << ", " << pname << ", " << params << ")"); // NOLINT
gles2::GetGLContext()->GetFramebufferAttachmentParameteriv(
target, attachment, pname, params);
}
void GLES2GetIntegerv(GLenum pname, GLint* params) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
GPU_CLIENT_LOG("GetIntegerv" << "(" << pname << ", " << params << ")");
gles2::GetGLContext()->GetIntegerv(pname, params);
}
void GLES2GetProgramiv(GLuint program, GLenum pname, GLint* params) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
GPU_CLIENT_LOG(
"GetProgramiv" << "(" << program << ", " << pname << ", " << params << ")"); // NOLINT
gles2::GetGLContext()->GetProgramiv(program, pname, params);
}
void GLES2GetProgramInfoLog(
GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLsizei, length);
GPU_CLIENT_LOG(
"GetProgramInfoLog" << "(" << program << ", " << bufsize << ", " << length << ", " << infolog << ")"); // NOLINT
gles2::GetGLContext()->GetProgramInfoLog(program, bufsize, length, infolog);
}
void GLES2GetRenderbufferParameteriv(
GLenum target, GLenum pname, GLint* params) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
GPU_CLIENT_LOG(
"GetRenderbufferParameteriv" << "(" << target << ", " << pname << ", " << params << ")"); // NOLINT
gles2::GetGLContext()->GetRenderbufferParameteriv(target, pname, params);
}
void GLES2GetShaderiv(GLuint shader, GLenum pname, GLint* params) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
GPU_CLIENT_LOG(
"GetShaderiv" << "(" << shader << ", " << pname << ", " << params << ")");
gles2::GetGLContext()->GetShaderiv(shader, pname, params);
}
void GLES2GetShaderInfoLog(
GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLsizei, length);
GPU_CLIENT_LOG(
"GetShaderInfoLog" << "(" << shader << ", " << bufsize << ", " << length << ", " << infolog << ")"); // NOLINT
gles2::GetGLContext()->GetShaderInfoLog(shader, bufsize, length, infolog);
}
void GLES2GetShaderPrecisionFormat(
GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, range);
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, precision);
GPU_CLIENT_LOG(
"GetShaderPrecisionFormat" << "(" << shadertype << ", " << precisiontype << ", " << range << ", " << precision << ")"); // NOLINT
gles2::GetGLContext()->GetShaderPrecisionFormat(
@@ -389,7 +371,6 @@ void GLES2GetShaderPrecisionFormat(
}
void GLES2GetShaderSource(
GLuint shader, GLsizei bufsize, GLsizei* length, char* source) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLsizei, length);
GPU_CLIENT_LOG(
"GetShaderSource" << "(" << shader << ", " << bufsize << ", " << length << ", " << source << ")"); // NOLINT
gles2::GetGLContext()->GetShaderSource(shader, bufsize, length, source);
@@ -406,7 +387,6 @@ void GLES2GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) {
gles2::GetGLContext()->GetTexParameterfv(target, pname, params);
}
void GLES2GetTexParameteriv(GLenum target, GLenum pname, GLint* params) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
GPU_CLIENT_LOG(
"GetTexParameteriv" << "(" << target << ", " << pname << ", " << params << ")"); // NOLINT
gles2::GetGLContext()->GetTexParameteriv(target, pname, params);
@@ -417,7 +397,6 @@ void GLES2GetUniformfv(GLuint program, GLint location, GLfloat* params) {
gles2::GetGLContext()->GetUniformfv(program, location, params);
}
void GLES2GetUniformiv(GLuint program, GLint location, GLint* params) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
GPU_CLIENT_LOG(
"GetUniformiv" << "(" << program << ", " << location << ", " << params << ")"); // NOLINT
gles2::GetGLContext()->GetUniformiv(program, location, params);
@@ -435,7 +414,6 @@ void GLES2GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) {
gles2::GetGLContext()->GetVertexAttribfv(index, pname, params);
}
void GLES2GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) {
- GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(GLint, params);
GPU_CLIENT_LOG(
"GetVertexAttribiv" << "(" << index << ", " << pname << ", " << params << ")"); // NOLINT
gles2::GetGLContext()->GetVertexAttribiv(index, pname, params);
diff --git a/gpu/command_buffer/client/gles2_demo_cc.cc b/gpu/command_buffer/client/gles2_demo_cc.cc
index a0ddaff..cb33f8c 100644
--- a/gpu/command_buffer/client/gles2_demo_cc.cc
+++ b/gpu/command_buffer/client/gles2_demo_cc.cc
@@ -47,7 +47,7 @@ GLuint LoadShader(GLenum type, const char* shaderSrc) {
// Compile the shader
glCompileShader(shader);
// Check the compile status
- GLint value = 0;
+ GLint value;
glGetShaderiv(shader, GL_COMPILE_STATUS, &value);
if (value == 0) {
char buffer[1024];
@@ -100,7 +100,7 @@ void InitShaders() {
// Link the program
glLinkProgram(programObject);
// Check the link status
- GLint linked = 0;
+ GLint linked;
glGetProgramiv(programObject, GL_LINK_STATUS, &linked);
if (linked == 0) {
char buffer[1024];
diff --git a/gpu/command_buffer/service/common_decoder.cc b/gpu/command_buffer/service/common_decoder.cc
index a116d04..ce45422 100644
--- a/gpu/command_buffer/service/common_decoder.cc
+++ b/gpu/command_buffer/service/common_decoder.cc
@@ -35,16 +35,11 @@ bool CommonDecoder::Bucket::SetData(
return false;
}
-void CommonDecoder::Bucket::SetFromString(const char* str) {
+void CommonDecoder::Bucket::SetFromString(const std::string& str) {
// Strings are passed NULL terminated to distinguish between empty string
// and no string.
- if (!str) {
- SetSize(0);
- } else {
- size_t size = strlen(str) + 1;
- SetSize(size);
- SetData(str, 0, size);
- }
+ SetSize(str.size() + 1);
+ SetData(str.c_str(), 0, str.size() + 1);
}
bool CommonDecoder::Bucket::GetAsString(std::string* str) {
diff --git a/gpu/command_buffer/service/common_decoder.h b/gpu/command_buffer/service/common_decoder.h
index ea4e520..7abc016 100644
--- a/gpu/command_buffer/service/common_decoder.h
+++ b/gpu/command_buffer/service/common_decoder.h
@@ -73,7 +73,7 @@ class CommonDecoder : public AsyncAPIInterface {
// Sets the bucket data from a string. Strings are passed NULL terminated to
// distinguish between empty string and no string.
- void SetFromString(const char* str);
+ void SetFromString(const std::string& str);
// Gets the bucket data as a string. Strings are passed NULL terminated to
// distrinquish between empty string and no string. Returns False if there
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 17d1f09..fbb6ca4 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -4313,7 +4313,7 @@ error::Error GLES2DecoderImpl::HandleGetShaderSource(
bucket->SetSize(0);
return error::kNoError;
}
- bucket->SetFromString(info->source().c_str());
+ bucket->SetFromString(info->source());
return error::kNoError;
}
@@ -4327,7 +4327,7 @@ error::Error GLES2DecoderImpl::HandleGetProgramInfoLog(
if (!info) {
return error::kNoError;
}
- bucket->SetFromString(info->log_info().c_str());
+ bucket->SetFromString(info->log_info());
return error::kNoError;
}
@@ -4342,7 +4342,7 @@ error::Error GLES2DecoderImpl::HandleGetShaderInfoLog(
bucket->SetSize(0);
return error::kNoError;
}
- bucket->SetFromString(info->log_info().c_str());
+ bucket->SetFromString(info->log_info());
return error::kNoError;
}
@@ -5739,7 +5739,7 @@ error::Error GLES2DecoderImpl::HandleGetActiveUniform(
result->size = uniform_info->size;
result->type = uniform_info->type;
Bucket* bucket = CreateBucket(name_bucket_id);
- bucket->SetFromString(uniform_info->name.c_str());
+ bucket->SetFromString(uniform_info->name);
return error::kNoError;
}
@@ -5773,7 +5773,7 @@ error::Error GLES2DecoderImpl::HandleGetActiveAttrib(
result->size = attrib_info->size;
result->type = attrib_info->type;
Bucket* bucket = CreateBucket(name_bucket_id);
- bucket->SetFromString(attrib_info->name.c_str());
+ bucket->SetFromString(attrib_info->name);
return error::kNoError;
}