Add basic supports of storage textures on OpenGL

This patch adds the basic supports of read-only and write-only storage
textures on OpenGL backend. Currently on OpenGL backend we only support
using either a layer of a texture or the entire texture as either read-
only or write-only storage texture.

BUG=dawn:267
TEST=dawn_end2end_tests

Change-Id: I235b98d8d961a17739ea35eec9726dcc80889c4b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/22180
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao
2020-05-29 07:51:08 +00:00
committed by Commit Bot service account
parent da6dccd7c5
commit 0e5301c23e
9 changed files with 115 additions and 42 deletions

View File

@@ -14,11 +14,54 @@
#include "dawn_native/opengl/BindGroupGL.h"
#include "dawn_native/Texture.h"
#include "dawn_native/opengl/BindGroupLayoutGL.h"
#include "dawn_native/opengl/DeviceGL.h"
namespace dawn_native { namespace opengl {
MaybeError ValidateGLBindGroupDescriptor(const BindGroupDescriptor* descriptor) {
const BindGroupLayoutBase::BindingMap& bindingMap = descriptor->layout->GetBindingMap();
for (uint32_t i = 0; i < descriptor->entryCount; ++i) {
const BindGroupEntry& entry = descriptor->entries[i];
const auto& it = bindingMap.find(BindingNumber(entry.binding));
BindingIndex bindingIndex = it->second;
ASSERT(bindingIndex < descriptor->layout->GetBindingCount());
const BindingInfo& bindingInfo = descriptor->layout->GetBindingInfo(bindingIndex);
switch (bindingInfo.type) {
case wgpu::BindingType::ReadonlyStorageTexture:
case wgpu::BindingType::WriteonlyStorageTexture: {
ASSERT(entry.textureView != nullptr);
const uint32_t textureViewLayerCount = entry.textureView->GetLayerCount();
if (textureViewLayerCount != 1 &&
textureViewLayerCount !=
entry.textureView->GetTexture()->GetArrayLayers()) {
return DAWN_VALIDATION_ERROR(
"Currently the OpenGL backend only supports either binding a layer or "
"the entire texture as storage texture.");
}
} break;
case wgpu::BindingType::UniformBuffer:
case wgpu::BindingType::StorageBuffer:
case wgpu::BindingType::ReadonlyStorageBuffer:
case wgpu::BindingType::SampledTexture:
case wgpu::BindingType::Sampler:
case wgpu::BindingType::ComparisonSampler:
break;
case wgpu::BindingType::StorageTexture:
default:
UNREACHABLE();
break;
}
}
return {};
}
BindGroup::BindGroup(Device* device, const BindGroupDescriptor* descriptor)
: BindGroupBase(this, device, descriptor) {
}