mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 20:28:32 +09:00
[Fix] (MG_Impl/Texture): read PBO if pixels == NULL at TexSubImage2D
This commit is contained in:
@@ -52,7 +52,9 @@ namespace MobileGL {
|
||||
TextureInputFormat textureInputFormat = MG_Util::ConvertGLEnumToTextureInputFormat(format);
|
||||
TexturePixelDataType texturePixelDataType = MG_Util::ConvertGLEnumToTexturePixelDataType(type);
|
||||
// TextureInternalFormat textureInternalFormat = MG_Util::ConvertGLEnumToTextureInternalFormat(format);
|
||||
|
||||
MGLOG_D("TexSubImage2D_State: (%d, %d), format = %s, pixels = %p", width, height,
|
||||
MG_Util::ConvertTextureInputFormatToString(textureInputFormat).c_str(),
|
||||
pixels);
|
||||
// ===================== Error Checking ==============================
|
||||
if (!TextureImpl::ValidateTexturePixelDataType(texturePixelDataType)) return;
|
||||
if (!TextureImpl::ValidateTextureInputFormat(textureInputFormat)) return;
|
||||
@@ -61,7 +63,6 @@ namespace MobileGL {
|
||||
if (!TextureImpl::ValidateTextureSizeWithTextureUploadTarget(textureUploadingTarget, width, height)) return;
|
||||
if (!TextureImpl::ValidateTextureSizeRange(width, height)) return;
|
||||
if (!TextureImpl::ValidateTextureLevelWithUploadTarget(textureUploadingTarget, level)) return;
|
||||
if (!pixels) return;
|
||||
|
||||
// TODO: GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the
|
||||
// GL_PIXEL_UNPACK_BUFFER target and the buffer object's data store is currently mapped.
|
||||
@@ -108,6 +109,13 @@ namespace MobileGL {
|
||||
originalPixels = reinterpret_cast<const char*>(pixelUnpackBufferObject->GetDataReadOnly()->data()) +
|
||||
reinterpret_cast<SizeT>(pixels);
|
||||
}
|
||||
|
||||
if (!originalPixels) {
|
||||
MG_State::pGLContext->RecordError(
|
||||
ErrorCode::InvalidOperation,
|
||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__, "No data supplied from pixels parameter and no PBO bound."));
|
||||
return;
|
||||
}
|
||||
|
||||
void* processedPixels = MG_Util::PixelStoreProcessor::ProcessTexturePixelsDataUnpack(
|
||||
originalPixels, MG_State::pGLContext->GetPixelStoreParameters(true), textureInternalFormat, textureInputFormat, texturePixelDataType, {width, height, 1},
|
||||
|
||||
Reference in New Issue
Block a user