[Chore] (...): Format code.

This commit is contained in:
BZLZHH
2025-11-28 15:17:50 +08:00
parent c67e6e26fa
commit a6b34ee5bf
27 changed files with 344 additions and 345 deletions
+1 -2
View File
@@ -71,8 +71,7 @@ namespace MobileGL {
.TargetGLVersion = {3, 3, 0}, // Target OpenGL Version
.TargetGLSLVersion = {4, 6, 0}, // Target Shading Language Version
.Extensions = {V_OpenGL30, V_OpenGL31, V_OpenGL32, // OpenGL Extensions
V_OpenGL33,
E_GL_ARB_draw_buffers_blend},
V_OpenGL33, E_GL_ARB_draw_buffers_blend},
.IsCompatibilityProfile = false // Is Compatibility Profile
},
.BackendCapability = {} // Backend Capability
+2 -2
View File
@@ -18,8 +18,8 @@ namespace MobileGL::MG_Backend::DirectGLES {
GLint dstY1, GLbitfield mask, GLenum filter);
void CopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width,
GLsizei height, GLint border);
void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
GLsizei width, GLsizei height);
void CopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width,
GLsizei height);
void GenerateMipmap(GLenum target);
const GLubyte* GetString(GLenum name);
} // namespace MobileGL::MG_Backend::DirectGLES
+47 -57
View File
@@ -277,15 +277,13 @@ namespace MobileGL::MG_Backend::DirectGLES {
const auto mipmapCount = stateTextureObject->GetMipmapLevelCount();
const auto baseSize = stateTextureObject->GetBaseSize();
StateTextureBasicInfo currentTextureInfo = {
stateTextureObject->GetFormat(), static_cast<SizeT>(baseSize.x()),
static_cast<SizeT>(baseSize.y()),
stateTextureObject->GetFormat(), static_cast<SizeT>(baseSize.x()), static_cast<SizeT>(baseSize.y()),
static_cast<SizeT>(baseSize.z()), mipmapCount};
Bool needsRegeneration = !m_isInitialized || (currentTextureInfo != m_prevTextureInfo);
MGLOG_D("%s: Got texture info: %dx%dx%d, mips %d, format %s", __func__,
baseSize.x(), baseSize.y(), baseSize.z(),
mipmapCount,
MGLOG_D("%s: Got texture info: %dx%dx%d, mips %d, format %s", __func__, baseSize.x(), baseSize.y(),
baseSize.z(), mipmapCount,
MG_Util::ConvertTextureInternalFormatToString(stateTextureObject->GetFormat()).c_str());
if (needsRegeneration) {
@@ -300,39 +298,29 @@ namespace MobileGL::MG_Backend::DirectGLES {
const auto& uploadTargets = stateTextureObject->GetUploadTargets();
for (auto uploadTarget : uploadTargets) {
for (SizeT level = 0; level < mipmapCount; ++level) {
auto levelTexelSize = stateTextureObject->GetMipmapTexelSize(
uploadTarget, level);
auto levelByteSize = stateTextureObject->GetMipmapByteSize(
uploadTarget, level);
bool levelDirty = stateTextureObject->IsStorageDirty(
uploadTarget, 0);
auto levelTexelSize = stateTextureObject->GetMipmapTexelSize(uploadTarget, level);
auto levelByteSize = stateTextureObject->GetMipmapByteSize(uploadTarget, level);
bool levelDirty = stateTextureObject->IsStorageDirty(uploadTarget, 0);
auto glUploadTarget = MG_Util::ConvertTextureUploadTargetToGLEnum(uploadTarget);
auto* pData = (levelDirty && levelByteSize != 0)
? stateTextureObject->MapMipmapData(
uploadTarget, level) : nullptr;
? stateTextureObject->MapMipmapData(uploadTarget, level)
: nullptr;
MGLOG_D("%s: target: %s: syncing mip %d: %dx%dx%d, byteSize = %d, pData = %p", __func__,
MG_Util::ConvertTextureUploadTargetToString(uploadTarget).c_str(),
level,
levelTexelSize.x(), levelTexelSize.y(), levelTexelSize.z(),
levelByteSize,
pData);
MG_Util::ConvertTextureUploadTargetToString(uploadTarget).c_str(), level,
levelTexelSize.x(), levelTexelSize.y(), levelTexelSize.z(), levelByteSize, pData);
BufferImpl::BackendBufferBindingProtector pixelUnpackProtector =
BufferImpl::BackendBufferBindingProtector(GL_PIXEL_UNPACK_BUFFER);
errorLopper.Clear();
MG_External::GLES::glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
MG_External::GLES::glTexImage2D(glUploadTarget, static_cast<GLint>(level),
glInternalFormat,
MG_External::GLES::glTexImage2D(glUploadTarget, static_cast<GLint>(level), glInternalFormat,
static_cast<GLsizei>(levelTexelSize.x()),
static_cast<GLsizei>(levelTexelSize.y()), 0,
glFormat, glType,
static_cast<GLsizei>(levelTexelSize.y()), 0, glFormat, glType,
pData);
// TODO: handle more texture types
MGLOG_D("Regenerated mipmap level %d for texture with ID: %u", level,
m_backendTextureId);
stateTextureObject->MarkStorageDirty(uploadTarget, level,
false);
MGLOG_D("Regenerated mipmap level %d for texture with ID: %u", level, m_backendTextureId);
stateTextureObject->MarkStorageDirty(uploadTarget, level, false);
}
}
@@ -348,20 +336,23 @@ namespace MobileGL::MG_Backend::DirectGLES {
MG_External::GLES::glTexParameteri(target, glName, \
MG_Util::ConvertSampler##type##ToGLEnum(samplerParams.internalName)); \
m_cacheSamplerParameters.internalName = samplerParams.internalName; \
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__, t = MG_Util::ConvertSampler##type##ToGLEnum(samplerParams.internalName)](GLenum err) { \
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__, \
t = MG_Util::ConvertSampler##type##ToGLEnum(samplerParams.internalName)](GLenum err) { \
MGLOG_D("%s(%s:%d) ES error %s, GL_TEXTURE_MIN_FILTER = %s", func, file, line, \
MG_Util::ConvertGLEnumToString(err).c_str(), MG_Util::ConvertGLEnumToString(t).c_str()); \
}); \
}
if (m_cacheSamplerParameters.minFilter != samplerParams.minFilter) {
MG_External::GLES::glTexParameteri(target, GL_TEXTURE_MIN_FILTER,
MG_External::GLES::glTexParameteri(
target, GL_TEXTURE_MIN_FILTER,
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerParams.minFilter, samplerParams.mipmapMode));
m_cacheSamplerParameters.minFilter = samplerParams.minFilter;
m_cacheSamplerParameters.mipmapMode = samplerParams.mipmapMode;
}
if (m_cacheSamplerParameters.magFilter != samplerParams.magFilter) {
MG_External::GLES::glTexParameteri(target, GL_TEXTURE_MAG_FILTER,
MG_External::GLES::glTexParameteri(
target, GL_TEXTURE_MAG_FILTER,
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerParams.magFilter, SamplerMipmapMode::None));
m_cacheSamplerParameters.magFilter = samplerParams.magFilter;
}
@@ -385,8 +376,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
m_cacheSamplerParameters.maxLod = samplerParams.maxLod;
}
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
MGLOG_D("%s(%s:%d) ES error %s", func, file, line,
MG_Util::ConvertGLEnumToString(err).c_str());
MGLOG_D("%s(%s:%d) ES error %s", func, file, line, MG_Util::ConvertGLEnumToString(err).c_str());
});
#undef SYNC_TEX_SAMPLER_PARAM_IF_CHANGED
}
@@ -397,13 +387,11 @@ namespace MobileGL::MG_Backend::DirectGLES {
const auto& levelRange = stateTextureObject->GetLevelRange();
MG_External::GLES::glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, static_cast<GLint>(levelRange.x()));
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
MGLOG_D("%s(%s:%d) ES error %s", func, file, line,
MG_Util::ConvertGLEnumToString(err).c_str());
MGLOG_D("%s(%s:%d) ES error %s", func, file, line, MG_Util::ConvertGLEnumToString(err).c_str());
});
MG_External::GLES::glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, static_cast<GLint>(levelRange.y()));
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
MGLOG_D("%s(%s:%d) ES error %s", func, file, line,
MG_Util::ConvertGLEnumToString(err).c_str());
MGLOG_D("%s(%s:%d) ES error %s", func, file, line, MG_Util::ConvertGLEnumToString(err).c_str());
});
GLenum swizzleParams[4] = {MG_Util::ConvertTextureSwizzleParamToGLEnum(
stateTextureObject->GetSwizzleParam(TextureSwizzleParam::Red)),
@@ -416,13 +404,15 @@ namespace MobileGL::MG_Backend::DirectGLES {
MG_External::GLES::glTexParameteri(target, GL_TEXTURE_SWIZZLE_R,
MG_Util::ConvertTextureSwizzleParamToGLEnum(
stateTextureObject->GetSwizzleParam(TextureSwizzleParam::Red)));
MG_External::GLES::glTexParameteri(target, GL_TEXTURE_SWIZZLE_G,
MG_External::GLES::glTexParameteri(
target, GL_TEXTURE_SWIZZLE_G,
MG_Util::ConvertTextureSwizzleParamToGLEnum(
stateTextureObject->GetSwizzleParam(TextureSwizzleParam::Green)));
MG_External::GLES::glTexParameteri(target, GL_TEXTURE_SWIZZLE_B,
MG_Util::ConvertTextureSwizzleParamToGLEnum(
stateTextureObject->GetSwizzleParam(TextureSwizzleParam::Blue)));
MG_External::GLES::glTexParameteri(target, GL_TEXTURE_SWIZZLE_A,
MG_External::GLES::glTexParameteri(
target, GL_TEXTURE_SWIZZLE_A,
MG_Util::ConvertTextureSwizzleParamToGLEnum(
stateTextureObject->GetSwizzleParam(TextureSwizzleParam::Alpha)));
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__, swizzleParams](GLenum err) {
@@ -450,8 +440,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
continue;
}
auto byteSize = stateTextureObject->GetMipmapByteSize(
uploadTarget, level);
auto byteSize = stateTextureObject->GetMipmapByteSize(uploadTarget, level);
if (byteSize == 0) {
MGLOG_W("Mipmap level %d has no data, skipping update.", level);
continue;
@@ -462,18 +451,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
BufferImpl::BackendBufferBindingProtector pixelUnpackProtector =
BufferImpl::BackendBufferBindingProtector(GL_PIXEL_UNPACK_BUFFER);
MG_External::GLES::glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
errorLopper.Loop(
[file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
errorLopper.Loop([file = __FILE__, line = __LINE__, func = __func__](GLenum err) {
MGLOG_D("%s(%s:%d) ES error: %s", func, file, line,
MG_Util::ConvertGLEnumToString(err).c_str());
});
auto texelSize = stateTextureObject->GetMipmapTexelSize(
uploadTarget, level);
MG_External::GLES::glTexSubImage2D(glUploadTarget, static_cast<GLint>(level),
0, 0,
auto texelSize = stateTextureObject->GetMipmapTexelSize(uploadTarget, level);
MG_External::GLES::glTexSubImage2D(glUploadTarget, static_cast<GLint>(level), 0, 0,
static_cast<GLsizei>(texelSize.x()),
static_cast<GLsizei>(texelSize.y()),
glFormat, glType,
static_cast<GLsizei>(texelSize.y()), glFormat, glType,
stateTextureObject->MapMipmapData(uploadTarget, level));
stateTextureObject->MarkStorageDirty(uploadTarget, level, false);
@@ -551,13 +536,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
if (asTarget == FramebufferTarget::Draw) {
// Create mappings for draw buffers
int nBuffers = 0;
std::fill(m_frontendDrawBuffers, m_frontendDrawBuffers + MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS,
std::fill(m_frontendDrawBuffers,
m_frontendDrawBuffers + MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS,
FramebufferAttachmentType::None);
std::fill(m_compactedFrontendDrawBuffers,
m_compactedFrontendDrawBuffers + MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS,
FramebufferAttachmentType::None);
std::fill(m_backendDrawBuffers, m_backendDrawBuffers + MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS,
GL_NONE);
std::fill(m_backendDrawBuffers,
m_backendDrawBuffers + MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS, GL_NONE);
auto& stateDrawBuffers = stateFBOObject->GetDrawBuffers();
for (GLint i = 0; i < MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS; ++i) {
if (stateDrawBuffers[i] == FramebufferAttachmentType::None) {
@@ -583,12 +569,14 @@ namespace MobileGL::MG_Backend::DirectGLES {
// const auto& attachment = attachments[static_cast<SizeT>(frontendAttachmentType)];
// if (!attachment.IsTexture()) continue;
// const auto& textureObject = attachment.GetTexture();
// const auto& backendTextureIt = TextureImpl::g_backendTextureObjects.find(textureObject);
// if (backendTextureIt == TextureImpl::g_backendTextureObjects.end()) continue;
// const auto& backendTextureObject = backendTextureIt->second;
// auto glTextureTarget = MG_Util::ConvertTextureTargetToGLEnum(textureObject->GetTarget());
// const auto& backendTextureIt =
// TextureImpl::g_backendTextureObjects.find(textureObject); if (backendTextureIt ==
// TextureImpl::g_backendTextureObjects.end()) continue; const auto&
// backendTextureObject = backendTextureIt->second; auto glTextureTarget =
// MG_Util::ConvertTextureTargetToGLEnum(textureObject->GetTarget());
// backendTextureObject->Bind(glTextureTarget);
// MG_External::GLES::glFramebufferTexture2D(glFBOTarget, backendAttachment, glTextureTarget,
// MG_External::GLES::glFramebufferTexture2D(glFBOTarget, backendAttachment,
// glTextureTarget,
// backendTextureObject->GetBackendTextureId(),
// static_cast<GLint>(attachment.GetTextureLevel()));
// }
@@ -838,13 +826,15 @@ namespace MobileGL::MG_Backend::DirectGLES {
}
if (m_cacheSamplerParameters.minFilter != samplerParams.minFilter) {
MG_External::GLES::glSamplerParameteri(m_backendSamplerId, GL_TEXTURE_MIN_FILTER,
MG_External::GLES::glSamplerParameteri(
m_backendSamplerId, GL_TEXTURE_MIN_FILTER,
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerParams.minFilter, samplerParams.mipmapMode));
m_cacheSamplerParameters.minFilter = samplerParams.minFilter;
m_cacheSamplerParameters.mipmapMode = samplerParams.mipmapMode;
}
if (m_cacheSamplerParameters.magFilter != samplerParams.magFilter) {
MG_External::GLES::glSamplerParameteri(m_backendSamplerId, GL_TEXTURE_MAG_FILTER,
MG_External::GLES::glSamplerParameteri(
m_backendSamplerId, GL_TEXTURE_MAG_FILTER,
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerParams.magFilter, SamplerMipmapMode::None));
m_cacheSamplerParameters.magFilter = samplerParams.magFilter;
}
+5 -2
View File
@@ -99,13 +99,16 @@ namespace MobileGL::MG_Backend::DirectGLES {
Probably useful to re-link shader output according to this.
aka. realizing `glBindFragDataLocation`
*/
FramebufferAttachmentType m_frontendDrawBuffers[MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS] = {FramebufferAttachmentType::None};
FramebufferAttachmentType m_frontendDrawBuffers[MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS] = {
FramebufferAttachmentType::None};
/* this will save buffers in its compacted GL form,
not consecutive is not allowed
i.e. it could be like [COLOR_ATTACHMENT0, COLOR_ATTACHMENT5, COLOR_ATTACHMENT4]
(no GL_NONE among those)
*/
FramebufferAttachmentType m_compactedFrontendDrawBuffers[MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS] = {FramebufferAttachmentType::None};
FramebufferAttachmentType
m_compactedFrontendDrawBuffers[MG_State::GLState::FramebufferObject::MAX_DRAW_BUFFERS] = {
FramebufferAttachmentType::None};
/* this will save buffers in stricter ES rules
reversion, absence or not consecutive are not allowed, according to ES spec
i.e. it could be like [COLOR_ATTACHMENT0, COLOR_ATTACHMENT1, NONE, NONE, ...]
+2 -1
View File
@@ -11,7 +11,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
ErrorLopper();
~ErrorLopper();
};
}
} // namespace DebugImpl
namespace BufferImpl {
class BackendBufferBindingProtector {
@@ -66,6 +66,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
static GLuint GetTempFBO(FramebufferTarget target);
static void BindTempFBO(FramebufferTarget target);
private:
GLenum m_target;
GLint m_previousBinding = 0;
+5 -3
View File
@@ -434,8 +434,9 @@ namespace MobileGL {
}
void BufferData_State(GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
MGLOG_D("%s: %s, size = %d, data = %p, usage = %s",
__func__, MG_Util::ConvertGLEnumToString(target).c_str(), size, data, MG_Util::ConvertGLEnumToString(usage).c_str());
MGLOG_D("%s: %s, size = %d, data = %p, usage = %s", __func__,
MG_Util::ConvertGLEnumToString(target).c_str(), size, data,
MG_Util::ConvertGLEnumToString(usage).c_str());
if (size < 0) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidValue,
@@ -479,7 +480,8 @@ namespace MobileGL {
auto& bindingSlot = MG_State::pGLContext->GetBufferBindingSlot(bufferTarget);
bindingSlot.Bind(bufferObject);
MGLOG_D("%s: bind buffer object %p -> %s", __func__, bufferObject.get(), MG_Util::ConvertGLEnumToString(target).c_str());
MGLOG_D("%s: bind buffer object %p -> %s", __func__, bufferObject.get(),
MG_Util::ConvertGLEnumToString(target).c_str());
}
void GenBuffers_State(GLsizei n, GLuint* buffers) {
+3 -3
View File
@@ -55,9 +55,9 @@ namespace MobileGL {
if (rendererString.empty()) {
const char* backendStr = (const char*)GetString_Backend(GL_RENDERER);
const char* backendVersionStr = (const char*)GetString_Backend(GL_VERSION);
rendererString =
std::format("{} ({}) ({} | {})", MG_Config::RendererInfoPtr->RendererName.c_str(),
MG_Config::CoreName.c_str(), backendStr ? backendStr : "<unknown GPU>", backendVersionStr ? backendVersionStr : "<unknown version>");
rendererString = std::format("{} ({}) ({} | {})", MG_Config::RendererInfoPtr->RendererName.c_str(),
MG_Config::CoreName.c_str(), backendStr ? backendStr : "<unknown GPU>",
backendVersionStr ? backendVersionStr : "<unknown version>");
}
return (const GLubyte*)rendererString.c_str();
}
+2 -1
View File
@@ -52,7 +52,8 @@ namespace MobileGL {
GLuint GetUniformBlockIndex(GLuint program, const GLchar* uniformBlockName);
void UniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
void GetActiveUniformBlockiv(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint* params);
void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length, GLchar* uniformBlockName);
void GetActiveUniformBlockName(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei* length,
GLchar* uniformBlockName);
void BindFragDataLocation(GLuint program, GLuint colorNumber, const char* name);
GLint GetFragDataLocation(GLuint program, const char* name);
void ValidateProgram(GLuint program);
@@ -76,10 +76,12 @@ namespace MobileGL {
*(GLint*)params = MG_Util::ConvertSamplerWrapModeToGLEnum(samplerObj->GetWrapR());
break;
case GL_TEXTURE_MIN_FILTER:
*(GLint*)params = MG_Util::ConvertSamplerFilterModeToGLEnum(samplerObj->GetMinFilter(), samplerObj->GetMipmapMode());
*(GLint*)params =
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerObj->GetMinFilter(), samplerObj->GetMipmapMode());
break;
case GL_TEXTURE_MAG_FILTER:
*(GLint*)params = MG_Util::ConvertSamplerFilterModeToGLEnum(samplerObj->GetMagFilter(), SamplerMipmapMode::None);
*(GLint*)params =
MG_Util::ConvertSamplerFilterModeToGLEnum(samplerObj->GetMagFilter(), SamplerMipmapMode::None);
break;
case GL_TEXTURE_MIN_LOD:
*(GLfloat*)params = samplerObj->GetMinLod();
+12 -13
View File
@@ -384,8 +384,7 @@ namespace MobileGL {
textureObject->SetInternalFormat(textureInternalFormat);
// if isProxy, no more pixel transfer needed below
if (isProxy)
return;
if (isProxy) return;
const void* originalPixels = pixels;
@@ -409,8 +408,8 @@ namespace MobileGL {
void* processedPixels = nullptr;
processedPixels = MG_Util::PixelStoreProcessor::ProcessTexturePixelsDataUnpack(
originalPixels, MG_State::pGLContext->GetPixelStoreParameters(true), bytesPerPixel,
{width, height, 1}, false, imageSize);
originalPixels, MG_State::pGLContext->GetPixelStoreParameters(true), bytesPerPixel, {width, height, 1},
false, imageSize);
if (processedPixels && imageSize > 0) {
if (imageSize != totalBytes) {
@@ -475,14 +474,15 @@ namespace MobileGL {
switch (pname) {
case GL_TEXTURE_MAG_FILTER:
if (params) {
*params =
MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMagFilter(), SamplerMipmapMode::None);
*params = MG_Util::ConvertSamplerFilterModeToGLEnum(
textureObject->GetSamplerObject()->GetMagFilter(), SamplerMipmapMode::None);
}
break;
case GL_TEXTURE_MIN_FILTER:
if (params) {
*params =
MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMinFilter(), textureObject->GetSamplerObject()->GetMipmapMode());
MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMinFilter(),
textureObject->GetSamplerObject()->GetMipmapMode());
}
break;
case GL_TEXTURE_MIN_LOD:
@@ -555,14 +555,15 @@ namespace MobileGL {
switch (pname) {
case GL_TEXTURE_MAG_FILTER:
if (params) {
*params =
MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMagFilter(), SamplerMipmapMode::None);
*params = MG_Util::ConvertSamplerFilterModeToGLEnum(
textureObject->GetSamplerObject()->GetMagFilter(), SamplerMipmapMode::None);
}
break;
case GL_TEXTURE_MIN_FILTER:
if (params) {
*params =
MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMinFilter(), textureObject->GetSamplerObject()->GetMipmapMode());
MG_Util::ConvertSamplerFilterModeToGLEnum(textureObject->GetSamplerObject()->GetMinFilter(),
textureObject->GetSamplerObject()->GetMipmapMode());
}
break;
case GL_TEXTURE_MIN_LOD:
@@ -880,9 +881,7 @@ namespace MobileGL {
auto textureObject = MG_State::pGLContext->GetTextureObject(texture);
// ===================== Error Checking ==============================
if (textureTarget != TextureTarget::TextureCubeMap &&
!TextureImpl::ValidateTextureTargetUniformity(textureObject, textureTarget))
return;
if (!TextureImpl::ValidateTextureTargetUniformity(textureObject, textureTarget)) return;
// ======================= Processing ================================
if (!textureObject) {
@@ -12,8 +12,8 @@ namespace MobileGL {
BufferTarget::TransformFeedback, BufferTarget::AtomicCounter, BufferTarget::DispatchIndirect,
BufferTarget::DrawIndirect, BufferTarget::ShaderStorage);
constexpr const auto BufferBindPointTargets =
ToArray(BufferTarget::Uniform, BufferTarget::TransformFeedback,
BufferTarget::AtomicCounter, BufferTarget::ShaderStorage);
ToArray(BufferTarget::Uniform, BufferTarget::TransformFeedback, BufferTarget::AtomicCounter,
BufferTarget::ShaderStorage);
class BufferState {
public:
@@ -40,7 +40,8 @@ namespace MobileGL {
Array<BindingSlot<BufferObject>, GlobalBufferTargets.size()> m_bindingSlots;
// TODO: query the count somewhere globally?
// For glBindBufferBase / glBindBufferRange
Array<Array<BindingSlotRange1D<BufferObject>, 16>, BufferBindPointTargets.size()> m_bufferBindPointTargets;
Array<Array<BindingSlotRange1D<BufferObject>, 16>, BufferBindPointTargets.size()>
m_bufferBindPointTargets;
};
} // namespace GLState
} // namespace MG_State
@@ -106,7 +106,8 @@ namespace MobileGL {
Uint GetExternalIndex() const { return m_externalIndex; }
// const UnorderedMap<String, Uint>& GetAttribLocationMap() const { return m_attribLocation; }
// const UnorderedMap<String, Uint>& GetAttribLocationMap() const { return
// m_attribLocation; }
private:
void DoReflection();
@@ -36,6 +36,6 @@ namespace MobileGL {
Bool SamplerState::ValidateSamplerObject(Uint index) const {
return m_samplerObjects.find(index) != m_samplerObjects.end();
}
}
}
}
} // namespace GLState
} // namespace MG_State
} // namespace MobileGL
+6 -6
View File
@@ -931,10 +931,10 @@ TEST_F(ProgramTest, CompileAndLinkWithExplicitVertexIn) {
spvcSession.Compile(&result);
printf("%s\n\n", result);
const char* ret = strstr(result, needle);
if (ret)
pSrcVertIn = (char*)ret;
if (ret) pSrcVertIn = (char*)ret;
// }
ASSERT_TRUE(pSrcVertIn != nullptr) << "Not found expected string in generated shader.\n(Searching for \"" << needle << "\")";
ASSERT_TRUE(pSrcVertIn != nullptr) << "Not found expected string in generated shader.\n(Searching for \"" << needle
<< "\")";
}
TEST_F(ProgramTest, CompileAndLinkWithExplicitFragmentOut) {
@@ -992,8 +992,8 @@ TEST_F(ProgramTest, CompileAndLinkWithExplicitFragmentOut) {
spvcSession.Compile(&result);
printf("%s\n\n", result);
const char* ret = strstr(result, needle);
if (ret)
pSrcfragOut = (char*)ret;
if (ret) pSrcfragOut = (char*)ret;
// }
ASSERT_TRUE(pSrcfragOut != nullptr) << "Not found expected string in generated shader.\n(Searching for \"" << needle << "\")";
ASSERT_TRUE(pSrcfragOut != nullptr) << "Not found expected string in generated shader.\n(Searching for \"" << needle
<< "\")";
}
+1 -2
View File
@@ -396,8 +396,7 @@ TEST_F(ProgramUtilTest, CompileAndLinkBlitProgram) {
ProgramAttrib programAttrib{// .shaderTypes = { GL_VERTEX_SHADER, GL_FRAGMENT_SHADER },
.shaders = {vs_res.value(), fs_res.value()},
.explicitVertexInLocations = attribLocations
};
.explicitVertexInLocations = attribLocations};
auto program_res = ShaderCompiler::LinkProgram(programAttrib);
if (!program_res) {
@@ -181,10 +181,9 @@ namespace MobileGL {
// UniquePtr<glslang::TIoMapResolver> resolver;
UniquePtr<TMglGlslIoResolver> resolver;
for (unsigned stage = 0; stage < EShLangCount; stage++) {
if (program->getIntermediate((EShLanguage)stage) == nullptr)
continue;
resolver = MakeUnique<TMglGlslIoResolver>(*program, (EShLanguage)stage,
attrib.explicitVertexInLocations,
if (program->getIntermediate((EShLanguage)stage) == nullptr) continue;
resolver =
MakeUnique<TMglGlslIoResolver>(*program, (EShLanguage)stage, attrib.explicitVertexInLocations,
attrib.explicitFragmentOutLocations);
break;
}
@@ -66,7 +66,8 @@ namespace MobileGL {
SPVC_CHK_INIT
const spvc_reflected_resource* list = nullptr;
size_t count = 0;
SPVC_CHK_RESULT(spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_STAGE_INPUT, &list, &count));
SPVC_CHK_RESULT(spvc_resources_get_resource_list_for_type(resources, SPVC_RESOURCE_TYPE_STAGE_INPUT,
&list, &count));
for (size_t i = 0; i < count; ++i) {
auto& resource = list[i];
auto it = location.find(resource.name);
@@ -24,4 +24,4 @@ namespace MobileGL {
}
TDefaultGlslIoResolver::reserverStorageSlot(ent, infoSink);
}
}
} // namespace MobileGL
@@ -17,15 +17,16 @@ namespace MobileGL {
class TMglGlslIoResolver : public glslang::TDefaultGlslIoResolver {
public:
using ExplicitVarSlotMap = UnorderedMap<String, Uint>;
TMglGlslIoResolver(const glslang::TIntermediate& intermediate, const ExplicitVarSlotMap& vertexIns, const ExplicitVarSlotMap& fragOuts):
TDefaultGlslIoResolver(intermediate), m_explicitVertexIns(vertexIns), m_explicitFragOuts(fragOuts) {}
TMglGlslIoResolver(const glslang::TProgram& program, const EShLanguage stage, const ExplicitVarSlotMap& vertexIns, const ExplicitVarSlotMap& fragOuts):
TMglGlslIoResolver(*program.getIntermediate(stage), vertexIns, fragOuts) {}
TMglGlslIoResolver(const glslang::TIntermediate& intermediate, const ExplicitVarSlotMap& vertexIns,
const ExplicitVarSlotMap& fragOuts)
: TDefaultGlslIoResolver(intermediate), m_explicitVertexIns(vertexIns), m_explicitFragOuts(fragOuts) {}
TMglGlslIoResolver(const glslang::TProgram& program, const EShLanguage stage,
const ExplicitVarSlotMap& vertexIns, const ExplicitVarSlotMap& fragOuts)
: TMglGlslIoResolver(*program.getIntermediate(stage), vertexIns, fragOuts) {}
void reserverStorageSlot(glslang::TVarEntryInfo& ent, TInfoSink& infoSink) override;
protected:
const ExplicitVarSlotMap& m_explicitVertexIns;
const ExplicitVarSlotMap& m_explicitFragOuts;
};
}
} // namespace MobileGL
@@ -26,4 +26,4 @@ namespace glslang {
void clearNewAssignments();
};
}
} // namespace glslang