[Perf] (Texture|State): Replace dynamic_cast hot paths with static_cast.

This commit is contained in:
BZLZHH
2026-02-24 15:40:06 +08:00
parent 8320b4f456
commit fff00e65c4
6 changed files with 41 additions and 40 deletions
-1
View File
@@ -62,7 +62,6 @@ cert-str34-c,
cppcoreguidelines-interfaces-global-init, cppcoreguidelines-interfaces-global-init,
cppcoreguidelines-narrowing-conversions, cppcoreguidelines-narrowing-conversions,
cppcoreguidelines-pro-type-member-init, cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-pro-type-static-cast-downcast,
cppcoreguidelines-slicing, cppcoreguidelines-slicing,
google-default-arguments, google-default-arguments,
google-runtime-operator, google-runtime-operator,
@@ -1403,7 +1403,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
return; return;
} }
auto* textureMipmapObject = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()); auto* textureMipmapObject = static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
auto& levelRange = textureMipmapObject->GetLevelRange(); auto& levelRange = textureMipmapObject->GetLevelRange();
MGLOG_D("GetTexImage: mipmap level range = [%d, %d)", levelRange.x(), levelRange.y()); MGLOG_D("GetTexImage: mipmap level range = [%d, %d)", levelRange.x(), levelRange.y());
+2 -2
View File
@@ -391,7 +391,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
switch (stateTextureObject->GetStorageType()) { switch (stateTextureObject->GetStorageType()) {
case TextureStorageType::Mipmap: { case TextureStorageType::Mipmap: {
auto* textureMipmapObject = auto* textureMipmapObject =
dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(stateTextureObject.get()); static_cast<MG_State::GLState::TextureObjectMipmap*>(stateTextureObject.get());
const auto mipmapCount = textureMipmapObject->GetMipmapLevelCount(); const auto mipmapCount = textureMipmapObject->GetMipmapLevelCount();
currentTextureInfo.mipmapLevels = mipmapCount; currentTextureInfo.mipmapLevels = mipmapCount;
@@ -515,7 +515,7 @@ namespace MobileGL::MG_Backend::DirectGLES {
} }
case TextureStorageType::Buffer: { case TextureStorageType::Buffer: {
auto* textureBufferObject = auto* textureBufferObject =
dynamic_cast<MG_State::GLState::TextureObjectBuffer*>(stateTextureObject.get()); static_cast<MG_State::GLState::TextureObjectBuffer*>(stateTextureObject.get());
auto& slot = textureBufferObject->GetBufferBindingSlot(); auto& slot = textureBufferObject->GetBufferBindingSlot();
auto& buffer = slot.GetBoundObject(); auto& buffer = slot.GetBoundObject();
auto bufferIndex = buffer->GetExternalIndex(); auto bufferIndex = buffer->GetExternalIndex();
@@ -145,7 +145,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
return false; return false;
} }
const auto* mipTexture = dynamic_cast<const MG_State::GLState::TextureObjectMipmap*>(&texture); const auto* mipTexture = static_cast<const MG_State::GLState::TextureObjectMipmap*>(&texture);
if (!mipTexture) { if (!mipTexture) {
return false; return false;
} }
@@ -198,7 +198,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
imageInfo.format = format; imageInfo.format = format;
imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL; imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
imageInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; imageInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
imageInfo.usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; imageInfo.usage =
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
imageInfo.samples = VK_SAMPLE_COUNT_1_BIT; imageInfo.samples = VK_SAMPLE_COUNT_1_BIT;
imageInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; imageInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
VK_VERIFY(vkCreateImage(m_device, &imageInfo, nullptr, &resource.image), "vkCreateImage(texture)"); VK_VERIFY(vkCreateImage(m_device, &imageInfo, nullptr, &resource.image), "vkCreateImage(texture)");
@@ -257,9 +258,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
VkMemoryAllocateInfo allocInfo{}; VkMemoryAllocateInfo allocInfo{};
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
allocInfo.allocationSize = requirements.size; allocInfo.allocationSize = requirements.size;
allocInfo.memoryTypeIndex = allocInfo.memoryTypeIndex = FindMemoryType(
FindMemoryType(requirements.memoryTypeBits, requirements.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
VK_VERIFY(vkAllocateMemory(m_device, &allocInfo, nullptr, &stagingMemory), "vkAllocateMemory(staging texture)"); VK_VERIFY(vkAllocateMemory(m_device, &allocInfo, nullptr, &stagingMemory), "vkAllocateMemory(staging texture)");
VK_VERIFY(vkBindBufferMemory(m_device, stagingBuffer, stagingMemory, 0), "vkBindBufferMemory(staging texture)"); VK_VERIFY(vkBindBufferMemory(m_device, stagingBuffer, stagingMemory, 0), "vkBindBufferMemory(staging texture)");
@@ -296,8 +296,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
copy.imageSubresource.layerCount = 1; copy.imageSubresource.layerCount = 1;
copy.imageOffset = {0, 0, 0}; copy.imageOffset = {0, 0, 0};
copy.imageExtent = {resource.extent.width, resource.extent.height, 1}; copy.imageExtent = {resource.extent.width, resource.extent.height, 1};
vkCmdCopyBufferToImage(commandBuffer, stagingBuffer, resource.image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, vkCmdCopyBufferToImage(commandBuffer, stagingBuffer, resource.image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
&copy); 1, &copy);
VkImageMemoryBarrier toSampled{}; VkImageMemoryBarrier toSampled{};
toSampled.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; toSampled.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
@@ -313,8 +313,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
toSampled.subresourceRange.levelCount = 1; toSampled.subresourceRange.levelCount = 1;
toSampled.subresourceRange.baseArrayLayer = 0; toSampled.subresourceRange.baseArrayLayer = 0;
toSampled.subresourceRange.layerCount = 1; toSampled.subresourceRange.layerCount = 1;
vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
0, nullptr, 0, nullptr, 1, &toSampled); 0, 0, nullptr, 0, nullptr, 1, &toSampled);
}); });
vkDestroyBuffer(m_device, stagingBuffer, nullptr); vkDestroyBuffer(m_device, stagingBuffer, nullptr);
@@ -378,7 +378,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
Bool VkTextureSamplerManager::ResolveLevel0(const MG_State::GLState::ITextureObject& texture, Bool VkTextureSamplerManager::ResolveLevel0(const MG_State::GLState::ITextureObject& texture,
TextureUploadTarget& outTarget, IntVec3& outTexelSize, TextureUploadTarget& outTarget, IntVec3& outTexelSize,
SizeT& outByteSize) { SizeT& outByteSize) {
const auto* mipTexture = dynamic_cast<const MG_State::GLState::TextureObjectMipmap*>(&texture); const auto* mipTexture = static_cast<const MG_State::GLState::TextureObjectMipmap*>(&texture);
if (!mipTexture) { if (!mipTexture) {
return false; return false;
} }
@@ -435,7 +435,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
samplerInfo.mipLodBias = sampler.GetLodBias(); samplerInfo.mipLodBias = sampler.GetLodBias();
samplerInfo.anisotropyEnable = VK_FALSE; samplerInfo.anisotropyEnable = VK_FALSE;
samplerInfo.maxAnisotropy = 1.0f; samplerInfo.maxAnisotropy = 1.0f;
samplerInfo.compareEnable = sampler.GetCompareMode() == SamplerCompareMode::CompareToTexture ? VK_TRUE : VK_FALSE; samplerInfo.compareEnable =
sampler.GetCompareMode() == SamplerCompareMode::CompareToTexture ? VK_TRUE : VK_FALSE;
samplerInfo.compareOp = ToVkCompareOp(sampler.GetSamplerCompareFunc()); samplerInfo.compareOp = ToVkCompareOp(sampler.GetSamplerCompareFunc());
samplerInfo.minLod = sampler.GetMinLod(); samplerInfo.minLod = sampler.GetMinLod();
samplerInfo.maxLod = sampler.GetMaxLod(); samplerInfo.maxLod = sampler.GetMaxLod();
@@ -531,10 +532,12 @@ namespace MobileGL::MG_Backend::DirectVulkan {
VkMemoryAllocateInfo imageAllocInfo{}; VkMemoryAllocateInfo imageAllocInfo{};
imageAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; imageAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
imageAllocInfo.allocationSize = imageMemReq.size; imageAllocInfo.allocationSize = imageMemReq.size;
imageAllocInfo.memoryTypeIndex = FindMemoryType(imageMemReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); imageAllocInfo.memoryTypeIndex =
FindMemoryType(imageMemReq.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
VK_VERIFY(vkAllocateMemory(m_device, &imageAllocInfo, nullptr, &m_fallbackImageMemory), VK_VERIFY(vkAllocateMemory(m_device, &imageAllocInfo, nullptr, &m_fallbackImageMemory),
"vkAllocateMemory(fallback)"); "vkAllocateMemory(fallback)");
VK_VERIFY(vkBindImageMemory(m_device, m_fallbackImage, m_fallbackImageMemory, 0), "vkBindImageMemory(fallback)"); VK_VERIFY(vkBindImageMemory(m_device, m_fallbackImage, m_fallbackImageMemory, 0),
"vkBindImageMemory(fallback)");
VkBuffer stagingBuffer = VK_NULL_HANDLE; VkBuffer stagingBuffer = VK_NULL_HANDLE;
VkDeviceMemory stagingMemory = VK_NULL_HANDLE; VkDeviceMemory stagingMemory = VK_NULL_HANDLE;
@@ -552,9 +555,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
VkMemoryAllocateInfo stagingAllocInfo{}; VkMemoryAllocateInfo stagingAllocInfo{};
stagingAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; stagingAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
stagingAllocInfo.allocationSize = stagingMemReq.size; stagingAllocInfo.allocationSize = stagingMemReq.size;
stagingAllocInfo.memoryTypeIndex = stagingAllocInfo.memoryTypeIndex = FindMemoryType(
FindMemoryType(stagingMemReq.memoryTypeBits, stagingMemReq.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
VK_VERIFY(vkAllocateMemory(m_device, &stagingAllocInfo, nullptr, &stagingMemory), "vkAllocateMemory(fallback)"); VK_VERIFY(vkAllocateMemory(m_device, &stagingAllocInfo, nullptr, &stagingMemory), "vkAllocateMemory(fallback)");
VK_VERIFY(vkBindBufferMemory(m_device, stagingBuffer, stagingMemory, 0), "vkBindBufferMemory(fallback)"); VK_VERIFY(vkBindBufferMemory(m_device, stagingBuffer, stagingMemory, 0), "vkBindBufferMemory(fallback)");
@@ -587,8 +589,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
copy.imageSubresource.baseArrayLayer = 0; copy.imageSubresource.baseArrayLayer = 0;
copy.imageSubresource.layerCount = 1; copy.imageSubresource.layerCount = 1;
copy.imageExtent = {1, 1, 1}; copy.imageExtent = {1, 1, 1};
vkCmdCopyBufferToImage(commandBuffer, stagingBuffer, m_fallbackImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, vkCmdCopyBufferToImage(commandBuffer, stagingBuffer, m_fallbackImage, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
&copy); 1, &copy);
VkImageMemoryBarrier toSampled{}; VkImageMemoryBarrier toSampled{};
toSampled.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; toSampled.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
@@ -604,8 +606,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
toSampled.subresourceRange.levelCount = 1; toSampled.subresourceRange.levelCount = 1;
toSampled.subresourceRange.baseArrayLayer = 0; toSampled.subresourceRange.baseArrayLayer = 0;
toSampled.subresourceRange.layerCount = 1; toSampled.subresourceRange.layerCount = 1;
vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, vkCmdPipelineBarrier(commandBuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
0, nullptr, 0, nullptr, 1, &toSampled); 0, 0, nullptr, 0, nullptr, 1, &toSampled);
}); });
vkDestroyBuffer(m_device, stagingBuffer, nullptr); vkDestroyBuffer(m_device, stagingBuffer, nullptr);
+14 -14
View File
@@ -103,9 +103,9 @@ namespace MobileGL::MG_Impl::GLImpl {
// Assert this for extra safety. // Assert this for extra safety.
// This should automatically compiled out in release, // This should automatically compiled out in release,
// so that we don't take the perf hit of dyn-cast. // so that we don't take the perf hit of dyn-cast.
MOBILEGL_ASSERT(nullptr != dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()), MOBILEGL_ASSERT(nullptr != static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()),
"Texture object here should always be an object with mipmap"); "Texture object here should always be an object with mipmap");
auto textureMipmapObject = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()); auto textureMipmapObject = static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
auto texelSize = textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level); auto texelSize = textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level);
SizeT inputSize = 0; SizeT inputSize = 0;
@@ -569,9 +569,9 @@ namespace MobileGL::MG_Impl::GLImpl {
reinterpret_cast<SizeT>(pixels); reinterpret_cast<SizeT>(pixels);
} }
MOBILEGL_ASSERT(nullptr != dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()), MOBILEGL_ASSERT(nullptr != static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()),
"Texture object here should always be an object with mipmap"); "Texture object here should always be an object with mipmap");
auto textureMipmapObject = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()); auto textureMipmapObject = static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
// Allocate in TextureObject // Allocate in TextureObject
textureMipmapObject->AllocateStorage(textureUploadTarget, level, {{width, height, depth}, internalBytes}); textureMipmapObject->AllocateStorage(textureUploadTarget, level, {{width, height, depth}, internalBytes});
@@ -686,9 +686,9 @@ namespace MobileGL::MG_Impl::GLImpl {
reinterpret_cast<SizeT>(pixels); reinterpret_cast<SizeT>(pixels);
} }
MOBILEGL_ASSERT(nullptr != dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()), MOBILEGL_ASSERT(nullptr != static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()),
"Texture object here should always be an object with mipmap"); "Texture object here should always be an object with mipmap");
auto textureMipmapObject = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()); auto textureMipmapObject = static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
// Allocate in TextureObject // Allocate in TextureObject
MGLOG_D("%s: Allocating %d bytes at mip %d", __func__, internalBytes, level); MGLOG_D("%s: Allocating %d bytes at mip %d", __func__, internalBytes, level);
@@ -764,7 +764,7 @@ namespace MobileGL::MG_Impl::GLImpl {
// ======================= Processing ================================ // ======================= Processing ================================
// Now we can rest assured, and down-cast texture object to texture buffer // Now we can rest assured, and down-cast texture object to texture buffer
auto* texBufferObject = dynamic_cast<MG_State::GLState::TextureObjectBuffer*>(textureObject.get()); auto* texBufferObject = static_cast<MG_State::GLState::TextureObjectBuffer*>(textureObject.get());
auto& bufferSlot = texBufferObject->GetBufferBindingSlot(); auto& bufferSlot = texBufferObject->GetBufferBindingSlot();
bufferSlot.Bind(bufferObject); bufferSlot.Bind(bufferObject);
@@ -978,7 +978,7 @@ namespace MobileGL::MG_Impl::GLImpl {
switch (textureObject->GetStorageType()) { switch (textureObject->GetStorageType()) {
case TextureStorageType::Mipmap: { case TextureStorageType::Mipmap: {
const auto textureMipmapObject = const auto textureMipmapObject =
dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()); static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
*params = textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level).x(); *params = textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level).x();
break; break;
} }
@@ -992,7 +992,7 @@ namespace MobileGL::MG_Impl::GLImpl {
switch (textureObject->GetStorageType()) { switch (textureObject->GetStorageType()) {
case TextureStorageType::Mipmap: { case TextureStorageType::Mipmap: {
const auto textureMipmapObject = const auto textureMipmapObject =
dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()); static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
*params = textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level).y(); *params = textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level).y();
break; break;
} }
@@ -1006,7 +1006,7 @@ namespace MobileGL::MG_Impl::GLImpl {
switch (textureObject->GetStorageType()) { switch (textureObject->GetStorageType()) {
case TextureStorageType::Mipmap: { case TextureStorageType::Mipmap: {
const auto textureMipmapObject = const auto textureMipmapObject =
dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()); static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
*params = textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level).z(); *params = textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level).z();
break; break;
} }
@@ -1067,7 +1067,7 @@ namespace MobileGL::MG_Impl::GLImpl {
switch (textureObject->GetStorageType()) { switch (textureObject->GetStorageType()) {
case TextureStorageType::Mipmap: { case TextureStorageType::Mipmap: {
const auto textureMipmapObject = const auto textureMipmapObject =
dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()); static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
*params = (GLfloat)textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level).x(); *params = (GLfloat)textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level).x();
break; break;
} }
@@ -1081,7 +1081,7 @@ namespace MobileGL::MG_Impl::GLImpl {
switch (textureObject->GetStorageType()) { switch (textureObject->GetStorageType()) {
case TextureStorageType::Mipmap: { case TextureStorageType::Mipmap: {
const auto textureMipmapObject = const auto textureMipmapObject =
dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()); static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
*params = (GLfloat)textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level).y(); *params = (GLfloat)textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level).y();
break; break;
} }
@@ -1095,7 +1095,7 @@ namespace MobileGL::MG_Impl::GLImpl {
switch (textureObject->GetStorageType()) { switch (textureObject->GetStorageType()) {
case TextureStorageType::Mipmap: { case TextureStorageType::Mipmap: {
const auto textureMipmapObject = const auto textureMipmapObject =
dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()); static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
*params = (GLfloat)textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level).z(); *params = (GLfloat)textureMipmapObject->GetMipmapTexelSize(textureUploadTarget, level).z();
break; break;
} }
@@ -1441,7 +1441,7 @@ namespace MobileGL::MG_Impl::GLImpl {
// Check for multisampling // Check for multisampling
if (textureObject->GetStorageType() == TextureStorageType::Mipmap) { if (textureObject->GetStorageType() == TextureStorageType::Mipmap) {
auto mipmapObject = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get()); auto mipmapObject = static_cast<MG_State::GLState::TextureObjectMipmap*>(textureObject.get());
if (mipmapObject->GetMipmapLevelCount() > 1) { if (mipmapObject->GetMipmapLevelCount() > 1) {
MG_State::pGLContext->RecordError( MG_State::pGLContext->RecordError(
ErrorCode::InvalidOperation, ErrorCode::InvalidOperation,
@@ -60,9 +60,9 @@ namespace MobileGL::MG_State::GLState {
IntVec3 FramebufferAttachmentObject::GetSize() const { IntVec3 FramebufferAttachmentObject::GetSize() const {
if (IsTexture()) { if (IsTexture()) {
// TODO: get correct upload target // TODO: get correct upload target
MOBILEGL_ASSERT(nullptr != dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(m_texture.get()), MOBILEGL_ASSERT(nullptr != static_cast<MG_State::GLState::TextureObjectMipmap*>(m_texture.get()),
"Texture object here should always be an object with mipmap"); "Texture object here should always be an object with mipmap");
auto textureMipmapObject = dynamic_cast<MG_State::GLState::TextureObjectMipmap*>(m_texture.get()); auto textureMipmapObject = static_cast<MG_State::GLState::TextureObjectMipmap*>(m_texture.get());
return textureMipmapObject->GetMipmapTexelSize(TextureUploadTarget::Texture2D, m_textureLevel); return textureMipmapObject->GetMipmapTexelSize(TextureUploadTarget::Texture2D, m_textureLevel);
} else if (IsRenderbuffer()) { } else if (IsRenderbuffer()) {
return {m_renderbuffer->GetWidth(), m_renderbuffer->GetHeight(), 1}; return {m_renderbuffer->GetWidth(), m_renderbuffer->GetHeight(), 1};