mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Feat] (MG_State/VertexArrayState): Add SwitchVersion for VA.
This commit is contained in:
@@ -29,13 +29,13 @@ namespace MobileGL {
|
|||||||
void VertexArrayObject::EnableAttribute(Uint index) {
|
void VertexArrayObject::EnableAttribute(Uint index) {
|
||||||
if (index >= MAX_VERTEX_ATTRIBS) return;
|
if (index >= MAX_VERTEX_ATTRIBS) return;
|
||||||
m_attributes[index].Enabled = true;
|
m_attributes[index].Enabled = true;
|
||||||
BumpAttributeFormatVersion(index);
|
BumpAttributeSwitchVersion(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexArrayObject::DisableAttribute(Uint index) {
|
void VertexArrayObject::DisableAttribute(Uint index) {
|
||||||
if (index >= MAX_VERTEX_ATTRIBS) return;
|
if (index >= MAX_VERTEX_ATTRIBS) return;
|
||||||
m_attributes[index].Enabled = false;
|
m_attributes[index].Enabled = false;
|
||||||
BumpAttributeFormatVersion(index);
|
BumpAttributeSwitchVersion(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool VertexArrayObject::IsAttributeEnabled(Uint index) const {
|
Bool VertexArrayObject::IsAttributeEnabled(Uint index) const {
|
||||||
@@ -109,6 +109,11 @@ namespace MobileGL {
|
|||||||
++m_attributeVersions[index].BufferVersion;
|
++m_attributeVersions[index].BufferVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VertexArrayObject::BumpAttributeSwitchVersion(Uint index) {
|
||||||
|
if (index >= MAX_VERTEX_ATTRIBS) return;
|
||||||
|
++m_attributeVersions[index].SwitchVersion;
|
||||||
|
}
|
||||||
|
|
||||||
const VertexAttributeVersion& VertexArrayObject::GetAttributeVersion(Uint index) const {
|
const VertexAttributeVersion& VertexArrayObject::GetAttributeVersion(Uint index) const {
|
||||||
static VertexAttributeVersion emptyVersion;
|
static VertexAttributeVersion emptyVersion;
|
||||||
if (index >= MAX_VERTEX_ATTRIBS) return emptyVersion;
|
if (index >= MAX_VERTEX_ATTRIBS) return emptyVersion;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ namespace MobileGL {
|
|||||||
struct VertexAttributeVersion {
|
struct VertexAttributeVersion {
|
||||||
Uint16 FormatVersion = 0;
|
Uint16 FormatVersion = 0;
|
||||||
Uint16 BufferVersion = 0;
|
Uint16 BufferVersion = 0;
|
||||||
|
Uint16 SwitchVersion = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class VertexArrayObject {
|
class VertexArrayObject {
|
||||||
@@ -62,10 +63,11 @@ namespace MobileGL {
|
|||||||
private:
|
private:
|
||||||
void BumpAttributeFormatVersion(Uint index);
|
void BumpAttributeFormatVersion(Uint index);
|
||||||
void BumpAttributeBufferVersion(Uint index);
|
void BumpAttributeBufferVersion(Uint index);
|
||||||
|
void BumpAttributeSwitchVersion(Uint index);
|
||||||
|
|
||||||
const Uint m_externalIndex = 0;
|
const Uint m_externalIndex = 0;
|
||||||
Array<VertexAttribute, MAX_VERTEX_ATTRIBS> m_attributes;
|
Array<VertexAttribute, MAX_VERTEX_ATTRIBS> m_attributes;
|
||||||
Array<VertexAttributeVersion, MAX_VERTEX_ATTRIBS> m_attributeVersions; // format version, buffer version
|
Array<VertexAttributeVersion, MAX_VERTEX_ATTRIBS> m_attributeVersions;
|
||||||
BindingSlot<BufferObject> m_indexBufferBindingSlot;
|
BindingSlot<BufferObject> m_indexBufferBindingSlot;
|
||||||
};
|
};
|
||||||
} // namespace GLState
|
} // namespace GLState
|
||||||
|
|||||||
Reference in New Issue
Block a user