mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 05:38:31 +09:00
[Feat] (MG_Impl/GLImpl, MG_State, MG_Backend): implement glColorMaski
Promote the color writemask to per-draw-buffer state and implement the indexed glColorMaski entry point (previously a stub), plus its read-back through glGetBooleani_v. - RenderState: replace the single BoolVec4 ColorMask with an array of MAX_DRAW_BUFFERS masks, all initialized to true. SetColorMask now broadcasts to every draw buffer (glColorMask semantics); GetColorMask returns draw buffer 0. Add indexed set/get accessors + GLContext wrappers. - glColorMaski sets only the addressed draw buffer; out-of-range index raises GL_INVALID_VALUE (buf is a GLuint, so no GL_INVALID_ENUM path), mirroring the indexed blend entry points' MAX_DRAW_BUFFERS bound. - glGetBooleani_v(GL_COLOR_WRITEMASK, i) reports draw buffer i's four booleans; the non-indexed glGetBooleanv still reports draw buffer 0. - Fix GLboolean coercion in the color-mask path: any nonzero value enables the component (was == GL_TRUE, which wrongly rejected e.g. 2). - DirectGLES sync reads ColorMasks[0] (GLES core has only non-indexed glColorMask). Tests: ColorMaskIndexedStoresAndReadsBack covers the per-buffer vs broadcast semantics, buffer-0 read-back, out-of-range INVALID_VALUE, and the GLboolean coercion (mutation-verified: == GL_TRUE fails it). Full SanityTest sweep green (30/30).
This commit is contained in:
@@ -26,7 +26,12 @@ namespace MobileGL {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
RenderState::RenderState() {}
|
||||
RenderState::RenderState() {
|
||||
// The color writemask defaults to all-true for every draw buffer.
|
||||
for (auto& mask : m_parameters.ColorMasks) {
|
||||
mask = BoolVec4(true, true, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
Uint RenderState::GetVersion() const {
|
||||
return m_version;
|
||||
@@ -437,14 +442,30 @@ namespace MobileGL {
|
||||
|
||||
// -------------------- Color Mask --------------------
|
||||
void RenderState::SetColorMask(BoolVec4 mask) {
|
||||
if (m_parameters.ColorMask == mask) return;
|
||||
|
||||
m_parameters.ColorMask = mask;
|
||||
++m_version;
|
||||
// glColorMask broadcasts the same mask to every draw buffer.
|
||||
Bool changed = false;
|
||||
for (auto& slot : m_parameters.ColorMasks) {
|
||||
if (!(slot == mask)) {
|
||||
slot = mask;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (changed) ++m_version;
|
||||
}
|
||||
|
||||
BoolVec4 RenderState::GetColorMask() const {
|
||||
return m_parameters.ColorMask;
|
||||
// Non-indexed query reports draw buffer 0.
|
||||
return m_parameters.ColorMasks[0];
|
||||
}
|
||||
|
||||
void RenderState::SetColorMaskIndexed(Uint index, BoolVec4 mask) {
|
||||
if (m_parameters.ColorMasks[index] == mask) return;
|
||||
m_parameters.ColorMasks[index] = mask;
|
||||
++m_version;
|
||||
}
|
||||
|
||||
BoolVec4 RenderState::GetColorMaskIndexed(Uint index) const {
|
||||
return m_parameters.ColorMasks[index];
|
||||
}
|
||||
|
||||
// -------------------- Clear State --------------------
|
||||
|
||||
Reference in New Issue
Block a user