Changeset 276190 in webkit
- Timestamp:
- Apr 16, 2021, 7:06:15 PM (5 years ago)
- Location:
- trunk/Source/ThirdParty/ANGLE
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
src/libANGLE/renderer/metal/TextureMtl.mm (modified) (6 diffs)
-
src/libANGLE/renderer/metal/mtl_utils.mm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/ThirdParty/ANGLE/ChangeLog
r276104 r276190 1 2021-04-16 Kyle Piddington <kpiddington@apple.com> 2 3 Metal-ANGLE: Shared memory texture tests failing in iOS Simulator 4 https://bugs.webkit.org/show_bug.cgi?id=222685 5 6 Reviewed by Dean Jackson. 7 8 Simulator-only path drives filling textures via Blit encoders instead of mapped memory. 9 This workaround fixes dropped texture writes when using replaceRegion 10 11 * src/libANGLE/renderer/metal/TextureMtl.mm: 12 * src/libANGLE/renderer/metal/mtl_utils.mm: 13 (rx::mtl::InitializeTextureContents): 14 1 15 2021-04-15 Alex Christensen <achristensen@webkit.org> 2 16 -
trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/TextureMtl.mm
r275649 r276190 175 175 } 176 176 177 178 #if TARGET_OS_SIMULATOR 179 void CopyTextureData(const MTLSize ®ionSize, 180 size_t srcRowPitch, 181 size_t src2DImageSize, 182 const uint8_t *psrc, 183 size_t destRowPitch, 184 size_t dest2DImageSize, 185 uint8_t *pdst) 186 { 187 { 188 size_t rowCopySize = std::min(srcRowPitch, destRowPitch); 189 for (NSUInteger d = 0; d < regionSize.depth; ++d) 190 { 191 for (NSUInteger r = 0; r < regionSize.height; ++r) 192 { 193 const uint8_t *pCopySrc = psrc + d * src2DImageSize + r * srcRowPitch; 194 uint8_t *pCopyDst = pdst + d * dest2DImageSize + r * destRowPitch; 195 memcpy(pCopyDst, pCopySrc, rowCopySize); 196 } 197 } 198 } 199 } 200 #endif 201 177 202 void ConvertDepthStencilData(const MTLSize ®ionSize, 178 203 const angle::Format &srcAngleFormat, … … 266 291 return angle::Result::Continue; 267 292 } 293 294 #if TARGET_OS_SIMULATOR 295 angle::Result CopyTextureContentsToStagingBuffer( 296 ContextMtl *contextMtl, 297 const angle::Format &textureAngleFormat, 298 const MTLSize ®ionSize, 299 const uint8_t *data, 300 size_t bytesPerRow, 301 size_t bytesPer2DImage, 302 size_t *bufferRowPitchOut, 303 size_t *buffer2DImageSizeOut, 304 mtl::BufferRef *bufferOut) 305 { 306 size_t stagingBufferRowPitch = regionSize.width * textureAngleFormat.pixelBytes; 307 size_t stagingBuffer2DImageSize = stagingBufferRowPitch * regionSize.height; 308 size_t stagingBufferSize = stagingBuffer2DImageSize * regionSize.depth; 309 mtl::BufferRef stagingBuffer; 310 ANGLE_TRY(mtl::Buffer::MakeBuffer(contextMtl, stagingBufferSize, nullptr, &stagingBuffer)); 311 312 uint8_t *pdst = stagingBuffer->map(contextMtl); 313 314 CopyTextureData(regionSize, bytesPerRow, bytesPer2DImage, 315 data, stagingBufferRowPitch, stagingBuffer2DImageSize, pdst); 316 317 stagingBuffer->unmap(contextMtl); 318 319 *bufferOut = stagingBuffer; 320 *bufferRowPitchOut = stagingBufferRowPitch; 321 *buffer2DImageSizeOut = stagingBuffer2DImageSize; 322 323 return angle::Result::Continue; 324 } 325 #endif 268 326 269 327 angle::Result UploadDepthStencilTextureContentsWithStagingBuffer( … … 379 437 } 380 438 439 #if TARGET_OS_SIMULATOR 440 angle::Result UploadTextureContentsWithStagingBuffer( 441 ContextMtl *contextMtl, 442 const angle::Format &textureAngleFormat, 443 MTLRegion region, 444 const mtl::MipmapNativeLevel &mipmapLevel, 445 uint32_t slice, 446 const uint8_t *data, 447 size_t bytesPerRow, 448 size_t bytesPer2DImage, 449 const mtl::TextureRef &texture) 450 { 451 ASSERT(texture && texture->valid()); 452 453 angle::FormatID stagingBufferFormatID = textureAngleFormat.id; 454 const angle::Format &angleStagingFormat = angle::Format::Get(stagingBufferFormatID); 455 456 457 size_t stagingBufferRowPitch; 458 size_t stagingBuffer2DImageSize; 459 mtl::BufferRef stagingBuffer; 460 461 // Copy depth data to staging depth buffer 462 ANGLE_TRY(CopyTextureContentsToStagingBuffer(contextMtl, angleStagingFormat, region.size, data, bytesPerRow, bytesPer2DImage, &stagingBufferRowPitch, &stagingBuffer2DImageSize, &stagingBuffer)); 463 mtl::BlitCommandEncoder *encoder = contextMtl->getBlitCommandEncoder(); 464 465 encoder->copyBufferToTexture(stagingBuffer, 0, stagingBufferRowPitch, 466 stagingBuffer2DImageSize, region.size, texture, slice, 467 mipmapLevel, region.origin, 0); 468 469 470 return angle::Result::Continue; 471 } 472 #endif 473 381 474 angle::Result UploadTextureContents(const gl::Context *context, 382 475 const angle::Format &textureAngleFormat, … … 391 484 ASSERT(texture && texture->valid()); 392 485 ContextMtl *contextMtl = mtl::GetImpl(context); 393 486 #if TARGET_OS_SIMULATOR 487 if (!textureAngleFormat.depthBits && !textureAngleFormat.stencilBits) 488 { 489 ANGLE_TRY(UploadTextureContentsWithStagingBuffer(contextMtl,textureAngleFormat,region,mipmapLevel,slice,data,bytesPerRow,bytesPer2DImage,texture)); 490 return angle::Result::Continue; 491 } 492 #else 394 493 if (texture->isCPUAccessible()) 395 494 { … … 400 499 return angle::Result::Continue; 401 500 } 402 501 #endif 403 502 ASSERT(textureAngleFormat.depthBits || textureAngleFormat.stencilBits); 404 503 … … 418 517 419 518 return angle::Result::Continue; 519 420 520 } 421 521 -
trunk/Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_utils.mm
r275476 r276190 114 114 const angle::Format &actualAngleFormat = textureObjFormat.actualAngleFormat(); 115 115 const gl::InternalFormat &intendedInternalFormat = textureObjFormat.intendedInternalFormat(); 116 116 bool forceGPUInitialization = false; 117 #if TARGET_OS_SIMULATOR 118 forceGPUInitialization = true; 119 #endif 117 120 // This function is called in many places to initialize the content of a texture. 118 121 // So it's better we do the sanity check here instead of let the callers do it themselves: … … 149 152 150 153 if (texture->isCPUAccessible() && index.getType() != gl::TextureType::_2DMultisample && 151 index.getType() != gl::TextureType::_2DMultisampleArray )154 index.getType() != gl::TextureType::_2DMultisampleArray && forceGPUInitialization == false) 152 155 { 153 156 const angle::Format &dstFormat = angle::Format::Get(textureObjFormat.actualFormatId); … … 199 202 } 200 203 } // if (texture->isCPUAccessible()) 204 201 205 else 202 206 {
Note:
See TracChangeset
for help on using the changeset viewer.