mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-13 06:38:31 +09:00
[Feat] (MG_State/RenderState, MG_Backend/DirectVulkan): make Distant
Horizon work - Implement BlendEquation/CullFaceMode/PointSize/PolygonMode - Implement GetFramebufferAttachmentParameter* - Downgrade some color attachment resolve failure - Downgrade some overly-strict shader stage linkage check (don't check on unused input var)
This commit is contained in:
@@ -313,6 +313,22 @@ namespace MobileGL::MG_State {
|
||||
m_renderState.GetBlendFuncIndexed(index, srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
}
|
||||
|
||||
void GLContext::SetBlendEquation(BlendEquation color, BlendEquation alpha) {
|
||||
m_renderState.SetBlendEquation(color, alpha);
|
||||
}
|
||||
|
||||
void GLContext::GetBlendEquation(BlendEquation& color, BlendEquation& alpha) const {
|
||||
m_renderState.GetBlendEquation(color, alpha);
|
||||
}
|
||||
|
||||
void GLContext::SetBlendEquationIndexed(Uint index, BlendEquation color, BlendEquation alpha) {
|
||||
m_renderState.SetBlendEquationIndexed(index, color, alpha);
|
||||
}
|
||||
|
||||
void GLContext::GetBlendEquationIndexed(Uint index, BlendEquation& color, BlendEquation& alpha) const {
|
||||
m_renderState.GetBlendEquationIndexed(index, color, alpha);
|
||||
}
|
||||
|
||||
void GLContext::SetDepthFunc(DepthTestFunc func) {
|
||||
m_renderState.SetDepthFunc(func);
|
||||
}
|
||||
|
||||
@@ -111,6 +111,10 @@ namespace MobileGL {
|
||||
BlendFactor dstAlpha);
|
||||
void GetBlendFuncIndexed(Uint index, BlendFactor& srcRGB, BlendFactor& dstRGB, BlendFactor& srcAlpha,
|
||||
BlendFactor& dstAlpha) const;
|
||||
void SetBlendEquation(BlendEquation color, BlendEquation alpha);
|
||||
void GetBlendEquation(BlendEquation& color, BlendEquation& alpha) const;
|
||||
void SetBlendEquationIndexed(Uint index, BlendEquation color, BlendEquation alpha);
|
||||
void GetBlendEquationIndexed(Uint index, BlendEquation& color, BlendEquation& alpha) const;
|
||||
void SetDepthFunc(DepthTestFunc func);
|
||||
DepthTestFunc GetDepthFunc() const;
|
||||
void SetDepthMask(Bool flag);
|
||||
|
||||
@@ -164,6 +164,48 @@ namespace MobileGL {
|
||||
dstAlpha = m_parameters.BlendStates[index].DstFactorAlpha;
|
||||
}
|
||||
|
||||
void RenderState::SetBlendEquation(BlendEquation color, BlendEquation alpha) {
|
||||
Bool stateChanged = false;
|
||||
for (auto& blendState : m_parameters.BlendStates) {
|
||||
if (blendState.ColorEquation == color && blendState.AlphaEquation == alpha) {
|
||||
continue;
|
||||
}
|
||||
blendState.ColorEquation = color;
|
||||
blendState.AlphaEquation = alpha;
|
||||
stateChanged = true;
|
||||
}
|
||||
if (!stateChanged) return;
|
||||
++m_version;
|
||||
}
|
||||
|
||||
void RenderState::GetBlendEquation(BlendEquation& color, BlendEquation& alpha) const {
|
||||
color = m_parameters.BlendStates[0].ColorEquation;
|
||||
alpha = m_parameters.BlendStates[0].AlphaEquation;
|
||||
}
|
||||
|
||||
void RenderState::SetBlendEquationIndexed(Uint index, BlendEquation color, BlendEquation alpha) {
|
||||
if (index >= MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS) {
|
||||
MOBILEGL_ASSERT(false, "Blend equation index out of range: %d", index);
|
||||
return;
|
||||
}
|
||||
PerBufferBlendState& blendState = m_parameters.BlendStates[index];
|
||||
if (blendState.ColorEquation == color && blendState.AlphaEquation == alpha) {
|
||||
return;
|
||||
}
|
||||
blendState.ColorEquation = color;
|
||||
blendState.AlphaEquation = alpha;
|
||||
++m_version;
|
||||
}
|
||||
|
||||
void RenderState::GetBlendEquationIndexed(Uint index, BlendEquation& color, BlendEquation& alpha) const {
|
||||
if (index >= MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS) {
|
||||
MOBILEGL_ASSERT(false, "Blend equation index out of range: %d", index);
|
||||
return;
|
||||
}
|
||||
color = m_parameters.BlendStates[index].ColorEquation;
|
||||
alpha = m_parameters.BlendStates[index].AlphaEquation;
|
||||
}
|
||||
|
||||
// -------------------- Depth --------------------
|
||||
void RenderState::SetDepthFunc(DepthTestFunc func) {
|
||||
if (m_parameters.DepthFunc == func) return;
|
||||
|
||||
@@ -31,6 +31,16 @@ namespace MobileGL {
|
||||
Unknown = -1
|
||||
};
|
||||
|
||||
enum class BlendEquation {
|
||||
Add,
|
||||
Subtract,
|
||||
ReverseSubtract,
|
||||
Min,
|
||||
Max,
|
||||
BlendEquationCount,
|
||||
Unknown = -1
|
||||
};
|
||||
|
||||
enum class DepthTestFunc {
|
||||
Never,
|
||||
Less,
|
||||
@@ -134,6 +144,8 @@ namespace MobileGL {
|
||||
BlendFactor DstFactorRGB = BlendFactor::Zero;
|
||||
BlendFactor SrcFactorAlpha = BlendFactor::One;
|
||||
BlendFactor DstFactorAlpha = BlendFactor::Zero;
|
||||
BlendEquation ColorEquation = BlendEquation::Add;
|
||||
BlendEquation AlphaEquation = BlendEquation::Add;
|
||||
};
|
||||
|
||||
struct RenderStateParameters {
|
||||
@@ -192,6 +204,10 @@ namespace MobileGL {
|
||||
BlendFactor dstAlpha);
|
||||
void GetBlendFuncIndexed(Uint index, BlendFactor& srcRGB, BlendFactor& dstRGB, BlendFactor& srcAlpha,
|
||||
BlendFactor& dstAlpha) const;
|
||||
void SetBlendEquation(BlendEquation color, BlendEquation alpha);
|
||||
void GetBlendEquation(BlendEquation& color, BlendEquation& alpha) const;
|
||||
void SetBlendEquationIndexed(Uint index, BlendEquation color, BlendEquation alpha);
|
||||
void GetBlendEquationIndexed(Uint index, BlendEquation& color, BlendEquation& alpha) const;
|
||||
|
||||
// Depth
|
||||
void SetDepthFunc(DepthTestFunc func);
|
||||
|
||||
Reference in New Issue
Block a user