mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-20 18:29:23 +00:00
Convert LayoutBindingInfo to an array of BindingInfos
This makes accessing per-index data simpler, and now that dynamic buffer bindings are packed at the front, the old IterateBitset on the dynamic buffer binding mask can be replaced with a simple loop over the beginning bindings. Bug: dawn:354 Change-Id: I1adf371c3228690758f90ab1f0de88ad8d0f950d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/17681 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
d5db214564
commit
0847cb4637
@@ -239,28 +239,45 @@ namespace dawn_native { namespace opengl {
|
||||
uint32_t dynamicOffsetCount,
|
||||
uint64_t* dynamicOffsets) {
|
||||
const auto& indices = ToBackend(mPipelineLayout)->GetBindingIndexInfo()[index];
|
||||
const BindGroupLayoutBase::LayoutBindingInfo& layout =
|
||||
group->GetLayout()->GetBindingInfo();
|
||||
uint32_t currentDynamicIndex = 0;
|
||||
uint32_t currentDynamicOffsetIndex = 0;
|
||||
|
||||
for (BindingIndex bindingIndex = 0; bindingIndex < layout.bindingCount;
|
||||
++bindingIndex) {
|
||||
switch (layout.types[bindingIndex]) {
|
||||
for (BindingIndex bindingIndex = 0;
|
||||
bindingIndex < group->GetLayout()->GetBindingCount(); ++bindingIndex) {
|
||||
const BindGroupLayoutBase::BindingInfo& bindingInfo =
|
||||
group->GetLayout()->GetBindingInfo(bindingIndex);
|
||||
|
||||
switch (bindingInfo.type) {
|
||||
case wgpu::BindingType::UniformBuffer: {
|
||||
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
|
||||
GLuint buffer = ToBackend(binding.buffer)->GetHandle();
|
||||
GLuint uboIndex = indices[bindingIndex];
|
||||
GLuint offset = binding.offset;
|
||||
|
||||
if (layout.hasDynamicOffset[bindingIndex]) {
|
||||
offset += dynamicOffsets[currentDynamicIndex];
|
||||
++currentDynamicIndex;
|
||||
if (bindingInfo.hasDynamicOffset) {
|
||||
offset += dynamicOffsets[currentDynamicOffsetIndex];
|
||||
++currentDynamicOffsetIndex;
|
||||
}
|
||||
|
||||
gl.BindBufferRange(GL_UNIFORM_BUFFER, uboIndex, buffer, offset,
|
||||
binding.size);
|
||||
} break;
|
||||
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer: {
|
||||
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
|
||||
GLuint buffer = ToBackend(binding.buffer)->GetHandle();
|
||||
GLuint ssboIndex = indices[bindingIndex];
|
||||
GLuint offset = binding.offset;
|
||||
|
||||
if (bindingInfo.hasDynamicOffset) {
|
||||
offset += dynamicOffsets[currentDynamicOffsetIndex];
|
||||
++currentDynamicOffsetIndex;
|
||||
}
|
||||
|
||||
gl.BindBufferRange(GL_SHADER_STORAGE_BUFFER, ssboIndex, buffer, offset,
|
||||
binding.size);
|
||||
} break;
|
||||
|
||||
case wgpu::BindingType::Sampler: {
|
||||
Sampler* sampler = ToBackend(group->GetBindingAsSampler(bindingIndex));
|
||||
GLuint samplerIndex = indices[bindingIndex];
|
||||
@@ -290,22 +307,6 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
} break;
|
||||
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer: {
|
||||
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
|
||||
GLuint buffer = ToBackend(binding.buffer)->GetHandle();
|
||||
GLuint ssboIndex = indices[bindingIndex];
|
||||
GLuint offset = binding.offset;
|
||||
|
||||
if (layout.hasDynamicOffset[bindingIndex]) {
|
||||
offset += dynamicOffsets[currentDynamicIndex];
|
||||
++currentDynamicIndex;
|
||||
}
|
||||
|
||||
gl.BindBufferRange(GL_SHADER_STORAGE_BUFFER, ssboIndex, buffer, offset,
|
||||
binding.size);
|
||||
} break;
|
||||
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageTexture:
|
||||
case wgpu::BindingType::WriteonlyStorageTexture:
|
||||
|
||||
@@ -107,15 +107,14 @@ namespace dawn_native { namespace opengl {
|
||||
const auto& indices = layout->GetBindingIndexInfo();
|
||||
|
||||
for (uint32_t group : IterateBitSet(layout->GetBindGroupLayoutsMask())) {
|
||||
const BindGroupLayoutBase::LayoutBindingInfo& groupInfo =
|
||||
layout->GetBindGroupLayout(group)->GetBindingInfo();
|
||||
const BindGroupLayoutBase* bgl = layout->GetBindGroupLayout(group);
|
||||
|
||||
for (const auto& it : layout->GetBindGroupLayout(group)->GetBindingMap()) {
|
||||
for (const auto& it : bgl->GetBindingMap()) {
|
||||
BindingNumber bindingNumber = it.first;
|
||||
BindingIndex bindingIndex = it.second;
|
||||
|
||||
std::string name = GetBindingName(group, bindingNumber);
|
||||
switch (groupInfo.types[bindingIndex]) {
|
||||
switch (bgl->GetBindingInfo(bindingIndex).type) {
|
||||
case wgpu::BindingType::UniformBuffer: {
|
||||
GLint location = gl.GetUniformBlockIndex(mProgram, name.c_str());
|
||||
if (location != -1) {
|
||||
@@ -178,10 +177,11 @@ namespace dawn_native { namespace opengl {
|
||||
indices[combined.textureLocation.group][combined.textureLocation.binding];
|
||||
mUnitsForTextures[textureIndex].push_back(textureUnit);
|
||||
|
||||
const BindGroupLayoutBase* bgl =
|
||||
layout->GetBindGroupLayout(combined.textureLocation.group);
|
||||
wgpu::TextureComponentType componentType =
|
||||
layout->GetBindGroupLayout(combined.textureLocation.group)
|
||||
->GetBindingInfo()
|
||||
.textureComponentTypes[combined.textureLocation.binding];
|
||||
bgl->GetBindingInfo(bgl->GetBindingIndex(combined.textureLocation.binding))
|
||||
.textureComponentType;
|
||||
bool shouldUseFiltering = componentType == wgpu::TextureComponentType::Float;
|
||||
|
||||
GLuint samplerIndex =
|
||||
|
||||
@@ -28,12 +28,11 @@ namespace dawn_native { namespace opengl {
|
||||
GLuint ssboIndex = 0;
|
||||
|
||||
for (uint32_t group : IterateBitSet(GetBindGroupLayoutsMask())) {
|
||||
const BindGroupLayoutBase::LayoutBindingInfo& groupInfo =
|
||||
GetBindGroupLayout(group)->GetBindingInfo();
|
||||
const BindGroupLayoutBase* bgl = GetBindGroupLayout(group);
|
||||
|
||||
for (BindingIndex bindingIndex = 0; bindingIndex < groupInfo.bindingCount;
|
||||
for (BindingIndex bindingIndex = 0; bindingIndex < bgl->GetBindingCount();
|
||||
++bindingIndex) {
|
||||
switch (groupInfo.types[bindingIndex]) {
|
||||
switch (bgl->GetBindingInfo(bindingIndex).type) {
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
mIndexInfo[group][bindingIndex] = uboIndex;
|
||||
uboIndex++;
|
||||
|
||||
Reference in New Issue
Block a user