Commit 4424ffec authored by hybrid's avatar hybrid

Support new blend op from recent AMD extension. OpenGL/AMD only for now.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3679 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 1dd826da
...@@ -43,7 +43,9 @@ namespace video ...@@ -43,7 +43,9 @@ namespace video
EBO_SUBTRACT, //!< This mode subtracts the color values EBO_SUBTRACT, //!< This mode subtracts the color values
EBO_REVSUBTRACT,//!< This modes subtracts destination from source EBO_REVSUBTRACT,//!< This modes subtracts destination from source
EBO_MIN, //!< Choose minimum value of each color channel EBO_MIN, //!< Choose minimum value of each color channel
EBO_MAX //!< Choose maximum value of each color channel EBO_MAX, //!< Choose maximum value of each color channel
EBO_MIN_FACTOR, //!< Choose minimum value of each color channel after applying blend factors, not widely supported
EBO_MAX_FACTOR //!< Choose maximum value of each color channel after applying blend factors, not widely supported
}; };
//! MaterialTypeParam: e.g. DirectX: D3DTOP_MODULATE, D3DTOP_MODULATE2X, D3DTOP_MODULATE4X //! MaterialTypeParam: e.g. DirectX: D3DTOP_MODULATE, D3DTOP_MODULATE2X, D3DTOP_MODULATE4X
......
...@@ -2265,18 +2265,20 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria ...@@ -2265,18 +2265,20 @@ void CD3D9Driver::setBasicRenderStates(const SMaterial& material, const SMateria
pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
switch (material.BlendOperation) switch (material.BlendOperation)
{ {
case EBO_MAX:
pID3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_MAX);
break;
case EBO_MIN:
pID3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_MIN);
break;
case EBO_SUBTRACT: case EBO_SUBTRACT:
pID3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_SUBTRACT); pID3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_SUBTRACT);
break; break;
case EBO_REVSUBTRACT: case EBO_REVSUBTRACT:
pID3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_REVSUBTRACT); pID3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_REVSUBTRACT);
break; break;
case EBO_MIN:
case EBO_MIN_FACTOR:
pID3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_MIN);
break;
case EBO_MAX:
case EBO_MAX_FACTOR:
pID3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_MAX);
break;
default: default:
pID3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); pID3DDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
break; break;
......
...@@ -2932,32 +2932,68 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -2932,32 +2932,68 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
#if defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op) || defined(GL_VERSION_1_2) #if defined(GL_EXT_blend_subtract) || defined(GL_EXT_blend_minmax) || defined(GL_EXT_blend_logic_op) || defined(GL_VERSION_1_2)
switch (material.BlendOperation) switch (material.BlendOperation)
{ {
case EBO_MAX: case EBO_SUBTRACT:
#if defined(GL_EXT_blend_minmax) #if defined(GL_EXT_blend_subtract)
extGlBlendEquation(GL_MAX_EXT); if (FeatureAvailable[IRR_EXT_blend_subtract] || (Version>=120))
extGlBlendEquation(GL_FUNC_SUBTRACT_EXT);
#elif defined(GL_VERSION_1_2) #elif defined(GL_VERSION_1_2)
extGlBlendEquation(GL_MAX); if (Version>=120)
extGlBlendEquation(GL_FUNC_SUBTRACT);
#endif
break;
case EBO_REVSUBTRACT:
#if defined(GL_EXT_blend_subtract)
if (FeatureAvailable[IRR_EXT_blend_subtract] || (Version>=120))
extGlBlendEquation(GL_FUNC_REVERSE_SUBTRACT_EXT);
#elif defined(GL_VERSION_1_2)
if (Version>=120)
extGlBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
#endif #endif
break; break;
case EBO_MIN: case EBO_MIN:
#if defined(GL_EXT_blend_minmax) #if defined(GL_EXT_blend_minmax)
if (FeatureAvailable[IRR_EXT_blend_minmax] || (Version>=120))
extGlBlendEquation(GL_MIN_EXT); extGlBlendEquation(GL_MIN_EXT);
#elif defined(GL_VERSION_1_2) #elif defined(GL_VERSION_1_2)
if (Version>=120)
extGlBlendEquation(GL_MIN); extGlBlendEquation(GL_MIN);
#endif #endif
break; break;
case EBO_SUBTRACT: case EBO_MAX:
#if defined(GL_EXT_blend_subtract) #if defined(GL_EXT_blend_minmax)
extGlBlendEquation(GL_FUNC_SUBTRACT_EXT); if (FeatureAvailable[IRR_EXT_blend_minmax] || (Version>=120))
extGlBlendEquation(GL_MAX_EXT);
#elif defined(GL_VERSION_1_2) #elif defined(GL_VERSION_1_2)
extGlBlendEquation(GL_FUNC_SUBTRACT); if (Version>=120)
extGlBlendEquation(GL_MAX);
#endif #endif
break; break;
case EBO_REVSUBTRACT: case EBO_MIN_FACTOR:
#if defined(GL_EXT_blend_subtract) #if defined(GL_AMD_blend_minmax_factor)
extGlBlendEquation(GL_FUNC_REVERSE_SUBTRACT_EXT); if (FeatureAvailable[IRR_AMD_blend_minmax_factor])
#elif defined(GL_VERSION_1_2) extGlBlendEquation(GL_FACTOR_MIN_AMD);
extGlBlendEquation(GL_FUNC_REVERSE_SUBTRACT); #endif
// fallback in case of missing extension
#if defined(GL_VERSION_1_2)
#if defined(GL_AMD_blend_minmax_factor)
else
#endif
if (Version>=120)
extGlBlendEquation(GL_MIN);
#endif
break;
case EBO_MAX_FACTOR:
#if defined(GL_AMD_blend_minmax_factor)
if (FeatureAvailable[IRR_AMD_blend_minmax_factor])
extGlBlendEquation(GL_FACTOR_MAX_AMD);
#endif
// fallback in case of missing extension
#if defined(GL_VERSION_1_2)
#if defined(GL_AMD_blend_minmax_factor)
else
#endif
if (Version>=120)
extGlBlendEquation(GL_MAX);
#endif #endif
break; break;
default: default:
...@@ -4080,6 +4116,7 @@ bool COpenGLDriver::setRenderTarget(const core::array<video::IRenderTarget>& tar ...@@ -4080,6 +4116,7 @@ bool COpenGLDriver::setRenderTarget(const core::array<video::IRenderTarget>& tar
else else
extGlEnableIndexed(GL_BLEND, i); extGlEnableIndexed(GL_BLEND, i);
} }
#if defined(GL_AMD_draw_buffers_blend) || defined(GL_ARB_draw_buffers_blend)
if (FeatureAvailable[IRR_AMD_draw_buffers_blend] || FeatureAvailable[IRR_ARB_draw_buffers_blend]) if (FeatureAvailable[IRR_AMD_draw_buffers_blend] || FeatureAvailable[IRR_ARB_draw_buffers_blend])
{ {
extGlBlendFuncIndexed(i, getGLBlend(targets[i].BlendFuncSrc), getGLBlend(targets[i].BlendFuncDst)); extGlBlendFuncIndexed(i, getGLBlend(targets[i].BlendFuncSrc), getGLBlend(targets[i].BlendFuncDst));
...@@ -4097,11 +4134,30 @@ bool COpenGLDriver::setRenderTarget(const core::array<video::IRenderTarget>& tar ...@@ -4097,11 +4134,30 @@ bool COpenGLDriver::setRenderTarget(const core::array<video::IRenderTarget>& tar
case EBO_MAX: case EBO_MAX:
extGlBlendEquationIndexed(i, GL_MAX); extGlBlendEquationIndexed(i, GL_MAX);
break; break;
case EBO_MIN_FACTOR:
#if defined(GL_AMD_blend_minmax_factor)
if (FeatureAvailable[IRR_AMD_blend_minmax_factor])
extGlBlendEquationIndexed(i, GL_FACTOR_MIN_AMD);
// fallback in case of missing extension
else
#endif
extGlBlendEquation(GL_MIN);
break;
case EBO_MAX_FACTOR:
#if defined(GL_AMD_blend_minmax_factor)
if (FeatureAvailable[IRR_AMD_blend_minmax_factor])
extGlBlendEquationIndexed(i, GL_FACTOR_MAX_AMD);
// fallback in case of missing extension
else
#endif
extGlBlendEquation(GL_MAX);
break;
default: default:
extGlBlendEquationIndexed(i, GL_FUNC_ADD); extGlBlendEquationIndexed(i, GL_FUNC_ADD);
break; break;
} }
} }
#endif
if (targets[i].TargetType==ERT_RENDER_TEXTURE) if (targets[i].TargetType==ERT_RENDER_TEXTURE)
{ {
GLenum attachment = GL_NONE; GLenum attachment = GL_NONE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment