mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-11 21:58:31 +09:00
[Improvement] (...): Optimize code.
This commit is contained in:
@@ -82,7 +82,7 @@ namespace MobileGL {
|
||||
Range1D m_dirtyRange;
|
||||
Range1D m_mappedRange;
|
||||
std::vector<Uint8> m_stagingData;
|
||||
bool m_ownsStagingData;
|
||||
Bool m_ownsStagingData;
|
||||
};
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
|
||||
@@ -53,11 +53,11 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
|
||||
bool BufferState::ValidateName(Uint index) const {
|
||||
Bool BufferState::ValidateName(Uint index) const {
|
||||
return m_indexGenerator.IsValid(index);
|
||||
}
|
||||
|
||||
bool BufferState::ValidateBufferObject(Uint index) const {
|
||||
Bool BufferState::ValidateBufferObject(Uint index) const {
|
||||
return m_bufferObjects.find(index) != m_bufferObjects.end();
|
||||
}
|
||||
} // namespace GLState
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <Includes.h>
|
||||
#include "BufferObject.h"
|
||||
#include <MG_Util/Miscellany/IndexGenerator.h>
|
||||
#include "BufferObject.h"
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_State {
|
||||
@@ -21,8 +21,8 @@ namespace MobileGL {
|
||||
SharedPtr<BufferObject> CreateBufferObject(Uint index);
|
||||
BindingSlot<BufferObject>& GetBindingSlot(BufferTarget target);
|
||||
void MarkBufferObjectForDeletion(Uint index);
|
||||
bool ValidateName(Uint index) const;
|
||||
bool ValidateBufferObject(Uint index) const;
|
||||
Bool ValidateName(Uint index) const;
|
||||
Bool ValidateBufferObject(Uint index) const;
|
||||
|
||||
private:
|
||||
UnorderedMap<Uint, SharedPtr<BufferObject>> m_bufferObjects;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
|
||||
bool ErrorState::HasNonGLError() const {
|
||||
Bool ErrorState::HasNonGLError() const {
|
||||
return !m_nonGLErrors.empty();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace MobileGL {
|
||||
return Optional<const Error>{error};
|
||||
}
|
||||
|
||||
bool ErrorState::HasGLError() const {
|
||||
Bool ErrorState::HasGLError() const {
|
||||
return !m_errors.empty();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace MobileGL {
|
||||
class ErrorState {
|
||||
public:
|
||||
void RecordError(ErrorCode code, SharedPtr<ErrorInfo> info = nullptr);
|
||||
bool HasNonGLError() const;
|
||||
Bool HasNonGLError() const;
|
||||
Optional<const Error> PeekNonGLError() const;
|
||||
Optional<Error> PopNonGLError();
|
||||
bool HasGLError() const;
|
||||
Bool HasGLError() const;
|
||||
Optional<const Error> PeekGLError() const;
|
||||
Optional<Error> PopGLError();
|
||||
void Clear();
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace MobileGL {
|
||||
// basically this contains SPIR-V in binary format
|
||||
Vector<Vector<Uint>> m_programBinary;
|
||||
String m_infoLog;
|
||||
bool m_deleteStatus = false;
|
||||
bool m_linkStatus = true;
|
||||
bool m_validateStatus = true;
|
||||
Bool m_deleteStatus = false;
|
||||
Bool m_linkStatus = true;
|
||||
Bool m_validateStatus = true;
|
||||
};
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace MobileGL {
|
||||
void DeleteProgram(Uint program);
|
||||
|
||||
private:
|
||||
bool CheckIndexAvail(SizeT idx) { return idx < m_programObjects.size(); }
|
||||
Bool CheckIndexAvail(SizeT idx) { return idx < m_programObjects.size(); }
|
||||
|
||||
void EnsureIndexAvail(SizeT idx) {
|
||||
if (CheckIndexAvail(idx)) return;
|
||||
|
||||
@@ -44,8 +44,8 @@ namespace MobileGL {
|
||||
SharedPtr<glslang::TShader> m_shader;
|
||||
std::string m_infoLog;
|
||||
|
||||
bool m_deleteStatus = false;
|
||||
bool m_compileStatus = false;
|
||||
Bool m_deleteStatus = false;
|
||||
Bool m_compileStatus = false;
|
||||
};
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace MobileGL {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add other texture types as needed
|
||||
// TODO: add other texture types as needed
|
||||
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
|
||||
@@ -214,7 +214,7 @@ namespace MobileGL {
|
||||
void SetMipmapImpl(const MipmapLevelInput& level) override;
|
||||
};
|
||||
|
||||
// TODO: Add other texture types as needed
|
||||
// TODO: add other texture types as needed
|
||||
|
||||
} // namespace GLState
|
||||
} // namespace MG_State
|
||||
|
||||
@@ -25,13 +25,13 @@ namespace MobileGL {
|
||||
m_attributes[index].Enabled = false;
|
||||
}
|
||||
|
||||
bool VertexArrayObject::IsAttributeEnabled(Uint index) const {
|
||||
Bool VertexArrayObject::IsAttributeEnabled(Uint index) const {
|
||||
if (index >= MAX_VERTEX_ATTRIBS) return false;
|
||||
return m_attributes[index].Enabled;
|
||||
}
|
||||
|
||||
void VertexArrayObject::SetAttributeFormat(Uint index, int size, DataType type, bool normalized, int stride,
|
||||
SizeT offset, bool isInteger) {
|
||||
void VertexArrayObject::SetAttributeFormat(Uint index, int size, DataType type, Bool normalized, int stride,
|
||||
SizeT offset, Bool isInteger) {
|
||||
if (index >= MAX_VERTEX_ATTRIBS) return;
|
||||
|
||||
if (size < 1 || size > 4) {
|
||||
|
||||
@@ -6,13 +6,13 @@ namespace MobileGL {
|
||||
namespace MG_State {
|
||||
namespace GLState {
|
||||
struct VertexAttribute {
|
||||
bool Enabled = false;
|
||||
Bool Enabled = false;
|
||||
int Size = 4;
|
||||
DataType Type = DataType::Float32;
|
||||
bool Normalized = false;
|
||||
Bool Normalized = false;
|
||||
int Stride = 0;
|
||||
SizeT Offset = 0;
|
||||
bool IsInteger = false;
|
||||
Bool IsInteger = false;
|
||||
SharedPtr<BufferObject> Buffer;
|
||||
};
|
||||
|
||||
@@ -24,10 +24,10 @@ namespace MobileGL {
|
||||
|
||||
void EnableAttribute(Uint index);
|
||||
void DisableAttribute(Uint index);
|
||||
bool IsAttributeEnabled(Uint index) const;
|
||||
Bool IsAttributeEnabled(Uint index) const;
|
||||
|
||||
void SetAttributeFormat(Uint index, int size, DataType type, bool normalized, int stride, SizeT offset,
|
||||
bool isInteger);
|
||||
void SetAttributeFormat(Uint index, int size, DataType type, Bool normalized, int stride, SizeT offset,
|
||||
Bool isInteger);
|
||||
|
||||
void BindAttributeBuffer(Uint index, const SharedPtr<BufferObject>& buffer);
|
||||
|
||||
|
||||
@@ -54,11 +54,11 @@ namespace MobileGL {
|
||||
// FIXME: report GL error here?
|
||||
}
|
||||
|
||||
bool VertexArrayState::ValidateName(Uint index) const {
|
||||
Bool VertexArrayState::ValidateName(Uint index) const {
|
||||
return m_indexGenerator.IsValid(index);
|
||||
}
|
||||
|
||||
bool VertexArrayState::ValidateVertexArrayObject(Uint index) const {
|
||||
Bool VertexArrayState::ValidateVertexArrayObject(Uint index) const {
|
||||
return index < m_vertexArrays.size() && m_vertexArrays[index] != nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace MobileGL {
|
||||
void Bind(Uint index);
|
||||
SharedPtr<VertexArrayObject> CreateVertexArrayObject(Uint index);
|
||||
void MarkVertexArrayForDeletion(Uint index);
|
||||
bool ValidateName(Uint index) const;
|
||||
bool ValidateVertexArrayObject(Uint index) const;
|
||||
Bool ValidateName(Uint index) const;
|
||||
Bool ValidateVertexArrayObject(Uint index) const;
|
||||
SharedPtr<VertexArrayObject> GetBoundVertexArray();
|
||||
Vector<SharedPtr<VertexArrayObject>>& GetAllVertexArrays();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user