@@ -48,6 +48,8 @@ angle::Result ProgramExecutableWgpu::updateUniformsAndGetBindGroup(
4848{
4949 if (mDefaultUniformBlocksDirty .any ())
5050 {
51+ const DawnProcTable *wgpu = webgpu::GetProcs (contextWgpu);
52+
5153 // TODO(anglebug.com/376553328): this creates an entire new buffer every time a single
5254 // uniform changes, and the old ones are just garbage collected. This should be optimized.
5355 webgpu::BufferHelper defaultUniformBuffer;
@@ -63,7 +65,7 @@ angle::Result ProgramExecutableWgpu::updateUniformsAndGetBindGroup(
6365 return angle::Result::Stop;
6466 }
6567
66- ANGLE_TRY (defaultUniformBuffer.initBuffer (contextWgpu->getDevice (), requiredSpace,
68+ ANGLE_TRY (defaultUniformBuffer.initBuffer (wgpu, contextWgpu->getDevice (), requiredSpace,
6769 WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst,
6870 webgpu::MapAtCreation::Yes));
6971
@@ -106,7 +108,7 @@ angle::Result ProgramExecutableWgpu::updateUniformsAndGetBindGroup(
106108 bindGroupDesc.entryCount = bindings.size ();
107109 bindGroupDesc.entries = bindings.data ();
108110 mDefaultBindGroup = webgpu::BindGroupHandle::Acquire (
109- wgpuDeviceCreateBindGroup (contextWgpu->getDevice ().get (), &bindGroupDesc));
111+ wgpu, wgpu-> deviceCreateBindGroup (contextWgpu->getDevice ().get (), &bindGroupDesc));
110112 }
111113
112114 ASSERT (mDefaultBindGroup );
@@ -121,6 +123,8 @@ angle::Result ProgramExecutableWgpu::getSamplerAndTextureBindGroup(
121123{
122124 if (mSamplerBindingsDirty )
123125 {
126+ const DawnProcTable *wgpu = webgpu::GetProcs (contextWgpu);
127+
124128 const gl::ActiveTexturesCache &completeTextures =
125129 contextWgpu->getState ().getActiveTexturesCache ();
126130
@@ -175,7 +179,7 @@ angle::Result ProgramExecutableWgpu::getSamplerAndTextureBindGroup(
175179 // TODO(anglebug.com/389145696): potentially cache sampler.
176180 WGPUSamplerDescriptor sampleDesc = gl_wgpu::GetWgpuSamplerDesc (samplerState);
177181 webgpu::SamplerHandle wgpuSampler = webgpu::SamplerHandle::Acquire (
178- wgpuDeviceCreateSampler (contextWgpu->getDevice ().get (), &sampleDesc));
182+ wgpu, wgpu-> deviceCreateSampler (contextWgpu->getDevice ().get (), &sampleDesc));
179183 samplers.push_back (wgpuSampler);
180184
181185 WGPUBindGroupEntry samplerBindGroupEntry = WGPU_BIND_GROUP_ENTRY_INIT;
@@ -207,7 +211,7 @@ angle::Result ProgramExecutableWgpu::getSamplerAndTextureBindGroup(
207211 bindGroupDesc.entryCount = bindings.size ();
208212 bindGroupDesc.entries = bindings.data ();
209213 mSamplersAndTexturesBindGroup = webgpu::BindGroupHandle::Acquire (
210- wgpuDeviceCreateBindGroup (contextWgpu->getDevice ().get (), &bindGroupDesc));
214+ wgpu, wgpu-> deviceCreateBindGroup (contextWgpu->getDevice ().get (), &bindGroupDesc));
211215
212216 mSamplerBindingsDirty = false ;
213217 }
@@ -480,6 +484,9 @@ void ProgramExecutableWgpu::genBindingLayoutIfNecessary(ContextWgpu *context)
480484 {
481485 return ;
482486 }
487+
488+ const DawnProcTable *wgpu = webgpu::GetProcs (context);
489+
483490 // TODO(anglebug.com/42267100): for now, only create a wgpu::PipelineLayout with the default
484491 // uniform block, driver uniform block, and textures/samplers. Will need to be extended for
485492 // UBOs. Also, possibly provide this layout as a compilation hint to createShaderModule().
@@ -516,7 +523,8 @@ void ProgramExecutableWgpu::genBindingLayoutIfNecessary(ContextWgpu *context)
516523 defaultBindGroupLayoutDesc.entryCount = defaultBindGroupLayoutEntries.size ();
517524 defaultBindGroupLayoutDesc.entries = defaultBindGroupLayoutEntries.data ();
518525 mDefaultBindGroupLayout = webgpu::BindGroupLayoutHandle::Acquire (
519- wgpuDeviceCreateBindGroupLayout (context->getDevice ().get (), &defaultBindGroupLayoutDesc));
526+ wgpu,
527+ wgpu->deviceCreateBindGroupLayout (context->getDevice ().get (), &defaultBindGroupLayoutDesc));
520528
521529 // Add the textures/samplers to the second bind group.
522530 std::vector<WGPUBindGroupLayoutEntry> samplersAndTexturesBindGroupLayoutEntries;
@@ -570,9 +578,9 @@ void ProgramExecutableWgpu::genBindingLayoutIfNecessary(ContextWgpu *context)
570578 samplersAndTexturesBindGroupLayoutEntries.size ();
571579 texturesAndSamplersBindGroupLayoutDesc.entries =
572580 samplersAndTexturesBindGroupLayoutEntries.data ();
573- mSamplersAndTexturesBindGroupLayout =
574- webgpu::BindGroupLayoutHandle::Acquire ( wgpuDeviceCreateBindGroupLayout (
575- context-> getDevice (). get (), &texturesAndSamplersBindGroupLayoutDesc));
581+ mSamplersAndTexturesBindGroupLayout = webgpu::BindGroupLayoutHandle::Acquire (
582+ wgpu, wgpu-> deviceCreateBindGroupLayout (context-> getDevice (). get (),
583+ &texturesAndSamplersBindGroupLayoutDesc));
576584
577585 // Driver uniforms bind groups are handled by ContextWgpu.
578586
@@ -592,7 +600,7 @@ void ProgramExecutableWgpu::genBindingLayoutIfNecessary(ContextWgpu *context)
592600 layoutDesc.bindGroupLayoutCount = groupLayouts.size ();
593601 layoutDesc.bindGroupLayouts = groupLayouts.data ();
594602 mPipelineLayout = webgpu::PipelineLayoutHandle::Acquire (
595- wgpuDeviceCreatePipelineLayout (context->getDevice ().get (), &layoutDesc));
603+ wgpu, wgpu-> deviceCreatePipelineLayout (context->getDevice ().get (), &layoutDesc));
596604}
597605
598606} // namespace rx
0 commit comments