mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 14:18:31 +09:00
[Improvement] (...): Optimize code.
This commit is contained in:
@@ -13,8 +13,8 @@ namespace MobileGL {
|
||||
void BlitFramebuffer_Backend(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0,
|
||||
GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
|
||||
#if MOBILEGL_BACKEND == MOBILEGL_BACKEND_TYPE_DIRECT_GLES
|
||||
MG_Backend::DirectGLES::BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0,
|
||||
dstX1, dstY1, mask, filter);
|
||||
MG_Backend::DirectGLES::BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask,
|
||||
filter);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,9 @@ namespace MobileGL {
|
||||
case GL_RENDERER: {
|
||||
if (rendererString.empty()) {
|
||||
const char* backendStr = (const char*)GetString_Backend(GL_RENDER);
|
||||
rendererString = std::format("{} ({}) ({})", MG_Config::RendererInfoPtr->RendererName.c_str(),
|
||||
MG_Config::CoreName.c_str(), backendStr ? backendStr : "<unknown GPU>");
|
||||
rendererString =
|
||||
std::format("{} ({}) ({})", MG_Config::RendererInfoPtr->RendererName.c_str(),
|
||||
MG_Config::CoreName.c_str(), backendStr ? backendStr : "<unknown GPU>");
|
||||
}
|
||||
return (const GLubyte*)rendererString.c_str();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "GL_Program.h"
|
||||
|
||||
#include "MG_State/GLState/Core.h"
|
||||
#include "MG_Util/Converters/SPIRVCrossToGL/SpvcTypeConverter.h"
|
||||
#include <MG_State/GLState/Core.h>
|
||||
#include <MG_Util/Converters/GLToMG/ProgramEnumConverter.h>
|
||||
#include <MG_Util/Converters/MGToGL/ProgramEnumConverter.h>
|
||||
#include <MG_Util/Converters/SPIRVCrossToGL/SpvcTypeConverter.h>
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
@@ -111,8 +112,7 @@ namespace MobileGL {
|
||||
}
|
||||
|
||||
GLuint CreateShader_State(GLenum type) {
|
||||
auto shaderId =
|
||||
MG_State::pGLContext->CreateShader(MG_State::GLState::ConvertMGLShaderStageByGLShaderType(type));
|
||||
auto shaderId = MG_State::pGLContext->CreateShader(MG_Util::ConvertGLEnumToShaderStage(type));
|
||||
if (shaderId == 0) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidValue,
|
||||
@@ -300,7 +300,7 @@ namespace MobileGL {
|
||||
|
||||
switch (pname) {
|
||||
case GL_SHADER_TYPE:
|
||||
*params = ConvertGLShaderTypeByMGLShaderStage(shaderObject->GetShaderStage());
|
||||
*params = MG_Util::ConvertShaderStageToGLEnum(shaderObject->GetShaderStage());
|
||||
break;
|
||||
case GL_DELETE_STATUS:
|
||||
*params = shaderObject->GetDeleteStatus();
|
||||
|
||||
@@ -4,46 +4,22 @@
|
||||
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
GLsync FenceSync_Backend(GLenum condition, GLbitfield flags) {
|
||||
GLsync FenceSync_Backend(GLenum condition, GLbitfield flags) {}
|
||||
|
||||
}
|
||||
GLenum ClientWaitSync_Backend(GLsync sync, GLbitfield flags, GLuint64 timeout) {}
|
||||
|
||||
GLenum ClientWaitSync_Backend(GLsync sync,
|
||||
GLbitfield flags,
|
||||
GLuint64 timeout) {
|
||||
void DeleteSync_Backend(GLsync sync) {}
|
||||
|
||||
}
|
||||
GLsync FenceSync_State(GLenum condition, GLbitfield flags) {}
|
||||
|
||||
void DeleteSync_Backend(GLsync sync) {
|
||||
GLenum ClientWaitSync_State(GLsync sync, GLbitfield flags, GLuint64 timeout) {}
|
||||
|
||||
}
|
||||
void DeleteSync_State(GLsync sync) {}
|
||||
|
||||
GLsync FenceSync_State(GLenum condition, GLbitfield flags) {
|
||||
GLsync FenceSync(GLenum condition, GLbitfield flags) {}
|
||||
|
||||
}
|
||||
GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) {}
|
||||
|
||||
GLenum ClientWaitSync_State(GLsync sync,
|
||||
GLbitfield flags,
|
||||
GLuint64 timeout) {
|
||||
|
||||
}
|
||||
|
||||
void DeleteSync_State(GLsync sync) {
|
||||
|
||||
}
|
||||
|
||||
GLsync FenceSync(GLenum condition, GLbitfield flags) {
|
||||
|
||||
}
|
||||
|
||||
GLenum ClientWaitSync(GLsync sync,
|
||||
GLbitfield flags,
|
||||
GLuint64 timeout) {
|
||||
|
||||
}
|
||||
|
||||
void DeleteSync(GLsync sync) {
|
||||
|
||||
}
|
||||
void DeleteSync(GLsync sync) {}
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
@@ -4,9 +4,7 @@
|
||||
namespace MobileGL {
|
||||
namespace MG_Impl::GLImpl {
|
||||
GLsync FenceSync(GLenum condition, GLbitfield flags);
|
||||
GLenum ClientWaitSync(GLsync sync,
|
||||
GLbitfield flags,
|
||||
GLuint64 timeout);
|
||||
GLenum ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout);
|
||||
void DeleteSync(GLsync sync);
|
||||
} // namespace MG_Impl::GLImpl
|
||||
} // namespace MobileGL
|
||||
|
||||
@@ -58,16 +58,15 @@ namespace MobileGL {
|
||||
if (!TextureImpl::ValidateTextureSubImageOffsets(textureObject, xoffset, width, yoffset, height)) return;
|
||||
|
||||
// ======================= Processing ================================
|
||||
// SizeT imageSize =
|
||||
// MG_Util::CalculateInputTextureImageSize(textureInternalFormat,
|
||||
// texturePixelDataType,
|
||||
// {width, height, 1});
|
||||
// SizeT imageSize =
|
||||
// MG_Util::CalculateInputTextureImageSize(textureInternalFormat,
|
||||
// texturePixelDataType,
|
||||
// {width, height, 1});
|
||||
auto& mipmap = textureObject->GetMipmap(level);
|
||||
Vector<Uint8>& data = mipmap.data;
|
||||
|
||||
SizeT bytesPerPixel =
|
||||
MG_Util::GetInputBytesPerPixel(textureInternalFormat, texturePixelDataType);
|
||||
// SizeT rowStride = mipmap.size.x() * bytesPerPixel;
|
||||
SizeT bytesPerPixel = MG_Util::GetInputBytesPerPixel(textureInternalFormat, texturePixelDataType);
|
||||
// SizeT rowStride = mipmap.size.x() * bytesPerPixel;
|
||||
|
||||
const Uint8* srcData = reinterpret_cast<const Uint8*>(pixels);
|
||||
if (!srcData) {
|
||||
@@ -90,9 +89,9 @@ namespace MobileGL {
|
||||
Memcpy(data.data() + dstOffset, srcData + srcOffset, width * bytesPerPixel);
|
||||
} else {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"Copy failed. Dest image does not have sufficient space."));
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||
"Copy failed. Dest image does not have sufficient space."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -308,12 +307,11 @@ namespace MobileGL {
|
||||
if (!TextureImpl::ValidateTextureObject(textureObject)) return;
|
||||
|
||||
// ======================= Processing ================================
|
||||
SizeT imageSize = isProxy ? 0 :
|
||||
MG_Util::CalculateInputTextureImageSize(textureInternalFormat,
|
||||
texturePixelDataType,
|
||||
{width, height, 1});
|
||||
SizeT imageSize = isProxy ? 0
|
||||
: MG_Util::CalculateInputTextureImageSize(
|
||||
textureInternalFormat, texturePixelDataType, {width, height, 1});
|
||||
|
||||
Uint8* skippedPixels = (Uint8 *) pixels;
|
||||
Uint8* skippedPixels = (Uint8*)pixels;
|
||||
if (pixels != nullptr) {
|
||||
auto rowsToSkip = MG_State::pGLContext->GetPixelStoreParam(PixelStoreParam::UnpackSkipRows);
|
||||
auto pixelsToSkip = MG_State::pGLContext->GetPixelStoreParam(PixelStoreParam::UnpackSkipPixels);
|
||||
@@ -323,7 +321,8 @@ namespace MobileGL {
|
||||
|
||||
textureObject->SetInternalFormat(textureInternalFormat);
|
||||
MG_State::GLState::MipmapLevelInput mipmap = MG_State::GLState::MipmapLevelInput(
|
||||
{width, height, 1}, level, false, 0, {const_cast<void*>(isProxy ? (void*)skippedPixels : nullptr), imageSize});
|
||||
{width, height, 1}, level, false, 0,
|
||||
{const_cast<void*>(isProxy ? (void*)skippedPixels : nullptr), imageSize});
|
||||
textureObject->SetMipmapLevel(mipmap);
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace MobileGL::MG_Impl::GLImpl {
|
||||
internalFormat != TextureInternalFormat::DepthComponent24 &&
|
||||
internalFormat != TextureInternalFormat::DepthComponent32F &&
|
||||
internalFormat != TextureInternalFormat::DepthComponent32 // workaround for Minecraft 1.21.5+
|
||||
)) {
|
||||
)) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", "ValidateTextureFormatWithType",
|
||||
|
||||
Reference in New Issue
Block a user