mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-08-20 02:41:48 +00:00
This is needed for two reasons: - TextureBase and TextureViewBase stored Formats by value which isn't too much overhead at this time but will get bigger in the future. - The OpenGL backends needs its own GLFormat structure to store data about each format which will eventually contain complicated logic to detect support in the GL driver so it shouldn't be duplicated in Textures. The computations of the information about Format is moved from being done whenever they are needed to being precomputed at DeviceBase initialization. This makes each format have a constant "index" in that can be used in the backends to address their own structure, for example a GLFormat table. Also some DeviceBase pointers were made const for validation. BUG=dawn:128 Change-Id: I37d1e9c739b87cddcea09cb1759e175704d90f9e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9101 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Jiawei Shao <jiawei.shao@intel.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
69 lines
2.4 KiB
C++
69 lines
2.4 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.
|
|
|
|
#include "dawn_native/Pipeline.h"
|
|
|
|
#include "dawn_native/Device.h"
|
|
#include "dawn_native/PipelineLayout.h"
|
|
#include "dawn_native/ShaderModule.h"
|
|
|
|
namespace dawn_native {
|
|
|
|
MaybeError ValidatePipelineStageDescriptor(const DeviceBase* device,
|
|
const PipelineStageDescriptor* descriptor,
|
|
const PipelineLayoutBase* layout,
|
|
ShaderStage stage) {
|
|
DAWN_TRY(device->ValidateObject(descriptor->module));
|
|
|
|
if (descriptor->entryPoint != std::string("main")) {
|
|
return DAWN_VALIDATION_ERROR("Entry point must be \"main\"");
|
|
}
|
|
if (descriptor->module->GetExecutionModel() != stage) {
|
|
return DAWN_VALIDATION_ERROR("Setting module with wrong stages");
|
|
}
|
|
if (!descriptor->module->IsCompatibleWithPipelineLayout(layout)) {
|
|
return DAWN_VALIDATION_ERROR("Stage not compatible with layout");
|
|
}
|
|
return {};
|
|
}
|
|
|
|
// PipelineBase
|
|
|
|
PipelineBase::PipelineBase(DeviceBase* device,
|
|
PipelineLayoutBase* layout,
|
|
dawn::ShaderStageBit stages)
|
|
: ObjectBase(device), mStageMask(stages), mLayout(layout) {
|
|
}
|
|
|
|
PipelineBase::PipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag)
|
|
: ObjectBase(device, tag) {
|
|
}
|
|
|
|
dawn::ShaderStageBit PipelineBase::GetStageMask() const {
|
|
ASSERT(!IsError());
|
|
return mStageMask;
|
|
}
|
|
|
|
PipelineLayoutBase* PipelineBase::GetLayout() {
|
|
ASSERT(!IsError());
|
|
return mLayout.Get();
|
|
}
|
|
|
|
const PipelineLayoutBase* PipelineBase::GetLayout() const {
|
|
ASSERT(!IsError());
|
|
return mLayout.Get();
|
|
}
|
|
|
|
} // namespace dawn_native
|