Allow bind group layouts to be sparse in pipeline layout
Instead of initializing all of the bind group layouts in the pipeline layout to default values, let them be nullptr and allow this elsewhere. Follow-up on some changes in #206
This commit is contained in:
parent
804fc749a0
commit
311e2a44b9
|
@ -34,7 +34,7 @@ namespace backend {
|
|||
|
||||
// PipelineLayoutBase
|
||||
|
||||
PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device,
|
||||
PipelineLayoutBase::PipelineLayoutBase(DeviceBase*,
|
||||
const nxt::PipelineLayoutDescriptor* descriptor) {
|
||||
ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups);
|
||||
for (uint32_t group = 0; group < descriptor->numBindGroupLayouts; ++group) {
|
||||
|
@ -42,15 +42,6 @@ namespace backend {
|
|||
reinterpret_cast<BindGroupLayoutBase*>(descriptor->bindGroupLayouts[group].Get());
|
||||
mMask.set(group);
|
||||
}
|
||||
// TODO(kainino@chromium.org): It shouldn't be necessary to construct default bind
|
||||
// group layouts here. Remove these and fix things so that they are not needed.
|
||||
for (uint32_t group = descriptor->numBindGroupLayouts; group < kMaxBindGroups; ++group) {
|
||||
auto builder = device->CreateBindGroupLayoutBuilder();
|
||||
mBindGroupLayouts[group] = builder->GetResult();
|
||||
// Remove the external ref objects are created with
|
||||
mBindGroupLayouts[group]->Release();
|
||||
builder->Release();
|
||||
}
|
||||
}
|
||||
|
||||
const BindGroupLayoutBase* PipelineLayoutBase::GetBindGroupLayout(size_t group) const {
|
||||
|
|
|
@ -37,6 +37,7 @@ namespace backend {
|
|||
PipelineLayoutBase(DeviceBase* device, const nxt::PipelineLayoutDescriptor* descriptor);
|
||||
|
||||
const BindGroupLayoutBase* GetBindGroupLayout(size_t group) const;
|
||||
// XXX: rename to GetBindGroupLayoutsMask?
|
||||
const std::bitset<kMaxBindGroups> GetBindGroupsLayoutMask() const;
|
||||
|
||||
// Utility functions to compute inherited bind groups.
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "backend/d3d12/BindGroupLayoutD3D12.h"
|
||||
#include "backend/d3d12/DeviceD3D12.h"
|
||||
#include "common/Assert.h"
|
||||
#include "common/BitSetIterator.h"
|
||||
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
|
@ -42,7 +43,7 @@ namespace backend { namespace d3d12 {
|
|||
uint32_t parameterIndex = 0;
|
||||
uint32_t rangeIndex = 0;
|
||||
|
||||
for (uint32_t group = 0; group < kMaxBindGroups; ++group) {
|
||||
for (uint32_t group : IterateBitSet(GetBindGroupsLayoutMask())) {
|
||||
const BindGroupLayout* bindGroupLayout = ToBackend(GetBindGroupLayout(group));
|
||||
|
||||
// Set the root descriptor table parameter and copy ranges. Ranges are offset by the
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "backend/BindGroupLayout.h"
|
||||
#include "backend/metal/DeviceMTL.h"
|
||||
#include "common/BitSetIterator.h"
|
||||
|
||||
namespace backend { namespace metal {
|
||||
|
||||
|
@ -28,7 +29,7 @@ namespace backend { namespace metal {
|
|||
uint32_t samplerIndex = 0;
|
||||
uint32_t textureIndex = 0;
|
||||
|
||||
for (size_t group = 0; group < kMaxBindGroups; ++group) {
|
||||
for (uint32_t group : IterateBitSet(GetBindGroupsLayoutMask())) {
|
||||
const auto& groupInfo = GetBindGroupLayout(group)->GetBindingInfo();
|
||||
for (size_t binding = 0; binding < kMaxBindingsPerGroup; ++binding) {
|
||||
if (!(groupInfo.visibilities[binding] & StageBit(stage))) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "backend/opengl/PersistentPipelineStateGL.h"
|
||||
#include "backend/opengl/PipelineLayoutGL.h"
|
||||
#include "backend/opengl/ShaderModuleGL.h"
|
||||
#include "common/BitSetIterator.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
|
@ -125,7 +126,7 @@ namespace backend { namespace opengl {
|
|||
const auto& layout = ToBackend(parent->GetLayout());
|
||||
const auto& indices = layout->GetBindingIndexInfo();
|
||||
|
||||
for (uint32_t group = 0; group < kMaxBindGroups; ++group) {
|
||||
for (uint32_t group : IterateBitSet(layout->GetBindGroupsLayoutMask())) {
|
||||
const auto& groupInfo = layout->GetBindGroupLayout(group)->GetBindingInfo();
|
||||
|
||||
for (uint32_t binding = 0; binding < kMaxBindingsPerGroup; ++binding) {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "backend/BindGroupLayout.h"
|
||||
#include "backend/opengl/DeviceGL.h"
|
||||
#include "common/BitSetIterator.h"
|
||||
|
||||
namespace backend { namespace opengl {
|
||||
|
||||
|
@ -26,7 +27,7 @@ namespace backend { namespace opengl {
|
|||
GLuint sampledTextureIndex = 0;
|
||||
GLuint ssboIndex = 0;
|
||||
|
||||
for (size_t group = 0; group < kMaxBindGroups; ++group) {
|
||||
for (uint32_t group : IterateBitSet(GetBindGroupsLayoutMask())) {
|
||||
const auto& groupInfo = GetBindGroupLayout(group)->GetBindingInfo();
|
||||
|
||||
for (size_t binding = 0; binding < kMaxBindingsPerGroup; ++binding) {
|
||||
|
|
Loading…
Reference in New Issue