Skip to content

Commit

Permalink
Fix IsExtensionAvailable so it calls GetStringHelper
Browse files Browse the repository at this point in the history
This is so it does not trigger the single threaded checks

TEST=unit test
BUG=none

R=zmo@chromium.org


Review URL: http://codereview.chromium.org/9006021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115265 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
gman@chromium.org committed Dec 21, 2011
1 parent ba29d04 commit df0729f
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 42 deletions.
1 change: 1 addition & 0 deletions gpu/command_buffer/build_gles2_cmd_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,7 @@
'client_test': False,
'extension': True,
'chromium': True,
'impl_func': False,
},
'GetMultipleIntegervCHROMIUM': {
'type': 'Custom',
Expand Down
83 changes: 58 additions & 25 deletions gpu/command_buffer/client/gles2_implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class ClientSideBufferHelper {
gl_helper->BindBuffer(GL_ARRAY_BUFFER, array_buffer_id_);
array_buffer_offset_ = 0;
if (total_size > array_buffer_size_) {
gl->BufferData(GL_ARRAY_BUFFER, total_size, NULL, GL_DYNAMIC_DRAW);
gl->BufferDataHelper(GL_ARRAY_BUFFER, total_size, NULL, GL_DYNAMIC_DRAW);
array_buffer_size_ = total_size;
}
for (GLuint ii = 0; ii < max_vertex_attribs_; ++ii) {
Expand All @@ -449,7 +449,7 @@ class ClientSideBufferHelper {
info.stride() : static_cast<GLsizei>(bytes_per_element);
GLsizei bytes_collected = CollectData(
info.pointer(), bytes_per_element, real_stride, num_elements);
gl->BufferSubData(
gl->BufferSubDataHelper(
GL_ARRAY_BUFFER, array_buffer_offset_, bytes_collected,
collection_buffer_.get());
gl_helper->VertexAttribPointer(
Expand All @@ -474,10 +474,11 @@ class ClientSideBufferHelper {
GLsizei bytes_needed = bytes_per_element * count;
if (bytes_needed > element_array_buffer_size_) {
element_array_buffer_size_ = bytes_needed;
gl->BufferData(GL_ELEMENT_ARRAY_BUFFER, bytes_needed, NULL,
GL_DYNAMIC_DRAW);
gl->BufferDataHelper(
GL_ELEMENT_ARRAY_BUFFER, bytes_needed, NULL, GL_DYNAMIC_DRAW);
}
gl->BufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, bytes_needed, indices);
gl->BufferSubDataHelper(
GL_ELEMENT_ARRAY_BUFFER, 0, bytes_needed, indices);
GLsizei max_index = -1;
switch (type) {
case GL_UNSIGNED_BYTE: {
Expand Down Expand Up @@ -745,10 +746,9 @@ void GLES2Implementation::WaitForCmd() {
helper_->CommandBufferHelper::Finish();
}

namespace {
bool IsExtensionAvailable(GLES2Implementation* gles2, const char ext[]) {
const char* extensions = reinterpret_cast<const char*>(
gles2->GetString(GL_EXTENSIONS));
bool GLES2Implementation::IsExtensionAvailable(const char* ext) {
const char* extensions =
reinterpret_cast<const char*>(GetStringHelper(GL_EXTENSIONS));
int length = strlen(ext);
while (true) {
int n = strcspn(extensions, " ");
Expand All @@ -758,10 +758,9 @@ bool IsExtensionAvailable(GLES2Implementation* gles2, const char ext[]) {
if ('\0' == extensions[n]) {
return false;
}
extensions += n+1;
extensions += n + 1;
}
}
}

bool GLES2Implementation::IsAnglePackReverseRowOrderAvailable() {
switch (angle_pack_reverse_row_order_status) {
Expand All @@ -770,7 +769,7 @@ bool GLES2Implementation::IsAnglePackReverseRowOrderAvailable() {
case kUnavailableExtensionStatus:
return false;
default:
if (IsExtensionAvailable(this, "GL_ANGLE_pack_reverse_row_order")) {
if (IsExtensionAvailable("GL_ANGLE_pack_reverse_row_order")) {
angle_pack_reverse_row_order_status = kAvailableExtensionStatus;
return true;
} else {
Expand Down Expand Up @@ -1018,6 +1017,30 @@ bool GLES2Implementation::GetIntegervHelper(GLenum pname, GLint* params) {
return GetHelper(pname, params);
}

GLuint GLES2Implementation::GetMaxValueInBufferCHROMIUMHelper(
GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) {
typedef GetMaxValueInBufferCHROMIUM::Result Result;
Result* result = GetResultAs<Result*>();
*result = 0;
helper_->GetMaxValueInBufferCHROMIUM(
buffer_id, count, type, offset, GetResultShmId(), GetResultShmOffset());
WaitForCmd();
return *result;
}

GLuint GLES2Implementation::GetMaxValueInBufferCHROMIUM(
GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG("[" << this << "] glGetMaxValueInBufferCHROMIUM("
<< buffer_id << ", " << count << ", "
<< GLES2Util::GetStringGetMaxIndexType(type)
<< ", " << offset << ")");
GLuint result = GetMaxValueInBufferCHROMIUMHelper(
buffer_id, count, type, offset);
GPU_CLIENT_LOG("returned " << result);
return result;
}

void GLES2Implementation::DrawElements(
GLenum mode, GLsizei count, GLenum type, const void* indices) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
Expand Down Expand Up @@ -1050,7 +1073,7 @@ void GLES2Implementation::DrawElements(
// changes the contents of any of the buffers. The service will still
// validate the indices. We just need to know how much to copy across.
if (have_client_side) {
num_elements = GetMaxValueInBufferCHROMIUM(
num_elements = GetMaxValueInBufferCHROMIUMHelper(
bound_element_array_buffer_id_, count, type, ToGLuint(indices)) + 1;
}
}
Expand Down Expand Up @@ -1482,14 +1505,8 @@ void GLES2Implementation::ShaderSource(
helper_->SetBucketSize(kResultBucketId, 0);
}

void GLES2Implementation::BufferData(
void GLES2Implementation::BufferDataHelper(
GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG("[" << this << "] glBufferData("
<< GLES2Util::GetStringBufferTarget(target) << ", "
<< size << ", "
<< static_cast<const void*>(data) << ", "
<< GLES2Util::GetStringBufferUsage(usage) << ")");
AlignedRingBuffer* transfer_buffer = transfer_buffer_.GetBuffer();
GLsizeiptr max_size = transfer_buffer->GetLargestFreeOrPendingSize();
if (size > max_size || !data) {
Expand All @@ -1511,13 +1528,19 @@ void GLES2Implementation::BufferData(
transfer_buffer->FreePendingToken(buffer, helper_->InsertToken());
}

void GLES2Implementation::BufferSubData(
GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
void GLES2Implementation::BufferData(
GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG("[" << this << "] glBufferSubData("
GPU_CLIENT_LOG("[" << this << "] glBufferData("
<< GLES2Util::GetStringBufferTarget(target) << ", "
<< offset << ", " << size << ", "
<< static_cast<const void*>(data) << ")");
<< size << ", "
<< static_cast<const void*>(data) << ", "
<< GLES2Util::GetStringBufferUsage(usage) << ")");
BufferDataHelper(target, size, data, usage);
}

void GLES2Implementation::BufferSubDataHelper(
GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
if (size == 0) {
return;
}
Expand All @@ -1544,6 +1567,16 @@ void GLES2Implementation::BufferSubData(
}
}

void GLES2Implementation::BufferSubData(
GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG("[" << this << "] glBufferSubData("
<< GLES2Util::GetStringBufferTarget(target) << ", "
<< offset << ", " << size << ", "
<< static_cast<const void*>(data) << ")");
BufferSubDataHelper(target, offset, size, data);
}

void GLES2Implementation::CompressedTexImage2D(
GLenum target, GLint level, GLenum internalformat, GLsizei width,
GLsizei height, GLint border, GLsizei image_size, const void* data) {
Expand Down
11 changes: 9 additions & 2 deletions gpu/command_buffer/client/gles2_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ class GLES2Implementation {
void FreeEverything();

private:
friend class ClientSideBufferHelper;

// Used to track whether an extension is available
enum ExtensionStatus {
kAvailableExtensionStatus,
Expand Down Expand Up @@ -465,11 +467,15 @@ class GLES2Implementation {
bool DeleteProgramHelper(GLuint program);
bool DeleteShaderHelper(GLuint shader);

void BufferDataHelper(
GLenum target, GLsizeiptr size, const void* data, GLenum usage);
void BufferSubDataHelper(
GLenum target, GLintptr offset, GLsizeiptr size, const void* data);

// Helper for GetVertexAttrib
bool GetVertexAttribHelper(GLuint index, GLenum pname, uint32* param);

// Asks the service for the max index in an element array buffer.
GLsizei GetMaxIndexInElementArrayBuffer(
GLuint GetMaxValueInBufferCHROMIUMHelper(
GLuint buffer_id, GLsizei count, GLenum type, GLuint offset);

bool CopyRectToBufferFlipped(
Expand All @@ -496,6 +502,7 @@ class GLES2Implementation {
bool GetTexParameterivHelper(GLenum target, GLenum pname, GLint* params);
const GLubyte* GetStringHelper(GLenum name);

bool IsExtensionAvailable(const char* ext);

GLES2Util util_;
GLES2CmdHelper* helper_;
Expand Down
13 changes: 1 addition & 12 deletions gpu/command_buffer/client/gles2_implementation_autogen.h
Original file line number Diff line number Diff line change
Expand Up @@ -1358,18 +1358,7 @@ void TexStorage2DEXT(
void SwapBuffers();

GLuint GetMaxValueInBufferCHROMIUM(
GLuint buffer_id, GLsizei count, GLenum type, GLuint offset) {
GPU_CLIENT_SINGLE_THREAD_CHECK();
GPU_CLIENT_LOG("[" << this << "] glGetMaxValueInBufferCHROMIUM(" << buffer_id << ", " << count << ", " << GLES2Util::GetStringGetMaxIndexType(type) << ", " << offset << ")"); // NOLINT
typedef GetMaxValueInBufferCHROMIUM::Result Result;
Result* result = GetResultAs<Result*>();
*result = 0;
helper_->GetMaxValueInBufferCHROMIUM(
buffer_id, count, type, offset, GetResultShmId(), GetResultShmOffset());
WaitForCmd();
GPU_CLIENT_LOG("returned " << *result);
return *result;
}
GLuint buffer_id, GLsizei count, GLenum type, GLuint offset);

void GenSharedIdsCHROMIUM(
GLuint namespace_id, GLuint id_offset, GLsizei n, GLuint* ids);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ static GLES2Util::EnumToString enum_to_string_table[] = {
{ 0x00000400, "GL_STENCIL_BUFFER_BIT", },
{ 0x800A, "GL_FUNC_SUBTRACT", },
{ 0x8E2C, "GL_DEPTH_COMPONENT16_NONLINEAR_NV", },
{ 0x8508, "GL_DECR_WRAP", },
{ 0x889F, "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING", },
{ 0x8006, "GL_FUNC_ADD", },
{ 0x8007, "GL_MIN_EXT", },
{ 0x8004, "GL_ONE_MINUS_CONSTANT_ALPHA", },
Expand Down Expand Up @@ -465,7 +465,7 @@ static GLES2Util::EnumToString enum_to_string_table[] = {
{ 0x8CE4, "GL_COLOR_ATTACHMENT4_NV", },
{ 0x8CD6, "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT", },
{ 0x8872, "GL_MAX_TEXTURE_IMAGE_UNITS", },
{ 0x889F, "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING", },
{ 0x8508, "GL_DECR_WRAP", },
{ 0x8507, "GL_INCR_WRAP", },
{ 0x8895, "GL_ELEMENT_ARRAY_BUFFER_BINDING", },
{ 0x8894, "GL_ARRAY_BUFFER_BINDING", },
Expand Down
23 changes: 22 additions & 1 deletion gpu/gpu.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,27 @@
# Library emulates GLES2 using command_buffers.
'target_name': 'gles2_implementation_client_side_arrays',
'type': 'static_library',
'defines': [
'GLES2_SUPPORT_CLIENT_SIDE_ARRAYS=1',
],
'dependencies': [
'../base/base.gyp:base',
'gles2_cmd_helper',
],
'all_dependent_settings': {
'include_dirs': [
# For GLES2/gl2.h
'<(DEPTH)/third_party/khronos',
],
},
'sources': [
'<@(gles2_implementation_source_files)',
],
},
{
# Library emulates GLES2 using command_buffers.
'target_name': 'gles2_implementation_client_side_arrays_no_check',
'type': 'static_library',
'defines': [
'GLES2_SUPPORT_CLIENT_SIDE_ARRAYS=1',
'GLES2_CONFORMANCE_TESTS=1',
Expand Down Expand Up @@ -138,7 +159,7 @@
'GLES2_CONFORMANCE_TESTS=1',
],
'dependencies': [
'gles2_implementation_client_side_arrays',
'gles2_implementation_client_side_arrays_no_check',
],
'sources': [
'<@(gles2_c_lib_source_files)',
Expand Down

0 comments on commit df0729f

Please sign in to comment.