summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/common
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-12 00:31:58 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-12 00:31:58 +0000
commit60f22d35af1bcf81ebe4e2c69bc7415379721d9d (patch)
treec3f5f7fc7a2b966cb173850ab305c8793986f16c /gpu/command_buffer/common
parenta14c9b9ae0e15becb11dc2a7e8940722a00374af (diff)
downloadchromium_src-60f22d35af1bcf81ebe4e2c69bc7415379721d9d.zip
chromium_src-60f22d35af1bcf81ebe4e2c69bc7415379721d9d.tar.gz
chromium_src-60f22d35af1bcf81ebe4e2c69bc7415379721d9d.tar.bz2
Plumb glDiscardFramebufferEXT entry point through command buffer
BUG= Review URL: https://chromiumcodereview.appspot.com/11465018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172468 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/common')
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_autogen.h100
-rw-r--r--gpu/command_buffer/common/gles2_cmd_format_test_autogen.h46
-rw-r--r--gpu/command_buffer/common/gles2_cmd_ids_autogen.h2
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils_autogen.h1
-rw-r--r--gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h10
5 files changed, 159 insertions, 0 deletions
diff --git a/gpu/command_buffer/common/gles2_cmd_format_autogen.h b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
index 3d291c0..d7e887d 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_autogen.h
@@ -10730,6 +10730,106 @@ COMPILE_ASSERT(offsetof(AsyncTexImage2DCHROMIUM, pixels_shm_id) == 36,
COMPILE_ASSERT(offsetof(AsyncTexImage2DCHROMIUM, pixels_shm_offset) == 40,
OffsetOf_AsyncTexImage2DCHROMIUM_pixels_shm_offset_not_40);
+struct DiscardFramebufferEXT {
+ typedef DiscardFramebufferEXT ValueType;
+ static const CommandId kCmdId = kDiscardFramebufferEXT;
+ static const cmd::ArgFlags kArgFlags = cmd::kFixed;
+
+ static uint32 ComputeSize() {
+ return static_cast<uint32>(sizeof(ValueType)); // NOLINT
+ }
+
+ void SetHeader() {
+ header.SetCmd<ValueType>();
+ }
+
+ void Init(
+ GLenum _target, GLsizei _count, uint32 _attachments_shm_id,
+ uint32 _attachments_shm_offset) {
+ SetHeader();
+ target = _target;
+ count = _count;
+ attachments_shm_id = _attachments_shm_id;
+ attachments_shm_offset = _attachments_shm_offset;
+ }
+
+ void* Set(
+ void* cmd, GLenum _target, GLsizei _count, uint32 _attachments_shm_id,
+ uint32 _attachments_shm_offset) {
+ static_cast<ValueType*>(
+ cmd)->Init(
+ _target, _count, _attachments_shm_id, _attachments_shm_offset);
+ return NextCmdAddress<ValueType>(cmd);
+ }
+
+ gpu::CommandHeader header;
+ uint32 target;
+ int32 count;
+ uint32 attachments_shm_id;
+ uint32 attachments_shm_offset;
+};
+
+COMPILE_ASSERT(sizeof(DiscardFramebufferEXT) == 20,
+ Sizeof_DiscardFramebufferEXT_is_not_20);
+COMPILE_ASSERT(offsetof(DiscardFramebufferEXT, header) == 0,
+ OffsetOf_DiscardFramebufferEXT_header_not_0);
+COMPILE_ASSERT(offsetof(DiscardFramebufferEXT, target) == 4,
+ OffsetOf_DiscardFramebufferEXT_target_not_4);
+COMPILE_ASSERT(offsetof(DiscardFramebufferEXT, count) == 8,
+ OffsetOf_DiscardFramebufferEXT_count_not_8);
+COMPILE_ASSERT(offsetof(DiscardFramebufferEXT, attachments_shm_id) == 12,
+ OffsetOf_DiscardFramebufferEXT_attachments_shm_id_not_12);
+COMPILE_ASSERT(offsetof(DiscardFramebufferEXT, attachments_shm_offset) == 16,
+ OffsetOf_DiscardFramebufferEXT_attachments_shm_offset_not_16);
+
+struct DiscardFramebufferEXTImmediate {
+ typedef DiscardFramebufferEXTImmediate ValueType;
+ static const CommandId kCmdId = kDiscardFramebufferEXTImmediate;
+ static const cmd::ArgFlags kArgFlags = cmd::kAtLeastN;
+
+ static uint32 ComputeDataSize(GLsizei count) {
+ return static_cast<uint32>(
+ sizeof(GLenum) * 1 * count); // NOLINT
+ }
+
+ static uint32 ComputeSize(GLsizei count) {
+ return static_cast<uint32>(
+ sizeof(ValueType) + ComputeDataSize(count)); // NOLINT
+ }
+
+ void SetHeader(GLsizei count) {
+ header.SetCmdByTotalSize<ValueType>(ComputeSize(count));
+ }
+
+ void Init(GLenum _target, GLsizei _count, const GLenum* _attachments) {
+ SetHeader(_count);
+ target = _target;
+ count = _count;
+ memcpy(ImmediateDataAddress(this),
+ _attachments, ComputeDataSize(_count));
+ }
+
+ void* Set(
+ void* cmd, GLenum _target, GLsizei _count, const GLenum* _attachments) {
+ static_cast<ValueType*>(cmd)->Init(_target, _count, _attachments);
+ const uint32 size = ComputeSize(_count);
+ return NextImmediateCmdAddressTotalSize<ValueType>(cmd, size);
+ }
+
+ gpu::CommandHeader header;
+ uint32 target;
+ int32 count;
+};
+
+COMPILE_ASSERT(sizeof(DiscardFramebufferEXTImmediate) == 12,
+ Sizeof_DiscardFramebufferEXTImmediate_is_not_12);
+COMPILE_ASSERT(offsetof(DiscardFramebufferEXTImmediate, header) == 0,
+ OffsetOf_DiscardFramebufferEXTImmediate_header_not_0);
+COMPILE_ASSERT(offsetof(DiscardFramebufferEXTImmediate, target) == 4,
+ OffsetOf_DiscardFramebufferEXTImmediate_target_not_4);
+COMPILE_ASSERT(offsetof(DiscardFramebufferEXTImmediate, count) == 8,
+ OffsetOf_DiscardFramebufferEXTImmediate_count_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 55009c2..54795a7 100644
--- a/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_format_test_autogen.h
@@ -4318,5 +4318,51 @@ TEST_F(GLES2FormatTest, AsyncTexImage2DCHROMIUM) {
next_cmd, sizeof(cmd));
}
+TEST_F(GLES2FormatTest, DiscardFramebufferEXT) {
+ DiscardFramebufferEXT& cmd = *GetBufferAs<DiscardFramebufferEXT>();
+ void* next_cmd = cmd.Set(
+ &cmd,
+ static_cast<GLenum>(11),
+ static_cast<GLsizei>(12),
+ static_cast<uint32>(13),
+ static_cast<uint32>(14));
+ EXPECT_EQ(static_cast<uint32>(DiscardFramebufferEXT::kCmdId),
+ cmd.header.command);
+ EXPECT_EQ(sizeof(cmd), cmd.header.size * 4u);
+ EXPECT_EQ(static_cast<GLenum>(11), cmd.target);
+ EXPECT_EQ(static_cast<GLsizei>(12), cmd.count);
+ EXPECT_EQ(static_cast<uint32>(13), cmd.attachments_shm_id);
+ EXPECT_EQ(static_cast<uint32>(14), cmd.attachments_shm_offset);
+ CheckBytesWrittenMatchesExpectedSize(
+ next_cmd, sizeof(cmd));
+}
+
+TEST_F(GLES2FormatTest, DiscardFramebufferEXTImmediate) {
+ const int kSomeBaseValueToTestWith = 51;
+ static GLenum data[] = {
+ static_cast<GLenum>(kSomeBaseValueToTestWith + 0),
+ static_cast<GLenum>(kSomeBaseValueToTestWith + 1),
+ };
+ DiscardFramebufferEXTImmediate& cmd =
+ *GetBufferAs<DiscardFramebufferEXTImmediate>();
+ const GLsizei kNumElements = 2;
+ const size_t kExpectedCmdSize =
+ sizeof(cmd) + kNumElements * sizeof(GLenum) * 1;
+ void* next_cmd = cmd.Set(
+ &cmd,
+ static_cast<GLenum>(1),
+ static_cast<GLsizei>(2),
+ data);
+ EXPECT_EQ(static_cast<uint32>(DiscardFramebufferEXTImmediate::kCmdId),
+ cmd.header.command);
+ EXPECT_EQ(kExpectedCmdSize, cmd.header.size * 4u);
+ EXPECT_EQ(static_cast<GLenum>(1), cmd.target);
+ EXPECT_EQ(static_cast<GLsizei>(2), cmd.count);
+ CheckBytesWrittenMatchesExpectedSize(
+ next_cmd, sizeof(cmd) +
+ RoundSizeToMultipleOfEntries(sizeof(data)));
+ // TODO(gman): Check that data was inserted;
+}
+
#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 70925cd..0a7a577 100644
--- a/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_ids_autogen.h
@@ -245,6 +245,8 @@
OP(TraceEndCHROMIUM) /* 488 */ \
OP(AsyncTexSubImage2DCHROMIUM) /* 489 */ \
OP(AsyncTexImage2DCHROMIUM) /* 490 */ \
+ OP(DiscardFramebufferEXT) /* 491 */ \
+ OP(DiscardFramebufferEXTImmediate) /* 492 */ \
enum CommandId {
kStartPoint = cmd::kLastCommonId, // All GLES2 commands start after this.
diff --git a/gpu/command_buffer/common/gles2_cmd_utils_autogen.h b/gpu/command_buffer/common/gles2_cmd_utils_autogen.h
index bc004e8..b2d155c 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_utils_autogen.h
@@ -10,6 +10,7 @@
#define GPU_COMMAND_BUFFER_COMMON_GLES2_CMD_UTILS_AUTOGEN_H_
static std::string GetStringAttachment(uint32 value);
+static std::string GetStringBackbufferAttachment(uint32 value);
static std::string GetStringBlitFilter(uint32 value);
static std::string GetStringBufferParameter(uint32 value);
static std::string GetStringBufferTarget(uint32 value);
diff --git a/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h b/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h
index a358e7b..c17da70 100644
--- a/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h
+++ b/gpu/command_buffer/common/gles2_cmd_utils_implementation_autogen.h
@@ -680,6 +680,16 @@ std::string GLES2Util::GetStringAttachment(uint32 value) {
string_table, arraysize(string_table), value);
}
+std::string GLES2Util::GetStringBackbufferAttachment(uint32 value) {
+ static EnumToString string_table[] = {
+ { GL_COLOR_EXT, "GL_COLOR_EXT" },
+ { GL_DEPTH_EXT, "GL_DEPTH_EXT" },
+ { GL_STENCIL_EXT, "GL_STENCIL_EXT" },
+ };
+ return GLES2Util::GetQualifiedEnumString(
+ string_table, arraysize(string_table), value);
+}
+
std::string GLES2Util::GetStringBlitFilter(uint32 value) {
static EnumToString string_table[] = {
{ GL_NEAREST, "GL_NEAREST" },