@@ -572,26 +572,26 @@ FenceStatus WebGPUDriver::getFenceStatus(Handle<HwFence> fenceHandle) {
572
572
// We create all textures using VK_IMAGE_TILING_OPTIMAL, so our definition of "supported" is that
573
573
// the GPU supports the given texture format with non-zero optimal tiling features.
574
574
bool WebGPUDriver::isTextureFormatSupported (const TextureFormat format) {
575
- return WebGPUTexture::fToWGPUTextureFormat (format) != wgpu::TextureFormat::Undefined;
575
+ return toWGPUTextureFormat (format) != wgpu::TextureFormat::Undefined;
576
576
}
577
577
578
578
bool WebGPUDriver::isTextureSwizzleSupported () {
579
579
return false ;
580
580
}
581
581
582
582
bool WebGPUDriver::isTextureFormatMipmappable (const TextureFormat format) {
583
+ const wgpu::TextureFormat webGpuFormat{ toWGPUTextureFormat (format) };
583
584
// passing 2D and sampleCount 1 to only check the format
584
585
const WebGPURenderPassMipmapGenerator::FormatCompatibility renderPassCompatibility{
585
- WebGPURenderPassMipmapGenerator::getCompatibilityFor (
586
- WebGPUTexture::fToWGPUTextureFormat (format), wgpu::TextureDimension::e2D, 1 )
586
+ WebGPURenderPassMipmapGenerator::getCompatibilityFor (webGpuFormat,
587
+ wgpu::TextureDimension::e2D, 1 )
587
588
};
588
589
589
590
if (renderPassCompatibility.compatible ) {
590
591
return true ;
591
592
}
592
593
593
- return WebGPUTexture::supportsMultipleMipLevelsViaStorageBinding (
594
- WebGPUTexture::fToWGPUTextureFormat (format));
594
+ return WebGPUTexture::supportsMultipleMipLevelsViaStorageBinding (webGpuFormat);
595
595
}
596
596
597
597
bool WebGPUDriver::isRenderTargetFormatSupported (const TextureFormat format) {
@@ -768,34 +768,33 @@ void WebGPUDriver::update3DImage(Handle<HwTexture> textureHandle, const uint32_t
768
768
scheduleDestroy (std::move (pixelBufferDescriptor));
769
769
return ;
770
770
}
771
-
772
771
const wgpu::TextureFormat inputPixelFormat{ toWebGPUFormat (inputData->format ,
773
772
inputData->type ) };
774
- const wgpu::TextureFormat outputLinearFormat{ toWebGPULinearFormat (
773
+ const wgpu::TextureFormat outputLinearFormat{ toLinearFormat (
775
774
texture->getTexture ().GetFormat ()) };
776
775
const bool conversionNecessary{
777
776
inputPixelFormat != outputLinearFormat && inputData->type != PixelDataType::COMPRESSED
778
777
}; // compressed formats should never need conversion
779
778
const bool doBlit{ conversionNecessary };
780
- #if FWGPU_ENABLED(FWGPU_DEBUG_VALIDATION)
781
- if (texture->width > 1000 && texture->height > 500 ) {
782
- FWGPU_LOGD << " Update3DImage(..., level=" << level << " , xoffset=" << xoffset
783
- << " , yoffset=" << yoffset << " , zoffset=" << zoffset << " , width=" << width
784
- << " , height=" << height << " , depth=" << depth << " , ...):" ;
785
- FWGPU_LOGD << " PixelBufferDescriptor format (input): " << toString (inputData->format );
786
- FWGPU_LOGD << " PixelBufferDescriptor type (input): " << toString (inputData->type );
787
- FWGPU_LOGD << " Pixel WebGPUFormat (input): "
788
- << webGPUTextureFormatToString (inputPixelFormat);
789
- FWGPU_LOGD << " Texture View format (output): "
790
- << webGPUTextureFormatToString (texture->getViewFormat ());
791
- FWGPU_LOGD << " Texture format (output): "
792
- << webGPUTextureFormatToString (texture->getTexture ().GetFormat ());
793
- FWGPU_LOGD << " Linear Texture format (output): "
794
- << webGPUTextureFormatToString (outputLinearFormat);
795
- FWGPU_LOGD << " Conversion Necessary: " << conversionNecessary;
796
- FWGPU_LOGD << " Do Blit: " << doBlit;
797
- }
798
- #endif
779
+ // #if FWGPU_ENABLED(FWGPU_DEBUG_VALIDATION)
780
+ // if (texture->width > 1000 && texture->height > 500) {
781
+ // FWGPU_LOGD << "Update3DImage(..., level=" << level << ", xoffset=" << xoffset
782
+ // << ", yoffset=" << yoffset << ", zoffset=" << zoffset << ", width=" << width
783
+ // << ", height=" << height << ", depth=" << depth << ", ...):";
784
+ // FWGPU_LOGD << " PixelBufferDescriptor format (input): " << toString(inputData->format);
785
+ // FWGPU_LOGD << " PixelBufferDescriptor type (input): " << toString(inputData->type);
786
+ // FWGPU_LOGD << " Pixel WebGPUFormat (input): "
787
+ // << webGPUTextureFormatToString(inputPixelFormat);
788
+ // FWGPU_LOGD << " Texture View format (output): "
789
+ // << webGPUTextureFormatToString(texture->getViewFormat());
790
+ // FWGPU_LOGD << " Texture format (output): "
791
+ // << webGPUTextureFormatToString(texture->getTexture().GetFormat());
792
+ // FWGPU_LOGD << " Linear Texture format (output): "
793
+ // << webGPUTextureFormatToString(outputLinearFormat);
794
+ // FWGPU_LOGD << " Conversion Necessary: " << conversionNecessary;
795
+ // FWGPU_LOGD << " Do Blit: " << doBlit;
796
+ // }
797
+ // #endif
799
798
FILAMENT_CHECK_PRECONDITION (inputData->type == PixelDataType::COMPRESSED ||
800
799
inputPixelFormat != wgpu::TextureFormat::Undefined)
801
800
<< " Failed to determine uncompressed input pixel format for WebGPU. Pixel format "
@@ -1290,8 +1289,7 @@ void WebGPUDriver::readPixels(Handle<HwRenderTarget> sourceRenderTargetHandle, c
1290
1289
1291
1290
const size_t dstBytesPerPixel = PixelBufferDescriptor::computePixelSize (
1292
1291
pixelBufferDescriptor.format , pixelBufferDescriptor.type );
1293
- const size_t srcBytesPerPixel =
1294
- WebGPUTexture::getWGPUTextureFormatPixelSize (srcTexture.GetFormat ());
1292
+ const size_t srcBytesPerPixel = getWGPUTextureFormatPixelSize (srcTexture.GetFormat ());
1295
1293
1296
1294
FILAMENT_CHECK_PRECONDITION (dstBytesPerPixel == srcBytesPerPixel && dstBytesPerPixel > 0 )
1297
1295
<< " Source texture pixel size (" << srcBytesPerPixel
@@ -1384,7 +1382,9 @@ void WebGPUDriver::readBufferSubData(Handle<HwBufferObject> bufferObjectHandle,
1384
1382
void WebGPUDriver::blitDEPRECATED (TargetBufferFlags buffers,
1385
1383
Handle<HwRenderTarget> destinationRenderTargetHandle, const Viewport destinationViewport,
1386
1384
Handle<HwRenderTarget> sourceRenderTargetHandle, const Viewport sourceViewport,
1387
- const SamplerMagFilter filter) {}
1385
+ const SamplerMagFilter filter) {
1386
+ PANIC_PRECONDITION (" WebGPUDriver::blitDEPRECATED not supported" );
1387
+ }
1388
1388
1389
1389
void WebGPUDriver::resolve (Handle<HwTexture> destinationTextureHandle, const uint8_t sourceLevel,
1390
1390
const uint8_t sourceLayer, Handle<HwTexture> sourceTextureHandle,
@@ -1424,43 +1424,47 @@ void WebGPUDriver::blit(Handle<HwTexture> destinationTextureHandle, const uint8_
1424
1424
const uint8_t destinationLayer, const math::uint2 sourceOrigin, const math::uint2 size) {
1425
1425
// TODO uncomment when texture format is taken into account with sampler settings in the
1426
1426
// blitter
1427
- // bool reusedCommandEncoder{ true };
1428
- // if (!mCommandEncoder) {
1429
- // reusedCommandEncoder = false;
1430
- // const wgpu::CommandEncoderDescriptor commandEncoderDescriptor{
1431
- // .label = "blit_command",
1432
- // };
1433
- // mCommandEncoder = mDevice.CreateCommandEncoder(&commandEncoderDescriptor);
1434
- // FILAMENT_CHECK_POSTCONDITION(mCommandEncoder)
1435
- // << "Failed to create command encoder for blit?";
1436
- // }
1437
- // const WebGPUBlitter::BlitArgs blitArgs{
1438
- // .source = {
1439
- // .texture = handleCast<WebGPUTexture>(sourceTextureHandle)->getTexture(),
1440
- // .origin = {.x = sourceOrigin.x, .y=sourceOrigin.y},
1441
- // .extent = {.width=size.x, .height =size.y},
1442
- // .mipLevel = sourceLevel,
1443
- // .layerOrDepth = sourceLayer,
1444
- // },
1445
- // .destination = {
1446
- // .texture = handleCast<WebGPUTexture>(destinationTextureHandle)->getTexture(),
1447
- // .origin = {.x = destinationOrigin.x, .y=destinationOrigin.y},
1448
- // .extent = {.width=size.x, .height =size.y},
1449
- // .mipLevel = destinationLevel,
1450
- // .layerOrDepth = destinationLayer,
1451
- // },
1452
- // .filter = SamplerMagFilter::NEAREST,
1453
- // };
1454
- // mBlitter.blit(mQueue, mCommandEncoder, blitArgs);
1455
- // if (!reusedCommandEncoder) {
1456
- // const wgpu::CommandBufferDescriptor commandBufferDescriptor{
1457
- // .label = "blit_command_buffer",
1458
- // };
1459
- // const wgpu::CommandBuffer blitCommand{ mCommandEncoder.Finish(&commandBufferDescriptor) };
1460
- // FILAMENT_CHECK_POSTCONDITION(blitCommand) << "Failed to create command buffer for blit?";
1461
- // mQueue.Submit(1, &blitCommand);
1462
- // mCommandEncoder = nullptr;
1463
- // }
1427
+ bool reusedCommandEncoder{ true };
1428
+ if (!mCommandEncoder ) {
1429
+ reusedCommandEncoder = false ;
1430
+ const wgpu::CommandEncoderDescriptor commandEncoderDescriptor{
1431
+ .label = " blit_command" ,
1432
+ };
1433
+ mCommandEncoder = mDevice .CreateCommandEncoder (&commandEncoderDescriptor);
1434
+ FILAMENT_CHECK_POSTCONDITION (mCommandEncoder )
1435
+ << " Failed to create command encoder for blit?" ;
1436
+ }
1437
+ const auto sourceTexture{ handleCast<WebGPUTexture>(sourceTextureHandle) };
1438
+ const auto destinationTexture{ handleCast<WebGPUTexture>(destinationTextureHandle) };
1439
+ const WebGPUBlitter::BlitArgs blitArgs{
1440
+ .source = {
1441
+ .texture = sourceTexture->getTexture (),
1442
+ .aspect = sourceTexture->getAspect (),
1443
+ .origin = {.x = sourceOrigin.x , .y =sourceOrigin.y },
1444
+ .extent = {.width =size.x , .height =size.y },
1445
+ .mipLevel = sourceLevel,
1446
+ .layerOrDepth = sourceLayer,
1447
+ },
1448
+ .destination = {
1449
+ .texture = destinationTexture->getTexture (),
1450
+ .aspect = destinationTexture->getAspect (),
1451
+ .origin = {.x = destinationOrigin.x , .y =destinationOrigin.y },
1452
+ .extent = {.width =size.x , .height =size.y },
1453
+ .mipLevel = destinationLevel,
1454
+ .layerOrDepth = destinationLayer,
1455
+ },
1456
+ .filter = SamplerMagFilter::NEAREST,
1457
+ };
1458
+ mBlitter .blit (mQueue , mCommandEncoder , blitArgs);
1459
+ if (!reusedCommandEncoder) {
1460
+ const wgpu::CommandBufferDescriptor commandBufferDescriptor{
1461
+ .label = " blit_command_buffer" ,
1462
+ };
1463
+ const wgpu::CommandBuffer blitCommand{ mCommandEncoder .Finish (&commandBufferDescriptor) };
1464
+ FILAMENT_CHECK_POSTCONDITION (blitCommand) << " Failed to create command buffer for blit?" ;
1465
+ mQueue .Submit (1 , &blitCommand);
1466
+ mCommandEncoder = nullptr ;
1467
+ }
1464
1468
}
1465
1469
1466
1470
void WebGPUDriver::bindPipeline (PipelineState const & pipelineState) {
0 commit comments