From 159d5c6a90a1e1d338c0bd8ce0654b541a9d3182 Mon Sep 17 00:00:00 2001 From: Austin Eng Date: Tue, 3 Dec 2019 21:21:55 +0000 Subject: [PATCH] Use GetBindGroupLayout in IOSurfaceWrappingTests Bug: dawn:276 Change-Id: Ie9bc27e8cc0ec5892b6e63429124249232e69725 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14027 Commit-Queue: Austin Eng Reviewed-by: Kai Ninomiya Reviewed-by: Corentin Wallez --- src/tests/end2end/IOSurfaceWrappingTests.cpp | 51 +++++++++----------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/src/tests/end2end/IOSurfaceWrappingTests.cpp b/src/tests/end2end/IOSurfaceWrappingTests.cpp index 4705835259..f2fe59aa14 100644 --- a/src/tests/end2end/IOSurfaceWrappingTests.cpp +++ b/src/tests/end2end/IOSurfaceWrappingTests.cpp @@ -237,34 +237,6 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase { memcpy(IOSurfaceGetBaseAddress(ioSurface), data, dataSize); IOSurfaceUnlock(ioSurface, 0, nullptr); - // The bindgroup containing the texture view for the ioSurface as well as the sampler. - wgpu::BindGroupLayout bgl; - wgpu::BindGroup bindGroup; - { - wgpu::TextureDescriptor textureDescriptor; - textureDescriptor.dimension = wgpu::TextureDimension::e2D; - textureDescriptor.format = format; - textureDescriptor.size = {1, 1, 1}; - textureDescriptor.sampleCount = 1; - textureDescriptor.arrayLayerCount = 1; - textureDescriptor.mipLevelCount = 1; - textureDescriptor.usage = wgpu::TextureUsage::Sampled; - wgpu::Texture wrappingTexture = WrapIOSurface(&textureDescriptor, ioSurface, 0); - - wgpu::TextureView textureView = wrappingTexture.CreateView(); - - wgpu::SamplerDescriptor samplerDescriptor = utils::GetDefaultSamplerDescriptor(); - wgpu::Sampler sampler = device.CreateSampler(&samplerDescriptor); - - bgl = utils::MakeBindGroupLayout( - device, { - {0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}, - {1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture}, - }); - - bindGroup = utils::MakeBindGroup(device, bgl, {{0, sampler}, {1, textureView}}); - } - // The simplest texture sampling pipeline. wgpu::RenderPipeline pipeline; { @@ -305,12 +277,33 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase { utils::ComboRenderPipelineDescriptor descriptor(device); descriptor.vertexStage.module = vs; descriptor.cFragmentStage.module = fs; - descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl); descriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm; pipeline = device.CreateRenderPipeline(&descriptor); } + // The bindgroup containing the texture view for the ioSurface as well as the sampler. + wgpu::BindGroup bindGroup; + { + wgpu::TextureDescriptor textureDescriptor; + textureDescriptor.dimension = wgpu::TextureDimension::e2D; + textureDescriptor.format = format; + textureDescriptor.size = {1, 1, 1}; + textureDescriptor.sampleCount = 1; + textureDescriptor.arrayLayerCount = 1; + textureDescriptor.mipLevelCount = 1; + textureDescriptor.usage = wgpu::TextureUsage::Sampled; + wgpu::Texture wrappingTexture = WrapIOSurface(&textureDescriptor, ioSurface, 0); + + wgpu::TextureView textureView = wrappingTexture.CreateView(); + + wgpu::SamplerDescriptor samplerDescriptor = utils::GetDefaultSamplerDescriptor(); + wgpu::Sampler sampler = device.CreateSampler(&samplerDescriptor); + + bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), + {{0, sampler}, {1, textureView}}); + } + // Submit commands samping from the ioSurface and writing the result to renderPass.color utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();