Skip to content

Commit

Permalink
gpu: Add TransformFeedback & Uniform Buffer related consts
Browse files Browse the repository at this point in the history
Added max_transform_feedback_separate_attribs, max_uniform_buffer_bindings,
and uniform_buffer_offset_alignment to Capabilities.
These were introducted in GLES 3.0.

BUG=429053
TEST=gpu_unittests

Review URL: https://codereview.chromium.org/885013002

Cr-Commit-Position: refs/heads/master@{#314725}
  • Loading branch information
hjrchung authored and Commit bot committed Feb 5, 2015
1 parent bde0971 commit 8f14329
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 19 deletions.
4 changes: 4 additions & 0 deletions gpu/command_buffer/build_gles2_cmd_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,10 @@
'type': 'Bind',
'id_mapping': [ 'Buffer' ],
'gen_func': 'GenBuffersARB',
'valid_args': {
'3': '4',
'4': '4'
},
'unsafe': True,
},
'BindFramebuffer': {
Expand Down
32 changes: 19 additions & 13 deletions gpu/command_buffer/client/gles2_implementation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,15 @@ bool GLES2Implementation::GetHelper(GLenum pname, GLint* params) {
return true;
}
return false;
case GL_MAX_UNIFORM_BUFFER_BINDINGS:
*params = capabilities_.max_uniform_buffer_bindings;
return true;
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
*params = capabilities_.max_transform_feedback_separate_attribs;
return true;
case GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT:
*params = capabilities_.uniform_buffer_offset_alignment;
return true;
default:
return false;
}
Expand Down Expand Up @@ -2638,6 +2647,10 @@ void GLES2Implementation::GenTransformFeedbacksHelper(
// the old model but possibly not true in the new model if another context has
// deleted the resource.

// NOTE #2: There is a bug in some BindXXXHelpers, that IDs might be marked as
// used even when Bind has failed. However, the bug is minor compared to the
// overhead & duplicated checking in client side.

void GLES2Implementation::BindBufferHelper(
GLenum target, GLuint buffer_id) {
// TODO(gman): See note #1 above.
Expand All @@ -2662,8 +2675,7 @@ void GLES2Implementation::BindBufferHelper(
changed = true;
break;
}
// TODO(gman): There's a bug here. If the target is invalid the ID will not be
// used even though it's marked it as used here.
// TODO(gman): See note #2 above.
if (changed) {
GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind(
this, target, buffer_id, &GLES2Implementation::BindBufferStub);
Expand All @@ -2679,8 +2691,7 @@ void GLES2Implementation::BindBufferStub(GLenum target, GLuint buffer) {
void GLES2Implementation::BindBufferBaseHelper(
GLenum target, GLuint index, GLuint buffer_id) {
// TODO(zmo): See note #1 above.
// TODO(zmo): There's a bug here. If the target or index is invalid the ID
// will not be used even though it's marked it as used here.
// TODO(zmo): See note #2 above.
GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind(
this, target, index, buffer_id, &GLES2Implementation::BindBufferBaseStub);
}
Expand All @@ -2696,8 +2707,7 @@ void GLES2Implementation::BindBufferRangeHelper(
GLenum target, GLuint index, GLuint buffer_id,
GLintptr offset, GLsizeiptr size) {
// TODO(zmo): See note #1 above.
// TODO(zmo): There's a bug here. If an arguments is invalid the ID will not
// be used even though it's marked it as used here.
// TODO(zmo): See note #2 above.
GetIdHandler(id_namespaces::kBuffers)->MarkAsUsedForBind(
this, target, index, buffer_id, offset, size,
&GLES2Implementation::BindBufferRangeStub);
Expand Down Expand Up @@ -2777,8 +2787,7 @@ void GLES2Implementation::BindRenderbufferHelper(
changed = true;
break;
}
// TODO(gman): There's a bug here. If the target is invalid the ID will not be
// used even though it's marked it as used here.
// TODO(zmo): See note #2 above.
if (changed) {
GetIdHandler(id_namespaces::kRenderbuffers)->MarkAsUsedForBind(
this, target, renderbuffer,
Expand Down Expand Up @@ -2827,8 +2836,7 @@ void GLES2Implementation::BindTextureHelper(GLenum target, GLuint texture) {
changed = true;
break;
}
// TODO(gman): There's a bug here. If the target is invalid the ID will not be
// used. even though it's marked it as used here.
// TODO(gman): See note #2 above.
if (changed) {
GetIdHandler(id_namespaces::kTextures)->MarkAsUsedForBind(
this, target, texture, &GLES2Implementation::BindTextureStub);
Expand All @@ -2847,7 +2855,6 @@ void GLES2Implementation::BindTransformFeedbackHelper(
}

void GLES2Implementation::BindVertexArrayOESHelper(GLuint array) {
// TODO(gman): See note #1 above.
bool changed = false;
if (vertex_array_object_manager_->BindVertexArray(array, &changed)) {
if (changed) {
Expand Down Expand Up @@ -2878,8 +2885,7 @@ void GLES2Implementation::BindValuebufferCHROMIUMHelper(GLenum target,
changed = true;
break;
}
// TODO(gman): There's a bug here. If the target is invalid the ID will not be
// used even though it's marked it as used here.
// TODO(gman): See note #2 above.
if (changed) {
GetIdHandler(id_namespaces::kValuebuffers)->MarkAsUsedForBind(
this, target, valuebuffer,
Expand Down
5 changes: 5 additions & 0 deletions gpu/command_buffer/client/gles2_implementation_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ class GLES2ImplementationTest : public testing::Test {
static const GLint kMaxVertexUniformVectors = 128;
static const GLint kNumCompressedTextureFormats = 0;
static const GLint kNumShaderBinaryFormats = 0;
static const GLuint kMaxTransformFeedbackSeparateAttribs = 4;
static const GLuint kMaxUniformBufferBindings = 36;
static const GLuint kStartId = 1024;
static const GLuint kBuffersStartId =
GLES2Implementation::kClientSideArrayId + 2 * kNumTestContexts;
Expand Down Expand Up @@ -439,6 +441,9 @@ class GLES2ImplementationTest : public testing::Test {
capabilities.num_compressed_texture_formats =
kNumCompressedTextureFormats;
capabilities.num_shader_binary_formats = kNumShaderBinaryFormats;
capabilities.max_transform_feedback_separate_attribs =
kMaxTransformFeedbackSeparateAttribs;
capabilities.max_uniform_buffer_bindings = kMaxUniformBufferBindings;
capabilities.bind_generates_resource_chromium =
bind_generates_resource_service ? 1 : 0;
EXPECT_CALL(*gpu_control_, GetCapabilities())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ TEST_F(GLES2ImplementationTest, BindBufferRange) {
cmds::BindBufferRange cmd;
};
Cmds expected;
expected.cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3, 4, 5);
expected.cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3, 4, 4);

gl_->BindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3, 4, 5);
gl_->BindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 2, 3, 4, 4);
EXPECT_EQ(0, memcmp(&expected, commands_, sizeof(expected)));
}

Expand Down
3 changes: 3 additions & 0 deletions gpu/command_buffer/common/capabilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Capabilities::Capabilities()
num_compressed_texture_formats(0),
num_shader_binary_formats(0),
bind_generates_resource_chromium(0),
max_transform_feedback_separate_attribs(0),
max_uniform_buffer_bindings(0),
uniform_buffer_offset_alignment(1),
post_sub_buffer(false),
egl_image_external(false),
texture_format_bgra8888(false),
Expand Down
3 changes: 3 additions & 0 deletions gpu/command_buffer/common/capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ struct GPU_EXPORT Capabilities {
int num_compressed_texture_formats;
int num_shader_binary_formats;
int bind_generates_resource_chromium;
int max_transform_feedback_separate_attribs;
int max_uniform_buffer_bindings;
int uniform_buffer_offset_alignment;

bool post_sub_buffer;
bool egl_image_external;
Expand Down
8 changes: 8 additions & 0 deletions gpu/command_buffer/service/gles2_cmd_decoder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2842,6 +2842,14 @@ Capabilities GLES2DecoderImpl::GetCapabilities() {
DoGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &caps.num_shader_binary_formats);
DoGetIntegerv(GL_BIND_GENERATES_RESOURCE_CHROMIUM,
&caps.bind_generates_resource_chromium);
if (unsafe_es3_apis_enabled()) {
DoGetIntegerv(GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS,
&caps.max_transform_feedback_separate_attribs);
DoGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS,
&caps.max_uniform_buffer_bindings);
DoGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
&caps.uniform_buffer_offset_alignment);
}

caps.egl_image_external =
feature_info_->feature_flags().oes_egl_image_external;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ TEST_P(GLES2DecoderTest1, BindBufferBaseValidArgsNewId) {

TEST_P(GLES2DecoderTest1, BindBufferRangeValidArgs) {
EXPECT_CALL(*gl_, BindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 2,
kServiceBufferId, 4, 5));
kServiceBufferId, 4, 4));
SpecializedSetup<cmds::BindBufferRange, 0>(true);
cmds::BindBufferRange cmd;
cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, client_buffer_id_, 4, 5);
cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, client_buffer_id_, 4, 4);
decoder_->set_unsafe_es3_apis_enabled(true);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
Expand All @@ -98,12 +98,12 @@ TEST_P(GLES2DecoderTest1, BindBufferRangeValidArgs) {

TEST_P(GLES2DecoderTest1, BindBufferRangeValidArgsNewId) {
EXPECT_CALL(*gl_, BindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, 2,
kNewServiceId, 4, 5));
kNewServiceId, 4, 4));
EXPECT_CALL(*gl_, GenBuffersARB(1, _))
.WillOnce(SetArgumentPointee<1>(kNewServiceId));
SpecializedSetup<cmds::BindBufferRange, 0>(true);
cmds::BindBufferRange cmd;
cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, kNewClientId, 4, 5);
cmd.Init(GL_TRANSFORM_FEEDBACK_BUFFER, 2, kNewClientId, 4, 4);
decoder_->set_unsafe_es3_apis_enabled(true);
EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
EXPECT_EQ(GL_NO_ERROR, GetGLError());
Expand Down
3 changes: 3 additions & 0 deletions gpu/ipc/gpu_command_buffer_traits_multi.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ IPC_STRUCT_TRAITS_BEGIN(gpu::Capabilities)
IPC_STRUCT_TRAITS_MEMBER(num_compressed_texture_formats)
IPC_STRUCT_TRAITS_MEMBER(num_shader_binary_formats)
IPC_STRUCT_TRAITS_MEMBER(bind_generates_resource_chromium)
IPC_STRUCT_TRAITS_MEMBER(max_transform_feedback_separate_attribs)
IPC_STRUCT_TRAITS_MEMBER(max_uniform_buffer_bindings)
IPC_STRUCT_TRAITS_MEMBER(uniform_buffer_offset_alignment)
IPC_STRUCT_TRAITS_MEMBER(post_sub_buffer)
IPC_STRUCT_TRAITS_MEMBER(egl_image_external)
IPC_STRUCT_TRAITS_MEMBER(texture_format_bgra8888)
Expand Down

0 comments on commit 8f14329

Please sign in to comment.