mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-10 21:28:32 +09:00
[Feat] (Tessellation): implement glPatchParameterfv and bake the default levels into both pass-through control stages
This commit is contained in:
@@ -812,6 +812,22 @@ namespace MobileGL::MG_State {
|
||||
m_renderState.SetPatchVertices(vertices);
|
||||
}
|
||||
|
||||
void GLContext::SetPatchDefaultOuterLevel(const FloatVec4& levels) {
|
||||
m_renderState.SetPatchDefaultOuterLevel(levels);
|
||||
}
|
||||
|
||||
const FloatVec4& GLContext::GetPatchDefaultOuterLevel() const {
|
||||
return m_renderState.GetPatchDefaultOuterLevel();
|
||||
}
|
||||
|
||||
void GLContext::SetPatchDefaultInnerLevel(const FloatVec2& levels) {
|
||||
m_renderState.SetPatchDefaultInnerLevel(levels);
|
||||
}
|
||||
|
||||
const FloatVec2& GLContext::GetPatchDefaultInnerLevel() const {
|
||||
return m_renderState.GetPatchDefaultInnerLevel();
|
||||
}
|
||||
|
||||
Uint GLContext::GetPatchVertices() const {
|
||||
return m_renderState.GetPatchVertices();
|
||||
}
|
||||
|
||||
@@ -213,6 +213,10 @@ namespace MobileGL {
|
||||
Float GetPointSize() const;
|
||||
void SetPatchVertices(Uint vertices);
|
||||
Uint GetPatchVertices() const;
|
||||
void SetPatchDefaultOuterLevel(const FloatVec4& levels);
|
||||
const FloatVec4& GetPatchDefaultOuterLevel() const;
|
||||
void SetPatchDefaultInnerLevel(const FloatVec2& levels);
|
||||
const FloatVec2& GetPatchDefaultInnerLevel() const;
|
||||
void SetPolygonOffset(Float factor, Float units);
|
||||
Float GetPolygonOffsetFactor() const;
|
||||
Float GetPolygonOffsetUnits() const;
|
||||
|
||||
@@ -217,6 +217,31 @@ namespace MobileGL {
|
||||
return m_parameters.PatchVertices;
|
||||
}
|
||||
|
||||
// BumpVersions(), not just ++m_version, for the same reason SetPatchVertices does it:
|
||||
// these levels are compiled INTO the synthesized pass-through tessellation control
|
||||
// stage on both backends, so changing one makes an already-built program stale.
|
||||
void RenderState::SetPatchDefaultOuterLevel(const FloatVec4& levels) {
|
||||
if (m_parameters.PatchDefaultOuterLevel == levels) return;
|
||||
|
||||
m_parameters.PatchDefaultOuterLevel = levels;
|
||||
BumpVersions();
|
||||
}
|
||||
|
||||
const FloatVec4& RenderState::GetPatchDefaultOuterLevel() const {
|
||||
return m_parameters.PatchDefaultOuterLevel;
|
||||
}
|
||||
|
||||
void RenderState::SetPatchDefaultInnerLevel(const FloatVec2& levels) {
|
||||
if (m_parameters.PatchDefaultInnerLevel == levels) return;
|
||||
|
||||
m_parameters.PatchDefaultInnerLevel = levels;
|
||||
BumpVersions();
|
||||
}
|
||||
|
||||
const FloatVec2& RenderState::GetPatchDefaultInnerLevel() const {
|
||||
return m_parameters.PatchDefaultInnerLevel;
|
||||
}
|
||||
|
||||
void RenderState::SetPolygonOffset(Float factor, Float units) {
|
||||
if (m_parameters.PolygonOffsetFactor == factor && m_parameters.PolygonOffsetUnits == units) return;
|
||||
|
||||
|
||||
@@ -240,6 +240,13 @@ namespace MobileGL {
|
||||
Float PointSize = 1.0f;
|
||||
// GL_PATCH_VERTICES: how many vertices one tessellation patch consumes.
|
||||
Uint PatchVertices = 3;
|
||||
// GL_PATCH_DEFAULT_OUTER_LEVEL / GL_PATCH_DEFAULT_INNER_LEVEL (glPatchParameterfv). The
|
||||
// tessellation levels used when a program has an evaluation stage and NO control stage -
|
||||
// GL's fixed-function pass-through (4.6 core 11.2.2). Both backends have to synthesize
|
||||
// that stage, and they bake these numbers into it, so a change here makes an already-built
|
||||
// one stale exactly as PATCH_VERTICES does. Default 1.0, per table 23.44.
|
||||
FloatVec4 PatchDefaultOuterLevel = FloatVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
FloatVec2 PatchDefaultInnerLevel = FloatVec2(1.0f, 1.0f);
|
||||
Float PolygonOffsetFactor = 0.0f;
|
||||
Float PolygonOffsetUnits = 0.0f;
|
||||
|
||||
@@ -374,6 +381,10 @@ namespace MobileGL {
|
||||
Float GetPointSize() const;
|
||||
void SetPatchVertices(Uint vertices);
|
||||
Uint GetPatchVertices() const;
|
||||
void SetPatchDefaultOuterLevel(const FloatVec4& levels);
|
||||
const FloatVec4& GetPatchDefaultOuterLevel() const;
|
||||
void SetPatchDefaultInnerLevel(const FloatVec2& levels);
|
||||
const FloatVec2& GetPatchDefaultInnerLevel() const;
|
||||
void SetPolygonOffset(Float factor, Float units);
|
||||
Float GetPolygonOffsetFactor() const;
|
||||
Float GetPolygonOffsetUnits() const;
|
||||
|
||||
Reference in New Issue
Block a user