mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 13:38:00 +00:00
Descriptorize BindGroups.
This commit adds utils::MakeBindGroup to make code craeting bind groups nicer to read. Additional tests are added that give 100% coverage of ValidateBindGroupDescriptor. BUG=dawn:3 Change-Id: I56e1da8c2952306ad233845b0ec3ec32aef793d9 Reviewed-on: https://dawn-review.googlesource.com/c/2802 Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
006f218392
commit
6f9d21e805
@@ -249,12 +249,11 @@ void initSim() {
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < 2; ++i) {
|
||||
updateBGs[i] = device.CreateBindGroupBuilder()
|
||||
.SetLayout(bgl)
|
||||
.SetBufferViews(0, 1, &updateParamsView)
|
||||
.SetBufferViews(1, 1, &views[i])
|
||||
.SetBufferViews(2, 1, &views[(i + 1) % 2])
|
||||
.GetResult();
|
||||
updateBGs[i] = utils::MakeBindGroup(device, bgl, {
|
||||
{0, updateParamsView},
|
||||
{1, views[i]},
|
||||
{2, views[(i + 1) % 2]}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -137,11 +137,10 @@ void init() {
|
||||
|
||||
dawn::TextureView view = texture.CreateDefaultTextureView();
|
||||
|
||||
bindGroup = device.CreateBindGroupBuilder()
|
||||
.SetLayout(bgl)
|
||||
.SetSamplers(0, 1, &sampler)
|
||||
.SetTextureViews(1, 1, &view)
|
||||
.GetResult();
|
||||
bindGroup = utils::MakeBindGroup(device, bgl, {
|
||||
{0, sampler},
|
||||
{1, view}
|
||||
});
|
||||
}
|
||||
|
||||
struct {uint32_t a; float b;} s;
|
||||
|
||||
@@ -193,17 +193,15 @@ void init() {
|
||||
.GetResult(),
|
||||
};
|
||||
|
||||
bindGroup[0] = device.CreateBindGroupBuilder()
|
||||
.SetLayout(bgl)
|
||||
.SetBufferViews(0, 1, &cameraBufferView)
|
||||
.SetBufferViews(1, 1, &transformBufferView[0])
|
||||
.GetResult();
|
||||
bindGroup[0] = utils::MakeBindGroup(device, bgl, {
|
||||
{0, cameraBufferView},
|
||||
{1, transformBufferView[0]}
|
||||
});
|
||||
|
||||
bindGroup[1] = device.CreateBindGroupBuilder()
|
||||
.SetLayout(bgl)
|
||||
.SetBufferViews(0, 1, &cameraBufferView)
|
||||
.SetBufferViews(1, 1, &transformBufferView[1])
|
||||
.GetResult();
|
||||
bindGroup[1] = utils::MakeBindGroup(device, bgl, {
|
||||
{0, cameraBufferView},
|
||||
{1, transformBufferView[1]}
|
||||
});
|
||||
|
||||
depthStencilView = CreateDefaultDepthStencilView(device);
|
||||
|
||||
|
||||
@@ -298,19 +298,22 @@ namespace {
|
||||
.SetDepthStencilState(depthStencilState)
|
||||
.GetResult();
|
||||
|
||||
auto bindGroupBuilder = device.CreateBindGroupBuilder();
|
||||
bindGroupBuilder.SetLayout(bindGroupLayout);
|
||||
dawn::BindGroup bindGroup;
|
||||
|
||||
if (hasTexture) {
|
||||
const auto& textureView = textures[iTextureID];
|
||||
const auto& iSamplerID = scene.textures[iTextureID].sampler;
|
||||
bindGroupBuilder.SetSamplers(0, 1, &samplers[iSamplerID]);
|
||||
bindGroupBuilder.SetTextureViews(1, 1, &textureView);
|
||||
bindGroup = utils::MakeBindGroup(device, bindGroupLayout, {
|
||||
{0, samplers[iSamplerID]},
|
||||
{1, textureView}
|
||||
});
|
||||
} else {
|
||||
bindGroup = utils::MakeBindGroup(device, bindGroupLayout, {});
|
||||
}
|
||||
|
||||
MaterialInfo material = {
|
||||
pipeline.Get(),
|
||||
bindGroupBuilder.GetResult(),
|
||||
pipeline,
|
||||
bindGroup,
|
||||
std::map<uint32_t, std::string>(),
|
||||
};
|
||||
materials[key] = std::move(material);
|
||||
|
||||
Reference in New Issue
Block a user