dawn-cmake/src/dawn_native/ShaderModule.h
Corentin Wallez 9e4518b57e Put the reference to DeviceBase in a new ObjectBase
ObjectBase will contain data that all WebGPU objects have such as a
pointer back to the device, a refcount (via inheriting from RefCounted),
a name, an error status etc.

BUG=dawn:24

Change-Id: I919e1a6d4a68811ceb6e503b2a793815c92f2528
Reviewed-on: https://dawn-review.googlesource.com/c/1620
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
2018-10-15 12:54:30 +00:00

82 lines
2.6 KiB
C++

// Copyright 2017 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef DAWNNATIVE_SHADERMODULE_H_
#define DAWNNATIVE_SHADERMODULE_H_
#include "common/Constants.h"
#include "dawn_native/Builder.h"
#include "dawn_native/Error.h"
#include "dawn_native/Forward.h"
#include "dawn_native/ObjectBase.h"
#include "dawn_native/dawn_platform.h"
#include <array>
#include <bitset>
#include <vector>
namespace spirv_cross {
class Compiler;
}
namespace dawn_native {
MaybeError ValidateShaderModuleDescriptor(DeviceBase* device,
const ShaderModuleDescriptor* descriptor);
class ShaderModuleBase : public ObjectBase {
public:
ShaderModuleBase(DeviceBase* device, const ShaderModuleDescriptor* descriptor);
void ExtractSpirvInfo(const spirv_cross::Compiler& compiler);
struct PushConstantInfo {
std::bitset<kMaxPushConstants> mask;
std::array<std::string, kMaxPushConstants> names;
std::array<uint32_t, kMaxPushConstants> sizes;
std::array<PushConstantType, kMaxPushConstants> types;
};
struct BindingInfo {
// The SPIRV ID of the resource.
uint32_t id;
uint32_t base_type_id;
dawn::BindingType type;
bool used = false;
};
using ModuleBindingInfo =
std::array<std::array<BindingInfo, kMaxBindingsPerGroup>, kMaxBindGroups>;
const PushConstantInfo& GetPushConstants() const;
const ModuleBindingInfo& GetBindingInfo() const;
const std::bitset<kMaxVertexAttributes>& GetUsedVertexAttributes() const;
dawn::ShaderStage GetExecutionModel() const;
bool IsCompatibleWithPipelineLayout(const PipelineLayoutBase* layout);
private:
bool IsCompatibleWithBindGroupLayout(size_t group, const BindGroupLayoutBase* layout);
PushConstantInfo mPushConstants = {};
ModuleBindingInfo mBindingInfo;
std::bitset<kMaxVertexAttributes> mUsedVertexAttributes;
dawn::ShaderStage mExecutionModel;
};
} // namespace dawn_native
#endif // DAWNNATIVE_SHADERMODULE_H_