mirror of https://github.com/bkaradzic/bgfx
Added support for independent RGB channel write control.
This commit is contained in:
parent
bee9ebc414
commit
584b8b34f0
|
@ -1,3 +1,22 @@
|
|||
#if defined(__GNUC__) || defined(__clang__)
|
||||
# if defined(__has_warning)
|
||||
# define STB_HAS_WARNING __has_warning
|
||||
# else
|
||||
# define STB_HAS_WARNING(w) 1
|
||||
# endif
|
||||
# if defined(__clang__)
|
||||
# pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
# endif // defined(__clang__)
|
||||
# pragma GCC diagnostic ignored "-Wtype-limits"
|
||||
# pragma GCC diagnostic ignored "-Wunused-function"
|
||||
# pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
# if STB_HAS_WARNING("-Wunused-but-set-variable")
|
||||
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
# endif
|
||||
#else
|
||||
# pragma warning(disable:4100) // C4100: 'c': unreferenced formal parameter
|
||||
#endif
|
||||
|
||||
// stb_rect_pack.h - v0.11 - public domain - rectangle packing
|
||||
// Sean Barrett 2014
|
||||
//
|
||||
|
|
|
@ -80,6 +80,10 @@ class ExampleCubes : public entry::AppI
|
|||
public:
|
||||
ExampleCubes(const char* _name, const char* _description)
|
||||
: entry::AppI(_name, _description)
|
||||
, m_r(true)
|
||||
, m_g(true)
|
||||
, m_b(true)
|
||||
, m_a(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -163,6 +167,27 @@ public:
|
|||
|
||||
showExampleDialog(this);
|
||||
|
||||
ImGui::SetNextWindowPos(
|
||||
ImVec2(m_width - m_width / 5.0f - 10.0f, 10.0f)
|
||||
, ImGuiCond_FirstUseEver
|
||||
);
|
||||
ImGui::SetNextWindowSize(
|
||||
ImVec2(m_width / 5.0f, m_height / 2.0f)
|
||||
, ImGuiCond_FirstUseEver
|
||||
);
|
||||
ImGui::Begin("Settings"
|
||||
, NULL
|
||||
, 0
|
||||
);
|
||||
|
||||
ImGui::Checkbox("Write R", &m_r);
|
||||
ImGui::Checkbox("Write G", &m_g);
|
||||
ImGui::Checkbox("Write B", &m_b);
|
||||
ImGui::Checkbox("Write A", &m_a);
|
||||
|
||||
ImGui::End();
|
||||
|
||||
|
||||
imguiEndFrame();
|
||||
|
||||
float time = (float)( (bx::getHPCounter()-m_timeOffset)/double(bx::getHPFrequency() ) );
|
||||
|
@ -221,7 +246,14 @@ public:
|
|||
|
||||
// Set render states.
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_DEFAULT
|
||||
| (m_r ? BGFX_STATE_WRITE_R : 0)
|
||||
| (m_g ? BGFX_STATE_WRITE_G : 0)
|
||||
| (m_b ? BGFX_STATE_WRITE_B : 0)
|
||||
| (m_a ? BGFX_STATE_WRITE_A : 0)
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_MSAA
|
||||
| BGFX_STATE_PT_TRISTRIP
|
||||
);
|
||||
|
||||
|
@ -250,6 +282,11 @@ public:
|
|||
bgfx::IndexBufferHandle m_ibh;
|
||||
bgfx::ProgramHandle m_program;
|
||||
int64_t m_timeOffset;
|
||||
|
||||
bool m_r;
|
||||
bool m_g;
|
||||
bool m_b;
|
||||
bool m_a;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -296,9 +296,9 @@ public:
|
|||
|
||||
// Set render states.
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_MSAA
|
||||
);
|
||||
|
@ -333,9 +333,9 @@ public:
|
|||
|
||||
// Set render states.
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_MSAA
|
||||
);
|
||||
|
|
|
@ -487,7 +487,7 @@ public:
|
|||
|
||||
// Render skybox into view hdrSkybox.
|
||||
bgfx::setTexture(0, s_texCube, m_uffizi);
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
bgfx::setUniform(u_mtx, mtx);
|
||||
screenSpaceQuad( (float)m_width, (float)m_height, true);
|
||||
bgfx::submit(hdrSkybox, m_skyProgram);
|
||||
|
@ -500,35 +500,35 @@ public:
|
|||
// Calculate luminance.
|
||||
setOffsets2x2Lum(u_offset, 128, 128);
|
||||
bgfx::setTexture(0, s_texColor, m_fbtextures[0]);
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad(128.0f, 128.0f, m_caps->originBottomLeft);
|
||||
bgfx::submit(hdrLuminance, m_lumProgram);
|
||||
|
||||
// Downscale luminance 0.
|
||||
setOffsets4x4Lum(u_offset, 128, 128);
|
||||
bgfx::setTexture(0, s_texColor, bgfx::getTexture(m_lum[0]) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad(64.0f, 64.0f, m_caps->originBottomLeft);
|
||||
bgfx::submit(hdrLumScale0, m_lumAvgProgram);
|
||||
|
||||
// Downscale luminance 1.
|
||||
setOffsets4x4Lum(u_offset, 64, 64);
|
||||
bgfx::setTexture(0, s_texColor, bgfx::getTexture(m_lum[1]) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad(16.0f, 16.0f, m_caps->originBottomLeft);
|
||||
bgfx::submit(hdrLumScale1, m_lumAvgProgram);
|
||||
|
||||
// Downscale luminance 2.
|
||||
setOffsets4x4Lum(u_offset, 16, 16);
|
||||
bgfx::setTexture(0, s_texColor, bgfx::getTexture(m_lum[2]) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad(4.0f, 4.0f, m_caps->originBottomLeft);
|
||||
bgfx::submit(hdrLumScale2, m_lumAvgProgram);
|
||||
|
||||
// Downscale luminance 3.
|
||||
setOffsets4x4Lum(u_offset, 4, 4);
|
||||
bgfx::setTexture(0, s_texColor, bgfx::getTexture(m_lum[3]) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad(1.0f, 1.0f, m_caps->originBottomLeft);
|
||||
bgfx::submit(hdrLumScale3, m_lumAvgProgram);
|
||||
|
||||
|
@ -536,14 +536,14 @@ public:
|
|||
setOffsets4x4Lum(u_offset, m_width/2, m_height/2);
|
||||
bgfx::setTexture(0, s_texColor, m_fbtextures[0]);
|
||||
bgfx::setTexture(1, s_texLum, bgfx::getTexture(m_lum[4]) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
bgfx::setUniform(u_tonemap, tonemap);
|
||||
screenSpaceQuad( (float)m_width/2.0f, (float)m_height/2.0f, m_caps->originBottomLeft);
|
||||
bgfx::submit(hdrBrightness, m_brightProgram);
|
||||
|
||||
// m_blur m_bright pass vertically.
|
||||
bgfx::setTexture(0, s_texColor, bgfx::getTexture(m_bright) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
bgfx::setUniform(u_tonemap, tonemap);
|
||||
screenSpaceQuad( (float)m_width/8.0f, (float)m_height/8.0f, m_caps->originBottomLeft);
|
||||
bgfx::submit(hdrVBlur, m_blurProgram);
|
||||
|
@ -552,7 +552,7 @@ public:
|
|||
bgfx::setTexture(0, s_texColor, m_fbtextures[0]);
|
||||
bgfx::setTexture(1, s_texLum, bgfx::getTexture(m_lum[4]) );
|
||||
bgfx::setTexture(2, s_texBlur, bgfx::getTexture(m_blur) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad( (float)m_width, (float)m_height, m_caps->originBottomLeft);
|
||||
bgfx::submit(hdrHBlurTonemap, m_tonemapProgram);
|
||||
|
||||
|
|
|
@ -219,8 +219,8 @@ public:
|
|||
stippleInv[2] = (float(m_transitionFrame)*4.0f/255.0f) - (1.0f/255.0f);
|
||||
|
||||
const uint64_t stateTransparent = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
|
|
@ -401,8 +401,8 @@ struct RenderState
|
|||
static RenderState s_renderStates[RenderState::Count] =
|
||||
{
|
||||
{ // StencilReflection_CraftStencil
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_MSAA
|
||||
, UINT32_MAX
|
||||
|
@ -415,10 +415,10 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // StencilReflection_DrawReflected
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CW //reflection matrix has inverted normals. using CCW instead of CW.
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -432,8 +432,8 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // StencilReflection_BlendPlane
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_SRC_COLOR)
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
|
@ -443,8 +443,8 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // StencilReflection_DrawScene
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -453,8 +453,8 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // ProjectionShadows_DrawAmbient
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE // write depth !
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_Z // write depth !
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -475,7 +475,7 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // ProjectionShadows_DrawDiffuse
|
||||
BGFX_STATE_RGB_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE)
|
||||
| BGFX_STATE_DEPTH_TEST_EQUAL
|
||||
| BGFX_STATE_CULL_CCW
|
||||
|
@ -490,9 +490,9 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // Custom_BlendLightTexture
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_COLOR, BGFX_STATE_BLEND_INV_SRC_COLOR)
|
||||
| BGFX_STATE_CULL_CCW
|
||||
|
@ -502,7 +502,7 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // Custom_DrawPlaneBottom
|
||||
BGFX_STATE_RGB_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_MSAA
|
||||
, UINT32_MAX
|
||||
|
|
|
@ -365,9 +365,9 @@ static void setRenderState(const RenderState& _renderState)
|
|||
static RenderState s_renderStates[RenderState::Count] =
|
||||
{
|
||||
{ // ShadowVolume_UsingStencilTexture_DrawAmbient
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -376,7 +376,7 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // ShadowVolume_UsingStencilTexture_BuildDepth
|
||||
BGFX_STATE_DEPTH_WRITE
|
||||
BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -385,8 +385,8 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // ShadowVolume_UsingStencilTexture_CraftStencil_DepthPass
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE)
|
||||
| BGFX_STATE_DEPTH_TEST_LEQUAL
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -395,8 +395,8 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // ShadowVolume_UsingStencilTexture_CraftStencil_DepthFail
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE)
|
||||
| BGFX_STATE_DEPTH_TEST_GEQUAL
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -405,10 +405,10 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // ShadowVolume_UsingStencilTexture_DrawDiffuse
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE)
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_EQUAL
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -417,9 +417,9 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // ShadowVolume_UsingStencilBuffer_DrawAmbient
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -462,8 +462,8 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
| BGFX_STENCIL_OP_PASS_Z_KEEP
|
||||
},
|
||||
{ // ShadowVolume_UsingStencilBuffer_DrawDiffuse
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE)
|
||||
| BGFX_STATE_DEPTH_TEST_EQUAL
|
||||
| BGFX_STATE_CULL_CCW
|
||||
|
@ -478,9 +478,9 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // Custom_Default
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -489,9 +489,9 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // Custom_BlendLightTexture
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_COLOR, BGFX_STATE_BLEND_INV_SRC_COLOR)
|
||||
| BGFX_STATE_CULL_CCW
|
||||
|
@ -501,9 +501,9 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // Custom_DrawPlaneBottom
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_MSAA
|
||||
, UINT32_MAX
|
||||
|
@ -511,7 +511,7 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // Custom_DrawShadowVolume_Lines
|
||||
BGFX_STATE_RGB_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_FACTOR, BGFX_STATE_BLEND_SRC_ALPHA)
|
||||
| BGFX_STATE_PT_LINES
|
||||
|
|
|
@ -179,9 +179,9 @@ public:
|
|||
|
||||
m_state[0] = meshStateCreate();
|
||||
m_state[0]->m_state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -192,9 +192,9 @@ public:
|
|||
|
||||
m_state[1] = meshStateCreate();
|
||||
m_state[1]->m_state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
|
|
@ -647,10 +647,10 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
{
|
||||
{ // Default
|
||||
0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
, UINT32_MAX
|
||||
|
@ -659,9 +659,9 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
},
|
||||
{ // ShadowMap_PackDepth
|
||||
0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -671,9 +671,9 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
},
|
||||
{ // ShadowMap_PackDepthHoriz
|
||||
0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -688,9 +688,9 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
},
|
||||
{ // ShadowMap_PackDepthVert
|
||||
0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
@ -704,9 +704,9 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // Custom_BlendLightTexture
|
||||
BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_COLOR, BGFX_STATE_BLEND_INV_SRC_COLOR)
|
||||
| BGFX_STATE_CULL_CCW
|
||||
|
@ -716,7 +716,7 @@ static RenderState s_renderStates[RenderState::Count] =
|
|||
, BGFX_STENCIL_NONE
|
||||
},
|
||||
{ // Custom_DrawPlaneBottom
|
||||
BGFX_STATE_RGB_WRITE
|
||||
BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_MSAA
|
||||
, UINT32_MAX
|
||||
|
@ -2894,12 +2894,12 @@ public:
|
|||
&& currentSmSettings->m_doBlur)
|
||||
{
|
||||
bgfx::setTexture(4, s_shadowMap[0], bgfx::getTexture(s_rtShadowMap[0]) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad(currentShadowMapSizef, currentShadowMapSizef, s_flipV);
|
||||
bgfx::submit(RENDERVIEW_VBLUR_0_ID, s_programs.m_vBlur[depthType]);
|
||||
|
||||
bgfx::setTexture(4, s_shadowMap[0], bgfx::getTexture(s_rtBlur) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad(currentShadowMapSizef, currentShadowMapSizef, s_flipV);
|
||||
bgfx::submit(RENDERVIEW_HBLUR_0_ID, s_programs.m_hBlur[depthType]);
|
||||
|
||||
|
@ -2910,12 +2910,12 @@ public:
|
|||
const uint8_t viewId = RENDERVIEW_VBLUR_0_ID + jj;
|
||||
|
||||
bgfx::setTexture(4, s_shadowMap[0], bgfx::getTexture(s_rtShadowMap[ii]) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad(currentShadowMapSizef, currentShadowMapSizef, s_flipV);
|
||||
bgfx::submit(viewId, s_programs.m_vBlur[depthType]);
|
||||
|
||||
bgfx::setTexture(4, s_shadowMap[0], bgfx::getTexture(s_rtBlur) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad(currentShadowMapSizef, currentShadowMapSizef, s_flipV);
|
||||
bgfx::submit(viewId+1, s_programs.m_hBlur[depthType]);
|
||||
}
|
||||
|
@ -3150,7 +3150,7 @@ public:
|
|||
if (m_settings.m_drawDepthBuffer)
|
||||
{
|
||||
bgfx::setTexture(4, s_shadowMap[0], bgfx::getTexture(s_rtShadowMap[0]) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad(currentShadowMapSizef, currentShadowMapSizef, s_flipV);
|
||||
bgfx::submit(RENDERVIEW_DRAWDEPTH_0_ID, s_programs.m_drawDepth[depthType]);
|
||||
|
||||
|
@ -3159,7 +3159,7 @@ public:
|
|||
for (uint8_t ii = 1; ii < m_settings.m_numSplits; ++ii)
|
||||
{
|
||||
bgfx::setTexture(4, s_shadowMap[0], bgfx::getTexture(s_rtShadowMap[ii]) );
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad(currentShadowMapSizef, currentShadowMapSizef, s_flipV);
|
||||
bgfx::submit(RENDERVIEW_DRAWDEPTH_0_ID+ii, s_programs.m_drawDepth[depthType]);
|
||||
}
|
||||
|
|
|
@ -842,7 +842,7 @@ public:
|
|||
// Submit view 0.
|
||||
bgfx::setTexture(0, s_texCube, m_lightProbes[m_currentLightProbe].m_tex);
|
||||
bgfx::setTexture(1, s_texCubeIrr, m_lightProbes[m_currentLightProbe].m_texIrr);
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A);
|
||||
screenSpaceQuad( (float)m_width, (float)m_height, true);
|
||||
m_uniforms.submit();
|
||||
bgfx::submit(0, m_programSky);
|
||||
|
|
|
@ -424,16 +424,16 @@ public:
|
|||
|
||||
const uint64_t state = 0
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_MSAA
|
||||
;
|
||||
|
||||
const uint64_t stateNoDepth = 0
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_DEPTH_TEST_ALWAYS
|
||||
| BGFX_STATE_MSAA
|
||||
;
|
||||
|
@ -486,7 +486,7 @@ public:
|
|||
bgfx::setTexture(0, s_texColor0, m_fbtextures[0]);
|
||||
bgfx::setTexture(1, s_texColor1, m_fbtextures[1]);
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_INV_SRC_ALPHA, BGFX_STATE_BLEND_SRC_ALPHA)
|
||||
);
|
||||
screenSpaceQuad( (float)m_width, (float)m_height, s_flipV);
|
||||
|
|
|
@ -531,9 +531,9 @@ public:
|
|||
|
||||
// Set render states.
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_MSAA
|
||||
);
|
||||
|
@ -640,7 +640,7 @@ public:
|
|||
bgfx::setVertexBuffer(0, &tvb);
|
||||
bgfx::setIndexBuffer(&tib);
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_PT_LINES
|
||||
| BGFX_STATE_BLEND_ALPHA
|
||||
);
|
||||
|
@ -666,8 +666,8 @@ public:
|
|||
bgfx::setTexture(0, s_normal, bgfx::getTexture(m_gbuffer, 1) );
|
||||
bgfx::setTexture(1, s_depth, bgfx::getTexture(m_gbuffer, 2) );
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_ADD
|
||||
);
|
||||
screenSpaceQuad( (float)m_width, (float)m_height, s_texelHalf, m_caps->originBottomLeft);
|
||||
|
@ -679,8 +679,8 @@ public:
|
|||
bgfx::setTexture(0, s_albedo, bgfx::getTexture(m_gbuffer, 0) );
|
||||
bgfx::setTexture(1, s_light, bgfx::getTexture(m_lightBuffer, 0) );
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
);
|
||||
screenSpaceQuad( (float)m_width, (float)m_height, s_texelHalf, m_caps->originBottomLeft);
|
||||
bgfx::submit(RENDER_PASS_COMBINE_ID, m_combineProgram);
|
||||
|
@ -703,7 +703,7 @@ public:
|
|||
bgfx::setVertexBuffer(0, m_vbh);
|
||||
bgfx::setIndexBuffer(m_ibh, 0, 6);
|
||||
bgfx::setTexture(0, s_texColor, m_gbufferTex[ii]);
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB);
|
||||
bgfx::submit(RENDER_PASS_DEBUG_GBUFFER_ID, m_debugProgram);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,8 +198,8 @@ void VectorDisplay::endFrame()
|
|||
bgfx::setVertexBuffer(0, m_vertexBuffers[i], 0, m_vertexBuffersSize[i]); // explicitly feed vertex number!
|
||||
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_DST_ALPHA)
|
||||
| BGFX_STATE_BLEND_EQUATION_SEPARATE(BGFX_STATE_BLEND_EQUATION_ADD, BGFX_STATE_BLEND_EQUATION_MAX)
|
||||
);
|
||||
|
@ -229,8 +229,8 @@ void VectorDisplay::endFrame()
|
|||
bgfx::setViewFrameBuffer(viewCounter, m_glow0FrameBuffer);
|
||||
bgfx::setViewRect(viewCounter, 0, 0, m_glowWidth, m_glowHeight);
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
);
|
||||
params[0] = 1.0f / m_glowWidth;
|
||||
params[1] = 0.0f;
|
||||
|
@ -257,8 +257,8 @@ void VectorDisplay::endFrame()
|
|||
bgfx::setUniform(u_params, params);
|
||||
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
);
|
||||
|
||||
bgfx::setViewName(viewCounter, "BlendPassB");
|
||||
|
@ -278,8 +278,8 @@ void VectorDisplay::endFrame()
|
|||
bgfx::setViewRect(viewCounter, 0, 0, m_screenWidth, m_screenHeight);
|
||||
bgfx::setTexture(0, s_texColor, bgfx::getTexture(m_sceneFrameBuffer) );
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE)
|
||||
);
|
||||
|
||||
|
@ -298,8 +298,8 @@ void VectorDisplay::endFrame()
|
|||
bgfx::setViewRect(viewCounter, 0, 0, m_screenWidth, m_screenHeight);
|
||||
bgfx::setTexture(0, s_texColor, bgfx::getTexture(m_glow1FrameBuffer) );
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_ONE, BGFX_STATE_BLEND_ONE)
|
||||
);
|
||||
|
||||
|
|
|
@ -420,7 +420,7 @@ public:
|
|||
|
||||
// Set render states.
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_BLEND_ADD
|
||||
| BGFX_STATE_DEPTH_TEST_ALWAYS
|
||||
);
|
||||
|
|
|
@ -475,9 +475,9 @@ public:
|
|||
if (DrawMode::Wireframe == m_drawMode)
|
||||
{
|
||||
uint64_t state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
|
||||
|
@ -487,10 +487,10 @@ public:
|
|||
else
|
||||
{
|
||||
uint64_t state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
;
|
||||
|
|
|
@ -525,9 +525,9 @@ public:
|
|||
bgfx::setUniform(u_sphereInfo, sphereInfo);
|
||||
|
||||
const uint64_t lightDrawState = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_BLEND_ADD // <=== Overlapping lights contribute more
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_CULL_CW // <=== If we go into the lights, there will be problems, so we draw the far back face.
|
||||
;
|
||||
|
||||
|
@ -565,8 +565,8 @@ public:
|
|||
// Set up state for combine pass
|
||||
// point of this is to avoid doing depth test, which is in the default state
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
);
|
||||
|
||||
// Set up transform matrix for fullscreen quad
|
||||
|
|
|
@ -345,9 +345,9 @@ public:
|
|||
|
||||
// Set render states.
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_MSAA
|
||||
);
|
||||
|
|
|
@ -393,7 +393,7 @@ namespace
|
|||
|
||||
void draw()
|
||||
{
|
||||
bgfx::setState(BGFX_STATE_RGB_WRITE | BGFX_STATE_DEPTH_TEST_EQUAL);
|
||||
bgfx::setState(BGFX_STATE_WRITE_RGB | BGFX_STATE_DEPTH_TEST_EQUAL);
|
||||
bgfx::setIndexBuffer(m_ibh);
|
||||
bgfx::setVertexBuffer(0, m_vbh);
|
||||
bgfx::submit(0, m_preventBanding ? m_skyProgram_colorBandingFix : m_skyProgram);
|
||||
|
|
|
@ -552,9 +552,9 @@ struct Mesh
|
|||
if (BGFX_STATE_MASK == _state)
|
||||
{
|
||||
_state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CCW
|
||||
| BGFX_STATE_MSAA
|
||||
|
|
|
@ -932,10 +932,10 @@ struct DebugDraw
|
|||
|
||||
Attrib& attrib = m_attrib[0];
|
||||
attrib.m_state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| (m_depthTestLess ? BGFX_STATE_DEPTH_TEST_LESS : BGFX_STATE_DEPTH_TEST_GREATER)
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_Z
|
||||
;
|
||||
attrib.m_scale = 1.0f;
|
||||
attrib.m_spin = 0.0f;
|
||||
|
@ -1068,7 +1068,7 @@ struct DebugDraw
|
|||
|
||||
uint64_t state = m_attrib[m_stack].m_state & ~(0
|
||||
| BGFX_STATE_DEPTH_TEST_MASK
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_CULL_CCW
|
||||
);
|
||||
|
@ -1079,7 +1079,7 @@ struct DebugDraw
|
|||
;
|
||||
|
||||
state |= _depthWrite
|
||||
? BGFX_STATE_DEPTH_WRITE
|
||||
? BGFX_STATE_WRITE_Z
|
||||
: 0
|
||||
;
|
||||
|
||||
|
@ -2131,7 +2131,7 @@ private:
|
|||
bgfx::setVertexBuffer(0, &tvb);
|
||||
bgfx::setIndexBuffer(&tib);
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_PT_LINES
|
||||
| attrib.m_state
|
||||
| BGFX_STATE_LINEAA
|
||||
|
|
|
@ -700,7 +700,7 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, bgfx::ViewId
|
|||
case FONT_TYPE_ALPHA:
|
||||
program = m_basicProgram;
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
|
||||
);
|
||||
break;
|
||||
|
@ -708,7 +708,7 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, bgfx::ViewId
|
|||
case FONT_TYPE_DISTANCE:
|
||||
program = m_distanceProgram;
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
|
||||
);
|
||||
break;
|
||||
|
@ -716,7 +716,7 @@ void TextBufferManager::submitTextBuffer(TextBufferHandle _handle, bgfx::ViewId
|
|||
case FONT_TYPE_DISTANCE_SUBPIXEL:
|
||||
program = m_distanceSubpixelProgram;
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_FACTOR, BGFX_STATE_BLEND_INV_SRC_COLOR)
|
||||
, bc.textBuffer->getTextColor()
|
||||
);
|
||||
|
|
|
@ -146,8 +146,8 @@ struct OcornutImguiContext
|
|||
else if (0 != cmd->ElemCount)
|
||||
{
|
||||
uint64_t state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_MSAA
|
||||
;
|
||||
|
||||
|
|
|
@ -777,8 +777,8 @@ namespace
|
|||
struct GLNVGcall* call = &gl->calls[ii];
|
||||
const GLNVGblend* blend = &call->blendFunc;
|
||||
gl->state = BGFX_STATE_BLEND_FUNC_SEPARATE(blend->srcRGB, blend->dstRGB, blend->srcAlpha, blend->dstAlpha)
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
;
|
||||
switch (call->type)
|
||||
{
|
||||
|
|
|
@ -604,8 +604,8 @@ namespace ps
|
|||
BX_FREE(m_allocator, particleSort);
|
||||
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_DEPTH_TEST_LESS
|
||||
| BGFX_STATE_CULL_CW
|
||||
| BGFX_STATE_BLEND_NORMAL
|
||||
|
|
|
@ -872,13 +872,11 @@ namespace bgfx
|
|||
///
|
||||
/// @param[in] _state State flags. Default state for primitive type is
|
||||
/// triangles. See: `BGFX_STATE_DEFAULT`.
|
||||
/// - `BGFX_STATE_ALPHA_WRITE` - Enable alpha write.
|
||||
/// - `BGFX_STATE_DEPTH_WRITE` - Enable depth write.
|
||||
/// - `BGFX_STATE_DEPTH_TEST_*` - Depth test function.
|
||||
/// - `BGFX_STATE_BLEND_*` - See remark 1 about BGFX_STATE_BLEND_FUNC.
|
||||
/// - `BGFX_STATE_BLEND_EQUATION_*` - See remark 2.
|
||||
/// - `BGFX_STATE_CULL_*` - Backface culling mode.
|
||||
/// - `BGFX_STATE_RGB_WRITE` - Enable RGB write.
|
||||
/// - `BGFX_STATE_WRITE_*` - Enable R, G, B, A or Z write.
|
||||
/// - `BGFX_STATE_MSAA` - Enable hardware multisample antialiasing.
|
||||
/// - `BGFX_STATE_PT_[TRISTRIP/LINES/POINTS]` - Primitive type.
|
||||
///
|
||||
|
@ -3201,13 +3199,11 @@ namespace bgfx
|
|||
///
|
||||
/// @param[in] _state State flags. Default state for primitive type is
|
||||
/// triangles. See: `BGFX_STATE_DEFAULT`.
|
||||
/// - `BGFX_STATE_ALPHA_WRITE` - Enable alpha write.
|
||||
/// - `BGFX_STATE_DEPTH_WRITE` - Enable depth write.
|
||||
/// - `BGFX_STATE_DEPTH_TEST_*` - Depth test function.
|
||||
/// - `BGFX_STATE_BLEND_*` - See remark 1 about BGFX_STATE_BLEND_FUNC.
|
||||
/// - `BGFX_STATE_BLEND_EQUATION_*` - See remark 2.
|
||||
/// - `BGFX_STATE_CULL_*` - Backface culling mode.
|
||||
/// - `BGFX_STATE_RGB_WRITE` - Enable RGB write.
|
||||
/// - `BGFX_STATE_WRITE_*` - Enable R, G, B, A or Z write.
|
||||
/// - `BGFX_STATE_MSAA` - Enable MSAA.
|
||||
/// - `BGFX_STATE_PT_[TRISTRIP/LINES/POINTS]` - Primitive type.
|
||||
///
|
||||
|
|
|
@ -6,12 +6,28 @@
|
|||
#ifndef BGFX_DEFINES_H_HEADER_GUARD
|
||||
#define BGFX_DEFINES_H_HEADER_GUARD
|
||||
|
||||
#define BGFX_API_VERSION UINT32_C(62)
|
||||
#define BGFX_API_VERSION UINT32_C(63)
|
||||
|
||||
/// Color RGB/alpha/depth write. When it's not specified write will be disabled.
|
||||
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write.
|
||||
#define BGFX_STATE_ALPHA_WRITE UINT64_C(0x0000000000000002) //!< Enable alpha write.
|
||||
#define BGFX_STATE_DEPTH_WRITE UINT64_C(0x0000000000000004) //!< Enable depth write.
|
||||
#define BGFX_STATE_WRITE_R UINT64_C(0x0000000000000001) //!< Enable R write.
|
||||
#define BGFX_STATE_WRITE_G UINT64_C(0x0000000000000002) //!< Enable G write.
|
||||
#define BGFX_STATE_WRITE_B UINT64_C(0x0000000000000004) //!< Enable B write.
|
||||
#define BGFX_STATE_WRITE_A UINT64_C(0x0000000000000008) //!< Enable alpha write.
|
||||
#define BGFX_STATE_WRITE_Z UINT64_C(0x0000004000000000) //!< Enable depth write.
|
||||
|
||||
/// Enable RGB write.
|
||||
#define BGFX_STATE_WRITE_RGB (0 \
|
||||
| BGFX_STATE_WRITE_R \
|
||||
| BGFX_STATE_WRITE_G \
|
||||
| BGFX_STATE_WRITE_B \
|
||||
)
|
||||
|
||||
/// Write all channels mask.
|
||||
#define BGFX_STATE_WRITE_MASK (0 \
|
||||
| BGFX_STATE_WRITE_RGB \
|
||||
| BGFX_STATE_WRITE_A \
|
||||
| BGFX_STATE_WRITE_Z \
|
||||
)
|
||||
|
||||
/// Depth test state. When `BGFX_STATE_DEPTH_` is not specified depth test will be disabled.
|
||||
#define BGFX_STATE_DEPTH_TEST_LESS UINT64_C(0x0000000000000010) //!< Enable depth test, less.
|
||||
|
@ -93,10 +109,10 @@
|
|||
/// Default state is write to RGB, alpha, and depth with depth test less enabled, with clockwise
|
||||
/// culling and MSAA (when writing into MSAA frame buffer, otherwise this flag is ignored).
|
||||
#define BGFX_STATE_DEFAULT (0 \
|
||||
| BGFX_STATE_RGB_WRITE \
|
||||
| BGFX_STATE_ALPHA_WRITE \
|
||||
| BGFX_STATE_WRITE_RGB \
|
||||
| BGFX_STATE_WRITE_A \
|
||||
| BGFX_STATE_WRITE_Z \
|
||||
| BGFX_STATE_DEPTH_TEST_LESS \
|
||||
| BGFX_STATE_DEPTH_WRITE \
|
||||
| BGFX_STATE_CULL_CW \
|
||||
| BGFX_STATE_MSAA \
|
||||
)
|
||||
|
|
32
src/bgfx.cpp
32
src/bgfx.cpp
|
@ -4465,6 +4465,38 @@ BX_STATIC_ASSERT(FLAGS_MASK_TEST(0
|
|||
, BGFX_SUBMIT_RESERVED_MASK
|
||||
) );
|
||||
|
||||
BX_STATIC_ASSERT( (0
|
||||
| BGFX_STATE_WRITE_MASK
|
||||
| BGFX_STATE_DEPTH_TEST_MASK
|
||||
| BGFX_STATE_BLEND_MASK
|
||||
| BGFX_STATE_BLEND_EQUATION_MASK
|
||||
| BGFX_STATE_BLEND_INDEPENDENT
|
||||
| BGFX_STATE_BLEND_ALPHA_TO_COVERAGE
|
||||
| BGFX_STATE_CULL_MASK
|
||||
| BGFX_STATE_ALPHA_REF_MASK
|
||||
| BGFX_STATE_PT_MASK
|
||||
| BGFX_STATE_POINT_SIZE_MASK
|
||||
| BGFX_STATE_MSAA
|
||||
| BGFX_STATE_LINEAA
|
||||
| BGFX_STATE_CONSERVATIVE_RASTER
|
||||
| BGFX_STATE_RESERVED_MASK
|
||||
) == (0
|
||||
^ BGFX_STATE_WRITE_MASK
|
||||
^ BGFX_STATE_DEPTH_TEST_MASK
|
||||
^ BGFX_STATE_BLEND_MASK
|
||||
^ BGFX_STATE_BLEND_EQUATION_MASK
|
||||
^ BGFX_STATE_BLEND_INDEPENDENT
|
||||
^ BGFX_STATE_BLEND_ALPHA_TO_COVERAGE
|
||||
^ BGFX_STATE_CULL_MASK
|
||||
^ BGFX_STATE_ALPHA_REF_MASK
|
||||
^ BGFX_STATE_PT_MASK
|
||||
^ BGFX_STATE_POINT_SIZE_MASK
|
||||
^ BGFX_STATE_MSAA
|
||||
^ BGFX_STATE_LINEAA
|
||||
^ BGFX_STATE_CONSERVATIVE_RASTER
|
||||
^ BGFX_STATE_RESERVED_MASK
|
||||
) );
|
||||
|
||||
#undef FLAGS_MASK_TEST
|
||||
|
||||
#define BGFX_C99_ENUM_CHECK(_enum, _c99enumcount) \
|
||||
|
|
|
@ -2380,8 +2380,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
vp.MaxDepth = 1.0f;
|
||||
deviceCtx->RSSetViewports(1, &vp);
|
||||
|
||||
uint64_t state = BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
uint64_t state = BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_DEPTH_TEST_ALWAYS
|
||||
;
|
||||
|
||||
|
@ -3089,16 +3089,11 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
drt->DestBlendAlpha = s_blendFactor[dstA][1];
|
||||
drt->BlendOpAlpha = s_blendEquation[equA];
|
||||
|
||||
uint8_t writeMask = (_state&BGFX_STATE_ALPHA_WRITE)
|
||||
? D3D11_COLOR_WRITE_ENABLE_ALPHA
|
||||
: 0
|
||||
;
|
||||
writeMask |= (_state&BGFX_STATE_RGB_WRITE)
|
||||
? D3D11_COLOR_WRITE_ENABLE_RED
|
||||
| D3D11_COLOR_WRITE_ENABLE_GREEN
|
||||
| D3D11_COLOR_WRITE_ENABLE_BLUE
|
||||
: 0
|
||||
;
|
||||
uint8_t writeMask = 0;
|
||||
writeMask |= (_state&BGFX_STATE_WRITE_R) ? D3D11_COLOR_WRITE_ENABLE_RED : 0;
|
||||
writeMask |= (_state&BGFX_STATE_WRITE_G) ? D3D11_COLOR_WRITE_ENABLE_GREEN : 0;
|
||||
writeMask |= (_state&BGFX_STATE_WRITE_B) ? D3D11_COLOR_WRITE_ENABLE_BLUE : 0;
|
||||
writeMask |= (_state&BGFX_STATE_WRITE_A) ? D3D11_COLOR_WRITE_ENABLE_ALPHA : 0;
|
||||
|
||||
drt->RenderTargetWriteMask = writeMask;
|
||||
|
||||
|
@ -3181,7 +3176,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
D3D11_DEPTH_STENCIL_DESC desc;
|
||||
bx::memSet(&desc, 0, sizeof(desc) );
|
||||
desc.DepthEnable = 0 != func;
|
||||
desc.DepthWriteMask = !!(BGFX_STATE_DEPTH_WRITE & _state) ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||
desc.DepthWriteMask = !!(BGFX_STATE_WRITE_Z & _state) ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||
desc.DepthFunc = s_cmpFunc[func];
|
||||
|
||||
uint32_t bstencil = unpackStencil(1, _stencil);
|
||||
|
@ -3752,8 +3747,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
|||
ID3D11DeviceContext* deviceCtx = m_deviceCtx;
|
||||
|
||||
uint64_t state = 0;
|
||||
state |= _clear.m_flags & BGFX_CLEAR_COLOR ? BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE : 0;
|
||||
state |= _clear.m_flags & BGFX_CLEAR_DEPTH ? BGFX_STATE_DEPTH_TEST_ALWAYS|BGFX_STATE_DEPTH_WRITE : 0;
|
||||
state |= _clear.m_flags & BGFX_CLEAR_COLOR ? BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A : 0;
|
||||
state |= _clear.m_flags & BGFX_CLEAR_DEPTH ? BGFX_STATE_DEPTH_TEST_ALWAYS|BGFX_STATE_WRITE_Z : 0;
|
||||
|
||||
uint64_t stencil = 0;
|
||||
stencil |= _clear.m_flags & BGFX_CLEAR_STENCIL ? 0
|
||||
|
|
|
@ -47,12 +47,12 @@ BX_PRAGMA_DIAGNOSTIC_POP()
|
|||
| BGFX_STATE_BLEND_EQUATION_MASK \
|
||||
| BGFX_STATE_BLEND_INDEPENDENT \
|
||||
| BGFX_STATE_BLEND_ALPHA_TO_COVERAGE \
|
||||
| BGFX_STATE_ALPHA_WRITE \
|
||||
| BGFX_STATE_RGB_WRITE \
|
||||
| BGFX_STATE_WRITE_A \
|
||||
| BGFX_STATE_WRITE_RGB \
|
||||
)
|
||||
|
||||
#define BGFX_D3D11_DEPTH_STENCIL_MASK (0 \
|
||||
| BGFX_STATE_DEPTH_WRITE \
|
||||
| BGFX_STATE_WRITE_Z \
|
||||
| BGFX_STATE_DEPTH_TEST_MASK \
|
||||
)
|
||||
|
||||
|
|
|
@ -2008,8 +2008,8 @@ namespace bgfx { namespace d3d12
|
|||
m_commandList->RSSetScissorRects(1, &rc);
|
||||
|
||||
const uint64_t state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_DEPTH_TEST_ALWAYS
|
||||
;
|
||||
|
||||
|
@ -2526,16 +2526,11 @@ data.NumQualityLevels = 0;
|
|||
drt->BlendOpAlpha = s_blendEquation[equA];
|
||||
}
|
||||
|
||||
uint8_t writeMask = (_state & BGFX_STATE_ALPHA_WRITE)
|
||||
? D3D12_COLOR_WRITE_ENABLE_ALPHA
|
||||
: 0
|
||||
;
|
||||
writeMask |= (_state & BGFX_STATE_RGB_WRITE)
|
||||
? D3D12_COLOR_WRITE_ENABLE_RED
|
||||
| D3D12_COLOR_WRITE_ENABLE_GREEN
|
||||
| D3D12_COLOR_WRITE_ENABLE_BLUE
|
||||
: 0
|
||||
;
|
||||
uint8_t writeMask = 0;
|
||||
writeMask |= (_state & BGFX_STATE_WRITE_R) ? D3D12_COLOR_WRITE_ENABLE_RED : 0;
|
||||
writeMask |= (_state & BGFX_STATE_WRITE_G) ? D3D12_COLOR_WRITE_ENABLE_GREEN : 0;
|
||||
writeMask |= (_state & BGFX_STATE_WRITE_B) ? D3D12_COLOR_WRITE_ENABLE_BLUE : 0;
|
||||
writeMask |= (_state & BGFX_STATE_WRITE_A) ? D3D12_COLOR_WRITE_ENABLE_ALPHA : 0;
|
||||
|
||||
drt->LogicOp = D3D12_LOGIC_OP_CLEAR;
|
||||
drt->RenderTargetWriteMask = writeMask;
|
||||
|
@ -2603,7 +2598,7 @@ data.NumQualityLevels = 0;
|
|||
bx::memSet(&_desc, 0, sizeof(_desc) );
|
||||
uint32_t func = (_state&BGFX_STATE_DEPTH_TEST_MASK)>>BGFX_STATE_DEPTH_TEST_SHIFT;
|
||||
_desc.DepthEnable = 0 != func;
|
||||
_desc.DepthWriteMask = !!(BGFX_STATE_DEPTH_WRITE & _state)
|
||||
_desc.DepthWriteMask = !!(BGFX_STATE_WRITE_Z & _state)
|
||||
? D3D12_DEPTH_WRITE_MASK_ALL
|
||||
: D3D12_DEPTH_WRITE_MASK_ZERO
|
||||
;
|
||||
|
@ -2759,9 +2754,9 @@ data.NumQualityLevels = 0;
|
|||
ProgramD3D12& program = m_program[_programIdx];
|
||||
|
||||
_state &= 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_MASK
|
||||
| BGFX_STATE_BLEND_MASK
|
||||
| BGFX_STATE_BLEND_EQUATION_MASK
|
||||
|
|
|
@ -3955,10 +3955,10 @@ namespace bgfx { namespace d3d9
|
|||
|
||||
if ( (0
|
||||
| BGFX_STATE_CULL_MASK
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_MASK
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_MASK
|
||||
| BGFX_STATE_BLEND_EQUATION_MASK
|
||||
| BGFX_STATE_ALPHA_REF_MASK
|
||||
|
@ -3973,9 +3973,9 @@ namespace bgfx { namespace d3d9
|
|||
DX_CHECK(device->SetRenderState(D3DRS_CULLMODE, s_cullMode[cull]) );
|
||||
}
|
||||
|
||||
if (BGFX_STATE_DEPTH_WRITE & changedFlags)
|
||||
if (BGFX_STATE_WRITE_Z & changedFlags)
|
||||
{
|
||||
DX_CHECK(device->SetRenderState(D3DRS_ZWRITEENABLE, !!(BGFX_STATE_DEPTH_WRITE & newFlags) ) );
|
||||
DX_CHECK(device->SetRenderState(D3DRS_ZWRITEENABLE, !!(BGFX_STATE_WRITE_Z & newFlags) ) );
|
||||
}
|
||||
|
||||
if (BGFX_STATE_DEPTH_TEST_MASK & changedFlags)
|
||||
|
@ -4010,10 +4010,13 @@ namespace bgfx { namespace d3d9
|
|||
DX_CHECK(m_device->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, !!(newFlags&BGFX_STATE_LINEAA) ) );
|
||||
}
|
||||
|
||||
if ( (BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE) & changedFlags)
|
||||
if ( (BGFX_STATE_WRITE_A|BGFX_STATE_WRITE_RGB) & changedFlags)
|
||||
{
|
||||
uint32_t writeEnable = (newFlags&BGFX_STATE_ALPHA_WRITE) ? D3DCOLORWRITEENABLE_ALPHA : 0;
|
||||
writeEnable |= (newFlags&BGFX_STATE_RGB_WRITE) ? D3DCOLORWRITEENABLE_RED|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_BLUE : 0;
|
||||
uint32_t writeEnable = 0;
|
||||
writeEnable |= (newFlags&BGFX_STATE_WRITE_R) ? D3DCOLORWRITEENABLE_RED : 0;
|
||||
writeEnable |= (newFlags&BGFX_STATE_WRITE_G) ? D3DCOLORWRITEENABLE_GREEN : 0;
|
||||
writeEnable |= (newFlags&BGFX_STATE_WRITE_B) ? D3DCOLORWRITEENABLE_BLUE : 0;
|
||||
writeEnable |= (newFlags&BGFX_STATE_WRITE_A) ? D3DCOLORWRITEENABLE_ALPHA : 0;
|
||||
DX_CHECK(device->SetRenderState(D3DRS_COLORWRITEENABLE, writeEnable) );
|
||||
}
|
||||
|
||||
|
|
|
@ -7009,10 +7009,10 @@ namespace bgfx { namespace gl
|
|||
|
||||
if ( (0
|
||||
| BGFX_STATE_CULL_MASK
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_MASK
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_MASK
|
||||
| BGFX_STATE_BLEND_EQUATION_MASK
|
||||
| BGFX_STATE_ALPHA_REF_MASK
|
||||
|
@ -7041,9 +7041,9 @@ namespace bgfx { namespace gl
|
|||
}
|
||||
}
|
||||
|
||||
if (BGFX_STATE_DEPTH_WRITE & changedFlags)
|
||||
if (BGFX_STATE_WRITE_Z & changedFlags)
|
||||
{
|
||||
GL_CHECK(glDepthMask(!!(BGFX_STATE_DEPTH_WRITE & newFlags) ) );
|
||||
GL_CHECK(glDepthMask(!!(BGFX_STATE_WRITE_Z & newFlags) ) );
|
||||
}
|
||||
|
||||
if (BGFX_STATE_DEPTH_TEST_MASK & changedFlags)
|
||||
|
@ -7057,7 +7057,7 @@ namespace bgfx { namespace gl
|
|||
}
|
||||
else
|
||||
{
|
||||
if (BGFX_STATE_DEPTH_WRITE & newFlags)
|
||||
if (BGFX_STATE_WRITE_Z & newFlags)
|
||||
{
|
||||
GL_CHECK(glEnable(GL_DEPTH_TEST) );
|
||||
GL_CHECK(glDepthFunc(GL_ALWAYS) );
|
||||
|
@ -7109,11 +7109,13 @@ namespace bgfx { namespace gl
|
|||
}
|
||||
}
|
||||
|
||||
if ( (BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE) & changedFlags)
|
||||
if ( (BGFX_STATE_WRITE_A|BGFX_STATE_WRITE_RGB) & changedFlags)
|
||||
{
|
||||
GLboolean alpha = !!(newFlags&BGFX_STATE_ALPHA_WRITE);
|
||||
GLboolean rgb = !!(newFlags&BGFX_STATE_RGB_WRITE);
|
||||
GL_CHECK(glColorMask(rgb, rgb, rgb, alpha) );
|
||||
const GLboolean rr = !!(newFlags&BGFX_STATE_WRITE_R);
|
||||
const GLboolean gg = !!(newFlags&BGFX_STATE_WRITE_G);
|
||||
const GLboolean bb = !!(newFlags&BGFX_STATE_WRITE_B);
|
||||
const GLboolean aa = !!(newFlags&BGFX_STATE_WRITE_A);
|
||||
GL_CHECK(glColorMask(rr, gg, bb, aa) );
|
||||
}
|
||||
|
||||
if ( ( (0
|
||||
|
|
|
@ -1051,8 +1051,8 @@ namespace bgfx { namespace mtl
|
|||
rce.setCullMode(MTLCullModeNone);
|
||||
|
||||
uint64_t state = 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_DEPTH_TEST_ALWAYS
|
||||
;
|
||||
|
||||
|
@ -1455,8 +1455,8 @@ namespace bgfx { namespace mtl
|
|||
|
||||
|
||||
uint64_t state = 0;
|
||||
state |= _clear.m_flags & BGFX_CLEAR_COLOR ? BGFX_STATE_RGB_WRITE|BGFX_STATE_ALPHA_WRITE : 0;
|
||||
state |= _clear.m_flags & BGFX_CLEAR_DEPTH ? BGFX_STATE_DEPTH_TEST_ALWAYS|BGFX_STATE_DEPTH_WRITE : 0;
|
||||
state |= _clear.m_flags & BGFX_CLEAR_COLOR ? BGFX_STATE_WRITE_RGB|BGFX_STATE_WRITE_A : 0;
|
||||
state |= _clear.m_flags & BGFX_CLEAR_DEPTH ? BGFX_STATE_DEPTH_TEST_ALWAYS|BGFX_STATE_WRITE_Z : 0;
|
||||
|
||||
uint64_t stencil = 0;
|
||||
stencil |= _clear.m_flags & BGFX_CLEAR_STENCIL ? 0
|
||||
|
@ -1643,7 +1643,7 @@ namespace bgfx { namespace mtl
|
|||
|
||||
void setDepthStencilState(uint64_t _state, uint64_t _stencil = 0)
|
||||
{
|
||||
_state &= BGFX_STATE_DEPTH_WRITE|BGFX_STATE_DEPTH_TEST_MASK;
|
||||
_state &= BGFX_STATE_WRITE_Z|BGFX_STATE_DEPTH_TEST_MASK;
|
||||
|
||||
uint32_t fstencil = unpackStencil(0, _stencil);
|
||||
uint32_t ref = (fstencil&BGFX_STENCIL_FUNC_REF_MASK)>>BGFX_STENCIL_FUNC_REF_SHIFT;
|
||||
|
@ -1661,7 +1661,7 @@ namespace bgfx { namespace mtl
|
|||
{
|
||||
DepthStencilDescriptor desc = m_depthStencilDescriptor;
|
||||
uint32_t func = (_state&BGFX_STATE_DEPTH_TEST_MASK)>>BGFX_STATE_DEPTH_TEST_SHIFT;
|
||||
desc.depthWriteEnabled = !!(BGFX_STATE_DEPTH_WRITE & _state);
|
||||
desc.depthWriteEnabled = !!(BGFX_STATE_WRITE_Z & _state);
|
||||
desc.depthCompareFunction = s_cmpFunc[func];
|
||||
|
||||
uint32_t bstencil = unpackStencil(1, _stencil);
|
||||
|
@ -2055,7 +2055,15 @@ namespace bgfx { namespace mtl
|
|||
|
||||
RenderPipelineState ProgramMtl::getRenderPipelineState(uint64_t _state, uint32_t _rgba, FrameBufferHandle _fbHandle, VertexDeclHandle _declHandle, uint16_t _numInstanceData)
|
||||
{
|
||||
_state &= (BGFX_STATE_BLEND_MASK|BGFX_STATE_BLEND_EQUATION_MASK|BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE|BGFX_STATE_BLEND_INDEPENDENT|BGFX_STATE_MSAA|BGFX_STATE_BLEND_ALPHA_TO_COVERAGE);
|
||||
_state &= (0
|
||||
| BGFX_STATE_BLEND_MASK
|
||||
| BGFX_STATE_BLEND_EQUATION_MASK
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_INDEPENDENT
|
||||
| BGFX_STATE_MSAA
|
||||
| BGFX_STATE_BLEND_ALPHA_TO_COVERAGE
|
||||
);
|
||||
|
||||
bool independentBlendEnable = !!(BGFX_STATE_BLEND_INDEPENDENT & _state);
|
||||
|
||||
|
@ -2137,8 +2145,11 @@ namespace bgfx { namespace mtl
|
|||
const uint32_t equRGB = (equation )&0x7;
|
||||
const uint32_t equA = (equation>>3)&0x7;
|
||||
|
||||
uint8_t writeMask = (_state&BGFX_STATE_ALPHA_WRITE) ? MTLColorWriteMaskAlpha : 0;
|
||||
writeMask |= (_state&BGFX_STATE_RGB_WRITE) ? MTLColorWriteMaskRed|MTLColorWriteMaskGreen|MTLColorWriteMaskBlue : 0;
|
||||
uint8_t writeMask = 0;
|
||||
writeMask |= (_state&BGFX_STATE_WRITE_R) ? MTLColorWriteMaskRed : 0;
|
||||
writeMask |= (_state&BGFX_STATE_WRITE_G) ? MTLColorWriteMaskGreen : 0;
|
||||
writeMask |= (_state&BGFX_STATE_WRITE_B) ? MTLColorWriteMaskBlue : 0;
|
||||
writeMask |= (_state&BGFX_STATE_WRITE_A) ? MTLColorWriteMaskAlpha : 0;
|
||||
|
||||
for (uint32_t ii = 0; ii < (independentBlendEnable ? 1 : frameBufferAttachment); ++ii)
|
||||
{
|
||||
|
@ -3596,7 +3607,7 @@ namespace bgfx { namespace mtl
|
|||
rce.setScissorRect(rc);
|
||||
}
|
||||
|
||||
if ( (BGFX_STATE_DEPTH_WRITE|BGFX_STATE_DEPTH_TEST_MASK) & changedFlags
|
||||
if ( (BGFX_STATE_WRITE_Z|BGFX_STATE_DEPTH_TEST_MASK) & changedFlags
|
||||
|| 0 != changedStencil)
|
||||
{
|
||||
setDepthStencilState(newFlags,newStencil);
|
||||
|
@ -3647,7 +3658,15 @@ namespace bgfx { namespace mtl
|
|||
rendererUpdateUniforms(this, _render->m_uniformBuffer[draw.m_uniformIdx], draw.m_uniformBegin, draw.m_uniformEnd);
|
||||
|
||||
if (key.m_program != programIdx
|
||||
|| (BGFX_STATE_BLEND_MASK|BGFX_STATE_BLEND_EQUATION_MASK|BGFX_STATE_ALPHA_WRITE|BGFX_STATE_RGB_WRITE|BGFX_STATE_BLEND_INDEPENDENT|BGFX_STATE_MSAA|BGFX_STATE_BLEND_ALPHA_TO_COVERAGE) & changedFlags
|
||||
|| (0
|
||||
| BGFX_STATE_BLEND_MASK
|
||||
| BGFX_STATE_BLEND_EQUATION_MASK
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_BLEND_INDEPENDENT
|
||||
| BGFX_STATE_MSAA
|
||||
| BGFX_STATE_BLEND_ALPHA_TO_COVERAGE
|
||||
) & changedFlags
|
||||
|| currentState.m_streamMask != draw.m_streamMask
|
||||
|| currentState.m_stream[0].m_handle.idx != draw.m_stream[0].m_handle.idx
|
||||
|| currentState.m_stream[0].m_decl.idx != draw.m_stream[0].m_decl.idx
|
||||
|
|
|
@ -2385,16 +2385,11 @@ VK_IMPORT_DEVICE
|
|||
{
|
||||
VkPipelineColorBlendAttachmentState* bas = const_cast<VkPipelineColorBlendAttachmentState*>(_desc.pAttachments);
|
||||
|
||||
uint8_t writeMask = (_state & BGFX_STATE_ALPHA_WRITE)
|
||||
? VK_COLOR_COMPONENT_A_BIT
|
||||
: 0
|
||||
;
|
||||
writeMask |= (_state & BGFX_STATE_RGB_WRITE)
|
||||
? VK_COLOR_COMPONENT_R_BIT
|
||||
| VK_COLOR_COMPONENT_G_BIT
|
||||
| VK_COLOR_COMPONENT_B_BIT
|
||||
: 0
|
||||
;
|
||||
uint8_t writeMask = 0;
|
||||
writeMask |= (_state & BGFX_STATE_WRITE_R) ? VK_COLOR_COMPONENT_R_BIT : 0;
|
||||
writeMask |= (_state & BGFX_STATE_WRITE_G) ? VK_COLOR_COMPONENT_G_BIT : 0;
|
||||
writeMask |= (_state & BGFX_STATE_WRITE_B) ? VK_COLOR_COMPONENT_B_BIT : 0;
|
||||
writeMask |= (_state & BGFX_STATE_WRITE_A) ? VK_COLOR_COMPONENT_A_BIT : 0;
|
||||
|
||||
bas->blendEnable = !!(BGFX_STATE_BLEND_MASK & _state);
|
||||
|
||||
|
@ -2501,7 +2496,7 @@ VK_IMPORT_DEVICE
|
|||
_desc.pNext = NULL;
|
||||
_desc.flags = 0;
|
||||
_desc.depthTestEnable = 0 != func;
|
||||
_desc.depthWriteEnable = !!(BGFX_STATE_DEPTH_WRITE & _state);
|
||||
_desc.depthWriteEnable = !!(BGFX_STATE_WRITE_Z & _state);
|
||||
_desc.depthCompareOp = s_cmpFunc[func];
|
||||
_desc.depthBoundsTestEnable = VK_FALSE;
|
||||
|
||||
|
@ -2581,9 +2576,9 @@ VK_IMPORT_DEVICE
|
|||
ProgramVK& program = m_program[_programIdx];
|
||||
|
||||
_state &= 0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_DEPTH_WRITE
|
||||
| BGFX_STATE_WRITE_RGB
|
||||
| BGFX_STATE_WRITE_A
|
||||
| BGFX_STATE_WRITE_Z
|
||||
| BGFX_STATE_DEPTH_TEST_MASK
|
||||
| BGFX_STATE_BLEND_MASK
|
||||
| BGFX_STATE_BLEND_EQUATION_MASK
|
||||
|
|
|
@ -1759,7 +1759,7 @@ int _main_(int _argc, char** _argv)
|
|||
);
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_A
|
||||
);
|
||||
bgfx::submit(BACKGROUND_VIEW_ID
|
||||
, textureProgram
|
||||
|
@ -1857,7 +1857,7 @@ int _main_(int _argc, char** _argv)
|
|||
);
|
||||
bgfx::setState(0
|
||||
| BGFX_STATE_RGB_WRITE
|
||||
| BGFX_STATE_ALPHA_WRITE
|
||||
| BGFX_STATE_WRITE_A
|
||||
| (view.m_alpha ? BGFX_STATE_BLEND_ALPHA : BGFX_STATE_NONE)
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue