Use GetBindGroupLayout in TextureViewTests

Bug: dawn:276
Change-Id: If502f933d3fbefb03bc04a7aceacb89874187d3e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14032
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Austin Eng 2019-12-03 21:40:05 +00:00 committed by Commit Bot service account
parent cd62568bc8
commit 53782d60dc
1 changed files with 7 additions and 15 deletions

View File

@ -150,18 +150,8 @@ protected:
} }
void Verify(const wgpu::TextureView& textureView, void Verify(const wgpu::TextureView& textureView,
wgpu::TextureViewDimension dimension,
const char* fragmentShader, const char* fragmentShader,
int expected) { int expected) {
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler},
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false,
false, dimension, wgpu::TextureComponentType::Float},
});
wgpu::BindGroup bindGroup =
utils::MakeBindGroup(device, bindGroupLayout, {{0, mSampler}, {1, textureView}});
wgpu::ShaderModule fsModule = wgpu::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fragmentShader); utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fragmentShader);
@ -169,11 +159,13 @@ protected:
utils::ComboRenderPipelineDescriptor textureDescriptor(device); utils::ComboRenderPipelineDescriptor textureDescriptor(device);
textureDescriptor.vertexStage.module = mVSModule; textureDescriptor.vertexStage.module = mVSModule;
textureDescriptor.cFragmentStage.module = fsModule; textureDescriptor.cFragmentStage.module = fsModule;
textureDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bindGroupLayout);
textureDescriptor.cColorStates[0].format = mRenderPass.colorFormat; textureDescriptor.cColorStates[0].format = mRenderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&textureDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&textureDescriptor);
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
{{0, mSampler}, {1, textureView}});
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&mRenderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&mRenderPass.renderPassInfo);
@ -224,7 +216,7 @@ protected:
)"; )";
const int expected = GenerateTestPixelValue(textureViewBaseLayer, textureViewBaseMipLevel); const int expected = GenerateTestPixelValue(textureViewBaseLayer, textureViewBaseMipLevel);
Verify(textureView, wgpu::TextureViewDimension::e2D, fragmentShader, expected); Verify(textureView, fragmentShader, expected);
} }
void Texture2DArrayViewTest(uint32_t textureArrayLayers, void Texture2DArrayViewTest(uint32_t textureArrayLayers,
@ -268,7 +260,7 @@ protected:
for (int i = 0; i < static_cast<int>(kTextureViewLayerCount); ++i) { for (int i = 0; i < static_cast<int>(kTextureViewLayerCount); ++i) {
expected += GenerateTestPixelValue(textureViewBaseLayer + i, textureViewBaseMipLevel); expected += GenerateTestPixelValue(textureViewBaseLayer + i, textureViewBaseMipLevel);
} }
Verify(textureView, wgpu::TextureViewDimension::e2DArray, fragmentShader, expected); Verify(textureView, fragmentShader, expected);
} }
std::string CreateFragmentShaderForCubeMapFace(uint32_t layer, bool isCubeMapArray) { std::string CreateFragmentShaderForCubeMapFace(uint32_t layer, bool isCubeMapArray) {
@ -337,7 +329,7 @@ protected:
CreateFragmentShaderForCubeMapFace(layer, isCubeMapArray); CreateFragmentShaderForCubeMapFace(layer, isCubeMapArray);
int expected = GenerateTestPixelValue(textureViewBaseLayer + layer, 0); int expected = GenerateTestPixelValue(textureViewBaseLayer + layer, 0);
Verify(cubeMapTextureView, dimension, fragmentShader.c_str(), expected); Verify(cubeMapTextureView, fragmentShader.c_str(), expected);
} }
} }
@ -376,7 +368,7 @@ TEST_P(TextureViewSamplingTest, Default2DArrayTexture) {
const int expected = GenerateTestPixelValue(0, 0) + GenerateTestPixelValue(1, 0) + const int expected = GenerateTestPixelValue(0, 0) + GenerateTestPixelValue(1, 0) +
GenerateTestPixelValue(2, 0); GenerateTestPixelValue(2, 0);
Verify(textureView, wgpu::TextureViewDimension::e2DArray, fragmentShader, expected); Verify(textureView, fragmentShader, expected);
} }
// Test sampling from a 2D texture view created on a 2D array texture. // Test sampling from a 2D texture view created on a 2D array texture.