diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-11 22:27:42 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-11 22:27:42 +0000 |
commit | 2318d34df86eea7fe41468b6c724008899e1f677 (patch) | |
tree | 3f610df04596c469985db776111c83688bd2bdf9 /gpu/command_buffer/common | |
parent | 8ebf9be5e65b179f25775ecbed4e778351b62198 (diff) | |
download | chromium_src-2318d34df86eea7fe41468b6c724008899e1f677.zip chromium_src-2318d34df86eea7fe41468b6c724008899e1f677.tar.gz chromium_src-2318d34df86eea7fe41468b6c724008899e1f677.tar.bz2 |
Add glGetProgramInfoCHROMIUM.
This passes all program data in one command.
I'll use this in another CL to cache program
data on the client side for contexts that are
not sharing resources.
TEST=unit tests
BUG=85966
Review URL: http://codereview.chromium.org/7324035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92066 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/common')
4 files changed, 105 insertions, 1 deletions
diff --git a/gpu/command_buffer/common/gles2_cmd_format.h b/gpu/command_buffer/common/gles2_cmd_format.h index e0da67d..ec9ea33 100644 --- a/gpu/command_buffer/common/gles2_cmd_format.h +++ b/gpu/command_buffer/common/gles2_cmd_format.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -115,6 +115,44 @@ COMPILE_ASSERT(offsetof(SizedResult<int8>, size) == 0, COMPILE_ASSERT(offsetof(SizedResult<int8>, data) == 4, OffsetOf_SizedResult_data_not_4); +// The data for one attrib or uniform from GetProgramInfoCHROMIUM. +struct ProgramInput { + uint32 type; // The type (GL_VEC3, GL_MAT3, GL_SAMPLER_2D, etc. + int32 size; // The size (how big the array is for uniforms) + uint32 location_offset; // offset from ProgramInfoHeader to 'size' locations + // for uniforms, 1 for attribs. + uint32 name_offset; // offset from ProgrmaInfoHeader to start of name. + uint32 name_length; // length of the name. +}; + +// The format of the bucket filled out by GetProgramInfoCHROMIUM +struct ProgramInfoHeader { + uint32 link_status; + uint32 num_attribs; + uint32 num_uniforms; + // ProgramInput inputs[num_attribs + num_uniforms]; +}; + +COMPILE_ASSERT(sizeof(ProgramInput) == 20, ProgramInput_size_not_20); +COMPILE_ASSERT(offsetof(ProgramInput, type) == 0, + OffsetOf_ProgramInput_type_not_0); +COMPILE_ASSERT(offsetof(ProgramInput, size) == 4, + OffsetOf_ProgramInput_size_not_4); +COMPILE_ASSERT(offsetof(ProgramInput, location_offset) == 8, + OffsetOf_ProgramInput_location_offset_not_8); +COMPILE_ASSERT(offsetof(ProgramInput, name_offset) == 12, + OffsetOf_ProgramInput_name_offset_not_12); +COMPILE_ASSERT(offsetof(ProgramInput, name_length) == 16, + OffsetOf_ProgramInput_name_length_not_16); + +COMPILE_ASSERT(sizeof(ProgramInfoHeader) == 12, ProgramInfoHeader_size_not_12); +COMPILE_ASSERT(offsetof(ProgramInfoHeader, link_status) == 0, + OffsetOf_ProgramInfoHeader_link_status_not_0); +COMPILE_ASSERT(offsetof(ProgramInfoHeader, num_attribs) == 4, + OffsetOf_ProgramInfoHeader_num_attribs_not_4); +COMPILE_ASSERT(offsetof(ProgramInfoHeader, num_uniforms) == 8, + OffsetOf_ProgramInfoHeader_num_uniforms_not_8); + #include "../common/gles2_cmd_format_autogen.h" // These are hand written commands. diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h index 6270f9a..3b76346 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h @@ -9077,6 +9077,56 @@ COMPILE_ASSERT(offsetof(GetMultipleIntegervCHROMIUM, results_shm_offset) == 20, COMPILE_ASSERT(offsetof(GetMultipleIntegervCHROMIUM, size) == 24, OffsetOf_GetMultipleIntegervCHROMIUM_size_not_24); +struct GetProgramInfoCHROMIUM { + typedef GetProgramInfoCHROMIUM ValueType; + static const CommandId kCmdId = kGetProgramInfoCHROMIUM; + static const cmd::ArgFlags kArgFlags = cmd::kFixed; + + struct Result { + uint32 link_status; + uint32 num_attribs; + uint32 num_uniforms; + }; + + static uint32 ComputeSize() { + return static_cast<uint32>(sizeof(ValueType)); // NOLINT + } + + void SetHeader() { + header.SetCmd<ValueType>(); + } + + void Init(GLuint _program, uint32 _bucket_id) { + SetHeader(); + program = _program; + bucket_id = _bucket_id; + } + + void* Set(void* cmd, GLuint _program, uint32 _bucket_id) { + static_cast<ValueType*>(cmd)->Init(_program, _bucket_id); + return NextCmdAddress<ValueType>(cmd); + } + + gpu::CommandHeader header; + uint32 program; + uint32 bucket_id; +}; + +COMPILE_ASSERT(sizeof(GetProgramInfoCHROMIUM) == 12, + Sizeof_GetProgramInfoCHROMIUM_is_not_12); +COMPILE_ASSERT(offsetof(GetProgramInfoCHROMIUM, header) == 0, + OffsetOf_GetProgramInfoCHROMIUM_header_not_0); +COMPILE_ASSERT(offsetof(GetProgramInfoCHROMIUM, program) == 4, + OffsetOf_GetProgramInfoCHROMIUM_program_not_4); +COMPILE_ASSERT(offsetof(GetProgramInfoCHROMIUM, bucket_id) == 8, + OffsetOf_GetProgramInfoCHROMIUM_bucket_id_not_8); +COMPILE_ASSERT(offsetof(GetProgramInfoCHROMIUM::Result, link_status) == 0, + OffsetOf_GetProgramInfoCHROMIUM_Result_link_status_not_0); +COMPILE_ASSERT(offsetof(GetProgramInfoCHROMIUM::Result, num_attribs) == 4, + OffsetOf_GetProgramInfoCHROMIUM_Result_num_attribs_not_4); +COMPILE_ASSERT(offsetof(GetProgramInfoCHROMIUM::Result, num_uniforms) == 8, + OffsetOf_GetProgramInfoCHROMIUM_Result_num_uniforms_not_8); + #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_AUTOGEN_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h index 212f8b3..40af555 100644 --- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h @@ -3572,5 +3572,20 @@ TEST(GLES2FormatTest, GetMultipleIntegervCHROMIUM) { EXPECT_EQ(static_cast<GLsizeiptr>(16), cmd.size); } +TEST(GLES2FormatTest, GetProgramInfoCHROMIUM) { + GetProgramInfoCHROMIUM cmd = { { 0 } }; + void* next_cmd = cmd.Set( + &cmd, + static_cast<GLuint>(11), + static_cast<uint32>(12)); + EXPECT_EQ(static_cast<uint32>(GetProgramInfoCHROMIUM::kCmdId), + cmd.header.command); + EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u); + EXPECT_EQ(static_cast<char*>(next_cmd), + reinterpret_cast<char*>(&cmd) + sizeof(cmd)); + EXPECT_EQ(static_cast<GLuint>(11), cmd.program); + EXPECT_EQ(static_cast<uint32>(12), cmd.bucket_id); +} + #endif // GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_FORMAT_TEST_AUTOGEN_H_ diff --git a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h index 95698a6..25bf081 100644 --- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h +++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h @@ -209,6 +209,7 @@ OP(WaitLatchCHROMIUM) /* 452 */ \ OP(SetSurfaceCHROMIUM) /* 453 */ \ OP(GetMultipleIntegervCHROMIUM) /* 454 */ \ + OP(GetProgramInfoCHROMIUM) /* 455 */ \ enum CommandId { kStartPoint = cmd::kLastCommonId, // All GLES2 commands start after this. |