Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: core/cross/command_buffer/states_cb.h

Issue 212018: Change command buffer client code to use structures.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « core/cross/command_buffer/sampler_cb.cc ('k') | core/cross/command_buffer/states_cb.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 // Sends commands to commit all the changed states. 53 // Sends commands to commit all the changed states.
54 void ValidateStates(command_buffer::CommandBufferHelper *helper); 54 void ValidateStates(command_buffer::CommandBufferHelper *helper);
55 55
56 // Adds the state handlers for all the states. 56 // Adds the state handlers for all the states.
57 void AddStateHandlers(RendererCB *renderer); 57 void AddStateHandlers(RendererCB *renderer);
58 private: 58 private:
59 // A template helper. This wraps a command sent to set a set of states. It 59 // A template helper. This wraps a command sent to set a set of states. It
60 // keeps all the arguments of a single command, that get modified by the 60 // keeps all the arguments of a single command, that get modified by the
61 // various handles, as well as a dirty bit. 61 // various handles, as well as a dirty bit.
62 template <command_buffer::CommandId command, unsigned int arg_count> 62 template <typename CommandType>
63 class StateHelper { 63 class StateHelper {
64 public: 64 public:
65 static const unsigned int kArgCount = arg_count;
66
67 StateHelper() : dirty_(false) { 65 StateHelper() : dirty_(false) {
68 for (unsigned int i = 0; i < kArgCount; ++i) { 66 // NOTE: This code assumes the state commands only need their
69 args_[i].value_uint32 = 0; 67 // header set and that the rest will be set by the state handlers.
70 } 68 memset(&command_, 0, sizeof(command_));
69 command_.SetHeader();
71 } 70 }
72 71
73 // Sends the command if it is marked as dirty. 72 // Sends the command if it is marked as dirty.
74 void Validate(command_buffer::CommandBufferHelper *helper) { 73 void Validate(command_buffer::CommandBufferHelper *helper) {
75 if (!dirty_) return; 74 if (!dirty_) return;
76 helper->AddCommand(command, kArgCount, args_); 75 helper->AddTypedCmdData(command_);
77 dirty_ = false; 76 dirty_ = false;
78 } 77 }
79 78
80 command_buffer::CommandBufferEntry *args() { return args_; } 79 CommandType& command() {
80 return command_;
81 }
82
81 bool *dirty_ptr() { return &dirty_; } 83 bool *dirty_ptr() { return &dirty_; }
82 private: 84 private:
83 bool dirty_; 85 bool dirty_;
84 command_buffer::CommandBufferEntry args_[kArgCount]; 86 CommandType command_;
85 DISALLOW_COPY_AND_ASSIGN(StateHelper); 87 DISALLOW_COPY_AND_ASSIGN(StateHelper);
86 }; 88 };
87 89
88 StateHelper<command_buffer::SET_POINT_LINE_RASTER, 2> point_line_helper_; 90 StateHelper<command_buffer::cmd::SetPointLineRaster> point_line_helper_;
89 StateHelper<command_buffer::SET_POLYGON_OFFSET, 2> poly_offset_helper_; 91 StateHelper<command_buffer::cmd::SetPolygonOffset> poly_offset_helper_;
90 StateHelper<command_buffer::SET_POLYGON_RASTER, 1> poly_raster_helper_; 92 StateHelper<command_buffer::cmd::SetPolygonRaster> poly_raster_helper_;
91 StateHelper<command_buffer::SET_ALPHA_TEST, 2> alpha_test_helper_; 93 StateHelper<command_buffer::cmd::SetAlphaTest> alpha_test_helper_;
92 StateHelper<command_buffer::SET_DEPTH_TEST, 1> depth_test_helper_; 94 StateHelper<command_buffer::cmd::SetDepthTest> depth_test_helper_;
93 StateHelper<command_buffer::SET_STENCIL_TEST, 2> stencil_test_helper_; 95 StateHelper<command_buffer::cmd::SetStencilTest> stencil_test_helper_;
94 StateHelper<command_buffer::SET_COLOR_WRITE, 1> color_write_helper_; 96 StateHelper<command_buffer::cmd::SetColorWrite> color_write_helper_;
95 StateHelper<command_buffer::SET_BLENDING, 1> blending_helper_; 97 StateHelper<command_buffer::cmd::SetBlending> blending_helper_;
96 StateHelper<command_buffer::SET_BLENDING_COLOR, 4> blending_color_helper_; 98 StateHelper<command_buffer::cmd::SetBlendingColor> blending_color_helper_;
97 DISALLOW_COPY_AND_ASSIGN(StateManager); 99 DISALLOW_COPY_AND_ASSIGN(StateManager);
98 }; 100 };
99 101
100 } // namespace o3d 102 } // namespace o3d
101 103
102 #endif // O3D_CORE_CROSS_COMMAND_BUFFER_STATES_CB_H_ 104 #endif // O3D_CORE_CROSS_COMMAND_BUFFER_STATES_CB_H_
OLDNEW
« no previous file with comments | « core/cross/command_buffer/sampler_cb.cc ('k') | core/cross/command_buffer/states_cb.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698