diff options
Diffstat (limited to 'o3d/core/cross/command_buffer/states_cb.cc')
-rw-r--r-- | o3d/core/cross/command_buffer/states_cb.cc | 245 |
1 files changed, 120 insertions, 125 deletions
diff --git a/o3d/core/cross/command_buffer/states_cb.cc b/o3d/core/cross/command_buffer/states_cb.cc index c6d4818..ab04583 100644 --- a/o3d/core/cross/command_buffer/states_cb.cc +++ b/o3d/core/cross/command_buffer/states_cb.cc @@ -42,137 +42,136 @@ namespace o3d { using command_buffer::CommandBufferEntry; using command_buffer::CommandBufferHelper; -using command_buffer::GAPIInterface; namespace { // Converts values meant to represent a Cull Mode to the corresponding // command-buffer value. // Default: CULL_NONE. -GAPIInterface::FaceCullMode CullModeToCB(int cull) { +command_buffer::FaceCullMode CullModeToCB(int cull) { switch (cull) { default: case State::CULL_NONE: - return GAPIInterface::CULL_NONE; + return command_buffer::kCullNone; case State::CULL_CW: - return GAPIInterface::CULL_CW; + return command_buffer::kCullCW; case State::CULL_CCW: - return GAPIInterface::CULL_CCW; + return command_buffer::kCullCCW; } } // Converts values meant to represent a Polygon Fill Mode to the corresponding // command-buffer value. -// Default: POLYGON_MODE_FILL. -GAPIInterface::PolygonMode FillModeToCB(int fill) { +// Default: kPolygonModeFill. +command_buffer::PolygonMode FillModeToCB(int fill) { switch (fill) { case State::POINT: - return GAPIInterface::POLYGON_MODE_POINTS; + return command_buffer::kPolygonModePoints; case State::WIREFRAME: - return GAPIInterface::POLYGON_MODE_LINES; + return command_buffer::kPolygonModeLines; default: case State::SOLID: - return GAPIInterface::POLYGON_MODE_FILL; + return command_buffer::kPolygonModeFill; } } // Converts values meant to represent a Comparison Function to the corresponding // command-buffer value. -// Default: ALWAYS. -GAPIInterface::Comparison ComparisonToCB(int comparison) { +// Default: kAlways. +command_buffer::Comparison ComparisonToCB(int comparison) { switch (comparison) { case State::CMP_NEVER: - return GAPIInterface::NEVER; + return command_buffer::kNever; case State::CMP_LESS: - return GAPIInterface::LESS; + return command_buffer::kLess; case State::CMP_EQUAL: - return GAPIInterface::EQUAL; + return command_buffer::kEqual; case State::CMP_LEQUAL: - return GAPIInterface::LEQUAL; + return command_buffer::kLEqual; case State::CMP_GREATER: - return GAPIInterface::GREATER; + return command_buffer::kGreater; case State::CMP_NOTEQUAL: - return GAPIInterface::NOT_EQUAL; + return command_buffer::kNotEqual; case State::CMP_GEQUAL: - return GAPIInterface::GEQUAL; + return command_buffer::kGEqual; case State::CMP_ALWAYS: default: - return GAPIInterface::ALWAYS; + return command_buffer::kAlways; } } // Converts values meant to represent a Stencil Operation to the corresponding // command-buffer value. -// Default: KEEP. -GAPIInterface::StencilOp StencilOpToCB(int op) { +// Default: kKeep. +command_buffer::StencilOp StencilOpToCB(int op) { switch (op) { default: case State::STENCIL_KEEP: - return GAPIInterface::KEEP; + return command_buffer::kKeep; case State::STENCIL_ZERO: - return GAPIInterface::ZERO; + return command_buffer::kZero; case State::STENCIL_REPLACE: - return GAPIInterface::REPLACE; + return command_buffer::kReplace; case State::STENCIL_INCREMENT_SATURATE: - return GAPIInterface::INC_NO_WRAP; + return command_buffer::kIncNoWrap; case State::STENCIL_DECREMENT_SATURATE: - return GAPIInterface::DEC_NO_WRAP; + return command_buffer::kDecNoWrap; case State::STENCIL_INVERT: - return GAPIInterface::INVERT; + return command_buffer::kInvert; case State::STENCIL_INCREMENT: - return GAPIInterface::INC_WRAP; + return command_buffer::kIncWrap; case State::STENCIL_DECREMENT: - return GAPIInterface::DEC_WRAP; + return command_buffer::kDecWrap; } } // Converts values meant to represent a Blending Function to the corresponding // command-buffer value. -// Default: BLEND_FUNC_ONE. -GAPIInterface::BlendFunc BlendFuncToCB(int func) { +// Default: kBlendFuncOne. +command_buffer::BlendFunc BlendFuncToCB(int func) { switch (func) { case State::BLENDFUNC_ZERO: - return GAPIInterface::BLEND_FUNC_ZERO; + return command_buffer::kBlendFuncZero; default: case State::BLENDFUNC_ONE: - return GAPIInterface::BLEND_FUNC_ONE; + return command_buffer::kBlendFuncOne; case State::BLENDFUNC_SOURCE_COLOR: - return GAPIInterface::BLEND_FUNC_SRC_COLOR; + return command_buffer::kBlendFuncSrcColor; case State::BLENDFUNC_INVERSE_SOURCE_COLOR: - return GAPIInterface::BLEND_FUNC_INV_SRC_COLOR; + return command_buffer::kBlendFuncInvSrcColor; case State::BLENDFUNC_SOURCE_ALPHA: - return GAPIInterface::BLEND_FUNC_SRC_ALPHA; + return command_buffer::kBlendFuncSrcAlpha; case State::BLENDFUNC_INVERSE_SOURCE_ALPHA: - return GAPIInterface::BLEND_FUNC_INV_SRC_ALPHA; + return command_buffer::kBlendFuncInvSrcAlpha; case State::BLENDFUNC_DESTINATION_ALPHA: - return GAPIInterface::BLEND_FUNC_DST_ALPHA; + return command_buffer::kBlendFuncDstAlpha; case State::BLENDFUNC_INVERSE_DESTINATION_ALPHA: - return GAPIInterface::BLEND_FUNC_INV_DST_ALPHA; + return command_buffer::kBlendFuncInvDstAlpha; case State::BLENDFUNC_DESTINATION_COLOR: - return GAPIInterface::BLEND_FUNC_DST_COLOR; + return command_buffer::kBlendFuncDstColor; case State::BLENDFUNC_INVERSE_DESTINATION_COLOR: - return GAPIInterface::BLEND_FUNC_INV_DST_COLOR; + return command_buffer::kBlendFuncInvDstColor; case State::BLENDFUNC_SOURCE_ALPHA_SATUTRATE: - return GAPIInterface::BLEND_FUNC_SRC_ALPHA_SATUTRATE; + return command_buffer::kBlendFuncSrcAlphaSaturate; } } // Converts values meant to represent a Blending Equation to the corresponding // command-buffer value. -// Default: BLEND_EQ_ADD. -GAPIInterface::BlendEq BlendEqToCB(int eq) { +// Default: kBlendEqAdd. +command_buffer::BlendEq BlendEqToCB(int eq) { switch (eq) { default: case State::BLEND_ADD: - return GAPIInterface::BLEND_EQ_ADD; + return command_buffer::kBlendEqAdd; case State::BLEND_SUBTRACT: - return GAPIInterface::BLEND_EQ_SUB; + return command_buffer::kBlendEqSub; case State::BLEND_REVERSE_SUBTRACT: - return GAPIInterface::BLEND_EQ_REV_SUB; + return command_buffer::kBlendEqRevSub; case State::BLEND_MIN: - return GAPIInterface::BLEND_EQ_MIN; + return command_buffer::kBlendEqMin; case State::BLEND_MAX: - return GAPIInterface::BLEND_EQ_MAX; + return command_buffer::kBlendEqMax; } } @@ -265,8 +264,9 @@ class ColorWriteStateHandler : public TypedStateHandler<ParamInteger> { virtual void SetStateFromTypedParam(RendererCB* renderer, ParamInteger* param) const { + using command_buffer::cmd::SetColorWrite; int mask = param->value(); - o3d::command_buffer::set_color_write::AllColorsMask::Set(value_, mask); + SetColorWrite::AllColorsMask::Set(value_, mask); renderer->SetWriteMask(mask); *dirty_ = true; } @@ -314,8 +314,8 @@ class CullModeStateHandler : public TypedStateHandler<ParamInteger> { virtual void SetStateFromTypedParam(RendererCB* renderer, ParamInteger* param) const { - using command_buffer::set_polygon_raster::CullMode; - CullMode::Set(value_, CullModeToCB(param->value())); + using command_buffer::cmd::SetPolygonRaster; + SetPolygonRaster::CullMode::Set(value_, CullModeToCB(param->value())); *dirty_ = true; } private: @@ -336,8 +336,8 @@ class FillModeStateHandler : public TypedStateHandler<ParamInteger> { virtual void SetStateFromTypedParam(RendererCB* renderer, ParamInteger* param) const { - using command_buffer::set_polygon_raster::FillMode; - FillMode::Set(value_, FillModeToCB(param->value())); + using command_buffer::cmd::SetPolygonRaster; + SetPolygonRaster::FillMode::Set(value_, FillModeToCB(param->value())); *dirty_ = true; } private: @@ -447,17 +447,17 @@ class BlendEqStateHandler : public TypedStateHandler<ParamInteger> { void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) { // Point/Line raster { - using command_buffer::set_point_line_raster::LineSmoothEnable; - using command_buffer::set_point_line_raster::PointSpriteEnable; bool *dirty = point_line_helper_.dirty_ptr(); - command_buffer::cmd::SetPointLineRaster& cmd = - point_line_helper_.command(); + using command_buffer::cmd::SetPointLineRaster; + SetPointLineRaster& cmd = point_line_helper_.command(); renderer->AddStateHandler( State::kLineSmoothEnableParamName, - new EnableStateHandler<LineSmoothEnable>(&cmd.fixme0, dirty)); + new EnableStateHandler< + SetPointLineRaster::LineSmoothEnable>(&cmd.enables, dirty)); renderer->AddStateHandler( State::kPointSpriteEnableParamName, - new EnableStateHandler<PointSpriteEnable>(&cmd.fixme0, dirty)); + new EnableStateHandler< + SetPointLineRaster::PointSpriteEnable>(&cmd.enables, dirty)); renderer->AddStateHandler(State::kPointSizeParamName, new ValueStateHandler<ParamFloat>( &cmd.point_size, dirty)); @@ -466,12 +466,12 @@ void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) { // Polygon Raster { bool *dirty = poly_raster_helper_.dirty_ptr(); - command_buffer::cmd::SetPolygonRaster& cmd = - poly_raster_helper_.command(); + using command_buffer::cmd::SetPolygonRaster; + SetPolygonRaster& cmd = poly_raster_helper_.command(); renderer->AddStateHandler(State::kCullModeParamName, - new CullModeStateHandler(&cmd.fixme0, dirty)); + new CullModeStateHandler(&cmd.fill_cull, dirty)); renderer->AddStateHandler(State::kFillModeParamName, - new FillModeStateHandler(&cmd.fixme0, dirty)); + new FillModeStateHandler(&cmd.fill_cull, dirty)); } // Polygon Offset @@ -489,16 +489,15 @@ void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) { // Alpha test { - using command_buffer::set_alpha_test::Enable; - using command_buffer::set_alpha_test::Func; - command_buffer::cmd::SetAlphaTest& cmd = alpha_test_helper_.command(); + using command_buffer::cmd::SetAlphaTest; + SetAlphaTest& cmd = alpha_test_helper_.command(); bool *dirty = alpha_test_helper_.dirty_ptr(); renderer->AddStateHandler( State::kAlphaTestEnableParamName, - new EnableStateHandler<Enable>(&cmd.fixme0, dirty)); + new EnableStateHandler<SetAlphaTest::Enable>(&cmd.func_enable, dirty)); renderer->AddStateHandler( State::kAlphaComparisonFunctionParamName, - new ComparisonStateHandler<Func>(&cmd.fixme0, dirty)); + new ComparisonStateHandler<SetAlphaTest::Func>(&cmd.func_enable, dirty)); renderer->AddStateHandler( State::kAlphaReferenceParamName, new ValueStateHandler<ParamFloat>(&cmd.value, dirty)); @@ -506,131 +505,127 @@ void RendererCB::StateManager::AddStateHandlers(RendererCB *renderer) { // Depth Test { - using command_buffer::set_depth_test::Enable; - using command_buffer::set_depth_test::WriteEnable; - using command_buffer::set_depth_test::Func; bool *dirty = depth_test_helper_.dirty_ptr(); - command_buffer::cmd::SetDepthTest& cmd = depth_test_helper_.command(); + using command_buffer::cmd::SetDepthTest; + SetDepthTest& cmd = depth_test_helper_.command(); renderer->AddStateHandler( State::kZWriteEnableParamName, - new EnableStateHandler<WriteEnable>(&cmd.fixme0, dirty)); + new EnableStateHandler<SetDepthTest::WriteEnable>(&cmd.func_enable, dirty)); renderer->AddStateHandler( State::kZEnableParamName, - new EnableStateHandler<Enable>(&cmd.fixme0, dirty)); + new EnableStateHandler<SetDepthTest::Enable>(&cmd.func_enable, dirty)); renderer->AddStateHandler( State::kZComparisonFunctionParamName, - new ComparisonStateHandler<Func>(&cmd.fixme0, dirty)); + new ComparisonStateHandler<SetDepthTest::Func>(&cmd.func_enable, dirty)); } // Stencil Test { - using command_buffer::set_stencil_test::Enable; - using command_buffer::set_stencil_test::SeparateCCW; - using command_buffer::set_stencil_test::WriteMask; - using command_buffer::set_stencil_test::CompareMask; - using command_buffer::set_stencil_test::ReferenceValue; - using command_buffer::set_stencil_test::CWFunc; - using command_buffer::set_stencil_test::CWPassOp; - using command_buffer::set_stencil_test::CWFailOp; - using command_buffer::set_stencil_test::CWZFailOp; - using command_buffer::set_stencil_test::CCWFunc; - using command_buffer::set_stencil_test::CCWPassOp; - using command_buffer::set_stencil_test::CCWFailOp; - using command_buffer::set_stencil_test::CCWZFailOp; bool *dirty = stencil_test_helper_.dirty_ptr(); - command_buffer::cmd::SetStencilTest& cmd = stencil_test_helper_.command(); + using command_buffer::cmd::SetStencilTest; + SetStencilTest& cmd = stencil_test_helper_.command(); renderer->AddStateHandler( State::kStencilEnableParamName, - new EnableStateHandler<Enable>(&cmd.fixme0, dirty)); + new EnableStateHandler<SetStencilTest::Enable>(&cmd.stencil_args0, dirty)); renderer->AddStateHandler( State::kTwoSidedStencilEnableParamName, - new EnableStateHandler<SeparateCCW>(&cmd.fixme0, dirty)); + new EnableStateHandler< + SetStencilTest::SeparateCCW>(&cmd.stencil_args0, dirty)); renderer->AddStateHandler( State::kStencilReferenceParamName, - new BitFieldStateHandler<ReferenceValue>(&cmd.fixme0, dirty)); + new BitFieldStateHandler< + SetStencilTest::ReferenceValue>(&cmd.stencil_args0, dirty)); renderer->AddStateHandler( State::kStencilMaskParamName, - new BitFieldStateHandler<CompareMask>(&cmd.fixme0, dirty)); + new BitFieldStateHandler< + SetStencilTest::CompareMask>(&cmd.stencil_args0, dirty)); renderer->AddStateHandler( State::kStencilWriteMaskParamName, - new BitFieldStateHandler<WriteMask>(&cmd.fixme0, dirty)); + new BitFieldStateHandler< + SetStencilTest::WriteMask>(&cmd.stencil_args0, dirty)); renderer->AddStateHandler( State::kStencilComparisonFunctionParamName, - new ComparisonStateHandler<CWFunc>(&cmd.fixme1, dirty)); + new ComparisonStateHandler< + SetStencilTest::CWFunc>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kStencilPassOperationParamName, - new StencilOpStateHandler<CWPassOp>(&cmd.fixme1, dirty)); + new StencilOpStateHandler< + SetStencilTest::CWPassOp>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kStencilFailOperationParamName, - new StencilOpStateHandler<CWFailOp>(&cmd.fixme1, dirty)); + new StencilOpStateHandler< + SetStencilTest::CWFailOp>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kStencilZFailOperationParamName, - new StencilOpStateHandler<CWZFailOp>(&cmd.fixme1, dirty)); + new StencilOpStateHandler< + SetStencilTest::CWZFailOp>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kCCWStencilComparisonFunctionParamName, - new ComparisonStateHandler<CCWFunc>(&cmd.fixme1, dirty)); + new ComparisonStateHandler< + SetStencilTest::CCWFunc>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kCCWStencilPassOperationParamName, - new StencilOpStateHandler<CCWPassOp>(&cmd.fixme1, dirty)); + new StencilOpStateHandler< + SetStencilTest::CCWPassOp>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kCCWStencilFailOperationParamName, - new StencilOpStateHandler<CCWFailOp>(&cmd.fixme1, dirty)); + new StencilOpStateHandler< + SetStencilTest::CCWFailOp>(&cmd.stencil_args1, dirty)); renderer->AddStateHandler( State::kCCWStencilZFailOperationParamName, - new StencilOpStateHandler<CCWZFailOp>(&cmd.fixme1, dirty)); + new StencilOpStateHandler< + SetStencilTest::CCWZFailOp>(&cmd.stencil_args1, dirty)); } // Blending { - using command_buffer::set_blending::Enable; - using command_buffer::set_blending::SeparateAlpha; - using command_buffer::set_blending::ColorEq; - using command_buffer::set_blending::ColorSrcFunc; - using command_buffer::set_blending::ColorDstFunc; - using command_buffer::set_blending::AlphaEq; - using command_buffer::set_blending::AlphaSrcFunc; - using command_buffer::set_blending::AlphaDstFunc; bool *dirty = blending_helper_.dirty_ptr(); - command_buffer::cmd::SetBlending& cmd = blending_helper_.command(); + using command_buffer::cmd::SetBlending; + SetBlending& cmd = blending_helper_.command(); renderer->AddStateHandler( State::kAlphaBlendEnableParamName, - new EnableStateHandler<Enable>(&cmd.fixme0, dirty)); + new EnableStateHandler<SetBlending::Enable>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kSeparateAlphaBlendEnableParamName, - new EnableStateHandler<SeparateAlpha>(&cmd.fixme0, dirty)); + new EnableStateHandler<SetBlending::SeparateAlpha>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kSourceBlendFunctionParamName, - new BlendFuncStateHandler<ColorSrcFunc>(&cmd.fixme0, dirty)); + new BlendFuncStateHandler< + SetBlending::ColorSrcFunc>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kDestinationBlendFunctionParamName, - new BlendFuncStateHandler<ColorDstFunc>(&cmd.fixme0, dirty)); + new BlendFuncStateHandler< + SetBlending::ColorDstFunc>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kBlendEquationParamName, - new BlendEqStateHandler<ColorEq>(&cmd.fixme0, dirty)); + new BlendEqStateHandler< + SetBlending::ColorEq>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kSourceBlendAlphaFunctionParamName, - new BlendFuncStateHandler<AlphaSrcFunc>(&cmd.fixme0, dirty)); + new BlendFuncStateHandler< + SetBlending::AlphaSrcFunc>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kDestinationBlendAlphaFunctionParamName, - new BlendFuncStateHandler<AlphaDstFunc>(&cmd.fixme0, dirty)); + new BlendFuncStateHandler< + SetBlending::AlphaDstFunc>(&cmd.blend_settings, dirty)); renderer->AddStateHandler( State::kBlendAlphaEquationParamName, - new BlendEqStateHandler<AlphaEq>(&cmd.fixme0, dirty)); + new BlendEqStateHandler< + SetBlending::AlphaEq>(&cmd.blend_settings, dirty)); } // Color Write { - using command_buffer::set_color_write::DitherEnable; - using command_buffer::set_color_write::AllColorsMask; bool *dirty = color_write_helper_.dirty_ptr(); - command_buffer::cmd::SetColorWrite& cmd = color_write_helper_.command(); + using command_buffer::cmd::SetColorWrite; + SetColorWrite& cmd = color_write_helper_.command(); renderer->AddStateHandler( State::kDitherEnableParamName, - new EnableStateHandler<DitherEnable>(&cmd.flags, dirty)); + new EnableStateHandler<SetColorWrite::DitherEnable>(&cmd.flags, dirty)); renderer->AddStateHandler( State::kColorWriteEnableParamName, new ColorWriteStateHandler(&cmd.flags, dirty)); |