OLD | NEW |
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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 #include "core/cross/precompile.h" | 36 #include "core/cross/precompile.h" |
37 #include "core/cross/state.h" | 37 #include "core/cross/state.h" |
38 #include "core/cross/command_buffer/renderer_cb.h" | 38 #include "core/cross/command_buffer/renderer_cb.h" |
39 #include "core/cross/command_buffer/states_cb.h" | 39 #include "core/cross/command_buffer/states_cb.h" |
40 #include "command_buffer/common/cross/gapi_interface.h" | 40 #include "command_buffer/common/cross/gapi_interface.h" |
41 | 41 |
42 namespace o3d { | 42 namespace o3d { |
43 using command_buffer::CommandBufferEntry; | 43 using command_buffer::CommandBufferEntry; |
44 using command_buffer::CommandBufferHelper; | 44 using command_buffer::CommandBufferHelper; |
45 using command_buffer::GAPIInterface; | |
46 | 45 |
47 namespace { | 46 namespace { |
48 | 47 |
49 // Converts values meant to represent a Cull Mode to the corresponding | 48 // Converts values meant to represent a Cull Mode to the corresponding |
50 // command-buffer value. | 49 // command-buffer value. |
51 // Default: CULL_NONE. | 50 // Default: CULL_NONE. |
52 GAPIInterface::FaceCullMode CullModeToCB(int cull) { | 51 command_buffer::FaceCullMode CullModeToCB(int cull) { |
53 switch (cull) { | 52 switch (cull) { |
54 default: | 53 default: |
55 case State::CULL_NONE: | 54 case State::CULL_NONE: |
56 return GAPIInterface::CULL_NONE; | 55 return command_buffer::kCullNone; |
57 case State::CULL_CW: | 56 case State::CULL_CW: |
58 return GAPIInterface::CULL_CW; | 57 return command_buffer::kCullCW; |
59 case State::CULL_CCW: | 58 case State::CULL_CCW: |
60 return GAPIInterface::CULL_CCW; | 59 return command_buffer::kCullCCW; |
61 } | 60 } |
62 } | 61 } |
63 | 62 |
64 // Converts values meant to represent a Polygon Fill Mode to the corresponding | 63 // Converts values meant to represent a Polygon Fill Mode to the corresponding |
65 // command-buffer value. | 64 // command-buffer value. |
66 // Default: POLYGON_MODE_FILL. | 65 // Default: kPolygonModeFill. |
67 GAPIInterface::PolygonMode FillModeToCB(int fill) { | 66 command_buffer::PolygonMode FillModeToCB(int fill) { |
68 switch (fill) { | 67 switch (fill) { |
69 case State::POINT: | 68 case State::POINT: |
70 return GAPIInterface::POLYGON_MODE_POINTS; | 69 return command_buffer::kPolygonModePoints; |
71 case State::WIREFRAME: | 70 case State::WIREFRAME: |
72 return GAPIInterface::POLYGON_MODE_LINES; | 71 return command_buffer::kPolygonModeLines; |
73 default: | 72 default: |
74 case State::SOLID: | 73 case State::SOLID: |
75 return GAPIInterface::POLYGON_MODE_FILL; | 74 return command_buffer::kPolygonModeFill; |
76 } | 75 } |
77 } | 76 } |
78 | 77 |
79 // Converts values meant to represent a Comparison Function to the corresponding | 78 // Converts values meant to represent a Comparison Function to the corresponding |
80 // command-buffer value. | 79 // command-buffer value. |
81 // Default: ALWAYS. | 80 // Default: kAlways. |
82 GAPIInterface::Comparison ComparisonToCB(int comparison) { | 81 command_buffer::Comparison ComparisonToCB(int comparison) { |
83 switch (comparison) { | 82 switch (comparison) { |
84 case State::CMP_NEVER: | 83 case State::CMP_NEVER: |
85 return GAPIInterface::NEVER; | 84 return command_buffer::kNever; |
86 case State::CMP_LESS: | 85 case State::CMP_LESS: |
87 return GAPIInterface::LESS; | 86 return command_buffer::kLess; |
88 case State::CMP_EQUAL: | 87 case State::CMP_EQUAL: |
89 return GAPIInterface::EQUAL; | 88 return command_buffer::kEqual; |
90 case State::CMP_LEQUAL: | 89 case State::CMP_LEQUAL: |
91 return GAPIInterface::LEQUAL; | 90 return command_buffer::kLEqual; |
92 case State::CMP_GREATER: | 91 case State::CMP_GREATER: |
93 return GAPIInterface::GREATER; | 92 return command_buffer::kGreater; |
94 case State::CMP_NOTEQUAL: | 93 case State::CMP_NOTEQUAL: |
95 return GAPIInterface::NOT_EQUAL; | 94 return command_buffer::kNotEqual; |
96 case State::CMP_GEQUAL: | 95 case State::CMP_GEQUAL: |
97 return GAPIInterface::GEQUAL; | 96 return command_buffer::kGEqual; |
98 case State::CMP_ALWAYS: | 97 case State::CMP_ALWAYS: |
99 default: | 98 default: |
100 return GAPIInterface::ALWAYS; | 99 return command_buffer::kAlways; |
101 } | 100 } |
102 } | 101 } |
103 | 102 |
104 // Converts values meant to represent a Stencil Operation to the corresponding | 103 // Converts values meant to represent a Stencil Operation to the corresponding |
105 // command-buffer value. | 104 // command-buffer value. |
106 // Default: KEEP. | 105 // Default: kKeep. |
107 GAPIInterface::StencilOp StencilOpToCB(int op) { | 106 command_buffer::StencilOp StencilOpToCB(int op) { |
108 switch (op) { | 107 switch (op) { |
109 default: | 108 default: |
110 case State::STENCIL_KEEP: | 109 case State::STENCIL_KEEP: |
111 return GAPIInterface::KEEP; | 110 return command_buffer::kKeep; |
112 case State::STENCIL_ZERO: | 111 case State::STENCIL_ZERO: |
113 return GAPIInterface::ZERO; | 112 return command_buffer::kZero; |
114 case State::STENCIL_REPLACE: | 113 case State::STENCIL_REPLACE: |
115 return GAPIInterface::REPLACE; | 114 return command_buffer::kReplace; |
116 case State::STENCIL_INCREMENT_SATURATE: | 115 case State::STENCIL_INCREMENT_SATURATE: |
117 return GAPIInterface::INC_NO_WRAP; | 116 return command_buffer::kIncNoWrap; |
118 case State::STENCIL_DECREMENT_SATURATE: | 117 case State::STENCIL_DECREMENT_SATURATE: |
119 return GAPIInterface::DEC_NO_WRAP; | 118 return command_buffer::kDecNoWrap; |
120 case State::STENCIL_INVERT: | 119 case State::STENCIL_INVERT: |
121 return GAPIInterface::INVERT; | 120 return command_buffer::kInvert; |
122 case State::STENCIL_INCREMENT: | 121 case State::STENCIL_INCREMENT: |
123 return GAPIInterface::INC_WRAP; | 122 return command_buffer::kIncWrap; |
124 case State::STENCIL_DECREMENT: | 123 case State::STENCIL_DECREMENT: |
125 return GAPIInterface::DEC_WRAP; | 124 return command_buffer::kDecWrap; |
126 } | 125 } |
127 } | 126 } |
128 | 127 |
129 // Converts values meant to represent a Blending Function to the corresponding | 128 // Converts values meant to represent a Blending Function to the corresponding |
130 // command-buffer value. | 129 // command-buffer value. |
131 // Default: BLEND_FUNC_ONE. | 130 // Default: kBlendFuncOne. |
132 GAPIInterface::BlendFunc BlendFuncToCB(int func) { | 131 command_buffer::BlendFunc BlendFuncToCB(int func) { |
133 switch (func) { | 132 switch (func) { |
134 case State::BLENDFUNC_ZERO: | 133 case State::BLENDFUNC_ZERO: |
135 return GAPIInterface::BLEND_FUNC_ZERO; | 134 return command_buffer::kBlendFuncZero; |
136 default: | 135 default: |
137 case State::BLENDFUNC_ONE: | 136 case State::BLENDFUNC_ONE: |
138 return GAPIInterface::BLEND_FUNC_ONE; | 137 return command_buffer::kBlendFuncOne; |
139 case State::BLENDFUNC_SOURCE_COLOR: | 138 case State::BLENDFUNC_SOURCE_COLOR: |
140 return GAPIInterface::BLEND_FUNC_SRC_COLOR; | 139 return command_buffer::kBlendFuncSrcColor; |
141 case State::BLENDFUNC_INVERSE_SOURCE_COLOR: | 140 case State::BLENDFUNC_INVERSE_SOURCE_COLOR: |
142 return GAPIInterface::BLEND_FUNC_INV_SRC_COLOR; | 141 return command_buffer::kBlendFuncInvSrcColor; |
143 case State::BLENDFUNC_SOURCE_ALPHA: | 142 case State::BLENDFUNC_SOURCE_ALPHA: |
144 return GAPIInterface::BLEND_FUNC_SRC_ALPHA; | 143 return command_buffer::kBlendFuncSrcAlpha; |
145 case State::BLENDFUNC_INVERSE_SOURCE_ALPHA: | 144 case State::BLENDFUNC_INVERSE_SOURCE_ALPHA: |
146 return GAPIInterface::BLEND_FUNC_INV_SRC_ALPHA; | 145 return command_buffer::kBlendFuncInvSrcAlpha; |
147 case State::BLENDFUNC_DESTINATION_ALPHA: | 146 case State::BLENDFUNC_DESTINATION_ALPHA: |
148 return GAPIInterface::BLEND_FUNC_DST_ALPHA; | 147 return command_buffer::kBlendFuncDstAlpha; |
149 case State::BLENDFUNC_INVERSE_DESTINATION_ALPHA: | 148 case State::BLENDFUNC_INVERSE_DESTINATION_ALPHA: |
150 return GAPIInterface::BLEND_FUNC_INV_DST_ALPHA; | 149 return command_buffer::kBlendFuncInvDstAlpha; |
151 case State::BLENDFUNC_DESTINATION_COLOR: | 150 case State::BLENDFUNC_DESTINATION_COLOR: |
152 return GAPIInterface::BLEND_FUNC_DST_COLOR; | 151 return command_buffer::kBlendFuncDstColor; |
153 case State::BLENDFUNC_INVERSE_DESTINATION_COLOR: | 152 case State::BLENDFUNC_INVERSE_DESTINATION_COLOR: |
154 return GAPIInterface::BLEND_FUNC_INV_DST_COLOR; | 153 return command_buffer::kBlendFuncInvDstColor; |
155 case State::BLENDFUNC_SOURCE_ALPHA_SATUTRATE: | 154 case State::BLENDFUNC_SOURCE_ALPHA_SATUTRATE: |
156 return GAPIInterface::BLEND_FUNC_SRC_ALPHA_SATUTRATE; | 155 return command_buffer::kBlendFuncSrcAlphaSaturate; |
157 } | 156 } |
158 } | 157 } |
159 | 158 |
160 // Converts values meant to represent a Blending Equation to the corresponding | 159 // Converts values meant to represent a Blending Equation to the corresponding |
161 // command-buffer value. | 160 // command-buffer value. |
162 // Default: BLEND_EQ_ADD. | 161 // Default: kBlendEqAdd. |
163 GAPIInterface::BlendEq BlendEqToCB(int eq) { | 162 command_buffer::BlendEq BlendEqToCB(int eq) { |
164 switch (eq) { | 163 switch (eq) { |
165 default: | 164 default: |
166 case State::BLEND_ADD: | 165 case State::BLEND_ADD: |
167 return GAPIInterface::BLEND_EQ_ADD; | 166 return command_buffer::kBlendEqAdd; |
168 case State::BLEND_SUBTRACT: | 167 case State::BLEND_SUBTRACT: |
169 return GAPIInterface::BLEND_EQ_SUB; | 168 return command_buffer::kBlendEqSub; |
170 case State::BLEND_REVERSE_SUBTRACT: | 169 case State::BLEND_REVERSE_SUBTRACT: |
171 return GAPIInterface::BLEND_EQ_REV_SUB; | 170 return command_buffer::kBlendEqRevSub; |
172 case State::BLEND_MIN: | 171 case State::BLEND_MIN: |
173 return GAPIInterface::BLEND_EQ_MIN; | 172 return command_buffer::kBlendEqMin; |
174 case State::BLEND_MAX: | 173 case State::BLEND_MAX: |
175 return GAPIInterface::BLEND_EQ_MAX; | 174 return command_buffer::kBlendEqMax; |
176 } | 175 } |
177 } | 176 } |
178 | 177 |
179 } // anonymous namespace | 178 } // anonymous namespace |
180 | 179 |
181 // This class wraps StateHandler to make it type-safe. | 180 // This class wraps StateHandler to make it type-safe. |
182 template <typename T> | 181 template <typename T> |
183 class TypedStateHandler : public RendererCB::StateHandler { | 182 class TypedStateHandler : public RendererCB::StateHandler { |
184 public: | 183 public: |
185 // Override this function to set a specific state. | 184 // Override this function to set a specific state. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 // A handler for the color write state. | 257 // A handler for the color write state. |
259 class ColorWriteStateHandler : public TypedStateHandler<ParamInteger> { | 258 class ColorWriteStateHandler : public TypedStateHandler<ParamInteger> { |
260 public: | 259 public: |
261 ColorWriteStateHandler(uint32 *value, bool *dirty) | 260 ColorWriteStateHandler(uint32 *value, bool *dirty) |
262 : value_(value), | 261 : value_(value), |
263 dirty_(dirty) { | 262 dirty_(dirty) { |
264 } | 263 } |
265 | 264 |
266 virtual void SetStateFromTypedParam(RendererCB* renderer, | 265 virtual void SetStateFromTypedParam(RendererCB* renderer, |
267 ParamInteger* param) const { | 266 ParamInteger* param) const { |
| 267 using command_buffer::cmd::SetColorWrite; |
268 int mask = param->value(); | 268 int mask = param->value(); |
269 o3d::command_buffer::set_color_write::AllColorsMask::Set(value_, mask); | 269 SetColorWrite::AllColorsMask::Set(value_, mask); |
270 renderer->SetWriteMask(mask); | 270 renderer->SetWriteMask(mask); |
271 *dirty_ = true; | 271 *dirty_ = true; |
272 } | 272 } |
273 private: | 273 private: |
274 uint32 *value_; | 274 uint32 *value_; |
275 bool *dirty_; | 275 bool *dirty_; |
276 }; | 276 }; |
277 | 277 |
278 // A template that generates a handler for full-size values (uint32, int32, | 278 // A template that generates a handler for full-size values (uint32, int32, |
279 // float). | 279 // float). |
(...skipping 27 matching lines...) Expand all Loading... |
307 // dirty: a pointer to the dirty bit. | 307 // dirty: a pointer to the dirty bit. |
308 class CullModeStateHandler : public TypedStateHandler<ParamInteger> { | 308 class CullModeStateHandler : public TypedStateHandler<ParamInteger> { |
309 public: | 309 public: |
310 CullModeStateHandler(uint32 *value, bool *dirty) | 310 CullModeStateHandler(uint32 *value, bool *dirty) |
311 : value_(value), | 311 : value_(value), |
312 dirty_(dirty) { | 312 dirty_(dirty) { |
313 } | 313 } |
314 | 314 |
315 virtual void SetStateFromTypedParam(RendererCB* renderer, | 315 virtual void SetStateFromTypedParam(RendererCB* renderer, |
316 ParamInteger* param) const { | 316 ParamInteger* param) const { |
317 using command_buffer::set_polygon_raster::CullMode; | 317 using command_buffer::cmd::SetPolygonRaster; |
318 CullMode::Set(value_, CullModeToCB(param->value())); | 318 SetPolygonRaster::CullMode::Set(value_, CullModeToCB(param->value())); |
319 *dirty_ = true; | 319 *dirty_ = true; |
320 } | 320 } |
321 private: | 321 private: |
322 uint32 *value_; | 322 uint32 *value_; |
323 bool *dirty_; | 323 bool *dirty_; |
324 }; | 324 }; |
325 | 325 |
326 // Handler for Polygon Fill Mode. | 326 // Handler for Polygon Fill Mode. |
327 // Parameters: | 327 // Parameters: |
328 // value: a pointer to the argument value as an uint32. | 328 // value: a pointer to the argument value as an uint32. |
329 // dirty: a pointer to the dirty bit. | 329 // dirty: a pointer to the dirty bit. |
330 class FillModeStateHandler : public TypedStateHandler<ParamInteger> { | 330 class FillModeStateHandler : public TypedStateHandler<ParamInteger> { |
331 public: | 331 public: |
332 FillModeStateHandler(uint32 *value, bool *dirty) | 332 FillModeStateHandler(uint32 *value, bool *dirty) |
333 : value_(value), | 333 : value_(value), |
334 dirty_(dirty) { | 334 dirty_(dirty) { |
335 } | 335 } |
336 | 336 |
337 virtual void SetStateFromTypedParam(RendererCB* renderer, | 337 virtual void SetStateFromTypedParam(RendererCB* renderer, |
338 ParamInteger* param) const { | 338 ParamInteger* param) const { |
339 using command_buffer::set_polygon_raster::FillMode; | 339 using command_buffer::cmd::SetPolygonRaster; |
340 FillMode::Set(value_, FillModeToCB(param->value())); | 340 SetPolygonRaster::FillMode::Set(value_, FillModeToCB(param->value())); |
341 *dirty_ = true; | 341 *dirty_ = true; |
342 } | 342 } |
343 private: | 343 private: |
344 uint32 *value_; | 344 uint32 *value_; |
345 bool *dirty_; | 345 bool *dirty_; |
346 }; | 346 }; |
347 | 347 |
348 // A template that generates a handler for comparison functions. | 348 // A template that generates a handler for comparison functions. |
349 // Template Parameters: | 349 // Template Parameters: |
350 // bit_field: the BitField type to access the proper bits. | 350 // bit_field: the BitField type to access the proper bits. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 uint32 *value_; | 440 uint32 *value_; |
441 bool *dirty_; | 441 bool *dirty_; |
442 }; | 442 }; |
443 | 443 |
444 // Adds all the state handlers for all the states. The list of handlers must | 444 // Adds all the state handlers for all the states. The list of handlers must |
445 // match in names and types the list in Renderer::AddDefaultStates() | 445 // match in names and types the list in Renderer::AddDefaultStates() |
446 // (in renderer.cc). | 446 // (in renderer.cc). |
447 void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) { | 447 void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) { |
448 // Point/Line raster | 448 // Point/Line raster |
449 { | 449 { |
450 using command_buffer::set_point_line_raster::LineSmoothEnable; | |
451 using command_buffer::set_point_line_raster::PointSpriteEnable; | |
452 bool *dirty = point_line_helper_.dirty_ptr(); | 450 bool *dirty = point_line_helper_.dirty_ptr(); |
453 command_buffer::cmd::SetPointLineRaster& cmd = | 451 using command_buffer::cmd::SetPointLineRaster; |
454 point_line_helper_.command(); | 452 SetPointLineRaster& cmd = point_line_helper_.command(); |
455 renderer->AddStateHandler( | 453 renderer->AddStateHandler( |
456 State::kLineSmoothEnableParamName, | 454 State::kLineSmoothEnableParamName, |
457 new EnableStateHandler<LineSmoothEnable>(&cmd.fixme0, dirty)); | 455 new EnableStateHandler< |
| 456 SetPointLineRaster::LineSmoothEnable>(&cmd.enables, dirty)); |
458 renderer->AddStateHandler( | 457 renderer->AddStateHandler( |
459 State::kPointSpriteEnableParamName, | 458 State::kPointSpriteEnableParamName, |
460 new EnableStateHandler<PointSpriteEnable>(&cmd.fixme0, dirty)); | 459 new EnableStateHandler< |
| 460 SetPointLineRaster::PointSpriteEnable>(&cmd.enables, dirty)); |
461 renderer->AddStateHandler(State::kPointSizeParamName, | 461 renderer->AddStateHandler(State::kPointSizeParamName, |
462 new ValueStateHandler<ParamFloat>( | 462 new ValueStateHandler<ParamFloat>( |
463 &cmd.point_size, dirty)); | 463 &cmd.point_size, dirty)); |
464 } | 464 } |
465 | 465 |
466 // Polygon Raster | 466 // Polygon Raster |
467 { | 467 { |
468 bool *dirty = poly_raster_helper_.dirty_ptr(); | 468 bool *dirty = poly_raster_helper_.dirty_ptr(); |
469 command_buffer::cmd::SetPolygonRaster& cmd = | 469 using command_buffer::cmd::SetPolygonRaster; |
470 poly_raster_helper_.command(); | 470 SetPolygonRaster& cmd = poly_raster_helper_.command(); |
471 renderer->AddStateHandler(State::kCullModeParamName, | 471 renderer->AddStateHandler(State::kCullModeParamName, |
472 new CullModeStateHandler(&cmd.fixme0, dirty)); | 472 new CullModeStateHandler(&cmd.fill_cull, dirty)); |
473 renderer->AddStateHandler(State::kFillModeParamName, | 473 renderer->AddStateHandler(State::kFillModeParamName, |
474 new FillModeStateHandler(&cmd.fixme0, dirty)); | 474 new FillModeStateHandler(&cmd.fill_cull, dirty)); |
475 } | 475 } |
476 | 476 |
477 // Polygon Offset | 477 // Polygon Offset |
478 { | 478 { |
479 bool *dirty = poly_offset_helper_.dirty_ptr(); | 479 bool *dirty = poly_offset_helper_.dirty_ptr(); |
480 command_buffer::cmd::SetPolygonOffset& cmd = | 480 command_buffer::cmd::SetPolygonOffset& cmd = |
481 poly_offset_helper_.command(); | 481 poly_offset_helper_.command(); |
482 renderer->AddStateHandler( | 482 renderer->AddStateHandler( |
483 State::kPolygonOffset1ParamName, | 483 State::kPolygonOffset1ParamName, |
484 new ValueStateHandler<ParamFloat>(&cmd.slope_factor, dirty)); | 484 new ValueStateHandler<ParamFloat>(&cmd.slope_factor, dirty)); |
485 renderer->AddStateHandler( | 485 renderer->AddStateHandler( |
486 State::kPolygonOffset2ParamName, | 486 State::kPolygonOffset2ParamName, |
487 new ValueStateHandler<ParamFloat>(&cmd.units, dirty)); | 487 new ValueStateHandler<ParamFloat>(&cmd.units, dirty)); |
488 } | 488 } |
489 | 489 |
490 // Alpha test | 490 // Alpha test |
491 { | 491 { |
492 using command_buffer::set_alpha_test::Enable; | 492 using command_buffer::cmd::SetAlphaTest; |
493 using command_buffer::set_alpha_test::Func; | 493 SetAlphaTest& cmd = alpha_test_helper_.command(); |
494 command_buffer::cmd::SetAlphaTest& cmd = alpha_test_helper_.command(); | |
495 bool *dirty = alpha_test_helper_.dirty_ptr(); | 494 bool *dirty = alpha_test_helper_.dirty_ptr(); |
496 renderer->AddStateHandler( | 495 renderer->AddStateHandler( |
497 State::kAlphaTestEnableParamName, | 496 State::kAlphaTestEnableParamName, |
498 new EnableStateHandler<Enable>(&cmd.fixme0, dirty)); | 497 new EnableStateHandler<SetAlphaTest::Enable>(&cmd.func_enable, dirty)); |
499 renderer->AddStateHandler( | 498 renderer->AddStateHandler( |
500 State::kAlphaComparisonFunctionParamName, | 499 State::kAlphaComparisonFunctionParamName, |
501 new ComparisonStateHandler<Func>(&cmd.fixme0, dirty)); | 500 new ComparisonStateHandler<SetAlphaTest::Func>(&cmd.func_enable, dirty))
; |
502 renderer->AddStateHandler( | 501 renderer->AddStateHandler( |
503 State::kAlphaReferenceParamName, | 502 State::kAlphaReferenceParamName, |
504 new ValueStateHandler<ParamFloat>(&cmd.value, dirty)); | 503 new ValueStateHandler<ParamFloat>(&cmd.value, dirty)); |
505 } | 504 } |
506 | 505 |
507 // Depth Test | 506 // Depth Test |
508 { | 507 { |
509 using command_buffer::set_depth_test::Enable; | |
510 using command_buffer::set_depth_test::WriteEnable; | |
511 using command_buffer::set_depth_test::Func; | |
512 bool *dirty = depth_test_helper_.dirty_ptr(); | 508 bool *dirty = depth_test_helper_.dirty_ptr(); |
513 command_buffer::cmd::SetDepthTest& cmd = depth_test_helper_.command(); | 509 using command_buffer::cmd::SetDepthTest; |
| 510 SetDepthTest& cmd = depth_test_helper_.command(); |
514 renderer->AddStateHandler( | 511 renderer->AddStateHandler( |
515 State::kZWriteEnableParamName, | 512 State::kZWriteEnableParamName, |
516 new EnableStateHandler<WriteEnable>(&cmd.fixme0, dirty)); | 513 new EnableStateHandler<SetDepthTest::WriteEnable>(&cmd.func_enable, dirt
y)); |
517 renderer->AddStateHandler( | 514 renderer->AddStateHandler( |
518 State::kZEnableParamName, | 515 State::kZEnableParamName, |
519 new EnableStateHandler<Enable>(&cmd.fixme0, dirty)); | 516 new EnableStateHandler<SetDepthTest::Enable>(&cmd.func_enable, dirty)); |
520 renderer->AddStateHandler( | 517 renderer->AddStateHandler( |
521 State::kZComparisonFunctionParamName, | 518 State::kZComparisonFunctionParamName, |
522 new ComparisonStateHandler<Func>(&cmd.fixme0, dirty)); | 519 new ComparisonStateHandler<SetDepthTest::Func>(&cmd.func_enable, dirty))
; |
523 } | 520 } |
524 | 521 |
525 // Stencil Test | 522 // Stencil Test |
526 { | 523 { |
527 using command_buffer::set_stencil_test::Enable; | |
528 using command_buffer::set_stencil_test::SeparateCCW; | |
529 using command_buffer::set_stencil_test::WriteMask; | |
530 using command_buffer::set_stencil_test::CompareMask; | |
531 using command_buffer::set_stencil_test::ReferenceValue; | |
532 using command_buffer::set_stencil_test::CWFunc; | |
533 using command_buffer::set_stencil_test::CWPassOp; | |
534 using command_buffer::set_stencil_test::CWFailOp; | |
535 using command_buffer::set_stencil_test::CWZFailOp; | |
536 using command_buffer::set_stencil_test::CCWFunc; | |
537 using command_buffer::set_stencil_test::CCWPassOp; | |
538 using command_buffer::set_stencil_test::CCWFailOp; | |
539 using command_buffer::set_stencil_test::CCWZFailOp; | |
540 bool *dirty = stencil_test_helper_.dirty_ptr(); | 524 bool *dirty = stencil_test_helper_.dirty_ptr(); |
541 command_buffer::cmd::SetStencilTest& cmd = stencil_test_helper_.command(); | 525 using command_buffer::cmd::SetStencilTest; |
| 526 SetStencilTest& cmd = stencil_test_helper_.command(); |
542 renderer->AddStateHandler( | 527 renderer->AddStateHandler( |
543 State::kStencilEnableParamName, | 528 State::kStencilEnableParamName, |
544 new EnableStateHandler<Enable>(&cmd.fixme0, dirty)); | 529 new EnableStateHandler<SetStencilTest::Enable>(&cmd.stencil_args0, dirty
)); |
545 renderer->AddStateHandler( | 530 renderer->AddStateHandler( |
546 State::kTwoSidedStencilEnableParamName, | 531 State::kTwoSidedStencilEnableParamName, |
547 new EnableStateHandler<SeparateCCW>(&cmd.fixme0, dirty)); | 532 new EnableStateHandler< |
| 533 SetStencilTest::SeparateCCW>(&cmd.stencil_args0, dirty)); |
548 renderer->AddStateHandler( | 534 renderer->AddStateHandler( |
549 State::kStencilReferenceParamName, | 535 State::kStencilReferenceParamName, |
550 new BitFieldStateHandler<ReferenceValue>(&cmd.fixme0, dirty)); | 536 new BitFieldStateHandler< |
| 537 SetStencilTest::ReferenceValue>(&cmd.stencil_args0, dirty)); |
551 renderer->AddStateHandler( | 538 renderer->AddStateHandler( |
552 State::kStencilMaskParamName, | 539 State::kStencilMaskParamName, |
553 new BitFieldStateHandler<CompareMask>(&cmd.fixme0, dirty)); | 540 new BitFieldStateHandler< |
| 541 SetStencilTest::CompareMask>(&cmd.stencil_args0, dirty)); |
554 renderer->AddStateHandler( | 542 renderer->AddStateHandler( |
555 State::kStencilWriteMaskParamName, | 543 State::kStencilWriteMaskParamName, |
556 new BitFieldStateHandler<WriteMask>(&cmd.fixme0, dirty)); | 544 new BitFieldStateHandler< |
| 545 SetStencilTest::WriteMask>(&cmd.stencil_args0, dirty)); |
557 | 546 |
558 renderer->AddStateHandler( | 547 renderer->AddStateHandler( |
559 State::kStencilComparisonFunctionParamName, | 548 State::kStencilComparisonFunctionParamName, |
560 new ComparisonStateHandler<CWFunc>(&cmd.fixme1, dirty)); | 549 new ComparisonStateHandler< |
| 550 SetStencilTest::CWFunc>(&cmd.stencil_args1, dirty)); |
561 renderer->AddStateHandler( | 551 renderer->AddStateHandler( |
562 State::kStencilPassOperationParamName, | 552 State::kStencilPassOperationParamName, |
563 new StencilOpStateHandler<CWPassOp>(&cmd.fixme1, dirty)); | 553 new StencilOpStateHandler< |
| 554 SetStencilTest::CWPassOp>(&cmd.stencil_args1, dirty)); |
564 renderer->AddStateHandler( | 555 renderer->AddStateHandler( |
565 State::kStencilFailOperationParamName, | 556 State::kStencilFailOperationParamName, |
566 new StencilOpStateHandler<CWFailOp>(&cmd.fixme1, dirty)); | 557 new StencilOpStateHandler< |
| 558 SetStencilTest::CWFailOp>(&cmd.stencil_args1, dirty)); |
567 renderer->AddStateHandler( | 559 renderer->AddStateHandler( |
568 State::kStencilZFailOperationParamName, | 560 State::kStencilZFailOperationParamName, |
569 new StencilOpStateHandler<CWZFailOp>(&cmd.fixme1, dirty)); | 561 new StencilOpStateHandler< |
| 562 SetStencilTest::CWZFailOp>(&cmd.stencil_args1, dirty)); |
570 | 563 |
571 renderer->AddStateHandler( | 564 renderer->AddStateHandler( |
572 State::kCCWStencilComparisonFunctionParamName, | 565 State::kCCWStencilComparisonFunctionParamName, |
573 new ComparisonStateHandler<CCWFunc>(&cmd.fixme1, dirty)); | 566 new ComparisonStateHandler< |
| 567 SetStencilTest::CCWFunc>(&cmd.stencil_args1, dirty)); |
574 | 568 |
575 renderer->AddStateHandler( | 569 renderer->AddStateHandler( |
576 State::kCCWStencilPassOperationParamName, | 570 State::kCCWStencilPassOperationParamName, |
577 new StencilOpStateHandler<CCWPassOp>(&cmd.fixme1, dirty)); | 571 new StencilOpStateHandler< |
| 572 SetStencilTest::CCWPassOp>(&cmd.stencil_args1, dirty)); |
578 renderer->AddStateHandler( | 573 renderer->AddStateHandler( |
579 State::kCCWStencilFailOperationParamName, | 574 State::kCCWStencilFailOperationParamName, |
580 new StencilOpStateHandler<CCWFailOp>(&cmd.fixme1, dirty)); | 575 new StencilOpStateHandler< |
| 576 SetStencilTest::CCWFailOp>(&cmd.stencil_args1, dirty)); |
581 renderer->AddStateHandler( | 577 renderer->AddStateHandler( |
582 State::kCCWStencilZFailOperationParamName, | 578 State::kCCWStencilZFailOperationParamName, |
583 new StencilOpStateHandler<CCWZFailOp>(&cmd.fixme1, dirty)); | 579 new StencilOpStateHandler< |
| 580 SetStencilTest::CCWZFailOp>(&cmd.stencil_args1, dirty)); |
584 } | 581 } |
585 | 582 |
586 // Blending | 583 // Blending |
587 { | 584 { |
588 using command_buffer::set_blending::Enable; | |
589 using command_buffer::set_blending::SeparateAlpha; | |
590 using command_buffer::set_blending::ColorEq; | |
591 using command_buffer::set_blending::ColorSrcFunc; | |
592 using command_buffer::set_blending::ColorDstFunc; | |
593 using command_buffer::set_blending::AlphaEq; | |
594 using command_buffer::set_blending::AlphaSrcFunc; | |
595 using command_buffer::set_blending::AlphaDstFunc; | |
596 bool *dirty = blending_helper_.dirty_ptr(); | 585 bool *dirty = blending_helper_.dirty_ptr(); |
597 command_buffer::cmd::SetBlending& cmd = blending_helper_.command(); | 586 using command_buffer::cmd::SetBlending; |
| 587 SetBlending& cmd = blending_helper_.command(); |
598 renderer->AddStateHandler( | 588 renderer->AddStateHandler( |
599 State::kAlphaBlendEnableParamName, | 589 State::kAlphaBlendEnableParamName, |
600 new EnableStateHandler<Enable>(&cmd.fixme0, dirty)); | 590 new EnableStateHandler<SetBlending::Enable>(&cmd.blend_settings, dirty))
; |
601 renderer->AddStateHandler( | 591 renderer->AddStateHandler( |
602 State::kSeparateAlphaBlendEnableParamName, | 592 State::kSeparateAlphaBlendEnableParamName, |
603 new EnableStateHandler<SeparateAlpha>(&cmd.fixme0, dirty)); | 593 new EnableStateHandler<SetBlending::SeparateAlpha>(&cmd.blend_settings,
dirty)); |
604 | 594 |
605 renderer->AddStateHandler( | 595 renderer->AddStateHandler( |
606 State::kSourceBlendFunctionParamName, | 596 State::kSourceBlendFunctionParamName, |
607 new BlendFuncStateHandler<ColorSrcFunc>(&cmd.fixme0, dirty)); | 597 new BlendFuncStateHandler< |
| 598 SetBlending::ColorSrcFunc>(&cmd.blend_settings, dirty)); |
608 renderer->AddStateHandler( | 599 renderer->AddStateHandler( |
609 State::kDestinationBlendFunctionParamName, | 600 State::kDestinationBlendFunctionParamName, |
610 new BlendFuncStateHandler<ColorDstFunc>(&cmd.fixme0, dirty)); | 601 new BlendFuncStateHandler< |
| 602 SetBlending::ColorDstFunc>(&cmd.blend_settings, dirty)); |
611 renderer->AddStateHandler( | 603 renderer->AddStateHandler( |
612 State::kBlendEquationParamName, | 604 State::kBlendEquationParamName, |
613 new BlendEqStateHandler<ColorEq>(&cmd.fixme0, dirty)); | 605 new BlendEqStateHandler< |
| 606 SetBlending::ColorEq>(&cmd.blend_settings, dirty)); |
614 renderer->AddStateHandler( | 607 renderer->AddStateHandler( |
615 State::kSourceBlendAlphaFunctionParamName, | 608 State::kSourceBlendAlphaFunctionParamName, |
616 new BlendFuncStateHandler<AlphaSrcFunc>(&cmd.fixme0, dirty)); | 609 new BlendFuncStateHandler< |
| 610 SetBlending::AlphaSrcFunc>(&cmd.blend_settings, dirty)); |
617 renderer->AddStateHandler( | 611 renderer->AddStateHandler( |
618 State::kDestinationBlendAlphaFunctionParamName, | 612 State::kDestinationBlendAlphaFunctionParamName, |
619 new BlendFuncStateHandler<AlphaDstFunc>(&cmd.fixme0, dirty)); | 613 new BlendFuncStateHandler< |
| 614 SetBlending::AlphaDstFunc>(&cmd.blend_settings, dirty)); |
620 renderer->AddStateHandler( | 615 renderer->AddStateHandler( |
621 State::kBlendAlphaEquationParamName, | 616 State::kBlendAlphaEquationParamName, |
622 new BlendEqStateHandler<AlphaEq>(&cmd.fixme0, dirty)); | 617 new BlendEqStateHandler< |
| 618 SetBlending::AlphaEq>(&cmd.blend_settings, dirty)); |
623 } | 619 } |
624 | 620 |
625 // Color Write | 621 // Color Write |
626 { | 622 { |
627 using command_buffer::set_color_write::DitherEnable; | |
628 using command_buffer::set_color_write::AllColorsMask; | |
629 bool *dirty = color_write_helper_.dirty_ptr(); | 623 bool *dirty = color_write_helper_.dirty_ptr(); |
630 command_buffer::cmd::SetColorWrite& cmd = color_write_helper_.command(); | 624 using command_buffer::cmd::SetColorWrite; |
| 625 SetColorWrite& cmd = color_write_helper_.command(); |
631 renderer->AddStateHandler( | 626 renderer->AddStateHandler( |
632 State::kDitherEnableParamName, | 627 State::kDitherEnableParamName, |
633 new EnableStateHandler<DitherEnable>(&cmd.flags, dirty)); | 628 new EnableStateHandler<SetColorWrite::DitherEnable>(&cmd.flags, dirty)); |
634 renderer->AddStateHandler( | 629 renderer->AddStateHandler( |
635 State::kColorWriteEnableParamName, | 630 State::kColorWriteEnableParamName, |
636 new ColorWriteStateHandler(&cmd.flags, dirty)); | 631 new ColorWriteStateHandler(&cmd.flags, dirty)); |
637 } | 632 } |
638 } | 633 } |
639 | 634 |
640 void RendererCB::StateManager::ValidateStates(CommandBufferHelper *helper) { | 635 void RendererCB::StateManager::ValidateStates(CommandBufferHelper *helper) { |
641 point_line_helper_.Validate(helper); | 636 point_line_helper_.Validate(helper); |
642 poly_offset_helper_.Validate(helper); | 637 poly_offset_helper_.Validate(helper); |
643 poly_raster_helper_.Validate(helper); | 638 poly_raster_helper_.Validate(helper); |
644 alpha_test_helper_.Validate(helper); | 639 alpha_test_helper_.Validate(helper); |
645 depth_test_helper_.Validate(helper); | 640 depth_test_helper_.Validate(helper); |
646 stencil_test_helper_.Validate(helper); | 641 stencil_test_helper_.Validate(helper); |
647 color_write_helper_.Validate(helper); | 642 color_write_helper_.Validate(helper); |
648 blending_helper_.Validate(helper); | 643 blending_helper_.Validate(helper); |
649 } | 644 } |
650 | 645 |
651 } // namespace o3d | 646 } // namespace o3d |
OLD | NEW |